diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..9f604ed4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.iml +.classpath +.project +.settings/ +log/ +target/ +.idea/ +eagle.py +.DS_Store +/bin/ +ci.yml \ No newline at end of file diff --git a/README.md b/README.md index e69de29b..4aafbbbb 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,340 @@ +# 概述 + +本文档主要介绍百度云JAVA语言版的开发者工具包(SDK),用户可基于该SDK使用JAVA语言接入百度云的各项产品(详见支持产品列表)。 +SDK封装了便捷的调用接口,保持了多种编程语言版的使用方式、调用接口相似,提供了统一的错误码和返回格式,方便开发者调试。 + +## 安装SDK工具包 + +### 运行环境 + +JAVA SDK可以在Java1.7,Java1.8环境下运行。 + +### 前提条件 + +[**AK/SK**](https://cloud.baidu.com/doc/Reference/s/9jwvz2egb):SDK 认证时必须传入 AK/SK 参数,在[安全认证页面](https://console.bce.baidu.com/iam/#/iam/accesslist) 获取 Access Key和Secret Key。 + +用户可以通过两种方式与百度智能云进行交互,包括认证方式和匿名方式。对于认证方式,需要通过使用Access Key / Secret Key加密的方法来验证某个请求的发送者身份。Access Key(AK) 用于标示用户,Secret Key(SK) 是用户用于加密认证字符串和百度智能云用来验证认证字符串的密钥,其中SK必须保密,只有用户和百度智能云知道。 + +### 安装SDK + +**使用Maven安装** + +在Maven的pom.xml文件中添加bce-java-sdk的依赖: + +```xml + + com.baidubce + bce-java-sdk + {version} + +``` + +**SDK目录结构** + +```text +com.baidubce +├── auth //BCE签名相关类 +├── http //BCE的Http通信相关类 +├── internal //SDK内部类 +├── model //BCE公用model类 +├── services +│ └─ bcc //BCC服务相关类 +│ └─ billing //BILLING服务相关类 +│ └─ bos //BOS服务相关类 +│ └─ cdn //CDN服务相关类 +│ └─ iothub //IOTHUB服务相关类 +│ └─ lss //LSS服务相关类 +│ └─ vpc //VPC服务相关类 +│ └─ ... //其它服务相关类 +├── util //BCE公用工具类 +├── BceClientConfiguration.class //对BCE的HttpClient的配置 +├── BceClientException.class //BCE客户端的异常类 +├── BceServiceException.class //与BCE服务端交互后的异常类 +├── ErrorCode.class //BCE通用的错误码 +└── Region.class //BCE提供服务的区域 +``` + +### 卸载SDK + +预期卸载SDK时,删除下载的源码即可。 + +## 快速开始 + +### 确认Endpoint + +在使用SDK之前,需确认您将接入的百度云产品的Endpoint(服务域名)。以百度云服务器产品为例,可阅读[BCC访问域名](https://cloud.baidu.com/doc/BCC/s/0jwvyo603)的部分,理解Endpoint相关的概念。其他服务类似,需理解并确认对应服务的Endpoint。 + +### 创建Client对象 + +每种具体的服务都有一个`Client`对象,为开发者与对应的服务进行交互封装了一系列易用的方法。 + +### 调用功能接口 + +开发者基于创建的对应服务的`Client`对象,即可调用相应的功能接口,使用百度云产品的功能。 + +### 示例 + +下面以百度云服务器(BCC)为例,给出一个基本的使用示例,详细使用说明请参考各服务的详细说明文档。 + +```java +public class Sample { + public static void main(String[] args) { + String ak = ; // 用户的Access Key ID + String sk = ; // 用户的Secret Access Key + + // 初始化一个BccClient + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + BccClient client = new BccClient(config); + } +} +``` + +在上面代码中,变量`AK`与`SK`是由系统分配给用户的,均为字符串,用于标识用户,为访问BCC做签名验证。 其中`AK`对应控制台中的“Access Key ID”,`SK`对应控制台中的“Access Key Secret”,获取方式请参考《操作指南 [获取ACCESSKEY](https://cloud.baidu.com/doc/Reference/s/9jwvz2egb)》。 + +上面的方式使用默认域名作为BCC的服务地址,如果用户需要自己指定域名,可以通过传入ENDPOINT参数来指定。 + +```java +String ak = ; // 用户的Access Key ID +String sk = ; // 用户的Secret Access Key +String endpoint = ; // 用户自己指定的域名 + +BceClientConfiguration config = new BceClientConfiguration(); +config.setCredentials(new DefaultBceCredentials(ak, sk)); +config.setEndpoint(endpointy); +BccClient client = new BccClient(config); +``` + +> **注意:** ENDPOINT参数只能用指定的包含区域的域名来进行定义,不指定时默认为北京区域`http://bcc.bj.baidubce.com`。百度智能云目前开放了多区域支持,请参考[区域选择说明](https://cloud.baidu.com/doc/Reference/s/2jwvz23xx)。 + +## 配置 + +### 使用HTTPS协议 + +该SDK支持使用HTTPS协议访问百度云的服务产品,您可以通过如下两种方式在BCC Java SDK中使用HTTPS访问BCC服务: + +- 在endpoint中指明https: + +```java +String ak = "ak"; +String sk = "sk"; +BceClientConfiguration config = new BceClientConfiguration(); +config.setCredentials(new DefaultBceCredentials(ak, sk)); +BccClient client = new BccClient(config); +``` + +- 通过调用setProtocol方法设置https协议: + +```java +String endpoint = "bcc.bj.baidubce.com"; // endpoint中不包含protocol +String ak = "ak"; +String sk = "sk"; +BceClientConfiguration config = new BceClientConfiguration(); +config.setCredentials(new DefaultBceCredentials(ak, sk)); +config.setEndpoint(endpoint); +config.setProtocol(Protocol.HTTPS); // 如果不指明, 则使用http +BccClient client = new BccClient(config); +``` + +> 注意:如果在endpoint中指明了protocol, 则endpoint中的生效, 另外单独再调用setProtocol()不起作用。 + +```java +String endpoint = "http://bcc.bj.baidubce.com"; +String ak = "ak"; +String sk = "sk"; +BceClientConfiguration config = new BceClientConfiguration(); +config.setCredentials(new DefaultBceCredentials(ak, sk)); +config.setEndpoint(endpoint); +config.setProtocol(Protocol.HTTPS); // endpoint中已经指明, 此为无效操作, 对http也是如此 +BccClient client = new BccClient(config); +``` + +### 配置BccClient + +如果用户需要配置BccClient的一些细节的参数,可以在构造BccClient的时候传入BceClientConfiguration对象。 BceClientConfiguration是服务的公用配置类,可以为客户端配置代理,最大连接数等参数。 + +### 使用代理 + +下面一段代码可以让客户端使用代理访问BCC服务: + +```java +String ak = ; // 用户的Access Key ID +String sk = ; // 用户的Secret Access Key +String endpoint = ; // 用户自己指定的域名 + +// 创建BceClientConfiguration实例 +BceClientConfiguration config = new BceClientConfiguration(); + +// 配置代理为本地8080端口 +config.setProxyHost("127.0.0.1"); +config.setProxyPort(8080); + +// 创建BCC客户端 +config.setCredentials(new DefaultBceCredentials(ak, sk)); +config.setEndpoint(endpoint); +BccClient client = new BccClient(config); +``` + + + +使用上面的代码段,客户端的所有操作都会通过127.0.0.1地址的8080端口做代理执行。 对于有用户验证的代理,可以通过下面的代码段配置用户名和密码: + +```java +// 创建BceClientConfiguration实例 +BceClientConfiguration config = new BceClientConfiguration(); + +// 配置代理为本地8080端口 +config.setProxyHost("127.0.0.1"); +config.setProxyPort(8080); + +//设置用户名和密码 +config.setProxyUsername(); //用户名 +config.setProxyPassword(); //密码 +``` + +### 设置网络参数 + +用户可以用BceClientConfiguration对基本网络参数进行设置: + +```java +BceClientConfiguration config = new BceClientConfiguration(); + +// 设置HTTP最大连接数为10 +config.setMaxConnections(10); + +// 设置TCP连接超时为5000毫秒 +config.setConnectionTimeout(5000); + +// 设置Socket传输数据超时的时间为2000毫秒 +config.setSocketTimeout(2000); +``` + +**参数说明** + +通过BceClientConfiguration能指定的所有参数如下表所示: + +| 参数 | 说明 | +| --------------------------------------- | ---------------------------------------------- | +| UserAgent用户代理,指HTTP的User-Agent头 | | +| Protocol | 连接协议类型 | +| ProxyDomain | 访问NTLM验证的代理服务器的Windows域名 | +| ProxyHost | 代理服务器主机地址 | +| ProxyPort | 代理服务器端口 | +| ProxyUsername | 代理服务器验证的用户名 | +| ProxyPassword | 代理服务器验证的密码 | +| ProxyPreemptiveAuthenticationEnabled | 是否设置用户代理认证 | +| ProxyWorkstation | NTLM代理服务器的Windows工作站名称 | +| LocalAddress | 本地地址 | +| ConnectionTimeoutInMillis | 建立连接的超时时间(单位:毫秒) | +| SocketTimeoutInMillis | 通过打开的连接传输数据的超时时间(单位:毫秒) | +| MaxConnections | 允许打开的最大HTTP连接数 | +| RetryPolicy | 连接重试策略 | +| SocketBufferSizeInBytes | Socket缓冲区大小 | +| StreamBufferSize | 流文件缓冲区大小 | + +## 错误处理 + +BCC异常提示有如下两种方式: + +| 异常方法 | 说明 | +| ------------------ | ---------- | +| BceClientException | 客户端异常 | +| BceServerException | 服务器异常 | + +用户可以使用try获取某个事件所产生的异常,例如: + +```java +try { + bccClient.listInstances(); +} catch (BceServiceException bce){ + System.out.println(bce.getMessage()); +} catch (BceClientException bce){ + System.out.println(bce.getMessage()); +} +``` + +### SDK日志 + +BCC Java SDK发布版本中增加了logback作为slf4j的实现,如果用户没有自己的实现可以直接用,如果工程中有其他的如log4j则可以替代。 + +### 默认日志 + +如果用户使用默认的logback,则需要配置logback.xml到classpath中。如果没有这个配置文件,日志级别默认为DEBUG。 + +```xml + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + ${LOG_HOME}/BccUnitTest.%d{yyyy-MM-dd}.log + 30 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + + 10MB + + + + + + + + +``` + +### 自有日志模块 + +若用户使用自己的日志实现模块,例如项目依赖于Maven,则可以类似下面的配置到pom.xml中来去除logback。 + +```xml + + + + com.baidubce + bce-java-sdk + ${bce.sdk.version} + + + ch.qos.logback + logback-classic + + + ch.qos.logback + logback-core + + + org.slf4j + jcl-over-slf4j + + + +``` + +## 支持产品列表 + +详见[SDK平台](https://cloud.baidu.com/doc/Developer/index.html) + +## 测试 +参照**快速开始**,使用自己的AK、SK进行调用测试。 + +## 如何贡献 +本项目是维护各产品线提供的SDK集合,需要产品线自行补充完善。 + +流程规范:[Java SDK 管理流程](https://ku.baidu-int.com/knowledge/HFVrC7hq1Q/tQvrZcAEPS/EqUK30nkdR/Tnyc_BAnFAbu9L)。 + +发布登记:[外部发布需求登记](https://ku.baidu-int.com/knowledge/HFVrC7hq1Q/tQvrZcAEPS/EqUK30nkdR/7MLNFoqX8pum-5)。 + +## 讨论 +https://github.com/baidubce/bce-sdk-java/issues + +如流群:7240682 \ No newline at end of file diff --git a/Release Notes.txt b/Release Notes.txt new file mode 100644 index 00000000..36475818 --- /dev/null +++ b/Release Notes.txt @@ -0,0 +1,968 @@ +发行说明:记录每次SDK更新的说明,最新版本的SDK包含以前所有版本的更新内容。 +--------------------------------------------------------------------- +【版本:v0.10.358】 +涉及产品:VPC 新增参数模板、专线网关、安全组、子网等接口;新增CSN带宽包询价接口,更新查询列表、详情等接口出入参字段。 + +【版本:v0.10.357】 +涉及产品:BLB HTTPS监听器支持扩展域名 + +【版本:v0.10.356】 +涉及产品:CDN 域名列表支持IP或域名源站筛选 + +【版本:v0.10.355】 +涉及产品:BOS 新增细粒度权限列表 + +【版本:v0.10.354】 +涉及产品:VOD, 更新媒资任务详情数据结构 + +【版本:v0.10.353】 +涉及产品:VOD 增加拉取上传方法 + +【版本:v0.10.352】 +涉及产品:MCP 多路音频支持音频流pad策略配置 + +【版本:v0.10.351】 +涉及产品:BEC, 更新虚机实例创建变配等接口、新增部署集、虚机镜像相关接口;新增网络部分VPC、子网、安全组、NAT、路由表、ACL相关接口;新增负载均衡applb相关接口。 + +【版本:v0.10.350】 +涉及产品:MCP 支持多路音频混流调节音量 + +【版本:v0.10.349】 +涉及产品:CDN CDN缓存规则设置接口升级 + +【版本:v0.10.348】 +涉及产品:MCP 创建模板和任务新增参数 + +【版本:v0.10.347】 +涉及产品:MCP 创建模板和任务新增参数 + +【版本:v0.10.346】 +涉及产品:BOS 修复文件后缀识别的bug + +【版本:v0.10.345】 +涉及产品:BOS 修复setBucketLifecycle的bug && 新增webp格式自动识别 && 支持多版本功能 && 修改请求默认同步模式 + +【版本:v0.10.344】 +涉及产品:aihc, aihc 新增java sdk + +【版本:v0.10.343】 +涉及产品:MMS, MMS 追加媒资ID字段 + +【版本:v0.10.342】 +涉及产品:vod, vod 新增java sdk + +【版本:v0.10.341】 +涉及产品:Billing, 账单支持查询调减金额 + +【版本:v0.10.340】 +涉及产品:BCC,后转预支持同时开启自动续费 + +【版本:v0.10.339】 +涉及产品:VCA,新增图片摘要分析功能 + +【版本:v0.10.338】 +涉及产品:BOS 修复endpoint设置https的bug && 新增acl支持not ipaddress字段 + +【版本:v0.10.337】 +涉及产品:BCI openApi 查询实例详情和实例列表增加规格信息返回 + +【版本:v0.10.336】 +涉及产品:BCM openApi 新增报警经历相关接口 + +【版本:v0.10.335】 +涉及产品:bcc openApi 查询套餐价格返回折扣价 + +【版本:v0.10.334】 +涉及产品:KAFKA, 新增流控管理相关接口 + +【版本:v0.10.333】 +涉及产品:bbc openApi 虚机列表和虚机详情增加tag信息返回 + +【版本:v0.10.332】 +涉及产品:BOS,修复list bug & 重定向默认开启 + +【版本:v0.10.331】 +涉及产品:billing openApi 增加成本拆分账单查询接口 + +【版本:v0.10.330】 +涉及产品:BOS,修复url生成bug + +【版本:v0.10.329】 +涉及产品:BOS,默认不支持重定向,新增自定义重定向接口 + +【版本:v0.10.328】 +涉及产品:RDS,新增备份管理+日志管理接口 + +【版本:v0.10.327】 +涉及产品:BCM,新增topn+data接口 + +【版本:v0.10.326】 +涉及产品:RDS,新增数据库管理相关接口 + +【版本:v0.10.325】 +涉及产品:RDS,新增账号管理相关接口 + +【版本:v0.10.324】 +涉及产品:BOS,新增文件下载进度条、List文件接口返回额外数据 + +【版本:v0.10.323】 +涉及产品:BCC,新增创建、修改预留实例卷功能相关接口 + +【版本:v0.10.322】 +涉及产品:RDS,新增实例管理相关接口 + +【版本:v0.10.321】 +涉及产品:BCC, 新增ehc集群管理功能 + +【版本:v0.10.320】 +涉及产品:BCC, 套餐列表、实例详情和实例列表新增flavorSubType字段;批量补充和修订SDK;实例详情返回resGroups + +【版本:v0.10.319】 +涉及产品:KAFKA, 新增集群重启、节点重启、获取集群当前Controller、获取集群历史Controller、消息查询、消息发送、产品间转储开关、主题分区和订阅关系概览、消费组订阅关系概览 + +【版本:v0.10.318】 +涉及产品:BCC, BF3网卡支持Jumbo帧 + +【版本:v0.10.317】 +涉及产品:BCC/BBC, 新增域名列表接口 + +【版本:v0.10.316】 +涉及产品:BCC, 新增查询回收站实例列表、查询实例网卡信息、批量转包年包月、变更vpc、查询可变配规格接口,补充查询实例列表、查询实例详情、 +创建CDS磁盘接口参数 + +【版本:v0.10.315】 +涉及产品:VCA, 新增视频分析取消接口 + +【版本:v0.10.314】 +涉及产品:BOS, 新增上传回调功能、补充acl权限列表 + +【版本:v0.10.313】 +涉及产品:TableStorage, 新增实例操作接口 + +【版本:v0.10.312】 +涉及产品:BCC, 新增CDS询价接口、新增创建/删除自动续费规则、instanceModel字段与API打平 + +【版本:v0.10.311】 +涉及产品:BCM, 修复根据部分纬度查询数据存在字段无法直接解析的问题 + +【版本:v0.10.310】 +涉及产品:BOS, 新增用户配置ioThread功能、新增headobject日志优化 + +【版本:v0.10.309】 +涉及产品:BCM, 增加TopN接口 + +【版本:v0.10.308】 +涉及产品:SMS, 增加手机号黑名单所属国家类型 + +【版本:v0.10.307】 +涉及产品:EIP, Eip、EipGroup、EipBp支持标签、资源组 + +【版本:v0.10.306】 +涉及产品:BOS, 兼容没有配置cname的自定义域名 + +【版本:v0.10.305】 +涉及产品:BCC/BBC, 新增预留实例券绑定tag接口 + +【版本:v0.10.304】 +涉及产品:BOS, 上传object接口新增设置acl,修复delete文件夹的bug + +【版本:v0.10.303】 + 涉及产品:EIP, 支持EIP绑定弹性网卡、主网卡辅助IP + +【版本:v0.10.302】 + 涉及产品:BCC 支持预付费批量退订 + +【版本:v0.10.301】 +涉及产品:BCM, 新增批量查询数据接口、新增站点监控管理、报警策略管理、实例组管理、事件监控、应用监控接口 + +【版本:v0.10.300】 +涉及产品:BCC/CDS, 创建BCC/CDS,CDS挂载、扩容接口增加 warningList + +【版本:v0.10.299】 +涉及产品:BCC, 创建CDS盘增加计费方式 + +【版本:v0.10.298】 +涉及产品:通用, jackson、spring-core、logback相关安全漏洞修复及JDK升级为8 + +【版本:v0.10.297】 +涉及产品:BCC, 支持查看实际本地盘容量 + +【版本:v0.10.296】 +涉及产品:EIP, 支持释放EIP时放入回收站 + +【版本:v0.10.295】 +涉及产品:BCC, 新增预付费实例退费接口 + +【版本:v0.10.294】 +涉及产品:KAFKA, 新增集群配置接口,新增集群变更操作,如存储策略设置、KAFKA配置变更、安全组变更,新增一些字段 + +【版本:v0.10.293】 +涉及产品:BOS, 支持crc32c校验,支持层级bucket下deleteDir + +【版本:v0.10.292】 +涉及产品:evs, 解决查询设备或通道的AI分析结果失败的问题 + +【版本:v0.10.291】 +涉及产品:billing openApi 成本分摊账单 增加预留实例券抵扣金额 + +【版本:v0.10.290】 +涉及产品:BCC, 释放实例新增部分请求参数 & 续费接口新增返回订单id和入参增加相关资源续费参数;Image, 查询快照链新增部分请求参数;DeploySet, 创建部署集新增并发数参数; CDS, 查询磁盘信息新增部分返回参数 + +【版本:v0.10.289】 +涉及产品:VPC,SUBNET,ACL,ROUTE,SECURITY GROUP,PEERCONN,ENI,ENDPOINT,HAVIP,IPv6,NAT,VPN,ROUTE,EIP,BLB,CFW,CSN-新增代码示例 + +【版本:v0.10.288】 +涉及产品:CDS, 同步创建磁盘接口新增返回部分磁盘信息 - 信息修复 + +【版本:v0.10.287】 +涉及产品:CDS, 同步创建磁盘接口新增返回部分磁盘信息 + +【版本:v0.10.286】 +涉及产品:通用, 去除兼容性风险依赖 + +【版本:v0.10.285】 +涉及产品:Billing, 订单列表查询支持按来源字段筛选 + +【版本:v0.10.284】 +涉及产品:SMS, 增加业务统计接口 + +【版本:v0.10.283】 +涉及产品:BCC, 新增按照规格查询公共镜像接口 + +【版本:v0.10.282】 +涉及产品:BCC, 新增编辑网卡队列数功能、网卡队列数查询功能, 新增查询密钥对列表接口支持指定密钥对名称 + +【版本:v0.10.281】 +涉及产品:DMP, 新增物模型版本管理相关接口&规则引擎接口新增目的地 + +【版本:v0.10.280】 +涉及产品:BOS, 新增renameObject接口 & 添加请求时带上requestid + +【版本:v0.10.279】 +涉及产品:KAFKA, 首次发布,通过Java SDK操作KAFKA专享版接口。 + +【版本:v0.10.278】 +涉及产品:BOS, 新增bucket回收站接口 + +【版本:v0.10.277】 +涉及产品:TSDB, 解决压缩数据返回异常的问题 + +【版本:v0.10.276】 +涉及产品:Billing, 订单 model 新增应付金额属性 + +【版本:v0.10.275】 +涉及产品:BOS, 新增bucket标签管理接口 + +【版本:v0.10.274】 +涉及产品:DMP, 新增产品仓库自定义模板&协议拓展&边缘网关 sdk + +【版本:v0.10.273】 +涉及产品:SMS, 增加手机号黑名单增、删、查接口 + +【版本:v0.10.272】 +涉及产品:BOS, 新增镜像回源接口 + +【版本:v0.10.271】 +涉及产品:BCI, 更新创建容器实例参数 + +【版本:v0.10.270】 +涉及产品:Local DNS, 内网dns openApi支持java sdk + +【版本:v0.10.269】 +涉及产品:BCC, 新增创建BCC实例时支持传入resGroupId + +【版本:v0.10.268】 +涉及产品:Billing, 订单 model 新增属性 + +【版本:v0.10.267】 +涉及产品:BCI, 更新创建容器实例参数 + +【版本:v0.10.266】 +涉及产品:Billing, 增加资源月账单可展示字段 + +【版本:v0.10.265】 +涉及产品:BOS, 修复Select Object大文件问题 + +【版本:v0.10.264】 +涉及产品:SMS, 修复模板状态字段的校验问题 + +【版本:v0.10.263】 +涉及产品:BCM, 新增推送自定义监控数据API + +【版本:v0.10.262】 +涉及产品:LSS, 更新LSS播放用量带宽、流量查询API + +【版本:v0.10.261】 +涉及产品:LSS, 新增LSS播放用量查询API + +【版本:v0.10.260】 +涉及产品:SMS, 配额频控查询接口新增配额申请信息字段 + +【版本:v0.10.259】 +涉及产品:MMS, 解决删除图片库中图片特征失败问题 + +【版本:v0.10.258】 +涉及产品:BCC, 新增创建BCC实例时传入内网IP + +【版本:v0.10.257】 +涉及产品:DMP, 新增TSDB查询;用户TSDB资源启停用;创建tsdb目的地;根据模板创建产品 + +【版本:v0.10.256】 +涉及产品:BOS, 支持namespace相关接口;修复fetchObject时referer配置 + +【版本:v0.10.255】 +涉及产品:BOS, 新增fetchObject相关参数 + +【版本:v0.10.254】 +涉及产品:BCI, 新增容器实例BCI openApi所有接口 + +【版本:v0.10.253】 +涉及产品:DMP, 新增目的地文件上传接口;evs相关接口返回值修复 + +【版本:v0.10.252】 +涉及产品:BOS, 增加select parquet接口;支持设置bucket tag;修复queryParams未编码问题 + +【版本:v0.10.251】 +涉及产品:TSDB, 增加购买额度校验 + +【版本:v0.10.250】 +涉及产品:TSDB, 管理接口支持新购、续费、升配功能,其中新购时支持自动续费 + +【版本:v0.10.249】 +涉及产品:DMP, 新增运营统计, 资源禁用解绑接口 + +【版本:v0.10.248】 +涉及产品:VCR, 文本审核接口新增位置信息 + +【版本:v0.10.247】 +涉及产品:VPC, 新增弹性网卡ENI接口 + +【版本:v0.10.246】 +涉及产品:DMP, 批量创建设备接口添加参数 + +【版本:v0.10.245】 +涉及产品:Billing, 新增根据 uuid 批量查询订单接口 + +【版本:v0.10.244】 +涉及产品:BOS, 新增音视频处理接口 + +【版本:v0.10.243】 +涉及产品:DMP, 新增实例创建/更新/删除接口 + +【版本:v0.10.242】 +涉及产品:DMP, 告警记录查询接口增加按状态查询 + +【版本:v0.10.241】 +涉及产品:DMP, 获取设备影子属性接口兼容timeStamp + +【版本:v0.10.240】 +涉及产品:BCC, 新增创建虚机自定义数据userData字段 + +【版本:v0.10.239】 +涉及产品:DMP,新增ota固件接口;新增批量操作接口;修复部分接口bug + +【版本:v0.10.238】 +涉及产品:VPC,新增企业安全组接口;nat、对等连接支持tag + +【版本:v0.10.237】 +涉及产品:MCA,新增精彩视频分析接口;为查询视频分析接口结果增加faceUrl/image/subTags/location等字段 + +【版本:v0.10.236】 +涉及产品:CDS, 新增CDS专属集群相关接口 + +【版本:v0.10.235】 +涉及产品:BVW(VideoWorks),快编增加获取单条草稿接口 + +【版本:v0.10.234】 +涉及产品:EVS, 新增创建BVCP空间、绑定BVCP设备接口 + +【版本:v0.10.233】 +涉及产品:Billing,新增资源账单、分摊账单等对账接口;新增资源查询接口 + +版本:v0.10.232】 +涉及产品:Billing,新增订单取消、支付接口; + +版本:v0.10.231】 +涉及产品:MMS,视频入库、搜索接口增加回调参数 + +版本:v0.10.230】 +涉及产品:IAM,虚拟云商平行账号对外接口 + +【版本:v0.10.229】 +涉及产品:DMP,新增网桥服务接口接口,修改获取资源连接信息接口 + +【版本:v0.10.228】 +涉及产品:MCP,新增视频加密密钥接口 + +【版本:v0.10.227】 +涉及产品:BOS, 新增单链接限速配置,默认使用bucket virtual host域名访问 + +【版本:v0.10.226】 +涉及产品:DNS, 新增公网DNS openApi所有接口 + +【版本:v0.10.225】 +涉及产品:BCC, 新增创建虚机隐藏系统盘SN字段 + +【版本:v0.10.224】 +涉及产品:BEC, 新增虚机节点粒度监控接口、模板管理相关接口、为实例组添加实例接口、更新虚机实例变配接口 + +【版本:v0.10.223】 +涉及产品:MMS, 新增查询库列表、查询库媒资列表接口 + +【版本:v0.10.222】 +涉及产品:DMP, 修复部分配置管理接口中使用泛型接收不可用问题 + +【版本:v0.10.221】 +涉及产品:BEC, 更新虚机、监控相关接口 + +【版本:v0.10.220】 +涉及产品:MMS, 新增创建、删除媒资库接口 + +【版本:v0.10.219】 +涉及产品:CFS, 发布java sdk + +【版本:v0.10.218】 +涉及产品:RDS, 修复部分接口 + +【版本:v0.10.217】 +涉及产品:DMP, 新增配置管理、文件上传相关接口 + +【版本:v0.10.216】 +涉及产品:MCA,新增直播分析接口 + +【版本:v0.10.215】 +涉及产品:MCP, 新增音频codec字段 + +【版本:v0.10.214】 +涉及产品:CFW, 新增CFW服务相关接口。 + +【版本:v0.10.213】 +涉及产品:CDN, SDK升级,对齐API官方文档。 + +【版本:v0.10.212】 +涉及产品:BOS, 新增上传进度回调接口;归档取回参数更新。 + +【版本:v0.10.211】 +涉及产品:EVS, 修改查询历史录像等接口 + +【版本:v0.10.210】 +涉及产品:DMP, 新增产品品类、产品仓库、告警中心接口 + +【版本:v0.10.209】 +涉及产品:BMR, 新增cancelStep等接口 + +【版本:v0.10.208】 +涉及产品:DMP, 新增场景联动及订阅接口,修复部分接口 + +【版本:v0.10.207】 +涉及产品:BMR 更新最新的创建集群等接口 + +【版本:v0.10.206】 +涉及产品:TSDB 数据点支持BigDecimal类型 + +【版本:v0.10.205】 +涉及产品:BOS 修复三步上传分块大小限制 + +【版本:v0.10.204】 +涉及产品:BMR 更新为最新的BMR api + +【版本:v0.10.203】 +涉及产品:BOS 修复STS下设置acl的编码问题 + +【版本:v0.10.202】 +涉及产品:EIP 列表查询接口增加 eipId 字段 + +【版本:v0.10.201】 +涉及产品:KMS,新增轮转配置接口 + +【版本:v0.10.200】 +涉及产品:EVS,添加扫码绑定BVCP设备 + +【版本:v0.10.199】 +涉及产品:SCS 创建实例支持设置密码 + +【版本:v0.10.198】 +涉及产品:MMS,根据ID查询任务状态及删除媒资 + +【版本:v0.10.197】 +涉及产品:DMP,设备列表参数修改,修复设备状态接口不可用 + +【版本:v0.10.196】 +涉及产品:BOS,调整三步上传分块大小限制 + +【版本:v0.10.195】 +涉及产品:RDS SDK新增获取慢日志下载任务列表,详情;获取配置参数列表;修改配置参数功能 + +【版本:v0.10.194】 +涉及产品:SCS/RDS SDK新增创建数据库,删除数据库,备份管理 + +【版本:v0.10.193】 +涉及产品:IOTDMP,修复部分接口 + +【版本:v0.10.192】 +涉及产品:SCS/RDS SDK新增可用区列表,子网列表等功能 + +【版本:v0.10.191】 +涉及产品:SCS/RDS SDK新增自动续费等功能 + +【版本:v0.10.190】 +涉及产品:SCS/RDS 新发布SDK,新增实例管理 + +【版本:v0.10.189】 +涉及产品:MCA,新增封面分析、查询接口 + +【版本:v0.10.188】 +涉及产品:IOTDMP,新增接口 + +【版本:v0.10.187】 +涉及产品:BCD,新增namingStatus字段 + +【版本:v0.10.186】 +涉及产品:KMS,新增国密SM1-128、SM2-256、SM4-128的密钥创建,新增SM2-256非对称密钥的导入 + +【版本:v0.10.185】 +涉及产品:EVS,添加空间创建设置计费类型 + +【版本:v0.10.184】 +涉及产品:BLB, 增加应用型BLBIP组接口;创建应用型BLB监听策略接口返回id + +【版本:v0.10.183】 +涉及产品:BVW(VideoWorks),修复素材库截图列表字段名;添加草稿箱sdk + +【版本:v0.10.181】 +涉及产品:BOS,修复软链接编码、分块上传默认content-type问题 + +【版本:v0.10.180】 +涉及产品:IOTDMP,首次发布,可以通过调用API进行设备管理 + +【版本:v0.10.179】 +涉及产品:MCP,Job 查询接口支持输出码率 + +【版本:v0.10.178】 +涉及产品:BVW(VideoWorks),新增打点sdk + +【版本:v0.10.177】 +涉及产品:EVS, 空间查询信息新增serialId、rtcAppId + +【版本:v0.10.176】 +涉及产品:EIP, 提供共享流量包SDK,支持创建、查询详情、查询列表信息功能 + +【版本:v0.10.175】 +涉及产品:BOS,修复默认Endpoint,新增object名限制 + +【版本:v0.10.174】 +涉及产品:LSS,修复getStream接口获取不到streamingStatus的问题 + +【版本:v0.10.173】 +涉及产品:BCD,域名详情接口增加联系人ID字段 + +【版本:v0.10.172】 +涉及产品:BCD,添加接口:域名查询、域名询价、域名注册、域名注册(异步)、域名注册(使用信息模板)、域名注册(使用信息模板)(异步)、域名续费、域名续费(异步)、域名过户(使用信息模板)、订单状态查询 + +【版本:v0.10.171】 +涉及产品: +VPC, 支持查询内网IP信息; +Security Group, 支持删除、更新安全组规则; +NAT,支持绑定、解绑 DNAT EIP,支持创建、删除、更新、查询 SNAT、DNAT 规则 + +【版本:v0.10.170】 +涉及产品:BCD,添加接口:查询域名解析列表、域名过户、修改联系人信息、查询域名实名认证状态、修改DNS信息、查询域名详情、上传域名实名认证 + +【版本:v0.10.169】 +涉及产品:BEC,更新监控接口,新增规格套餐查询接口、独占盘套餐查询接口 + +【版本:v0.10.168】 +涉及产品:BOS,支持sts生成presigned url + +【版本:v0.10.167】 +涉及产品:EVS,修复部分实体私有属性为添加get、set方法 + +【版本:v0.10.166】 +涉及产品:EVS,首次发布,添加空间:创建、启用、停用、查询、修改、删除、列表功能; +添加设备:基础操作、国标通道管理、录像截图、PTZ操作、预置位管理、国标配置功能。 + +【版本:v0.10.165】 +涉及产品:BCD,首次发布,添加模板查询、添加、更新、删除,DNS解析记录的添加、删除、更新。 + +【版本:v0.10.164】 + 涉及产品:BVW,持素材上传/查询/删除,支持预置素材上传/查询/删除 + +【版本:v0.10.163】 +涉及产品:VPC,SUBNET接口支持IPv6 Cidr + +【版本:v0.10.162】 +涉及产品:SUBNET,get接口返回可用ip数 + +【版本:v0.10.161】 +涉及产品:基础包,修复PATCH方法无Content问题。 + +【版本:v0.10.160】 +涉及产品:基础包,增加PATCH方法支持。 + +【版本:v0.10.159】 +涉及产品:MCA,图片分析接口可自定义请求设置title、source、preset。 + +【版本:v0.10.158】 +涉及产品:MCA,支持图片分析。 + +【版本:v0.10.157】 +涉及产品:MCT, 支持MediaInfo获取dar、rotate,Watermark新增参数 + +【版本:v0.10.156】 +涉及产品:IAM, list AccessKey返回上次使用时间 + +【版本:v0.10.155】 +涉及产品:BES, 支持升配集群配置 + +【版本:v0.10.154】 +涉及产品:VOD, 修复统计接口反序列化赋值异常问题 + +【版本:v0.10.153】 +涉及产品:IOTHUB, 新增IoTCore设备和模版相关接口 + +【版本:v0.10.152】 +涉及产品:MCT, 新增转码输出信息到Job查询接口 + +【版本:v0.10.151】 +涉及产品:SMS, 新增签名、模板列表查询接口 + +【版本:v0.10.150】 +涉及产品:MMS, 提供多媒体检索SDK + +【版本:v0.10.149】 +涉及产品:BES,支持创建带有专用master节点的集群 + +【版本:v0.10.148】 +涉及产品:BVW(VideoWorks),字幕转语音结果支持毫秒级别时长 + +【版本:v0.10.147】 +涉及产品:BCM,新增批量获取监控数据接口 + +【版本:v0.10.146】 +涉及产品:BCM,获取监控数据接口 + +【版本:v0.10.145】 +涉及产品:BVW(VideoWorks),智能云编辑SDK支持9:16纵横比编辑合成 + +【版本:v0.10.144】 +涉及产品:BES,支持计算资源和存储资源分离的新套餐 + +【版本:v0.10.143】 +涉及产品:VPN,新增VPN、VPN隧道相关接口 + +【版本:v0.10.142】 +涉及产品:BES,新增续费相关功能和对于自动续费规则的增删改查 + +【版本:v0.10.141】 +涉及产品:MCA,提交视频分析接口增加参数subTitle、category、description。 + +【版本:v0.10.140】 +涉及产品:MCA,提交视频分析接口增加参数priority。 + +【版本:v0.10.139】 +涉及产品:更新BMR + +【版本:v0.10.138】 +涉及产品:MCA,修改ResultItem实体类增加参数version。 + +【版本:v0.10.137】 +涉及产品:CFC,修改invoke函数输入参数payload格式,改为byte[]。 + +【版本:v0.10.136】 +涉及产品:BEC, 首次发布,可以通过调用API创建BEC虚机服务、获取BEC虚机服务列表、更新BEC虚机服务、获取BEC虚机服务详情、 +操作BEC虚机服务、删除BEC虚机服务、获取BEC服务监控;获取BEC虚机列表、获取所在节点的BEC虚机列表、获取BEC虚机详情、删除BEC虚机、 +更新BEC虚机资源、重装BEC虚机系统、操作BEC虚机资源、获取虚机服务监控、获取相同BEC虚机实例配置;创建Blb负载均衡、获取Blb负载均衡列表、 +获取Blb详情、删除指定的Blb、更新指定的Blb、创建BLB监听设置、获取BLB监听设备列表、获取指定BLB指定监听端口的详情、修改BLB监听端口设置、 +获取指定BEC LB后端绑定Pod/VM列表、获取指定BLB可绑定的部署StatefulSet/VmReplicas组、 +获取指定的StatefulSet/VmReplicas后端可绑定的Pod/Vm组、为指定BLB绑定后端StatefulSet/VmReplicas、 +修改指定BLB后端绑定容器组Pod/虚机组Vm的权重、获取BEC BLB 监控;获取用户总体概览信息、获取容器服务概览信息、 +获取虚机服务概览信息、获取容器资源使用量走势、获取虚机资源使用量走势。 + +【版本:v0.10.135】 +涉及产品:BOS,支持获取Bucket或特定前缀下的容量、object数、文件数 + +【版本:v0.10.134】 +涉及产品:BVW(VideoWorks), 支持text2Audio试听,支持Timeline预处理标记参数。 +涉及产品:MCT, 支持MediaInfo毫秒返回值。 + +【版本:v0.10.133】 +涉及产品:BVW(VideoWorks), 支持text2Audio指定bucket。 + +【版本:v0.10.132】 +涉及产品:BILLING,新增用户余额查询接口 + +【版本:v0.10.131】 +涉及产品:BES(百度Elasticsearch), 新增BES集群创建 操作 查询等相关接口。 + +【版本:v0.10.130】 +涉及产品:BVW(VideoWorks), 修改timeline对象。 + +【版本:v0.10.129】 +涉及产品:SHC,新增广播接口,新增token接口,现有product接口增加可选参数asrKafka。 + +【版本:v0.10.128】 +涉及产品:BVW(VideoWorks),新增Timeline对象 + +【版本:v0.10.127】 +涉及产品:BILLING,新增资源账单查询接口 + +【版本:v0.10.126】 +涉及产品:BVW(VideoWorks),支持视频快编合成和查询快编任务状态。 + +【版本:v0.10.125】 +涉及产品:BOS(对象存储),新增支持软链接、多规则replication、取消重定向、归档状态显示等相关接口。 + +【版本:v0.10.124】 +涉及产品:BVW(VideoWorks),支持上传素材和查询素材。 + +【版本:v0.10.123】 +涉及产品:CNAP,支持获取工作空间名称。 + +【版本:v0.10.122】 +涉及产品:DCC,创建DCC自实例新增hostname参数。 + +【版本:v0.10.121】 +涉及产品:BCC,创建BCC新增hostname参数,新增修改hostname接口。 + +【版本:v0.10.120】 +涉及产品:MCT,新增缩略图模板、字幕服务接口,转码、缩略图任务参数更新。 + +【版本:v0.10.119】 +涉及产品:SMS(云短信),新增签名、模板、配额、频控相关接口 + +【版本:v0.10.118】 +涉及产品:BCC,修改VolumeModel参数 + +【版本:v0.10.117】 +涉及产品:BILLING,新增获取财务圈账号现金余额api + +【版本:v0.10.116】 +涉及产品:LSS,支持重置直播流(中断当前直播流并支持立即重推) + +【版本:v0.10.115】 +涉及产品:IAM,首次发布,可以通过API实现多用户访问控制 + +【版本:v0.10.114】 +涉及产品:BCC,新增创建竞价实例、查询竞价实例套餐、查询竞价实例市场价、取消竞价实例订单、查询可关机不可计费的实例列表、重装实例(批量重装)、计费 +变更-转预付费、释放实例(POST请求的释放)、实例变更子网、磁盘开通自动续费、磁盘取消自动续费、磁盘重命名、查询部署集列表、创建部署集、删除部署集、 +修改部署集等接口。 +涉及产品:AS,首次发布,可以通过调用API查询伸缩组列表,查询伸缩组详情,伸缩组扩容,伸缩组缩容,伸缩组节点数量调整,查询伸缩组下节点列表。 + +【版本:v0.10.113】 +涉及产品:EIP, 提供带宽包SDK。 + +【版本:v0.10.112】 +涉及产品:VOD, 修改初始化client方法,提供自定义BosClient设置。 +涉及产品:BVW,增加工作流任务类型。 + +【版本:v0.10.111】 +涉及产品:BOS, 新增SelectObject接口 + +【版本:v0.10.110】 +涉及产品:VCR, 新增获取直播流审核结果、直播流审核任务列表的V2接口 + +【版本:v0.10.109】 +涉及产品:VCR, 新增直播流审核、取消直播流审核的V2接口 + +【版本:v0.10.108】 +涉及产品:BILLING,新增预付费资源自动续费列表查询和自动续费设置API + +【版本:v0.10.107】 +涉及产品:SHC, 首次发布, 可通过SDK调用智能语音服务API。 +涉及产品:TSDB,修复sql查询参数长度问题。 + +【版本:v0.10.106】 +涉及产品:ROS, 新增混合更新接口,新增创建排单排线(V3)接口。 + +【版本:v0.10.105】 +涉及产品:DCC,新增创建专属实例接口,支持对明文密码加密。 + +【版本:v0.10.104】 +涉及产品:Videoworks(VOD2.0),修改处理媒资动态参数 + +【版本:v0.10.103】 +涉及产品:BILLING,新增预付费分摊账单的查询API + +【版本:v0.10.102】 +涉及产品:智能调度排单排线 + +【版本:v0.10.101】 +涉及产品:BILLING,新增主子账号收款、划款, 提供资金往来的查询 + +【版本:v0.10.100】 +涉及产品:ROS快速排单vehicleModelId。 + +【版本:v0.10.99】 +涉及产品:SMS,新增SMS3.0短信发送接口。 + +【版本:v0.10.98】 +涉及产品:BILLING,资源月账单API新增支持按天查询账单。 + +【版本:v0.10.97】 +涉及产品:BCC,新增获取实例套餐规格列表,通过实例套餐规格询价,通过实例套餐规格创建实例接口。 + +【版本:v0.10.96】 +涉及产品:BILLING,订单API新增短ID,shortId。 + +【版本:v0.10.95】 +涉及产品:MCT,MCT对其API功能:新增通知和更新模板队列接口,新增模板、转码任务、缩略图任务参数。 + +【版本:v0.10.94】 +涉及产品:BOS,Bucket Acl支持secureTransport。 + +【版本:v0.10.93】 +涉及产品:BILLING,资源月账单新增折扣用量。 + +【版本:v0.10.92】 +涉及产品:BCC,BCC创建接口增加系统盘参数。 + +【版本:v0.10.91】 +涉及产品:BLB,应用型负载均衡所有接口。 + +【版本:v0.10.90】 +涉及产品:ILS,智能物流调度增加通用的创建任务接口以及请求格式,增加多仓拆单仓的创建任务接口 + +【版本:v0.10.89】 +涉及产品:VCA,支持基于媒资地址和标题进行分析 + +【版本:v0.10.88】 +涉及产品:LPS,支持路网任务的时间查询 + +【版本:v0.10.87】 +涉及产品:CNAP,支持工作空间管理、环境管理、集群管理、仓库管理、镜像管理、访问方式管理、应用管理、部署组管理、发布记录管理、报警管理。 + +【版本:v0.10.86】 +涉及产品:ILS,智能物流调度支持创建排单排线增加vehicleSkills,补充修改。 + +【版本:v0.10.85】 +涉及产品:LPS,物流地图增加私有路线上传、列表及删除接口。 + +【版本:v0.10.84】 +涉及产品:ILS,智能物流调度支持创建排单排线增加vehicleSkills。 + +【版本:v0.10.83】 +涉及产品:ILS,智能物流调度支持创建排单排线分区。 + +【版本:v0.10.82】 +涉及产品:BOS,新增支持三步上传封装、服务端加密、静态网站托管、原图保护功能。 + +【版本:v0.10.81】 +涉及产品:Videoworks(VOD2.0),新增通知验证功能和工作流不转码功能节点。 + +【版本:v0.10.80】 +涉及产品:DUMAP,修复了智能硬件定位的请求问题。 + +【版本:v0.10.79】 +涉及产品:ILS, 智能物流调度支持创建多仓排单排线任务。 + +【版本:v0.10.78】 +涉及产品:TableStorage, 新增支持数据多版本功能。 +涉及产品:LPS, 物流地图路线规划服务支持途经点输入。 + +【版本:v0.10.77】 +涉及产品:ILS, 智能物流调度支持创建路网设置网点名称 + +【版本:v0.10.76】 +涉及产品:BOS, 支持归档存储 + +【版本:v0.10.75】 +涉及产品:ILS, 智能物流调度支持创建路网的时候设置名称 + +【版本:v0.10.74】 +涉及产品:LSS, 新增正在直播中流列表的查询接口。 +涉及产品:TableStorage,新增支持SATA容量型。 + +【版本:v0.10.73】 +涉及产品:CAS,新增查询详情,改名,替换,删除接口。 + +【版本:v0.10.72】 +涉及产品:LSS,新增录制裁剪接口。 + +【版本:v0.10.71】 +涉及产品:BILLING,新增订单列表查询接口,新增按量付费产品价格查询接口,新增按时长付费产品价格查询接口。 + +【版本:v0.10.70】 +涉及产品:CFC, invoke函数时,解析函数执行结果时指定编码格式为utf8。 +涉及产品:TSDB, 增加数据查询接口对offset的支持。 +涉及产品:Videoworks(VOD2.0)。首次发布,提供Videoworks服务的媒资、工作流、工作流运行实例和任务、通知等操作的接口。 + +【版本:v0.10.69】 +涉及产品:VCR,新增音频审核接口,增加异步图审接口中description字段,废弃直播审核接口。 + +【版本:v0.10.68】 +涉及产品:TableStorage,ttl最小值改为23小时,BufferedMutator在close前先进行flush操作。 +涉及产品:DuGo,增加车载视频监控相关接口。 + +【版本:v0.10.67】 +涉及产品:DUMAP,修复了骑行路线规划和驾车路线规划的路径问题。 + +【版本:v0.10.66】 +涉及产品:TSDB:新增升配和和续费功能。 + +【版本:v0.10.65】 +涉及产品:ILS:物流大脑。快速排单增加V2版本结果查询接口,新增maxVisited参数限制。 + +【版本:v0.10.64】 +涉及产品:VOD,支持音频,字幕等合成功能。 +涉及产品:HISK,新增设备端安全SDK,包括获取设备ID,获取激活数据,加密和解密等功能。 + +【版本:v0.10.63】 +涉及产品:BILLING,首次发布,交易系统支持资源月账单查询功能。 + +【版本:v0.10.62】 +涉及产品:ILS:物流大脑。首次发布,可通过SDK调用物流大脑的路网矩阵、排单排线、快速排单等功能。 + +【版本:v0.10.61】 +涉及产品:TableStorage,发布TableStorage HBaseClient,提供与HBaseClient兼容的接口。 +涉及产品:BMR,增加了新套餐的支持 +涉及产品:VMS(Voice Message Service)。首次发布语音通知产品的SDK,新增语音通知产品的 发起呼叫 相关的接口。 +涉及产品:CFC(Cloud Function Compute)。首次发布,通过Java SDK调用CFC相关接口。 +注意:由于新版本依赖了1.2.0版本的HBaseClient,而此依赖要求的JDK版本为1.7,因此bce-java-sdk自此版本开始,要求的JDK版本为1.7或1.8。 + +【版本:v0.10.58】 +涉及产品:TableStorage,首次发布,支持表格和数据操作。 + +【版本:v0.10.55】 +涉及产品:LPS,首次发布,物流路线规划和物流批量算路功能。 + +【版本:v0.10.52】 +涉及产品:BCC,新增自动快照策略、密钥对相关操作;优化多个接口。 +涉及产品:DuGo,SDK改为默认使用HTTPS协议。 +涉及产品:TSDB,优化创建接口、获取db信息接口的字段。 + +【版本:v0.10.49】 +涉及产品:VCR,VCR Client新增了“自定义库”相关接口。 + +【版本:v0.10.48】 +涉及产品:BMR,添加集群高可用和安全模式支持。 + +【版本:v0.10.46】 +涉及产品:DuMap,新增普通IP定位服务,智能定位服务。 + +【版本:v0.10.41】 +涉及产品:KMS,首次发布,通过Java SDK操作KMS。 + +【版本:v0.10.36】 +涉及产品:BOS,新增判断对象是否存在接口。 + +【版本:v0.10.28】 +涉及产品:MCT,支持多视频合并;转码、缩略图服务去水印等。 + +【版本:v0.10.22】 +涉及产品:LSS,新增统计stream实时观看人数和带宽功能。 + +【版本:v0.10.21】 +涉及产品:物接入(设备型),新增创建设备、获取设备Profile、查询设备等功能。 + +【版本:v0.10.16】 +涉及产品:VOD,支持音视频点播服务,包括媒资管理、播放器管理、日志管理等。 +涉及产品:DOC,文档服务 DOC 支持文档服务,包括文档处理、文档通知、文档日志等。 + +【版本:v0.10.13】 +涉及产品:BMR,添加集群高可用和安全模式支持。 + +【版本:v0.10.12】 +涉及产品:Rule Engine,首次发布。 + +【版本:v0.10.11】 +涉及产品:SMS,更新创建模板接口,使用v2版本API。 diff --git a/pom.xml b/pom.xml index bd7dc87c..ee921ab5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidubce bce-java-sdk - 0.10.17 + 0.10.358 bce-sdk-java The BCE SDK for Java provides Java APIs for all of BCE services. http://bce.baidu.com/sdk/index.html @@ -38,18 +38,30 @@ UTF-8 UTF-8 1.7.7 - 1.1.2 + 1.4.14 1.9 2.4 17.0 4.0.2 - 2.1.1 + 2.13.5 2.3 4.11 1.3 + 3.5 + 1.18.2 + 1.2.1 + 1.2.0 + 1.59 + 8.4.5 + 5.3.32 + + org.apache.commons + commons-lang3 + ${commons-lang3-version} + org.slf4j slf4j-api @@ -95,7 +107,7 @@ com.fasterxml.jackson.core jackson-core - ${jackson.version} + 2.12.7 com.fasterxml.jackson.core @@ -105,7 +117,7 @@ com.fasterxml.jackson.core jackson-annotations - ${jackson.version} + 2.12.7 joda-time @@ -130,18 +142,73 @@ 2.5.2 test - + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + ${mqttv3.version} + + + javax.validation + validation-api + 1.1.0.Final + + + org.springframework + spring-core + ${spring-core.version} + + + org.apache.hbase + hbase-client + ${hbase-client.version} + + + org.bouncycastle + bcprov-jdk15on + ${bouncycastle.version} + + + org.mockito + mockito-all + 1.9.5 + test + + + org.jacoco + jacoco-maven-plugin + 0.7.9 + + + + prepare-agent + + + + generate-code-coverage-report + test + + report + + + + org.apache.maven.plugins maven-compiler-plugin 2.3 - 1.6 - 1.6 + 1.8 + 1.8 UTF-8 @@ -202,42 +269,43 @@ xml + - - - publishing - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - + + + publishing + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.5.1 - true - - sonatype-nexus-staging - https://oss.sonatype.org - - - - - + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.5.1 + true + + sonatype-nexus-staging + https://oss.sonatype.org + + + + + diff --git a/src/main/java/com/baidubce/AbstractBceClient.java b/src/main/java/com/baidubce/AbstractBceClient.java old mode 100644 new mode 100755 index c8065049..d054b84c --- a/src/main/java/com/baidubce/AbstractBceClient.java +++ b/src/main/java/com/baidubce/AbstractBceClient.java @@ -25,14 +25,13 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Date; +import java.util.concurrent.ConcurrentHashMap; /** * Abstract base class for BCE service clients. - * *

* Responsible for basic client capabilities that are the same across all BCE SDK Java clients * (ex: setting the client endpoint). - * *

* Subclass names should be in the form of "com.baidubce.services.xxx.XxxClient", while "xxx" is the service ID and * "Xxx" is the capitalized service ID. @@ -69,6 +68,11 @@ public abstract class AbstractBceClient { */ private URI endpoint; + /** + * The bucket virtual hosting(bucket..bcebos.com) endpoint URI for the service. + */ + private ConcurrentHashMap bktVirEndpoint = new ConcurrentHashMap(); + /** * Responsible for sending HTTP requests to services. */ @@ -88,21 +92,20 @@ public abstract class AbstractBceClient { /** * Constructs a new AbstractBceClient with the specified client configuration and handlers. - * *

* The constructor will extract serviceId from the class name automatically. * And if there is no endpoint specified in the client configuration, the constructor will create a default one. * - * @param config the client configuration. The constructor makes a copy of this parameter so that it is - * safe to change the configuration after then. - * @param responseHandlers a list of handlers for processing HTTP responses from services. See - * {@link com.baidubce.http.BceHttpClient#execute(InternalRequest, Class, HttpResponseHandler[])} + * @param config the client configuration. The constructor makes a copy of this parameter so that it is + * safe to change the configuration after then. + * @param responseHandlers a list of handlers for processing HTTP responses from services. See + * {@link com.baidubce.http.BceHttpClient#execute(InternalRequest, Class, HttpResponseHandler[])} * @param isHttpAsyncPutEnabled whether or not PUT method use Async manner. - * @throws IllegalStateException if the class name does not follow the naming convention for BCE clients. + * @throws IllegalStateException if the class name does not follow the naming convention for BCE clients. * @throws IllegalArgumentException if the endpoint specified in the client configuration is not a valid URI. */ - public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers, - boolean isHttpAsyncPutEnabled) { + public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers, + boolean isHttpAsyncPutEnabled) { this.serviceId = this.computeServiceId(); this.config = config; this.endpoint = this.computeEndpoint(); @@ -111,7 +114,14 @@ public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] re } /** - * constructor with isHttpAsyncPutEnabled default value : false + * Equivalent to AbstractBceClient(config, responseHandlers, false) + * + * @param config the client configuration. The constructor makes a copy of this parameter so that it is + * safe to change the configuration after then. + * @param responseHandlers a list of handlers for processing HTTP responses from services. See + * {@link com.baidubce.http.BceHttpClient#execute(InternalRequest, Class, HttpResponseHandler[])} + * @throws IllegalStateException if the class name does not follow the naming convention for BCE clients. + * @throws IllegalArgumentException if the endpoint specified in the client configuration is not a valid URI. */ public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers) { this(config, responseHandlers, false); @@ -119,7 +129,6 @@ public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] re /** * Returns true if the target service supports regions. - * *

* The result will impact the construction of default service endpoint. * @@ -157,7 +166,6 @@ public void setClient(BceHttpClient client) { /** * Shuts down the client and releases all underlying resources. - * *

* Invoking this method is NOT a must. Once it is called, no subsequent requests should be made. */ @@ -167,12 +175,12 @@ public void shutdown() { /** * Subclasses should invoke this method for sending request to the target service. - * *

* This method will add "Content-Type" and "Date" to headers with default values if not present. * - * @param request the request to build up the HTTP request. + * @param request the request to build up the HTTP request. * @param responseClass the response class. + * @param the type of response * @return the final response object. */ protected T invokeHttpClient(InternalRequest request, Class responseClass) { @@ -189,7 +197,6 @@ protected T invokeHttpClient(InternalRequest req /** * Returns the service ID based on the actual class name. - * *

* The class name should be in the form of "com.baidubce.services.xxx.XxxClient", * while "xxx" is the service ID and @@ -198,7 +205,7 @@ protected T invokeHttpClient(InternalRequest req * @return the computed service ID. * @throws IllegalStateException if the class name does not follow the naming convention for BCE clients. */ - private String computeServiceId() { + public String computeServiceId() { String packageName = this.getClass().getPackage().getName(); String prefix = AbstractBceClient.class.getPackage().getName() + ".services."; if (!packageName.startsWith(prefix)) { @@ -206,6 +213,10 @@ private String computeServiceId() { + "'" + prefix + "' expected"); } String serviceId = packageName.substring(prefix.length()); + // Compatible with v2 version sdk. + if (serviceId.endsWith(".v2")) { + serviceId = serviceId.substring(0, serviceId.length() - 3); + } if (serviceId.indexOf('.') != -1) { throw new IllegalStateException("The client class should be put in package like " + prefix + "XXX"); } @@ -213,9 +224,9 @@ private String computeServiceId() { String expectedClassName = packageName + '.' + Character.toUpperCase(serviceId.charAt(0)) + serviceId.substring(1) + "Client"; /** - * Comment out this verification for media services, since media service is a suit of + * Comment out this verification for media services, since media service is a suit of * services, the media package contains multiple Client classes. - * + * */ // if (!className.equals(expectedClassName)) { // throw new IllegalStateException("Invalid class name " @@ -226,7 +237,6 @@ private String computeServiceId() { /** * Returns the default target service endpoint. - * *

* The endpoint will be in the form of "http(s)://[.].baidubce.com". * @@ -251,4 +261,53 @@ private URI computeEndpoint() { throw new IllegalArgumentException("Invalid endpoint." + endpoint, e); } } + + /** + * Returns the service endpoint(bucket virtual hosting) to which this client will send requests. + * + * @return the service endpoint(bucket virtual hosting) to which this client will send requests. + */ + public URI getBktVirEndpoint(String bucketName) { + if (!bktVirEndpoint.isEmpty() && bktVirEndpoint.containsKey(bucketName)) { + return bktVirEndpoint.get(bucketName); + } + return null; + } + + /** + * BOS + *

+ * Returns the bucket virtual hosting service endpoint. + *

+ * The endpoint will be in the form of "http(s)://[.].bcebos.com". + * + * @return the computed service endpoint + * @throws IllegalArgumentException if the endpoint specified in the client configuration is not a valid URI. + */ + public void computeBktVirEndpoint(String bucketName) { + if (bucketName == null || bucketName.isEmpty()) { + return; + } + String host = this.endpoint.getHost(); + String protocol = this.endpoint.getScheme(); + + String uri = null; + if (!host.contains("bcebos.com") && !host.contains("baidu-int.com")) { + // this means host is diy, and should not compute virtual host + return; + } + if (host.startsWith(bucketName) && host.split("\\.").length >= 4) { + uri = protocol + "://" + host; + } else { + uri = protocol + "://" + bucketName + '.' + host; + } + try { + if (uri != null) { + this.bktVirEndpoint.put(bucketName, new URI(uri)); + } + } catch (URISyntaxException e) { + // only if the endpoint specified in the client configuration is not a valid URI, which is not expected. + throw new IllegalArgumentException("Invalid endpoint." + endpoint, e); + } + } } diff --git a/src/main/java/com/baidubce/BceClientConfiguration.java b/src/main/java/com/baidubce/BceClientConfiguration.java old mode 100644 new mode 100755 index e100b41e..e211bad5 --- a/src/main/java/com/baidubce/BceClientConfiguration.java +++ b/src/main/java/com/baidubce/BceClientConfiguration.java @@ -22,8 +22,6 @@ import org.apache.http.annotation.NotThreadSafe; import java.net.InetAddress; -import java.net.MalformedURLException; -import java.net.URL; /** * Basic client configurations for BCE clients. @@ -157,6 +155,19 @@ public class BceClientConfiguration { */ private BceCredentials credentials = null; + /** + * determines whether redirects should be handled automatically + * + * @return + */ + private boolean redirectsEnabled = true; + + /** + * defalut io thread count + * + */ + private int ioThreadCount = Runtime.getRuntime().availableProcessors(); + // Initialize DEFAULT_USER_AGENT static { String language = System.getProperty("user.language"); @@ -168,10 +179,10 @@ public class BceClientConfiguration { region = ""; } DEFAULT_USER_AGENT = Joiner.on('/').join("bce-sdk-java", BceConstants.VERSION, System.getProperty("os.name"), - System.getProperty("os.version"), - System.getProperty("java.vm.name"), - System.getProperty("java.vm.version"), - System.getProperty("java.version"), language, region) + System.getProperty("os.version"), + System.getProperty("java.vm.name"), + System.getProperty("java.vm.version"), + System.getProperty("java.version"), language, region) .replace(' ', '_'); } @@ -189,6 +200,7 @@ public BceClientConfiguration() { public BceClientConfiguration(BceClientConfiguration other) { this.connectionTimeoutInMillis = other.connectionTimeoutInMillis; this.maxConnections = other.maxConnections; + this.ioThreadCount = other.ioThreadCount; this.retryPolicy = other.retryPolicy; this.localAddress = other.localAddress; this.protocol = other.protocol; @@ -205,6 +217,7 @@ public BceClientConfiguration(BceClientConfiguration other) { this.endpoint = other.endpoint; this.region = other.region; this.credentials = other.credentials; + this.redirectsEnabled = other.redirectsEnabled; } /** @@ -212,12 +225,14 @@ public BceClientConfiguration(BceClientConfiguration other) { * This constructor is used to create a client configuration from one SDK to another SDK. e.g. from VOD to BOS. * In this case endpoint should be changed while other attributes keep same. * - * @param other the configuration to copy settings from. + * @param other the configuration to copy settings from. + * @param endpoint the endpoint */ public BceClientConfiguration(BceClientConfiguration other, String endpoint) { this.endpoint = endpoint; this.connectionTimeoutInMillis = other.connectionTimeoutInMillis; this.maxConnections = other.maxConnections; + this.ioThreadCount = other.ioThreadCount; this.retryPolicy = other.retryPolicy; this.localAddress = other.localAddress; this.protocol = other.protocol; @@ -233,6 +248,7 @@ public BceClientConfiguration(BceClientConfiguration other, String endpoint) { this.socketBufferSizeInBytes = other.socketBufferSizeInBytes; this.region = other.region; this.credentials = other.credentials; + this.redirectsEnabled = other.redirectsEnabled; } /** @@ -297,6 +313,38 @@ public BceClientConfiguration withMaxConnections(int maxConnections) { return this; } + /** + * Returns the maximum number of io thread. + * + * @return the maximum number of io thread. + */ + public int getIoThreadCount() { + return this.ioThreadCount; + } + + /** + * Sets the maximum number of open io thread. + * + * @param ioThreadCount the maximum number of open HTTP connections. + * @throws IllegalArgumentException if ioThreadCount is negative. + */ + public void setIoThreadCount(int ioThreadCount) { + checkArgument(ioThreadCount >= 0, "ioThreadCount should not be negative."); + this.ioThreadCount = ioThreadCount; + } + + /** + * Sets the maximum number of io thread, and returns the updated configuration instance. + * + * @param ioThreadCount the maximum number of io thread. + * @return the updated configuration instance. + * @throws IllegalArgumentException if ioThreadCount is negative. + */ + public BceClientConfiguration withIoThreadCount(int ioThreadCount) { + this.setIoThreadCount(ioThreadCount); + return this; + } + /** * Returns the User-Agent header value to use when sending requests to BCE services. * @@ -308,7 +356,6 @@ public String getUserAgent() { /** * Sets the User-Agent header value to use when sending requests to BCE services. - * *

* If the specified value is null, DEFAULT_USER_AGENT is used. If the specified value does not end with * DEFAULT_USER_AGENT, DEFAULT_USER_AGENT is appended. @@ -328,7 +375,6 @@ public void setUserAgent(String userAgent) { /** * Sets the User-Agent header value to use when sending requests to BCE services, and returns the updated * configuration instance. - * *

* If the specified value is null, DEFAULT_USER_AGENT is used. If the specified value does not end with * DEFAULT_USER_AGENT, DEFAULT_USER_AGENT is appended. @@ -371,6 +417,36 @@ public BceClientConfiguration withLocalAddress(InetAddress localAddress) { return this; } + + /** + * Gets the flag of http redirection + * + * @return + */ + public boolean isRedirectsEnabled() { + return redirectsEnabled; + } + + /** + * Sets the flag of http redirection + * + * @param redirectsEnabled + */ + public void setRedirectsEnabled(boolean redirectsEnabled) { + this.redirectsEnabled = redirectsEnabled; + } + + /** + * Sets the flag of http redirection + * + * @param redirectsEnabled + * @return the updated configuration instance. + */ + public BceClientConfiguration withRedirectsEnabled(boolean redirectsEnabled) { + this.setRedirectsEnabled(redirectsEnabled); + return this; + } + /** * Returns the optional proxy host the client will connect through. * @@ -382,7 +458,6 @@ public String getProxyHost() { /** * Sets the optional proxy host the client will connect through. - * *

* The client will connect through the proxy only if the host is not null and the port is positive. * @@ -394,7 +469,6 @@ public void setProxyHost(String proxyHost) { /** * Sets the optional proxy host the client will connect through, and returns the updated configuration instance. - * *

* The client will connect through the proxy only if the host is not null and the port is positive. * @@ -417,7 +491,6 @@ public int getProxyPort() { /** * Sets the optional proxy port the client will connect through. - * *

* The client will connect through the proxy only if the host is not null and the port is positive. * @@ -429,7 +502,6 @@ public void setProxyPort(int proxyPort) { /** * Sets the optional proxy port the client will connect through, and returns the updated configuration instance. - * *

* The client will connect through the proxy only if the host is not null and the port is positive. * @@ -782,7 +854,6 @@ public Region getRegion() { /** * Sets the region of service. This value is used by the client to construct the endpoint URL automatically, and is * ignored if endpoint is not null. - * *

* If the specified region is null, sets to DEFAULT_REGION. * @@ -795,7 +866,6 @@ public void setRegion(Region region) { /** * Sets the region of service, and returns the updated configuration instance. This value is used by the client to * construct the endpoint URL automatically, and is ignored if endpoint is not null. - * *

* If the specified region is null, sets to DEFAULT_REGION. * @@ -846,15 +916,16 @@ public String toString() { + ", \n retryPolicy=" + retryPolicy + ", \n localAddress=" + localAddress + ", \n protocol=" + protocol + ", \n proxyHost=" + proxyHost + ", \n proxyPort=" + proxyPort + ", \n proxyUsername=" - + proxyUsername + ", \n proxyPassword=" + proxyPassword + + proxyUsername + ", \n proxyPassword=******" + ", \n proxyDomain=" + proxyDomain + ", \n proxyWorkstation=" + proxyWorkstation + ", \n proxyPreemptiveAuthenticationEnabled=" + proxyPreemptiveAuthenticationEnabled + ", \n maxConnections=" - + maxConnections + ", \n socketTimeoutInMillis=" + + maxConnections + ", \n ioThreadCount=" + + ioThreadCount + ", \n socketTimeoutInMillis=" + socketTimeoutInMillis + ", \n connectionTimeoutInMillis=" + connectionTimeoutInMillis + ", \n socketBufferSizeInBytes=" + socketBufferSizeInBytes + ", \n endpoint=" + endpoint + ", \n region=" + region + ", \n credentials=" + credentials + "]\n"; } - + } \ No newline at end of file diff --git a/src/main/java/com/baidubce/BceConstants.java b/src/main/java/com/baidubce/BceConstants.java index 021c5b8d..ea93ffb2 100644 --- a/src/main/java/com/baidubce/BceConstants.java +++ b/src/main/java/com/baidubce/BceConstants.java @@ -16,5 +16,8 @@ * Common constants used by the whole SDK. */ public class BceConstants { - public static final String VERSION = "0.10.17"; + public static final String VERSION = "0.10.355"; + + public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + public static final String DEFAULT_TIME_ZONE = "UTC"; } diff --git a/src/main/java/com/baidubce/BceResponseMetadata.java b/src/main/java/com/baidubce/BceResponseMetadata.java index c9ae84b6..56b650b5 100644 --- a/src/main/java/com/baidubce/BceResponseMetadata.java +++ b/src/main/java/com/baidubce/BceResponseMetadata.java @@ -12,12 +12,13 @@ */ package com.baidubce; +import java.io.Serializable; import java.util.Date; /** * Represents additional metadata included with a response from BCE. */ -public class BceResponseMetadata { +public class BceResponseMetadata implements Serializable { private String bceRequestId; private String bceContentSha256; @@ -48,6 +49,18 @@ public class BceResponseMetadata { private String location; + private String bucketType; + + public String getSymlinkTarget() { + return symlinkTarget; + } + + public void setSymlinkTarget(String symlinkTarget) { + this.symlinkTarget = symlinkTarget; + } + + private String symlinkTarget; + public String getBceRequestId() { return this.bceRequestId; } @@ -168,6 +181,14 @@ public void setTransferEncoding(String transferEncoding) { this.transferEncoding = transferEncoding; } + public String getBucketType() { + return bucketType; + } + + public void setBucketType(String bucketType) { + this.bucketType = bucketType; + } + @Override public String toString() { return "BceResponseMetadata [\n bceRequestId=" + bceRequestId diff --git a/src/main/java/com/baidubce/auth/BceV1Signer.java b/src/main/java/com/baidubce/auth/BceV1Signer.java index 55919331..14116c0a 100644 --- a/src/main/java/com/baidubce/auth/BceV1Signer.java +++ b/src/main/java/com/baidubce/auth/BceV1Signer.java @@ -98,7 +98,12 @@ public void sign(InternalRequest request, BceCredentials credentials, SignOption request.addHeader(Headers.HOST, HttpUtils.generateHostHeader(request.getUri())); if (credentials instanceof BceSessionCredentials) { - request.addHeader(Headers.BCE_SECURITY_TOKEN, ((BceSessionCredentials) credentials).getSessionToken()); + if (options.getUseStsHeader()) { + request.addHeader(Headers.BCE_SECURITY_TOKEN, ((BceSessionCredentials) credentials).getSessionToken()); + } else { + request.addParameter(Headers.BCE_SECURITY_TOKEN, + ((BceSessionCredentials) credentials).getSessionToken()); + } } Date timestamp = options.getTimestamp(); diff --git a/src/main/java/com/baidubce/auth/SignOptions.java b/src/main/java/com/baidubce/auth/SignOptions.java old mode 100644 new mode 100755 index aa722819..232e8cc3 --- a/src/main/java/com/baidubce/auth/SignOptions.java +++ b/src/main/java/com/baidubce/auth/SignOptions.java @@ -15,14 +15,14 @@ import static com.google.common.base.Preconditions.checkArgument; import java.util.Date; +import java.util.HashSet; import java.util.Set; /** * Options for signing the request. - * *

* There are 3 options available: - * + *
* * * @@ -49,7 +49,6 @@ * * - * * *
OptionDescriptionThe time until the signature will expire, which starts from the timestamp. By default, it is set to 1800 (half an * hour).
*/ public class SignOptions { @@ -81,6 +80,11 @@ public class SignOptions { */ private int expirationInSeconds = DEFAULT_EXPIRATION_IN_SECONDS; + /** + * The set of headers to be signed. + */ + private Boolean useStsHeader = true; + /** * Returns the set of headers to be signed. * @@ -99,6 +103,18 @@ public void setHeadersToSign(Set headersToSign) { this.headersToSign = headersToSign; } + /** + * Add the key of headers to be signed. + * + * @param headerKey the key of headers to be signed. + */ + public void addHeadersToSign(String headerKey) { + if (this.headersToSign == null) { + headersToSign = new HashSet(); + } + headersToSign.add(headerKey); + } + /** * Returns the time when the signature was created. * @@ -130,17 +146,34 @@ public int getExpirationInSeconds() { * Sets the time until the signature will expire. * * @param expirationInSeconds The time until the signature will expire. - * */ public void setExpirationInSeconds(int expirationInSeconds) { this.expirationInSeconds = expirationInSeconds; } + /** + * Get the options of whether add header(x-bce-security-token) + * + * @return The set of headers to be signed. + */ + public Boolean getUseStsHeader() { + return useStsHeader; + } + + /** + * Set stsHeader options + * + * @param useStsHeader The set of headers to be signed. + */ + public void setUseStsHeader(Boolean useStsHeader) { + this.useStsHeader = useStsHeader; + } + @Override public String toString() { return "SignOptions [\n headersToSign=" + headersToSign + ",\n timestamp=" + timestamp + ",\n expirationInSeconds=" + expirationInSeconds + "]"; } - + } diff --git a/src/main/java/com/baidubce/auth/Signature.java b/src/main/java/com/baidubce/auth/Signature.java new file mode 100644 index 00000000..e6940fc2 --- /dev/null +++ b/src/main/java/com/baidubce/auth/Signature.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2020 Baidu. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.auth; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.Map; +import java.util.TimeZone; +import java.util.TreeSet; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baidubce.BceConstants; +import com.baidubce.http.Headers; +import com.baidubce.internal.BaseRequest; +import com.baidubce.internal.InternalRequest; + +/** + * The V1 implementation of Signature verification with the BCE signing protocol. + * + * @author chenjiayi05 + * @date 2020/04/28 + */ +public class Signature { + private static final Logger LOGGER = LoggerFactory.getLogger(Signature.class); + + private static final String AUTH_PREFIX = "bce-auth-v1"; + + /** + * verify the signature with default auth header + * + * @param baseRequest origin request info + * @param credentials identity + * @return result + */ + public boolean verify(BaseRequest baseRequest, BceCredentials credentials) { + return verify(baseRequest, credentials, Headers.AUTHORIZATION); + } + + /** + * verify the signature + * + * @param baseRequest origin request info + * @param credentials identity + * @param authHeader auth header + * @return result + */ + public boolean verify(BaseRequest baseRequest, BceCredentials credentials, String authHeader) { + if (baseRequest == null || credentials == null || authHeader == null) { + return false; + } + Map headers = baseRequest.getHeaders(); + if (headers == null || headers.get(Headers.HOST) == null && headers.get(Headers.HOST.toLowerCase()) == null) { + return false; + } + + // format: auth_prefix/ak/timestamp/expirationPeriodInSeconds/signedHeaders/signature + String authString = headers.get(authHeader); + if (authString == null) { + // compatibility mode + for (Map.Entry header : headers.entrySet()) { + if (header.getKey().equalsIgnoreCase(authHeader)) { + authString = header.getValue(); + break; + } + } + } + if (authString == null) { + return false; + } + + // verify length + String[] parts = authString.split("/", 6); + if (parts.length != 6) { + return false; + } + + // verify auth_prefix + if (!parts[0].equals(AUTH_PREFIX)) { + return false; + } + + // verify ak + String accessKey = parts[1]; + if (!accessKey.equals(credentials.getAccessKeyId())) { + return false; + } + + // extract timestamp + Date date; + SimpleDateFormat format = new SimpleDateFormat(BceConstants.DEFAULT_DATETIME_FORMAT); + format.setTimeZone(TimeZone.getTimeZone(BceConstants.DEFAULT_TIME_ZONE)); + try { + date = format.parse(parts[2]); + } catch (ParseException e) { + LOGGER.error("parse timestamp error."); + return false; + } + SignOptions options = new SignOptions(); + options.setTimestamp(date); + + // extract expirationPeriodInSeconds + options.setExpirationInSeconds(Integer.parseInt(parts[3])); + + // extract signedHeaders + if (StringUtils.isEmpty(parts[4])) { + // default signature + options = SignOptions.DEFAULT; + options.setTimestamp(date); + } else { + String[] signedHeaders = parts[4].split(";"); + options.setHeadersToSign(new TreeSet(Arrays.asList(signedHeaders))); + } + + // verify signature + InternalRequest request = BaseRequest.toInternalRequest(baseRequest); + BceV1Signer signer = new BceV1Signer(); + request.setSignOptions(options); + signer.sign(request, credentials); + String verifiedAuth = request.getHeaders().get(Headers.AUTHORIZATION); + + if (authString.split("/")[5].equals(verifiedAuth.split("/")[5])) { + return true; + } else { + return false; + } + } +} diff --git a/src/main/java/com/baidubce/common/ApiInfo.java b/src/main/java/com/baidubce/common/ApiInfo.java new file mode 100644 index 00000000..dfca47d7 --- /dev/null +++ b/src/main/java/com/baidubce/common/ApiInfo.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.common; + +import java.util.Map; + +import com.baidubce.http.HttpMethodName; + +/** + * Api info for v2 client to create request + * + * @author zhangquan07 + */ +public class ApiInfo { + /** + * Api method name + */ + private HttpMethodName method; + /** + * Api path, use [] to represents path variable. + */ + private ApiPath path; + /** + * Api query variables. + */ + private Map queries; + /** + * Api header variables. + */ + private Map headers; + + public HttpMethodName getMethod() { + return method; + } + + public ApiPath getPath() { + return path; + } + + public Map getQueries() { + return queries; + } + + public Map getHeaders() { + return headers; + } + + public ApiInfo(HttpMethodName method, ApiPath path, Map queries, + Map headers) { + this.method = method; + this.path = path; + this.queries = queries; + this.headers = headers; + } + + public ApiInfo(ApiInfo other) { + this.method = other.getMethod(); + this.path = other.getPath(); + this.queries = other.getQueries(); + this.headers = other.getHeaders(); + } +} diff --git a/src/main/java/com/baidubce/common/ApiPath.java b/src/main/java/com/baidubce/common/ApiPath.java new file mode 100644 index 00000000..a85e8bd1 --- /dev/null +++ b/src/main/java/com/baidubce/common/ApiPath.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.common; + +/** + * Api path for v2 client to create request + * + * @author zhangquan07 + */ +public class ApiPath { + private String path; + + public ApiPath(String path) { + this.path = path; + } + + public String get() { + return path; + } + + public ApiPath withPathParameter(String key, String value) { + return new ApiPath(path.replace("[" + key + "]", value)); + } +} diff --git a/src/main/java/com/baidubce/common/BaseBceClient.java b/src/main/java/com/baidubce/common/BaseBceClient.java new file mode 100644 index 00000000..5abcc92d --- /dev/null +++ b/src/main/java/com/baidubce/common/BaseBceClient.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.common; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +/** + * Base bce client + * + * @author zhangquan07 + */ +public class BaseBceClient extends AbstractBceClient { + private String serviceId; + private HttpRequestHandler[] httpRequestHandlers; + + public BaseBceClient(String serviceId, String ak, String sk, String endpoint) { + super(ServiceConfigFactory.getClientConfiguration(serviceId).withEndpoint(endpoint) + .withCredentials(new DefaultBceCredentials(ak, sk)), + ServiceConfigFactory.getResponseHandlers(serviceId)); + this.httpRequestHandlers = ServiceConfigFactory.getRequestHandlers(serviceId); + this.serviceId = serviceId; + } + + public BaseBceClient(BceClientConfiguration configuration) { + this(configuration, false); + } + + public BaseBceClient(BceClientConfiguration configuration, boolean isHttpAsyncPutEnabled) { + super(configuration, ServiceConfigFactory.getDefaultResponseHandlers(), isHttpAsyncPutEnabled); + this.serviceId = this.computeServiceId(); + this.httpRequestHandlers = ServiceConfigFactory.getRequestHandlers(serviceId); + } + + /** + * Create internal request with path, query, header and body. + * + * @param httpMethod http method + * @param path path + * @param queries queries + * @param headers headers + * @param bceRequest bce request + * @return Internal request + */ + protected InternalRequest createRequest( + HttpMethodName httpMethod, + String path, + Map queries, + Map headers, + BaseBceRequest bceRequest) { + URI uri = HttpUtils.appendUri(this.getEndpoint(), path); + InternalRequest internalRequest = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign( + new HashSet(Arrays.asList(ServiceConfigFactory.getDefaultHeadersToSign(serviceId)))); + internalRequest.setSignOptions(signOptions); + if (bceRequest == null) { + bceRequest = new BaseBceRequest(); + } else { + internalRequest.setCredentials(bceRequest.getRequestCredentials()); + } + internalRequest.setHeaders(headers); + internalRequest.setParameters(queries); + + for (HttpRequestHandler httpRequestHandler : httpRequestHandlers) { + if (!httpRequestHandler.handle(internalRequest, bceRequest)) { + break; + } + } + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + return internalRequest; + } +} diff --git a/src/main/java/com/baidubce/common/BaseBceRequest.java b/src/main/java/com/baidubce/common/BaseBceRequest.java new file mode 100644 index 00000000..383a19cf --- /dev/null +++ b/src/main/java/com/baidubce/common/BaseBceRequest.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.common; + +import org.apache.http.annotation.NotThreadSafe; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Base class for all BCE web service request objects. + * + * @author zhangquan07 + */ +@NotThreadSafe +public class BaseBceRequest extends AbstractBceRequest { + + public BaseBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/common/BaseBceResponse.java b/src/main/java/com/baidubce/common/BaseBceResponse.java new file mode 100644 index 00000000..6e3639df --- /dev/null +++ b/src/main/java/com/baidubce/common/BaseBceResponse.java @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.common; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Base bce response + * + * @author zhangquan07 + */ +public class BaseBceResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/common/BceRegion.java b/src/main/java/com/baidubce/common/BceRegion.java new file mode 100644 index 00000000..1f8a8b70 --- /dev/null +++ b/src/main/java/com/baidubce/common/BceRegion.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.common; + +/** + * Bce region + * + * @author zhangquan07 + */ +public enum BceRegion { + DEFAULT, // 默认 + BJ, // 华北-北京 + BD, // 华北-保定 + HBFSG, // 华北-度小满金融专区 + SU, // 华东-苏州 + GZ, // 华南-广州 + FSH, // 金融华东-上海 + FWH, // 金融华中-武汉 + HKG, // 香港 + SIN // 新加坡 +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/common/HttpRequestHandler.java b/src/main/java/com/baidubce/common/HttpRequestHandler.java new file mode 100644 index 00000000..dfaa8f35 --- /dev/null +++ b/src/main/java/com/baidubce/common/HttpRequestHandler.java @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.common; + +import com.baidubce.internal.InternalRequest; + +/** + * Responsible for handling an HTTP request. + * + * @author zhangquan07 + */ +public interface HttpRequestHandler { + + boolean handle(InternalRequest internalRequest, BaseBceRequest bceRequest); +} diff --git a/src/main/java/com/baidubce/common/ServiceConfigFactory.java b/src/main/java/com/baidubce/common/ServiceConfigFactory.java new file mode 100644 index 00000000..46f38f49 --- /dev/null +++ b/src/main/java/com/baidubce/common/ServiceConfigFactory.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.common; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; + +/** + * Service config of service. + * + * @author zhangquan07 + */ +public class ServiceConfigFactory { + /** + * Service client configuration. + */ + private static final BceClientConfiguration DEFAULT_CONFIGURATION = new BceClientConfiguration(); + + /** + * Default headers to sign. + */ + private static final String[] DEFAULT_HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling httpRequest from all service calls. + */ + private static final HttpRequestHandler[] DEFAULT_REQUEST_HANDLERS = new HttpRequestHandler[0]; + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static final HttpResponseHandler[] DEFAULT_RESPONSE_HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public static BceClientConfiguration getClientConfiguration(String serviceName) { + return DEFAULT_CONFIGURATION; + } + + public static String[] getDefaultHeadersToSign(String serviceName) { + return DEFAULT_HEADERS_TO_SIGN; + } + + public static HttpResponseHandler[] getResponseHandlers(String serviceName) { + return DEFAULT_RESPONSE_HANDLERS; + } + + public static HttpRequestHandler[] getRequestHandlers(String serviceName) { + return DEFAULT_REQUEST_HANDLERS; + } + + public static HttpResponseHandler[] getDefaultResponseHandlers() { + return DEFAULT_RESPONSE_HANDLERS; + } + +} diff --git a/src/main/java/com/baidubce/examples/acl/ExampleAclList.java b/src/main/java/com/baidubce/examples/acl/ExampleAclList.java new file mode 100644 index 00000000..c07e4948 --- /dev/null +++ b/src/main/java/com/baidubce/examples/acl/ExampleAclList.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.acl; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.acl.AclClient; +import com.baidubce.services.acl.AclClientConfiguration; +import com.baidubce.services.acl.model.GetAclResponse; + +public class ExampleAclList { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + AclClientConfiguration config = new AclClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AclClient aclClient = new AclClient(config); // 初始化AclClient + + try { + GetAclResponse response = aclClient.getAcl("vpc-b9ycwxxisrb7"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/acl/ExampleAddAclRule.java b/src/main/java/com/baidubce/examples/acl/ExampleAddAclRule.java new file mode 100644 index 00000000..62cfc6e5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/acl/ExampleAddAclRule.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.acl; + +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.acl.AclClient; +import com.baidubce.services.acl.AclClientConfiguration; +import com.baidubce.services.acl.model.AclRule; +import com.google.common.collect.Lists; + +public class ExampleAddAclRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + AclClientConfiguration config = new AclClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AclClient aclClient = new AclClient(config); // 初始化AclClient + + AclRule aclRule = new AclRule(); + aclRule.setSubnetId("sbn-6ha6gp1vczuv"); // acl规则的子网Id + aclRule.setAction("allow"); // 规则允许或者拒绝访问 + aclRule.setDescription("acl rule"); // 描述 + aclRule.setDirection("ingress"); // 规则的方向 + aclRule.setName("acl_name"); // 规则名称 + aclRule.setPosition(9000); // 规则的端口 + aclRule.setProtocol("all"); // acl规则的协议 + aclRule.setDestinationIpAddress("192.168.0.8"); // acl规则目的地址 + aclRule.setDestinationPort("80"); // acl规则目地端口 + aclRule.setSourceIpAddress("all"); // acl规则源地址 + aclRule.setSourcePort("90"); // acl规则源端口 + + List aclRules = Lists.newArrayList(aclRule); + try { + aclClient.createAcl(aclRules); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/acl/ExampleDeleteAclRule.java b/src/main/java/com/baidubce/examples/acl/ExampleDeleteAclRule.java new file mode 100644 index 00000000..6de90d98 --- /dev/null +++ b/src/main/java/com/baidubce/examples/acl/ExampleDeleteAclRule.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.acl; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.acl.AclClient; +import com.baidubce.services.acl.AclClientConfiguration; + +public class ExampleDeleteAclRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + AclClientConfiguration config = new AclClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AclClient aclClient = new AclClient(config); // 初始化AclClient + + try { + aclClient.deleteAcl("ar-ynf9u87ppu1x"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/acl/ExampleMarkerListAcl.java b/src/main/java/com/baidubce/examples/acl/ExampleMarkerListAcl.java new file mode 100644 index 00000000..35df4ade --- /dev/null +++ b/src/main/java/com/baidubce/examples/acl/ExampleMarkerListAcl.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.acl; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.acl.AclClient; +import com.baidubce.services.acl.AclClientConfiguration; +import com.baidubce.services.acl.model.ListAclRequest; +import com.baidubce.services.acl.model.ListAclResponse; + +public class ExampleMarkerListAcl { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + AclClientConfiguration config = new AclClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AclClient aclClient = new AclClient(config); // 初始化AclClient + + ListAclRequest listAclRequest = new ListAclRequest(); + listAclRequest.setSubnetId("sbn-6ha6gp1vczuv"); // 查询该子网的acl规则 + listAclRequest.setMaxKeys(20); // 本次查询最多20条 + try { + ListAclResponse response = aclClient.listAclRules(listAclRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/acl/ExampleUpdateAclRule.java b/src/main/java/com/baidubce/examples/acl/ExampleUpdateAclRule.java new file mode 100644 index 00000000..5226edc6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/acl/ExampleUpdateAclRule.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.acl; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.acl.AclClient; +import com.baidubce.services.acl.AclClientConfiguration; +import com.baidubce.services.acl.model.ModifyAclRuleAttributesRequest; + +public class ExampleUpdateAclRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + AclClientConfiguration config = new AclClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AclClient aclClient = new AclClient(config); // 初始化AclClient + + ModifyAclRuleAttributesRequest modifyAclRuleAttributesRequest = new ModifyAclRuleAttributesRequest(); + modifyAclRuleAttributesRequest.setAclRuleId("ar-ynf9u87ppu1x"); + modifyAclRuleAttributesRequest.setDescription("new_desc"); + modifyAclRuleAttributesRequest.setName("name"); + modifyAclRuleAttributesRequest.setDestinationPort("9090"); + modifyAclRuleAttributesRequest.setSourcePort("8080"); + try { + aclClient.modifyAclRuleAttributes(modifyAclRuleAttributesRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleAppDetails.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleAppDetails.java new file mode 100644 index 00000000..e0a5b384 --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleAppDetails.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.AppDetailsRequest; +import com.baidubce.services.aihc.model.inference.AppDetailsResponse; + +public class ExampleAppDetails { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + AppDetailsRequest request = new AppDetailsRequest(); + request.setAppId("test"); + try { + AppDetailsResponse response = client.appDetails(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleBlockPod.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleBlockPod.java new file mode 100644 index 00000000..d7b3892f --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleBlockPod.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.BlockPodRequest; +import com.baidubce.services.aihc.model.inference.BlockPodResponse; + +public class ExampleBlockPod { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + BlockPodRequest request = new BlockPodRequest(); + request.setAppId("test"); + request.setInsID("test"); + request.setBlock(true); + + try { + BlockPodResponse response = client.blockPod(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleChangeDetail.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleChangeDetail.java new file mode 100644 index 00000000..da969624 --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleChangeDetail.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.AppChangeDetailRequest; +import com.baidubce.services.aihc.model.inference.AppChangeDetailResponse; + +public class ExampleChangeDetail { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + AppChangeDetailRequest request = new AppChangeDetailRequest(); + request.setChangeId("test"); + + try { + AppChangeDetailResponse response = client.appChangeDetail(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleCreateApp.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleCreateApp.java new file mode 100644 index 00000000..bb03922f --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleCreateApp.java @@ -0,0 +1,85 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.CreateAppRequest; +import com.baidubce.services.aihc.model.inference.CreateAppResponse; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ExampleCreateApp { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + CreateAppRequest request = new CreateAppRequest(); + + request.setAppName("test"); + request.setChipType("test"); + request.setInsCount(1); + + request.setResPool(new CreateAppRequest.ResPoolConf("test", "test")); + + List volumns = new ArrayList<>(); + volumns.add(new CreateAppRequest.VolumnConf("", "", + new CreateAppRequest.PFSConfig(""), + new CreateAppRequest.HostPathConfig(""))); + request.setStorage(new CreateAppRequest.StorageConf(16, volumns)); + + request.setAccess(new CreateAppRequest.AccessConf(false, "")); + + request.setLog(new CreateAppRequest.LogConf(true)); + + request.setDeploy(new CreateAppRequest.DeployConf(new CreateAppRequest.CanaryStrategyConf(25, 25))); + + Map podLabels = new HashMap(); + podLabels.put("test", ""); + request.setMisc(new CreateAppRequest.Misc(podLabels, null)); + + List runCmd = new ArrayList(); + runCmd.add("/bin/sh"); + runCmd.add("-c"); + runCmd.add("test"); + + Map env = new HashMap<>(); + env.put("test", "test"); + + List containers = new ArrayList<>(); + List volumeMounts = new ArrayList<>(); + volumeMounts.add(new CreateAppRequest.VolumnMountConf("", "", true)); + + List command = new ArrayList<>(); + command.add("/bin/sh"); + + containers.add(new CreateAppRequest.ContainerConf("inference", 1, 16, 1, runCmd, null, null, env, + new CreateAppRequest.ImageConf(2, "registry.baidubce.com/test/test:test", "", ""), + volumeMounts, + new CreateAppRequest.ProbeConf(1,1,1,1,1, new CreateAppRequest.ProbeHandlerConf( + new CreateAppRequest.ExecAction(command), new CreateAppRequest.HTTPGetAction("", 2000), new CreateAppRequest.TCPSocketAction(2000) + )), + null, null)); + + request.setContainers(containers); + + try { + CreateAppResponse response = client.createApp(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleDeleteApp.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleDeleteApp.java new file mode 100644 index 00000000..fafdcedc --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleDeleteApp.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.DeleteAppRequest; +import com.baidubce.services.aihc.model.inference.DeleteAppResponse; + +public class ExampleDeleteApp { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + DeleteAppRequest request = new DeleteAppRequest(); + request.setAppId("test"); + + try { + DeleteAppResponse response = client.deleteApp(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleDeletePod.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleDeletePod.java new file mode 100644 index 00000000..f3c71121 --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleDeletePod.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.DeletePodRequest; +import com.baidubce.services.aihc.model.inference.DeletePodResponse; + +public class ExampleDeletePod { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + DeletePodRequest request = new DeletePodRequest(); + request.setAppId("test"); + request.setInsID("test"); + + try { + DeletePodResponse response = client.deletePod(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleListApp.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListApp.java new file mode 100644 index 00000000..c51003fd --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListApp.java @@ -0,0 +1,37 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.ListAppRequest; +import com.baidubce.services.aihc.model.inference.ListAppResponse; + +public class ExampleListApp { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + ListAppRequest request = new ListAppRequest(); + request.setPageNo(1); + request.setPageSize(10); + request.setKeyword("test"); + request.setOrder("desc"); + request.setOrderBy("ctime"); + try { + ListAppResponse response = client.listApp(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleListChange.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListChange.java new file mode 100644 index 00000000..0acd1612 --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListChange.java @@ -0,0 +1,38 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.ListChangeRequest; +import com.baidubce.services.aihc.model.inference.ListChangeResponse; + +public class ExampleListChange { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + ListChangeRequest request = new ListChangeRequest(); + request.setAppId("test"); + request.setOrder("desc"); + request.setOrderBy("ctime"); + request.setPageNo(1); + request.setPageSize(10); + request.setChangeType(1); + try { + ListChangeResponse response = client.listChange(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleListPod.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListPod.java new file mode 100644 index 00000000..c59ea7cb --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListPod.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.ListPodRequest; +import com.baidubce.services.aihc.model.inference.ListPodResponse; + +public class ExampleListPod { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + ListPodRequest request = new ListPodRequest(); + request.setAppId("test"); + + try { + ListPodResponse response = client.listPod(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleListResPoolBrief.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListResPoolBrief.java new file mode 100644 index 00000000..9dae0203 --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListResPoolBrief.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.ListResPoolBriefRequest; +import com.baidubce.services.aihc.model.inference.ListResPoolBriefResponse; + +public class ExampleListResPoolBrief { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + ListResPoolBriefRequest request = new ListResPoolBriefRequest(); + + request.setPageNo(1); + request.setPageSize(10); + try { + ListResPoolBriefResponse response = client.listResPoolBrief(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleListStat.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListStat.java new file mode 100644 index 00000000..51b12d20 --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleListStat.java @@ -0,0 +1,39 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.ListStatsRequest; +import com.baidubce.services.aihc.model.inference.ListStatsResponse; + +import java.util.ArrayList; +import java.util.List; + +public class ExampleListStat { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + ListStatsRequest request = new ListStatsRequest(); + + List appIds = new ArrayList(); + appIds.add("test"); + request.setAppIds(appIds); + try { + ListStatsResponse response = client.listStats(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExamplePubAccess.java b/src/main/java/com/baidubce/examples/aihc/inference/ExamplePubAccess.java new file mode 100644 index 00000000..41b17add --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExamplePubAccess.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.PubAccessRequest; +import com.baidubce.services.aihc.model.inference.PubAccessResponse; + +public class ExamplePubAccess { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + PubAccessRequest request = new PubAccessRequest(); + request.setAppId("test"); + request.setPublicAccess(true); + request.setEip("test"); + + try { + PubAccessResponse response = client.pubAccess(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleResPoolDetail.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleResPoolDetail.java new file mode 100644 index 00000000..d8a6c3b3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleResPoolDetail.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.ResPoolDetailRequest; +import com.baidubce.services.aihc.model.inference.ResPoolDetailResponse; + +public class ExampleResPoolDetail { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + ResPoolDetailRequest request = new ResPoolDetailRequest(); + + request.setResPoolId("test"); + try { + ResPoolDetailResponse response = client.resPoolDetail(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleScaleApp.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleScaleApp.java new file mode 100644 index 00000000..e6aba14d --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleScaleApp.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.ScaleAppRequest; +import com.baidubce.services.aihc.model.inference.ScaleAppResponse; + +public class ExampleScaleApp { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + ScaleAppRequest request = new ScaleAppRequest(); + request.setAppId("test"); + request.setInsCount(1); + + try { + ScaleAppResponse response = client.scaleApp(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/aihc/inference/ExampleUpdateApp.java b/src/main/java/com/baidubce/examples/aihc/inference/ExampleUpdateApp.java new file mode 100644 index 00000000..db07a6f4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/aihc/inference/ExampleUpdateApp.java @@ -0,0 +1,88 @@ +package com.baidubce.examples.aihc.inference; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.aihc.AihcInferenceClient; +import com.baidubce.services.aihc.model.inference.CreateAppRequest; +import com.baidubce.services.aihc.model.inference.UpdateAppRequest; +import com.baidubce.services.aihc.model.inference.UpdateAppResponse; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ExampleUpdateApp { + public static void main(String[] args) { + String ak = "Your AK"; + String sk = "Your SK"; + String endpoint = "aihc.baidubce.com"; + String region = "bj"; + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + config.setProtocol(Protocol.HTTPS); + AihcInferenceClient client = new AihcInferenceClient(config); + + UpdateAppRequest request = new UpdateAppRequest(); + request.setAppId("test"); + request.setShortDesc("test"); + + request.setAppName("test"); + request.setChipType("test"); + request.setInsCount(1); + + request.setResPool(new CreateAppRequest.ResPoolConf("test", "test")); + + List volumns = new ArrayList<>(); + volumns.add(new CreateAppRequest.VolumnConf("", "", + new CreateAppRequest.PFSConfig(""), + new CreateAppRequest.HostPathConfig(""))); + request.setStorage(new CreateAppRequest.StorageConf(16, volumns)); + + request.setAccess(new CreateAppRequest.AccessConf(false, "")); + + request.setLog(new CreateAppRequest.LogConf(true)); + + request.setDeploy(new CreateAppRequest.DeployConf(new CreateAppRequest.CanaryStrategyConf(25, 25))); + + Map podLabels = new HashMap(); + podLabels.put("test", ""); + request.setMisc(new CreateAppRequest.Misc(podLabels, null)); + + List runCmd = new ArrayList(); + runCmd.add("/bin/sh"); + runCmd.add("-c"); + runCmd.add("test"); + + Map env = new HashMap<>(); + env.put("test", "test"); + + List containers = new ArrayList<>(); + List volumeMounts = new ArrayList<>(); + volumeMounts.add(new CreateAppRequest.VolumnMountConf("", "", true)); + + List command = new ArrayList<>(); + command.add("/bin/sh"); + + containers.add(new CreateAppRequest.ContainerConf("inference", 1, 16, 1, runCmd, null, null, env, + new CreateAppRequest.ImageConf(2, "registry.baidubce.com/test/test:test", "", ""), + volumeMounts, + new CreateAppRequest.ProbeConf(1,1,1,1,1, new CreateAppRequest.ProbeHandlerConf( + new CreateAppRequest.ExecAction(command), new CreateAppRequest.HTTPGetAction("", 2000), new CreateAppRequest.TCPSocketAction(2000) + )), + null, null)); + + request.setContainers(containers); + + try { + UpdateAppResponse response = client.updateApp(request, region); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/bbc/ExampleBindReservedToTags.java b/src/main/java/com/baidubce/examples/bbc/ExampleBindReservedToTags.java new file mode 100644 index 00000000..d42cc3e9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/bbc/ExampleBindReservedToTags.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.bbc; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bbc.BbcClient; +import com.baidubce.services.bbc.BbcClientConfiguration; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.bcc.model.reversed.ReservedTagsRequest; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ExampleBindReservedToTags { + public static void main(String[] args) { + // 设置您的ak、sk和要访问的endpoint + String endpoint = "bbc.bj.baidubce.com"; + String ak = "ak"; + String sk = "sk"; + // 设置默认配置 + BceClientConfiguration bbcClientConfiguration = new BbcClientConfiguration() + .withProtocol(Protocol.HTTP) + .withCredentials(new DefaultBceCredentials(ak, sk)) + .withEndpoint(endpoint); + // 创建bbc client + BbcClient bbcClient = new BbcClient(bbcClientConfiguration); + + ReservedTagsRequest reservedTagsRequest = new ReservedTagsRequest(); + // 标签列表 + List changeTags = new ArrayList(); + TagModel tagModel = new TagModel().withTagKey("Key").withTagValue("Value"); + changeTags.add(tagModel); + reservedTagsRequest.setChangeTags(changeTags); + // 实例券ID列表,最多支持100个 + reservedTagsRequest.withInstanceIds(Arrays.asList("r-oFpMXKhv", "r-HrztSVk0")); + + bbcClient.bindReservedInstanceToTags(reservedTagsRequest); + } +} diff --git a/src/main/java/com/baidubce/examples/bbc/ExampleUnbindReservedFromTags.java b/src/main/java/com/baidubce/examples/bbc/ExampleUnbindReservedFromTags.java new file mode 100644 index 00000000..8fd28b02 --- /dev/null +++ b/src/main/java/com/baidubce/examples/bbc/ExampleUnbindReservedFromTags.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.bbc; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bbc.BbcClient; +import com.baidubce.services.bbc.BbcClientConfiguration; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.bcc.model.reversed.ReservedTagsRequest; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ExampleUnbindReservedFromTags { + public static void main(String[] args) { + // 设置您的ak、sk和要访问的endpoint + String endpoint = "bbc.bj.baidubce.com"; + String ak = "ak"; + String sk = "sk"; + // 设置默认配置 + BceClientConfiguration bbcClientConfiguration = new BbcClientConfiguration() + .withProtocol(Protocol.HTTP) + .withCredentials(new DefaultBceCredentials(ak, sk)) + .withEndpoint(endpoint); + // 创建bbc client + BbcClient bbcClient = new BbcClient(bbcClientConfiguration); + + ReservedTagsRequest reservedTagsRequest = new ReservedTagsRequest(); + // 标签列表 + List changeTags = new ArrayList(); + TagModel tagModel = new TagModel().withTagKey("Key***").withTagValue("Value***"); + changeTags.add(tagModel); + reservedTagsRequest.setChangeTags(changeTags); + // 预留实例券ID列表,最多支持100个 + reservedTagsRequest.withInstanceIds(Arrays.asList("r-oFpMXKhv", "r-HrztSVk0")); + + bbcClient.unbindReservedInstanceFromTags(reservedTagsRequest); + } +} diff --git a/src/main/java/com/baidubce/examples/bcc/ExampleBindReservedToTags.java b/src/main/java/com/baidubce/examples/bcc/ExampleBindReservedToTags.java new file mode 100644 index 00000000..cf39ddb5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/bcc/ExampleBindReservedToTags.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.bcc; + +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.TagModel; +import com.baidubce.services.bcc.model.reversed.ReservedTagsRequest; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ExampleBindReservedToTags { + 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 bccClient = new BccClient(bccClientConfiguration); + + ReservedTagsRequest reservedTagsRequest = new ReservedTagsRequest(); + // 标签列表 + List changeTags = new ArrayList(); + TagModel tagModel = new TagModel().withTagKey("Key***").withTagValue("Value***"); + changeTags.add(tagModel); + reservedTagsRequest.setChangeTags(changeTags); + // 实例券ID列表,最多支持100个 + reservedTagsRequest.withInstanceIds(Arrays.asList("r-oFpMXKhv", "r-HrztSVk0")); + + bccClient.bindReservedInstanceToTags(reservedTagsRequest); + } +} diff --git a/src/main/java/com/baidubce/examples/bcc/ExampleCreateReservedInstance.java b/src/main/java/com/baidubce/examples/bcc/ExampleCreateReservedInstance.java new file mode 100644 index 00000000..91f86879 --- /dev/null +++ b/src/main/java/com/baidubce/examples/bcc/ExampleCreateReservedInstance.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.bcc; + +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.TagModel; +import com.baidubce.services.bcc.model.reversed.CreateReservedInstanceResponse; +import com.baidubce.services.bcc.model.reversed.CreateReservedInstancesRequest; +import lombok.extern.slf4j.Slf4j; + +import java.util.Collections; + +@Slf4j +public class ExampleCreateReservedInstance { + 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 bccClient = new BccClient(bccClientConfiguration); + + CreateReservedInstancesRequest request = new CreateReservedInstancesRequest(); + request.setReservedInstanceName("bj-test"); + request.setScope("AZ"); + request.setZoneName("cn-bj-a"); + request.setSpec("bcc.c5.c2m8"); + request.setOfferingType("FullyPrepay"); + request.setInstanceCount(1); + request.setReservedInstanceCount(1); + request.setReservedInstanceTime(1); + request.setReservedInstanceTimeUnit("month"); + request.setAutoRenewTimeUnit("month"); + request.setAutoRenewTime(1); + request.setAutoRenew(true); + + TagModel tagModel = new TagModel(); + tagModel.setTagKey("testKey"); + tagModel.setTagValue("testValue"); + request.setTags(Collections.singletonList(tagModel)); + + CreateReservedInstanceResponse response = bccClient.createReservedInstances(request); + log.debug("CreateReservedInstanceResponse: {}", response); + } +} diff --git a/src/main/java/com/baidubce/examples/bcc/ExampleModifyReservedInstances.java b/src/main/java/com/baidubce/examples/bcc/ExampleModifyReservedInstances.java new file mode 100644 index 00000000..be65235c --- /dev/null +++ b/src/main/java/com/baidubce/examples/bcc/ExampleModifyReservedInstances.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.bcc; + +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.reversed.ModifyReservedInstancesResponse; +import com.baidubce.services.bcc.model.reversed.ModifyReservedInstancesRequest; +import com.baidubce.services.bcc.model.reversed.ModifyReservedInstancesRequest.ReservedInstance; +import lombok.extern.slf4j.Slf4j; + +import java.util.Collections; + +@Slf4j +public class ExampleModifyReservedInstances { + + 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 bccClient = new BccClient(bccClientConfiguration); + + ModifyReservedInstancesRequest request = new ModifyReservedInstancesRequest(); + + // 修改名称 + ReservedInstance modifyName = new ReservedInstance(); + modifyName.setReservedInstanceId("r-qt4ItfUP"); + modifyName.setReservedInstanceName("update-reserved-instance"); + request.setReservedInstances(Collections.singletonList(modifyName)); + + ModifyReservedInstancesResponse response = bccClient.modifyReservedInstances(request); + log.debug("ModifyReservedInstancesResponse:{}", response); + } +} diff --git a/src/main/java/com/baidubce/examples/bcc/ExampleUnbindReservedFromTags.java b/src/main/java/com/baidubce/examples/bcc/ExampleUnbindReservedFromTags.java new file mode 100644 index 00000000..7eb10f2d --- /dev/null +++ b/src/main/java/com/baidubce/examples/bcc/ExampleUnbindReservedFromTags.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.bcc; + +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.TagModel; +import com.baidubce.services.bcc.model.reversed.ReservedTagsRequest; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ExampleUnbindReservedFromTags { + 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 bccClient = new BccClient(bccClientConfiguration); + + ReservedTagsRequest reservedTagsRequest = new ReservedTagsRequest(); + // 标签列表 + List changeTags = new ArrayList(); + TagModel tagModel = new TagModel().withTagKey("Key***").withTagValue("Value***"); + changeTags.add(tagModel); + reservedTagsRequest.setChangeTags(changeTags); + // 预留实例券ID列表,最多支持100个 + reservedTagsRequest.withInstanceIds(Arrays.asList("r-oFpMXKhv", "r-HrztSVk0")); + + bccClient.unbindReservedInstanceFromTags(reservedTagsRequest); + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleAppBlbDetail.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleAppBlbDetail.java new file mode 100644 index 00000000..c4a9ebe0 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleAppBlbDetail.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbDetailRequest; +import com.baidubce.services.blb.model.BlbInstance; + +public class ExampleAppBlbDetail { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbDetailRequest blbDetailRequest = new BlbDetailRequest(); + blbDetailRequest.setBlbId("lb-9629aac9"); // 要查询的LoadBalancer的标识符 + + try { + BlbInstance blbInstance = appBlbClient.blbDetail(blbDetailRequest); + System.out.println(blbInstance); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleBindEsg.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleBindEsg.java new file mode 100644 index 00000000..8b424f66 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleBindEsg.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.EsgOperateRequest; + +public class ExampleBindEsg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + EsgOperateRequest esgOperateRequest = new EsgOperateRequest(); + esgOperateRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + List enterpriseSecurityGroupIds = new ArrayList(); // 绑定的企业安全组ID列表 + enterpriseSecurityGroupIds.add("esg-tv9jcdnyz5ap"); // 绑定的企业安全组ID + esgOperateRequest.setEnterpriseSecurityGroupIds(enterpriseSecurityGroupIds); + + try { + appBlbClient.bindEsg(esgOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleBindSg.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleBindSg.java new file mode 100644 index 00000000..55fedc97 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleBindSg.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.SgOperateRequest; + +public class ExampleBindSg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + SgOperateRequest sgOperateRequest = new SgOperateRequest(); + sgOperateRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + List securityGroupIds = new ArrayList(); // 绑定的普通安全组ID列表 + securityGroupIds.add("g-msrvz0w5kvuz"); // 绑定的普通安全组ID + sgOperateRequest.setSecurityGroupIds(securityGroupIds); + + try { + appBlbClient.bindSg(sgOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppBlb.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppBlb.java new file mode 100644 index 00000000..46b05b31 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppBlb.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.CreateBlbRequest; +import com.baidubce.services.blb.model.CreateBlbResponse; + +public class ExampleCreateAppBlb { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + CreateBlbRequest createBlbRequest = new CreateBlbRequest(); + createBlbRequest.setName("blb_1204_1"); // LoadBalancer的名称 + createBlbRequest.setDesc("desc info"); // LoadBalancer实例的描述 + createBlbRequest.setVpcId("vpc-syx4vuhy9z0f"); // LoadBalancer实例所属VPC的ID + createBlbRequest.setSubnetId("sbn-xgbjx1ecjf22"); // LoadBalancer实例所属子网的ID + + try { + CreateBlbResponse createBlbResponse = appBlbClient.createBlb(createBlbRequest); + System.out.println(createBlbResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppHttpListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppHttpListener.java new file mode 100644 index 00000000..68ce4cde --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppHttpListener.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateAppHttpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType("HTTP"); // 监听器类型 + blbListenerRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(90); // 监听器的监听端口 + blbListenerRequest.setScheduler("RoundRobin"); // 负载均衡算法 + + try { + appBlbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppHttpsListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppHttpsListener.java new file mode 100644 index 00000000..83eb9fa4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppHttpsListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateAppHttpsListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType("HTTPS"); // 监听器类型 + blbListenerRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(22); // 监听器的监听端口 + blbListenerRequest.setScheduler("RoundRobin"); // 负载均衡算法 + blbListenerRequest.setCertIds(Arrays.asList("cert-btq9faddgkpb")); // 监听器要加载的证书链 + + try { + appBlbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppServerGroup.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppServerGroup.java new file mode 100644 index 00000000..84689ef3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppServerGroup.java @@ -0,0 +1,45 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.AppBackendServer; +import com.baidubce.services.blb.model.AppSgResponse; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleCreateAppServerGroup { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + List backendServerList = new ArrayList(); + AppBackendServer appBackendServer = new AppBackendServer(); + appBackendServer.setInstanceId("i-mWyp1Bjd"); // 后端服务器实例ID + appBackendServer.setWeight(100); // 后端服务器权重 + backendServerList.add(appBackendServer); + try { + AppSgResponse response = + appBlbClient.createAppServerGroup("lb-99fa2577", "appSg", "", backendServerList); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppServerGroupPort.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppServerGroupPort.java new file mode 100644 index 00000000..81afb5aa --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppServerGroupPort.java @@ -0,0 +1,42 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.AppSgPortRequest; +import com.baidubce.services.blb.model.AppSgPortResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleCreateAppServerGroupPort { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + AppSgPortRequest request = new AppSgPortRequest(); + request.setBlbId("lb-99fa2577"); // 负载均衡实例ID + request.setSgId("sg-9153c2d9"); // 应用服务器组ID + request.setPort(90); // 端口号 + request.setType("HTTP"); // 协议类型 + request.setHealthCheck("HTTP"); // 健康检查类型 + try { + AppSgPortResponse response = appBlbClient.createAppServerGroupPort(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppSslListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppSslListener.java new file mode 100644 index 00000000..597e3965 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppSslListener.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateAppSslListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType("SSL"); // 监听器类型 + blbListenerRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(32); // 监听器的监听端口 + blbListenerRequest.setScheduler("RoundRobin"); // 负载均衡算法 + blbListenerRequest.setCertIds(Arrays.asList("cert-btq9faddgkpb")); // 监听器要加载的证书链 + + try { + appBlbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppTcpListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppTcpListener.java new file mode 100644 index 00000000..61dfb25d --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppTcpListener.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateAppTcpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType("TCP"); // 监听器类型 + blbListenerRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(81); // 监听器的监听端口 + blbListenerRequest.setScheduler("Hash"); // 负载均衡算法 + + try { + appBlbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppUdpListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppUdpListener.java new file mode 100644 index 00000000..93a4dab6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateAppUdpListener.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateAppUdpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType("UDP"); // 监听器协议类型 + blbListenerRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(82); // 监听器的监听端口 + blbListenerRequest.setScheduler("Hash"); // 负载均衡算法 + blbListenerRequest.setHealthCheckString("\\00"); // 健康检查发送的请求字符串 + + try { + appBlbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateBlbRs.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateBlbRs.java new file mode 100644 index 00000000..25d17620 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreateBlbRs.java @@ -0,0 +1,42 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.AppBackendServer; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleCreateBlbRs { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + List backendServerList = new ArrayList(); // 后端服务器列表 + AppBackendServer appBackendServer = new AppBackendServer(); + appBackendServer.setInstanceId("i-mWyp1Bjd"); // 后端服务器实例ID + appBackendServer.setWeight(100); // 后端服务器权重 + backendServerList.add(appBackendServer); + try { + appBlbClient.createBlbRs("lb-99fa2577", "sg-0bf84edc", backendServerList); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreatePolicys.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreatePolicys.java new file mode 100644 index 00000000..2db405e5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleCreatePolicys.java @@ -0,0 +1,53 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.AppPolicy; +import com.baidubce.services.blb.model.AppRule; +import com.baidubce.services.blb.model.CreateAppPolicyResponse; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleCreatePolicys { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + List appPolicyVos = new ArrayList(); // 创建策略列表 + AppPolicy appPolicy = new AppPolicy(); + appPolicyVos.add(appPolicy); + appPolicy.setPriority(7); // 策略优先级 + List ruleList = new ArrayList(); // 策略规则列表 + AppRule appRule = new AppRule(); + appRule.setKey("*"); // 策略规则类型 + appRule.setValue("*"); // 策略规则值 + ruleList.add(appRule); + appPolicy.setRuleList(ruleList); + appPolicy.setAppServerGroupId("sg-1fd8a838"); // 服务器组ID + appPolicy.setBackendPort(90); // 后端端口 + try { + CreateAppPolicyResponse response = + appBlbClient.createPolicys("lb-2986ed03", 80, null, appPolicyVos); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppBlb.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppBlb.java new file mode 100644 index 00000000..6b3bb464 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppBlb.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; + +public class ExampleDeleteAppBlb { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + String blbId = "lb-9629aac9"; // 待释放的LoadBalancer的ID + + try { + appBlbClient.deleteBlb(blbId); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppListeners.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppListeners.java new file mode 100644 index 00000000..1855a05d --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppListeners.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; + +import java.util.Arrays; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDeleteAppListeners { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + appBlbClient.deleteListener("lb-99fa2577", Arrays.asList(81, 82)); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppServerGroup.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppServerGroup.java new file mode 100644 index 00000000..7539da72 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppServerGroup.java @@ -0,0 +1,30 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDeleteAppServerGroup { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + appBlbClient.deleteAppServerGroup("lb-99fa2577", "sg-c2eac39c"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppServerGroupPort.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppServerGroupPort.java new file mode 100644 index 00000000..216028be --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteAppServerGroupPort.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; + +import java.util.Arrays; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDeleteAppServerGroupPort { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + appBlbClient.deleteAppServerGroupPort("lb-99fa2577", "sg-9153c2d9", Arrays.asList("port-2b68dae3")); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteBlbRs.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteBlbRs.java new file mode 100644 index 00000000..f7e2be40 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeleteBlbRs.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; + +import java.util.Arrays; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDeleteBlbRs { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + appBlbClient.deleteBlbRs("lb-99fa2577", "sg-9153c2d9", Arrays.asList("i-mWyp1Bjd")); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeletePolicys.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeletePolicys.java new file mode 100644 index 00000000..758fe986 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDeletePolicys.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; + +import java.util.Arrays; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDeletePolicys { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + appBlbClient.deletePolicys("lb-99fa2577", 90, Arrays.asList("policy-01940c30")); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppAllListeners.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppAllListeners.java new file mode 100644 index 00000000..f5081cae --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppAllListeners.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.AllListener; +import com.baidubce.services.blb.model.ListListenerResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeAppAllListeners { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListListenerResponse response = appBlbClient.listAllListener("lb-1ef11a87"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppHTTPListeners.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppHTTPListeners.java new file mode 100644 index 00000000..707ed574 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppHTTPListeners.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.HttpListener; +import com.baidubce.services.blb.model.ListListenerResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeAppHTTPListeners { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListListenerResponse response = appBlbClient.listHttpListener("lb-b69cd42f"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppHTTPSListeners.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppHTTPSListeners.java new file mode 100644 index 00000000..d2f69630 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppHTTPSListeners.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.HttpsListener; +import com.baidubce.services.blb.model.ListListenerResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeAppHTTPSListeners { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListListenerResponse response = appBlbClient.listHttpsListener("lb-1ef11a87"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppSSLListeners.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppSSLListeners.java new file mode 100644 index 00000000..1cfbde6a --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppSSLListeners.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListListenerResponse; +import com.baidubce.services.blb.model.SslListener; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeAppSSLListeners { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListListenerResponse response = appBlbClient.listSslListener("lb-1ef11a87"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppServerGroup.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppServerGroup.java new file mode 100644 index 00000000..ffdf2a0d --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppServerGroup.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListAppSgResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeAppServerGroup { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListAppSgResponse response = appBlbClient.listAppServerGroup("lb-99fa2577", "ccqSg"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppTCPListeners.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppTCPListeners.java new file mode 100644 index 00000000..93e51e4b --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppTCPListeners.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListListenerResponse; +import com.baidubce.services.blb.model.TcpListener; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeAppTCPListeners { + + public static void main(String[] args) { + + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListListenerResponse response = appBlbClient.listTcpListener("lb-b69cd42f"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppUDPListeners.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppUDPListeners.java new file mode 100644 index 00000000..c61f6e63 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeAppUDPListeners.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListListenerResponse; +import com.baidubce.services.blb.model.UdpListener; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeAppUDPListeners { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListListenerResponse response = appBlbClient.listUdpListener("lb-1ef11a87"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeBlbRs.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeBlbRs.java new file mode 100644 index 00000000..dabef8d6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeBlbRs.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListAppRsResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeBlbRs { + + public static void main(String[] args) { + + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListAppRsResponse response = appBlbClient.listBlbRs("lb-b69cd42f", "sg-b8221879"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribePolicys.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribePolicys.java new file mode 100644 index 00000000..14671b8a --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribePolicys.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListAppPolicyResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribePolicys { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListAppPolicyResponse response = appBlbClient.listPolicys("lb-1ef11a87", 80); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeRsMount.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeRsMount.java new file mode 100644 index 00000000..43b53e6f --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeRsMount.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListAppRsMountResponse; + + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeRsMount { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListAppRsMountResponse response = appBlbClient.listBlbRsMount("lb-b69cd42f", "sg-b8221879"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeRsUnMount.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeRsUnMount.java new file mode 100644 index 00000000..a19e6e57 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleDescribeRsUnMount.java @@ -0,0 +1,37 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListAppRsUnMountResponse; + + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleDescribeRsUnMount { + + public static void main(String[] args) { + + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + try { + ListAppRsUnMountResponse response = appBlbClient.listBlbRsUnMount("lb-b69cd42f", "sg-b8221879"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleListAppBlbEsg.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleListAppBlbEsg.java new file mode 100644 index 00000000..cc29635b --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleListAppBlbEsg.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListBlbEsgResponse; +import com.baidubce.services.blb.model.ListBlbSgRequest; + +public class ExampleListAppBlbEsg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + ListBlbSgRequest listBlbSgRequest = new ListBlbSgRequest(); + listBlbSgRequest.setBlbId("lb-166d3dbe"); // 要查询的LoadBalancer的标识符 + + try { + ListBlbEsgResponse listBlbEsgResponse = appBlbClient.listBlbEsg(listBlbSgRequest); + System.out.println(listBlbEsgResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleListAppBlbSg.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleListAppBlbSg.java new file mode 100644 index 00000000..7e4d7476 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleListAppBlbSg.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListBlbSgRequest; +import com.baidubce.services.blb.model.ListBlbSgResponse; + +public class ExampleListAppBlbSg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + ListBlbSgRequest listBlbSgRequest = new ListBlbSgRequest(); + listBlbSgRequest.setBlbId("lb-166d3dbe"); // 要查询的LoadBalancer的标识符 + + try { + ListBlbSgResponse listBlbSgResponse = appBlbClient.listBlbSg(listBlbSgRequest); + System.out.println(listBlbSgResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleListAppBlbs.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleListAppBlbs.java new file mode 100644 index 00000000..84df1d05 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleListAppBlbs.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListBlbRequest; +import com.baidubce.services.blb.model.ListBlbResponse; + +public class ExampleListAppBlbs { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + ListBlbRequest listBlbRequest = new ListBlbRequest(); + listBlbRequest.setName("blb_1204_1_1"); // 要查询的LoadBalancer名称 + + try { + ListBlbResponse response = appBlbClient.listBlbs(listBlbRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleModifyAppBlbAttributes.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleModifyAppBlbAttributes.java new file mode 100644 index 00000000..11c43ceb --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleModifyAppBlbAttributes.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ModifyBlbAttributesRequest; + +public class ExampleModifyAppBlbAttributes { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + ModifyBlbAttributesRequest modifyBlbAttributesRequest = new ModifyBlbAttributesRequest(); + modifyBlbAttributesRequest.setBlbId("lb-9629aac9"); // 待更新的LoadBalancer的ID + modifyBlbAttributesRequest.setName("blb_1204_1_1"); // LoadBalancer的名称 + + try { + appBlbClient.modifyBlbAttributes(modifyBlbAttributesRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUnBindEsg.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUnBindEsg.java new file mode 100644 index 00000000..eff65a46 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUnBindEsg.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.EsgOperateRequest; + +public class ExampleUnBindEsg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + EsgOperateRequest esgOperateRequest = new EsgOperateRequest(); + esgOperateRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + List enterpriseSecurityGroupIds = new ArrayList(); // 解绑的企业安全组ID列表 + enterpriseSecurityGroupIds.add("esg-tv9jcdnyz5ap"); // 解绑的企业安全组ID + esgOperateRequest.setEnterpriseSecurityGroupIds(enterpriseSecurityGroupIds); + + try { + appBlbClient.unBindEsg(esgOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUnBindSg.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUnBindSg.java new file mode 100644 index 00000000..e7d4c1d9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUnBindSg.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.SgOperateRequest; + +public class ExampleUnBindSg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + SgOperateRequest sgOperateRequest = new SgOperateRequest(); + sgOperateRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + List securityGroupIds = new ArrayList(); // 解绑的普通安全组ID列表 + securityGroupIds.add("g-msrvz0w5kvuz"); // 解绑的普通安全组ID + sgOperateRequest.setSecurityGroupIds(securityGroupIds); + + try { + appBlbClient.unBindSg(sgOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppHTTPSListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppHTTPSListener.java new file mode 100644 index 00000000..42dabc20 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppHTTPSListener.java @@ -0,0 +1,39 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleUpdateAppHTTPSListener { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest request = new BlbListenerRequest(); + request.setType("HTTPS"); // 监听器协议类型 + request.setBlbId("lb-99fa2577"); // 负载均衡器ID + request.setListenerPort(22); // 监听器端口 + request.setScheduler("LeastConnection"); // 调度算法 + try { + appBlbClient.modifyListenerAttributes(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppHttpListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppHttpListener.java new file mode 100644 index 00000000..bfb4642d --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppHttpListener.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleUpdateAppHttpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType("HTTP"); // 监听器类型 + blbListenerRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(90); // 监听器的监听端口 + blbListenerRequest.setScheduler("Hash"); // 负载均衡算法 + + try { + appBlbClient.modifyListenerAttributes(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppSSLListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppSSLListener.java new file mode 100644 index 00000000..e18336fb --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppSSLListener.java @@ -0,0 +1,39 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleUpdateAppSSLListener { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest request = new BlbListenerRequest(); + request.setType("SSL"); // 监听器类型 + request.setBlbId("lb-99fa2577"); // 负载均衡器ID + request.setListenerPort(23); // 监听器端口 + request.setScheduler("LeastConnection"); // 调度算法 + try { + appBlbClient.modifyListenerAttributes(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppServerGroup.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppServerGroup.java new file mode 100644 index 00000000..470465ec --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppServerGroup.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleUpdateAppServerGroup { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + try { + appBlbClient.modifyAppServerGroupAttributes("lb-99fa2577", "sg-9153c2d9", "ccqSg", "ccqSgDesc"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppServerGroupPort.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppServerGroupPort.java new file mode 100644 index 00000000..922ddc09 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppServerGroupPort.java @@ -0,0 +1,40 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.AppSgPortRequest; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleUpdateAppServerGroupPort { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + AppSgPortRequest request = new AppSgPortRequest(); + request.setBlbId("lb-99fa2577"); // 负载均衡器ID + request.setSgId("sg-9153c2d9"); // 应用服务器组ID + request.setPortId("port-2b68dae3"); // 应用服务器组端口ID + request.setHealthCheck("HTTP"); // 健康检查协议 + request.setHealthCheckTimeoutInSecond(50); // 健康检查超时时间 + try { + appBlbClient.modifyAppServerGroupPortAttributes(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppTcpListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppTcpListener.java new file mode 100644 index 00000000..93aeddb8 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppTcpListener.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleUpdateAppTcpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType("TCP"); // 监听器类型 + blbListenerRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(81); // 监听器的监听端口 + blbListenerRequest.setScheduler("RoundRobin"); // 负载均衡算法 + + try { + appBlbClient.modifyListenerAttributes(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppUdpListener.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppUdpListener.java new file mode 100644 index 00000000..81ba7ab3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateAppUdpListener.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.appblb; + + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleUpdateAppUdpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType("UDP"); // 监听器类型 + blbListenerRequest.setBlbId("lb-166d3dbe"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(82); // 监听器的监听端口 + blbListenerRequest.setScheduler("RoundRobin"); // 负载均衡算法 + + try { + appBlbClient.modifyListenerAttributes(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateBlbRs.java b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateBlbRs.java new file mode 100644 index 00000000..b0978596 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/appblb/ExampleUpdateBlbRs.java @@ -0,0 +1,42 @@ +package com.baidubce.examples.blb.appblb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.AppBlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.AppBackendServer; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleUpdateBlbRs { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + AppBlbClient appBlbClient = new AppBlbClient(config); // 初始化AppBlbClient + + List backendServerList = new ArrayList(); // 后端服务器列表 + AppBackendServer appBackendServer = new AppBackendServer(); + appBackendServer.setInstanceId("i-mWyp1Bjd"); // 后端服务器实例ID + appBackendServer.setWeight(50); // 权重 + backendServerList.add(appBackendServer); + try { + appBlbClient.modifyBlbRs("lb-99fa2577", "sg-0bf84edc", backendServerList); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleAddBackendServers.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleAddBackendServers.java new file mode 100644 index 00000000..6beb48bc --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleAddBackendServers.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BackendServer; + +public class ExampleAddBackendServers { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + String blbId = "lb-081b7605"; // 所属LoadBalancer的标识符 + List backendServerList = new ArrayList(); + BackendServer backendServer = new BackendServer(); + backendServer.setInstanceId("i-VfM3kz2D"); // 后端服务器标识符 + backendServer.setWeight(50); // 后端服务器权重 + backendServerList.add(backendServer); + + try { + blbClient.addBackendServers(blbId, backendServerList); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleBindEsg.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleBindEsg.java new file mode 100644 index 00000000..473b276d --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleBindEsg.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.EsgOperateRequest; + +public class ExampleBindEsg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + EsgOperateRequest esgOperateRequest = new EsgOperateRequest(); + esgOperateRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + List enterpriseSecurityGroupIds = new ArrayList(); // 绑定的企业安全组ID列表 + enterpriseSecurityGroupIds.add("esg-tv9jcdnyz5ap"); // 绑定的企业安全组ID + esgOperateRequest.setEnterpriseSecurityGroupIds(enterpriseSecurityGroupIds); + + try { + blbClient.bindEsg(esgOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleBindSg.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleBindSg.java new file mode 100644 index 00000000..2525decf --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleBindSg.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.SgOperateRequest; + +public class ExampleBindSg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + SgOperateRequest sgOperateRequest = new SgOperateRequest(); + sgOperateRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + List securityGroupIds = new ArrayList(); // 绑定的普通安全组ID列表 + securityGroupIds.add("g-msrvz0w5kvuz"); // 绑定的普通安全组ID + sgOperateRequest.setSecurityGroupIds(securityGroupIds); + + try { + blbClient.bindSg(sgOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleBlbDetail.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleBlbDetail.java new file mode 100644 index 00000000..d136ff3a --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleBlbDetail.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbDetailRequest; +import com.baidubce.services.blb.model.BlbInstance; + +public class ExampleBlbDetail { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbDetailRequest blbDetailRequest = new BlbDetailRequest(); + blbDetailRequest.setBlbId("lb-77d58dc4"); // 要查询的LoadBalancer的标识符 + + try { + BlbInstance blbInstance = blbClient.blbDetail(blbDetailRequest); + System.out.println(blbInstance); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateBlb.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateBlb.java new file mode 100644 index 00000000..5ce7fa72 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateBlb.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.CreateBlbRequest; +import com.baidubce.services.blb.model.CreateBlbResponse; + +public class ExampleCreateBlb { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + CreateBlbRequest createBlbRequest = new CreateBlbRequest(); + createBlbRequest.setName("blb_1130_1"); // LoadBalancer的名称 + createBlbRequest.setDesc("desc info"); // LoadBalancer实例的描述 + createBlbRequest.setVpcId("vpc-syx4vuhy9z0f"); // LoadBalancer实例所属VPC的ID + createBlbRequest.setSubnetId("sbn-xgbjx1ecjf22"); // LoadBalancer实例所属子网的ID + + try { + CreateBlbResponse response = blbClient.createBlb(createBlbRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateHttpListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateHttpListener.java new file mode 100644 index 00000000..27393605 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateHttpListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.HTTP_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateHttpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(HTTP_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(90); // 监听器的监听端口 + blbListenerRequest.setBackendPort(90); // 后端服务器的监听端口 + blbListenerRequest.setScheduler("RoundRobin"); // 负载均衡算法 + + try { + blbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateHttpsListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateHttpsListener.java new file mode 100644 index 00000000..386700a0 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateHttpsListener.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.HTTPS_LISTENER; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateHttpsListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(HTTPS_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(22); // 监听器的监听端口 + blbListenerRequest.setBackendPort(22); // 后端服务器的监听端口 + blbListenerRequest.setScheduler("RoundRobin"); // 负载均衡算法 + blbListenerRequest.setCertIds(Arrays.asList("cert-btq9faddgkpb")); // 监听器要加载的证书链 + + try { + blbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateSslListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateSslListener.java new file mode 100644 index 00000000..ed51d30d --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateSslListener.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.SSL_LISTENER; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateSslListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(SSL_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(32); // 监听器的监听端口 + blbListenerRequest.setBackendPort(32); // 后端服务器的监听端口 + blbListenerRequest.setScheduler("RoundRobin"); // 负载均衡算法 + blbListenerRequest.setCertIds(Arrays.asList("cert-btq9faddgkpb")); // 监听器要加载的证书链 + + try { + blbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateTcpListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateTcpListener.java new file mode 100644 index 00000000..f6b417c9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateTcpListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.TCP_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateTcpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(TCP_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(81); // 监听器的监听端口 + blbListenerRequest.setBackendPort(81); // 后端服务器的监听端口 + blbListenerRequest.setScheduler("Hash"); // 负载均衡算法 + + try { + blbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateUdpListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateUdpListener.java new file mode 100644 index 00000000..0818a5b3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleCreateUdpListener.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.UDP_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleCreateUdpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(UDP_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(82); // 监听器的监听端口 + blbListenerRequest.setBackendPort(82); // 后端服务器的监听端口 + blbListenerRequest.setScheduler("Hash"); // 负载均衡算法 + blbListenerRequest.setHealthCheckString("\\00"); // 健康检查发送的请求字符串 + + try { + blbClient.createListener(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleDeleteBackendServers.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleDeleteBackendServers.java new file mode 100644 index 00000000..f16dbe5a --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleDeleteBackendServers.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; + +public class ExampleDeleteBackendServers { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + String blbId = "lb-081b7605"; // 所属LoadBalancer的标识符 + List backendServerList = new ArrayList(); // 所有待释放的后端服务器标识符 + backendServerList.add("i-VfM3kz2D"); // 后端服务器标识符 + + try { + blbClient.deleteBackendServers(blbId, backendServerList); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleDeleteBlb.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleDeleteBlb.java new file mode 100644 index 00000000..9bda1a6e --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleDeleteBlb.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; + +public class ExampleDeleteBlb { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + String blbId = "lb-081b7605"; // 待释放的LoadBalancer的ID + + try { + blbClient.deleteBlb(blbId); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleDeleteListeners.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleDeleteListeners.java new file mode 100644 index 00000000..7b821a14 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleDeleteListeners.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.DeleteListenerRequest; + +public class ExampleDeleteListeners { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + DeleteListenerRequest deleteListenerRequest = new DeleteListenerRequest(); + deleteListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + deleteListenerRequest.setPortList(Arrays.asList(81)); // 所有待释放的监听器的端口 + + try { + blbClient.deleteListener(deleteListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListAllListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListAllListener.java new file mode 100644 index 00000000..a154ce3b --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListAllListener.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.AllListener; +import com.baidubce.services.blb.model.ListListenerResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleListAllListener { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + try { + ListListenerResponse response = blbClient.listAllListener("lb-1ef11a87"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListBackendServerStatus.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBackendServerStatus.java new file mode 100644 index 00000000..60511de2 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBackendServerStatus.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListBackendServerStatusResponse; + +public class ExampleListBackendServerStatus { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + String blbId = "lb-081b7605"; // 所属LoadBalancer的标识符 + int listenerPort = 90; // 要查询的监听器端口 + + try { + ListBackendServerStatusResponse response = blbClient + .listBackendServerStatus(blbId, listenerPort); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListBackendServers.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBackendServers.java new file mode 100644 index 00000000..c8750b2c --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBackendServers.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListBackendServerResponse; + +public class ExampleListBackendServers { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + String blbId = "lb-081b7605"; // 所属LoadBalancer的标识符 + + try { + ListBackendServerResponse response = blbClient.listBackendServers(blbId); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListBlbEsg.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBlbEsg.java new file mode 100644 index 00000000..db3624fc --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBlbEsg.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListBlbEsgResponse; +import com.baidubce.services.blb.model.ListBlbSgRequest; + +public class ExampleListBlbEsg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + ListBlbSgRequest listBlbSgRequest = new ListBlbSgRequest(); + listBlbSgRequest.setBlbId("lb-081b7605"); // 要查询的LoadBalancer的标识符 + + try { + ListBlbEsgResponse listBlbEsgResponse = blbClient.listBlbEsg(listBlbSgRequest); + System.out.println(listBlbEsgResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListBlbSg.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBlbSg.java new file mode 100644 index 00000000..8237f76a --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBlbSg.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListBlbSgRequest; +import com.baidubce.services.blb.model.ListBlbSgResponse; + +public class ExampleListBlbSg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + ListBlbSgRequest listBlbSgRequest = new ListBlbSgRequest(); + listBlbSgRequest.setBlbId("lb-081b7605"); // 要查询的LoadBalancer的标识符 + + try { + ListBlbSgResponse listBlbSgResponse = blbClient.listBlbSg(listBlbSgRequest); + System.out.println(listBlbSgResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListBlbs.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBlbs.java new file mode 100644 index 00000000..9d157fe5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListBlbs.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListBlbRequest; +import com.baidubce.services.blb.model.ListBlbResponse; + +public class ExampleListBlbs { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + ListBlbRequest listBlbRequest = new ListBlbRequest(); + listBlbRequest.setName("blb_1129_1"); // 要查询的LoadBalancer名称 + + try { + ListBlbResponse response = blbClient.listBlbs(listBlbRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListHttpListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListHttpListener.java new file mode 100644 index 00000000..6eef6d4a --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListHttpListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.HTTP_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListListenerRequest; +import com.baidubce.services.blb.model.ListListenerResponse; + +public class ExampleListHttpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + ListListenerRequest listListenerRequest = new ListListenerRequest(); + listListenerRequest.setType(HTTP_LISTENER); + listListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + listListenerRequest.setListenerPort(90); // 要查询的监听器端口 + + try { + ListListenerResponse listListenerResponse = blbClient.listListener(listListenerRequest); + System.out.println(listListenerResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListHttpsListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListHttpsListener.java new file mode 100644 index 00000000..e0b9ac1f --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListHttpsListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.HTTPS_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListListenerRequest; +import com.baidubce.services.blb.model.ListListenerResponse; + +public class ExampleListHttpsListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + ListListenerRequest listListenerRequest = new ListListenerRequest(); + listListenerRequest.setType(HTTPS_LISTENER); + listListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + listListenerRequest.setListenerPort(22); // 要查询的监听器端口 + + try { + ListListenerResponse listListenerResponse = blbClient.listListener(listListenerRequest); + System.out.println(listListenerResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListSslListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListSslListener.java new file mode 100644 index 00000000..c7221001 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListSslListener.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListListenerResponse; +import com.baidubce.services.blb.model.SslListener; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleListSslListener { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + try { + ListListenerResponse response = blbClient.listSslListener("lb-1ef11a87"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListTcpListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListTcpListener.java new file mode 100644 index 00000000..d646e2d4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListTcpListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.TCP_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListListenerRequest; +import com.baidubce.services.blb.model.ListListenerResponse; + +public class ExampleListTcpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + ListListenerRequest listListenerRequest = new ListListenerRequest(); + listListenerRequest.setType(TCP_LISTENER); + listListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + listListenerRequest.setListenerPort(81); // 要查询的监听器端口 + + try { + ListListenerResponse listListenerResponse = blbClient.listListener(listListenerRequest); + System.out.println(listListenerResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleListUdpListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleListUdpListener.java new file mode 100644 index 00000000..82384a79 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleListUdpListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.UDP_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListListenerRequest; +import com.baidubce.services.blb.model.ListListenerResponse; + +public class ExampleListUdpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + ListListenerRequest listListenerRequest = new ListListenerRequest(); + listListenerRequest.setType(UDP_LISTENER); + listListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + listListenerRequest.setListenerPort(82); // 要查询的监听器端口 + + try { + ListListenerResponse listListenerResponse = blbClient.listListener(listListenerRequest); + System.out.println(listListenerResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleModifyBackendServerAttributes.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleModifyBackendServerAttributes.java new file mode 100644 index 00000000..0d4d5260 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleModifyBackendServerAttributes.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BackendServer; + +public class ExampleModifyBackendServerAttributes { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + String blbId = "lb-081b7605"; // 所属LoadBalancer的标识符 + List backendServerList = new ArrayList(); + BackendServer backendServer = new BackendServer(); + backendServer.setInstanceId("i-VfM3kz2D"); // 后端服务器标识符 + backendServer.setWeight(60); // 后端服务器权重 + backendServerList.add(backendServer); + + try { + blbClient.modifyBackendServerAttributes(blbId, backendServerList); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleModifyBlbAttributes.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleModifyBlbAttributes.java new file mode 100644 index 00000000..7b1cd620 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleModifyBlbAttributes.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ModifyBlbAttributesRequest; + +public class ExampleModifyBlbAttributes { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + ModifyBlbAttributesRequest modifyBlbAttributesRequest = new ModifyBlbAttributesRequest(); + modifyBlbAttributesRequest.setBlbId("lb-77d58dc4"); // 待更新的LoadBalancer的ID + modifyBlbAttributesRequest.setName("blb_1129_1_1"); // LoadBalancer的名称 + + try { + blbClient.modifyBlbAttributes(modifyBlbAttributesRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleUnBindEsg.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleUnBindEsg.java new file mode 100644 index 00000000..8f8ebf85 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleUnBindEsg.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.EsgOperateRequest; + +public class ExampleUnBindEsg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + EsgOperateRequest esgOperateRequest = new EsgOperateRequest(); + esgOperateRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + List enterpriseSecurityGroupIds = new ArrayList(); // 解绑的企业安全组ID列表 + enterpriseSecurityGroupIds.add("esg-tv9jcdnyz5ap"); // 解绑的企业安全组ID + esgOperateRequest.setEnterpriseSecurityGroupIds(enterpriseSecurityGroupIds); + + try { + blbClient.unBindEsg(esgOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleUnBindSg.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleUnBindSg.java new file mode 100644 index 00000000..a3d0619d --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleUnBindSg.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.SgOperateRequest; + +public class ExampleUnBindSg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + SgOperateRequest sgOperateRequest = new SgOperateRequest(); + sgOperateRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + List securityGroupIds = new ArrayList(); // 解绑的普通安全组ID列表 + securityGroupIds.add("g-msrvz0w5kvuz"); // 解绑的普通安全组ID + sgOperateRequest.setSecurityGroupIds(securityGroupIds); + + try { + blbClient.unBindSg(sgOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateHttpListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateHttpListener.java new file mode 100644 index 00000000..e67728db --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateHttpListener.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.HTTP_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleUpdateHttpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(HTTP_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(90); // 监听器的监听端口 + blbListenerRequest.setBackendPort(91); // 后端服务器的监听端口 + + try { + blbClient.modifyListenerAttributes(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateHttpsListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateHttpsListener.java new file mode 100644 index 00000000..ed578d08 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateHttpsListener.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.HTTPS_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleUpdateHttpsListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(HTTPS_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(22); // 监听器的监听端口 + blbListenerRequest.setBackendPort(23); // 后端服务器的监听端口 + + try { + blbClient.modifyListenerAttributes(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateLoadBalancerAcl.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateLoadBalancerAcl.java new file mode 100644 index 00000000..850c1b43 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateLoadBalancerAcl.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.UpdateLoadBalancerAclRequest; + +public class ExampleUpdateLoadBalancerAcl { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + UpdateLoadBalancerAclRequest updateLoadBalancerAclRequest = new UpdateLoadBalancerAclRequest(); + updateLoadBalancerAclRequest.setBlbId("lb-d20d573f"); // 待更新的LoadBalancer的ID + updateLoadBalancerAclRequest.setSupportAcl(true); // 是否支持ACL + + try { + blbClient.updateLoadBalancerAcl(updateLoadBalancerAclRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateSslListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateSslListener.java new file mode 100644 index 00000000..5255effc --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateSslListener.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.SSL_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleUpdateSslListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(SSL_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(32); // 监听器的监听端口 + blbListenerRequest.setBackendPort(33); // 后端服务器的监听端口 + + try { + blbClient.modifyListenerAttributes(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateTcpListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateTcpListener.java new file mode 100644 index 00000000..9a0d23cd --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateTcpListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.TCP_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleUpdateTcpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(TCP_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(81); // 监听器的监听端口 + blbListenerRequest.setBackendPort(82); // 后端服务器的监听端口 + blbListenerRequest.setScheduler("Hash"); // 负载均衡算法 + + try { + blbClient.modifyListenerAttributes(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateUdpListener.java b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateUdpListener.java new file mode 100644 index 00000000..7a64b100 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/blb/ExampleUpdateUdpListener.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.blb.blb; + +import static com.baidubce.services.blb.model.ListenerConstant.UDP_LISTENER; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.BlbListenerRequest; + +public class ExampleUpdateUdpListener { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.su.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + BlbListenerRequest blbListenerRequest = new BlbListenerRequest(); + blbListenerRequest.setType(UDP_LISTENER); + blbListenerRequest.setBlbId("lb-081b7605"); // 所属LoadBalancer的标识符 + blbListenerRequest.setListenerPort(82); // 监听器的监听端口 + blbListenerRequest.setBackendPort(83); // 后端服务器的监听端口 + blbListenerRequest.setScheduler("Hash"); // 负载均衡算法 + + try { + blbClient.modifyListenerAttributes(blbListenerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/blb/ipv6blb/ExampleCreateIpv6Blb.java b/src/main/java/com/baidubce/examples/blb/ipv6blb/ExampleCreateIpv6Blb.java new file mode 100644 index 00000000..aea0af95 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/ipv6blb/ExampleCreateIpv6Blb.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.blb.ipv6blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.CreateBlbResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleCreateIpv6Blb { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + try { + CreateBlbResponse response = blbClient.createIpv6Blb("ipv6blb-test", + "ipv6blb-desc", "vpc-gg92ixpgmpw7", "sbn-ej7r34w74p69"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/blb/ipv6blb/ExampleListIpv6Blb.java b/src/main/java/com/baidubce/examples/blb/ipv6blb/ExampleListIpv6Blb.java new file mode 100644 index 00000000..e69b7f76 --- /dev/null +++ b/src/main/java/com/baidubce/examples/blb/ipv6blb/ExampleListIpv6Blb.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.blb.ipv6blb; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.blb.BlbClient; +import com.baidubce.services.blb.BlbClientConfiguration; +import com.baidubce.services.blb.model.ListBlbResponse; + +/** + * @author chenchangquan + * @date 2023/11/28 + */ +public class ExampleListIpv6Blb { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BlbClientConfiguration config = new BlbClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BlbClient blbClient = new BlbClient(config); // 初始化BlbClient + + try { + ListBlbResponse response = blbClient.listIpv6Blbs("", "", "", ""); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleAttachInstance.java b/src/main/java/com/baidubce/examples/csn/ExampleAttachInstance.java new file mode 100644 index 00000000..82353c38 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleAttachInstance.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.AttachInstanceRequest; + +import java.util.UUID; + +public class ExampleAttachInstance { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnId = "csn-b65m2hez6h60iwa1"; // 云智能网ID + String instanceAccountId = "Your Instance Account ID"; // 跨账号加载网络实例场景下,网络实例所属账号的ID + AttachInstanceRequest attachInstanceRequest = AttachInstanceRequest.builder() + .instanceType("vpc") // 加载的实例类型,取值 [vpc|channel|bec_vpc],分别表示私有网络、专线通道、边缘网络 + .instanceId("vpc-33ajnsvj41r6") // 加载的实例ID + .instanceRegion("bj") // 加载的实例所属的region + .instanceAccountId(instanceAccountId) + .build(); + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.attachInstance(csnId, attachInstanceRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleBindCsnBp.java b/src/main/java/com/baidubce/examples/csn/ExampleBindCsnBp.java new file mode 100644 index 00000000..895e79b8 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleBindCsnBp.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.BindCsnBpRequest; + +import java.util.UUID; + +public class ExampleBindCsnBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-jm5sb75yz4j8"; // 带宽包的ID + BindCsnBpRequest bindCsnBpRequest = BindCsnBpRequest.builder() + .csnId("csn-b65m2hez6h60iwa1") // 云智能网ID + .build(); + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.bindCsnBp(csnBpId, bindCsnBpRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleCreateAssociation.java b/src/main/java/com/baidubce/examples/csn/ExampleCreateAssociation.java new file mode 100644 index 00000000..33bbd3d3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleCreateAssociation.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.CreateAssociationRequest; + +import java.util.UUID; + +public class ExampleCreateAssociation { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnRtId = "csnRt-szxfb2vcr62x41ui"; // 云智能网路由表的ID + CreateAssociationRequest createAssociationRequest = CreateAssociationRequest.builder() + .attachId("tgwAttach-s8bcrz57d3mpv6x8") // 网络实例在云智能网中的身份ID + .description("create csn association description.") // 描述 + .build(); + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.createAssociation(csnRtId, createAssociationRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleCreateCsn.java b/src/main/java/com/baidubce/examples/csn/ExampleCreateCsn.java new file mode 100644 index 00000000..6dd193a5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleCreateCsn.java @@ -0,0 +1,43 @@ +package com.baidubce.examples.csn; + +import java.util.UUID; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.CreateCsnRequest; +import com.baidubce.services.csn.model.CreateCsnResponse; +import com.baidubce.services.tag.model.Tag; +import com.google.common.collect.Lists; + +public class ExampleCreateCsn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + CreateCsnRequest request = new CreateCsnRequest(); + request.setName("javaSdkTest"); // 云智能网的名称 + request.setDescription("java sdk test"); // 云智能网的描述 + + Tag tag = new Tag(); + tag.setTagKey("tagKey"); + tag.setTagValue("tagValue"); + request.setTags(Lists.newArrayList(tag)); // 云智能网的标签 + + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + CreateCsnResponse response = csnClient.createCsn(request, clientToken); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleCreateCsnBp.java b/src/main/java/com/baidubce/examples/csn/ExampleCreateCsnBp.java new file mode 100644 index 00000000..39b21fb3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleCreateCsnBp.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.CreateCsnBpRequest; +import com.baidubce.services.csn.model.CreateCsnBpResponse; +import com.baidubce.services.tag.model.Tag; +import com.google.common.collect.Lists; + +import java.util.UUID; + +public class ExampleCreateCsnBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + // 预付费购买csnBp + // 保留信息,支付方式为后付费时不需要设置,预付费时必须设置 + CreateCsnBpRequest.Billing.Reservation reservation = CreateCsnBpRequest.Billing.Reservation.builder() + .reservationTimeUnit("month") // 时间单位,当前仅支持按月,取值month + .reservationLength(1) // 时长,[1,2,3,4,5,6,7,8,9,12,24,36] + .build(); + CreateCsnBpRequest.Billing prepaidBilling = CreateCsnBpRequest.Billing.builder() + .paymentTiming("Prepaid") // 付款时间,预支付(Prepaid)和后支付(Postpaid) + .reservation(reservation) // 保留信息 + .build(); + // 带宽包的互通类型,取值 [ center | center-edge | edge-edge ],分别表示云间互通、云边互通、边边互通,默认为云间互通 + String interWorkType = "center"; + CreateCsnBpRequest prepaidCreateCsnBpRequest = CreateCsnBpRequest.builder() + .name("prepaidCsnBpTest") // 带宽包的名称,不能为空 + .bandwidth(100) // 带宽包的带宽值,最大值为10000 + .geographicA("China") // 网络实例所属的区域。取值 [ China | Asia-Pacific ],分别表示中国大陆、亚太区域 + .geographicB("China") // 另一个网络实例所属的区域。取值 [ China | Asia-Pacific ],分别表示中国大陆、亚太区域 + .interworkType(interWorkType) // 带宽包的互通类型 + .billing(prepaidBilling) // 计费信息 + .tags(Lists.newArrayList(new Tag().withTagKey("test").withTagValue("test"))) // 标签信息,可为空 + .build(); + String prepaidClientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + CreateCsnBpResponse prepaidCsnBp = csnClient.createCsnBp(prepaidCreateCsnBpRequest, prepaidClientToken); + System.out.println("prepaidCsnBp = " + prepaidCsnBp); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + // 后付费购买csnBp + CreateCsnBpRequest.Billing postpaidBilling = CreateCsnBpRequest.Billing.builder() + .paymentTiming("Postpaid") // 付款时间,预支付(Prepaid)和后支付(Postpaid) + .build(); + CreateCsnBpRequest postpaidCreateCsnBpRequest = CreateCsnBpRequest.builder() + .name("postpaidCsnBpTest") // 带宽包的名称,不能为空 + .bandwidth(100) // 带宽包的带宽值,最大值为10000 + .geographicA("China") // 网络实例所属的区域。取值 [ China | Asia-Pacific ],分别表示中国大陆、亚太区域 + .geographicB("China") // 另一个网络实例所属的区域。取值 [ China | Asia-Pacific ],分别表示中国大陆、亚太区域 + .interworkType(interWorkType) // 带宽包的互通类型 + .billing(postpaidBilling) + .tags(Lists.newArrayList(new Tag().withTagKey("test").withTagValue("test"))) // 标签信息,可为空 + .build(); + String postpaidClientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + CreateCsnBpResponse postpaidCsnBp = csnClient.createCsnBp(postpaidCreateCsnBpRequest, postpaidClientToken); + System.out.println("postpaidCsnBp = " + postpaidCsnBp); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleCreateCsnBpLimit.java b/src/main/java/com/baidubce/examples/csn/ExampleCreateCsnBpLimit.java new file mode 100644 index 00000000..ae00d22f --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleCreateCsnBpLimit.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.CreateCsnBpLimitRequest; + +import java.util.UUID; + +public class ExampleCreateCsnBpLimit { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-jm5sb75yz4j8"; // 带宽包的ID + CreateCsnBpLimitRequest createCsnBpLimitRequest = CreateCsnBpLimitRequest.builder() + .localRegion("bj") // 地域带宽的本端region,云边互通场景中表示云端region + .peerRegion("bd") // 地域带宽的对端region,云边互通场景中表示边缘region + .bandwidth(10) // 地域带宽的带宽值 + .build(); + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.createCsnBpLimit(csnBpId, createCsnBpLimitRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleCreatePropagation.java b/src/main/java/com/baidubce/examples/csn/ExampleCreatePropagation.java new file mode 100644 index 00000000..4e7acbc6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleCreatePropagation.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import java.util.UUID; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.CreatePropagationRequest; + +public class ExampleCreatePropagation { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnRtId = "csnRt-bhnis7ubpgnmyk5f"; // 云智能网路由表的ID + CreatePropagationRequest createPropagationRequest = new CreatePropagationRequest(); + createPropagationRequest.setAttachId("tgwAttach-5ttgra63p7v4q69z"); // 网络实例在云智能网中的身份的ID + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.createPropagation(csnRtId, createPropagationRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleCreateRouteRule.java b/src/main/java/com/baidubce/examples/csn/ExampleCreateRouteRule.java new file mode 100644 index 00000000..2abc87b0 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleCreateRouteRule.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import java.util.UUID; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.CreateRouteRuleRequest; + +public class ExampleCreateRouteRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnRtId = "csnRt-bhnis7ubpgnmyk5f"; // 云智能网路由表的ID + CreateRouteRuleRequest createRouteRuleRequest = new CreateRouteRuleRequest(); + createRouteRuleRequest.setAttachId("tgwAttach-5ttgra63p7v4q69z"); // 网络实例在云智能网中的身份的ID + createRouteRuleRequest.setDestAddress("0.0.0.0/0"); // 路由的目的地址 + createRouteRuleRequest.setRouteType("custom"); // 路由类型 + String clientToken = UUID.randomUUID().toString(); + + try { + csnClient.createRouteRule(csnRtId, createRouteRuleRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleCsnBpPrice.java b/src/main/java/com/baidubce/examples/csn/ExampleCsnBpPrice.java new file mode 100644 index 00000000..c116d3b3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleCsnBpPrice.java @@ -0,0 +1,45 @@ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.CreateCsnBpRequest; +import com.baidubce.services.csn.model.CsnBpPriceRequest; +import com.baidubce.services.csn.model.CsnBpPriceResponse; + +public class ExampleCsnBpPrice { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + CsnBpPriceRequest request = new CsnBpPriceRequest(); + request.setName("test_prepay"); + request.setBandwidth(10); + request.setGeographicA("China"); + request.setGeographicB("China"); + + CreateCsnBpRequest.Billing.Reservation reservation = CreateCsnBpRequest.Billing.Reservation.builder() + .reservationTimeUnit("month") // 时间单位,当前仅支持按月,取值month + .reservationLength(1) // 时长,[1,2,3,4,5,6,7,8,9,12,24,36] + .build(); + CreateCsnBpRequest.Billing billing = CreateCsnBpRequest.Billing.builder() + .paymentTiming("Prepaid") // 付款时间,预支付(Prepaid)和后支付(Postpaid) + .billingMethod("ByBandwidth") // 计费方式 + .reservation(reservation) // 保留信息 + .build(); + request.setBilling(billing); + + try { + CsnBpPriceResponse response = csnClient.csnBpPrice(request); // 获取价格 + System.out.println("price = " + response); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleDeleteAssociation.java b/src/main/java/com/baidubce/examples/csn/ExampleDeleteAssociation.java new file mode 100644 index 00000000..d8ed06f5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleDeleteAssociation.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; + +import java.util.UUID; + +public class ExampleDeleteAssociation { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnRtId = "csnRt-szxfb2vcr62x41ui"; // 云智能网路由表的ID + String attachId = "tgwAttach-s8bcrz57d3mpv6x8"; // 网络实例在云智能网中的身份ID + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.deleteAssociation(csnRtId, attachId, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleDeleteCsn.java b/src/main/java/com/baidubce/examples/csn/ExampleDeleteCsn.java new file mode 100644 index 00000000..62a3f996 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleDeleteCsn.java @@ -0,0 +1,30 @@ +package com.baidubce.examples.csn; + +import java.util.UUID; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; + +public class ExampleDeleteCsn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + String csnId = "csn-2jssjbhvyd8v1gxn"; // 云智能网ID + + try { + csnClient.deleteCsn(csnId, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleDeleteCsnBp.java b/src/main/java/com/baidubce/examples/csn/ExampleDeleteCsnBp.java new file mode 100644 index 00000000..b8486c39 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleDeleteCsnBp.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; + +import java.util.UUID; + +public class ExampleDeleteCsnBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-59i18xrv382t"; // 带宽包的ID + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.deleteCsnBp(csnBpId, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleDeleteCsnBpLimit.java b/src/main/java/com/baidubce/examples/csn/ExampleDeleteCsnBpLimit.java new file mode 100644 index 00000000..2be49d21 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleDeleteCsnBpLimit.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.DeleteCsnBpLimitRequest; + +import java.util.UUID; + +public class ExampleDeleteCsnBpLimit { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-jm5sb75yz4j8"; // 带宽包的ID + DeleteCsnBpLimitRequest deleteCsnBpLimitRequest = DeleteCsnBpLimitRequest.builder() + .localRegion("bj") // 地域带宽的本端region + .peerRegion("bd") // 地域带宽的对端region + .build(); + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.deleteCsnBpLimit(csnBpId, deleteCsnBpLimitRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleDeletePropagation.java b/src/main/java/com/baidubce/examples/csn/ExampleDeletePropagation.java new file mode 100644 index 00000000..60a6388b --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleDeletePropagation.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import java.util.UUID; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; + +public class ExampleDeletePropagation { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnRtId = "csnRt-bhnis7ubpgnmyk5f"; // 云智能网路由表的ID + String attachId = "tgwAttach-5ttgra63p7v4q69z"; // 网络实例在云智能网中的身份的ID + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.deletePropagation(csnRtId, attachId, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleDeleteRouteRule.java b/src/main/java/com/baidubce/examples/csn/ExampleDeleteRouteRule.java new file mode 100644 index 00000000..c934e5d7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleDeleteRouteRule.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import java.util.UUID; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; + +public class ExampleDeleteRouteRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnRtId = "csnRt-bhnis7ubpgnmyk5f"; // 路由表的ID + String csnRtRuleId = "bfe6294f-1058-421c-8759-0973589a4442"; // 路由条目的ID + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.deleteRouteRule(csnRtId, csnRtRuleId, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleDetachInstance.java b/src/main/java/com/baidubce/examples/csn/ExampleDetachInstance.java new file mode 100644 index 00000000..fce161c3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleDetachInstance.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.DetachInstanceRequest; + +import java.util.UUID; + +public class ExampleDetachInstance { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnId = "csn-b65m2hez6h60iwa1"; // 云智能网ID + String instanceAccountId = "Your Instance Account ID"; // 跨账号卸载网络实例场景下,网络实例所属账号的ID + DetachInstanceRequest detachInstanceRequest = DetachInstanceRequest.builder() + .instanceType("vpc") // 卸载的实例类型,取值 [vpc|channel|bec_vpc],分别表示私有网络、专线通道、边缘网络 + .instanceId("vpc-33ajnsvj41r6") // 卸载的实例ID + .instanceRegion("bj") // 卸载的实例所属的region + .instanceAccountId(instanceAccountId) + .build(); + String clientToken = UUID.randomUUID().toString(); + + try { + csnClient.detachInstance(csnId, detachInstanceRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleGetCsn.java b/src/main/java/com/baidubce/examples/csn/ExampleGetCsn.java new file mode 100644 index 00000000..cb1fb58b --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleGetCsn.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.GetCsnResponse; + +public class ExampleGetCsn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnId = "csn-b65m2hez6h60iwa1"; // 云智能网ID + + try { + GetCsnResponse getCsnResponse = csnClient.getCsn(csnId); + System.out.println("getCsnResponse = " + getCsnResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleGetCsnBp.java b/src/main/java/com/baidubce/examples/csn/ExampleGetCsnBp.java new file mode 100644 index 00000000..27a0e579 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleGetCsnBp.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.GetCsnBpResponse; + +public class ExampleGetCsnBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-0wehdvzn9hid"; // 带宽包的ID + + try { + GetCsnBpResponse csnBpDetail = csnClient.getCsnBp(csnBpId); + System.out.println("csnBpDetail = " + csnBpDetail); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListAssociation.java b/src/main/java/com/baidubce/examples/csn/ExampleListAssociation.java new file mode 100644 index 00000000..cd173b1b --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListAssociation.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListAssociationResponse; + +public class ExampleListAssociation { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnRtId = "csnRt-bhnis7ubpgnmyk5f"; // 云智能网路由表的ID + + try { + ListAssociationResponse response = csnClient.listAssociation(csnRtId); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListCsn.java b/src/main/java/com/baidubce/examples/csn/ExampleListCsn.java new file mode 100644 index 00000000..5827d030 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListCsn.java @@ -0,0 +1,30 @@ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListCsnResponse; + +public class ExampleListCsn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String marker = "csn-2jssjbhvyd8v1gxn"; // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + int maxKeys = 10; // 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + + try { + ListCsnResponse response = csnClient.listCsn(marker, maxKeys); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListCsnBp.java b/src/main/java/com/baidubce/examples/csn/ExampleListCsnBp.java new file mode 100644 index 00000000..40a5b317 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListCsnBp.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListCsnBpResponse; + +public class ExampleListCsnBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String marker = ""; // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + Integer maxKeys = 10; // 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + + try { + ListCsnBpResponse listCsnBpResponse = csnClient.listCsnBp(marker, maxKeys); + System.out.println("listCsnBpResponse = " + listCsnBpResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListCsnBpLimit.java b/src/main/java/com/baidubce/examples/csn/ExampleListCsnBpLimit.java new file mode 100644 index 00000000..a95b5dc3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListCsnBpLimit.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListCsnBpLimitResponse; + +public class ExampleListCsnBpLimit { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-jm5sb75yz4j8"; // 带宽包的ID + + try { + ListCsnBpLimitResponse listCsnBpLimitResponse = csnClient.listCsnBpLimit(csnBpId); + System.out.println("listCsnBpLimitResponse = " + listCsnBpLimitResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListCsnBpLimitByCsnId.java b/src/main/java/com/baidubce/examples/csn/ExampleListCsnBpLimitByCsnId.java new file mode 100644 index 00000000..5dbd027c --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListCsnBpLimitByCsnId.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListCsnBpLimitByCsnIdResponse; + +public class ExampleListCsnBpLimitByCsnId { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnId = "csn-b65m2hez6h60iwa1"; // 云智能网的ID + + try { + ListCsnBpLimitByCsnIdResponse listCsnBpLimitByCsnIdResponse = csnClient.listCsnBpLimitByCsnId(csnId); + System.out.println("listCsnBpLimitByCsnIdResponse = " + listCsnBpLimitByCsnIdResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListInstance.java b/src/main/java/com/baidubce/examples/csn/ExampleListInstance.java new file mode 100644 index 00000000..8124937c --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListInstance.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListInstanceResponse; + +public class ExampleListInstance { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String testCsnId = "csn-b65m2hez6h60iwa1"; + String marker = ""; // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + Integer maxKeys = 10; // 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + + try { + ListInstanceResponse listInstanceResponse = csnClient.listInstance(testCsnId, marker, maxKeys); + System.out.println("listInstanceResponse = " + listInstanceResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListPropagation.java b/src/main/java/com/baidubce/examples/csn/ExampleListPropagation.java new file mode 100644 index 00000000..07a24d45 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListPropagation.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListPropagationResponse; + +public class ExampleListPropagation { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnRtId = "csnRt-bhnis7ubpgnmyk5f"; // 云智能网路由表的ID + + try { + ListPropagationResponse response = csnClient.listPropagation(csnRtId); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListRouteRule.java b/src/main/java/com/baidubce/examples/csn/ExampleListRouteRule.java new file mode 100644 index 00000000..2e65ef22 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListRouteRule.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListRouteRuleResponse; + +public class ExampleListRouteRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnRtId = "csnRt-bhnis7ubpgnmyk5f"; // 云智能网路由表的ID + String marker = ""; // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + Integer maxKeys = 10; // 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + + try { + ListRouteRuleResponse response = csnClient.listRouteRule(csnRtId, marker, maxKeys); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListRouteTable.java b/src/main/java/com/baidubce/examples/csn/ExampleListRouteTable.java new file mode 100644 index 00000000..3043b8f1 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListRouteTable.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListRouteTableResponse; + +public class ExampleListRouteTable { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnId = "csn-2qi3430b3vqbcfgd"; // 云智能网的ID + String marker = ""; // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + Integer maxKeys = 10; // 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + + try { + ListRouteTableResponse response = csnClient.listRouteTable(csnId, marker, maxKeys); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListTgw.java b/src/main/java/com/baidubce/examples/csn/ExampleListTgw.java new file mode 100644 index 00000000..101d04ac --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListTgw.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListTgwResponse; + +public class ExampleListTgw { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnId = "csn-2qi3430b3vqbcfgd"; // 云智能网的ID + String marker = ""; // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + Integer maxKeys = 10; // 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + + try { + ListTgwResponse response = csnClient.listTgw(csnId, marker, maxKeys); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleListTgwRule.java b/src/main/java/com/baidubce/examples/csn/ExampleListTgwRule.java new file mode 100644 index 00000000..d6b2cd63 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleListTgwRule.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ListTgwRuleResponse; + +public class ExampleListTgwRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnId = "csn-2qi3430b3vqbcfgd"; // 云智能网的ID + String tgwId = "tgw-5yvyjar8bi32dwru"; // TGW的ID + String marker = ""; // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + Integer maxKeys = 10; // 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + + try { + ListTgwRuleResponse response = csnClient.listTgwRule(csnId, tgwId, marker, maxKeys); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleResizeCsnBp.java b/src/main/java/com/baidubce/examples/csn/ExampleResizeCsnBp.java new file mode 100644 index 00000000..4ac75dd2 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleResizeCsnBp.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.ResizeCsnBpRequest; + +import java.util.UUID; + +public class ExampleResizeCsnBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-jm5sb75yz4j8"; // 带宽包的ID + ResizeCsnBpRequest resizeCsnBpRequest = ResizeCsnBpRequest.builder() + .bandwidth(50) // 升降级的带宽值,最大值为10000 + .build(); + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.resizeCsnBp(csnBpId, resizeCsnBpRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleUnbindCsnBp.java b/src/main/java/com/baidubce/examples/csn/ExampleUnbindCsnBp.java new file mode 100644 index 00000000..dd5f4475 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleUnbindCsnBp.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.UnbindCsnBpRequest; + +import java.util.UUID; + +public class ExampleUnbindCsnBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-jm5sb75yz4j8"; // 带宽包的ID + UnbindCsnBpRequest unbindCsnBpRequest = UnbindCsnBpRequest.builder() + .csnId("csn-b65m2hez6h60iwa1") // 云智能网ID + .build(); + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.unbindCsnBp(csnBpId, unbindCsnBpRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleUpdateCsn.java b/src/main/java/com/baidubce/examples/csn/ExampleUpdateCsn.java new file mode 100644 index 00000000..43dc11c1 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleUpdateCsn.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.csn; + +import java.util.UUID; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.UpdateCsnRequest; + +public class ExampleUpdateCsn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + UpdateCsnRequest request = new UpdateCsnRequest(); + request.setName("javaSdkTest"); // 云智能网的名称 + request.setDescription("java sdk test"); // 云智能网的描述 + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + String csnId = "csn-2jssjbhvyd8v1gxn"; // 云智能网ID + + try { + csnClient.updateCsn(csnId, request, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleUpdateCsnBp.java b/src/main/java/com/baidubce/examples/csn/ExampleUpdateCsnBp.java new file mode 100644 index 00000000..f8ca9818 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleUpdateCsnBp.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.UpdateCsnBpRequest; + +import java.util.UUID; + +public class ExampleUpdateCsnBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-0wehdvzn9hid"; // 带宽包的ID + UpdateCsnBpRequest updateCsnBpRequest = UpdateCsnBpRequest.builder() + .name("updateNameCsnBpTest") // 带宽包名称 + .build(); + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.updateCsnBp(csnBpId, updateCsnBpRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleUpdateCsnBpLimit.java b/src/main/java/com/baidubce/examples/csn/ExampleUpdateCsnBpLimit.java new file mode 100644 index 00000000..f342e064 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleUpdateCsnBpLimit.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.UpdateCsnBpLimitRequest; + +import java.util.UUID; + +public class ExampleUpdateCsnBpLimit { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnBpId = "csnBp-jm5sb75yz4j8"; // 带宽包的ID + UpdateCsnBpLimitRequest updateCsnBpLimitRequest = UpdateCsnBpLimitRequest.builder() + .localRegion("bj") // 地域带宽的本端region,该值不能改变 + .peerRegion("gz") // 地域带宽的对端region,该值不能改变 + .bandwidth(15) // 更新的地域带宽的带宽值 + .build(); + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.updateCsnBpLimit(csnBpId, updateCsnBpLimitRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/csn/ExampleUpdateTgw.java b/src/main/java/com/baidubce/examples/csn/ExampleUpdateTgw.java new file mode 100644 index 00000000..17035dd8 --- /dev/null +++ b/src/main/java/com/baidubce/examples/csn/ExampleUpdateTgw.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.csn; + +import java.util.UUID; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.csn.CsnClient; +import com.baidubce.services.csn.model.UpdateTgwRequest; + +public class ExampleUpdateTgw { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "csn.baidubce.com"; // CSN服务对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + CsnClient csnClient = new CsnClient(config); // 初始化CsnClient + + String csnId = "csn-2qi3430b3vqbcfgd"; // 云智能网的ID + String tgwId = "tgw-5yvyjar8bi32dwru"; // TGW实例的ID + UpdateTgwRequest updateTgwRequest = new UpdateTgwRequest(); + updateTgwRequest.setName("tgw_1"); // TGW的名称 + updateTgwRequest.setDescription("desc"); // TGW的描述信息 + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + + try { + csnClient.updateTgw(csnId, tgwId, updateTgwRequest, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleAddLineGroup.java b/src/main/java/com/baidubce/examples/dns/ExampleAddLineGroup.java new file mode 100644 index 00000000..454f5b90 --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleAddLineGroup.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.AddLineGroupRequest; + +import java.util.Arrays; + +public class ExampleAddLineGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + AddLineGroupRequest request = new AddLineGroupRequest(); + request.setName("ccqLine"); // 线路组名称 + request.setLines(Arrays.asList("yunnan.ct", "henan.ct")); // 解析线路 + + + try { + dnsClient.addLineGroup(request, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleAddRecordOnZone.java b/src/main/java/com/baidubce/examples/dns/ExampleAddRecordOnZone.java new file mode 100644 index 00000000..a511f5ed --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleAddRecordOnZone.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.CreateRecordRequest; + +public class ExampleAddRecordOnZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String zoneName = "javaSdk.com"; // 域名名称 + CreateRecordRequest request = new CreateRecordRequest(); + request.setRr("www"); // 主机记录 + request.setType("A"); // 解析记录类型 + request.setValue("1.1.1.1"); // 记录值 + + try { + dnsClient.createRecord(zoneName, request, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleCreatePaidZone.java b/src/main/java/com/baidubce/examples/dns/ExampleCreatePaidZone.java new file mode 100644 index 00000000..2165355c --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleCreatePaidZone.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.CreatePaidZoneRequest; + +import java.util.Arrays; + +public class ExampleCreatePaidZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + CreatePaidZoneRequest request = new CreatePaidZoneRequest(); + CreatePaidZoneRequest.Billing billing = new CreatePaidZoneRequest.Billing(); + billing.setPaymentTiming("Prepaid"); // 计费方式,预付费 + CreatePaidZoneRequest.Billing.Reservation reservation = new CreatePaidZoneRequest.Billing.Reservation(); + reservation.setReservationLength(1); // 计费时长 + billing.setReservation(reservation); + request.setNames(Arrays.asList("javaSdkPaid.com")); // 域名名称 + request.setBilling(billing); + request.setProductVersion("discount"); // 购买的产品版本,普惠版(“discount”)、企业版(“flagship”) + + try { + dnsClient.createPaidZone(request, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleCreateZone.java b/src/main/java/com/baidubce/examples/dns/ExampleCreateZone.java new file mode 100644 index 00000000..e3011d6e --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleCreateZone.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.CreateZoneRequest; + +public class ExampleCreateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + CreateZoneRequest request = new CreateZoneRequest(); + request.setName("javaSdk.com"); // 域名名称 + + try { + dnsClient.createZone(request, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleDeleteLineGroup.java b/src/main/java/com/baidubce/examples/dns/ExampleDeleteLineGroup.java new file mode 100644 index 00000000..09cd231a --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleDeleteLineGroup.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; + +public class ExampleDeleteLineGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String lineId = "6166"; // 线路的id + + try { + dnsClient.deleteLineGroup(lineId, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleDeleteRecordOfZone.java b/src/main/java/com/baidubce/examples/dns/ExampleDeleteRecordOfZone.java new file mode 100644 index 00000000..76653db2 --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleDeleteRecordOfZone.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; + +public class ExampleDeleteRecordOfZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String zoneName = "javaSdk.com"; // 域名名称 + String recordId = "48554"; // 记录的id + + try { + dnsClient.deleteRecord(zoneName, recordId, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleDeleteZone.java b/src/main/java/com/baidubce/examples/dns/ExampleDeleteZone.java new file mode 100644 index 00000000..4242bf7c --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleDeleteZone.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; + +public class ExampleDeleteZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String zoneName = "javasdk.com"; // 域名名称 + + try { + dnsClient.deleteZone(zoneName, null); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleDisableRecordOfZone.java b/src/main/java/com/baidubce/examples/dns/ExampleDisableRecordOfZone.java new file mode 100644 index 00000000..d27d7eb0 --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleDisableRecordOfZone.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; + +public class ExampleDisableRecordOfZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String zoneName = "javaSdk.com"; // 域名名称 + String recordId = "48554"; // 记录的id + + try { + dnsClient.updateRecordDisable(zoneName, recordId, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleEnableRecordOfZone.java b/src/main/java/com/baidubce/examples/dns/ExampleEnableRecordOfZone.java new file mode 100644 index 00000000..f24111d4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleEnableRecordOfZone.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; + +public class ExampleEnableRecordOfZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String zoneName = "javaSdk.com"; // 域名名称 + String recordId = "48554"; // 记录的id + + try { + dnsClient.updateRecordEnable(zoneName, recordId, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleListLineGroup.java b/src/main/java/com/baidubce/examples/dns/ExampleListLineGroup.java new file mode 100644 index 00000000..2dca8544 --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleListLineGroup.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.ListLineGroupResponse; + +public class ExampleListLineGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + try { + ListLineGroupResponse response = dnsClient.listLineGroup("", 10); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleListRecordOfZone.java b/src/main/java/com/baidubce/examples/dns/ExampleListRecordOfZone.java new file mode 100644 index 00000000..53f5ef54 --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleListRecordOfZone.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.ListRecordResponse; + +public class ExampleListRecordOfZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String zoneName = "javaSdk.com"; // 域名名称 + + try { + ListRecordResponse response = dnsClient.listRecord(zoneName, "", "", "", 10); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleListZone.java b/src/main/java/com/baidubce/examples/dns/ExampleListZone.java new file mode 100644 index 00000000..b4487294 --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleListZone.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.ListZoneResponse; + +public class ExampleListZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + try { + ListZoneResponse response = dnsClient.listZone("", "", 100); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleRenewZone.java b/src/main/java/com/baidubce/examples/dns/ExampleRenewZone.java new file mode 100644 index 00000000..80ef01cb --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleRenewZone.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.RenewZoneRequest; + +public class ExampleRenewZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String zoneName = "javaSdk.com"; // 域名名称 + RenewZoneRequest request = new RenewZoneRequest(); + RenewZoneRequest.Billing billing = new RenewZoneRequest.Billing(); + RenewZoneRequest.Billing.Reservation reservation = new RenewZoneRequest.Billing.Reservation(); + reservation.setReservationLength(1); // 续费时长 + billing.setReservation(reservation); + request.setBilling(billing); + + try { + dnsClient.renewZone(zoneName, request, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleUpdateLineGroup.java b/src/main/java/com/baidubce/examples/dns/ExampleUpdateLineGroup.java new file mode 100644 index 00000000..770bdb5c --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleUpdateLineGroup.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.UpdateLineGroupRequest; + +import java.util.Arrays; + +public class ExampleUpdateLineGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String lineId = "6166"; // 线路的id + UpdateLineGroupRequest request = new UpdateLineGroupRequest(); + request.setName("ccqLine1"); // 线路组名称 + request.setLines(Arrays.asList("yunnan.ct")); // 解析线路 + + try { + dnsClient.updateLineGroup(lineId, request, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleUpdateRecordOfZone.java b/src/main/java/com/baidubce/examples/dns/ExampleUpdateRecordOfZone.java new file mode 100644 index 00000000..ebfe0b65 --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleUpdateRecordOfZone.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.UpdateRecordRequest; + +public class ExampleUpdateRecordOfZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + String zoneName = "javaSdk.com"; // 域名名称 + String recordId = "48554"; // 记录的id + UpdateRecordRequest request = new UpdateRecordRequest(); + request.setRr("www"); // 主机记录 + request.setType("A"); // 解析记录类型 + request.setValue("1.1.1.2"); // 记录值 + + try { + dnsClient.updateRecord(zoneName, recordId, request, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/dns/ExampleUpgradeZone.java b/src/main/java/com/baidubce/examples/dns/ExampleUpgradeZone.java new file mode 100644 index 00000000..a7326c37 --- /dev/null +++ b/src/main/java/com/baidubce/examples/dns/ExampleUpgradeZone.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.dns.DnsClient; +import com.baidubce.services.dns.model.UpgradeZoneRequest; + +import java.util.Arrays; + +public class ExampleUpgradeZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "dns.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + DnsClient dnsClient = new DnsClient(config); // 初始化DnsClient + + UpgradeZoneRequest request = new UpgradeZoneRequest(); + UpgradeZoneRequest.Billing billing = new UpgradeZoneRequest.Billing(); + billing.setPaymentTiming("Prepaid"); // 计费方式,预付费 + UpgradeZoneRequest.Billing.Reservation reservation = new UpgradeZoneRequest.Billing.Reservation(); + reservation.setReservationLength(1); // 计费时长 + billing.setReservation(reservation); + request.setNames(Arrays.asList("javaSdk.com")); // 域名名称 + request.setBilling(billing); + + try { + dnsClient.upgradeZone(request, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/eip/ExampleAutoRenewEip.java b/src/main/java/com/baidubce/examples/eip/ExampleAutoRenewEip.java new file mode 100644 index 00000000..c32d598c --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleAutoRenewEip.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.AutoRenewEipRequest; + +public class ExampleAutoRenewEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + AutoRenewEipRequest request = new AutoRenewEipRequest(); + request.setEip("100.88.11.128"); // eip地址 + request.setAutoRenewTimeUnit("month"); // 自动续费时间单位 + request.setAutoRenewTime(1); // 自动续费时长 + + try { + eipClient.startAutoRenew(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleBindEip.java b/src/main/java/com/baidubce/examples/eip/ExampleBindEip.java new file mode 100644 index 00000000..7ad6b22f --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleBindEip.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.BindEipRequest; + +public class ExampleBindEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + BindEipRequest request = new BindEipRequest(); + request.setEip("10.107.245.97"); // eip地址 + request.setInstanceId("i-VPKFiIGz"); // eip要绑定的实例id + request.setInstanceIp("192.169.0.9"); // eip要绑定的实例中的ip,可选字段,如绑定BCC主网卡中辅助ip或者ipv6可以用这个 + request.setInstanceType("BCC"); // eip要绑定的实例类型 + + try { + eipClient.bindEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleCreateEip.java b/src/main/java/com/baidubce/examples/eip/ExampleCreateEip.java new file mode 100644 index 00000000..668728c9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleCreateEip.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.eip.model.CreateEipRequest; +import com.baidubce.services.eip.model.CreateEipResponse; +import com.google.common.collect.Lists; + +public class ExampleCreateEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + CreateEipRequest request = new CreateEipRequest(); + request.setBandwidthInMbps(1); // eip带宽 + request.setName("cdhTest"); // eip名称 + Billing billing = new Billing(); + billing.setPaymentTiming("postpaid"); // eip计费方式。预付费或后付费 + billing.setBillingMethod("ByBandwidth"); // eip后付费具体计费方案 + request.setBilling(billing); + + request.setResourceGroupId("RESG-J7PdULjguvB"); // eip要绑定的资源组 + + TagModel tagModel = new TagModel(); + tagModel.setTagKey("tagK"); + tagModel.setTagValue("tagV"); + request.setTags(Lists.newArrayList(tagModel)); // eip要绑定的标签 + + try { + CreateEipResponse response = eipClient.createEip(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleDirectEip.java b/src/main/java/com/baidubce/examples/eip/ExampleDirectEip.java new file mode 100644 index 00000000..bba8c3c6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleDirectEip.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.DirectEipRequest; + +public class ExampleDirectEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + DirectEipRequest request = new DirectEipRequest(); + request.setEip("100.88.11.128"); // eip地址 + + try { + eipClient.directEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleListEip.java b/src/main/java/com/baidubce/examples/eip/ExampleListEip.java new file mode 100644 index 00000000..2af38100 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleListEip.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.ListEipsRequest; +import com.baidubce.services.eip.model.ListEipsResponse; + +public class ExampleListEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + ListEipsRequest request = new ListEipsRequest(); + try { + ListEipsResponse response = eipClient.listEips(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleListRecycleEips.java b/src/main/java/com/baidubce/examples/eip/ExampleListRecycleEips.java new file mode 100644 index 00000000..31cc7124 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleListRecycleEips.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.ListRecycleEipsRequest; +import com.baidubce.services.eip.model.ListRecycleEipsResponse; + +public class ExampleListRecycleEips { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + ListRecycleEipsRequest request = new ListRecycleEipsRequest(); + try { + ListRecycleEipsResponse response = eipClient.listRecycleEips(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleOptionalReleaseEip.java b/src/main/java/com/baidubce/examples/eip/ExampleOptionalReleaseEip.java new file mode 100644 index 00000000..94e0fb66 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleOptionalReleaseEip.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.OptionalReleaseEipRequest; + +public class ExampleOptionalReleaseEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + OptionalReleaseEipRequest request = new OptionalReleaseEipRequest(); + request.setEip("100.88.7.75"); // eip地址 + request.setReleaseToRecycle(true); + try { + eipClient.optionalReleaseEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleReleaseEip.java b/src/main/java/com/baidubce/examples/eip/ExampleReleaseEip.java new file mode 100644 index 00000000..9c532a78 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleReleaseEip.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.OptionalReleaseEipRequest; +import com.baidubce.services.eip.model.ReleaseEipRequest; + +public class ExampleReleaseEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + ReleaseEipRequest request = new ReleaseEipRequest(); + request.setEip("10.107.245.112"); // eip地址 + + try { + // 直接删除eip + eipClient.releaseEip(request); + + // 将eip移入回收站 + OptionalReleaseEipRequest releaseEipRequest = new OptionalReleaseEipRequest(); + releaseEipRequest.setEip("106.13.244.190"); // eip地址 + releaseEipRequest.setReleaseToRecycle(true); // true:将eip移入回收站;false:直接删除eip + eipClient.optionalReleaseEip(releaseEipRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleReleaseEipFromRecycle.java b/src/main/java/com/baidubce/examples/eip/ExampleReleaseEipFromRecycle.java new file mode 100644 index 00000000..3cd3dc9c --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleReleaseEipFromRecycle.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.RecycleOperateEipRequest; + +public class ExampleReleaseEipFromRecycle { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + RecycleOperateEipRequest request = new RecycleOperateEipRequest(); + request.setEip("100.88.7.75"); // eip地址 + try { + eipClient.releaseEipFromRecycle(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleRenewEip.java b/src/main/java/com/baidubce/examples/eip/ExampleRenewEip.java new file mode 100644 index 00000000..3139a65f --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleRenewEip.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.eip.model.PurchaseReservedEipRequest; + +public class ExampleRenewEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + PurchaseReservedEipRequest request = new PurchaseReservedEipRequest(); + request.setEip("10.107.245.97"); // eip地址 + Billing billing = new Billing(); + Billing.Reservation reservation = new Billing.Reservation(); + reservation.setReservationLength(1); // eip续费时长 + reservation.setReservationTimeUnit("Month"); // eip续费时间单位 + billing.setReservation(reservation); + try { + eipClient.purchaseReservedEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleResizeEip.java b/src/main/java/com/baidubce/examples/eip/ExampleResizeEip.java new file mode 100644 index 00000000..b12f58df --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleResizeEip.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.ResizeEipRequest; + +public class ExampleResizeEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + ResizeEipRequest request = new ResizeEipRequest(); + request.setEip("10.107.245.112"); // eip地址 + request.setNewBandwidthInMbps(2); // eip要变配的带宽 + + try { + eipClient.resizeEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleRestoreEipFromRecycle.java b/src/main/java/com/baidubce/examples/eip/ExampleRestoreEipFromRecycle.java new file mode 100644 index 00000000..a3373670 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleRestoreEipFromRecycle.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.RecycleOperateEipRequest; + +public class ExampleRestoreEipFromRecycle { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + RecycleOperateEipRequest request = new RecycleOperateEipRequest(); + request.setEip("100.88.7.75"); // eip地址 + try { + eipClient.restoreEipFromRecycle(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleStopAutoRenewEip.java b/src/main/java/com/baidubce/examples/eip/ExampleStopAutoRenewEip.java new file mode 100644 index 00000000..bcfe453b --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleStopAutoRenewEip.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.StopAutoRenewEipRequest; + +public class ExampleStopAutoRenewEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + StopAutoRenewEipRequest request = new StopAutoRenewEipRequest(); + request.setEip("100.88.11.128"); // eip地址 + + try { + eipClient.stopAutoRenew(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleUnBindEip.java b/src/main/java/com/baidubce/examples/eip/ExampleUnBindEip.java new file mode 100644 index 00000000..01e5f43f --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleUnBindEip.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.UnbindEipRequest; + +public class ExampleUnBindEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + UnbindEipRequest request = new UnbindEipRequest(); + request.setEip("10.107.245.97"); // eip地址 + + try { + eipClient.unbindEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eip/ExampleUnDirectEip.java b/src/main/java/com/baidubce/examples/eip/ExampleUnDirectEip.java new file mode 100644 index 00000000..965056ed --- /dev/null +++ b/src/main/java/com/baidubce/examples/eip/ExampleUnDirectEip.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eip; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.EipClient; +import com.baidubce.services.eip.model.DirectEipRequest; + +public class ExampleUnDirectEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipClient eipClient = new EipClient(config); // 初始化EipClient + + DirectEipRequest request = new DirectEipRequest(); + request.setEip("100.88.11.128"); // eip地址 + + try { + eipClient.unDirectEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eipbp/ExampleCreateEipBp.java b/src/main/java/com/baidubce/examples/eipbp/ExampleCreateEipBp.java new file mode 100644 index 00000000..a29ea471 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipbp/ExampleCreateEipBp.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipbp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.eipbp.EipBpClient; +import com.baidubce.services.eipbp.model.CreateEipBpRequest; +import com.baidubce.services.eipbp.model.CreateEipBpResponse; +import com.google.common.collect.Lists; + +public class ExampleCreateEipBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipBpClient eipBpClient = new EipBpClient(config); // 初始化EipBpClient + + CreateEipBpRequest request = new CreateEipBpRequest(); + request.setEip("192.168.4.252"); // 带宽包要绑定的eip实例的ip地址 + request.setBandwidthInMbps(10); // 带宽包带宽值 + request.setName("test"); // 带宽包名称 + request.setResourceGroupId("RESG-J7PdULjguvB"); // 带宽包要绑定的资源组 + + TagModel tagModel = new TagModel(); + tagModel.setTagKey("tagK"); + tagModel.setTagValue("tagV"); + request.setTags(Lists.newArrayList(tagModel)); // 带宽包要绑定的标签 + + try { + CreateEipBpResponse response = eipBpClient.createEipBp(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipbp/ExampleGetEipBpDetail.java b/src/main/java/com/baidubce/examples/eipbp/ExampleGetEipBpDetail.java new file mode 100644 index 00000000..30b216f1 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipbp/ExampleGetEipBpDetail.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipbp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipbp.EipBpClient; +import com.baidubce.services.eipbp.model.EipBpDetailResponse; +import com.baidubce.services.eipbp.model.GetEipBpRequest; + +public class ExampleGetEipBpDetail { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipBpClient eipBpClient = new EipBpClient(config); // 初始化EipBpClient + + GetEipBpRequest request = new GetEipBpRequest(); + request.setId("bw-2ede9df3"); // 带宽包id + + try { + EipBpDetailResponse eipBpDetailResponse = eipBpClient.getEipBpDetail(request); + System.out.println(eipBpDetailResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/eipbp/ExampleListEipBps.java b/src/main/java/com/baidubce/examples/eipbp/ExampleListEipBps.java new file mode 100644 index 00000000..9ead8764 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipbp/ExampleListEipBps.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipbp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipbp.EipBpClient; +import com.baidubce.services.eipbp.model.ListEipBpsRequest; +import com.baidubce.services.eipbp.model.ListEipBpsResponse; + +public class ExampleListEipBps { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipBpClient eipBpClient = new EipBpClient(config); // 初始化EipBpClient + + ListEipBpsRequest request = new ListEipBpsRequest(); + request.setId("bw-2ede9df3"); // 要查询的带宽包id + request.setName("test-name"); // 要查询的带宽包名称 + request.setBindType("eip"); // 要查询的带宽包所绑定的资源的类型,"eip"(弹性公网EIP)或"eipgroup"(共享带宽) + request.setType("BandwidthPackage"); // 带宽包的类型,包括BandwidthPackage(带宽包)和AccelerationPackage(跨境加速包),默认全选 + request.setMarker("bw-IyWRnII7"); // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + request.setMaxKeys(10); // 每页包含的最大数量,最大数量不超过1000。缺省值为1000 + + try { + ListEipBpsResponse listEipBpsResponse = eipBpClient.listEipBps(request); + System.out.println(listEipBpsResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/eipbp/ExampleReleaseEipBp.java b/src/main/java/com/baidubce/examples/eipbp/ExampleReleaseEipBp.java new file mode 100644 index 00000000..b2c45c12 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipbp/ExampleReleaseEipBp.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipbp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipbp.EipBpClient; +import com.baidubce.services.eipbp.model.ReleaseEipBpRequest; + +public class ExampleReleaseEipBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipBpClient eipBpClient = new EipBpClient(config); // 初始化EipBpClient + + ReleaseEipBpRequest request = new ReleaseEipBpRequest(); + request.setId("bw-2ede9df3"); // 带宽包id + + try { + eipBpClient.releaseEipBp(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/eipbp/ExampleRenameEipBp.java b/src/main/java/com/baidubce/examples/eipbp/ExampleRenameEipBp.java new file mode 100644 index 00000000..ee417396 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipbp/ExampleRenameEipBp.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipbp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipbp.EipBpClient; +import com.baidubce.services.eipbp.model.UpdateEipBpNameRequest; + +public class ExampleRenameEipBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipBpClient eipBpClient = new EipBpClient(config); // 初始化EipBpClient + + UpdateEipBpNameRequest request = new UpdateEipBpNameRequest(); + request.setId("bw-2ede9df3"); // 带宽包id + request.setName("newname"); // 更新后带宽包的名称 + + try { + eipBpClient.renameEipBp(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/eipbp/ExampleResizeEipBp.java b/src/main/java/com/baidubce/examples/eipbp/ExampleResizeEipBp.java new file mode 100644 index 00000000..2bc487ca --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipbp/ExampleResizeEipBp.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipbp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipbp.EipBpClient; +import com.baidubce.services.eipbp.model.ResizeEipBpRequest; + +public class ExampleResizeEipBp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipBpClient eipBpClient = new EipBpClient(config); // 初始化EipBpClient + + ResizeEipBpRequest request = new ResizeEipBpRequest(); + request.setId("bw-2ede9df3"); // 带宽包实例id + request.setBandwidthInMbps(20); // 带宽包要变配的带宽值 + + try { + eipBpClient.resizeEipBp(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipbp/ExampleUpdateEipBpAutoReleaseTime.java b/src/main/java/com/baidubce/examples/eipbp/ExampleUpdateEipBpAutoReleaseTime.java new file mode 100644 index 00000000..dcc5a52b --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipbp/ExampleUpdateEipBpAutoReleaseTime.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipbp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipbp.EipBpClient; +import com.baidubce.services.eipbp.model.UpdateEipBpAutoReleaseTimeRequest; + +public class ExampleUpdateEipBpAutoReleaseTime { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipBpClient eipBpClient = new EipBpClient(config); // 初始化EipBpClient + + UpdateEipBpAutoReleaseTimeRequest request = new UpdateEipBpAutoReleaseTimeRequest(); + request.setId("bw-2ede9df3"); // 带宽包id + request.setAutoReleaseTime("2020-07-23T12:00:00Z"); // 更新后带宽包的自动释放时间 + + try { + eipBpClient.updateAutoReleaseTime(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleCreateEipGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleCreateEipGroup.java new file mode 100644 index 00000000..51c2b8e8 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleCreateEipGroup.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.CreateEipGroupRequest; +import com.baidubce.services.eipgroup.model.IdResponse; +import com.google.common.collect.Lists; + +public class ExampleCreateEipGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + CreateEipGroupRequest request = new CreateEipGroupRequest(); + Billing.Reservation reservation = new Billing.Reservation(); + reservation.setReservationLength(1); // eipGroup购买时长 + reservation.setReservationTimeUnit("Month"); // eipGroup购买时间单位 + Billing billing = new Billing(); + billing.setPaymentTiming("Prepaid"); // eipGroup购买计费方式,预付费或后付费 + billing.setReservation(reservation); + request.setBilling(billing); + request.setName("EipGroupTest"); // eipGroup的名称 + request.setEipCount(2); // eipGroup内ip数量 + request.setBandwidthInMbps(10); // eipGroup的带宽 + request.setResourceGroupId("RESG-J7PdULjguvB"); // eipGroup要绑定的资源组 + + TagModel tagModel = new TagModel(); + tagModel.setTagKey("tagK"); + tagModel.setTagValue("tagV"); + request.setTags(Lists.newArrayList(tagModel)); // eipGroup要绑定的标签 + + try { + IdResponse response = eipGroupClient.createEipGroup(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleDetailEipGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleDetailEipGroup.java new file mode 100644 index 00000000..f46d219e --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleDetailEipGroup.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.GetEipGroupRequest; +import com.baidubce.services.eipgroup.model.GetEipGroupResponse; + +public class ExampleDetailEipGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + GetEipGroupRequest request = new GetEipGroupRequest(); + request.setId("eg-7e358ead"); // eipgroup实例id + + try { + GetEipGroupResponse response = eipGroupClient.getEipGroup(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleListEipGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleListEipGroup.java new file mode 100644 index 00000000..ebaae354 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleListEipGroup.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.ListEipGroupRequest; +import com.baidubce.services.eipgroup.model.ListEipGroupResponse; + +public class ExampleListEipGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + ListEipGroupRequest request = new ListEipGroupRequest(); + + try { + ListEipGroupResponse response = eipGroupClient.listEipGroup(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleMoveEipIntoGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleMoveEipIntoGroup.java new file mode 100644 index 00000000..b2982e67 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleMoveEipIntoGroup.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.MoveInRequest; + +import java.util.Arrays; +import java.util.List; + +public class ExampleMoveEipIntoGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + MoveInRequest request = new MoveInRequest(); + request.setId("eg-8yxeMV47"); // eipgroup实例id + List eips = Arrays.asList("100.88.9.177"); // 要移入的eip的ip地址 + request.setEips(eips); + try { + eipGroupClient.moveInEips(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleMoveOutEipFromGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleMoveOutEipFromGroup.java new file mode 100644 index 00000000..0366b91a --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleMoveOutEipFromGroup.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.MoveOutRequest; + +import java.util.Arrays; + +public class ExampleMoveOutEipFromGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + MoveOutRequest request = new MoveOutRequest(); + request.setId("eg-8yxeMV47"); // eipgroup的实例id + MoveOutRequest.EipMoveOutModel moveOutModel = new MoveOutRequest.EipMoveOutModel(); + moveOutModel.setEip("100.88.9.177"); // 要移出的eip地址 + moveOutModel.setBandwidthInMbps(100); // 要移出的eip带宽 + Billing billing = new Billing(); + billing.setPaymentTiming("Postpaid"); // 要移出的eip指定为后付费 + billing.setBillingMethod("ByTraffic"); // 要移出的eip指定为按流量计费 + moveOutModel.setBilling(billing); + request.setMoveOutEips(Arrays.asList(moveOutModel)); + try { + eipGroupClient.moveOutEips(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleReleaseEipGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleReleaseEipGroup.java new file mode 100644 index 00000000..4c2974e2 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleReleaseEipGroup.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.EipGroupOperateRequest; + +public class ExampleReleaseEipGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + EipGroupOperateRequest request = new EipGroupOperateRequest(); + request.setId("eg-aXT5LIDG"); // eipgroup的实例id + try { + eipGroupClient.releaseEipGroup(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleRenameEipGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleRenameEipGroup.java new file mode 100644 index 00000000..5e9a1919 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleRenameEipGroup.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.EipNameRequest; + +public class ExampleRenameEipGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + EipNameRequest request = new EipNameRequest(); + request.setId("eg-7e358ead"); // eipgroup实例id + request.setName("updateName"); // eipgroup的新名称 + + try { + eipGroupClient.update(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleRenewEipGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleRenewEipGroup.java new file mode 100644 index 00000000..f86f8136 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleRenewEipGroup.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.PurchaseReservedEipGroupRequest; + +public class ExampleRenewEipGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + PurchaseReservedEipGroupRequest request = new PurchaseReservedEipGroupRequest(); + request.setId("eg-7e358ead"); // eipgroup实例id + Billing billing = new Billing(); + Billing.Reservation reservation = new Billing.Reservation(); + reservation.setReservationLength(1); // eipgroup续费时长 + reservation.setReservationTimeUnit("Month"); // eipgroup续费时间单位 + billing.setReservation(reservation); + request.setBilling(billing); + + try { + eipGroupClient.purchaseReservedEipGroup(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleResizeBandwidthEipGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleResizeBandwidthEipGroup.java new file mode 100644 index 00000000..b6bb1457 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleResizeBandwidthEipGroup.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.BandwidthInMbpsRequest; + +public class ExampleResizeBandwidthEipGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + BandwidthInMbpsRequest request = new BandwidthInMbpsRequest(); + request.setBandwidthInMbps(20); // eipgroup要变配的带宽值 + request.setId("eg-7e358ead"); // eipgroup实例id + + try { + eipGroupClient.resizeBandwidth(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eipgroup/ExampleResizeIpNumEipGroup.java b/src/main/java/com/baidubce/examples/eipgroup/ExampleResizeIpNumEipGroup.java new file mode 100644 index 00000000..ab27da2a --- /dev/null +++ b/src/main/java/com/baidubce/examples/eipgroup/ExampleResizeIpNumEipGroup.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eipgroup.EipGroupClient; +import com.baidubce.services.eipgroup.EipGroupClientConfiguration; +import com.baidubce.services.eipgroup.model.EipCountRequest; + +public class ExampleResizeIpNumEipGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + EipGroupClientConfiguration config = new EipGroupClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipGroupClient eipGroupClient = new EipGroupClient(config); // 初始化EipGroupClient + + EipCountRequest request = new EipCountRequest(); + request.setId("eg-7e358ead"); // eipgroup实例id + request.setEipAddCount(2); // eipgroup增加的ip数量 + + try { + eipGroupClient.addCount(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/eiptp/ExampleCreateEipTp.java b/src/main/java/com/baidubce/examples/eiptp/ExampleCreateEipTp.java new file mode 100644 index 00000000..b87ec245 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eiptp/ExampleCreateEipTp.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eiptp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eiptp.EipTpClient; +import com.baidubce.services.eiptp.model.CreateEipTpRequest; +import com.baidubce.services.eiptp.model.CreateEipTpResponse; + +public class ExampleCreateEipTp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipTpClient eipTpClient = new EipTpClient(config); // 初始化EipTpClient + + CreateEipTpRequest createEipTpRequest = new CreateEipTpRequest(); + createEipTpRequest.setReservationLength(1); // 共享流量包有效期(单位:月) + createEipTpRequest.setCapacity("10G"); // 共享流量包容量 + + try { + CreateEipTpResponse response = eipTpClient.createEipTp(createEipTpRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/eiptp/ExampleGetEipTpDetail.java b/src/main/java/com/baidubce/examples/eiptp/ExampleGetEipTpDetail.java new file mode 100644 index 00000000..177fa879 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eiptp/ExampleGetEipTpDetail.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eiptp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eiptp.EipTpClient; +import com.baidubce.services.eiptp.model.EipTpDetailResponse; + +public class ExampleGetEipTpDetail { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipTpClient eipTpClient = new EipTpClient(config); // 初始化EipTpClient + + String eipTpId = "tp-c7pdMpkpbB"; // 共享流量包id + + try { + EipTpDetailResponse response = eipTpClient.getEipTpDetail(eipTpId); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/eiptp/ExampleListEipTps.java b/src/main/java/com/baidubce/examples/eiptp/ExampleListEipTps.java new file mode 100644 index 00000000..b7938cb6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eiptp/ExampleListEipTps.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eiptp; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eiptp.EipTpClient; +import com.baidubce.services.eiptp.model.ListEipTpsRequest; +import com.baidubce.services.eiptp.model.ListEipTpsResponse; + +public class ExampleListEipTps { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "eip.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EipTpClient eipTpClient = new EipTpClient(config); // 初始化EipTpClient + + ListEipTpsRequest listEipTpsRequest = new ListEipTpsRequest(); + listEipTpsRequest.setMarker(""); // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + listEipTpsRequest.setMaxKeys(10); // 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + + try { + ListEipTpsResponse response = eipTpClient.listEipTps(listEipTpsRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/endpoint/ExampleCreateEndpoint.java b/src/main/java/com/baidubce/examples/endpoint/ExampleCreateEndpoint.java new file mode 100644 index 00000000..69ad68b9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/endpoint/ExampleCreateEndpoint.java @@ -0,0 +1,41 @@ +package com.baidubce.examples.endpoint; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.endpoint.EndpointClient; +import com.baidubce.services.endpoint.EndpointClientConfiguration; +import com.baidubce.services.endpoint.model.CreateEndpointRequest; +import com.baidubce.services.endpoint.model.CreateEndpointResponse; + +public class ExampleCreateEndpoint { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EndpointClientConfiguration config = new EndpointClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EndpointClient endpointClient = new EndpointClient(config); // 初始化EndpointClient + + CreateEndpointRequest request = new CreateEndpointRequest(); + request.setName("sdk-1"); // 服务网卡的名称,大小写字母、数字以及-_/.特殊字符、中文,必须以字母开头,长度1-65 + request.setVpcId("vpc-va6hhmx62vyp"); // 所属vpc的id + request.setSubnetId("sbn-1rmebtrbxxn6"); // 所在子网的id + request.setService("www.test.com"); // 挂载的服务域名 + request.setDescription("sdk create"); // 服务网卡描述 + request.setIpAddress("192.168.0.1"); // 指定服务网卡ip地址,不传自动分配ip地址 + Billing billing = new Billing(); + billing.setPaymentTiming("Postpaid"); // 计费信息 + request.setBilling(billing); + try { + CreateEndpointResponse response = endpointClient.createEndpoint(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + + } +} diff --git a/src/main/java/com/baidubce/examples/endpoint/ExampleDeleteEndpoint.java b/src/main/java/com/baidubce/examples/endpoint/ExampleDeleteEndpoint.java new file mode 100644 index 00000000..2e96dc52 --- /dev/null +++ b/src/main/java/com/baidubce/examples/endpoint/ExampleDeleteEndpoint.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.endpoint; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.endpoint.EndpointClient; +import com.baidubce.services.endpoint.EndpointClientConfiguration; +import com.baidubce.services.endpoint.model.ReleaseEndpointRequest; + +public class ExampleDeleteEndpoint { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EndpointClientConfiguration config = new EndpointClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EndpointClient endpointClient = new EndpointClient(config); // 初始化EndpointClient + + ReleaseEndpointRequest request = new ReleaseEndpointRequest(); + request.setEndpointId("endpoint-11b09ce6"); // 服务网卡的id + try { + endpointClient.releaseEndpoint(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/endpoint/ExampleGetEndpoint.java b/src/main/java/com/baidubce/examples/endpoint/ExampleGetEndpoint.java new file mode 100644 index 00000000..2ec680df --- /dev/null +++ b/src/main/java/com/baidubce/examples/endpoint/ExampleGetEndpoint.java @@ -0,0 +1,26 @@ +package com.baidubce.examples.endpoint; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.endpoint.EndpointClient; +import com.baidubce.services.endpoint.EndpointClientConfiguration; + +public class ExampleGetEndpoint { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EndpointClientConfiguration config = new EndpointClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EndpointClient endpointClient = new EndpointClient(config); // 初始化EndpointClient + + try { + endpointClient.getEndpoint("endpoint-11b09ce6"); // 服务网卡的id + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/endpoint/ExampleGetPublicServices.java b/src/main/java/com/baidubce/examples/endpoint/ExampleGetPublicServices.java new file mode 100644 index 00000000..64d057da --- /dev/null +++ b/src/main/java/com/baidubce/examples/endpoint/ExampleGetPublicServices.java @@ -0,0 +1,28 @@ +package com.baidubce.examples.endpoint; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.endpoint.EndpointClient; +import com.baidubce.services.endpoint.EndpointClientConfiguration; +import com.baidubce.services.endpoint.model.ServiceResponse; + +public class ExampleGetPublicServices { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EndpointClientConfiguration config = new EndpointClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EndpointClient endpointClient = new EndpointClient(config); // 初始化EndpointClient + + try { + ServiceResponse serviceResponse = endpointClient.listService(); // 查询可挂载的公共服务 + System.out.println(serviceResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/endpoint/ExampleListEndpoint.java b/src/main/java/com/baidubce/examples/endpoint/ExampleListEndpoint.java new file mode 100644 index 00000000..558b8054 --- /dev/null +++ b/src/main/java/com/baidubce/examples/endpoint/ExampleListEndpoint.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.endpoint; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.endpoint.EndpointClient; +import com.baidubce.services.endpoint.EndpointClientConfiguration; +import com.baidubce.services.endpoint.model.ListEndpointRequest; +import com.baidubce.services.endpoint.model.ListEndpointResponse; + +public class ExampleListEndpoint { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EndpointClientConfiguration config = new EndpointClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EndpointClient endpointClient = new EndpointClient(config); // 初始化EndpointClient + + ListEndpointRequest listEndpointRequest = new ListEndpointRequest(); + listEndpointRequest.setVpcId("vpc-va6hhmx62vyp"); // 服务网卡所属VPC + try { + ListEndpointResponse listEndpointResponse = endpointClient.listEndpoint(listEndpointRequest); + System.out.println(listEndpointResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/endpoint/ExampleUpdateEndpoint.java b/src/main/java/com/baidubce/examples/endpoint/ExampleUpdateEndpoint.java new file mode 100644 index 00000000..100ac059 --- /dev/null +++ b/src/main/java/com/baidubce/examples/endpoint/ExampleUpdateEndpoint.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.endpoint; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.endpoint.EndpointClient; +import com.baidubce.services.endpoint.EndpointClientConfiguration; +import com.baidubce.services.endpoint.model.ModifyEndpointRequest; + +public class ExampleUpdateEndpoint { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EndpointClientConfiguration config = new EndpointClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EndpointClient endpointClient = new EndpointClient(config); // 初始化EndpointClient + + String endpointId = "endpoint-11b09ce6"; // 服务网卡的id + ModifyEndpointRequest request = new ModifyEndpointRequest(); + request.setEndpointId(endpointId); + request.setName("sdk-update-2"); // 服务网卡名称,长度不超过65个字符,可由数字,字符,下划线、中文组成 + try { + endpointClient.modifyEndpoint(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/endpoint/ExampleUpdateEndpointSecurityGroup.java b/src/main/java/com/baidubce/examples/endpoint/ExampleUpdateEndpointSecurityGroup.java new file mode 100644 index 00000000..5d23cf2a --- /dev/null +++ b/src/main/java/com/baidubce/examples/endpoint/ExampleUpdateEndpointSecurityGroup.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.endpoint; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.endpoint.EndpointClient; +import com.baidubce.services.endpoint.EndpointClientConfiguration; +import com.baidubce.services.endpoint.model.UpdateSecurityGroups; + +public class ExampleUpdateEndpointSecurityGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EndpointClientConfiguration config = new EndpointClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EndpointClient endpointClient = new EndpointClient(config); // 初始化EndpointClient + + UpdateSecurityGroups updateSecurityGroups = new UpdateSecurityGroups(); + updateSecurityGroups.setEndpointId("endpoint-daa07eb2"); + updateSecurityGroups.setSecurityGroupIds(Arrays.asList("g-6r0ds9xbxwes")); + + try { + endpointClient.updateSecurityGroups(updateSecurityGroups); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/endpoint/ExampleUpdateEnterpriseSecurityGroup.java b/src/main/java/com/baidubce/examples/endpoint/ExampleUpdateEnterpriseSecurityGroup.java new file mode 100644 index 00000000..dd0188e9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/endpoint/ExampleUpdateEnterpriseSecurityGroup.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.endpoint; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.endpoint.EndpointClient; +import com.baidubce.services.endpoint.EndpointClientConfiguration; +import com.baidubce.services.endpoint.model.UpdateEnterpriseSecurityGroups; + +public class ExampleUpdateEnterpriseSecurityGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EndpointClientConfiguration config = new EndpointClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EndpointClient endpointClient = new EndpointClient(config); // 初始化EndpointClient + + UpdateEnterpriseSecurityGroups updateSecurityGroups = new UpdateEnterpriseSecurityGroups(); + updateSecurityGroups.setEndpointId("endpoint-daa07eb2"); + updateSecurityGroups.setEnterpriseSecurityGroupIds(Arrays.asList("esg-6q04xad5xmh6")); + + try { + endpointClient.updateEnterpriseSecurityGroups(updateSecurityGroups); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/eni/ExampleCreateEni.java b/src/main/java/com/baidubce/examples/eni/ExampleCreateEni.java new file mode 100644 index 00000000..aec2768d --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleCreateEni.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import java.util.Arrays; +import java.util.List; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.CreateEniRequest; +import com.baidubce.services.eni.model.CreateEniResponse; +import com.baidubce.services.eni.model.PrivateIp; +import com.google.common.collect.Lists; + +public class ExampleCreateEni { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + CreateEniRequest request = new CreateEniRequest(); + request.setSubnetId("sbn-6ha6gp1vczuv"); // eni所属的子网Id + request.setDescription("desc"); // eni的描述 + request.setName("testEni"); // eni的名称 + request.setSecurityGroupIds(Arrays.asList("g-vs94kdqxw078")); // eni的安全组列表 + request.setNetworkInterfaceTrafficMode("standard"); + List privateIpSet = Lists.newArrayList(); // Eni的Ip列表 + PrivateIp ip = new PrivateIp(); + ip.setPrimary(true); // 设置为主IP + ip.setPrivateIpAddress("192.168.0.9"); // eni的内网IP + privateIpSet.add(ip); + + request.setPrivateIpSet(privateIpSet); + try { + CreateEniResponse response = eniClient.createEni(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleDeleteEni.java b/src/main/java/com/baidubce/examples/eni/ExampleDeleteEni.java new file mode 100644 index 00000000..4e97f311 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleDeleteEni.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; + +public class ExampleDeleteEni { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + try { + eniClient.deleteEni("eni-nm4dx9vtnh3p"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniAddPrivateIp.java b/src/main/java/com/baidubce/examples/eni/ExampleEniAddPrivateIp.java new file mode 100644 index 00000000..83b99a54 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniAddPrivateIp.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniPrivateIpOperateRequest; + +public class ExampleEniAddPrivateIp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniPrivateIpOperateRequest eniPrivateIpOperateRequest = new EniPrivateIpOperateRequest(); + eniPrivateIpOperateRequest.setEniId("eni-nm4dx9vtnh3p"); + eniPrivateIpOperateRequest.setPrivateIpAddress("192.168.0.10"); + try { + eniClient.addPrivateIp(eniPrivateIpOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniAttachVm.java b/src/main/java/com/baidubce/examples/eni/ExampleEniAttachVm.java new file mode 100644 index 00000000..6f477ffa --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniAttachVm.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniInstanceOperateRequest; + +public class ExampleEniAttachVm { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniInstanceOperateRequest eniInstanceOperateRequest = new EniInstanceOperateRequest(); + eniInstanceOperateRequest.setInstanceId("i-PSCezwEn"); // eniId + eniInstanceOperateRequest.setEniId("eni-nm4dx9vtnh3p"); // 虚机Id + + try { + eniClient.attachEniInstance(eniInstanceOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniBatchAddPrivateIp.java b/src/main/java/com/baidubce/examples/eni/ExampleEniBatchAddPrivateIp.java new file mode 100644 index 00000000..30c2e9e8 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniBatchAddPrivateIp.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniPrivateIpBatchAddRequest; + +public class ExampleEniBatchAddPrivateIp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniPrivateIpBatchAddRequest eniPrivateIpBatchAddRequest = new EniPrivateIpBatchAddRequest(); + eniPrivateIpBatchAddRequest.setEniId("eni-nm4dx9vtnh3p"); + eniPrivateIpBatchAddRequest.setPrivateIpAddressCount(2); // 自动分配2个Ip + + try { + eniClient.batchAddPrivateIp(eniPrivateIpBatchAddRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniBatchDelPrivateIp.java b/src/main/java/com/baidubce/examples/eni/ExampleEniBatchDelPrivateIp.java new file mode 100644 index 00000000..ec9eead9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniBatchDelPrivateIp.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniPrivateIpBatchOperateRequest; + +public class ExampleEniBatchDelPrivateIp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniPrivateIpBatchOperateRequest eniPrivateIpBatchOperateRequest = new EniPrivateIpBatchOperateRequest(); + eniPrivateIpBatchOperateRequest.setEniId("eni-nm4dx9vtnh3p"); + eniPrivateIpBatchOperateRequest.setPrivateIpAddresses(Arrays.asList("192.168.0.5", "192.168.0.6")); + + try { + eniClient.batchDeletePrivateIp(eniPrivateIpBatchOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniBindEip.java b/src/main/java/com/baidubce/examples/eni/ExampleEniBindEip.java new file mode 100644 index 00000000..5db6ff6e --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniBindEip.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniBindEipRequest; + +public class ExampleEniBindEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniBindEipRequest eniBindEipRequest = new EniBindEipRequest(); + eniBindEipRequest.setEniId("eni-nm4dx9vtnh3p"); + eniBindEipRequest.setPrivateIpAddress("192.168.0.9"); + eniBindEipRequest.setPublicIpAddress("100.88.11.97"); + + try { + eniClient.bindEniPublicIp(eniBindEipRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniDelPrivateIp.java b/src/main/java/com/baidubce/examples/eni/ExampleEniDelPrivateIp.java new file mode 100644 index 00000000..262a4433 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniDelPrivateIp.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniPrivateIpOperateRequest; + +public class ExampleEniDelPrivateIp { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniPrivateIpOperateRequest eniPrivateIpOperateRequest = new EniPrivateIpOperateRequest(); + eniPrivateIpOperateRequest.setEniId("eni-nm4dx9vtnh3p"); + eniPrivateIpOperateRequest.setPrivateIpAddress("192.168.0.10"); + try { + eniClient.deletePrivateIp(eniPrivateIpOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniDetail.java b/src/main/java/com/baidubce/examples/eni/ExampleEniDetail.java new file mode 100644 index 00000000..d6300338 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniDetail.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniDetail; +import com.baidubce.services.eni.model.GetEniDetailRequest; + +public class ExampleEniDetail { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + GetEniDetailRequest request = new GetEniDetailRequest(); + request.setEniId("eni-nm4dx9vtnh3p"); + + try { + EniDetail response = eniClient.getEniDetail(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniDettachVm.java b/src/main/java/com/baidubce/examples/eni/ExampleEniDettachVm.java new file mode 100644 index 00000000..9f3ad12a --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniDettachVm.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniInstanceOperateRequest; + +public class ExampleEniDettachVm { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniInstanceOperateRequest eniInstanceOperateRequest = new EniInstanceOperateRequest(); + eniInstanceOperateRequest.setEniId("eni-nm4dx9vtnh3p"); // eniId + eniInstanceOperateRequest.setInstanceId("i-PSCezwEn"); // 虚机Id + + try { + eniClient.detachEniInstance(eniInstanceOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniUnBindEip.java b/src/main/java/com/baidubce/examples/eni/ExampleEniUnBindEip.java new file mode 100644 index 00000000..406b9f5e --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniUnBindEip.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniUnBindEipRequest; + +public class ExampleEniUnBindEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniUnBindEipRequest eniUnBindEipRequest = new EniUnBindEipRequest(); + eniUnBindEipRequest.setEniId("eni-nm4dx9vtnh3p"); // 弹性网卡Id + eniUnBindEipRequest.setPublicIpAddress("100.88.11.97"); // 解绑的eip + + try { + eniClient.unBindEniPublicIp(eniUnBindEipRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniUpdateEnterpriseSecurityGroups.java b/src/main/java/com/baidubce/examples/eni/ExampleEniUpdateEnterpriseSecurityGroups.java new file mode 100644 index 00000000..a7ed4583 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniUpdateEnterpriseSecurityGroups.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniUpdateEnterpriseSecurityGroupRequest; + +public class ExampleEniUpdateEnterpriseSecurityGroups { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniUpdateEnterpriseSecurityGroupRequest eniUpdateEnterpriseSecurityGroupRequest = + new EniUpdateEnterpriseSecurityGroupRequest(); + eniUpdateEnterpriseSecurityGroupRequest.setEniId("eni-nm4dx9vtnh3p"); + eniUpdateEnterpriseSecurityGroupRequest.setEnterpriseSecurityGroupIds(Arrays.asList("esg-6q04xad5xmh6")); + + try { + eniClient.updateEniEnterpriseSecurityGroup(eniUpdateEnterpriseSecurityGroupRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleEniUpdateSecurityGroups.java b/src/main/java/com/baidubce/examples/eni/ExampleEniUpdateSecurityGroups.java new file mode 100644 index 00000000..f5366898 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleEniUpdateSecurityGroups.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniUpdateSecurityGroupRequest; + +public class ExampleEniUpdateSecurityGroups { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniUpdateSecurityGroupRequest eniUpdateSecurityGroupRequest = new EniUpdateSecurityGroupRequest(); + eniUpdateSecurityGroupRequest.setEniId("eni-nm4dx9vtnh3p"); + eniUpdateSecurityGroupRequest.setSecurityGroupIds(Arrays.asList("g-vs94kdqxw078")); + + try { + eniClient.updateEniSecurityGroup(eniUpdateSecurityGroupRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleGetEniStatus.java b/src/main/java/com/baidubce/examples/eni/ExampleGetEniStatus.java new file mode 100644 index 00000000..fbbc4da9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleGetEniStatus.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniStatusResponse; + +public class ExampleGetEniStatus { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + + try { + EniStatusResponse response = eniClient.getEniStatus("eni-wjz6683jaswn"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleListEni.java b/src/main/java/com/baidubce/examples/eni/ExampleListEni.java new file mode 100644 index 00000000..6e2043d7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleListEni.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.ListEniRequest; +import com.baidubce.services.eni.model.ListEniResponse; + +public class ExampleListEni { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + ListEniRequest listEniRequest = new ListEniRequest(); + listEniRequest.setVpcId("vpc-b9ycwxxisrb7"); + + try { + ListEniResponse response = eniClient.listEni(listEniRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/eni/ExampleUpdateEni.java b/src/main/java/com/baidubce/examples/eni/ExampleUpdateEni.java new file mode 100644 index 00000000..d88a8a85 --- /dev/null +++ b/src/main/java/com/baidubce/examples/eni/ExampleUpdateEni.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.eni; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eni.EniClient; +import com.baidubce.services.eni.EniClientConfiguration; +import com.baidubce.services.eni.model.EniUpdateRequest; + +public class ExampleUpdateEni { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EniClientConfiguration config = new EniClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EniClient eniClient = new EniClient(config); // 初始化EniClient + + EniUpdateRequest eniUpdateRequest = new EniUpdateRequest(); + eniUpdateRequest.setEniId("eni-nm4dx9vtnh3p"); + eniUpdateRequest.setName("name1"); + eniUpdateRequest.setDescription("desc"); + + try { + eniClient.updateEni(eniUpdateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/esg/ExampleAddEsgRule.java b/src/main/java/com/baidubce/examples/esg/ExampleAddEsgRule.java new file mode 100644 index 00000000..c0273ae7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/esg/ExampleAddEsgRule.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.esg; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.esg.EsgClient; +import com.baidubce.services.esg.EsgClientConfiguration; +import com.baidubce.services.esg.model.EnterpriseSecurityGroupRule; +import com.baidubce.services.esg.model.EsgRuleOperateRequest; + +public class ExampleAddEsgRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EsgClientConfiguration config = new EsgClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EsgClient esgClient = new EsgClient(config); // 初始化EsgClient + + EnterpriseSecurityGroupRule enterpriseSecurityGroupRule = new EnterpriseSecurityGroupRule(); // esg规则 + enterpriseSecurityGroupRule.setSourceIp("all"); // 规则源IP + enterpriseSecurityGroupRule.setDestIp("all"); // 规则目的IP + enterpriseSecurityGroupRule.setAction("allow"); // 规则允许 + enterpriseSecurityGroupRule.setDirection("ingress"); // 规则的方向 + enterpriseSecurityGroupRule.setPriority(100); // 规则优先级 + enterpriseSecurityGroupRule.setProtocol("tcp"); // 规则协议 + enterpriseSecurityGroupRule.setPortRange("2000-3000"); // 规则端口范围 + enterpriseSecurityGroupRule.setEthertype("IPv4"); // 规则IPv4版本 + + EsgRuleOperateRequest esgRuleOperateRequest = new EsgRuleOperateRequest(); + esgRuleOperateRequest.setEnterpriseSecurityGroupId("esg-cza4aa7z2wtd"); + esgRuleOperateRequest.setRules(Arrays.asList(enterpriseSecurityGroupRule)); + try { + esgClient.authorizeEsgRule(esgRuleOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/esg/ExampleCreateEsg.java b/src/main/java/com/baidubce/examples/esg/ExampleCreateEsg.java new file mode 100644 index 00000000..16c08f46 --- /dev/null +++ b/src/main/java/com/baidubce/examples/esg/ExampleCreateEsg.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.esg; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.esg.EsgClient; +import com.baidubce.services.esg.EsgClientConfiguration; +import com.baidubce.services.esg.model.CreateEsgRequest; +import com.baidubce.services.esg.model.CreateEsgResponse; +import com.baidubce.services.esg.model.EnterpriseSecurityGroupRule; + +public class ExampleCreateEsg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EsgClientConfiguration config = new EsgClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EsgClient esgClient = new EsgClient(config); // 初始化EsgClient + + CreateEsgRequest createEsgRequest = new CreateEsgRequest(); + createEsgRequest.setName("esgName"); // esg名称 + createEsgRequest.setDesc("desc"); // esg描述 + EnterpriseSecurityGroupRule enterpriseSecurityGroupRule = new EnterpriseSecurityGroupRule(); // esg规则 + enterpriseSecurityGroupRule.setSourceIp("all"); // 规则源IP + enterpriseSecurityGroupRule.setDestIp("all"); // 规则目的IP + enterpriseSecurityGroupRule.setAction("allow"); // 规则允许 + enterpriseSecurityGroupRule.setDirection("ingress"); // 规则的方向 + enterpriseSecurityGroupRule.setPriority(100); // 规则优先级 + enterpriseSecurityGroupRule.setProtocol("tcp"); // 规则协议 + enterpriseSecurityGroupRule.setPortRange("1000-3000"); // 规则端口范围 + enterpriseSecurityGroupRule.setEthertype("IPv4"); // 规则IPv4版本 + + createEsgRequest.setRules(Arrays.asList(enterpriseSecurityGroupRule)); + try { + CreateEsgResponse response = esgClient.createEsg(createEsgRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/esg/ExampleDeleteEsg.java b/src/main/java/com/baidubce/examples/esg/ExampleDeleteEsg.java new file mode 100644 index 00000000..920a1735 --- /dev/null +++ b/src/main/java/com/baidubce/examples/esg/ExampleDeleteEsg.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.esg; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.esg.EsgClient; +import com.baidubce.services.esg.EsgClientConfiguration; + +public class ExampleDeleteEsg { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EsgClientConfiguration config = new EsgClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EsgClient esgClient = new EsgClient(config); // 初始化EsgClient + + try { + esgClient.deleteEsg("esg-6q04xad5xmh6"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/esg/ExampleDeleteEsgRule.java b/src/main/java/com/baidubce/examples/esg/ExampleDeleteEsgRule.java new file mode 100644 index 00000000..3f24a9a6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/esg/ExampleDeleteEsgRule.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.esg; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.esg.EsgClient; +import com.baidubce.services.esg.EsgClientConfiguration; + +public class ExampleDeleteEsgRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EsgClientConfiguration config = new EsgClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EsgClient esgClient = new EsgClient(config); // 初始化EsgClient + + try { + esgClient.deleteEsgRule("esgr-ghwpcwxv3v1x"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/esg/ExampleEsgList.java b/src/main/java/com/baidubce/examples/esg/ExampleEsgList.java new file mode 100644 index 00000000..45e81d6b --- /dev/null +++ b/src/main/java/com/baidubce/examples/esg/ExampleEsgList.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.esg; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.esg.EsgClient; +import com.baidubce.services.esg.EsgClientConfiguration; +import com.baidubce.services.esg.model.ListEsgRequest; +import com.baidubce.services.esg.model.ListEsgResponse; + +public class ExampleEsgList { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EsgClientConfiguration config = new EsgClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EsgClient esgClient = new EsgClient(config); // 初始化EsgClient + + ListEsgRequest listEsgRequest = new ListEsgRequest(); + listEsgRequest.setMaxKeys(100); // 最大返回数量 + try { + ListEsgResponse response = esgClient.listEsg(listEsgRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/esg/ExampleUpdateEsgRule.java b/src/main/java/com/baidubce/examples/esg/ExampleUpdateEsgRule.java new file mode 100644 index 00000000..d558bf3c --- /dev/null +++ b/src/main/java/com/baidubce/examples/esg/ExampleUpdateEsgRule.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.esg; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.esg.EsgClient; +import com.baidubce.services.esg.EsgClientConfiguration; +import com.baidubce.services.esg.model.UpdateEsgRuleRequest; + +public class ExampleUpdateEsgRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EsgClientConfiguration config = new EsgClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EsgClient esgClient = new EsgClient(config); // 初始化EsgClient + + UpdateEsgRuleRequest updateEsgRuleRequest = new UpdateEsgRuleRequest(); + updateEsgRuleRequest.setEnterpriseSecurityGroupRuleId("esgr-ghwpcwxv3v1x"); + updateEsgRuleRequest.setSourceIp("all"); // 规则源IP + updateEsgRuleRequest.setDestIp("all"); // 规则目的IP + updateEsgRuleRequest.setAction("allow"); // 规则允许 + updateEsgRuleRequest.setDirection("ingress"); // 规则的方向 + updateEsgRuleRequest.setPriority(300); // 规则优先级 + updateEsgRuleRequest.setProtocol("tcp"); // 规则协议 + updateEsgRuleRequest.setPortRange("1000-3000"); // 规则端口范围 + updateEsgRuleRequest.setEthertype("IPv4"); // 规则IPv4版本 + + try { + esgClient.updateEsgRule(updateEsgRuleRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/et/ExampleApplyForEt.java b/src/main/java/com/baidubce/examples/et/ExampleApplyForEt.java new file mode 100644 index 00000000..3b74f346 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleApplyForEt.java @@ -0,0 +1,40 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.ApplyForEtRequest; +import com.baidubce.services.et.model.ApplyForEtResponse; + +public class ExampleApplyForEt { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + ApplyForEtRequest request = new ApplyForEtRequest(); + request.setName("NewJavaSdkTestET"); // ET名称 + request.setDescription("New Java sdk test ET"); // ET描述 + request.setIsp("ISP_CMCC"); // 运营商 + request.setIntfType("1G"); // 物理端口规格 + request.setApType("BAIDU"); // 线路类型,百度内部用户:BAIDU,外部用户:SINGLE + request.setApAddr("BB"); // 接入点 + request.setUserIdc("北京|市辖区|东城区|东单"); // 对端地址 + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + ApplyForEtResponse response = etClient.applyForEt(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleAssociateEtChannel.java b/src/main/java/com/baidubce/examples/et/ExampleAssociateEtChannel.java new file mode 100644 index 00000000..5aea169e --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleAssociateEtChannel.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.et; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.AssociateEtChannelRequest; + +public class ExampleAssociateEtChannel { + + /** + * 关联专线通道测试函数 + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + AssociateEtChannelRequest request = new AssociateEtChannelRequest(); + request.setEtId("dcphy-zzdark9nuk1g"); + request.setEtChannelId("dedicatedconn-hzf4aigzqttd"); + request.setExtraChannelId("dedicatedconn-i05sdfw25kqz"); + + try { + etClient.associateEtChannel(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleCreateEtChannel.java b/src/main/java/com/baidubce/examples/et/ExampleCreateEtChannel.java new file mode 100644 index 00000000..0d985623 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleCreateEtChannel.java @@ -0,0 +1,42 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.CreateEtChannelRequest; +import com.baidubce.services.et.model.CreateEtChannelResponse; +import com.google.common.collect.Lists; + +public class ExampleCreateEtChannel { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + CreateEtChannelRequest request = new CreateEtChannelRequest(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-6vtqgw1fk3mj"); // ET ID + request.setAuthorizedUsers(Lists.newArrayList("1beb4ad4762746db96941a5ad253ac8c")); // 分配对象 + request.setDescription("Java sdk test ET channel"); // 专线通道描述 + request.setBaiduAddress("192.168.0.2/24"); // 云端网络互联IP + request.setName("JavaSdkTestEtChannel"); // 通道名称 + request.setCustomerAddress("192.168.0.3/24"); // IDC互联IP + request.setRouteType("static-route"); // 路由协议,当前支持”static-route“(静态)和”bgp“(动态) + request.setVlanId(2); // VLAN ID,取值范围:0, 2-4009 + + try { + CreateEtChannelResponse response = etClient.createEtChannel(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleCreateEtChannelRouteRule.java b/src/main/java/com/baidubce/examples/et/ExampleCreateEtChannelRouteRule.java new file mode 100644 index 00000000..a8beadf7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleCreateEtChannelRouteRule.java @@ -0,0 +1,40 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.CreateEtChannelRouteResponse; +import com.baidubce.services.et.model.CreateEtChannelRouteRuleRequest; + +public class ExampleCreateEtChannelRouteRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + CreateEtChannelRouteRuleRequest request = new CreateEtChannelRouteRuleRequest(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-axibreesn6af"); // ET ID + request.setEtChannelId("dedicatedconn-nezh65s7z325"); // 专线通道ID + request.setIpVersion(4); // IP协议类型,取值[4 | 6],默认为4 + request.setDestAddress("192.168.0.9/32"); // 目标网段 + request.setNexthopType("etChannel"); // 下一跳类型,取值["etGateway" | "etChannel"],分别表示专线网关、专线通道 + request.setNexthopId("dedicatedconn-nezh65s7z325"); // 下一跳实例ID + request.setDescription("Java SDK test"); // 描述 + + try { + CreateEtChannelRouteResponse response = etClient.createEtChannelRouteRule(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleDeleteEtChannel.java b/src/main/java/com/baidubce/examples/et/ExampleDeleteEtChannel.java new file mode 100644 index 00000000..4da4b0ef --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleDeleteEtChannel.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.EtChannelIdRequest; + +public class ExampleDeleteEtChannel { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + EtChannelIdRequest request = new EtChannelIdRequest(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-axibreesn6af"); // ET ID + request.setEtChannelId("dedicatedconn-tkki3g71vr09"); // 专线通道ID + try { + etClient.deleteEtChannel(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleDeleteEtRouteRule.java b/src/main/java/com/baidubce/examples/et/ExampleDeleteEtRouteRule.java new file mode 100644 index 00000000..fb981d50 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleDeleteEtRouteRule.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.EtChannelRouteRuleIdRequest; + +public class ExampleDeleteEtRouteRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + EtChannelRouteRuleIdRequest request = new EtChannelRouteRuleIdRequest(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-axibreesn6af"); // ET ID + request.setEtChannelId("dedicatedconn-nezh65s7z325"); // 专线通道ID + request.setRouteRuleId("dcrr-bf5545b8-de8"); // 专线通道路由规则ID + + try { + etClient.deleteEtRouteRule(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleDisableEtChannelIpv6.java b/src/main/java/com/baidubce/examples/et/ExampleDisableEtChannelIpv6.java new file mode 100644 index 00000000..662f4d61 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleDisableEtChannelIpv6.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.EtChannelIdRequest; + +public class ExampleDisableEtChannelIpv6 { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + EtChannelIdRequest request = new EtChannelIdRequest(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-bjrtsp6ar5ug"); // ET ID + request.setEtChannelId("dedicatedconn-xdzaphpgcqfn"); // 专线通道ID + + try { + etClient.disableEtChannelIpv6(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleDisassociateEtChannel.java b/src/main/java/com/baidubce/examples/et/ExampleDisassociateEtChannel.java new file mode 100644 index 00000000..8f32fa46 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleDisassociateEtChannel.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.et; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.DisassociateEtChannelRequest; + +public class ExampleDisassociateEtChannel { + + /** + * 解关联专线通道测试函数 + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + DisassociateEtChannelRequest request = new DisassociateEtChannelRequest(); + request.setEtId("dcphy-zzdark9nuk1g"); + request.setEtChannelId("dedicatedconn-hzf4aigzqttd"); + request.setExtraChannelId("dedicatedconn-i05sdfw25kqz"); + + try { + etClient.disassociateEtChannel(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleEnableEtChannelIpv6.java b/src/main/java/com/baidubce/examples/et/ExampleEnableEtChannelIpv6.java new file mode 100644 index 00000000..a1f60b48 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleEnableEtChannelIpv6.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.EnableEtChannelIpv6Request; + +public class ExampleEnableEtChannelIpv6 { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + EnableEtChannelIpv6Request request = new EnableEtChannelIpv6Request(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-bjrtsp6ar5ug"); // ET ID + request.setEtChannelId("dedicatedconn-xdzaphpgcqfn"); // 专线通道ID + request.setBaiduIpv6Address("2400:DA00:E003:0000:016A:0400:0000:100/127"); // 云端网络侧IPv6互联地址 + request.setCustomerIpv6Address("2400:DA00:E003:0000:016A:0400:0000:101/127"); // IDC侧IPv6互联地址 + + try { + etClient.enableEtChannelIpv6(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleGetEtDetail.java b/src/main/java/com/baidubce/examples/et/ExampleGetEtDetail.java new file mode 100644 index 00000000..c608ac71 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleGetEtDetail.java @@ -0,0 +1,27 @@ +package com.baidubce.examples.et; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.Et; + +public class ExampleGetEtDetail { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + try { + Et et = etClient.getEtDetail("dcphy-t6ewxjaekkt2"); // 获取对应ET ID的ET详情 + System.out.println(et); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleListEtChannelRouteRules.java b/src/main/java/com/baidubce/examples/et/ExampleListEtChannelRouteRules.java new file mode 100644 index 00000000..8c0f1b35 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleListEtChannelRouteRules.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.et; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.ListEtChannelRouteRulesRequest; +import com.baidubce.services.et.model.ListEtChannelRouteRulesResponse; + +public class ExampleListEtChannelRouteRules { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + ListEtChannelRouteRulesRequest request = new ListEtChannelRouteRulesRequest(); + request.setEtId("dcphy-axibreesn6af"); // ET ID + request.setEtChannelId("dedicatedconn-nezh65s7z325"); // 专线通道ID + request.setDestAddress("192.168.0.9/32"); // 目标网段 + + try { + ListEtChannelRouteRulesResponse response = etClient.listEtChannelRouteRules(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleListEtChannels.java b/src/main/java/com/baidubce/examples/et/ExampleListEtChannels.java new file mode 100644 index 00000000..f7ac7212 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleListEtChannels.java @@ -0,0 +1,27 @@ +package com.baidubce.examples.et; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.ListEtChannelsResponse; + +public class ExampleListEtChannels { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + try { + ListEtChannelsResponse response = etClient.listEtChannels("dcphy-axibreesn6af"); // 获取对应ET ID下的通道 + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleListEts.java b/src/main/java/com/baidubce/examples/et/ExampleListEts.java new file mode 100644 index 00000000..ccae46c1 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleListEts.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.et; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.ListEtRequest; +import com.baidubce.services.et.model.ListEtResponse; + +public class ExampleListEts { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + ListEtRequest request = new ListEtRequest(); + request.setMarker("dcphy-t6ewxjaekkt2"); // 批量获取列表的查询的起始位置,ET ID标记 + request.setMaxKeys(5); // 每页包含的最大数量,最大数量通常不超过1000,缺省值为1000 + request.setStatus("ack-wait"); + try { + ListEtResponse response = etClient.listEts(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleResubmitEtChannel.java b/src/main/java/com/baidubce/examples/et/ExampleResubmitEtChannel.java new file mode 100644 index 00000000..0b5dc587 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleResubmitEtChannel.java @@ -0,0 +1,41 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.ResubmitEtChannelRequest; +import com.google.common.collect.Lists; + +public class ExampleResubmitEtChannel { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + ResubmitEtChannelRequest request = new ResubmitEtChannelRequest(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-axibreesn6af"); // ET ID + request.setEtChannelId("dedicatedconn-3nv9cus8geaf"); // 专线通道ID + request.setAuthorizedUsers(Lists.newArrayList("1beb4ad4762746db96941a5ad253ac8c")); // 分配对象 + request.setDescription("Java sdk test ET channel"); // 专线通道描述 + request.setBaiduAddress("192.168.1.1/24"); // 云端网络互联IP + request.setName("JavaSdkTestEtChannel"); // 通道名称 + request.setCustomerAddress("192.168.1.2/24"); // IDC互联IP + request.setRouteType("static-route"); // 路由协议,当前支持”static-route“(静态)和”bgp“(动态) + request.setVlanId(2); // VLAN ID,取值范围:0, 2-4009 + + try { + etClient.resubmitEtChannel(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleUpdateEt.java b/src/main/java/com/baidubce/examples/et/ExampleUpdateEt.java new file mode 100644 index 00000000..d6867426 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleUpdateEt.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.UpdateEtRequest; + +public class ExampleUpdateEt { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + UpdateEtRequest request = new UpdateEtRequest(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-t6ewxjaekkt2"); // ET ID + request.setName("JavaSdkTestETUpdate"); // ET 更新名字 + request.setDescription("Java sdk test ET update"); // ET 更新描述 + + try { + etClient.updateEt(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleUpdateEtChannel.java b/src/main/java/com/baidubce/examples/et/ExampleUpdateEtChannel.java new file mode 100644 index 00000000..5a764438 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleUpdateEtChannel.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.UpdateEtChannelRequest; + +public class ExampleUpdateEtChannel { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + UpdateEtChannelRequest request = new UpdateEtChannelRequest(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-axibreesn6af"); // ET ID + request.setEtChannelId("dedicatedconn-kd1ff138ypnm"); // 专线通道ID + request.setDescription("Java sdk test ET channel update"); // 专线通道描述 + request.setName("JavaSdkTestEtChannelUpdate"); // 通道名称 + + try { + etClient.updateEtChannel(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/et/ExampleUpdateEtChannelRouteRule.java b/src/main/java/com/baidubce/examples/et/ExampleUpdateEtChannelRouteRule.java new file mode 100644 index 00000000..f3a94c37 --- /dev/null +++ b/src/main/java/com/baidubce/examples/et/ExampleUpdateEtChannelRouteRule.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.et; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.et.EtClient; +import com.baidubce.services.et.EtClientConfiguration; +import com.baidubce.services.et.model.UpdateEtChannelRouteRuleRequest; + +public class ExampleUpdateEtChannelRouteRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // ET服务对应的域名 + + EtClientConfiguration config = new EtClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtClient etClient = new EtClient(config); // 初始化ET client + + UpdateEtChannelRouteRuleRequest request = new UpdateEtChannelRouteRuleRequest(); + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + request.setEtId("dcphy-axibreesn6af"); // ET ID + request.setEtChannelId("dedicatedconn-nezh65s7z325"); // 专线通道ID + request.setRouteRuleId("dcrr-bf5545b8-de8"); // 专线通道路由规则ID + request.setDescription("Java SDK test update"); // 描述信息 + + try { + etClient.updateEtChannelRouteRule(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/etgateway/ExampleBindEtChannel.java b/src/main/java/com/baidubce/examples/etgateway/ExampleBindEtChannel.java new file mode 100644 index 00000000..8989ad27 --- /dev/null +++ b/src/main/java/com/baidubce/examples/etgateway/ExampleBindEtChannel.java @@ -0,0 +1,39 @@ +package com.baidubce.examples.etgateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.etgateway.EtGatewayClient; +import com.baidubce.services.etgateway.EtGatewayClientConfiguration; +import com.baidubce.services.etgateway.model.BindEtChannelRequest; +import com.google.common.collect.Lists; + +import java.util.UUID; + +public class ExampleBindEtChannel { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EtGatewayClientConfiguration config = new EtGatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtGatewayClient etGatewayClient = new EtGatewayClient(config); // 初始化Client + + BindEtChannelRequest bindEtChannelRequest = new BindEtChannelRequest(); + bindEtChannelRequest.setEtGatewayId("dcgw-9pwwq206xj58"); // 专线网关的id + bindEtChannelRequest.setEtId("dcphy-ejtn7ffk9rnd"); // 绑定的物理专线的id,etId和channelId必须同时存在 + bindEtChannelRequest.setChannelId("dedicatedconn-xzxm902fvz9d"); // 绑定的专线通道的id + + // 专线网关的云端网络,用户可以选本vpc网段或自定义一个或多个网段 + bindEtChannelRequest.setLocalCidrs(Lists.newArrayList("192.168.0.0/20")); + + bindEtChannelRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + etGatewayClient.bindEtChannel(bindEtChannelRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/etgateway/ExampleCreateEtGateway.java b/src/main/java/com/baidubce/examples/etgateway/ExampleCreateEtGateway.java new file mode 100644 index 00000000..da44d05f --- /dev/null +++ b/src/main/java/com/baidubce/examples/etgateway/ExampleCreateEtGateway.java @@ -0,0 +1,47 @@ +package com.baidubce.examples.etgateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.etgateway.EtGatewayClient; +import com.baidubce.services.etgateway.EtGatewayClientConfiguration; +import com.baidubce.services.etgateway.model.CreateEtGatewayRequest; +import com.baidubce.services.etgateway.model.CreateEtGatewayResponse; +import com.google.common.collect.Lists; + +import java.util.UUID; + +public class ExampleCreateEtGateway { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EtGatewayClientConfiguration config = new EtGatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtGatewayClient etGatewayClient = new EtGatewayClient(config); // 初始化Client + + CreateEtGatewayRequest createEtGatewayRequest = new CreateEtGatewayRequest(); + + // 专线网关的名称,由大小写字母、数字以及-_ /.特殊字符组成,必须以字母开头,长度1-65 + createEtGatewayRequest.setName("java_sdk_test_et_gw1"); + + createEtGatewayRequest.setVpcId("vpc-63b9cr90g5zn"); // 专线网关所属vpc的id + createEtGatewayRequest.setSpeed(100); // 专线网关带宽的限速值,单位为Mbps。限制为为2~10000之间的整数 + createEtGatewayRequest.setDescription("java sdk test et gateway."); // 专线网关的描述,不超过200字符 + createEtGatewayRequest.setEtId("dcphy-ejtn7ffk9rnd"); // 绑定的物理专线的id,etId和channelId必须同时存在 + createEtGatewayRequest.setChannelId("dedicatedconn-xzxm902fvz9d"); // 绑定的专线通道的id,etId和channelId必须同时存在 + + // 专线网关的云端网络,用户可以选本vpc网段或自定义一个或多个网段,仅当参数etId和channelId存在时可以设置 + createEtGatewayRequest.setLocalCidrs(Lists.newArrayList("192.168.0.0/20")); + + createEtGatewayRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + CreateEtGatewayResponse createEtGatewayResponse = etGatewayClient.createEtGateway(createEtGatewayRequest); + System.out.println("createEtGatewayResponse = " + createEtGatewayResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/etgateway/ExampleCreateEtGatewayHealthCheck.java b/src/main/java/com/baidubce/examples/etgateway/ExampleCreateEtGatewayHealthCheck.java new file mode 100644 index 00000000..84a61958 --- /dev/null +++ b/src/main/java/com/baidubce/examples/etgateway/ExampleCreateEtGatewayHealthCheck.java @@ -0,0 +1,42 @@ +package com.baidubce.examples.etgateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.etgateway.EtGatewayClient; +import com.baidubce.services.etgateway.EtGatewayClientConfiguration; +import com.baidubce.services.etgateway.model.CreateEtGatewayHealthCheckRequest; + +import java.util.UUID; + +public class ExampleCreateEtGatewayHealthCheck { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EtGatewayClientConfiguration config = new EtGatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtGatewayClient etGatewayClient = new EtGatewayClient(config); // 初始化Client + + CreateEtGatewayHealthCheckRequest createEtGatewayHealthCheckRequest = new CreateEtGatewayHealthCheckRequest(); + createEtGatewayHealthCheckRequest.setEtGatewayId("dcgw-9pwwq206xj58"); // 专线网关的id + createEtGatewayHealthCheckRequest.setHealthCheckSourceIp(""); // 若不传该参数,系统会自动分配一个IP + createEtGatewayHealthCheckRequest.setHealthCheckType("ICMP"); // 参数可取值为"ICMP",默认为"ICMP" + createEtGatewayHealthCheckRequest.setHealthCheckPort(8000); // 健康检查的端口 + createEtGatewayHealthCheckRequest.setHealthCheckInterval(40); // 健康检查的间隔,1-60之间的整数,单位s + createEtGatewayHealthCheckRequest.setHealthThreshold(2); // 健康检查阈值,2-5之间的整数 + createEtGatewayHealthCheckRequest.setUnhealthThreshold(4); // 不健康检查阈值,2-5之间的整数 + + // 是否自动生成探测路由,默认开启。如需关闭,选择false。 + createEtGatewayHealthCheckRequest.setAutoGenerateRouteRule(false); + + createEtGatewayHealthCheckRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + etGatewayClient.createEtGatewayHealthCheck(createEtGatewayHealthCheckRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/etgateway/ExampleDeleteEtGateway.java b/src/main/java/com/baidubce/examples/etgateway/ExampleDeleteEtGateway.java new file mode 100644 index 00000000..1e705327 --- /dev/null +++ b/src/main/java/com/baidubce/examples/etgateway/ExampleDeleteEtGateway.java @@ -0,0 +1,40 @@ +package com.baidubce.examples.etgateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.etgateway.EtGatewayClient; +import com.baidubce.services.etgateway.EtGatewayClientConfiguration; + +import java.util.UUID; + +public class ExampleDeleteEtGateway { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EtGatewayClientConfiguration config = new EtGatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtGatewayClient etGatewayClient = new EtGatewayClient(config); // 初始化Client + + String etGatewayId = "dcgw-9pwwq206xj58"; // 需要释放的专线网关的id + + // 方式一 + try { + // 没设置幂等,自动加上幂等参数 + etGatewayClient.deleteEtGateway(etGatewayId); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + // 方式二 + String clientToken = UUID.randomUUID().toString(); // 幂等性Token + try { + etGatewayClient.deleteEtGateway(etGatewayId, clientToken); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/etgateway/ExampleGetEtGateway.java b/src/main/java/com/baidubce/examples/etgateway/ExampleGetEtGateway.java new file mode 100644 index 00000000..5d28f1a6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/etgateway/ExampleGetEtGateway.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.etgateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.etgateway.EtGatewayClient; +import com.baidubce.services.etgateway.EtGatewayClientConfiguration; +import com.baidubce.services.etgateway.model.GetEtGatewayResponse; + +public class ExampleGetEtGateway { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EtGatewayClientConfiguration config = new EtGatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtGatewayClient etGatewayClient = new EtGatewayClient(config); // 初始化Client + + String etGatewayId = "dcgw-9pwwq206xj58"; // 专线网关的id + + try { + GetEtGatewayResponse getEtGatewayResponse = etGatewayClient.getEtGateway(etGatewayId); + System.out.println("getEtGatewayResponse = " + getEtGatewayResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/etgateway/ExampleListEtGateways.java b/src/main/java/com/baidubce/examples/etgateway/ExampleListEtGateways.java new file mode 100644 index 00000000..b050e5eb --- /dev/null +++ b/src/main/java/com/baidubce/examples/etgateway/ExampleListEtGateways.java @@ -0,0 +1,37 @@ +package com.baidubce.examples.etgateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.etgateway.EtGatewayClient; +import com.baidubce.services.etgateway.EtGatewayClientConfiguration; +import com.baidubce.services.etgateway.model.ListEtGatewayRequest; +import com.baidubce.services.etgateway.model.ListEtGatewayResponse; + +public class ExampleListEtGateways { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EtGatewayClientConfiguration config = new EtGatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtGatewayClient etGatewayClient = new EtGatewayClient(config); // 初始化Client + + ListEtGatewayRequest listEtGatewayRequest = new ListEtGatewayRequest(); + listEtGatewayRequest.setVpcId("vpc-63b9cr90g5zn"); // vpc的id + listEtGatewayRequest.setEtGatewayId(""); // 专线网关的id + listEtGatewayRequest.setName("java_sdk"); // 专线网关的名称,支持模糊查询 + listEtGatewayRequest.setStatus("running"); // 专线网关的状态 + listEtGatewayRequest.setMarker(""); // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + listEtGatewayRequest.setMaxKeys(10); // 每页包含的最大数量,最大数量不超过1000。缺省值为1000 + + + try { + ListEtGatewayResponse listEtGatewayResponse = etGatewayClient.listEtGateways(listEtGatewayRequest); + System.out.println("listEtGatewayResponse = " + listEtGatewayResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/etgateway/ExampleUnbindEtChannel.java b/src/main/java/com/baidubce/examples/etgateway/ExampleUnbindEtChannel.java new file mode 100644 index 00000000..19051e58 --- /dev/null +++ b/src/main/java/com/baidubce/examples/etgateway/ExampleUnbindEtChannel.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.etgateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.etgateway.EtGatewayClient; +import com.baidubce.services.etgateway.EtGatewayClientConfiguration; +import com.baidubce.services.etgateway.model.UnbindEtChannelRequest; + +import java.util.UUID; + +public class ExampleUnbindEtChannel { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EtGatewayClientConfiguration config = new EtGatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtGatewayClient etGatewayClient = new EtGatewayClient(config); // 初始化Client + + UnbindEtChannelRequest unbindEtChannelRequest = new UnbindEtChannelRequest(); + unbindEtChannelRequest.setEtGatewayId("dcgw-9pwwq206xj58"); // 专线网关的id + unbindEtChannelRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + etGatewayClient.unbindEtChannel(unbindEtChannelRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/etgateway/ExampleUpdateEtGateway.java b/src/main/java/com/baidubce/examples/etgateway/ExampleUpdateEtGateway.java new file mode 100644 index 00000000..cfc2b815 --- /dev/null +++ b/src/main/java/com/baidubce/examples/etgateway/ExampleUpdateEtGateway.java @@ -0,0 +1,48 @@ +package com.baidubce.examples.etgateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.etgateway.EtGatewayClient; +import com.baidubce.services.etgateway.EtGatewayClientConfiguration; +import com.baidubce.services.etgateway.model.UpdateEtGatewayRequest; +import com.google.common.collect.Lists; + +import java.util.UUID; + +public class ExampleUpdateEtGateway { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + EtGatewayClientConfiguration config = new EtGatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + EtGatewayClient etGatewayClient = new EtGatewayClient(config); // 初始化Client + + UpdateEtGatewayRequest updateEtGatewayRequest = new UpdateEtGatewayRequest(); + updateEtGatewayRequest.setEtGatewayId("dcgw-9pwwq206xj58"); // 专线网关的id + + // 专线网关的名称,由大小写字母、数字以及-_ /.特殊字符组成,必须以字母开头,长度1-65 + updateEtGatewayRequest.setName("java_sdk_et_gw_update"); + + updateEtGatewayRequest.setSpeed(200); // 专线网关带宽的限速值,单位为Mbps。限制为2~100000之间的整数 + updateEtGatewayRequest.setDescription("java sdk test update et gateway."); // 专线网关的描述,不超过200字符 + + // 专线网关的IPv4云端网络,用户可以选本vpc网段或自定义一个或多个网段 + updateEtGatewayRequest.setLocalCidrs(Lists.newArrayList("192.168.0.0/20")); + + updateEtGatewayRequest.setEnableIpv6(1); // IPv6功能是否开启,1是0否,IPv6为白名单功能 + + // 专线网关的IPv6云端网络,用户可以选本vpc网段或自定义一个或多个IPv6网段 + updateEtGatewayRequest.setIpv6LocalCidrs(Lists.newArrayList("240c:4085:0:6a02::/80")); + + updateEtGatewayRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + etGatewayClient.updateEtGateway(updateEtGatewayRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/havip/ExampleCreateHaVip.java b/src/main/java/com/baidubce/examples/havip/ExampleCreateHaVip.java new file mode 100644 index 00000000..9402f23c --- /dev/null +++ b/src/main/java/com/baidubce/examples/havip/ExampleCreateHaVip.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.havip; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.havip.HaVipClient; +import com.baidubce.services.havip.HaVipClientConfiguration; +import com.baidubce.services.havip.model.CreateHaVipRequest; +import com.baidubce.services.havip.model.CreateHaVipResponse; + +public class ExampleCreateHaVip { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + HaVipClientConfiguration config = new HaVipClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + HaVipClient haVipClient = new HaVipClient(config); // 初始化Client + CreateHaVipRequest createHaVipRequest = new CreateHaVipRequest(); + createHaVipRequest.setSubnetId(""); // 子网ID + createHaVipRequest.setDescription("desc"); // 描述 + createHaVipRequest.setName("havip"); // havip名字 + createHaVipRequest.setPrivateIpAddress(""); // 指定havip IP地址 + + try { + CreateHaVipResponse createHaVipResponse = haVipClient.createHaVip(createHaVipRequest); + System.out.println(createHaVipResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/havip/ExampleDeleteHaVip.java b/src/main/java/com/baidubce/examples/havip/ExampleDeleteHaVip.java new file mode 100644 index 00000000..30023f5f --- /dev/null +++ b/src/main/java/com/baidubce/examples/havip/ExampleDeleteHaVip.java @@ -0,0 +1,30 @@ +package com.baidubce.examples.havip; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.havip.HaVipClient; +import com.baidubce.services.havip.HaVipClientConfiguration; +import com.baidubce.services.havip.model.DeleteHaVipRequest; + +public class ExampleDeleteHaVip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + HaVipClientConfiguration config = new HaVipClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + HaVipClient haVipClient = new HaVipClient(config); // 初始化Client + + DeleteHaVipRequest deleteHaVipRequest = new DeleteHaVipRequest(); + deleteHaVipRequest.setHaVipId("havip-w2d4kgc3x0y1"); // 高可用虚拟IP的ID + + try { + haVipClient.deleteHaVip(deleteHaVipRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/havip/ExampleGetHaVip.java b/src/main/java/com/baidubce/examples/havip/ExampleGetHaVip.java new file mode 100644 index 00000000..44804a7f --- /dev/null +++ b/src/main/java/com/baidubce/examples/havip/ExampleGetHaVip.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.havip; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.havip.HaVipClient; +import com.baidubce.services.havip.HaVipClientConfiguration; +import com.baidubce.services.havip.model.HaVipResponse; + +public class ExampleGetHaVip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + HaVipClientConfiguration config = new HaVipClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + HaVipClient haVipClient = new HaVipClient(config); // 初始化Client + + String haVipId = "havip-w2d4kgc3x0y1"; // 高可用虚拟IP的ID + + try { + HaVipResponse haVip = haVipClient.getHaVip(haVipId); + System.out.println(haVip); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/havip/ExampleHaVipBindEip.java b/src/main/java/com/baidubce/examples/havip/ExampleHaVipBindEip.java new file mode 100644 index 00000000..87522a74 --- /dev/null +++ b/src/main/java/com/baidubce/examples/havip/ExampleHaVipBindEip.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.havip; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.havip.HaVipClient; +import com.baidubce.services.havip.HaVipClientConfiguration; +import com.baidubce.services.havip.model.BindEipRequest; + +public class ExampleHaVipBindEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + HaVipClientConfiguration config = new HaVipClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + HaVipClient haVipClient = new HaVipClient(config); // 初始化Client + + BindEipRequest bindEipRequest = new BindEipRequest(); + bindEipRequest.setHaVipId("havip-w2d4kgc3x0y1"); // 高可用虚拟IP的ID + bindEipRequest.setPublicIpAddress("180.76.245.166"); // 公网IP + + + try { + haVipClient.bindEip(bindEipRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/havip/ExampleHaVipBindInstance.java b/src/main/java/com/baidubce/examples/havip/ExampleHaVipBindInstance.java new file mode 100644 index 00000000..23befb35 --- /dev/null +++ b/src/main/java/com/baidubce/examples/havip/ExampleHaVipBindInstance.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.havip; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.havip.HaVipClient; +import com.baidubce.services.havip.HaVipClientConfiguration; +import com.baidubce.services.havip.model.BindInstanceRequest; + +import java.util.Arrays; + +public class ExampleHaVipBindInstance { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + HaVipClientConfiguration config = new HaVipClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + HaVipClient haVipClient = new HaVipClient(config); // 初始化Client + + BindInstanceRequest bindInstanceRequest = new BindInstanceRequest(); + bindInstanceRequest.setHaVipId("havip-w2d4kgc3x0y1"); // 高可用虚拟IP的ID + bindInstanceRequest.setInstanceType("ENI"); // 绑定的实例类型,"SERVER"表示云服务器(BCC/BBC/DCC),"ENI"表示弹性网卡 + bindInstanceRequest.setInstanceIds(Arrays.asList("eni-w2d4kgc3x0y1")); // 绑定的实例ID列表,列表长度不大于5 + + + try { + haVipClient.bindInstance(bindInstanceRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/havip/ExampleHaVipUnbindEip.java b/src/main/java/com/baidubce/examples/havip/ExampleHaVipUnbindEip.java new file mode 100644 index 00000000..4ceb03f5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/havip/ExampleHaVipUnbindEip.java @@ -0,0 +1,30 @@ +package com.baidubce.examples.havip; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.havip.HaVipClient; +import com.baidubce.services.havip.HaVipClientConfiguration; +import com.baidubce.services.havip.model.UnBindEipRequest; + +public class ExampleHaVipUnbindEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + HaVipClientConfiguration config = new HaVipClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + HaVipClient haVipClient = new HaVipClient(config); // 初始化Client + + UnBindEipRequest unBindEipRequest = new UnBindEipRequest(); + unBindEipRequest.setHaVipId("havip-w2d4kgc3x0y1"); // 高可用虚拟IP的ID + + try { + haVipClient.unBindEip(unBindEipRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/havip/ExampleHaVipUnbindInstance.java b/src/main/java/com/baidubce/examples/havip/ExampleHaVipUnbindInstance.java new file mode 100644 index 00000000..3f4f7a75 --- /dev/null +++ b/src/main/java/com/baidubce/examples/havip/ExampleHaVipUnbindInstance.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.havip; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.havip.HaVipClient; +import com.baidubce.services.havip.HaVipClientConfiguration; +import com.baidubce.services.havip.model.UnBindInstanceRequest; + +import java.util.Arrays; + +public class ExampleHaVipUnbindInstance { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + HaVipClientConfiguration config = new HaVipClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + HaVipClient haVipClient = new HaVipClient(config); // 初始化Client + + UnBindInstanceRequest unBindInstanceRequest = new UnBindInstanceRequest(); + unBindInstanceRequest.setHaVipId("havip-w2d4kgc3x0y1"); // 高可用虚拟IP的ID + unBindInstanceRequest.setInstanceType("ENI"); // 解绑的实例类型,"SERVER"表示云服务器(BCC/BBC/DCC),"ENI"表示弹性网卡 + unBindInstanceRequest.setInstanceIds(Arrays.asList("eni-w2d4kgc3x0y1")); // 解绑的实例ID列表,列表长度不大于5 + + + try { + haVipClient.unBindInstance(unBindInstanceRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/havip/ExampleListHaVip.java b/src/main/java/com/baidubce/examples/havip/ExampleListHaVip.java new file mode 100644 index 00000000..7d1fd8a2 --- /dev/null +++ b/src/main/java/com/baidubce/examples/havip/ExampleListHaVip.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.havip; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.havip.HaVipClient; +import com.baidubce.services.havip.HaVipClientConfiguration; +import com.baidubce.services.havip.model.ListHaVipResponse; + +public class ExampleListHaVip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + HaVipClientConfiguration config = new HaVipClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + HaVipClient haVipClient = new HaVipClient(config); // 初始化Client + + String vpcId = "vpc-r625rqw3wuer"; // 高可用虚拟IP所属的VPC ID + + try { + ListHaVipResponse listHaVipResponse = haVipClient.listHaVip(vpcId); + System.out.println(listHaVipResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/havip/ExampleUpdateHaVip.java b/src/main/java/com/baidubce/examples/havip/ExampleUpdateHaVip.java new file mode 100644 index 00000000..ee4b63cf --- /dev/null +++ b/src/main/java/com/baidubce/examples/havip/ExampleUpdateHaVip.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.havip; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.havip.HaVipClient; +import com.baidubce.services.havip.HaVipClientConfiguration; +import com.baidubce.services.havip.model.UpdateHaVipRequest; + +public class ExampleUpdateHaVip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + HaVipClientConfiguration config = new HaVipClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + HaVipClient haVipClient = new HaVipClient(config); // 初始化Client + + UpdateHaVipRequest updateHaVipRequest = new UpdateHaVipRequest(); + updateHaVipRequest.setHaVipId("havip-w2d4kgc3x0y1"); // 高可用虚拟IP的ID + updateHaVipRequest.setDescription("desc"); // 高可用虚拟IP的描述 + updateHaVipRequest.setName("name"); // 高可用虚拟IP的名称 + + try { + haVipClient.updateHaVip(updateHaVipRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleBindIpSet.java b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleBindIpSet.java new file mode 100644 index 00000000..7b043e95 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleBindIpSet.java @@ -0,0 +1,41 @@ +package com.baidubce.examples.ipcollection.ipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipgroup.BindIpSetRequest; + +import java.util.ArrayList; +import java.util.List; + +public class ExampleBindIpSet { + + /** + * ExampleBindIpSet main method + * + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + BindIpSetRequest request = new BindIpSetRequest(); + request.setIpGroupId("ipg-p40bmsaw3aad"); + List ipSetIds = new ArrayList<>(); + ipSetIds.add("ips-zmbp03b6wz8a"); + ipSetIds.add("ips-vqkhe16ex5vb"); + request.setIpSetIds(ipSetIds); + try { + ipCollectionClient.bindIpSet(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } + +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleCreateIpAddressGroup.java b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleCreateIpAddressGroup.java new file mode 100644 index 00000000..1df00a4b --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleCreateIpAddressGroup.java @@ -0,0 +1,40 @@ +package com.baidubce.examples.ipcollection.ipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipgroup.CreateIpAddressGroupRequest; + +import java.util.ArrayList; +import java.util.List; + +public class ExampleCreateIpAddressGroup { + /** + * ExampleCreateIpAddressGroup main method + * + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + CreateIpAddressGroupRequest request = new CreateIpAddressGroupRequest(); + request.setName("ipGroupByCode"); + request.setIpVersion("IPv4"); + request.setDescription("test description"); + List ipSetList = new ArrayList<>(); + ipSetList.add("ips-xwnu2mdjcxfy"); + request.setIpSetIds(ipSetList); + try { + ipCollectionClient.createIpAddressGroup(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleDeleteIpGroup.java b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleDeleteIpGroup.java new file mode 100644 index 00000000..5137d994 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleDeleteIpGroup.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.ipcollection.ipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipgroup.DeleteIpGroupRequest; + +public class ExampleDeleteIpGroup { + /** + * ExampleDeleteIpGroup main method + * + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + DeleteIpGroupRequest request = new DeleteIpGroupRequest(); + request.setIpGroupId("ipg-8mnay8wgvd1i"); + try { + ipCollectionClient.deleteIpGroup(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleQueryIpGroupDetail.java b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleQueryIpGroupDetail.java new file mode 100644 index 00000000..268c2be7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleQueryIpGroupDetail.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.ipcollection.ipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipgroup.QueryIpGroupDetailRequest; +import com.baidubce.services.ipcollection.model.ipgroup.QueryIpGroupDetailResponse; + +public class ExampleQueryIpGroupDetail { + /** + * ExampleQueryIpGroupDetail main method + * + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + QueryIpGroupDetailRequest request = new QueryIpGroupDetailRequest(); + request.setIpGroupId("ipg-p40bmsaw3aad"); + try { + QueryIpGroupDetailResponse response = ipCollectionClient.queryIpGroupDetail(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleQueryIpGroupList.java b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleQueryIpGroupList.java new file mode 100644 index 00000000..90e19103 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleQueryIpGroupList.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.ipcollection.ipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipgroup.QueryIpGroupListRequest; +import com.baidubce.services.ipcollection.model.ipgroup.QueryIpGroupListResponse; + +public class ExampleQueryIpGroupList { + /** + * ExampleQueryIpGroupList main method + * + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + QueryIpGroupListRequest request = new QueryIpGroupListRequest(); + request.setIpVersion("IPv4"); + request.setMaxKeys(10); + request.setMarker("ipg-de165m88ipiz"); + try { + QueryIpGroupListResponse response = ipCollectionClient.queryIpGroupList(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleUnBindIpSet.java b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleUnBindIpSet.java new file mode 100644 index 00000000..45db2ddf --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleUnBindIpSet.java @@ -0,0 +1,39 @@ +package com.baidubce.examples.ipcollection.ipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipgroup.UnBindIpSetRequest; + +import java.util.ArrayList; +import java.util.List; + +public class ExampleUnBindIpSet { + /** + * ExampleUnBindIpSet main method + * + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + UnBindIpSetRequest request = new UnBindIpSetRequest(); + request.setIpGroupId("ipg-p40bmsaw3aad"); + List ipSetIds = new ArrayList<>(); + ipSetIds.add("ips-zmbp03b6wz8a"); + ipSetIds.add("ips-vqkhe16ex5vb"); + request.setIpSetIds(ipSetIds); + try { + ipCollectionClient.unBindIpSet(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleUpdateIpGroup.java b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleUpdateIpGroup.java new file mode 100644 index 00000000..ff0586d3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipgroup/ExampleUpdateIpGroup.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.ipcollection.ipgroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipgroup.UpdateIpGroupRequest; + +public class ExampleUpdateIpGroup { + /** + * ExampleUpdateIpGroup main method + * + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + UpdateIpGroupRequest request = new UpdateIpGroupRequest(); + request.setIpGroupId("ipg-p40bmsaw3aad"); + request.setName("ipGroupByCode_Update"); + request.setDescription("test description update"); + try { + ipCollectionClient.updateIpGroup(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleAddIpAddressToIpSet.java b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleAddIpAddressToIpSet.java new file mode 100644 index 00000000..c4150186 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleAddIpAddressToIpSet.java @@ -0,0 +1,43 @@ +package com.baidubce.examples.ipcollection.ipset; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipset.AddIpAddressToIpSetRequest; +import com.baidubce.services.ipcollection.model.TemplateIpAddressInfo; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ExampleAddIpAddressToIpSet { + /** + * ExampleAddIpAddressToIpSet main method + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + AddIpAddressToIpSetRequest request = new AddIpAddressToIpSetRequest(); + request.setClientToken(UUID.randomUUID().toString()); + request.setIpSetId("ips-zmbp03b6wz8a"); + List ipAddressInfo = new ArrayList<>(); + TemplateIpAddressInfo templateIpAddressInfo = new TemplateIpAddressInfo(); + templateIpAddressInfo.setIpAddress("192.168.35.0"); + templateIpAddressInfo.setDescription("test ip address"); + ipAddressInfo.add(templateIpAddressInfo); + request.setIpAddressInfo(ipAddressInfo); + try { + ipCollectionClient.addIpAddressToIpSet(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleCreateIpAddressSet.java b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleCreateIpAddressSet.java new file mode 100644 index 00000000..2ceec2a0 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleCreateIpAddressSet.java @@ -0,0 +1,45 @@ +package com.baidubce.examples.ipcollection.ipset; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipset.CreateIpAddressSetRequest; +import com.baidubce.services.ipcollection.model.TemplateIpAddressInfo; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ExampleCreateIpAddressSet { + /** + * ExampleCreateIpAddressSet main method + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + CreateIpAddressSetRequest createIpAddressGroupRequest = new CreateIpAddressSetRequest(); + createIpAddressGroupRequest.setClientToken(UUID.randomUUID().toString()); + createIpAddressGroupRequest.setName("ipSet_name"); + createIpAddressGroupRequest.setIpVersion("IPv4"); + List ipAddressInfo = new ArrayList<>(); + TemplateIpAddressInfo templateIpAddressInfo = new TemplateIpAddressInfo(); + templateIpAddressInfo.setIpAddress("192.168.33.0"); + templateIpAddressInfo.setDescription("ipAddress description"); + ipAddressInfo.add(templateIpAddressInfo); + createIpAddressGroupRequest.setIpAddressInfo(ipAddressInfo); + createIpAddressGroupRequest.setDescription("ipSet description"); + try { + ipCollectionClient.createIpAddressSet(createIpAddressGroupRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleDeleteIpSet.java b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleDeleteIpSet.java new file mode 100644 index 00000000..27ba6f23 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleDeleteIpSet.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.ipcollection.ipset; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipset.DeleteIpSetRequest; + +import java.util.UUID; + +public class ExampleDeleteIpSet { + /** + * ExampleDeleteIpSet main method + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + DeleteIpSetRequest deleteIpSetRequest = new DeleteIpSetRequest(); + deleteIpSetRequest.setClientToken(UUID.randomUUID().toString()); + deleteIpSetRequest.setIpSetId("ips-vc9utvvvhrqb"); + try { + ipCollectionClient.deleteIpSet(deleteIpSetRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleQueryIpSetDetail.java b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleQueryIpSetDetail.java new file mode 100644 index 00000000..598fce39 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleQueryIpSetDetail.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.ipcollection.ipset; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipset.QueryIpSetDetailRequest; +import com.baidubce.services.ipcollection.model.ipset.QueryIpSetDetailResponse; + +public class ExampleQueryIpSetDetail { + /** + * ExampleQueryIpSetDetail main method + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + QueryIpSetDetailRequest request = new QueryIpSetDetailRequest(); + request.setIpSetId("ips-xwnu2mdjcxfy"); + try { + QueryIpSetDetailResponse queryIpSetDetailResponse = ipCollectionClient.queryIpSetDetail(request); + System.out.println(queryIpSetDetailResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleQueryIpSetList.java b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleQueryIpSetList.java new file mode 100644 index 00000000..b4f06a5e --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleQueryIpSetList.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.ipcollection.ipset; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipset.QueryIpSetListRequest; +import com.baidubce.services.ipcollection.model.ipset.QueryIpSetListResponse; + +public class ExampleQueryIpSetList { + + /** + * ExampleQueryIpSetList main method + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + QueryIpSetListRequest request = new QueryIpSetListRequest(); + request.setIpVersion("IPv4"); + request.setMaxKeys(10); + request.setMarker("ips-xwnu2mdjcxfy"); + try { + QueryIpSetListResponse response = ipCollectionClient.queryIpSetList(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleRemoveIpAddressFromIpSet.java b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleRemoveIpAddressFromIpSet.java new file mode 100644 index 00000000..2d95f34a --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleRemoveIpAddressFromIpSet.java @@ -0,0 +1,41 @@ +package com.baidubce.examples.ipcollection.ipset; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipset.RemoveIpAddressFromIpSetRequest; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ExampleRemoveIpAddressFromIpSet { + + /** + * ExampleRemoveIpAddressFromIpSet main method + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + RemoveIpAddressFromIpSetRequest request = new RemoveIpAddressFromIpSetRequest(); + request.setClientToken(UUID.randomUUID().toString()); + request.setIpSetId("ips-zmbp03b6wz8a"); + List ipAddressInfo = new ArrayList<>(); + ipAddressInfo.add("192.168.34.0"); + ipAddressInfo.add("192.168.35.0"); + request.setIpAddressInfo(ipAddressInfo); + try { + ipCollectionClient.removeIpAddressFromIpSet(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleUpdateIpSet.java b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleUpdateIpSet.java new file mode 100644 index 00000000..699e7459 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipcollection/ipset/ExampleUpdateIpSet.java @@ -0,0 +1,37 @@ +package com.baidubce.examples.ipcollection.ipset; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipcollection.IpCollectionClient; +import com.baidubce.services.ipcollection.IpCollectionClientConfiguration; +import com.baidubce.services.ipcollection.model.ipset.UpdateIpSetRequest; + +import java.util.UUID; + +public class ExampleUpdateIpSet { + + /** + * ExampleUpdateIpSet main method + * @param args + */ + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + IpCollectionClientConfiguration config = new IpCollectionClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + IpCollectionClient ipCollectionClient = new IpCollectionClient(config); + + UpdateIpSetRequest updateIpSetRequest = new UpdateIpSetRequest(); + updateIpSetRequest.setClientToken(UUID.randomUUID().toString()); + updateIpSetRequest.setDescription("description update"); + updateIpSetRequest.setIpSetId("ips-zmbp03b6wz8a"); + updateIpSetRequest.setName("test update ipSet"); + try { + ipCollectionClient.updateIpSet(updateIpSetRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleCreateIpv6Gateway.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleCreateIpv6Gateway.java new file mode 100644 index 00000000..fa91468e --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleCreateIpv6Gateway.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; + +public class ExampleCreateIpv6Gateway { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + String vpcId = "vpc-g7cufa91auif"; // vpc的ID + String name = "testIpv6"; // IPv6网关的名称 + Integer bandwidthInMbps = 20; // 带宽 + + // 计费信息,目前只支持后付费,默认封装 + + try { + ipv6GatewayClient.createIpv6Gateway(vpcId, name, bandwidthInMbps); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleCreateIpv6GatewayEgressOnlyRule.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleCreateIpv6GatewayEgressOnlyRule.java new file mode 100644 index 00000000..5a728043 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleCreateIpv6GatewayEgressOnlyRule.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; +import com.baidubce.services.ipv6Gateway.model.CreateEgressOnlyRuleRequest; +import com.baidubce.services.ipv6Gateway.model.CreateEgressOnlyRuleResponse; + +public class ExampleCreateIpv6GatewayEgressOnlyRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + CreateEgressOnlyRuleRequest request = new CreateEgressOnlyRuleRequest(); + request.setGatewayId("gw-5af4eb65"); // IPv6网关的Id + request.setCidr("2400:da00:e003:400::2/128"); // 只出不进策略的CIDR + try { + CreateEgressOnlyRuleResponse egressOnlyRule = ipv6GatewayClient.createEgressOnlyRule(request); + System.out.println(egressOnlyRule); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleCreateIpv6GatewayRateLimitRule.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleCreateIpv6GatewayRateLimitRule.java new file mode 100644 index 00000000..05b4de21 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleCreateIpv6GatewayRateLimitRule.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; +import com.baidubce.services.ipv6Gateway.model.CreateRateLimitRuleRequest; +import com.baidubce.services.ipv6Gateway.model.RateLimitRuleResponse; + +public class ExampleCreateIpv6GatewayRateLimitRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + CreateRateLimitRuleRequest request = new CreateRateLimitRuleRequest(); + request.setEgressBandwidthInMbps(10); // 限速策略的出向带宽 + request.setGatewayId(""); // IPv6网关的Id + request.setIngressBandwidthInMbps(20); // 限速策略的入向带宽 + request.setIpv6Address("2400:da00:e003:400::1"); // Ipv6的地址 + + try { + RateLimitRuleResponse rateLimitRule = ipv6GatewayClient.createRateLimitRule(request); + System.out.println(rateLimitRule); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleDeleteIpv6Gateway.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleDeleteIpv6Gateway.java new file mode 100644 index 00000000..b8dcdb59 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleDeleteIpv6Gateway.java @@ -0,0 +1,28 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; + +public class ExampleDeleteIpv6Gateway { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + String ipv6GatewayId = "gw-5af4eb65"; // IPv6网关的Id + try { + ipv6GatewayClient.deleteIpv6Gateway(ipv6GatewayId); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleDeleteIpv6GatewayEgressOnlyRule.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleDeleteIpv6GatewayEgressOnlyRule.java new file mode 100644 index 00000000..1f0ee5f9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleDeleteIpv6GatewayEgressOnlyRule.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; + +public class ExampleDeleteIpv6GatewayEgressOnlyRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + + String ipv6GatewayId = "gw-5af4eb65"; // IPv6网关的Id + String egressOnlyRuleId = "pv6_seg-c9e3b428"; // 只出不进策略的Id + try { + ipv6GatewayClient.deleteIpv6GatewayEgressOnlyRule(ipv6GatewayId, egressOnlyRuleId); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleDeleteIpv6GatewayRateLimitRule.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleDeleteIpv6GatewayRateLimitRule.java new file mode 100644 index 00000000..0b4690fb --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleDeleteIpv6GatewayRateLimitRule.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; + +public class ExampleDeleteIpv6GatewayRateLimitRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + + String ipv6GatewayId = "gw-5af4eb65"; // IPv6网关的Id + String rateLimitRuleId = "ipv6_qos-0b56ec38"; // 限速策略的Id + try { + ipv6GatewayClient.deleteIpv6GatewayRateLimitRule(ipv6GatewayId, rateLimitRuleId); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleGetIpv6Gateway.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleGetIpv6Gateway.java new file mode 100644 index 00000000..2a48a4b3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleGetIpv6Gateway.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; +import com.baidubce.services.ipv6Gateway.model.Ipv6GatewayResponse; + +public class ExampleGetIpv6Gateway { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + String vpcId = "vpcId=g7cufa91auif"; // IPv6网关所属的vpc的Id + + try { + Ipv6GatewayResponse ipv6Gateway = ipv6GatewayClient.getIpv6Gateway(vpcId); + System.out.println(ipv6Gateway); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleListIpv6GatewayEgressOnlyRule.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleListIpv6GatewayEgressOnlyRule.java new file mode 100644 index 00000000..f7329e01 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleListIpv6GatewayEgressOnlyRule.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; +import com.baidubce.services.ipv6Gateway.model.ListEgressOnlyRuleResponse; + +public class ExampleListIpv6GatewayEgressOnlyRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + String ipv6GatewayId = "gw-5af4eb65"; // IPv6网关的Id + + try { + ListEgressOnlyRuleResponse listEgressOnlyRuleResponse = ipv6GatewayClient.listEgressOnlyRule(ipv6GatewayId); + System.out.println(listEgressOnlyRuleResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleListIpv6GatewayRateLimitRule.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleListIpv6GatewayRateLimitRule.java new file mode 100644 index 00000000..daf7241f --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleListIpv6GatewayRateLimitRule.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; +import com.baidubce.services.ipv6Gateway.model.ListRateLimitRuleResponse; + +public class ExampleListIpv6GatewayRateLimitRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + + String ipv6GatewayId = "gw-5af4eb65"; // IPv6网关的Id + + try { + ListRateLimitRuleResponse listRateLimitRuleResponse = ipv6GatewayClient.listRateLimitRule(ipv6GatewayId); + System.out.println(listRateLimitRuleResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleResizeIpv6Gateway.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleResizeIpv6Gateway.java new file mode 100644 index 00000000..0bf044a6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleResizeIpv6Gateway.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; + +public class ExampleResizeIpv6Gateway { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + String ipv6GatewayId ="gw-5af4eb65"; // IPv6网关的Id + int newBandwidthInMbps = 20; // 更新后的IPv6网关的带宽 + + try { + ipv6GatewayClient.resizeIpv6Gateway(ipv6GatewayId, newBandwidthInMbps); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + + } + } +} diff --git a/src/main/java/com/baidubce/examples/ipv6gateway/ExampleUpdateIpv6GatewayRateLimitRule.java b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleUpdateIpv6GatewayRateLimitRule.java new file mode 100644 index 00000000..4571ee65 --- /dev/null +++ b/src/main/java/com/baidubce/examples/ipv6gateway/ExampleUpdateIpv6GatewayRateLimitRule.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.ipv6gateway; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClient; +import com.baidubce.services.ipv6Gateway.Ipv6GatewayClientConfiguration; +import com.baidubce.services.ipv6Gateway.model.UpdateRateLimitRuleRequest; + +public class ExampleUpdateIpv6GatewayRateLimitRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + Ipv6GatewayClientConfiguration config = new Ipv6GatewayClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + Ipv6GatewayClient ipv6GatewayClient = new Ipv6GatewayClient(config); // 初始化Client + + UpdateRateLimitRuleRequest updateRateLimitRule = new UpdateRateLimitRuleRequest(); + updateRateLimitRule.setGatewayId("gw-5af4eb65"); // IPv6网关的Id + updateRateLimitRule.setEgressBandwidthInMbps(8); // 限速策略的出向带宽 + updateRateLimitRule.setIngressBandwidthInMbps(6); // 限速策略的入向带宽 + updateRateLimitRule.setRateLimitRuleId("ipv6_qos-0b56ec38"); // 限速策略的Id + + try { + ipv6GatewayClient.updateRateLimitRule(updateRateLimitRule); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/lbdc/ExampleCreateLbdc.java b/src/main/java/com/baidubce/examples/lbdc/ExampleCreateLbdc.java new file mode 100644 index 00000000..3cf3a58b --- /dev/null +++ b/src/main/java/com/baidubce/examples/lbdc/ExampleCreateLbdc.java @@ -0,0 +1,48 @@ +package com.baidubce.examples.lbdc; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.lbdc.LbdcClient; +import com.baidubce.services.lbdc.model.CreateLbdcRequest; +import com.baidubce.services.lbdc.model.CreateLbdcResponse; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleCreateLbdc { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LbdcClient lbdcClient = new LbdcClient(config); // 初始化LbdcClient + + CreateLbdcRequest createLbdcRequest = new CreateLbdcRequest(); + createLbdcRequest.setName("lbdcName"); // 创建的lbdc名称 + createLbdcRequest.setType("4Layer"); // 创建的lbdc类型,4Layer或7Layer + createLbdcRequest.setCcuCount(2); // 创建的lbdc的ccu数量 (ccu代表集群的性能容量单位) + CreateLbdcRequest.BillingForCreate billingForCreate = new CreateLbdcRequest.BillingForCreate(); + billingForCreate.setPaymentTiming("Prepaid"); // 创建的lbdc的计费方式,Prepaid表示预付费 + CreateLbdcRequest.Reservation reservation = new CreateLbdcRequest.Reservation(); + reservation.setReservationLength(3); // 创建的lbdc的预付费时长的长度,单位为月 + billingForCreate.setReservation(reservation); + createLbdcRequest.setRenewReservation(reservation); // 创建的lbdc的续费时长的长度,单位为月 + createLbdcRequest.setBilling(billingForCreate); + + try { + CreateLbdcResponse response = lbdcClient.createLbdc(createLbdcRequest, ""); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/lbdc/ExampleGetBoundBlBListOfLbdc.java b/src/main/java/com/baidubce/examples/lbdc/ExampleGetBoundBlBListOfLbdc.java new file mode 100644 index 00000000..b77050e8 --- /dev/null +++ b/src/main/java/com/baidubce/examples/lbdc/ExampleGetBoundBlBListOfLbdc.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.lbdc; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.lbdc.LbdcClient; +import com.baidubce.services.lbdc.model.GetBoundBlBListOfLbdcResponse; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleGetBoundBlBListOfLbdc { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LbdcClient lbdcClient = new LbdcClient(config); // 初始化LbdcClient + + try { + GetBoundBlBListOfLbdcResponse response = lbdcClient.getBoundBlBListOfLbdc("bgw_group-f632f4bb"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/lbdc/ExampleGetLbdc.java b/src/main/java/com/baidubce/examples/lbdc/ExampleGetLbdc.java new file mode 100644 index 00000000..180290dc --- /dev/null +++ b/src/main/java/com/baidubce/examples/lbdc/ExampleGetLbdc.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.lbdc; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.lbdc.LbdcClient; +import com.baidubce.services.lbdc.model.GetLbdcResponse; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleGetLbdc { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LbdcClient lbdcClient = new LbdcClient(config); // 初始化LbdcClient + + try { + GetLbdcResponse response = lbdcClient.getLbdc("bgw_group-1f1b6e17"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/lbdc/ExampleListLbdc.java b/src/main/java/com/baidubce/examples/lbdc/ExampleListLbdc.java new file mode 100644 index 00000000..a769c6bc --- /dev/null +++ b/src/main/java/com/baidubce/examples/lbdc/ExampleListLbdc.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.lbdc; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.lbdc.LbdcClient; +import com.baidubce.services.lbdc.model.ListLbdcResponse; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleListLbdc { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LbdcClient lbdcClient = new LbdcClient(config); // 初始化LbdcClient + + try { + ListLbdcResponse response = lbdcClient.listLbdc(null, null); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/lbdc/ExampleRenewLbdc.java b/src/main/java/com/baidubce/examples/lbdc/ExampleRenewLbdc.java new file mode 100644 index 00000000..8483ad8b --- /dev/null +++ b/src/main/java/com/baidubce/examples/lbdc/ExampleRenewLbdc.java @@ -0,0 +1,41 @@ +package com.baidubce.examples.lbdc; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.lbdc.LbdcClient; +import com.baidubce.services.lbdc.model.RenewLbdcRequest; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleRenewLbdc { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LbdcClient lbdcClient = new LbdcClient(config); // 初始化LbdcClient + + RenewLbdcRequest renewLbdcRequest = new RenewLbdcRequest(); + RenewLbdcRequest.BillingForRenew billingForRenew = new RenewLbdcRequest.BillingForRenew(); + RenewLbdcRequest.BillingForRenew.Reservation reservation = new RenewLbdcRequest.BillingForRenew.Reservation(); + reservation.setReservationLength(5); // 续费时长,单位为月 + billingForRenew.setReservation(reservation); + renewLbdcRequest.setBilling(billingForRenew); + + try { + lbdcClient.renewLbdc("bgw_group-1f1b6e17", renewLbdcRequest, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/lbdc/ExampleUpdateLbdc.java b/src/main/java/com/baidubce/examples/lbdc/ExampleUpdateLbdc.java new file mode 100644 index 00000000..d32df02d --- /dev/null +++ b/src/main/java/com/baidubce/examples/lbdc/ExampleUpdateLbdc.java @@ -0,0 +1,37 @@ +package com.baidubce.examples.lbdc; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.lbdc.LbdcClient; +import com.baidubce.services.lbdc.model.UpdateLbdcRequest; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleUpdateLbdc { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LbdcClient lbdcClient = new LbdcClient(config); // 初始化LbdcClient + + UpdateLbdcRequest updateLbdcRequest = new UpdateLbdcRequest(); + updateLbdcRequest.setDesc("updateDesc"); // 修改描述 + + try { + lbdcClient.updateLbdc("bgw_group-1f1b6e17", updateLbdcRequest, null); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/lbdc/ExampleUpgradeLbdc.java b/src/main/java/com/baidubce/examples/lbdc/ExampleUpgradeLbdc.java new file mode 100644 index 00000000..4aa3b03e --- /dev/null +++ b/src/main/java/com/baidubce/examples/lbdc/ExampleUpgradeLbdc.java @@ -0,0 +1,37 @@ +package com.baidubce.examples.lbdc; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.lbdc.LbdcClient; +import com.baidubce.services.lbdc.model.UpgradeLbdcRequest; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleUpgradeLbdc { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LbdcClient lbdcClient = new LbdcClient(config); // 初始化LbdcClient + + UpgradeLbdcRequest upgradeLbdcRequest = new UpgradeLbdcRequest(); + upgradeLbdcRequest.setCcuCount(8); // 升级后CCU数量 + + try { + lbdcClient.upgradeLbdc("bgw_group-1f1b6e17", upgradeLbdcRequest, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleBatchCreateDnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleBatchCreateDnatRule.java new file mode 100644 index 00000000..d1eda6c6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleBatchCreateDnatRule.java @@ -0,0 +1,40 @@ +package com.baidubce.examples.nat; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.BatchAddDnatRulesRequest; +import com.baidubce.services.nat.model.CreateDnatRule; + +public class ExampleBatchCreateDnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + BatchAddDnatRulesRequest batchAddDnatRulesRequest = new BatchAddDnatRulesRequest(); + batchAddDnatRulesRequest.setNatId("nat-bmnbjkvm8h24"); + CreateDnatRule createDnatRule = new CreateDnatRule(); + createDnatRule.setRuleName("aa"); + createDnatRule.setProtocol("TCP"); + createDnatRule.setPrivatePort(8990); + createDnatRule.setPrivateIpAddress("192.168.0.25"); + createDnatRule.setPublicIpAddress("100.88.10.213"); + createDnatRule.setPublicPort(8991); + batchAddDnatRulesRequest.setRules(Arrays.asList(createDnatRule)); + try { + natClient.batchAddDnatRules(batchAddDnatRulesRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleBatchCreateSnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleBatchCreateSnatRule.java new file mode 100644 index 00000000..8a6eaf2a --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleBatchCreateSnatRule.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.nat; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.BatchAddSnatRuleRequest; + +public class ExampleBatchCreateSnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + BatchAddSnatRuleRequest batchAddSnatRuleRequest = new BatchAddSnatRuleRequest(); + batchAddSnatRuleRequest.setNatId("nat-bmnbjkvm8h24"); + BatchAddSnatRuleRequest.CreateSnatRule createSnatRule = new BatchAddSnatRuleRequest.CreateSnatRule(); + createSnatRule.setRuleName("name"); + createSnatRule.setSourceCIDR("192.168.0.0/24"); + createSnatRule.setPublicIpsAddress(Arrays.asList("100.88.0.51")); + batchAddSnatRuleRequest.setSnatRules(Arrays.asList(createSnatRule)); + try { + natClient.batchAddSnatRules(batchAddSnatRuleRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleBindDnatEip.java b/src/main/java/com/baidubce/examples/nat/ExampleBindDnatEip.java new file mode 100644 index 00000000..8184edf8 --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleBindDnatEip.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.BindDnatEipRequest; + +import java.util.Arrays; + +public class ExampleBindDnatEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + BindDnatEipRequest request = new BindDnatEipRequest(); + request.setNatId("nat-b58rnkn1g98h"); // 需要绑定dnat EIP的nat + request.setDnatEips(Arrays.asList("180.76.186.174")); // 公网IP + try { + natClient.bindDnatEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleBindSnatEip.java b/src/main/java/com/baidubce/examples/nat/ExampleBindSnatEip.java new file mode 100644 index 00000000..6c1b88b4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleBindSnatEip.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.BindEipRequest; + +import java.util.Arrays; + +public class ExampleBindSnatEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + BindEipRequest request = new BindEipRequest(); + request.setEips(Arrays.asList("180.76.186.174")); // 需要绑定的EIP + request.setNatId("nat-b58rnkn1g98h"); // 需要绑定EIP的natId + + try { + natClient.bindEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleCreateDnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleCreateDnatRule.java new file mode 100644 index 00000000..5711368a --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleCreateDnatRule.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.CreateDnatRuleRequest; + +public class ExampleCreateDnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + CreateDnatRuleRequest request = new CreateDnatRuleRequest(); + request.setNatId("nat-b58rnkn1g98h"); // natID + request.setRuleName("ruleTest"); // 名称,由大小写字母、数字以及-_ /.特殊字符组成,必须以字母开头,长度1-65 + request.setPublicIpAddress("180.76.186.174"); // 公网IP,关联在NAT网关DNAT上的EIP或共享带宽中的IP + request.setPrivateIpAddress("192.168.1.1"); // 内网IP + request.setProtocol("all"); // 协议,支持TCP、UDP、all + + try { + natClient.createDnatRule(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleCreateNat.java b/src/main/java/com/baidubce/examples/nat/ExampleCreateNat.java new file mode 100644 index 00000000..dceb30d9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleCreateNat.java @@ -0,0 +1,55 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.Reservation; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.CreateNatRequest; +import com.baidubce.services.nat.model.CreateNatResponse; + +import java.util.ArrayList; +import java.util.List; + +public class ExampleCreateNat { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + CreateNatRequest request = new CreateNatRequest(); // 创建NAT 请求参数 + Reservation reservation = new Reservation(); // 保留信息,支付方式为后支付时不需要设置,预支付时必须设置 + reservation.setReservationLength(1); // 时长 + reservation.setReservationTimeUnit("month"); // 单位 + Billing billing = new Billing(); + billing.setPaymentTiming("Prepaid"); // 预付费(Prepaid)和后付费(Postpaid) + billing.setReservation(reservation); + request.setBilling(billing); + request.setName("NatTest"); // nat名字 + // NAT网关的大小, + // 有small(最多支持绑定5个公网IP)、 + // medium(最多支持绑定10个公网IP)、 + // large(最多支持绑定15个公网IP)三种;该参数和cuNum只能二选一 +// request.setSpec("small"); + request.setCuNum(2); // NAT网关的CU数量,该参数和spec只能二选一 + request.setVpcId("vpc-a4sg6vsfzbra"); // 创建nat网关所在的vpcId + List tags = new ArrayList(); // 标签信息 + tags.add(new TagModel().withTagKey("testKey").withTagValue("testValue")); + request.setTags(tags); + + try { + CreateNatResponse createNatResponse = natClient.createNat(request); + System.out.println(createNatResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleCreateSnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleCreateSnatRule.java new file mode 100644 index 00000000..0909a23d --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleCreateSnatRule.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.CreateSnatRuleRequest; + +import java.util.Arrays; + +public class ExampleCreateSnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + CreateSnatRuleRequest request = new CreateSnatRuleRequest(); + request.setNatId("nat-b58rnkn1g98h"); // 需要创建snat 的nat + request.setRuleName("rule2"); // 名称,由大小写字母、数字以及-_ /.特殊字符组成,必须以字母开头,长度1-65 + request.setSourceCIDR("192.168.1.0/24"); // 内网IP/网段 + request.setPublicIpsAddress(Arrays.asList("180.76.186.174")); // 公网IPs,关联在NAT网关SNAT上的EIP或共享带宽中的IPs + + try { + natClient.createSnatRule(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleDeleteDnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleDeleteDnatRule.java new file mode 100644 index 00000000..b9feec5e --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleDeleteDnatRule.java @@ -0,0 +1,30 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.DeleteNatRuleRequest; + +public class ExampleDeleteDnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + DeleteNatRuleRequest request = new DeleteNatRuleRequest(); + request.setNatId("nat-b58rnkn1g98h"); // dnat所属nat + request.setRuleId("rule-zrsaybxm7nrn"); // 需要删除的dnat规则ID + + try { + natClient.deleteDnatRule(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleDeleteNat.java b/src/main/java/com/baidubce/examples/nat/ExampleDeleteNat.java new file mode 100644 index 00000000..dc7c7f2e --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleDeleteNat.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.ReleaseNatRequest; + +public class ExampleDeleteNat { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + ReleaseNatRequest request = new ReleaseNatRequest(); + request.setNatId("nat-b58rnkn1g98h"); // 需要删除的natId + + try { + natClient.releaseNat(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleDeleteSnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleDeleteSnatRule.java new file mode 100644 index 00000000..9019899d --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleDeleteSnatRule.java @@ -0,0 +1,30 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.DeleteNatRuleRequest; + +public class ExampleDeleteSnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + DeleteNatRuleRequest request = new DeleteNatRuleRequest(); + request.setNatId("nat-b58rnkn1g98h"); // 需要删除snat 的nat + request.setRuleId("rule-zrsaybxm7nrn"); // 需要删除的snat规则ID + + try { + natClient.deleteSnatRule(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleGetNat.java b/src/main/java/com/baidubce/examples/nat/ExampleGetNat.java new file mode 100644 index 00000000..6d7870e4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleGetNat.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.GetNatResponse; + +public class ExampleGetNat { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + + try { + GetNatResponse response = natClient.getNat("nat-b58rnkn1g98h"); // 需要查看详情的natId + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleListDnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleListDnatRule.java new file mode 100644 index 00000000..e9394c9f --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleListDnatRule.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.ListDnatRuleResponse; +import com.baidubce.services.nat.model.ListNatRuleRequest; + +public class ExampleListDnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + ListNatRuleRequest request = new ListNatRuleRequest(); + request.setMaxKeys(10); + request.setNatId("nat-b58rnkn1g98h"); // 需要查询dnat规则的natId + + try { + ListDnatRuleResponse listDnatRuleResponse = natClient.listDnatRule(request); + System.out.println(listDnatRuleResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleListNat.java b/src/main/java/com/baidubce/examples/nat/ExampleListNat.java new file mode 100644 index 00000000..7b74af7d --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleListNat.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.ListNatRequest; +import com.baidubce.services.nat.model.ListNatResponse; + +public class ExampleListNat { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + ListNatRequest request = new ListNatRequest(); + request.setVpcId("vpcId"); // 根据vpcId查询vpc下面的nat列表 + + try { + ListNatResponse response = natClient.listNat(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleListSnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleListSnatRule.java new file mode 100644 index 00000000..d3a5338c --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleListSnatRule.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.ListNatRuleRequest; +import com.baidubce.services.nat.model.ListSnatRuleResponse; + +public class ExampleListSnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + ListNatRuleRequest request = new ListNatRuleRequest(); + request.setNatId("nat-b58rnkn1g98h"); // 需要查询snat 的nat + + + try { + ListSnatRuleResponse listSnatRuleResponse = natClient.listSnatRule(request); + System.out.println(listSnatRuleResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleRenewNat.java b/src/main/java/com/baidubce/examples/nat/ExampleRenewNat.java new file mode 100644 index 00000000..65229606 --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleRenewNat.java @@ -0,0 +1,37 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.Reservation; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.PurchaseReservedNatRequest; + +public class ExampleRenewNat { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + PurchaseReservedNatRequest request = new PurchaseReservedNatRequest(); + request.setNatId("nat-b58rnkn1g98h"); // 需要续费的natId, 只有预付费nat才能续费 + Billing billing = new Billing(); // 续费信息 + Reservation reservation = new Reservation(); + reservation.setReservationLength(1); // 续费时长 + reservation.setReservationTimeUnit("month"); // 续费单位 + billing.setReservation(reservation); + request.setBilling(billing); + + try { + natClient.purchaseReservedNat(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleUnbindDnatEip.java b/src/main/java/com/baidubce/examples/nat/ExampleUnbindDnatEip.java new file mode 100644 index 00000000..ccf90f1b --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleUnbindDnatEip.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.BindDnatEipRequest; + +import java.util.ArrayList; +import java.util.List; + +public class ExampleUnbindDnatEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + BindDnatEipRequest request = new BindDnatEipRequest(); + request.setNatId("nat-b58rnkn1g98h"); // 需要解绑dnat EIP的nat + List dnatEips = new ArrayList(); + dnatEips.add("180.76.186.174"); // 公网IP + request.setDnatEips(dnatEips); + + try { + natClient.unbindDnatEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleUnbindSnatEip.java b/src/main/java/com/baidubce/examples/nat/ExampleUnbindSnatEip.java new file mode 100644 index 00000000..a3794a37 --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleUnbindSnatEip.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.BindEipRequest; + +import java.util.Arrays; + +public class ExampleUnbindSnatEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + BindEipRequest request = new BindEipRequest(); + request.setEips(Arrays.asList("180.76.186.174")); // 需要解绑的SNAT EIP + request.setNatId("nat-b58rnkn1g98h"); // natID + + try { + natClient.unbindEip(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleUpdateDnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleUpdateDnatRule.java new file mode 100644 index 00000000..d2fa2901 --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleUpdateDnatRule.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.UpdateDnatRuleRequest; + +public class ExampleUpdateDnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + UpdateDnatRuleRequest request = new UpdateDnatRuleRequest(); + request.setNatId("nat-b58rnkn1g98h"); // dnat所属natId + request.setRuleId(""); // dnat的规则ID + request.setRuleName("rule2"); // DNAT规则名字 + request.setProtocol("UDP"); // 协议,支持TCP、UDP、all + request.setPrivatePort(80); // 公网端口 + request.setPublicPort(80); // 内网端口 + request.setPrivateIpAddress("172.16.0.101"); // 内网IP + + try { + natClient.updateDnatRule(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleUpdateNat.java b/src/main/java/com/baidubce/examples/nat/ExampleUpdateNat.java new file mode 100644 index 00000000..ecd03889 --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleUpdateNat.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.ModifyNatRequest; + +public class ExampleUpdateNat { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + ModifyNatRequest request = new ModifyNatRequest(); + request.setNatId("nat-b58rnkn1g98h"); // 需要修改的natID + request.setName("name"); // 修改的名字 + + try { + natClient.modifyNat(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } + +} diff --git a/src/main/java/com/baidubce/examples/nat/ExampleUpdateSnatRule.java b/src/main/java/com/baidubce/examples/nat/ExampleUpdateSnatRule.java new file mode 100644 index 00000000..616601ba --- /dev/null +++ b/src/main/java/com/baidubce/examples/nat/ExampleUpdateSnatRule.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.nat; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.nat.NatClient; +import com.baidubce.services.nat.NatClientConfiguration; +import com.baidubce.services.nat.model.UpdateSnatRuleRequest; + +import java.util.Arrays; + +public class ExampleUpdateSnatRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + NatClientConfiguration config = new NatClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + NatClient natClient = new NatClient(config); // 初始化Client + + UpdateSnatRuleRequest request = new UpdateSnatRuleRequest(); + request.setNatId("nat-b58rnkn1g98h"); // 需要更新snat 的nat + request.setRuleId("rule-zrsaybxm7nrn"); // 需要更新的snat规则ID + request.setRuleName("rule2"); // // 名称,由大小写字母、数字以及-_ /.特殊字符组成,必须以字母开头,长度1-65 + request.setSourceCIDR("192.168.1.0/24"); // 内网IP/网段 + request.setPublicIpsAddress(Arrays.asList("180.76.186.174")); // 公网IPs,关联在NAT网关SNAT上的EIP或共享带宽中的IPs + + try { + natClient.updateSnatRule(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleCloseSyncDns.java b/src/main/java/com/baidubce/examples/peerconn/ExampleCloseSyncDns.java new file mode 100644 index 00000000..f8a58a28 --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleCloseSyncDns.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.SyncDnsRequest; + +import java.util.UUID; + +public class ExampleCloseSyncDns { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + SyncDnsRequest syncDnsRequest = new SyncDnsRequest(); + syncDnsRequest.setPeerConnId("peerconn-dtska37u3eih"); // 已开启同步dns记录的对等连接 + syncDnsRequest.setRole("initiator"); // 发起端"initiator" 接收端"acceptor" + syncDnsRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + peerConnClient.closeSyncDns(syncDnsRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleCreatePeerConn.java b/src/main/java/com/baidubce/examples/peerconn/ExampleCreatePeerConn.java new file mode 100644 index 00000000..5ed4ed16 --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleCreatePeerConn.java @@ -0,0 +1,59 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.CreatePeerConnRequest; +import com.baidubce.services.peerconn.model.CreatePeerConnResponse; +import com.google.common.collect.Lists; + +import java.util.List; +import java.util.UUID; + +public class ExampleCreatePeerConn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + CreatePeerConnRequest createPeerConnRequest = new CreatePeerConnRequest(); + createPeerConnRequest.setBandwidthInMbps(500); // 对等连接的带宽 + createPeerConnRequest.setDescription("java sdk test peer conn."); // 对等连接的备注 + createPeerConnRequest.setLocalIfName("peer_conn_local"); // 本端接口名称 + createPeerConnRequest.setLocalVpcId("vpc-nteqxm76n65t"); // 本端VPC的ID + createPeerConnRequest.setPeerAccountId("PeerAccountId"); // 对端账户ID,只有在建立跨账号的对等连接时需要该字段 + createPeerConnRequest.setPeerVpcId("vpc-z9new983u7ne"); // 对等连接对端VPC的ID + createPeerConnRequest.setPeerRegion("su"); // 对等连接的对端区域 + createPeerConnRequest.setPeerIfName("peer_conn_peer"); // 对等连接对端接口名称,只有本账号的对等连接才允许设置该字段 + createPeerConnRequest.setDeleteProtect(true); // 对等连接是否开启释放保护 + + // 计费信息 + Billing.Reservation reservation = new Billing.Reservation(); + reservation.setReservationLength(1); + reservation.setReservationTimeUnit("month"); + Billing billing = new Billing(); + billing.setPaymentTiming("Prepaid"); + billing.setReservation(reservation); + createPeerConnRequest.setBilling(billing); + + // 待创建的标签键值对列表。 + List tags = Lists.newArrayList(new TagModel().withTagKey("testKey").withTagValue("testValue")); + createPeerConnRequest.setTags(tags); + + createPeerConnRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + try { + CreatePeerConnResponse createPeerConnResponse = peerConnClient.createPeerConn(createPeerConnRequest); + System.out.println("createPeerConnResponse = " + createPeerConnResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleDeletePeerConn.java b/src/main/java/com/baidubce/examples/peerconn/ExampleDeletePeerConn.java new file mode 100644 index 00000000..ced8e168 --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleDeletePeerConn.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.PeerConnIdRequest; + +import java.util.UUID; + +public class ExampleDeletePeerConn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + PeerConnIdRequest peerConnIdRequest = new PeerConnIdRequest(); + peerConnIdRequest.setPeerConnId("id"); // 对等连接的ID + peerConnIdRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + peerConnClient.release(peerConnIdRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleGetPeerConn.java b/src/main/java/com/baidubce/examples/peerconn/ExampleGetPeerConn.java new file mode 100644 index 00000000..c75e50bf --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleGetPeerConn.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.GetPeerConnRequest; +import com.baidubce.services.peerconn.model.GetPeerConnResponse; + +public class ExampleGetPeerConn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + GetPeerConnRequest getPeerConnRequest = new GetPeerConnRequest(); + getPeerConnRequest.setPeerConnId("peerconn-dtska37u3eih"); // 对等连接的ID + + // "initiator"表示发起端"acceptor"表示接受端,同region的对等连接可以据此进行详情查询。 + // 若不设置该参数,同region则随机返回一端信息。 + getPeerConnRequest.setRole("initiator"); + + try { + GetPeerConnResponse getPeerConnResponse = peerConnClient.getPeerConn(getPeerConnRequest); + System.out.println("getPeerConnResponse = " + getPeerConnResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleListPeerConn.java b/src/main/java/com/baidubce/examples/peerconn/ExampleListPeerConn.java new file mode 100644 index 00000000..fe3aada7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleListPeerConn.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.ListPeerConnRequest; +import com.baidubce.services.peerconn.model.ListPeerConnResponse; + +public class ExampleListPeerConn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + ListPeerConnRequest listPeerConnRequest = new ListPeerConnRequest(); + listPeerConnRequest.setVpcId("vpc-0pyknh7t2cgn"); // vpc的ID + listPeerConnRequest.setMarker(""); // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + listPeerConnRequest.setMaxKeys(10); // 每页包含的最大数量,最大数量不超过1000。缺省值为1000 + + try { + ListPeerConnResponse listPeerConnResponse = peerConnClient.listPeerConn(listPeerConnRequest); + System.out.println("listPeerConnResponse = " + listPeerConnResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleModifyBandwith.java b/src/main/java/com/baidubce/examples/peerconn/ExampleModifyBandwith.java new file mode 100644 index 00000000..7c6fce8e --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleModifyBandwith.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.ModifyBandwidthRequest; + +import java.util.UUID; + +public class ExampleModifyBandwith { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + ModifyBandwidthRequest modifyBandwidthRequest = new ModifyBandwidthRequest(); + modifyBandwidthRequest.setPeerConnId("peerconn-dtska37u3eih"); // 待升降配的对等连接ID + modifyBandwidthRequest.setNewBandwidthInMbps(400); // 升降级的带宽 + modifyBandwidthRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + peerConnClient.modifyBandwith(modifyBandwidthRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleModifyPeerConn.java b/src/main/java/com/baidubce/examples/peerconn/ExampleModifyPeerConn.java new file mode 100644 index 00000000..f4c7f451 --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleModifyPeerConn.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.ModifyPeerConnRequest; + +import java.util.UUID; + +public class ExampleModifyPeerConn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + ModifyPeerConnRequest modifyPeerConnRequest = new ModifyPeerConnRequest(); + modifyPeerConnRequest.setPeerConnId("peerconn-dtska37u3eih"); // 对等连接的ID + modifyPeerConnRequest.setLocalIfId("qpif-v305m2suuzmq"); // 对等连接的接口ID 不可更改 + modifyPeerConnRequest.setLocalIfName("peer_conn_local_update"); // 本端接口名称 + modifyPeerConnRequest.setDescription("update peer conn description"); // 备注 + modifyPeerConnRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + peerConnClient.modifyPeerConn(modifyPeerConnRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleOpenSyncDns.java b/src/main/java/com/baidubce/examples/peerconn/ExampleOpenSyncDns.java new file mode 100644 index 00000000..135704c0 --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleOpenSyncDns.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.SyncDnsRequest; + +import java.util.UUID; + +public class ExampleOpenSyncDns { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + SyncDnsRequest syncDnsRequest = new SyncDnsRequest(); + syncDnsRequest.setPeerConnId("peerconn-dtska37u3eih"); // 开启同步dns记录的对等连接 + syncDnsRequest.setRole("initiator"); // 发起端"initiator" 接收端"acceptor" + syncDnsRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + peerConnClient.openSyncDns(syncDnsRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleProcessPeerConnApply.java b/src/main/java/com/baidubce/examples/peerconn/ExampleProcessPeerConnApply.java new file mode 100644 index 00000000..936caa77 --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleProcessPeerConnApply.java @@ -0,0 +1,44 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.PeerConnIdRequest; + +import java.util.UUID; + +public class ExampleProcessPeerConnApply { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + // 接收对等连接申请 + PeerConnIdRequest peerConnIdRequest = new PeerConnIdRequest(); + peerConnIdRequest.setPeerConnId("peerconn-4pj6d45dv79n"); // 对等连接的ID + peerConnIdRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + peerConnClient.accept(peerConnIdRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + // 拒绝对等连接申请 + PeerConnIdRequest peerConnIdRequest1 = new PeerConnIdRequest(); + peerConnIdRequest1.setPeerConnId("peerconn-2a2p0cftceg5"); // 对等连接的ID + peerConnIdRequest1.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + peerConnClient.reject(peerConnIdRequest1); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExamplePurchaseReserved.java b/src/main/java/com/baidubce/examples/peerconn/ExamplePurchaseReserved.java new file mode 100644 index 00000000..749b67a3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExamplePurchaseReserved.java @@ -0,0 +1,43 @@ +package com.baidubce.examples.peerconn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.PurchaseReservedPeerConnRequest; + +import java.util.UUID; + +public class ExamplePurchaseReserved { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + PurchaseReservedPeerConnRequest purchaseReservedPeerConnRequest = new PurchaseReservedPeerConnRequest(); + purchaseReservedPeerConnRequest.setPeerConnId("peerconn-wchhrady3my3"); // 续费的对等连接 + + // 订单信息 + Billing.Reservation reservation = new Billing.Reservation(); + reservation.setReservationLength(1); + reservation.setReservationTimeUnit("month"); + + Billing billing = new Billing(); + billing.setReservation(reservation); + purchaseReservedPeerConnRequest.setBilling(billing); + + purchaseReservedPeerConnRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + peerConnClient.purchaseReserved(purchaseReservedPeerConnRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/peerconn/ExampleSwitchDeleteProtect.java b/src/main/java/com/baidubce/examples/peerconn/ExampleSwitchDeleteProtect.java new file mode 100644 index 00000000..67883c6a --- /dev/null +++ b/src/main/java/com/baidubce/examples/peerconn/ExampleSwitchDeleteProtect.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.peerconn; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.peerconn.PeerConnClient; +import com.baidubce.services.peerconn.PeerConnClientConfiguration; +import com.baidubce.services.peerconn.model.SwitchPeerConnDeleteProtectRequest; + +public class ExampleSwitchDeleteProtect { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + PeerConnClientConfiguration config = new PeerConnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + PeerConnClient peerConnClient = new PeerConnClient(config); // 初始化Client + + SwitchPeerConnDeleteProtectRequest request = new SwitchPeerConnDeleteProtectRequest(); + request.setPeerConnId("peerconn-ptvh4hbi6285"); // 对等连接的ID + request.setDeleteProtect(false); // 开启释放保护 + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + peerConnClient.switchDeleteProtect(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleAddRecordOnPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleAddRecordOnPrivateZone.java new file mode 100644 index 00000000..9ab7d2d6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleAddRecordOnPrivateZone.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; +import com.baidubce.services.localdns.model.AddRecordRequest; +import com.baidubce.services.localdns.model.AddRecordResponse; + +public class ExampleAddRecordOnPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String zoneId = "zone-eej8ps6qp5ic"; // 要添加解析记录的privateZone的id + AddRecordRequest addRecordRequest = new AddRecordRequest(); + addRecordRequest.setRr("www"); // 主机记录 + addRecordRequest.setType("A"); // 记录类型 + addRecordRequest.setValue("1.1.1.1"); // 记录值 + try { + AddRecordResponse response = ldClient.addRecord(zoneId, addRecordRequest, ""); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleBindVpcOnPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleBindVpcOnPrivateZone.java new file mode 100644 index 00000000..c725e27a --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleBindVpcOnPrivateZone.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; +import com.baidubce.services.localdns.model.BindVpcRequest; + +import java.util.Arrays; + +public class ExampleBindVpcOnPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String zoneId = "zone-eej8ps6qp5ic"; // 要关联的privateZone的id + BindVpcRequest bindVpcRequest = new BindVpcRequest(); + bindVpcRequest.setRegion("bj"); // 关联的vpc所在区域 + bindVpcRequest.setVpcIds(Arrays.asList("vpc-4kzjwxgvx4fi")); // 关联的vpc的id列表 + + try { + ldClient.bindVpc(zoneId, bindVpcRequest, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleCreatePrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleCreatePrivateZone.java new file mode 100644 index 00000000..e7fb6801 --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleCreatePrivateZone.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; +import com.baidubce.services.localdns.model.CreatePrivateZoneRequest; +import com.baidubce.services.localdns.model.CreatePrivateZoneResponse; + +public class ExampleCreatePrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + CreatePrivateZoneRequest createZoneRequest = new CreatePrivateZoneRequest(); + createZoneRequest.setZoneName("javaSdk.com"); // privateZone的名称 + + try { + CreatePrivateZoneResponse response = ldClient.createPrivateZone(createZoneRequest, ""); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleDeletePrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleDeletePrivateZone.java new file mode 100644 index 00000000..d0714072 --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleDeletePrivateZone.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; + +public class ExampleDeletePrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String zoneId = "zone-a15wns86jnff"; // privateZone的id + + try { + ldClient.deletePrivateZone(zoneId, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleDeleteRecordOnPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleDeleteRecordOnPrivateZone.java new file mode 100644 index 00000000..1a3389d1 --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleDeleteRecordOnPrivateZone.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; + +public class ExampleDeleteRecordOnPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String recordId = "rc-byx2936gep0s"; // 要删除的记录id + + try { + ldClient.deleteRecord(recordId, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleDetailPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleDetailPrivateZone.java new file mode 100644 index 00000000..6033bef2 --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleDetailPrivateZone.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; +import com.baidubce.services.localdns.model.GetPrivateZoneResponse; + +public class ExampleDetailPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String zoneId = "zone-eej8ps6qp5ic"; // 查询的privateZone id + + try { + GetPrivateZoneResponse response = ldClient.getPrivateZone(zoneId); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleDisableRecordOnPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleDisableRecordOnPrivateZone.java new file mode 100644 index 00000000..2f59fc47 --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleDisableRecordOnPrivateZone.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; + +public class ExampleDisableRecordOnPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String recordId = "rc-byx2936gep0s"; // 要暂停的记录id + + try { + ldClient.disableRecord(recordId, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleEnableRecordOnPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleEnableRecordOnPrivateZone.java new file mode 100644 index 00000000..397a2ec5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleEnableRecordOnPrivateZone.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; + +public class ExampleEnableRecordOnPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String recordId = "rc-byx2936gep0s"; // 要开启的记录id + + try { + ldClient.enableRecord(recordId, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleListPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleListPrivateZone.java new file mode 100644 index 00000000..660d64ba --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleListPrivateZone.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; +import com.baidubce.services.localdns.model.ListPrivateZoneResponse; + +public class ExampleListPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String marker = ""; // 查询的marker + Integer maxKeys = 1000; // 查询的maxKeys + + try { + ListPrivateZoneResponse response = ldClient.listPrivateZone(marker, maxKeys); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleListRecordsOfPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleListRecordsOfPrivateZone.java new file mode 100644 index 00000000..44b81280 --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleListRecordsOfPrivateZone.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; +import com.baidubce.services.localdns.model.ListRecordResponse; + +public class ExampleListRecordsOfPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String zoneId = "zone-nqa0uqyse51z"; // privateZone的id + + try { + ListRecordResponse response = ldClient.listRecord(zoneId); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleUnBindVpcFromPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleUnBindVpcFromPrivateZone.java new file mode 100644 index 00000000..c853afc7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleUnBindVpcFromPrivateZone.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; +import com.baidubce.services.localdns.model.UnbindVpcRequest; + +import java.util.Arrays; + +public class ExampleUnBindVpcFromPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String zoneId = "zone-eej8ps6qp5ic"; // 要解关联的privateZone的id + UnbindVpcRequest unbindVpcRequest = new UnbindVpcRequest(); + unbindVpcRequest.setRegion("bj"); // 解关联的vpc所在区域 + unbindVpcRequest.setVpcIds(Arrays.asList("vpc-4kzjwxgvx4fi")); // 解关联的vpc的id列表 + + try { + ldClient.unbindVpc(zoneId, unbindVpcRequest, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/privatezone/ExampleUpdateRecordOnPrivateZone.java b/src/main/java/com/baidubce/examples/privatezone/ExampleUpdateRecordOnPrivateZone.java new file mode 100644 index 00000000..f5ebfadd --- /dev/null +++ b/src/main/java/com/baidubce/examples/privatezone/ExampleUpdateRecordOnPrivateZone.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.privatezone; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.localdns.LdClient; +import com.baidubce.services.localdns.model.UpdateRecordRequest; + +public class ExampleUpdateRecordOnPrivateZone { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + LdClient ldClient = new LdClient(config); // 初始化LdClient + + String recordId = "rc-byx2936gep0s"; // 要修改的记录id + UpdateRecordRequest updateRecordRequest = new UpdateRecordRequest(); + updateRecordRequest.setRr("www"); // 主机记录 + updateRecordRequest.setType("A"); // 记录类型 + updateRecordRequest.setValue("1.1.1.2"); // 记录值 + try { + ldClient.updateRecord(recordId, updateRecordRequest, ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/probe/ExampleCreateProbe.java b/src/main/java/com/baidubce/examples/probe/ExampleCreateProbe.java new file mode 100644 index 00000000..1fc1f264 --- /dev/null +++ b/src/main/java/com/baidubce/examples/probe/ExampleCreateProbe.java @@ -0,0 +1,45 @@ +package com.baidubce.examples.probe; + +import java.util.Arrays; +import java.util.UUID; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.probe.ProbeClient; +import com.baidubce.services.probe.model.CreateProbeRequest; +import com.baidubce.services.probe.model.CreateProbeResponse; + +public class ExampleCreateProbe { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + ProbeClient probeClient = new ProbeClient(config); // 初始化ProbeClient + + CreateProbeRequest createProbeRequest = new CreateProbeRequest(); + createProbeRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token,是一个长度不超过64位的ASCII字符串 + createProbeRequest.setName("test"); // 网络探测名称,长度不超过65个字符,可由数字、字符、下划线组成 + createProbeRequest.setDescription("desc"); // 网络探测描述,不超过200字符 + createProbeRequest.setVpcId("vpc-sf52s4f7s1d"); // 网络探测所属VPC ID + createProbeRequest.setSubnetId("sbn-dtzcawikg1g2"); // 网络探测所属子网ID + createProbeRequest.setProtocol("UDP"); // 探测类型。目前支持ICMP、TCP、UDP、DNS + createProbeRequest.setFrequency(10); // 探测频率取值为10、20、30 + createProbeRequest.setSourceIps(Arrays.asList("192.168.0.1")); // 探测源IP列表 + createProbeRequest.setSourceIpNum(2); // 探测源IP个数,当个数大于IP列表长度时,多出的IP会自动分配 + createProbeRequest.setDestIp("10.0.5.8"); // 探测目的IP + createProbeRequest.setDestPort(80); // 探测目的端口,TCP、UDP和DNS类型的需要 + createProbeRequest.setPayload("udp_probe"); // UDP类型的探测字符串和DNS类型的探测域名 + + try { + CreateProbeResponse probe = probeClient.createProbe(createProbeRequest); + System.out.println(probe); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/probe/ExampleDeleteProbe.java b/src/main/java/com/baidubce/examples/probe/ExampleDeleteProbe.java new file mode 100644 index 00000000..70109590 --- /dev/null +++ b/src/main/java/com/baidubce/examples/probe/ExampleDeleteProbe.java @@ -0,0 +1,24 @@ +package com.baidubce.examples.probe; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.probe.ProbeClient; + +public class ExampleDeleteProbe { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + ProbeClient probeClient = new ProbeClient(config); // 初始化ProbeClient + + try { + probeClient.deleteProbe("probe-25sd634a4xasd"); // 网络探测的ID + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/probe/ExampleGetProbe.java b/src/main/java/com/baidubce/examples/probe/ExampleGetProbe.java new file mode 100644 index 00000000..c52003b3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/probe/ExampleGetProbe.java @@ -0,0 +1,26 @@ +package com.baidubce.examples.probe; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.probe.ProbeClient; +import com.baidubce.services.probe.model.GetProbeResponse; + +public class ExampleGetProbe { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + ProbeClient probeClient = new ProbeClient(config); // 初始化ProbeClient + + try { + GetProbeResponse probe = probeClient.getProbe("probe-25sd634a4xasd"); // 网络探测的ID + System.out.println(probe); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/probe/ExampleListProbe.java b/src/main/java/com/baidubce/examples/probe/ExampleListProbe.java new file mode 100644 index 00000000..41c367ac --- /dev/null +++ b/src/main/java/com/baidubce/examples/probe/ExampleListProbe.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.probe; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.probe.ProbeClient; +import com.baidubce.services.probe.model.ListProbeRequest; +import com.baidubce.services.probe.model.ListProbeResponse; + +public class ExampleListProbe { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + ProbeClient probeClient = new ProbeClient(config); // 初始化ProbeClient + + ListProbeRequest listProbeRequest = new ListProbeRequest(); + listProbeRequest.setMaxKeys(10); // 每页包含的最大数量。最大数量通常不超过1000,缺省值为1000 + listProbeRequest.setMarker("marker"); // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + + try { + ListProbeResponse listProbeResponse = probeClient.listProbes(listProbeRequest); + System.out.println(listProbeResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/probe/ExampleUpdateProbe.java b/src/main/java/com/baidubce/examples/probe/ExampleUpdateProbe.java new file mode 100644 index 00000000..b1c8ede4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/probe/ExampleUpdateProbe.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.probe; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.probe.ProbeClient; +import com.baidubce.services.probe.model.GetProbeResponse; +import com.baidubce.services.probe.model.UpdateProbeRequest; + +public class ExampleUpdateProbe { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + ProbeClient probeClient = new ProbeClient(config); // 初始化ProbeClient + + UpdateProbeRequest updateProbeRequest = new UpdateProbeRequest(); + updateProbeRequest.setProbeId("probe-25sd634a4xasd"); // 需要更新的网络探测的ID + updateProbeRequest.setName("name-update"); // 网络探测的name + probeClient.updateProbe(updateProbeRequest); + + try { + GetProbeResponse probe = probeClient.getProbe(updateProbeRequest.getProbeId()); + System.out.println(probe); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/rds/RdsUtil.java b/src/main/java/com/baidubce/examples/rds/RdsUtil.java new file mode 100644 index 00000000..86f68759 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/RdsUtil.java @@ -0,0 +1,46 @@ +package com.baidubce.examples.rds; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +public class RdsUtil { + public static T readJson(String file, Class clazz) { + URL resource = clazz.getClassLoader().getResource(file); + if (resource != null) { + try (InputStream inputStream = resource.openStream()) { + return new ObjectMapper().readValue(inputStream, clazz); + } catch (IOException e) { + throw new RuntimeException("Failed to read JSON from file: " + file, e); + } + } + return null; + } + public static RdsClient createRdsClient() { + String endPoint = "rds.bj.baidubce.com"; + String accessKey = "ak"; + String secretAccessKy = "sk"; + BceClientConfiguration config = + new BceClientConfiguration() + .withCredentials(new DefaultBceCredentials(accessKey, secretAccessKy)) + .withEndpoint(endPoint); + RdsClient rdsClient = new RdsClient(config); + return rdsClient; + } + + public static void print(String method, Object obj) { + try { + String json = JsonUtils.toJsonPrettyString(obj); + System.out.println(json); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestAutoRenew.java b/src/main/java/com/baidubce/examples/rds/TestAutoRenew.java new file mode 100644 index 00000000..4dc5b547 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestAutoRenew.java @@ -0,0 +1,17 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsAutoRenewRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.readJson; + + +public class TestAutoRenew { + public static void main(String[] args) { + RdsClient rdsClient= createRdsClient(); + RdsAutoRenewRequest request = readJson("rds/json/TestAutoRenew.json", RdsAutoRenewRequest.class); + AbstractBceResponse response = rdsClient.autoRenew(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestBindingTags.java b/src/main/java/com/baidubce/examples/rds/TestBindingTags.java new file mode 100644 index 00000000..79c7072a --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestBindingTags.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsBindingTagsRequest; +import com.baidubce.services.rds.model.RdsTag; +import com.baidubce.services.rds.model.Resource; + + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + + +public class TestBindingTags { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsBindingTagsRequest request = new RdsBindingTagsRequest(); + RdsTag tag = new RdsTag(); + tag.setTagValue("testValue"); + tag.setTagKey("testKey"); + List tags = new ArrayList<>(); + tags.add(tag); + String instanceId = "rds-lZIdjcC3"; + Resource resource = new Resource(instanceId, tags); + List resources = new ArrayList<>(); + resources.add(resource); + request.setResources(resources); + AbstractBceResponse response = rdsClient.bindingTags(request); + print("bindingTags", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestChangeDatabasePort.java b/src/main/java/com/baidubce/examples/rds/TestChangeDatabasePort.java new file mode 100644 index 00000000..e44a6996 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestChangeDatabasePort.java @@ -0,0 +1,18 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsChangeDatabasePortRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestChangeDatabasePort { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsChangeDatabasePortRequest request = new RdsChangeDatabasePortRequest(); + request.setInstanceId("rds-Ml7QDBqz"); + request.setEntryPort(13206); + AbstractBceResponse response = rdsClient.changeDatabasePort(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestClusterStatusCheck.java b/src/main/java/com/baidubce/examples/rds/TestClusterStatusCheck.java new file mode 100644 index 00000000..1784f880 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestClusterStatusCheck.java @@ -0,0 +1,19 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsClusterStatusCheckRequest; +import com.baidubce.services.rds.model.RdsClusterStatusCheckResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestClusterStatusCheck { + public static void main(String[] args) { + RdsClient rdsClient= createRdsClient(); + + RdsClusterStatusCheckRequest request = new RdsClusterStatusCheckRequest(); + request.setInstanceId("rds-k1dffnQn"); + RdsClusterStatusCheckResponse response = rdsClient.clusterStatusCheck(request); + print("clusterStatusCheck", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestCreateAccount.java b/src/main/java/com/baidubce/examples/rds/TestCreateAccount.java new file mode 100644 index 00000000..18379fbe --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestCreateAccount.java @@ -0,0 +1,39 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.DatabasePrivilege; +import com.baidubce.services.rds.model.RdsAccountType; +import com.baidubce.services.rds.model.RdsCreateAccountRequest; + +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; +public class TestCreateAccount { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsCreateAccountRequest createAccountRequest = new RdsCreateAccountRequest(); + createAccountRequest.setInstanceId("rds-nr2GCznE"); + createAccountRequest.setAccountName("test_acc"); + createAccountRequest.setPassword("rds_passwordKJH"); + createAccountRequest.setAccountType(RdsAccountType.Common); + DatabasePrivilege privilege = new DatabasePrivilege(); + privilege.setDbName("test"); + privilege.setAuthType("ReadOnly"); + List privileges = new ArrayList<>(); + privileges.add(privilege); + createAccountRequest.setDatabasePrivileges(privileges); + createAccountRequest.setDesc("rds_sdk_created_createAccount_test"); + createAccountRequest.setType("OnlyMaster"); + try { + AbstractBceResponse accountResponse = rdsClient.createAccount(createAccountRequest); + print("createAccount", accountResponse); + } catch (GeneralSecurityException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestCreateDatabase.java b/src/main/java/com/baidubce/examples/rds/TestCreateDatabase.java new file mode 100644 index 00000000..4ce73d2c --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestCreateDatabase.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsAccountPrivileges; +import com.baidubce.services.rds.model.RdsCharacterSet; +import com.baidubce.services.rds.model.RdsCreateDatabaseRequest; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestCreateDatabase { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsCreateDatabaseRequest request = new RdsCreateDatabaseRequest(); + request.setInstanceId("rds-Qk2LpXBj"); + request.setCharacterSetName(RdsCharacterSet.UTF8); + request.setDbName("testMysqlDatabase"); + request.setRemark("testRemark"); + RdsAccountPrivileges privileges = new RdsAccountPrivileges(); + privileges.setAccountName("rdsroot1"); + privileges.setAuthType("ReadWrite"); + List privilegesList = new ArrayList<>(); + privilegesList.add(privileges); + request.setAccountPrivileges(privilegesList); + request.setCtype("zh_CN.utf-8"); + request.setCollate("zh_CN.utf-8"); + request.setOwner("rdsroot1"); + AbstractBceResponse response = rdsClient.createDatabase(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestCreateInstance.java b/src/main/java/com/baidubce/examples/rds/TestCreateInstance.java new file mode 100644 index 00000000..379a3110 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestCreateInstance.java @@ -0,0 +1,75 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsBilling; +import com.baidubce.services.rds.model.RdsCreateInstanceRequest; +import com.baidubce.services.rds.model.RdsCreateInstanceResponse; +import com.baidubce.services.rds.model.RdsEngine; +import com.baidubce.services.rds.model.RdsPaymentTiming; +import com.baidubce.services.rds.model.RdsRenewTimeUnit; +import com.baidubce.services.rds.model.RdsReservation; +import com.baidubce.services.rds.model.RdsSubnet; +import com.baidubce.services.rds.model.RdsTag; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestCreateInstance { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsCreateInstanceRequest request = new RdsCreateInstanceRequest(); + RdsBilling billing = new RdsBilling(); + RdsPaymentTiming rdsPaymentTiming = RdsPaymentTiming.create("Prepaid"); + RdsReservation reservation = new RdsReservation(); + reservation.setReservationLength(1); + billing.setPaymentTiming(rdsPaymentTiming); + billing.setReservation(reservation); + request.setBilling(billing); + + RdsRenewTimeUnit renewTimeUnit = RdsRenewTimeUnit.create("year"); + request.setAutoRenewTimeUnit(renewTimeUnit); + request.setAutoRenewTime(1); + + request.setPurchaseCount(1); + request.setInstanceName("rds-010"); + + request.setEngine(RdsEngine.MySQL); + request.setEngineVersion("5.6"); + request.setCharacterSetName("utf8mb4"); + request.setCpuCount(1); + request.setMemoryCapacity(2); + request.setVolumeCapacity(5); + request.setDiskIoType("normal_io"); + + List zoneNames = new ArrayList<>(); + zoneNames.add("cn-bj-d"); + request.setZoneNames(zoneNames); + + request.setVpcId("vpc-70pxg3pmv8rv"); + request.setIsDirectPay(true); + RdsSubnet subnet = new RdsSubnet(); + subnet.setSubnetId("sbn-dqafncqsy3y4"); + subnet.setZoneName("cn-bj-d"); + + List subnets = new ArrayList<>(); + subnets.add(subnet); + + request.setSubnets(subnets); + + RdsTag tag = new RdsTag(); + tag.setTagKey("goods_type"); + tag.setTagValue("music"); + + List tags = new ArrayList<>(); + tags.add(tag); + request.setTags(tags); + + print("request is ", request); + RdsCreateInstanceResponse instanceResponse = rdsClient.createInstance(request); + print("createInstance", instanceResponse); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestCreateProxyInstance.java b/src/main/java/com/baidubce/examples/rds/TestCreateProxyInstance.java new file mode 100644 index 00000000..25104f24 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestCreateProxyInstance.java @@ -0,0 +1,51 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsBilling; +import com.baidubce.services.rds.model.RdsCreateInstanceResponse; +import com.baidubce.services.rds.model.RdsCreateProxyInstance; +import com.baidubce.services.rds.model.RdsPaymentTiming; +import com.baidubce.services.rds.model.RdsSubnet; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestCreateProxyInstance { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsCreateProxyInstance proxyInstance = new RdsCreateProxyInstance(); + + RdsBilling billing = new RdsBilling(); + RdsPaymentTiming rdsPaymentTiming = RdsPaymentTiming.create("Postpaid"); + billing.setPaymentTiming(rdsPaymentTiming); + + proxyInstance.setSourceInstanceId("rds-tKEPFelh"); + proxyInstance.setInstanceName("mysql80"); + + proxyInstance.setNodeAmount(2); + + List zoneNames = new ArrayList<>(); + zoneNames.add("cn-bj-d"); + proxyInstance.setZoneNames(zoneNames); + + proxyInstance.setVpcId("vpc-70pxg3pmv8rv"); + + RdsSubnet subnet = new RdsSubnet(); + subnet.setSubnetId("sbn-dqafncqsy3y4"); + subnet.setZoneName("cn-bj-d"); + + proxyInstance.setIsDirectPay(false); + + subnet.setZoneName("cn-bj-d"); + List subnets = new ArrayList<>(); + subnets.add(subnet); + proxyInstance.setSubnets(subnets); + + RdsCreateInstanceResponse response = rdsClient.createInstanceProxy(proxyInstance); + print("createProxyInstance", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestCreateReadableInstance.java b/src/main/java/com/baidubce/examples/rds/TestCreateReadableInstance.java new file mode 100644 index 00000000..a8e439d4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestCreateReadableInstance.java @@ -0,0 +1,59 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsBilling; +import com.baidubce.services.rds.model.RdsCreateInstanceResponse; +import com.baidubce.services.rds.model.RdsCreateReadableInstance; +import com.baidubce.services.rds.model.RdsPaymentTiming; +import com.baidubce.services.rds.model.RdsReservation; +import com.baidubce.services.rds.model.RdsSubnet; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestCreateReadableInstance { + public static void main(String[] args) { + + RdsClient rdsClient = createRdsClient(); + + RdsCreateReadableInstance createReadableInstance = new RdsCreateReadableInstance(); + + RdsBilling billing = new RdsBilling(); + RdsPaymentTiming rdsPaymentTiming = RdsPaymentTiming.create("Postpaid"); + RdsReservation reservation = new RdsReservation(); + reservation.setReservationLength(1); + billing.setPaymentTiming(rdsPaymentTiming); + billing.setReservation(reservation); + createReadableInstance.setBilling(billing); + + createReadableInstance.setInstanceName("rds-oKFG"); + createReadableInstance.setCpuCount(1); + createReadableInstance.setMemoryCapacity(2); + createReadableInstance.setVolumeCapacity(50); + createReadableInstance.setDiskIoType("normal_io"); + createReadableInstance.setIsDirectPay(false); + createReadableInstance.setPurchaseCount(1); + createReadableInstance.setInstanceName("rds-019"); + String sourceInstanceId = "rds-tKEPFelh"; + createReadableInstance.setSourceInstanceId(sourceInstanceId); + String zoneName = "cn-bj-d"; + List zoneNames = new ArrayList<>(); + zoneNames.add(zoneName); + createReadableInstance.setZoneNames(zoneNames); + createReadableInstance.setVpcId("vpc-70pxg3pmv8rv"); + + RdsSubnet subnet = new RdsSubnet(); + subnet.setSubnetId("sbn-dqafncqsy3y4"); + subnet.setZoneName("cn-bj-d"); + List subnets = new ArrayList<>(); + subnets.add(subnet); + createReadableInstance.setSubnets(subnets); + createReadableInstance.setEntryPort(3306); + + RdsCreateInstanceResponse response = rdsClient.createInstanceReadableReplica(createReadableInstance); + print("createReadableInstance", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestDeleteAccount.java b/src/main/java/com/baidubce/examples/rds/TestDeleteAccount.java new file mode 100644 index 00000000..1c586252 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestDeleteAccount.java @@ -0,0 +1,18 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsDeleteAccountRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestDeleteAccount { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsDeleteAccountRequest request = new RdsDeleteAccountRequest(); + request.setInstanceId("rds-RhmXpFKn"); + request.setAccountName("delaccount"); + AbstractBceResponse response = rdsClient.deleteAccount(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestDeleteDatabase.java b/src/main/java/com/baidubce/examples/rds/TestDeleteDatabase.java new file mode 100644 index 00000000..dbf8723f --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestDeleteDatabase.java @@ -0,0 +1,18 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsDeleteDatabaseRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestDeleteDatabase { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsDeleteDatabaseRequest request = new RdsDeleteDatabaseRequest(); + request.setInstanceId("rds-Qk2LpXBj"); + request.setDbName("testMysqlDatabase"); + AbstractBceResponse response = rdsClient.deleteDatabase(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestDeleteTheSpecifiedBackupSet.java b/src/main/java/com/baidubce/examples/rds/TestDeleteTheSpecifiedBackupSet.java new file mode 100644 index 00000000..a1f596bf --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestDeleteTheSpecifiedBackupSet.java @@ -0,0 +1,21 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsDeleteSpecifiedBackUpRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestDeleteTheSpecifiedBackupSet { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsDeleteSpecifiedBackUpRequest request = new RdsDeleteSpecifiedBackUpRequest(); + request.setInstanceId("rdsmsn17thg0i4p"); + request.setSnapshotId("1720671279584629601"); + AbstractBceResponse response = rdsClient.deleteTheSpecifiedBackupSet(request); + print("deleteTheSpecifiedBackupSet", response); + + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestDialingTest.java b/src/main/java/com/baidubce/examples/rds/TestDialingTest.java new file mode 100644 index 00000000..0e2b788b --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestDialingTest.java @@ -0,0 +1,18 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsDialingTestRequest; +import com.baidubce.services.rds.model.RdsDialingTestResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; +public class TestDialingTest { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsDialingTestRequest request = new RdsDialingTestRequest(); + request.setInstanceId("rds-6QCusckC"); + RdsDialingTestResponse response = rdsClient.dialingTest(request); + print("dialingTest", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetAccountList.java b/src/main/java/com/baidubce/examples/rds/TestGetAccountList.java new file mode 100644 index 00000000..b35c53cd --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetAccountList.java @@ -0,0 +1,19 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsAccountListRequest; +import com.baidubce.services.rds.model.RdsAccountListResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetAccountList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsAccountListRequest listRequest = new RdsAccountListRequest(); + listRequest.setInstanceId("rds-jHqrZCEk"); + RdsAccountListResponse listResponse = rdsClient.getAccountList(listRequest); + print("getAccountList", listResponse); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetAutoConfigForSpecified.java b/src/main/java/com/baidubce/examples/rds/TestGetAutoConfigForSpecified.java new file mode 100644 index 00000000..9ed9d25a --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetAutoConfigForSpecified.java @@ -0,0 +1,18 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsGetAutoConfigForSpecifiedRequest; +import com.baidubce.services.rds.model.RdsGetAutoConfigForSpecifiedResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; +public class TestGetAutoConfigForSpecified { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsGetAutoConfigForSpecifiedRequest request = new RdsGetAutoConfigForSpecifiedRequest(); + request.setInstanceId("rds-7xabvFUH"); + RdsGetAutoConfigForSpecifiedResponse response = rdsClient.getAutoConfigForSpecified(request); + print("testGetAutoConfigForSpecified", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetBinLogInfo.java b/src/main/java/com/baidubce/examples/rds/TestGetBinLogInfo.java new file mode 100644 index 00000000..1e0b55f7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetBinLogInfo.java @@ -0,0 +1,21 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsGetBinLogInfoRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetBinLogInfo { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsGetBinLogInfoRequest request = new RdsGetBinLogInfoRequest(); + request.setInstanceId("rds-1Cm4tVAO"); + request.setLogId("1720685193973036601"); + request.setDownloadValidTimeInSec("1800"); + AbstractBceResponse response = rdsClient.getBinLogInfo(request); + print("getBinLogInfo", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetBinLogList.java b/src/main/java/com/baidubce/examples/rds/TestGetBinLogList.java new file mode 100644 index 00000000..67952353 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetBinLogList.java @@ -0,0 +1,20 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsGetBinLogListRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetBinLogList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsGetBinLogListRequest request = new RdsGetBinLogListRequest(); + request.setInstanceId("rds-1Cm4tVAO"); + request.setDatetime("2024-07-11T06:48:29Z"); + AbstractBceResponse response = rdsClient.getBinLogList(request); + print("getBinLogList", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetDatabaseList.java b/src/main/java/com/baidubce/examples/rds/TestGetDatabaseList.java new file mode 100644 index 00000000..b519cb50 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetDatabaseList.java @@ -0,0 +1,17 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsGetDatabaseListRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestGetDatabaseList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsGetDatabaseListRequest request = new RdsGetDatabaseListRequest(); + request.setInstanceId("rds-Ml7QDBqz"); + AbstractBceResponse response = rdsClient.getDatabaseList(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetInstanceDetail.java b/src/main/java/com/baidubce/examples/rds/TestGetInstanceDetail.java new file mode 100644 index 00000000..5c21afdf --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetInstanceDetail.java @@ -0,0 +1,19 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsInstanceDetailRequest; +import com.baidubce.services.rds.model.RdsInstanceDetailResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetInstanceDetail { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsInstanceDetailRequest detailRequest = new RdsInstanceDetailRequest(); + detailRequest.setInstanceId(""); + RdsInstanceDetailResponse detailResponse = rdsClient.getRdsInstanceDetail(detailRequest); + print("getInstanceDetail", detailResponse); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetNewPurchasePrice.java b/src/main/java/com/baidubce/examples/rds/TestGetNewPurchasePrice.java new file mode 100644 index 00000000..f1fd5ef4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetNewPurchasePrice.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.rds; + + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsGetNewPurchasePriceRequest; +import com.baidubce.services.rds.model.RdsGetNewPurchasePriceResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetNewPurchasePrice { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsGetNewPurchasePriceRequest request = new RdsGetNewPurchasePriceRequest(); + request.setDuration(1); + RdsGetNewPurchasePriceRequest.Instance instances = new RdsGetNewPurchasePriceRequest.Instance(); + instances.setEngine("MySQL"); + instances.setCpuCount(1); + instances.setAllocatedMemoryInGB(1); + instances.setAllocatedStorageInGB(50); + instances.setDiskIoType("cloud_high"); + request.setInstance(instances); + request.setNumber(1); + request.setProductType("postpay"); + RdsGetNewPurchasePriceResponse response = rdsClient.getNewPurchasePrice(request); + print("getNewPurchasePrice", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetOrderStatus.java b/src/main/java/com/baidubce/examples/rds/TestGetOrderStatus.java new file mode 100644 index 00000000..de4e53fb --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetOrderStatus.java @@ -0,0 +1,19 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsGetOrderStatusRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetOrderStatus { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsGetOrderStatusRequest request = new RdsGetOrderStatusRequest(); + request.setOrderId("0fa2f32386184e7aa47233446b9614dd"); + AbstractBceResponse response = rdsClient.getOrderStatus(request); + print("getOrderStatus", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetPGList.java b/src/main/java/com/baidubce/examples/rds/TestGetPGList.java new file mode 100644 index 00000000..6722e4c5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetPGList.java @@ -0,0 +1,20 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsGetPGListRequest; +import com.baidubce.services.rds.model.RdsGetPGListResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetPGList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsGetPGListRequest request = new RdsGetPGListRequest(); + request.setInstanceId("rds-jHqrZCEk"); + request.setDate("2023-06-14"); + RdsGetPGListResponse response = rdsClient.getPGList(request); + print("getPGList", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetPGLogDetails.java b/src/main/java/com/baidubce/examples/rds/TestGetPGLogDetails.java new file mode 100644 index 00000000..980f6222 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetPGLogDetails.java @@ -0,0 +1,21 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsGetPGLogDetailsRequest; +import com.baidubce.services.rds.model.RdsGetPGLogDetailsResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetPGLogDetails { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsGetPGLogDetailsRequest request = new RdsGetPGLogDetailsRequest(); + request.setInstanceId("rds-jHqrZCEk"); + request.setPglogId("postgresql-2024-07-11_000000.log"); + request.setDownloadValidTimeInSec(3600); + RdsGetPGLogDetailsResponse response = rdsClient.getPGLogDetails(request); + print("getPGLogDetails", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetPriceDifference.java b/src/main/java/com/baidubce/examples/rds/TestGetPriceDifference.java new file mode 100644 index 00000000..133ec763 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetPriceDifference.java @@ -0,0 +1,23 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsGetPriceDifferenceRequest; +import com.baidubce.services.rds.model.RdsGetPriceDifferenceResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetPriceDifference { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsGetPriceDifferenceRequest request = new RdsGetPriceDifferenceRequest(); + request.setInstanceId("rds-6QCusckC"); + request.setCpuCount(1); + request.setAllocatedMemoryInGB(1); + request.setAllocatedStorageInGB(50); + request.setDiskIoType("cloud_high"); + RdsGetPriceDifferenceResponse response = rdsClient.getPriceDifference(request); + print("getPriceDifference", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetRdsInstanceList.java b/src/main/java/com/baidubce/examples/rds/TestGetRdsInstanceList.java new file mode 100644 index 00000000..20ffb3ba --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetRdsInstanceList.java @@ -0,0 +1,16 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsInstanceListRequest; +import com.baidubce.services.rds.model.RdsInstanceListResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestGetRdsInstanceList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsInstanceListRequest request = new RdsInstanceListRequest(); + RdsInstanceListResponse rdsInstanceList = rdsClient.getRdsInstanceList(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetSlowLogErrorLogDownloadDetails.java b/src/main/java/com/baidubce/examples/rds/TestGetSlowLogErrorLogDownloadDetails.java new file mode 100644 index 00000000..f9cbaea1 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetSlowLogErrorLogDownloadDetails.java @@ -0,0 +1,20 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsSlowLogErrorLogDownloadDetailsRequest; +import com.baidubce.services.rds.model.RdsSlowLogErrorLogDownloadDetailsResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetSlowLogErrorLogDownloadDetails { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + RdsSlowLogErrorLogDownloadDetailsRequest request = new RdsSlowLogErrorLogDownloadDetailsRequest(); + request.setInstanceId("rds-1AfwpHXs"); + request.setLogId("postgresql-2024-07-11_000000.log"); + request.setDownloadValidTimeInSec(1090); + RdsSlowLogErrorLogDownloadDetailsResponse response = rdsClient.getSlowLogErrorLogDownloadDetails(request); + print("getSlowLogErrorLogDownloadDetails", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetSlowLogGetErrorLogDetails.java b/src/main/java/com/baidubce/examples/rds/TestGetSlowLogGetErrorLogDetails.java new file mode 100644 index 00000000..426543fe --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetSlowLogGetErrorLogDetails.java @@ -0,0 +1,24 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsSlowLogGetErrorLogDetailsRequest; +import com.baidubce.services.rds.model.RdsSlowLogGetErrorLogDetailsResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetSlowLogGetErrorLogDetails { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsSlowLogGetErrorLogDetailsRequest request = new RdsSlowLogGetErrorLogDetailsRequest(); + request.setInstanceId("rds-b3VFCjMA"); + request.setStartTime("2024-07-10T16:00:00Z"); + request.setEndTime("2024-07-10T16:00:05Z"); + request.setPageNo("1"); + request.setPageSize("10"); + request.setKeyWord("Logging"); + RdsSlowLogGetErrorLogDetailsResponse response = rdsClient.getSlowLogGetErrorLogDetails(request); + print("getSlowLogGetErrorLogDetails", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetSpecificAccountInfo.java b/src/main/java/com/baidubce/examples/rds/TestGetSpecificAccountInfo.java new file mode 100644 index 00000000..d914bef5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetSpecificAccountInfo.java @@ -0,0 +1,21 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsAccount; +import com.baidubce.services.rds.model.RdsAccountInfoRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetSpecificAccountInfo { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsAccountInfoRequest infoRequest = new RdsAccountInfoRequest(); + infoRequest.setInstanceId("rds-jHqrZCEk"); + infoRequest.setAccountName("test_account123"); + RdsAccount accountInfo = rdsClient.getSpecificAccountInfo(infoRequest); + print("getSpecificAccountInfo", accountInfo); + + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetSubnetList.java b/src/main/java/com/baidubce/examples/rds/TestGetSubnetList.java new file mode 100644 index 00000000..95637428 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetSubnetList.java @@ -0,0 +1,18 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsSubnetRequest; +import com.baidubce.services.rds.model.RdsSubnetResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestGetSubnetList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsSubnetRequest request = new RdsSubnetRequest(); + RdsSubnetResponse subnetResponse = rdsClient.getSubnetList(request); + print("getSubnetList", subnetResponse); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestGetZoneList.java b/src/main/java/com/baidubce/examples/rds/TestGetZoneList.java new file mode 100644 index 00000000..2236bc91 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestGetZoneList.java @@ -0,0 +1,15 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsZoneResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; +public class TestGetZoneList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsZoneResponse zoneResponse = rdsClient.getZoneList(); + print("getZoneList", zoneResponse); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestManuallyInitiateFullPhysicalBackup.java b/src/main/java/com/baidubce/examples/rds/TestManuallyInitiateFullPhysicalBackup.java new file mode 100644 index 00000000..fadd3674 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestManuallyInitiateFullPhysicalBackup.java @@ -0,0 +1,19 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsFullPhysicalBackupRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestManuallyInitiateFullPhysicalBackup { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsFullPhysicalBackupRequest request = new RdsFullPhysicalBackupRequest(); + request.setInstanceId("rds-5WIldjI3"); + AbstractBceResponse response = rdsClient.manuallyInitiateFullPhysicalBackup(request); + print("manuallyInitiateFullPhysicalBackup", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestModifyAccountPassword.java b/src/main/java/com/baidubce/examples/rds/TestModifyAccountPassword.java new file mode 100644 index 00000000..ef8aacd9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestModifyAccountPassword.java @@ -0,0 +1,23 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsModifyAccountPasswordRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestModifyAccountPassword { + public static void main(String[] args) { + try { + RdsClient rdsClient = createRdsClient(); + + RdsModifyAccountPasswordRequest request = new RdsModifyAccountPasswordRequest(); + request.setInstanceId("rds-tXjFULZA"); + request.setAccountName("nosuper"); + request.setPassword("123jklMN"); + AbstractBceResponse response = rdsClient.modifyAccountPassword(request); + } catch (Throwable t) { + System.exit(1); + } + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestModifyAccountPermissions.java b/src/main/java/com/baidubce/examples/rds/TestModifyAccountPermissions.java new file mode 100644 index 00000000..a897cee4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestModifyAccountPermissions.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.DatabasePrivilege; +import com.baidubce.services.rds.model.RdsModifyAccountPermissionRequest; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestModifyAccountPermissions { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsModifyAccountPermissionRequest request = new RdsModifyAccountPermissionRequest(); + + request.setInstanceId("rds-tXjFULZA"); + request.setAccountName("nosuper"); + + DatabasePrivilege privilege = new DatabasePrivilege(); + privilege.setAuthType("ReadOnly"); + privilege.setDbName("nosuperdb"); + + List privileges = new ArrayList<>(); + privileges.add(privilege); + request.setDatabasePrivileges(privileges); + AbstractBceResponse response =rdsClient.modifyAccountPermissions(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestModifyAccountRemark.java b/src/main/java/com/baidubce/examples/rds/TestModifyAccountRemark.java new file mode 100644 index 00000000..14c6d127 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestModifyAccountRemark.java @@ -0,0 +1,19 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsModifyAccountRemarksRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestModifyAccountRemark { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsModifyAccountRemarksRequest request = new RdsModifyAccountRemarksRequest(); + request.setInstanceId("rds-jHqrZCEk"); + request.setRemark("remark1111111944499994"); + request.setAccountName("test_account123"); + AbstractBceResponse response = rdsClient.modifyAccountRemark(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestModifyDatabaseDescription.java b/src/main/java/com/baidubce/examples/rds/TestModifyDatabaseDescription.java new file mode 100644 index 00000000..41d810f6 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestModifyDatabaseDescription.java @@ -0,0 +1,19 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsModifyDatabaseDescriptionRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestModifyDatabaseDescription { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsModifyDatabaseDescriptionRequest request = new RdsModifyDatabaseDescriptionRequest(); + request.setInstanceId("rds-1a6K6qX8"); + request.setDbName("dbfakfl"); + request.setRemark("testRemark"); + AbstractBceResponse response = rdsClient.modifyDatabaseDescription(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestRdsRenewal.java b/src/main/java/com/baidubce/examples/rds/TestRdsRenewal.java new file mode 100644 index 00000000..aa3eb2c1 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestRdsRenewal.java @@ -0,0 +1,25 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsRenewalRequest; +import com.baidubce.services.rds.model.RdsRenewalResponse; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestRdsRenewal { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsRenewalRequest request = new RdsRenewalRequest(); + request.setDuration("1"); + List id = new ArrayList<>(); + id.add("rds-6f17R5R3"); + request.setInstanceIds(id); + RdsRenewalResponse response = rdsClient.rdsRenewal(request); + print("rdsRenewal", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestRdsRestart.java b/src/main/java/com/baidubce/examples/rds/TestRdsRestart.java new file mode 100644 index 00000000..cf1e7305 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestRdsRestart.java @@ -0,0 +1,18 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsRestartRequest; + + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; + +public class TestRdsRestart { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsRestartRequest request = new RdsRestartRequest(); + request.setInstanceId("rds-6QCusckC"); + AbstractBceResponse response = rdsClient.rdsRestart(request); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestRdsUpdateTimeWindow.java b/src/main/java/com/baidubce/examples/rds/TestRdsUpdateTimeWindow.java new file mode 100644 index 00000000..a7a60f54 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestRdsUpdateTimeWindow.java @@ -0,0 +1,22 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsUpdateTimeWindowRequest; + + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestRdsUpdateTimeWindow { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsUpdateTimeWindowRequest request = new RdsUpdateTimeWindowRequest(); + request.setInstanceId("rds-7xabvFUH"); + request.setMaintainDuration(1); + request.setMaintainStartTime("01:00:00"); + AbstractBceResponse response = rdsClient.rdsUpdateTimeWindow(request); + print("rdsUpdateTimeWindow", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestRecoverForBackUpSet.java b/src/main/java/com/baidubce/examples/rds/TestRecoverForBackUpSet.java new file mode 100644 index 00000000..c01c33e9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestRecoverForBackUpSet.java @@ -0,0 +1,44 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsRecoverForBackUpSetRequest; +import com.baidubce.services.rds.model.RecoveryToSourceInstanceModel; +import com.baidubce.services.rds.model.RecoveryToSourceInstanceTableModel; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestRecoverForBackUpSet { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsRecoverForBackUpSetRequest request = new RdsRecoverForBackUpSetRequest(); + request.setInstanceId("rds-JC7L0yFI"); + request.setSourceInstanceId("rds-1Cm4tVAO"); + request.setTargetInstanceId("rds-1Cm4tVAO"); + request.setSnapshotId("1720637060912738501"); + List datas = new ArrayList<>(); + RecoveryToSourceInstanceModel data = new RecoveryToSourceInstanceModel(); + + List tables = new ArrayList<>(); + RecoveryToSourceInstanceTableModel table = new RecoveryToSourceInstanceTableModel(); + + table.setTableName("newcxtest"); + table.setNewTablename("cxtest"); + + data.setDbName("newdeadlock"); + data.setNewDbname("deadlock"); + data.setRestoreMode("table"); + data.setTables(tables); + + datas.add(data); + request.setData(datas); + + AbstractBceResponse response = rdsClient.recoverForBackUpSet(request); + print("recoverForBackUpSet", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestRecoverForTimeNode.java b/src/main/java/com/baidubce/examples/rds/TestRecoverForTimeNode.java new file mode 100644 index 00000000..7f015423 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestRecoverForTimeNode.java @@ -0,0 +1,47 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsRecoverForTimeNodeRequest; +import com.baidubce.services.rds.model.RecoveryToSourceInstanceModel; +import com.baidubce.services.rds.model.RecoveryToSourceInstanceTableModel; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + + +public class TestRecoverForTimeNode { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsRecoverForTimeNodeRequest request = new RdsRecoverForTimeNodeRequest(); + request.setInstanceId("rds-1Cm4tVAO"); + request.setSourceInstanceId("rds-1Cm4tVAO"); + request.setTargetInstanceId("rds-1Cm4tVAO"); + request.setDatetime("2024-07-10T18:36:46Z"); + + List datas = new ArrayList<>(); + RecoveryToSourceInstanceModel data = new RecoveryToSourceInstanceModel(); + + List tables = new ArrayList<>(); + RecoveryToSourceInstanceTableModel table = new RecoveryToSourceInstanceTableModel(); + + table.setTableName("deadlock"); + table.setNewTablename("newdeadlock"); + tables.add(table); + + data.setDbName("cxtest"); + data.setNewDbname("newcxtest"); + data.setRestoreMode("table"); + data.setTables(tables); + + + datas.add(data); + request.setData(datas); + AbstractBceResponse response = rdsClient.recoverForTimeNode(request); + print("recoverForTimeNode", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestReleaseInstance.java b/src/main/java/com/baidubce/examples/rds/TestReleaseInstance.java new file mode 100644 index 00000000..fd343149 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestReleaseInstance.java @@ -0,0 +1,25 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsReleaseInstanceRequest; +import com.baidubce.services.rds.model.RdsReleaseInstanceResponse; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestReleaseInstance { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsReleaseInstanceRequest request = new RdsReleaseInstanceRequest(); + String instanceId = "rds-v1JOe6Di"; + List instanceIds = new ArrayList<>(); + instanceIds.add(instanceId); + request.setInstanceIds(instanceIds); + RdsReleaseInstanceResponse response = rdsClient.releaseInstance(request); + print("releaseInstance", response);; + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestResizeInstance.java b/src/main/java/com/baidubce/examples/rds/TestResizeInstance.java new file mode 100644 index 00000000..a66bbd41 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestResizeInstance.java @@ -0,0 +1,22 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsInstanceResizeRequest; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestResizeInstance { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsInstanceResizeRequest resizeRequest = new RdsInstanceResizeRequest(); + resizeRequest.setInstanceId("rds-EzZEzrYA"); + resizeRequest.setVolumeCapacity(10); + resizeRequest.setIsDirectPay(true); + AbstractBceResponse resizeResponse = rdsClient.resizeInstance(resizeRequest); + print("resizeInstance", resizeResponse); + + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestSlowLogGetErrorLogList.java b/src/main/java/com/baidubce/examples/rds/TestSlowLogGetErrorLogList.java new file mode 100644 index 00000000..409ceab1 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestSlowLogGetErrorLogList.java @@ -0,0 +1,20 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsSlowLogGetErrorLogListRequest; +import com.baidubce.services.rds.model.RdsSlowLogGetErrorLogListResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestSlowLogGetErrorLogList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsSlowLogGetErrorLogListRequest request = new RdsSlowLogGetErrorLogListRequest(); + request.setInstanceId("rds-jHqrZCEk"); + request.setDatetime("2024-07-11 00:00:00"); + RdsSlowLogGetErrorLogListResponse response = rdsClient.slowLogGetErrorLogList(request); + print("slowLogGetErrorLogList", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestSupportEnableAutoExpansion.java b/src/main/java/com/baidubce/examples/rds/TestSupportEnableAutoExpansion.java new file mode 100644 index 00000000..14d4edd5 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestSupportEnableAutoExpansion.java @@ -0,0 +1,19 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsSupportEnableAutoExpansionRequest; +import com.baidubce.services.rds.model.RdsSupportEnableAutoExpansionResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestSupportEnableAutoExpansion { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsSupportEnableAutoExpansionRequest request = new RdsSupportEnableAutoExpansionRequest(); + request.setInstanceId("rds-k1dffnQn"); + RdsSupportEnableAutoExpansionResponse response = rdsClient.supportEnableAutoExpansion(request); + print("supportEnableAutoExpansion", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestSupportHotSwapping.java b/src/main/java/com/baidubce/examples/rds/TestSupportHotSwapping.java new file mode 100644 index 00000000..49aa35ac --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestSupportHotSwapping.java @@ -0,0 +1,26 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsSupportHotSwappingRequest; +import com.baidubce.services.rds.model.RdsSupportHotSwappingResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestSupportHotSwapping { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsSupportHotSwappingRequest request = new RdsSupportHotSwappingRequest(); + request.setInstanceId("rds-6QCusckC"); + request.setBackupAzone("cn-bj-d"); + request.setAllocatedMemoryInMB(1024); + request.setAllocatedStorageInGB(50); + request.setCpuCount(1); + request.setMasterAzone("cn-bj-d"); + request.setSubnetId("sbn-dqafncqsy3y4"); + RdsSupportHotSwappingResponse response = rdsClient.supportHotSwapping(request); + print("supportHotSwapping", response); + } + +} diff --git a/src/main/java/com/baidubce/examples/rds/TestUpdateRdsConnectionInformation.java b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsConnectionInformation.java new file mode 100644 index 00000000..b4ebd2bd --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsConnectionInformation.java @@ -0,0 +1,21 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsConnInformationRequest; + + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestUpdateRdsConnectionInformation { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsConnInformationRequest request = new RdsConnInformationRequest(); + request.setInstanceId("rds-6f17R5R3"); + request.setAddress("fkajsdlk"); + AbstractBceResponse response = rdsClient.updateRdsConnectionInformation(request); + print("updateRdsConnectionInformation", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestUpdateRdsName.java b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsName.java new file mode 100644 index 00000000..d4472b01 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsName.java @@ -0,0 +1,21 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsUpdateNameRequest; + + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestUpdateRdsName { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsUpdateNameRequest request = new RdsUpdateNameRequest(); + request.setInstanceId("rds-17JzX6Wm"); + request.setInstanceName("gaojianPGSQL"); + AbstractBceResponse response = rdsClient.updateRdsName(request); + print("updateRdsName", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestUpdateRdsPublicNetworkAccessStatus.java b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsPublicNetworkAccessStatus.java new file mode 100644 index 00000000..9db6a38b --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsPublicNetworkAccessStatus.java @@ -0,0 +1,21 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsNetworkStatusRequest; + + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestUpdateRdsPublicNetworkAccessStatus { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsNetworkStatusRequest request = new RdsNetworkStatusRequest(); + request.setInstanceId("rds-17JzX6Wm"); + request.setPublicAccess(false); + AbstractBceResponse response = rdsClient.updateRdsPublicNetworkAccessStatus(request); + print("updateRdsPublicNetworkAccessStatus", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestUpdateRdsStorageAutoExpansionConfig.java b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsStorageAutoExpansionConfig.java new file mode 100644 index 00000000..cf5fd334 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsStorageAutoExpansionConfig.java @@ -0,0 +1,20 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsUpdateStorageAutoExpansionConfigRequest; +import com.baidubce.services.rds.model.RdsUpdateStorageAutoExpansionConfigResPonse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestUpdateRdsStorageAutoExpansionConfig { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsUpdateStorageAutoExpansionConfigRequest request = new RdsUpdateStorageAutoExpansionConfigRequest(); + request.setInstanceId("rds-lZIdjcC3"); + request.setAction("close"); + RdsUpdateStorageAutoExpansionConfigResPonse response = rdsClient.updateRdsStorageAutoExpansionConfig(request); + print("updateRdsStorageAutoExpansionConfig", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestUpdateRdsSyncMode.java b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsSyncMode.java new file mode 100644 index 00000000..2ad3089d --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestUpdateRdsSyncMode.java @@ -0,0 +1,21 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsSyncModeRequest; + + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestUpdateRdsSyncMode { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsSyncModeRequest request = new RdsSyncModeRequest(); + request.setSyncMode("async"); + request.setInstanceId("rds-17JzX6Wm"); + AbstractBceResponse response = rdsClient.updateRdsSyncMode(request); + print("updateRdsSyncMode", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestUpdateWriteList.java b/src/main/java/com/baidubce/examples/rds/TestUpdateWriteList.java new file mode 100644 index 00000000..eb175a4b --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestUpdateWriteList.java @@ -0,0 +1,24 @@ +package com.baidubce.examples.rds; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsUpdateWriteListResquest; + +import java.util.Arrays; +import java.util.List; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestUpdateWriteList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsUpdateWriteListResquest resquest = new RdsUpdateWriteListResquest(); + resquest.setInstanceId("rds-5WIldjI3"); + List ips = Arrays.asList("%"); + resquest.setSecurityIps(ips); + AbstractBceResponse response =rdsClient.updateWriteList(resquest); + print("updateWriteList", response); + } +} diff --git a/src/main/java/com/baidubce/examples/rds/TestViewWriteList.java b/src/main/java/com/baidubce/examples/rds/TestViewWriteList.java new file mode 100644 index 00000000..7b7b7921 --- /dev/null +++ b/src/main/java/com/baidubce/examples/rds/TestViewWriteList.java @@ -0,0 +1,19 @@ +package com.baidubce.examples.rds; + +import com.baidubce.services.rds.RdsClient; +import com.baidubce.services.rds.model.RdsViewWriteListRequest; +import com.baidubce.services.rds.model.RdsViewWriteListResponse; + +import static com.baidubce.examples.rds.RdsUtil.createRdsClient; +import static com.baidubce.examples.rds.RdsUtil.print; + +public class TestViewWriteList { + public static void main(String[] args) { + RdsClient rdsClient = createRdsClient(); + + RdsViewWriteListRequest request = new RdsViewWriteListRequest(); + request.setInstanceId("rds-5WIldjI3"); + RdsViewWriteListResponse response = rdsClient.viewWriteList(request); + print("viewWriteList", response); + } +} diff --git a/src/main/java/com/baidubce/examples/route/ExampleCreateRouteRule.java b/src/main/java/com/baidubce/examples/route/ExampleCreateRouteRule.java new file mode 100644 index 00000000..9d4063ef --- /dev/null +++ b/src/main/java/com/baidubce/examples/route/ExampleCreateRouteRule.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.route; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.route.RouteClient; +import com.baidubce.services.route.RouteClientConfiguration; +import com.baidubce.services.route.model.CreateRouteRequest; +import com.baidubce.services.route.model.CreateRouteResponse; + +public class ExampleCreateRouteRule { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + RouteClientConfiguration config = new RouteClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + RouteClient routeClient = new RouteClient(config); // 初始化VpcClient + + CreateRouteRequest createRouteRequest = new CreateRouteRequest(); + createRouteRequest.setRouteTableId("rt-s3qmp80vq02q"); // 路由表Id + createRouteRequest.setSourceAddress("2400:da00:e003:9b00::/88"); // 路由源地址 + createRouteRequest.setDestinationAddress("::/0"); // 路由目的地址 + createRouteRequest.setNexthopType("enic"); // 路由下一跳 + createRouteRequest.setNexthopId("eni-wjz6683jaswn"); // 路由类型 + createRouteRequest.setDescription("desc"); // 路由描述 + createRouteRequest.setIpVersion(6); // 路由 ipversion 4或者6 默认是4 + + try { + CreateRouteResponse response = routeClient.createRoute(createRouteRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/route/ExampleDeleteRouteRule.java b/src/main/java/com/baidubce/examples/route/ExampleDeleteRouteRule.java new file mode 100644 index 00000000..652759b4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/route/ExampleDeleteRouteRule.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.route; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.route.RouteClient; +import com.baidubce.services.route.RouteClientConfiguration; + +public class ExampleDeleteRouteRule { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + RouteClientConfiguration config = new RouteClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + RouteClient routeClient = new RouteClient(config); // 初始化VpcClient + + try { + routeClient.deleteRouteRule("rr-vvhz3aiv0gz2"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/route/ExampleListRouteRule.java b/src/main/java/com/baidubce/examples/route/ExampleListRouteRule.java new file mode 100644 index 00000000..be4a5e0b --- /dev/null +++ b/src/main/java/com/baidubce/examples/route/ExampleListRouteRule.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.route; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.route.RouteClient; +import com.baidubce.services.route.RouteClientConfiguration; +import com.baidubce.services.route.model.GetRouteResponse; + +public class ExampleListRouteRule { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + RouteClientConfiguration config = new RouteClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + RouteClient routeClient = new RouteClient(config); // 初始化VpcClient + + try { + GetRouteResponse response = routeClient.getRoute("rt-s3qmp80vq02q", null); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/route/ExampleMarkerListRouteRule.java b/src/main/java/com/baidubce/examples/route/ExampleMarkerListRouteRule.java new file mode 100644 index 00000000..1f618515 --- /dev/null +++ b/src/main/java/com/baidubce/examples/route/ExampleMarkerListRouteRule.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.route; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.route.RouteClient; +import com.baidubce.services.route.RouteClientConfiguration; +import com.baidubce.services.route.model.ListRouteRuleReq; +import com.baidubce.services.route.model.ListRouteRuleResponse; + +public class ExampleMarkerListRouteRule { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + RouteClientConfiguration config = new RouteClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + RouteClient routeClient = new RouteClient(config); // 初始化VpcClient + + + ListRouteRuleReq listRouteRuleReq = new ListRouteRuleReq(); + listRouteRuleReq.setRouteTableId("rt-s3qmp80vq02q"); + try { + ListRouteRuleResponse response = routeClient.listRouteRule(listRouteRuleReq); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/route/ExampleRouteRuleSwithHa.java b/src/main/java/com/baidubce/examples/route/ExampleRouteRuleSwithHa.java new file mode 100644 index 00000000..d40bdddd --- /dev/null +++ b/src/main/java/com/baidubce/examples/route/ExampleRouteRuleSwithHa.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.route; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.route.RouteClient; +import com.baidubce.services.route.RouteClientConfiguration; + +public class ExampleRouteRuleSwithHa { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + RouteClientConfiguration config = new RouteClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + RouteClient routeClient = new RouteClient(config); // 初始化VpcClient + + try { + routeClient.switchRouteHa("rr-jcr3w2xryq2g"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/route/ExampleUpdateRouteRule.java b/src/main/java/com/baidubce/examples/route/ExampleUpdateRouteRule.java new file mode 100644 index 00000000..09670218 --- /dev/null +++ b/src/main/java/com/baidubce/examples/route/ExampleUpdateRouteRule.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.route; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.route.RouteClient; +import com.baidubce.services.route.RouteClientConfiguration; +import com.baidubce.services.route.model.UpdateRouteRuleRequest; + +public class ExampleUpdateRouteRule { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + RouteClientConfiguration config = new RouteClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + RouteClient routeClient = new RouteClient(config); // 初始化VpcClient + + UpdateRouteRuleRequest updateRouteRuleRequest = new UpdateRouteRuleRequest(); + updateRouteRuleRequest.setRouteRuleId("rr-jcr3w2xryq2g"); + updateRouteRuleRequest.setDescription("desc_new"); + + try { + routeClient.updateRouteRule(updateRouteRuleRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/securitygroup/ExampleAddSecurityGroupRule.java b/src/main/java/com/baidubce/examples/securitygroup/ExampleAddSecurityGroupRule.java new file mode 100644 index 00000000..4bb21675 --- /dev/null +++ b/src/main/java/com/baidubce/examples/securitygroup/ExampleAddSecurityGroupRule.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.securitygroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.SecurityGroupRuleModel; +import com.baidubce.services.bcc.model.securitygroup.SecurityGroupRuleOperateRequest; + +public class ExampleAddSecurityGroupRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BccClientConfiguration config = new BccClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BccClient bccClient = new BccClient(config); // 初始化SecurityGroupClient + + SecurityGroupRuleOperateRequest securityGroupRuleOperateRequest = new SecurityGroupRuleOperateRequest(); + securityGroupRuleOperateRequest.setSecurityGroupId("g-z7e2nm72eezs"); + + SecurityGroupRuleModel securityGroupRuleModel = new SecurityGroupRuleModel(); + securityGroupRuleModel.setSourceIp("all"); // 规则源IP + securityGroupRuleModel.setDestIp("all"); // 规则目的IP + securityGroupRuleModel.setDirection("ingress"); // 规则的方向 + securityGroupRuleModel.setProtocol("tcp"); // 规则协议 + securityGroupRuleModel.setPortRange("1000-3000"); // 规则端口范围 + securityGroupRuleModel.setEthertype("IPv4"); // 规则IPv4版本 + + securityGroupRuleOperateRequest.setRule(securityGroupRuleModel); + try { + bccClient.authorizeSecurityGroupRule(securityGroupRuleOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/securitygroup/ExampleCreateSecurityGroup.java b/src/main/java/com/baidubce/examples/securitygroup/ExampleCreateSecurityGroup.java new file mode 100644 index 00000000..85d51bc2 --- /dev/null +++ b/src/main/java/com/baidubce/examples/securitygroup/ExampleCreateSecurityGroup.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.securitygroup; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.SecurityGroupRuleModel; +import com.baidubce.services.bcc.model.securitygroup.CreateSecurityGroupRequest; +import com.baidubce.services.bcc.model.securitygroup.CreateSecurityGroupResponse; + +public class ExampleCreateSecurityGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BccClientConfiguration config = new BccClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BccClient bccClient = new BccClient(config); // 初始化SecurityGroupClient + + CreateSecurityGroupRequest createSecurityGroupRequest = new CreateSecurityGroupRequest(); + createSecurityGroupRequest.setName("sgName"); // sg名称 + createSecurityGroupRequest.setDesc("desc"); // sg描述 + createSecurityGroupRequest.setVpcId("vpc-b9ycwxxisrb7"); // sg所属VPC + SecurityGroupRuleModel securityGroupRuleModel = new SecurityGroupRuleModel(); + securityGroupRuleModel.setSourceIp("all"); // 规则源IP + securityGroupRuleModel.setDestIp("all"); // 规则目的IP + securityGroupRuleModel.setDirection("ingress"); // 规则的方向 + securityGroupRuleModel.setProtocol("tcp"); // 规则协议 + securityGroupRuleModel.setPortRange("1000-3000"); // 规则端口范围 + securityGroupRuleModel.setEthertype("IPv4"); // 规则IPv4版本 + + createSecurityGroupRequest.setRules(Arrays.asList(securityGroupRuleModel)); + try { + CreateSecurityGroupResponse response = bccClient.createSecurityGroup(createSecurityGroupRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/securitygroup/ExampleDeleteSecurityGroup.java b/src/main/java/com/baidubce/examples/securitygroup/ExampleDeleteSecurityGroup.java new file mode 100644 index 00000000..e82bc8ba --- /dev/null +++ b/src/main/java/com/baidubce/examples/securitygroup/ExampleDeleteSecurityGroup.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.securitygroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; + +public class ExampleDeleteSecurityGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BccClientConfiguration config = new BccClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BccClient bccClient = new BccClient(config); // 初始化SecurityGroupClient + try { + bccClient.deleteSecurityGroup("g-jnh9zaurh5s6"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/securitygroup/ExampleDeleteSecurityGroupRule.java b/src/main/java/com/baidubce/examples/securitygroup/ExampleDeleteSecurityGroupRule.java new file mode 100644 index 00000000..9bed398b --- /dev/null +++ b/src/main/java/com/baidubce/examples/securitygroup/ExampleDeleteSecurityGroupRule.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.securitygroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.securitygroup.ListSecurityGroupsRequest; + +public class ExampleDeleteSecurityGroupRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BccClientConfiguration config = new BccClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BccClient bccClient = new BccClient(config); // 初始化SecurityGroupClient + + ListSecurityGroupsRequest listSecurityGroupsRequest = new ListSecurityGroupsRequest(); + listSecurityGroupsRequest.setVpcId("vpc-b9ycwxxisrb7"); + try { + bccClient.deleteSecurityGroupRule("r-2guv5ze6yx48"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/securitygroup/ExampleGetSecurityGroup.java b/src/main/java/com/baidubce/examples/securitygroup/ExampleGetSecurityGroup.java new file mode 100644 index 00000000..051093ab --- /dev/null +++ b/src/main/java/com/baidubce/examples/securitygroup/ExampleGetSecurityGroup.java @@ -0,0 +1,27 @@ +package com.baidubce.examples.securitygroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.SecurityGroupModel; + +public class ExampleGetSecurityGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BccClientConfiguration config = new BccClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BccClient bccClient = new BccClient(config); // 初始化SecurityGroupClient + + try { + SecurityGroupModel response = bccClient.getSecurityGroup("g-zhc4yv5aw2i9"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/securitygroup/ExampleListSecurityGroup.java b/src/main/java/com/baidubce/examples/securitygroup/ExampleListSecurityGroup.java new file mode 100644 index 00000000..dc35e806 --- /dev/null +++ b/src/main/java/com/baidubce/examples/securitygroup/ExampleListSecurityGroup.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.securitygroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.securitygroup.ListSecurityGroupsRequest; +import com.baidubce.services.bcc.model.securitygroup.ListSecurityGroupsResponse; + +public class ExampleListSecurityGroup { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BccClientConfiguration config = new BccClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BccClient bccClient = new BccClient(config); // 初始化SecurityGroupClient + + ListSecurityGroupsRequest listSecurityGroupsRequest = new ListSecurityGroupsRequest(); + listSecurityGroupsRequest.setVpcId("vpc-b9ycwxxisrb7"); // 安全组的vpcId + + try { + ListSecurityGroupsResponse response = bccClient.listSecurityGroups(listSecurityGroupsRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/securitygroup/ExampleRevokeSecurityGroupRule.java b/src/main/java/com/baidubce/examples/securitygroup/ExampleRevokeSecurityGroupRule.java new file mode 100644 index 00000000..1af238b9 --- /dev/null +++ b/src/main/java/com/baidubce/examples/securitygroup/ExampleRevokeSecurityGroupRule.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.securitygroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.SecurityGroupRuleModel; +import com.baidubce.services.bcc.model.securitygroup.SecurityGroupRuleOperateRequest; + +public class ExampleRevokeSecurityGroupRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BccClientConfiguration config = new BccClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BccClient bccClient = new BccClient(config); // 初始化SecurityGroupClient + SecurityGroupRuleOperateRequest securityGroupRuleOperateRequest = new SecurityGroupRuleOperateRequest(); + securityGroupRuleOperateRequest.setSecurityGroupId("g-unsf3zrpb80u"); + + SecurityGroupRuleModel securityGroupRuleModel = new SecurityGroupRuleModel(); // 要删除的规则对象 + securityGroupRuleModel.setSourceIp("all"); // 规则源IP + securityGroupRuleModel.setDestIp("all"); // 规则目的IP + securityGroupRuleModel.setDirection("ingress"); // 规则的方向 + securityGroupRuleModel.setProtocol("tcp"); // 规则协议 + securityGroupRuleModel.setPortRange("1000-3000"); // 规则端口范围 + securityGroupRuleModel.setEthertype("IPv4"); // 规则IPv4版本 + securityGroupRuleOperateRequest.setRule(securityGroupRuleModel); + try { + bccClient.revokeSecurityGroupRule(securityGroupRuleOperateRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/securitygroup/ExampleUpdateSecurityGroupRule.java b/src/main/java/com/baidubce/examples/securitygroup/ExampleUpdateSecurityGroupRule.java new file mode 100644 index 00000000..54307a4c --- /dev/null +++ b/src/main/java/com/baidubce/examples/securitygroup/ExampleUpdateSecurityGroupRule.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.securitygroup; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.securitygroup.UpdateSecurityGroupRuleRequest; + +public class ExampleUpdateSecurityGroupRule { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + BccClientConfiguration config = new BccClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + BccClient bccClient = new BccClient(config); // 初始化SecurityGroupClient + + UpdateSecurityGroupRuleRequest updateSecurityGroupRuleRequest = new UpdateSecurityGroupRuleRequest(); + updateSecurityGroupRuleRequest.setSecurityGroupRuleId("r-icyc1fkct9wk"); + updateSecurityGroupRuleRequest.setRemark("desc"); + try { + bccClient.updateSecurityGroupRule(updateSecurityGroupRuleRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/subnet/ExampleCreateIpReserve.java b/src/main/java/com/baidubce/examples/subnet/ExampleCreateIpReserve.java new file mode 100644 index 00000000..7420f82f --- /dev/null +++ b/src/main/java/com/baidubce/examples/subnet/ExampleCreateIpReserve.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.subnet; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.subnet.SubnetClient; +import com.baidubce.services.subnet.SubnetClientConfiguration; +import com.baidubce.services.subnet.model.CreateIpReservedReq; +import com.baidubce.services.subnet.model.CreateIpReservedResponse; + +public class ExampleCreateIpReserve { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + SubnetClientConfiguration config = new SubnetClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + SubnetClient subnetClient = new SubnetClient(config); // 初始化SubnetClient + + CreateIpReservedReq createIpReservedReq = new CreateIpReservedReq(); + createIpReservedReq.setSubnetId("sbn-6ha6gp1vczuv"); + createIpReservedReq.setIpCidr("192.168.0.0/30"); + createIpReservedReq.setDescription("aaa"); + + try { + CreateIpReservedResponse createIpReservedResponse = subnetClient.createIpReserved(createIpReservedReq); + System.out.println(createIpReservedResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/subnet/ExampleCreateSubnet.java b/src/main/java/com/baidubce/examples/subnet/ExampleCreateSubnet.java new file mode 100644 index 00000000..55b3cd5c --- /dev/null +++ b/src/main/java/com/baidubce/examples/subnet/ExampleCreateSubnet.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.subnet; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.subnet.SubnetClient; +import com.baidubce.services.subnet.SubnetClientConfiguration; +import com.baidubce.services.subnet.model.CreateSubnetRequest; +import com.baidubce.services.subnet.model.CreateSubnetResponse; +import com.baidubce.services.tag.model.Tag; +import com.google.common.collect.Lists; + +public class ExampleCreateSubnet { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + SubnetClientConfiguration config = new SubnetClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + SubnetClient subnetClient = new SubnetClient(config); // 初始化SubnetClient + + CreateSubnetRequest createSubnetRequest = new CreateSubnetRequest(); + createSubnetRequest.setVpcId("vpc-6fykvyb927mk"); + createSubnetRequest.setCidr("10.0.0.0/28"); + createSubnetRequest.setName("testSubnet"); + createSubnetRequest.setZoneName("cn-bj-a"); + createSubnetRequest.setVpcSecondaryCidr("10.0.0.0/24"); + + Tag tag = new Tag(); + tag.setTagKey("tagKey"); + tag.setTagValue("tagValue"); + createSubnetRequest.setTags(Lists.newArrayList(tag)); + + try { + CreateSubnetResponse createSubnetResponse = subnetClient.createSubnet(createSubnetRequest); + System.out.println(createSubnetResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/subnet/ExampleDeleteIpReserve.java b/src/main/java/com/baidubce/examples/subnet/ExampleDeleteIpReserve.java new file mode 100644 index 00000000..cb2a9f06 --- /dev/null +++ b/src/main/java/com/baidubce/examples/subnet/ExampleDeleteIpReserve.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.subnet; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.subnet.SubnetClient; +import com.baidubce.services.subnet.SubnetClientConfiguration; + +public class ExampleDeleteIpReserve { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + SubnetClientConfiguration config = new SubnetClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + SubnetClient subnetClient = new SubnetClient(config); // 初始化SubnetClient + + try { + subnetClient.deleteIpReserve("ipr-zemfd9sursiw"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/subnet/ExampleDeleteSubnet.java b/src/main/java/com/baidubce/examples/subnet/ExampleDeleteSubnet.java new file mode 100644 index 00000000..03f8c2b3 --- /dev/null +++ b/src/main/java/com/baidubce/examples/subnet/ExampleDeleteSubnet.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.subnet; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.subnet.SubnetClient; +import com.baidubce.services.subnet.SubnetClientConfiguration; + +public class ExampleDeleteSubnet { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + SubnetClientConfiguration config = new SubnetClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + SubnetClient subnetClient = new SubnetClient(config); // 初始化SubnetClient + + try { + subnetClient.deleteSubnet("sbn-tzm673arie6j"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/subnet/ExampleGetSubnet.java b/src/main/java/com/baidubce/examples/subnet/ExampleGetSubnet.java new file mode 100644 index 00000000..f2257082 --- /dev/null +++ b/src/main/java/com/baidubce/examples/subnet/ExampleGetSubnet.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.subnet; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.subnet.SubnetClient; +import com.baidubce.services.subnet.SubnetClientConfiguration; +import com.baidubce.services.subnet.model.GetSubnetDetailResponse; + +public class ExampleGetSubnet { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + SubnetClientConfiguration config = new SubnetClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + SubnetClient subnetClient = new SubnetClient(config); // 初始化SubnetClient + + + try { + GetSubnetDetailResponse getSubnetDetailResponse = subnetClient.getSubnetDetail("sbn-qz55vemw0n40"); + System.out.println(getSubnetDetailResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/subnet/ExampleListIpReserve.java b/src/main/java/com/baidubce/examples/subnet/ExampleListIpReserve.java new file mode 100644 index 00000000..59ffdcf1 --- /dev/null +++ b/src/main/java/com/baidubce/examples/subnet/ExampleListIpReserve.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.subnet; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.subnet.SubnetClient; +import com.baidubce.services.subnet.SubnetClientConfiguration; +import com.baidubce.services.subnet.model.ListIpReserveResponse; + +public class ExampleListIpReserve { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + SubnetClientConfiguration config = new SubnetClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + SubnetClient subnetClient = new SubnetClient(config); // 初始化SubnetClient + try { + ListIpReserveResponse listIpReserveResponse = subnetClient.listIpReserve(); + System.out.println(listIpReserveResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/subnet/ExampleListSubnet.java b/src/main/java/com/baidubce/examples/subnet/ExampleListSubnet.java new file mode 100644 index 00000000..3603db84 --- /dev/null +++ b/src/main/java/com/baidubce/examples/subnet/ExampleListSubnet.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.subnet; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.subnet.SubnetClient; +import com.baidubce.services.subnet.SubnetClientConfiguration; +import com.baidubce.services.subnet.model.ListSubnetsResponse; + +public class ExampleListSubnet { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + SubnetClientConfiguration config = new SubnetClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + SubnetClient subnetClient = new SubnetClient(config); // 初始化SubnetClient + + try { + ListSubnetsResponse listSubnets = subnetClient.listSubnets(); + System.out.println(listSubnets); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/subnet/ExampleUpdateSubnet.java b/src/main/java/com/baidubce/examples/subnet/ExampleUpdateSubnet.java new file mode 100644 index 00000000..4a64ef68 --- /dev/null +++ b/src/main/java/com/baidubce/examples/subnet/ExampleUpdateSubnet.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.subnet; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.subnet.SubnetClient; +import com.baidubce.services.subnet.SubnetClientConfiguration; + +public class ExampleUpdateSubnet { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + SubnetClientConfiguration config = new SubnetClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + SubnetClient subnetClient = new SubnetClient(config); // 初始化SubnetClient¬ + + try { + subnetClient.modifySubnetAttributes("sbn-6ha6gp1vczuv", "name1"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/com/baidubce/examples/tag/ExampleBindTagsBatchByResourceType.java b/src/main/java/com/baidubce/examples/tag/ExampleBindTagsBatchByResourceType.java new file mode 100644 index 00000000..794b2336 --- /dev/null +++ b/src/main/java/com/baidubce/examples/tag/ExampleBindTagsBatchByResourceType.java @@ -0,0 +1,40 @@ +package com.baidubce.examples.tag; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.model.ResourceType; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.bcc.model.TagsOperationRequest; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ExampleBindTagsBatchByResourceType { + 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 bccClient = new BccClient(bccClientConfiguration); + TagsOperationRequest tagsOperationRequest = new TagsOperationRequest(); + // 标签列表 + List changeTags = new ArrayList(); + TagModel tagModel = new TagModel().withTagKey("Key-example").withTagValue("Value"); + changeTags.add(tagModel); + tagsOperationRequest.setTags(changeTags); + // 预留实例券ID列表 + tagsOperationRequest.setResourceIds(Arrays.asList("r-oFpMXKhv", "r-HrztSVk0")); + + tagsOperationRequest.setResourceType(ResourceType.bccri.name()); + bccClient.bindTagsBatchByResourceType(tagsOperationRequest); + } +} diff --git a/src/main/java/com/baidubce/examples/tag/ExampleUnbindTagsBatchByResourceType.java b/src/main/java/com/baidubce/examples/tag/ExampleUnbindTagsBatchByResourceType.java new file mode 100644 index 00000000..67f65357 --- /dev/null +++ b/src/main/java/com/baidubce/examples/tag/ExampleUnbindTagsBatchByResourceType.java @@ -0,0 +1,40 @@ +package com.baidubce.examples.tag; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.Protocol; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.model.ResourceType; +import com.baidubce.services.bcc.BccClient; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.bcc.model.TagsOperationRequest; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ExampleUnbindTagsBatchByResourceType { + 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 bccClient = new BccClient(bccClientConfiguration); + TagsOperationRequest tagsOperationRequest = new TagsOperationRequest(); + // 标签列表 + List changeTags = new ArrayList(); + TagModel tagModel = new TagModel().withTagKey("Key-example").withTagValue("Value"); + changeTags.add(tagModel); + tagsOperationRequest.setTags(changeTags); + // 预留实例券ID列表,最多支持100个 + tagsOperationRequest.setResourceIds(Arrays.asList("r-oFpMXKhv", "r-HrztSVk0")); + + tagsOperationRequest.setResourceType(ResourceType.bccri.name()); + bccClient.unbindTagsBatchByResourceType(tagsOperationRequest); + } +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleAddAuth.java b/src/main/java/com/baidubce/examples/userservice/ExampleAddAuth.java new file mode 100644 index 00000000..5ca48bed --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleAddAuth.java @@ -0,0 +1,46 @@ +package com.baidubce.examples.userservice; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; +import com.baidubce.services.userservice.model.AddAuthRequest; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleAddAuth { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + AddAuthRequest addAuthRequest = new AddAuthRequest(); + List authList = new ArrayList(); // 添加的权限列表 + AddAuthRequest.Auth auth = new AddAuthRequest.Auth(); + auth.setAuth("allow"); // 权限类型,取值为allow和deny + auth.setUid("7cc5aff841ff4b648028d80b84e1917e"); // 用户ID + authList.add(auth); + addAuthRequest.setAuthList(authList); + + try { + userserviceClient.addAuth("testService.uservice-9fbf1146.beijing.baidubce.com", + addAuthRequest, null); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleBindInstance.java b/src/main/java/com/baidubce/examples/userservice/ExampleBindInstance.java new file mode 100644 index 00000000..e518befb --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleBindInstance.java @@ -0,0 +1,38 @@ +package com.baidubce.examples.userservice; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; +import com.baidubce.services.userservice.model.BindInstanceRequest; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleBindInstance { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + BindInstanceRequest bindInstanceRequest = new BindInstanceRequest(); + bindInstanceRequest.setInstanceId("lb-b69cd42f"); // 绑定的实例ID + + try { + userserviceClient.bindInstance("testService.uservice-9fbf1146.beijing.baidubce.com", + bindInstanceRequest, null); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleCreateUserService.java b/src/main/java/com/baidubce/examples/userservice/ExampleCreateUserService.java new file mode 100644 index 00000000..fdbeadae --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleCreateUserService.java @@ -0,0 +1,51 @@ +package com.baidubce.examples.userservice; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; +import com.baidubce.services.userservice.model.CreateUserServiceRequest; +import com.baidubce.services.userservice.model.CreateUserServiceResponse; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleCreateUserService { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + CreateUserServiceRequest createUserServiceRequest = new CreateUserServiceRequest(); + createUserServiceRequest.setName("name"); // 服务发布点名称 + createUserServiceRequest.setDescription("desc"); // 描述 + createUserServiceRequest.setServiceName("testService"); // 服务名称 + createUserServiceRequest.setInstanceId("lb-b69cd42f"); // 绑定的实例id + List authList = new ArrayList(); // 权限列表 + CreateUserServiceRequest.Auth auth = new CreateUserServiceRequest.Auth(); + auth.setAuth("allow"); // 权限类型,取值为allow和deny + auth.setUid("*"); // 用户id + authList.add(auth); + createUserServiceRequest.setAuthList(authList); + + try { + CreateUserServiceResponse response = userserviceClient.createUserService(createUserServiceRequest, ""); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleDeleteUserService.java b/src/main/java/com/baidubce/examples/userservice/ExampleDeleteUserService.java new file mode 100644 index 00000000..bb3f7d09 --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleDeleteUserService.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.userservice; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleDeleteUserService { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + try { + userserviceClient.deleteUserService("testService.uservice-9fbf1146.beijing.baidubce.com", ""); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleEditAuth.java b/src/main/java/com/baidubce/examples/userservice/ExampleEditAuth.java new file mode 100644 index 00000000..160ade39 --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleEditAuth.java @@ -0,0 +1,46 @@ +package com.baidubce.examples.userservice; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; +import com.baidubce.services.userservice.model.EditAuthRequest; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleEditAuth { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + EditAuthRequest editAuthRequest = new EditAuthRequest(); + List authList = new ArrayList(); // 添加的权限列表 + EditAuthRequest.Auth auth = new EditAuthRequest.Auth(); + auth.setAuth("deny"); // 权限类型,取值为allow和deny + auth.setUid("7cc5aff841ff4b648028d80b84e1917e"); // 用户uid + authList.add(auth); + editAuthRequest.setAuthList(authList); + + try { + userserviceClient.editAuth("testService.uservice-9fbf1146.beijing.baidubce.com", + editAuthRequest, null); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleGetUserService.java b/src/main/java/com/baidubce/examples/userservice/ExampleGetUserService.java new file mode 100644 index 00000000..b02c218b --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleGetUserService.java @@ -0,0 +1,36 @@ +package com.baidubce.examples.userservice; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; +import com.baidubce.services.userservice.model.GetUserServiceResponse; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleGetUserService { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + try { + GetUserServiceResponse response = + userserviceClient.getUserService("testService.uservice-9fbf1146.beijing.baidubce.com"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleListUserService.java b/src/main/java/com/baidubce/examples/userservice/ExampleListUserService.java new file mode 100644 index 00000000..6d3da55f --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleListUserService.java @@ -0,0 +1,35 @@ +package com.baidubce.examples.userservice; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; +import com.baidubce.services.userservice.model.ListUserServiceResponse; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleListUserService { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + try { + ListUserServiceResponse response = userserviceClient.listUserService(null, null); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleRemoveAuth.java b/src/main/java/com/baidubce/examples/userservice/ExampleRemoveAuth.java new file mode 100644 index 00000000..2156ec8d --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleRemoveAuth.java @@ -0,0 +1,43 @@ +package com.baidubce.examples.userservice; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; +import com.baidubce.services.userservice.model.RemoveAuthRequest; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleRemoveAuth { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + RemoveAuthRequest removeAuthRequest = new RemoveAuthRequest(); + List uidList = new ArrayList(); // 要移除的用户uid列表 + uidList.add("7cc5aff841ff4b648028d80b84e1917e"); // 用户uid + removeAuthRequest.setUidList(uidList); + + try { + userserviceClient.removeAuth("testService.uservice-9fbf1146.beijing.baidubce.com", + removeAuthRequest, null); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleUnbindInstance.java b/src/main/java/com/baidubce/examples/userservice/ExampleUnbindInstance.java new file mode 100644 index 00000000..f9f2ae33 --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleUnbindInstance.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.userservice; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleUnbindInstance { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + try { + userserviceClient.unbindInstance("testService.uservice-9fbf1146.beijing.baidubce.com", + null); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/userservice/ExampleUpdateUserService.java b/src/main/java/com/baidubce/examples/userservice/ExampleUpdateUserService.java new file mode 100644 index 00000000..4bbd951a --- /dev/null +++ b/src/main/java/com/baidubce/examples/userservice/ExampleUpdateUserService.java @@ -0,0 +1,39 @@ +package com.baidubce.examples.userservice; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.userservice.UserserviceClient; +import com.baidubce.services.userservice.model.UpdateUserServiceRequest; + +/** + * @author chenchangquan + * @date 2023/11/27 + */ +public class ExampleUpdateUserService { + + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "blb.bj.baidubce.com"; // 请求的服务region对应的域名 + + BceClientConfiguration config = new BceClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + UserserviceClient userserviceClient = new UserserviceClient(config); // 初始化UserserviceClient + + UpdateUserServiceRequest updateUserServiceRequest = new UpdateUserServiceRequest(); + updateUserServiceRequest.setName("updateName1"); // 修改后的服务名称 + updateUserServiceRequest.setDescription("updateDesc"); // 修改后的描述 + + try { + userserviceClient.updateUserService("testService.uservice-9fbf1146.beijing.baidubce.com", + updateUserServiceRequest, null); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } + + +} diff --git a/src/main/java/com/baidubce/examples/vpc/ExampleCreateVpc.java b/src/main/java/com/baidubce/examples/vpc/ExampleCreateVpc.java new file mode 100644 index 00000000..62fda3e7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpc/ExampleCreateVpc.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.vpc; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.tag.model.Tag; +import com.baidubce.services.vpc.VpcClient; +import com.baidubce.services.vpc.VpcClientConfiguration; +import com.baidubce.services.vpc.model.CreateVpcRequest; +import com.baidubce.services.vpc.model.CreateVpcResponse; +import com.google.common.collect.Lists; + +public class ExampleCreateVpc { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpcClientConfiguration config = new VpcClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpcClient vpcClient = new VpcClient(config); // 初始化VpcClient + + CreateVpcRequest createVpcRequest = new CreateVpcRequest(); + createVpcRequest.setName("vpcTest"); // vpc名称 + createVpcRequest.setCidr("192.168.0.0/16"); // vpc cidr + createVpcRequest.setDescription("desc"); // vpc描述 + createVpcRequest.setEnableIpv6(false); // 是否分配IPv6网段 + + Tag tag = new Tag(); + tag.setTagKey("tagKey"); + tag.setTagValue("tagValue"); + createVpcRequest.setTags(Lists.newArrayList(tag)); // 设置vpc标签 + + try { + CreateVpcResponse response = vpcClient.createVpc(createVpcRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/com/baidubce/examples/vpc/ExampleDeleteVpc.java b/src/main/java/com/baidubce/examples/vpc/ExampleDeleteVpc.java new file mode 100644 index 00000000..66792fc2 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpc/ExampleDeleteVpc.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.vpc; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpc.VpcClient; +import com.baidubce.services.vpc.VpcClientConfiguration; + +public class ExampleDeleteVpc { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpcClientConfiguration config = new VpcClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpcClient vpcClient = new VpcClient(config); // 初始化VpcClient + + try { + vpcClient.deleteVpc("vpc-xysha3j7gce1"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/vpc/ExampleGetVpc.java b/src/main/java/com/baidubce/examples/vpc/ExampleGetVpc.java new file mode 100644 index 00000000..a361f1c4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpc/ExampleGetVpc.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.vpc; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpc.VpcClient; +import com.baidubce.services.vpc.VpcClientConfiguration; +import com.baidubce.services.vpc.model.GetVpcResponse; + +public class ExampleGetVpc { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpcClientConfiguration config = new VpcClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpcClient vpcClient = new VpcClient(config); // 初始化VpcClient + + try { + GetVpcResponse response = vpcClient.getVpc("vpc-xysha3j7gce1"); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/vpc/ExampleGetVpcPrivateIpAddressInfo.java b/src/main/java/com/baidubce/examples/vpc/ExampleGetVpcPrivateIpAddressInfo.java new file mode 100644 index 00000000..73709c1f --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpc/ExampleGetVpcPrivateIpAddressInfo.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.vpc; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpc.VpcClient; +import com.baidubce.services.vpc.VpcClientConfiguration; +import com.baidubce.services.vpc.model.GetVpcPrivateAddressInfoResponse; +import com.baidubce.services.vpc.model.GetVpcPrivateIpAddressInfoRequest; + +public class ExampleGetVpcPrivateIpAddressInfo { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpcClientConfiguration config = new VpcClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpcClient vpcClient = new VpcClient(config); // 初始化VpcClient + + GetVpcPrivateIpAddressInfoRequest getVpcPrivateIpAddressInfoRequest = new GetVpcPrivateIpAddressInfoRequest(); + getVpcPrivateIpAddressInfoRequest.setVpcId("vpc-xysha3j7gce1"); // vpcId + getVpcPrivateIpAddressInfoRequest.setPrivateIpRange("192.168.0.0-192.168.0.80"); // 查询该ip区间内Ip的使用信息 + + try { + GetVpcPrivateAddressInfoResponse response = + vpcClient.getVpcPrivateIpAddressInfo(getVpcPrivateIpAddressInfoRequest); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/vpc/ExampleGetVpcResourceIpInfo.java b/src/main/java/com/baidubce/examples/vpc/ExampleGetVpcResourceIpInfo.java new file mode 100644 index 00000000..9222f5a8 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpc/ExampleGetVpcResourceIpInfo.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.vpc; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpc.VpcClient; +import com.baidubce.services.vpc.VpcClientConfiguration; +import com.baidubce.services.vpc.model.GetVpcResourceIpRequest; +import com.baidubce.services.vpc.model.GetVpcResourceIpResponse; + +public class ExampleGetVpcResourceIpInfo { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpcClientConfiguration config = new VpcClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpcClient vpcClient = new VpcClient(config); // 初始化VpcClient + + GetVpcResourceIpRequest request = new GetVpcResourceIpRequest(); + request.setVpcId("vpc-xysha3j7gce1"); // vpc id + request.setSubnetId("sbn-iz20ee97p4u8"); // subnet id + + try { + GetVpcResourceIpResponse response = vpcClient.getVpcResourceIpInfo(request); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpc/ExampleListVpc.java b/src/main/java/com/baidubce/examples/vpc/ExampleListVpc.java new file mode 100644 index 00000000..4dcf90df --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpc/ExampleListVpc.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.vpc; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpc.VpcClient; +import com.baidubce.services.vpc.VpcClientConfiguration; +import com.baidubce.services.vpc.model.ListVpcResponse; + +public class ExampleListVpc { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpcClientConfiguration config = new VpcClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpcClient vpcClient = new VpcClient(config); // 初始化VpcClient + + try { + ListVpcResponse response = vpcClient.listVpcs(); + System.out.println(response); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/vpc/ExampleOpenVpcRelay.java b/src/main/java/com/baidubce/examples/vpc/ExampleOpenVpcRelay.java new file mode 100644 index 00000000..ca62d6e7 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpc/ExampleOpenVpcRelay.java @@ -0,0 +1,25 @@ +package com.baidubce.examples.vpc; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpc.VpcClient; +import com.baidubce.services.vpc.VpcClientConfiguration; + +public class ExampleOpenVpcRelay { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpcClientConfiguration config = new VpcClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpcClient vpcClient = new VpcClient(config); // 初始化VpcClient + + try { + vpcClient.openVpcRelay("vpc-k88jn6i2acgx"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpc/ExampleShutDownVpcRelay.java b/src/main/java/com/baidubce/examples/vpc/ExampleShutDownVpcRelay.java new file mode 100644 index 00000000..96d96c9b --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpc/ExampleShutDownVpcRelay.java @@ -0,0 +1,25 @@ +package com.baidubce.examples.vpc; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpc.VpcClient; +import com.baidubce.services.vpc.VpcClientConfiguration; + +public class ExampleShutDownVpcRelay { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpcClientConfiguration config = new VpcClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpcClient vpcClient = new VpcClient(config); // 初始化VpcClient + + try { + vpcClient.shutDownVpcRelay("vpc-k88jn6i2acgx"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpc/ExampleUpdateVpc.java b/src/main/java/com/baidubce/examples/vpc/ExampleUpdateVpc.java new file mode 100644 index 00000000..504078bf --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpc/ExampleUpdateVpc.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.examples.vpc; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpc.VpcClient; +import com.baidubce.services.vpc.VpcClientConfiguration; + +public class ExampleUpdateVpc { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpcClientConfiguration config = new VpcClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpcClient vpcClient = new VpcClient(config); // 初始化VpcClient + + try { + vpcClient.modifyInstanceAttributes("vpcName", "vpc-xysha3j7gce1"); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + + } +} + diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleBatchCreateSslVpnUser.java b/src/main/java/com/baidubce/examples/vpn/ExampleBatchCreateSslVpnUser.java new file mode 100644 index 00000000..50b577c4 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleBatchCreateSslVpnUser.java @@ -0,0 +1,50 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.BatchCreateSslVpnUserRequest; +import com.baidubce.services.vpn.model.BatchCreateSslVpnUserResponse; +import com.baidubce.services.vpn.model.SslVpnUser; + +import java.util.Arrays; +import java.util.UUID; + +public class ExampleBatchCreateSslVpnUser { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + BatchCreateSslVpnUserRequest batchCreateSslVpnUserRequest = new BatchCreateSslVpnUserRequest(); + batchCreateSslVpnUserRequest.setVpnId("vpn-b1z6gjrhm1an"); // VPN的ID + + // SSL-VPN用户列表 + SslVpnUser sslVpnUser1 = new SslVpnUser(); + sslVpnUser1.setUserName("user1"); // 用户名,大小写字母、数字以及-_/.特殊字符,必须以字母开头,长度1-65 + sslVpnUser1.setPassword("qwe123Test.1"); // 密码,8~17位字符,英文、数字和符号必须同时存在,符号仅限!@#$%^*(_ + sslVpnUser1.setDescription("desc user1"); // 描述 + + SslVpnUser sslVpnUser2 = new SslVpnUser(); + sslVpnUser2.setUserName("user2"); + sslVpnUser2.setPassword("qwe123Test.2"); + sslVpnUser2.setDescription("desc user2"); + batchCreateSslVpnUserRequest.setSslVpnUsers(Arrays.asList(sslVpnUser1, sslVpnUser2)); + + batchCreateSslVpnUserRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + BatchCreateSslVpnUserResponse batchCreateSslVpnUserResponse + = vpnClient.batchCreateSslVpnUser(batchCreateSslVpnUserRequest); + System.out.println("batchCreateSslVpnUserResponse = " + batchCreateSslVpnUserResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleBindEip.java b/src/main/java/com/baidubce/examples/vpn/ExampleBindEip.java new file mode 100644 index 00000000..a828d360 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleBindEip.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.BindEipRequest; + +import java.util.UUID; + +public class ExampleBindEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + BindEipRequest bindEipRequest = new BindEipRequest(); + bindEipRequest.setVpnId("vpn-bwc4p652n57b"); // vpn的ID + bindEipRequest.setEip("100.89.0.221"); // 需要绑定的eip + bindEipRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.bindEip(bindEipRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleCreateSslVpnServer.java b/src/main/java/com/baidubce/examples/vpn/ExampleCreateSslVpnServer.java new file mode 100644 index 00000000..8dbfd748 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleCreateSslVpnServer.java @@ -0,0 +1,47 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.CreateSslVpnServerRequest; +import com.baidubce.services.vpn.model.CreateSslVpnServerResponse; +import com.google.common.collect.Lists; + +import java.util.UUID; + +public class ExampleCreateSslVpnServer { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + CreateSslVpnServerRequest createSslVpnServerRequest = new CreateSslVpnServerRequest(); + createSslVpnServerRequest.setVpnId("vpn-b1z6gjrhm1an"); // VPN的ID + + // SSL-VPN服务端实例名称,大小写字母、数字以及-_/.特殊字符,必须以字母开头,长度1-65 + createSslVpnServerRequest.setSslVpnServerName("java_sdk_test_ssl_vpn_server"); + + // SSL-VPN服务端接口类型。取值[tap, tun],默认为 tap + createSslVpnServerRequest.setInterfaceType("tap"); + + createSslVpnServerRequest.setLocalSubnets(Lists.newArrayList("192.168.50.0/24")); // 本端网络CIDR列表 + createSslVpnServerRequest.setRemoteSubnet("192.168.10.0/24"); // 客户端网络CIDR + createSslVpnServerRequest.setClientDns("100.88.0.83"); // 客户端的DNS地址 + + createSslVpnServerRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + CreateSslVpnServerResponse createSslVpnServerResponse + = vpnClient.createSslVpnServer(createSslVpnServerRequest); + System.out.println("createSslVpnServerResponse = " + createSslVpnServerResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleCreateVpn.java b/src/main/java/com/baidubce/examples/vpn/ExampleCreateVpn.java new file mode 100644 index 00000000..635cc284 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleCreateVpn.java @@ -0,0 +1,50 @@ +package com.baidubce.examples.vpn; + +import java.util.Arrays; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.tag.model.Tag; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.CreateVpnRequest; +import com.baidubce.services.vpn.model.CreateVpnResponse; + +public class ExampleCreateVpn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + CreateVpnRequest createVpnRequest = new CreateVpnRequest(); + createVpnRequest.setVpcId("vpc-8gc432kidqqb"); // 所属VPC的ID + createVpnRequest.setVpnName("VpnJavaSdkTest"); // VPN的名称,大小写字母、数字以及-_/.特殊字符,必须以字母开头,长度1-65 + createVpnRequest.setSubnetId("sbn-ptb45cw0icpk"); // 所属子网的ID + createVpnRequest.setType("SSL"); // VPN的类型 + createVpnRequest.setMaxConnection(20); // SSL-VPN最大客户端连接数 + Billing billing = new Billing(); + billing.setPaymentTiming("Postpaid"); // 计费信息 + createVpnRequest.setBilling(billing); + createVpnRequest.setDescription("this is a desc"); // 描述信息 + + Tag tag = new Tag(); + tag.setTagKey("tagKey"); + tag.setTagValue("tagValue"); + createVpnRequest.setTags(Arrays.asList(tag)); // 标签信息 + createVpnRequest.setResourceGroupId("RESG-xyfmAVnHGzK"); // 资源组ID + createVpnRequest.setDeleteProtect(true); // 是否开启释放保护 + + try { + CreateVpnResponse vpn = vpnClient.createVpn(createVpnRequest); + System.out.println(vpn); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleCreateVpnConn.java b/src/main/java/com/baidubce/examples/vpn/ExampleCreateVpnConn.java new file mode 100644 index 00000000..4c48d2cc --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleCreateVpnConn.java @@ -0,0 +1,63 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.CreateVpnConnRequest; +import com.baidubce.services.vpn.model.CreateVpnConnResponse; +import com.baidubce.services.vpn.model.IkeConfig; +import com.baidubce.services.vpn.model.IpsecConfig; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ExampleCreateVpnConn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + CreateVpnConnRequest createVpnConnRequest = new CreateVpnConnRequest(); + createVpnConnRequest.setVpnId("vpn-bwc4p652n57b"); // vpn的ID + + // 共享秘钥,8~17位字符,英文、数字和符号必须同时存在,符号仅限!@#$%^*()_ + createVpnConnRequest.setSecretKey("abc123456!"); + + List localSubnets = new ArrayList(); + localSubnets.add("192.168.16.0/20"); + createVpnConnRequest.setLocalSubnets(localSubnets); // 本端网络cidr列表 + + createVpnConnRequest.setRemoteIp("180.76.121.25"); // 对端VPN网关公网IP + + List remoteSubnets = new ArrayList(); + remoteSubnets.add("192.168.50.0/24"); + createVpnConnRequest.setRemoteSubnets(remoteSubnets); // 对端网络cidr列表 + + // VPN隧道名称,大小写字母、数字以及-_/.特殊字符,必须以字母开头,长度1-65 + createVpnConnRequest.setVpnConnName("java_sdk_test_conn"); + + // IKE配置 + IkeConfig ikeConfig = new IkeConfig(); + createVpnConnRequest.setIkeConfig(ikeConfig); + + // IPSec配置 + IpsecConfig ipsecConfig = new IpsecConfig(); + createVpnConnRequest.setIpsecConfig(ipsecConfig); + + createVpnConnRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + CreateVpnConnResponse createVpnConnResponse = vpnClient.createVpnConn(createVpnConnRequest); + System.out.println("createVpnConnResponse = " + createVpnConnResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleDeleteSslVpnServer.java b/src/main/java/com/baidubce/examples/vpn/ExampleDeleteSslVpnServer.java new file mode 100644 index 00000000..804c9ffa --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleDeleteSslVpnServer.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.DeleteSslVpnServerRequest; + +import java.util.UUID; + +public class ExampleDeleteSslVpnServer { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + DeleteSslVpnServerRequest deleteSslVpnServerRequest = new DeleteSslVpnServerRequest(); + deleteSslVpnServerRequest.setVpnId("vpn-b1z6gjrhm1an"); // VPN的ID + deleteSslVpnServerRequest.setSslVpnServerId("sslvpn-2746vp5u7jvf"); // SSL-VPN服务端ID + deleteSslVpnServerRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.deleteSslVpnServer(deleteSslVpnServerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleDeleteSslVpnUser.java b/src/main/java/com/baidubce/examples/vpn/ExampleDeleteSslVpnUser.java new file mode 100644 index 00000000..a4a1f808 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleDeleteSslVpnUser.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.DeleteSslVpnUserRequest; + +import java.util.UUID; + +public class ExampleDeleteSslVpnUser { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + DeleteSslVpnUserRequest deleteSslVpnUserRequest = new DeleteSslVpnUserRequest(); + deleteSslVpnUserRequest.setVpnId("vpn-b1z6gjrhm1an"); // VPN的ID + deleteSslVpnUserRequest.setUserId("vpn-ssl-user-s6uiuv9wdf1j"); // SSL-VPN用户ID + deleteSslVpnUserRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.deleteSslVpnUser(deleteSslVpnUserRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleDeleteVpn.java b/src/main/java/com/baidubce/examples/vpn/ExampleDeleteVpn.java new file mode 100644 index 00000000..37bd6e6c --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleDeleteVpn.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.DeleteVpnRequest; + +public class ExampleDeleteVpn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + DeleteVpnRequest deleteVpnRequest = new DeleteVpnRequest(); + deleteVpnRequest.setVpnId("vpn-ku4cxya6nisq"); // 需要删除的vpnId + + try { + vpnClient.deleteVpn(deleteVpnRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleDeleteVpnConn.java b/src/main/java/com/baidubce/examples/vpn/ExampleDeleteVpnConn.java new file mode 100644 index 00000000..b44c0b1e --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleDeleteVpnConn.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.DeleteVpnConnRequest; + +import java.util.UUID; + +public class ExampleDeleteVpnConn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + DeleteVpnConnRequest deleteVpnConnRequest = new DeleteVpnConnRequest(); + deleteVpnConnRequest.setVpnConnId("vpnconn-c2ugxt6evfkm"); // vpn隧道的ID + deleteVpnConnRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.deleteVpnConn(deleteVpnConnRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleGetSslVpnServer.java b/src/main/java/com/baidubce/examples/vpn/ExampleGetSslVpnServer.java new file mode 100644 index 00000000..ae355edc --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleGetSslVpnServer.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.GetSslVpnServerResponse; + +public class ExampleGetSslVpnServer { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + String vpnId = "vpn-b1z6gjrhm1an"; // VPN的ID + + try { + GetSslVpnServerResponse getSslVpnServerResponse = vpnClient.getSslVpnServer(vpnId); + System.out.println("getSslVpnServerResponse = " + getSslVpnServerResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleGetSslVpnUser.java b/src/main/java/com/baidubce/examples/vpn/ExampleGetSslVpnUser.java new file mode 100644 index 00000000..68ad7246 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleGetSslVpnUser.java @@ -0,0 +1,34 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.ListSslVpnUserRequest; +import com.baidubce.services.vpn.model.ListSslVpnUserResponse; + +public class ExampleGetSslVpnUser { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + ListSslVpnUserRequest listSslVpnUserRequest = new ListSslVpnUserRequest(); + listSslVpnUserRequest.setVpnId("vpn-b1z6gjrhm1an"); // SSL-VPN的ID + listSslVpnUserRequest.setMarker(""); // 批量获取列表的查询起始位置,是一个由系统生成的字符串 + listSslVpnUserRequest.setMaxKeys(10); // 每页包含的最大数量,最大数量通常不超过1000,缺省值为1000 + listSslVpnUserRequest.setUserName("user1"); // SSL-VPN用户名称 + + try { + ListSslVpnUserResponse listSslVpnUserResponse = vpnClient.getSslVpnUser(listSslVpnUserRequest); + System.out.println("listSslVpnUserResponse = " + listSslVpnUserResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleGetVpn.java b/src/main/java/com/baidubce/examples/vpn/ExampleGetVpn.java new file mode 100644 index 00000000..09e93478 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleGetVpn.java @@ -0,0 +1,29 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.GetVpnResponse; + +public class ExampleGetVpn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + String vpnId = "vpn-bwc4p652n57b"; // vpn的ID + + try { + GetVpnResponse getVpnResponse = vpnClient.getVpn(vpnId); + System.out.println("getVpnResponse = " + getVpnResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleListVpn.java b/src/main/java/com/baidubce/examples/vpn/ExampleListVpn.java new file mode 100644 index 00000000..9653bf1d --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleListVpn.java @@ -0,0 +1,37 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.ListVpnRequest; +import com.baidubce.services.vpn.model.ListVpnResponse; + +public class ExampleListVpn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + ListVpnRequest listVpnRequest = new ListVpnRequest(); + listVpnRequest.setVpcId("vpc-ut211bnd95cg"); // VPN所属VPC ID + listVpnRequest.setMarker(""); // 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + listVpnRequest.setMaxKeys(10); // 每页包含的最大数量,最大数量通常不超过1000,缺省值为1000 + listVpnRequest.setEip("100.89.0.221"); // VPN绑定的eip地址 + + // VPN网关类型,值“IPSec”返回IPsec-VPN网关,值“SSL”返回SSL-VPN网关,默认为空,返回所有类型的VPN网关 + listVpnRequest.setType("IPSec"); + + try { + ListVpnResponse listVpnResponse = vpnClient.listVpns(listVpnRequest); + System.out.println("listVpnResponse = " + listVpnResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleListVpnConn.java b/src/main/java/com/baidubce/examples/vpn/ExampleListVpnConn.java new file mode 100644 index 00000000..21dc0a35 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleListVpnConn.java @@ -0,0 +1,31 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.ListVpnConnRequest; +import com.baidubce.services.vpn.model.ListVpnConnResponse; + +public class ExampleListVpnConn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + ListVpnConnRequest listVpnConnRequest = new ListVpnConnRequest(); + listVpnConnRequest.setVpnId("vpn-bwc4p652n57b"); // vpn的ID + + try { + ListVpnConnResponse listVpnConnResponse = vpnClient.listVpnConns(listVpnConnRequest); + System.out.println("listVpnConnResponse = " + listVpnConnResponse); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleRenewVpn.java b/src/main/java/com/baidubce/examples/vpn/ExampleRenewVpn.java new file mode 100644 index 00000000..41a8257e --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleRenewVpn.java @@ -0,0 +1,43 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.RenewVpnRequest; + +import java.util.UUID; + +public class ExampleRenewVpn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + RenewVpnRequest renewVpnRequest = new RenewVpnRequest(); + renewVpnRequest.setVpnId("vpn-biqctbbdzrz2"); + + // 订单信息 + Billing billing = new Billing(); + billing.setPaymentTiming("Prepaid"); // 付款时间,预支付(Prepaid)和后支付(Postpaid) + Billing.Reservation reservation = new Billing.Reservation(); // 保留信息,支付方式为后支付时不需要设置,预支付时必须设置 + reservation.setReservationLength(1); // 时长,[1,2,3,4,5,6,7,8,9,12,24,36] + reservation.setReservationTimeUnit("month"); // 时间单位,month,当前仅支持按月 + billing.setReservation(reservation); + renewVpnRequest.setBilling(billing); + + renewVpnRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.renewVpn(renewVpnRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleSwitchVpnDeleteProtect.java b/src/main/java/com/baidubce/examples/vpn/ExampleSwitchVpnDeleteProtect.java new file mode 100644 index 00000000..18b55d9c --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleSwitchVpnDeleteProtect.java @@ -0,0 +1,33 @@ +package com.baidubce.examples.vpn; + +import java.util.UUID; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.SwitchVpnDeleteProtectRequest; + +public class ExampleSwitchVpnDeleteProtect { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + SwitchVpnDeleteProtectRequest request = new SwitchVpnDeleteProtectRequest(); + request.setVpnId("vpn-9c875b4065b5"); // vpn的ID + request.setDeleteProtect(true); // 开启释放保护 + request.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.switchDeleteProtect(request); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleUnBindEip.java b/src/main/java/com/baidubce/examples/vpn/ExampleUnBindEip.java new file mode 100644 index 00000000..6b333589 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleUnBindEip.java @@ -0,0 +1,32 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.UnBindEipRequest; + +import java.util.UUID; + +public class ExampleUnBindEip { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + UnBindEipRequest unBindEipRequest = new UnBindEipRequest(); + unBindEipRequest.setVpnId("vpn-bwc4p652n57b"); // vpn的ID + unBindEipRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.unBindEip(unBindEipRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleUpdateSslVpnServer.java b/src/main/java/com/baidubce/examples/vpn/ExampleUpdateSslVpnServer.java new file mode 100644 index 00000000..b33827af --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleUpdateSslVpnServer.java @@ -0,0 +1,41 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.UpdateSslVpnServerRequest; +import com.google.common.collect.Lists; + +import java.util.UUID; + +public class ExampleUpdateSslVpnServer { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + UpdateSslVpnServerRequest updateSslVpnServerRequest = new UpdateSslVpnServerRequest(); + updateSslVpnServerRequest.setVpnId("vpn-b1z6gjrhm1an"); // VPN的ID + updateSslVpnServerRequest.setSslVpnServerId("sslvpn-2746vp5u7jvf"); // SSL-VPN服务端ID + + // SSL-VPN服务端实例名称,大小写字母、数字以及-_/.特殊字符,必须以字母开头,长度1-65 + updateSslVpnServerRequest.setSslVpnServerName("testServer-update"); + + updateSslVpnServerRequest.setLocalSubnets(Lists.newArrayList("192.168.40.0/24")); + updateSslVpnServerRequest.setRemoteSubnet("192.168.100.0/24"); + updateSslVpnServerRequest.setClientDns("100.88.0.83"); // 客户端的DNS地址 + updateSslVpnServerRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.updateSslVpnServer(updateSslVpnServerRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleUpdateSslVpnUser.java b/src/main/java/com/baidubce/examples/vpn/ExampleUpdateSslVpnUser.java new file mode 100644 index 00000000..79de19cd --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleUpdateSslVpnUser.java @@ -0,0 +1,38 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.UpdateSslVpnUserRequest; + +import java.util.UUID; + +public class ExampleUpdateSslVpnUser { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + UpdateSslVpnUserRequest updateSslVpnUserRequest = new UpdateSslVpnUserRequest(); + updateSslVpnUserRequest.setVpnId("vpn-b1z6gjrhm1an"); // VPN的ID + updateSslVpnUserRequest.setUserId("vpn-ssl-user-s6uiuv9wdf1j"); // SSL-VPN用户ID + + // 密码,8~17位字符,英文、数字和符号必须同时存在,符号仅限!@#$%^*(_ + updateSslVpnUserRequest.setPassword("1234567abc!"); + + updateSslVpnUserRequest.setDescription("description-update"); // 描述 + updateSslVpnUserRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.updateSslVpnUser(updateSslVpnUserRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleUpdateVpn.java b/src/main/java/com/baidubce/examples/vpn/ExampleUpdateVpn.java new file mode 100644 index 00000000..5ea1fa5f --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleUpdateVpn.java @@ -0,0 +1,37 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.UpdateVpnRequest; + +import java.util.UUID; + +public class ExampleUpdateVpn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + UpdateVpnRequest updateVpnRequest = new UpdateVpnRequest(); + updateVpnRequest.setVpnId("vpn-bwc4p652n57b"); // vpn的ID + + // VPN名称,不能取值"default",长度不超过65个字符,可由数字,字符,下划线组成 + updateVpnRequest.setVpnName("java_sdk_test_update_vpn"); + + updateVpnRequest.setDescription("test update vpn description."); // vpn的描述,不超过200字符 + updateVpnRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.updateVpn(updateVpnRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/examples/vpn/ExampleUpdateVpnConn.java b/src/main/java/com/baidubce/examples/vpn/ExampleUpdateVpnConn.java new file mode 100644 index 00000000..7d0c6210 --- /dev/null +++ b/src/main/java/com/baidubce/examples/vpn/ExampleUpdateVpnConn.java @@ -0,0 +1,64 @@ +package com.baidubce.examples.vpn; + +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.vpn.VpnClient; +import com.baidubce.services.vpn.VpnClientConfiguration; +import com.baidubce.services.vpn.model.IkeConfig; +import com.baidubce.services.vpn.model.IpsecConfig; +import com.baidubce.services.vpn.model.UpdateVpnConnRequest; +import com.google.common.collect.Lists; + +import java.util.List; +import java.util.UUID; + +public class ExampleUpdateVpnConn { + public static void main(String[] args) { + String ak = "Your Ak"; + String sk = "Your Sk"; + String endpoint = "bcc.bj.baidubce.com"; // 请求的服务region对应的域名 + + VpnClientConfiguration config = new VpnClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ak, sk)); + config.setEndpoint(endpoint); + VpnClient vpnClient = new VpnClient(config); // 初始化Client + + UpdateVpnConnRequest updateVpnConnRequest = new UpdateVpnConnRequest(); + updateVpnConnRequest.setVpnConnId("vpnconn-c2ugxt6evfkm"); // vpn隧道的ID + updateVpnConnRequest.setVpnId("vpn-bwc4p652n57b"); // vpn隧道所属vpn的ID + + // 共享秘钥,8~17位字符,英文、数字和符号必须同时存在,符号仅限!@#$%^*()_ + updateVpnConnRequest.setSecretKey("abc123456!"); + + // 本端网络cidr列表 + List localSubnets = Lists.newArrayList("192.168.0.0/20"); + updateVpnConnRequest.setLocalSubnets(localSubnets); + + updateVpnConnRequest.setRemoteIp("180.76.121.30"); // 对端VPN网关公网IP + + // 对端网络cidr列表 + List remoteSubnets = Lists.newArrayList("192.168.100.0/24"); + updateVpnConnRequest.setRemoteSubnets(remoteSubnets); + + // VPN隧道名称,大小写字母、数字以及-_/.特殊字符,必须以字母开头,长度1-65 + updateVpnConnRequest.setVpnConnName("test_vpn_conn_update"); + + updateVpnConnRequest.setDescription("update vpn conn description."); // 描述 + + // IKE配置 + IkeConfig ikeConfig = new IkeConfig(); + updateVpnConnRequest.setIkeConfig(ikeConfig); + + // IPSec配置 + IpsecConfig ipsecConfig = new IpsecConfig(); + updateVpnConnRequest.setIpsecConfig(ipsecConfig); + + updateVpnConnRequest.setClientToken(UUID.randomUUID().toString()); // 幂等性Token + + try { + vpnClient.updateVpnConn(updateVpnConnRequest); + } catch (BceClientException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/com/baidubce/http/BceHttpClient.java b/src/main/java/com/baidubce/http/BceHttpClient.java old mode 100644 new mode 100755 index fe304962..84bf2830 --- a/src/main/java/com/baidubce/http/BceHttpClient.java +++ b/src/main/java/com/baidubce/http/BceHttpClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Baidu, Inc. + * Copyright 2014-2019 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -16,13 +16,13 @@ import com.baidubce.BceClientConfiguration; import com.baidubce.BceClientException; -import com.baidubce.BceServiceException; import com.baidubce.Protocol; import com.baidubce.auth.BceCredentials; import com.baidubce.auth.Signer; import com.baidubce.http.handler.HttpResponseHandler; import com.baidubce.internal.InternalRequest; import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bos.model.GetObjectResponse; import com.baidubce.util.HttpUtils; import org.apache.http.HttpEntity; @@ -39,6 +39,7 @@ import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; +import org.apache.http.client.methods.HttpPatch; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpRequestBase; @@ -81,6 +82,7 @@ import java.io.InputStream; import java.security.NoSuchAlgorithmException; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @ThreadSafe @@ -102,7 +104,12 @@ public class BceHttpClient { * Internal client for sending HTTP requests */ protected CloseableHttpClient httpClient; - + + /** + * Internal async client for sending HTTP requests + */ + protected CloseableHttpAsyncClient httpAsyncClient; + /** * Client configuration options, such as proxy settings, max retries, etc. */ @@ -111,6 +118,7 @@ public class BceHttpClient { protected Signer signer; private HttpClientConnectionManager connectionManager; + private NHttpClientConnectionManager nioConnectionManager; private RequestConfig.Builder requestConfigBuilder; private CredentialsProvider credentialsProvider; @@ -118,13 +126,20 @@ public class BceHttpClient { private boolean isHttpAsyncPutEnabled = false; + // Maintain a single instance with endpoint + private static ConcurrentHashMap asyncClientMap = + new ConcurrentHashMap(); + + private static ConcurrentHashMap managerMap = + new ConcurrentHashMap(); + /** * Constructs a new BCE client using the specified client configuration options (ex: max retry attempts, proxy * settings, etc), and request metric collector. * * @param config Configuration options specifying how this client will communicate with BCE (ex: proxy settings, * retry count, etc.). - * + * @param signer signer used to sign http requests * @throws java.lang.IllegalArgumentException If config or signer is null. */ public BceHttpClient(BceClientConfiguration config, Signer signer) { @@ -139,6 +154,7 @@ public BceHttpClient(BceClientConfiguration config, Signer signer) { this.requestConfigBuilder = RequestConfig.custom(); this.requestConfigBuilder.setConnectTimeout(config.getConnectionTimeoutInMillis()); this.requestConfigBuilder.setStaleConnectionCheckEnabled(true); + this.requestConfigBuilder.setRedirectsEnabled(config.isRedirectsEnabled()); if (config.getLocalAddress() != null) { this.requestConfigBuilder.setLocalAddress(config.getLocalAddress()); } @@ -164,28 +180,42 @@ public BceHttpClient(BceClientConfiguration config, Signer signer) { /** * Constructs a new BCE Http Client with httpAsyncPutEnabled. - * @param config Configuration options specifying how this client will communicate with BCE (ex: proxy settings, - * retry count, etc.). + * + * @param config Configuration options specifying how this client will communicate with BCE (ex: proxy settings, + * retry count, etc.). + * @param signer signer used to sign http requests * @param isHttpAsyncPutEnabled whether use Async for PUT method. */ public BceHttpClient(BceClientConfiguration config, Signer signer, boolean isHttpAsyncPutEnabled) { this(config, signer); - this.isHttpAsyncPutEnabled = isHttpAsyncPutEnabled; + if (isHttpAsyncPutEnabled) { + try { + this.nioConnectionManager = this.createNHttpClientConnectionManager(); + this.httpAsyncClient = this.createHttpAsyncClient(this.nioConnectionManager); + this.httpAsyncClient.start(); + this.isHttpAsyncPutEnabled = true; + } catch (IOReactorException e) { + this.isHttpAsyncPutEnabled = false; + } + } else { + this.isHttpAsyncPutEnabled = false; + } } /** * Executes the request and returns the result. * + * @param The type of response * @param request The BCE request to send to the remote server * @param responseClass A response handler to accept a successful response from the remote server * @param responseHandlers A response handler to accept an unsuccessful response from the remote server - * + * @return The response from the remote server * @throws com.baidubce.BceClientException If any errors are encountered on the client while making the - * request or handling the response. + * request or handling the response. * @throws com.baidubce.BceServiceException If any errors occurred in BCE while processing the request. */ public T execute(InternalRequest request, Class responseClass, - HttpResponseHandler[] responseHandlers) { + HttpResponseHandler[] responseHandlers) { // Apply whatever request options we know how to handle, such as user-agent. request.addHeader(Headers.USER_AGENT, this.config.getUserAgent()); BceCredentials credentials = config.getCredentials(); @@ -193,16 +223,16 @@ public T execute(InternalRequest request, Class< credentials = request.getCredentials(); } long delayForNextRetryInMillis = 0; - for (int attempt = 1; ; ++attempt) { + boolean isBosHead404 = false; + for (int attempt = 1; ; ++attempt) { HttpRequestBase httpRequest = null; CloseableHttpResponse httpResponse = null; - CloseableHttpAsyncClient httpAsyncClient = null; try { // Sign the request if credentials were provided if (credentials != null) { this.signer.sign(request, credentials); } - + requestLogger.debug("Sending Request: {}", request); httpRequest = this.createHttpRequest(request); @@ -210,19 +240,18 @@ public T execute(InternalRequest request, Class< HttpContext httpContext = this.createHttpContext(request); if (this.isHttpAsyncPutEnabled && httpRequest.getMethod().equals("PUT")) { - httpAsyncClient = this.createHttpAsyncClient(this.createNHttpClientConnectionManager()); - httpAsyncClient.start(); Future future = httpAsyncClient.execute(HttpAsyncMethods.create(httpRequest), - new BasicAsyncResponseConsumer(), - httpContext, null); + new BasicAsyncResponseConsumer(), + httpContext, null); httpResponse = new BceCloseableHttpResponse(future.get()); } else { httpResponse = this.httpClient.execute(httpRequest, httpContext); } - HttpUtils.printRequest(httpRequest); + HttpUtils.printRequest(httpRequest); BceHttpResponse bceHttpResponse = new BceHttpResponse(httpResponse); T response = responseClass.newInstance(); + isBosHead404 = HttpMethodName.HEAD.equals(request.getHttpMethod()) && response instanceof GetObjectResponse && bceHttpResponse.getStatusCode() == 404; for (HttpResponseHandler handler : responseHandlers) { if (handler.handle(bceHttpResponse, response)) { break; @@ -232,7 +261,7 @@ public T execute(InternalRequest request, Class< // everything is ok return response; } catch (Exception e) { - if (logger.isInfoEnabled()) { + if (logger.isInfoEnabled() && !isBosHead404) { logger.info("Unable to execute HTTP request", e); } @@ -276,14 +305,6 @@ public T execute(InternalRequest request, Class< } } } - } finally { - try { - if (httpAsyncClient != null) { - httpAsyncClient.close(); - } - } catch (IOException e) { - logger.debug("Fail to close HttpAsyncClient", e); - } } } } @@ -295,20 +316,47 @@ public T execute(InternalRequest request, Class< */ public void shutdown() { IdleConnectionReaper.removeConnectionManager(this.connectionManager); + try { + this.httpClient.close(); + } catch (IOException e) { + logger.debug("Fail to close httpClient", e); + } this.connectionManager.shutdown(); } + /** + * The difference between shutdown() is that releasing all resources including nio and idle. + */ + public void shutdownClean() { + shutdown(); + IdleConnectionReaper.shutdown(); + if (this.httpAsyncClient != null) { + try { + this.httpAsyncClient.close(); + } catch (IOException e) { + logger.debug("Fail to close httpAsyncClient", e); + } + } + if (this.nioConnectionManager != null) { + try { + this.nioConnectionManager.shutdown(); + } catch (IOException e) { + logger.debug("Fail to shutdown nioConnectionManager", e); + } + } + } + /** * Get delay time before next retry. * - * @param method The current HTTP method being executed. - * @param exception The client/service exception from the failed request. - * @param attempt The number of times the current request has been attempted. + * @param method The current HTTP method being executed. + * @param exception The client/service exception from the failed request. + * @param attempt The number of times the current request has been attempted. * @param retryPolicy The retryPolicy being used. * @return The deley time before next retry. */ protected long getDelayBeforeNextRetryInMillis(HttpRequestBase method, BceClientException exception, int attempt, - RetryPolicy retryPolicy) { + RetryPolicy retryPolicy) { int retries = attempt - 1; int maxErrorRetry = retryPolicy.getMaxErrorRetry(); @@ -361,15 +409,21 @@ private HttpClientConnectionManager createHttpClientConnectionManager() { * Create connection manager for asynchronous http client. * * @return Connection manager for asynchronous http client. - * @throws IOReactorException + * @throws IOReactorException in case if a non-recoverable I/O error. */ protected NHttpClientConnectionManager createNHttpClientConnectionManager() throws IOReactorException { + if (managerMap.containsKey(config.getEndpoint())) { + return managerMap.get(config.getEndpoint()); + } ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(IOReactorConfig.custom() + .setSoReuseAddress(true) + .setIoThreadCount(this.config.getIoThreadCount()) .setSoTimeout(this.config.getSocketTimeoutInMillis()).setTcpNoDelay(true).build()); PoolingNHttpClientConnectionManager connectionManager = new PoolingNHttpClientConnectionManager(ioReactor); connectionManager.setDefaultMaxPerRoute(this.config.getMaxConnections()); connectionManager.setMaxTotal(this.config.getMaxConnections()); + managerMap.putIfAbsent(config.getEndpoint(), connectionManager); return connectionManager; } @@ -398,7 +452,10 @@ private CloseableHttpClient createHttpClient(HttpClientConnectionManager connect * @param connectionManager Asynchronous http client connection manager. * @return Asynchronous http client based on connection manager. */ - protected CloseableHttpAsyncClient createHttpAsyncClient (NHttpClientConnectionManager connectionManager) { + protected CloseableHttpAsyncClient createHttpAsyncClient(NHttpClientConnectionManager connectionManager) { + if (asyncClientMap.containsKey(config.getEndpoint())) { + return asyncClientMap.get(config.getEndpoint()); + } HttpAsyncClientBuilder builder = HttpAsyncClients.custom().setConnectionManager(connectionManager); int socketBufferSizeInBytes = this.config.getSocketBufferSizeInBytes(); @@ -406,7 +463,9 @@ protected CloseableHttpAsyncClient createHttpAsyncClient (NHttpClientConnectionM builder.setDefaultConnectionConfig( ConnectionConfig.custom().setBufferSize(socketBufferSizeInBytes).build()); } - return builder.build(); + CloseableHttpAsyncClient client = builder.build(); + asyncClientMap.putIfAbsent(config.getEndpoint(), client); + return client; } /** @@ -448,12 +507,17 @@ protected HttpRequestBase createHttpRequest(InternalRequest request) { httpRequest = new HttpDelete(uri); } else if (request.getHttpMethod() == HttpMethodName.HEAD) { httpRequest = new HttpHead(uri); + } else if (request.getHttpMethod() == HttpMethodName.PATCH) { + HttpPatch patchMethod = new HttpPatch(uri); + httpRequest = patchMethod; + if (request.getContent() != null) { + patchMethod.setEntity(new InputStreamEntity(request.getContent(), contentLength)); + } } else { throw new BceClientException("Unknown HTTP method name: " + request.getHttpMethod()); } httpRequest.addHeader(Headers.HOST, HttpUtils.generateHostHeader(request.getUri())); - // Copy over any other headers already in our request for (Entry entry : request.getHeaders().entrySet()) { /* @@ -480,8 +544,15 @@ protected HttpRequestBase createHttpRequest(InternalRequest request) { */ protected HttpClientContext createHttpContext(InternalRequest request) { HttpClientContext context = HttpClientContext.create(); - context.setRequestConfig(this.requestConfigBuilder.setExpectContinueEnabled(request.isExpectContinueEnabled()) - .build()); + this.requestConfigBuilder.setExpectContinueEnabled(request.isExpectContinueEnabled()) + .setSocketTimeout(this.config.getSocketTimeoutInMillis()); + if (request.isRedirectsEnabled() != null) { + // redirect set by user + this.requestConfigBuilder + .setMaxRedirects(request.getMaxRedirects()) + .setRedirectsEnabled(request.isRedirectsEnabled().booleanValue()); + } + context.setRequestConfig(this.requestConfigBuilder.build()); if (this.credentialsProvider != null) { context.setCredentialsProvider(this.credentialsProvider); } diff --git a/src/main/java/com/baidubce/http/Headers.java b/src/main/java/com/baidubce/http/Headers.java index 43ff887a..cd48d650 100644 --- a/src/main/java/com/baidubce/http/Headers.java +++ b/src/main/java/com/baidubce/http/Headers.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Baidu, Inc. + * Copyright 2014-2019 Baidu, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -64,6 +64,10 @@ public interface Headers { public static final String BCE_ACL = "x-bce-acl"; + public static final String BCE_ACL_GRANT_READ = "x-bce-grant-read"; + + public static final String BCE_ACL_GRANT_FULL_CONTROL = "x-bce-grant-full-control"; + public static final String BCE_CONTENT_SHA256 = "x-bce-content-sha256"; public static final String BCE_COPY_METADATA_DIRECTIVE = "x-bce-metadata-directive"; @@ -80,18 +84,26 @@ public interface Headers { public static final String BCE_USER_METADATA_PREFIX = "x-bce-meta-"; + public static final String BCE_CONTENT_CRC32 = "x-bce-content-crc32"; + /* * BOS HTTP Headers */ public static final String BCE_COPY_SOURCE = "x-bce-copy-source"; + public static final String BCE_COPY_SOURCE_RANGE = "x-bce-copy-source-range"; + public static final String BCE_COPY_SOURCE_IF_MODIFIED_SINCE = "x-bce-copy-source-if-modified-since"; public static final String BCE_COPY_SOURCE_IF_NONE_MATCH = "x-bce-copy-source-if-none-match"; public static final String BCE_COPY_SOURCE_IF_UNMODIFIED_SINCE = "x-bce-copy-source-if-unmodified-since"; + public static final String BCE_FETCH_SOURCE = "x-bce-fetch-source"; + + public static final String BCE_FETCH_MODE = "x-bce-fetch-mode"; + public static final String BCE_DEBUG_ID = "x-bce-debug-id"; public static final String BCE_NEXT_APPEND_OFFSET = "x-bce-next-append-offset"; @@ -100,4 +112,50 @@ public interface Headers { public static final String BCE_STORAGE_CLASS = "x-bce-storage-class"; + public static final String BCE_RESTORE_TIER = "x-bce-restore-tier"; + + public static final String BCE_RESTORE_DAYS = "x-bce-restore-days"; + + public static final String BCE_SYMLINK_TARGET = "x-bce-symlink-target"; + + public static final String BCE_FORBID_OVERWRITE = "x-bce-forbid-overwrite"; + + public static final String BCE_RESTORE = "x-bce-restore"; + + public static final String BOS_TRAFFIC_LIMIT = "x-bce-traffic-limit"; + + public static final String BOS_PROCESS = "x-bce-process"; + + public static final String BCE_TAG_LIST = "x-bce-tag-list"; + + public static final String BCE_REFERER = "referer"; + + public static final String BCE_FETCH_USER_AGENT = "x-bce-fetch-user-agent"; + + public static final String BCE_FETCH_CALLBACK_ADDRESS = "x-bce-callback-address"; + + public static final String BCE_BUCKET_TYPE = "x-bce-bucket-type"; + + public static final String BCE_DELETE_RECURSIVE = "x-bce-delete-recursive"; + + public static final String BCE_DELETE_TOKEN = "x-bce-delete-token"; + + public static final String BCE_CONTENT_CRC32C = "x-bce-content-crc32c"; + + public static final String BCE_CONTENT_CRC32C_FLAG = "x-bce-content-crc32c-flag"; + + public static final String BCE_CONSISTENCY_VIEW = "x-bce-consistency-view"; + + public static final String BCE_LIST_WITH_EXT_META = "x-bce-list-with-ext-meta"; + + public static final String BCE_VERSIONING = "x-bce-versioning"; + + public static final String BCE_VERSION_ID = "x-bce-version-id"; + + /* + * CFC HTTP Headers + */ + + public static final String BCE_LOG_RESULT = "X-Bce-Log-Result"; + } diff --git a/src/main/java/com/baidubce/http/HttpMethodName.java b/src/main/java/com/baidubce/http/HttpMethodName.java index f71fb398..1fd3639b 100644 --- a/src/main/java/com/baidubce/http/HttpMethodName.java +++ b/src/main/java/com/baidubce/http/HttpMethodName.java @@ -16,5 +16,5 @@ * The name of http method. */ public enum HttpMethodName { - GET, POST, PUT, DELETE, HEAD; + GET, POST, PUT, DELETE, HEAD, TRACE, PATCH, CONNECT, OPTIONS, ANY; } diff --git a/src/main/java/com/baidubce/http/IdleConnectionReaper.java b/src/main/java/com/baidubce/http/IdleConnectionReaper.java old mode 100644 new mode 100755 index e1c12234..d1533411 --- a/src/main/java/com/baidubce/http/IdleConnectionReaper.java +++ b/src/main/java/com/baidubce/http/IdleConnectionReaper.java @@ -23,16 +23,13 @@ /** * Daemon thread to periodically check connection pools for idle connections. - * *

* Connections sitting around idle in the HTTP connection pool for too long will eventually be terminated by the BCE end * of the connection, and will go into CLOSE_WAIT. If this happens, sockets will sit around in CLOSE_WAIT, still using * resources on the client side to manage that socket. Many sockets stuck in CLOSE_WAIT can prevent the OS from creating * new connections. - * *

* This class closes idle connections before they can move into the CLOSE_WAIT state. - * *

* This thread is important because by default, we disable Apache HttpClient's stale connection checking, so without * this thread running in the background, cleaning up old/inactive HTTP connections, we'd see more IO exceptions when @@ -77,6 +74,7 @@ private IdleConnectionReaper() { /** * Registers the given connection manager with this reaper; * + * @param connectionManager the connection manager to be registered. * @return true if the connection manager has been successfully registered; false otherwise. */ public static synchronized boolean registerConnectionManager(HttpClientConnectionManager connectionManager) { @@ -90,6 +88,7 @@ public static synchronized boolean registerConnectionManager(HttpClientConnectio * Removes the given connection manager from this reaper, and shutting down the reaper if there is zero connection * manager left. * + * @param connectionManager the connection manager to be registered. * @return true if the connection manager has been successfully removed; false otherwise. */ public static synchronized boolean removeConnectionManager(HttpClientConnectionManager connectionManager) { @@ -132,7 +131,6 @@ public void run() { /** * Shuts down the thread, allowing the class and instance to be collected. - * *

* Since this is a daemon thread, its running will not prevent JVM shutdown. It will, however, prevent this class * from being unloaded or garbage collected, in the context of a long-running application, until it is interrupted. diff --git a/src/main/java/com/baidubce/http/handler/BceMetadataResponseHandler.java b/src/main/java/com/baidubce/http/handler/BceMetadataResponseHandler.java index fca8b38a..03af27bb 100644 --- a/src/main/java/com/baidubce/http/handler/BceMetadataResponseHandler.java +++ b/src/main/java/com/baidubce/http/handler/BceMetadataResponseHandler.java @@ -36,6 +36,8 @@ public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response metadata.setContentType(httpResponse.getHeader(Headers.CONTENT_TYPE)); metadata.setDate(httpResponse.getHeaderAsRfc822Date(Headers.DATE)); metadata.setTransferEncoding(httpResponse.getHeader(Headers.TRANSFER_ENCODING)); + metadata.setSymlinkTarget(httpResponse.getHeader(Headers.BCE_SYMLINK_TARGET)); + metadata.setBucketType(httpResponse.getHeader(Headers.BCE_BUCKET_TYPE)); String eTag = httpResponse.getHeader(Headers.ETAG); if (eTag != null) { metadata.setETag(CharMatcher.is('"').trimFrom(eTag)); diff --git a/src/main/java/com/baidubce/internal/BaseRequest.java b/src/main/java/com/baidubce/internal/BaseRequest.java new file mode 100644 index 00000000..9de87bd0 --- /dev/null +++ b/src/main/java/com/baidubce/internal/BaseRequest.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2020 Baidu. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.internal; + +import java.net.URI; +import java.util.Map; + +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.google.common.collect.Maps; + +/** + * Represents a base request being sent to a BCE Service, including the + * parameters being sent as part of the request, the endpoint to which the + * request should be sent, etc. + * + * @author chenjiayi05 + * @date 2020/04/28 + */ +public class BaseRequest { + + /** + * The default protocol to construct URI + */ + private static final String DEFAULT_PROTOCOL_PREFIX = "http://"; + + /** + * The HTTP method to use when sending this request. + */ + private HttpMethodName httpMethod; + + /** + * The path to which this request should be sent + */ + private String path; + + /** + * Map of the parameters being sent as part of this request. + */ + private Map parameters = Maps.newHashMap(); + + /** + * Map of the headers included in this request + */ + private Map headers = Maps.newHashMap(); + + public void addHeader(String name, String value) { + this.headers.put(name, value); + } + + public Map getHeaders() { + return this.headers; + } + + public void addParameter(String name, String value) { + this.parameters.put(name, value); + } + + public Map getParameters() { + return this.parameters; + } + + public HttpMethodName getHttpMethod() { + return this.httpMethod; + } + + public void setHttpMethod(HttpMethodName httpMethod) { + this.httpMethod = httpMethod; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public void setHeaders(Map headers) { + this.headers.clear(); + this.headers.putAll(headers); + } + + public void setParameters(Map parameters) { + this.parameters.clear(); + this.parameters.putAll(parameters); + } + + public BaseRequest(HttpMethodName httpMethod, String path, Map parameters, + Map headers) { + this.httpMethod = httpMethod; + this.path = path; + this.parameters = parameters; + this.headers = headers; + } + + /** + * transfer from base request to internal request + * + * @param request base request + * @return internal request + */ + public static InternalRequest toInternalRequest(BaseRequest request) { + Map headers = request.getHeaders(); + String host; + + // deal with the default header "Host" + if (headers.containsKey(Headers.HOST)) { + host = headers.get(Headers.HOST); + } else { + host = headers.get(Headers.HOST.toLowerCase()); + headers.remove(Headers.HOST.toLowerCase()); + } + + URI uri = URI.create(DEFAULT_PROTOCOL_PREFIX + host + request.getPath()); + InternalRequest res = new InternalRequest(request.getHttpMethod(), uri); + res.setParameters(request.getParameters()); + res.setHeaders(headers); + return res; + } +} diff --git a/src/main/java/com/baidubce/internal/InternalRequest.java b/src/main/java/com/baidubce/internal/InternalRequest.java index 17ecaab3..07883a9d 100644 --- a/src/main/java/com/baidubce/internal/InternalRequest.java +++ b/src/main/java/com/baidubce/internal/InternalRequest.java @@ -62,6 +62,20 @@ public class InternalRequest { private boolean expectContinueEnabled; + /** + * determines whether redirects should be handled automatically + * + * @return + */ + private Boolean redirectsEnabled = null; + + /** + * determines the redirects times. + * + * @return + */ + private int maxRedirects = 1; + public InternalRequest(HttpMethodName httpMethod, URI uri) { this.httpMethod = httpMethod; this.uri = uri; @@ -133,6 +147,43 @@ public void setExpectContinueEnabled(boolean expectContinueEnabled) { this.expectContinueEnabled = expectContinueEnabled; } + /** + * Gets the flag of redirection times + * + * @return + */ + public int getMaxRedirects() { + return this.maxRedirects; + } + + /** + * Sets the flag of redirection times + * + * @param maxRedirects + */ + public void setMaxRedirects(int maxRedirects) { + this.maxRedirects = maxRedirects; + } + + /** + * Gets the flag of http redirection + * + * @return + */ + public Boolean isRedirectsEnabled() { + return redirectsEnabled; + } + + /** + * Sets the flag of http redirection + * + * @param redirectsEnabled + */ + public void setRedirectsEnabled(boolean redirectsEnabled) { + this.redirectsEnabled = redirectsEnabled; + } + + @Override public String toString() { return "InternalRequest [httpMethod=" + this.httpMethod + ", uri=" + this.uri + ", " diff --git a/src/main/java/com/baidubce/internal/RestartableFileInputStream.java b/src/main/java/com/baidubce/internal/RestartableFileInputStream.java index e2b6c848..1ffe5137 100644 --- a/src/main/java/com/baidubce/internal/RestartableFileInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableFileInputStream.java @@ -20,6 +20,7 @@ import java.io.IOException; import com.baidubce.BceClientException; +import com.baidubce.services.bos.model.BosProgressCallback; /** * Restartable File InputStream extends Restartable InputStream. @@ -36,11 +37,17 @@ public RestartableFileInputStream(File file) throws FileNotFoundException { this.input = new FileInputStream(file); } + public RestartableFileInputStream(File file, BosProgressCallback progressCallback) throws FileNotFoundException { + this(file); + super.setProgressCallback(progressCallback); + } + @Override public void restart() { try { this.input.close(); this.input = new FileInputStream(this.file); + super.restartProgressCallback(); } catch (IOException e) { throw new BceClientException("Fail to restart.", e); } @@ -48,12 +55,23 @@ public void restart() { @Override public int read(byte[] b, int off, int len) throws IOException { - return this.input.read(b, off, len); + int count = this.input.read(b, off, len); + if (count < 0) { + return count; + } + super.doProgressCallback(count); + + return count; } @Override public int read() throws IOException { - return this.input.read(); + int count = this.input.read(); + if (count < 0) { + return count; + } + super.doProgressCallback(1); + return count; } @Override diff --git a/src/main/java/com/baidubce/internal/RestartableInputStream.java b/src/main/java/com/baidubce/internal/RestartableInputStream.java index abb1da62..31925110 100644 --- a/src/main/java/com/baidubce/internal/RestartableInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableInputStream.java @@ -12,6 +12,8 @@ */ package com.baidubce.internal; +import com.baidubce.services.bos.model.BosProgressCallback; + import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -19,6 +21,8 @@ * Abstract class Restartable InputStream extends InputStream. */ public abstract class RestartableInputStream extends InputStream { + private BosProgressCallback progressCallback = null; + public abstract void restart(); public static RestartableInputStream wrap(byte[] b) { @@ -26,4 +30,20 @@ public static RestartableInputStream wrap(byte[] b) { input.mark(b.length); return new RestartableResettableInputStream(input); } + + public void setProgressCallback(BosProgressCallback progressCallback) { + this.progressCallback = progressCallback; + } + + public void doProgressCallback(int count) { + if (progressCallback != null) { + progressCallback.addCurrentSize(count); + } + } + + public void restartProgressCallback() { + if (progressCallback != null) { + progressCallback.setCurrentSize(0); + } + } } diff --git a/src/main/java/com/baidubce/internal/RestartableMultiByteArrayInputStream.java b/src/main/java/com/baidubce/internal/RestartableMultiByteArrayInputStream.java index 0b40d8ab..5a119855 100644 --- a/src/main/java/com/baidubce/internal/RestartableMultiByteArrayInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableMultiByteArrayInputStream.java @@ -12,6 +12,8 @@ */ package com.baidubce.internal; +import com.baidubce.services.bos.model.BosProgressCallback; + import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -53,6 +55,12 @@ public RestartableMultiByteArrayInputStream(List byteArrayList, long len this.length = length; } + public RestartableMultiByteArrayInputStream(List byteArrayList, long length, + BosProgressCallback progressCallback) { + this(byteArrayList, length); + super.setProgressCallback(progressCallback); + } + @Override public void restart() { this.pos = 0; @@ -82,6 +90,8 @@ public int read(byte[] b, int off, int len) throws IOException { len -= copyLength; count += copyLength; } + super.doProgressCallback(count); + return count; } @@ -93,6 +103,7 @@ public int read() { int index = (int) (this.pos / this.blockSize); int offset = (int) (this.pos % this.blockSize); ++this.pos; + super.doProgressCallback(1); return this.byteArrayList.get(index)[offset] & 0xff; } } diff --git a/src/main/java/com/baidubce/internal/RestartableNonResettableInputStream.java b/src/main/java/com/baidubce/internal/RestartableNonResettableInputStream.java index 569df535..2e978ae4 100644 --- a/src/main/java/com/baidubce/internal/RestartableNonResettableInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableNonResettableInputStream.java @@ -13,6 +13,7 @@ package com.baidubce.internal; import com.baidubce.BceClientException; +import com.baidubce.services.bos.model.BosProgressCallback; import java.io.IOException; import java.io.InputStream; @@ -55,12 +56,20 @@ public RestartableNonResettableInputStream(InputStream input, int bufferSize) { } } + public RestartableNonResettableInputStream(InputStream input, int bufferSize, + BosProgressCallback progressCallback) { + this(input, bufferSize); + super.setProgressCallback(progressCallback); + } + + @Override public void restart() { if (this.buffer == null) { throw new IllegalStateException("Fail to restart. Input buffer exhausted."); } this.offset = 0; + super.restartProgressCallback(); } @Override @@ -79,6 +88,7 @@ public int read(byte[] b, int off, int len) throws IOException { } System.arraycopy(this.buffer, this.offset, b, off, copyLength); this.offset += copyLength; + super.doProgressCallback(copyLength); return copyLength; } if (this.eof) { @@ -90,13 +100,16 @@ public int read(byte[] b, int off, int len) throws IOException { return -1; } this.buffer = null; + super.doProgressCallback(result); return result; } @Override public int read() throws IOException { if (this.offset < this.length) { - return this.buffer[this.offset++] & 0xff; + int result = this.buffer[this.offset++] & 0xff; + super.doProgressCallback(1); + return result; } if (this.eof) { return -1; @@ -107,6 +120,7 @@ public int read() throws IOException { return -1; } this.buffer = null; + super.doProgressCallback(1); return result; } diff --git a/src/main/java/com/baidubce/internal/RestartableResettableInputStream.java b/src/main/java/com/baidubce/internal/RestartableResettableInputStream.java index 764ecd65..6e1290c0 100644 --- a/src/main/java/com/baidubce/internal/RestartableResettableInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableResettableInputStream.java @@ -13,6 +13,7 @@ package com.baidubce.internal; import com.baidubce.BceClientException; +import com.baidubce.services.bos.model.BosProgressCallback; import java.io.IOException; import java.io.InputStream; @@ -32,10 +33,16 @@ public RestartableResettableInputStream(InputStream input) { this.input = input; } + public RestartableResettableInputStream(InputStream input, BosProgressCallback progressCallback) { + this(input); + super.setProgressCallback(progressCallback); + } + @Override public void restart() { try { this.input.reset(); + super.restartProgressCallback(); } catch (IOException e) { throw new BceClientException("Fail to reset the underlying input stream.", e); } @@ -43,12 +50,23 @@ public void restart() { @Override public int read(byte[] b, int off, int len) throws IOException { - return this.input.read(b, off, len); + int count = this.input.read(b, off, len); + if (count < 0) { + return count; + } + super.doProgressCallback(count); + + return count; } @Override public int read() throws IOException { - return this.input.read(); + int count = this.input.read(); + if (count < 0) { + return count; + } + super.doProgressCallback(1); + return count; } @Override diff --git a/src/main/java/com/baidubce/model/AbstractBceResponse.java b/src/main/java/com/baidubce/model/AbstractBceResponse.java index 5825c532..9b1f62ad 100644 --- a/src/main/java/com/baidubce/model/AbstractBceResponse.java +++ b/src/main/java/com/baidubce/model/AbstractBceResponse.java @@ -14,12 +14,15 @@ import com.baidubce.BceResponseMetadata; +import java.io.Serializable; + /** * Represents the response from an BCE service, including the result payload and any response metadata. BCE response * metadata consists primarily of the BCE request ID, which can be used for debugging purposes when services aren't * acting as expected. */ -public class AbstractBceResponse { +public class AbstractBceResponse implements Serializable { + protected BceResponseMetadata metadata = new BceResponseMetadata(); public BceResponseMetadata getMetadata() { diff --git a/src/main/java/com/baidubce/model/ListRequest.java b/src/main/java/com/baidubce/model/ListRequest.java new file mode 100644 index 00000000..33372d65 --- /dev/null +++ b/src/main/java/com/baidubce/model/ListRequest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.model; + +/** + * Container for the parameters of the list operation. + */ +public abstract class ListRequest extends AbstractBceRequest { + + /** + * The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + *

+ * Together with the marker, specifies the list result which listing should begin. + *

+ * If the marker is not specified, the list result will listing from the first one. + * + */ + private String marker; + + /** + * The optional parameter to specifies the max number of list result to return. + */ + private int maxKeys = -1; + + /** + * Returning the optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * + * @return The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + */ + public String getMarker() { + return marker; + } + + /** + * Setting the optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + */ + public void setMarker(String marker) { + this.marker = marker; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListRequest with specified marker. + */ + public ListRequest withMarker(String marker) { + this.marker = marker; + return this; + } + + /** + * Returning the optional parameter that specifies the max number of list result to return . + * + * @return The optional parameter in the original request to specifies the max number of list result to return . + */ + public int getMaxKeys() { + return maxKeys; + } + + /** + * Setting the optional parameter to specifies the max number of list result to return + * + * @param maxKeys The optional parameter in the original request to specifies the max number of list result to return . + */ + public void setMaxKeys(int maxKeys) { + this.maxKeys = maxKeys; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListRequest with specified maxKeys. + */ + public ListRequest withMaxKeys(int maxKeys) { + this.maxKeys = maxKeys; + return this; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/model/ListResponse.java b/src/main/java/com/baidubce/model/ListResponse.java new file mode 100644 index 00000000..67ccfc12 --- /dev/null +++ b/src/main/java/com/baidubce/model/ListResponse.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.model; + +/** + * The base response contains the base information about list operation. + */ +public abstract class ListResponse extends AbstractBceResponse { + + /** + * The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + */ + private String marker; + + /** + * Indicates if the listing is truncated, and additional requests need to be + * made to get more results. + */ + private boolean isTruncated; + + /** + * If this listing is truncated, this is the next marker that should be + * used in the next request to get the next page of results. + */ + private String nextMarker; + + /** + * The optional parameter in the original request to specifies the max number of list result to return . + */ + private Integer maxKeys; + + /** + * Returning the optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * + * @return The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + */ + public String getMarker() { + return marker; + } + + /** + * Setting the optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + */ + public void setMarker(String marker) { + this.marker = marker; + } + + /** + * Returning false to indicate that there is not more result in the next page, + * otherwise returning true meaning there is more result in next page. + * + * @return Returning false to indicate that there is not more result in the next page, + * otherwise returning true meaning there is more result in next page. + */ + public boolean getIsTruncated() { + return isTruncated; + } + + /** + * Setting the boolean value to indicate that there is not more result in the next page. + * + * Setting false to indicate that there is not more result in the next page, + * Setting true meaning there is more result in next page. + * + * @param isTruncated The boolean value to indicate that there is not more result in the next page. + */ + public void setIsTruncated(boolean isTruncated) { + this.isTruncated = isTruncated; + } + + /** + * Returns the next marker that should be used in the next request to + * get the next page of results. This value is only valid if + * isTruncated indicates this listing is truncated. + * + * @return the next key marker that should be used in the next request to + * get the next page of results. This value is only valid if + * isTruncated() indicates this listing is truncated. + */ + public String getNextMarker() { + return nextMarker; + } + + /** + * Sets the next marker that should be used in the next request to get + * the next page of results. + * + * @param nextMarker The next marker that should be used in the next request to + * get the next page of results. + */ + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + /** + * Returning the optional parameter in the original request to specifies the max number of list result to return . + * + * @return The optional parameter in the original request to specifies the max number of list result to return . + */ + public Integer getMaxKeys() { + return maxKeys; + } + + /** + * Setting the optional parameter in the original request to specifies the max number of list result to return + * + * @param maxKeys The optional parameter in the original request to specifies the max number of list result to return . + */ + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + +} diff --git a/src/main/java/com/baidubce/model/ResourceType.java b/src/main/java/com/baidubce/model/ResourceType.java new file mode 100644 index 00000000..f5826fac --- /dev/null +++ b/src/main/java/com/baidubce/model/ResourceType.java @@ -0,0 +1,5 @@ +package com.baidubce.model; + +public enum ResourceType { + bcc, cds, image, snapshotchain, bccri +} diff --git a/src/main/java/com/baidubce/model/User.java b/src/main/java/com/baidubce/model/User.java old mode 100644 new mode 100755 index bfdf07f1..bba75eba --- a/src/main/java/com/baidubce/model/User.java +++ b/src/main/java/com/baidubce/model/User.java @@ -30,7 +30,7 @@ public User() { /** * Constructs a new user with the specified ID and display name. * - * @param id The ID for the user. + * @param id The ID for the user. * @param displayName The display name for the user. */ public User(String id, String displayName) { @@ -60,6 +60,7 @@ public void setId(String id) { * Sets the ID of the user. * * @param id The ID of the user. + * @return this object */ public User withId(String id) { this.setId(id); @@ -88,6 +89,7 @@ public void setDisplayName(String displayName) { * Sets the display name of the user. * * @param displayName The display name of the user. + * @return this object */ public User withDisplayName(String displayName) { this.setDisplayName(displayName); diff --git a/src/main/java/com/baidubce/services/acl/AclClient.java b/src/main/java/com/baidubce/services/acl/AclClient.java new file mode 100644 index 00000000..ccaa3c60 --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/AclClient.java @@ -0,0 +1,305 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl; + +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.acl.model.AclRule; +import com.baidubce.services.acl.model.CreateAclRequest; +import com.baidubce.services.acl.model.DeleteAclRequest; +import com.baidubce.services.acl.model.GetAclRequest; +import com.baidubce.services.acl.model.GetAclResponse; +import com.baidubce.services.acl.model.ListAclRequest; +import com.baidubce.services.acl.model.ListAclResponse; +import com.baidubce.services.acl.model.ModifyAclRuleAttributesRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; + +/** + * Provides the client for accessing the Baidu Cloud network Service Access Control List (ACL). + */ +public class AclClient extends AbstractBceClient { + + /** + * ACL API pathVersion + */ + private static final String VERSION = "v1"; + + private static final String PREFIX = "acl"; + + private static final String RULE_PREFIX = "rule"; + + private static final String CLIENT_TOKEN_IDENTIFY = "clientToken"; + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static final HttpResponseHandler[] aclHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on network. + */ + public AclClient() { + this(new AclClientConfiguration()); + } + + /** + * Constructs a new network client using the client configuration to access network. + * + * @param clientConfiguration The network client configuration options controlling how this client + * connects to network (e.g. proxy settings, retry counts, etc). + */ + public AclClient(AclClientConfiguration clientConfiguration) { + super(clientConfiguration, aclHandlers); + } + + /** + * Creates and initializes a new request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * Create a acl with the specified options. + * + * @param aclRules The rules of acl + */ + public void createAcl(List aclRules) { + CreateAclRequest request = new CreateAclRequest(); + request.setAclRules(aclRules); + createAcl(request); + } + + /** + * Create a acl with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param createAclRequest The request containing all options for creating a acl. + */ + public void createAcl(CreateAclRequest createAclRequest) { + checkNotNull(createAclRequest, "request should not be null."); + if (Strings.isNullOrEmpty(createAclRequest.getClientToken())) { + createAclRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(createAclRequest.getAclRules(), "aclRules should not be null."); + InternalRequest internalRequest = + this.createRequest(createAclRequest, HttpMethodName.POST, PREFIX, RULE_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, createAclRequest.getClientToken()); + fillPayload(internalRequest, createAclRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of aclRules owned by the specified subnet. + * + * @return The response containing a list of aclRules owned by the subnet. + */ + public ListAclResponse listAclRules(String subnetId) { + return listAclRules(new ListAclRequest().withSubnetId(subnetId)); + } + + /** + * Return a list of aclRules owned by the specified subnet. + * + * @param listAclRequest The request containing all options for listing subnet's aclRule. + * + * @return The response containing a list of aclRules owned by the specified subnet. + */ + public ListAclResponse listAclRules(ListAclRequest listAclRequest) { + checkNotNull(listAclRequest, "request should not be null."); + checkStringNotEmpty(listAclRequest.getSubnetId(), "request subnetId should not be null"); + InternalRequest internalRequest = this.createRequest(listAclRequest, HttpMethodName.GET, PREFIX, RULE_PREFIX); + internalRequest.addParameter("subnetId", listAclRequest.getSubnetId()); + if (listAclRequest.getMarker() != null) { + internalRequest.addParameter("marker", listAclRequest.getMarker()); + } + if (listAclRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listAclRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListAclResponse.class); + } + + /** + * Get the detail acl information of specified vpc. + * + * @param vpcId The id of the network. + * + * @return A acl detail model for the vpcId. + */ + public GetAclResponse getAcl(String vpcId) { + return getAcl(new GetAclRequest().withVpcId(vpcId)); + } + + /** + * Get the detail acl information of specified vpc. + * + * @param getAclRequest The request containing all options for getting the acl info. + * + * @return A acl detail model for the vpcId. + */ + public GetAclResponse getAcl(GetAclRequest getAclRequest) { + checkNotNull(getAclRequest, "request should not be null."); + checkStringNotEmpty(getAclRequest.getVpcId(), "request vpcId should not be null"); + InternalRequest internalRequest = this.createRequest(getAclRequest, HttpMethodName.GET, PREFIX); + internalRequest.addParameter("vpcId", getAclRequest.getVpcId()); + return invokeHttpClient(internalRequest, GetAclResponse.class); + } + + /** + * Delete the specified aclRule. + *

+ * + * @param aclRuleId The id of the aclRule to delete. + */ + public void deleteAcl(String aclRuleId) { + deleteAcl(new DeleteAclRequest().withAclRuleId(aclRuleId)); + } + + /** + * Delete the specified aclRule. + *

+ * + * @param deleteAclRequest The request containing all options for deleting aclRule. + */ + public void deleteAcl(DeleteAclRequest deleteAclRequest) { + checkNotNull(deleteAclRequest, "request should not be null."); + checkStringNotEmpty(deleteAclRequest.getAclRuleId(), "request aclRuleId should not be null."); + if (Strings.isNullOrEmpty(deleteAclRequest.getClientToken())) { + deleteAclRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = + this.createRequest(deleteAclRequest, HttpMethodName.DELETE, PREFIX, RULE_PREFIX, + deleteAclRequest.getAclRuleId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, deleteAclRequest.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Modifying the special attribute to new aclRule owned by the user. + * + * @param aclRuleId The id of the aclRule + * @param aclRule the aclRule after modifying + */ + public void modifyAclRuleAttributes(String aclRuleId, AclRule aclRule) { + ModifyAclRuleAttributesRequest request = + new ModifyAclRuleAttributesRequest().withAclRuleId(aclRuleId).withDescription + (aclRule.getDescription()).withProtocol(aclRule.getProtocol()).withSourceIpAddress(aclRule + .getSourceIpAddress()).withDestinationIpAddress(aclRule.getDestinationIpAddress()) + .withSourcePort(aclRule.getSourcePort()).withDestinationPort(aclRule.getDestinationPort()) + .withPosition(aclRule.getPosition()).withAction(aclRule.getAction()); + modifyAclRuleAttributes(request); + } + + /** + * Modifying the special attribute to new aclRule owned by the user. + *

+ * + * @param modifyAclRuleAttributesRequest The request containing all options for modifying own's aclRule. + */ + public void modifyAclRuleAttributes(ModifyAclRuleAttributesRequest modifyAclRuleAttributesRequest) { + checkNotNull(modifyAclRuleAttributesRequest, "request should not be null."); + checkStringNotEmpty(modifyAclRuleAttributesRequest.getAclRuleId(), "request aclRuleId should not be null."); + if (Strings.isNullOrEmpty(modifyAclRuleAttributesRequest.getClientToken())) { + modifyAclRuleAttributesRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = + this.createRequest(modifyAclRuleAttributesRequest, HttpMethodName.PUT, PREFIX, RULE_PREFIX, + modifyAclRuleAttributesRequest.getAclRuleId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, modifyAclRuleAttributesRequest.getClientToken()); + fillPayload(internalRequest, modifyAclRuleAttributesRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/acl/AclClientConfiguration.java b/src/main/java/com/baidubce/services/acl/AclClientConfiguration.java new file mode 100644 index 00000000..0ff8c06e --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/AclClientConfiguration.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for bcc service. + */ +public class AclClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/acl/model/AclEntry.java b/src/main/java/com/baidubce/services/acl/model/AclEntry.java new file mode 100644 index 00000000..28239898 --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/model/AclEntry.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl.model; + +import java.util.List; + +/** + * acl detail info model + */ +public class AclEntry { + + /** + * the subnetId of the acl + */ + private String subnetId; + + /** + * the subnetName of the acl + */ + private String subnetName; + + /** + * the subnetCidr of the acl + */ + private String subnetCidr; + + /** + * the rules of the acl + */ + private List aclRules; + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getSubnetName() { + return subnetName; + } + + public void setSubnetName(String subnetName) { + this.subnetName = subnetName; + } + + public String getSubnetCidr() { + return subnetCidr; + } + + public void setSubnetCidr(String subnetCidr) { + this.subnetCidr = subnetCidr; + } + + public List getAclRules() { + return aclRules; + } + + public void setAclRules(List aclRules) { + this.aclRules = aclRules; + } + + @Override + public String toString() { + return "AclEntry{" + + "subnetId='" + subnetId + '\'' + + ", subnetName='" + subnetName + '\'' + + ", subnetCidr='" + subnetCidr + '\'' + + ", aclRules=" + aclRules + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/acl/model/AclRule.java b/src/main/java/com/baidubce/services/acl/model/AclRule.java new file mode 100644 index 00000000..d3c580f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/model/AclRule.java @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl.model; + +/** + * aclRule detail info model + */ +public class AclRule { + + /** + * the id of the aclRule + */ + private String id; + + /** + * the subnet id of the aclRule + */ + private String subnetId; + + /** + * the name of the aclRule + */ + private String name; + + /** + * the option param to describe the aclRule + */ + private String description; + + /** + * the protocol of the aclRule
+ * contains "all", "tcp", "udp", "icmp" + */ + private String protocol; + + /** + * the source ip address of the aclRule
+ * can be a specific ip or value "all" + */ + private String sourceIpAddress; + + /** + * the destination ip address of the aclRule
+ * can be a specific ip or value "all" + */ + private String destinationIpAddress; + + /** + * the source port of the aclRule + */ + private String sourcePort; + + /** + * the destination port of the aclRule + */ + private String destinationPort; + + /** + * the position of the aclRule
+ * the value can only be one of 1-5000
+ * aclRule's priority is higher with the smaller position value + */ + private Integer position; + + /** + * the direction of the aclRule
+ * value contains "ingress" and "egress" + */ + private String direction; + + /** + * the strategy of the aclRule
+ * value contains "allow" and "deny" + */ + private String action; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getSourceIpAddress() { + return sourceIpAddress; + } + + public void setSourceIpAddress(String sourceIpAddress) { + this.sourceIpAddress = sourceIpAddress; + } + + public String getDestinationIpAddress() { + return destinationIpAddress; + } + + public void setDestinationIpAddress(String destinationIpAddress) { + this.destinationIpAddress = destinationIpAddress; + } + + public String getSourcePort() { + return sourcePort; + } + + public void setSourcePort(String sourcePort) { + this.sourcePort = sourcePort; + } + + public String getDestinationPort() { + return destinationPort; + } + + public void setDestinationPort(String destinationPort) { + this.destinationPort = destinationPort; + } + + public Integer getPosition() { + return position; + } + + public void setPosition(Integer position) { + this.position = position; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + @Override + public String toString() { + return "AclRule{" + + "id='" + id + '\'' + + ", subnetId='" + subnetId + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", protocol='" + protocol + '\'' + + ", sourceIpAddress='" + sourceIpAddress + '\'' + + ", destinationIpAddress='" + destinationIpAddress + '\'' + + ", sourcePort='" + sourcePort + '\'' + + ", destinationPort='" + destinationPort + '\'' + + ", position=" + position + + ", direction='" + direction + '\'' + + ", action='" + action + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/acl/model/CreateAclRequest.java b/src/main/java/com/baidubce/services/acl/model/CreateAclRequest.java new file mode 100644 index 00000000..9a569158 --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/model/CreateAclRequest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for create acl + */ +public class CreateAclRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * aclRules detail info to create + */ + private List aclRules; + + private CreateAclRequest withAclRules(List aclRules) { + this.setAclRules(aclRules); + return this; + } + + private CreateAclRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public List getAclRules() { + return aclRules; + } + + public void setAclRules(List aclRules) { + this.aclRules = aclRules; + } + + @Override + public CreateAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/acl/model/DeleteAclRequest.java b/src/main/java/com/baidubce/services/acl/model/DeleteAclRequest.java new file mode 100644 index 00000000..f0f77e7b --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/model/DeleteAclRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for delete acl + */ +public class DeleteAclRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the aclRule id + */ + private String aclRuleId; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * + * @return DeleteSubnetRequest with specific clientToken + */ + public DeleteAclRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public DeleteAclRequest withAclRuleId(String aclRuleId) { + this.aclRuleId = aclRuleId; + return this; + } + + public String getAclRuleId() { + return aclRuleId; + } + + public void setAclRuleId(String aclRuleId) { + this.aclRuleId = aclRuleId; + } + + @Override + public DeleteAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/acl/model/GetAclRequest.java b/src/main/java/com/baidubce/services/acl/model/GetAclRequest.java new file mode 100644 index 00000000..30eb3d5c --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/model/GetAclRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting acl + */ +public class GetAclRequest extends AbstractBceRequest { + + /** + * The id of vpc + */ + private String vpcId; + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public GetAclRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetSubnetRequest with credentials. + */ + @Override + public GetAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/acl/model/GetAclResponse.java b/src/main/java/com/baidubce/services/acl/model/GetAclResponse.java new file mode 100644 index 00000000..60c3687a --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/model/GetAclResponse.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for GetAclRequest. + */ +public class GetAclResponse extends AbstractBceResponse { + + /** + * the vpc id of the acl + */ + private String vpcId; + + /** + * the vpc name of the acl + */ + private String vpcName; + + /** + * the vpc cidr of the acl + */ + private String vpcCidr; + + /** + * the acl entry detail info + */ + private List aclEntrys; + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getVpcName() { + return vpcName; + } + + public void setVpcName(String vpcName) { + this.vpcName = vpcName; + } + + public String getVpcCidr() { + return vpcCidr; + } + + public void setVpcCidr(String vpcCidr) { + this.vpcCidr = vpcCidr; + } + + public List getAclEntrys() { + return aclEntrys; + } + + public void setAclEntrys(List aclEntrys) { + this.aclEntrys = aclEntrys; + } + + @Override + public String toString() { + return "GetAclResponse{" + + "vpcId='" + vpcId + '\'' + + ", vpcName='" + vpcName + '\'' + + ", vpcCidr='" + vpcCidr + '\'' + + ", aclEntrys=" + aclEntrys + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/acl/model/ListAclRequest.java b/src/main/java/com/baidubce/services/acl/model/ListAclRequest.java new file mode 100644 index 00000000..a0d55690 --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/model/ListAclRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list acl + */ +public class ListAclRequest extends ListRequest { + + /** + * the subnet id of the acl + */ + private String subnetId; + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public ListAclRequest withSubnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + @Override + public ListAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/acl/model/ListAclResponse.java b/src/main/java/com/baidubce/services/acl/model/ListAclResponse.java new file mode 100644 index 00000000..e15a690b --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/model/ListAclResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +/** + * The response for ListAclRequest. + */ +public class ListAclResponse extends ListResponse { + + /** + * List of acl rules. + */ + private List aclRules; + + public List getAclRules() { + return aclRules; + } + + public void setAclRules(List aclRules) { + this.aclRules = aclRules; + } + + @Override + public String toString() { + return "ListAclResponse{" + + "marker= " + getMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "aclRules=" + aclRules + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/acl/model/ModifyAclRuleAttributesRequest.java b/src/main/java/com/baidubce/services/acl/model/ModifyAclRuleAttributesRequest.java new file mode 100644 index 00000000..5e6e6fc6 --- /dev/null +++ b/src/main/java/com/baidubce/services/acl/model/ModifyAclRuleAttributesRequest.java @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.acl.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for modify aclRuleAttributes + */ +public class ModifyAclRuleAttributesRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the id of aclRule modified. + */ + @JsonIgnore + private String aclRuleId; + + /** + * the id of the aclRule + */ + private String id; + + /** + * the subnet id of the aclRule + */ + private String subnetId; + + /** + * the name of the aclRule + */ + private String name; + + /** + * the option param to describe the aclRule + */ + private String description; + + /** + * the protocol of the aclRule
+ * contains "all", "tcp", "udp", "icmp" + */ + private String protocol; + + /** + * the source ip address of the aclRule
+ * can be a specific ip or value "all" + */ + private String sourceIpAddress; + + /** + * the destination ip address of the aclRule
+ * can be a specific ip or value "all" + */ + private String destinationIpAddress; + + /** + * the source port of the aclRule + */ + private String sourcePort; + + /** + * the destination port of the aclRule + */ + private String destinationPort; + + /** + * the position of the aclRule
+ * the value can only be one of 1-5000
+ * aclRule's priority is higher with the smaller position value + */ + private Integer position; + + /** + * the direction of the aclRule
+ * value contains "ingress" and "egress" + */ + private String direction; + + /** + * the strategy of the aclRule
+ * value contains "allow" and "deny" + */ + private String action; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getSourceIpAddress() { + return sourceIpAddress; + } + + public void setSourceIpAddress(String sourceIpAddress) { + this.sourceIpAddress = sourceIpAddress; + } + + public String getDestinationIpAddress() { + return destinationIpAddress; + } + + public void setDestinationIpAddress(String destinationIpAddress) { + this.destinationIpAddress = destinationIpAddress; + } + + public String getSourcePort() { + return sourcePort; + } + + public void setSourcePort(String sourcePort) { + this.sourcePort = sourcePort; + } + + public String getDestinationPort() { + return destinationPort; + } + + public void setDestinationPort(String destinationPort) { + this.destinationPort = destinationPort; + } + + public Integer getPosition() { + return position; + } + + public void setPosition(Integer position) { + this.position = position; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getAclRuleId() { + return aclRuleId; + } + + public void setAclRuleId(String aclRuleId) { + this.aclRuleId = aclRuleId; + } + + public ModifyAclRuleAttributesRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public ModifyAclRuleAttributesRequest withAclRuleId(String aclRuleId) { + this.aclRuleId = aclRuleId; + return this; + } + + public ModifyAclRuleAttributesRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public ModifyAclRuleAttributesRequest withProtocol(String protocol) { + this.setProtocol(protocol); + return this; + } + + public ModifyAclRuleAttributesRequest withSourceIpAddress(String sourceIpAddress) { + this.setSourceIpAddress(sourceIpAddress); + return this; + } + + public ModifyAclRuleAttributesRequest withDestinationIpAddress(String destinationIpAddress) { + this.setDestinationIpAddress(destinationIpAddress); + return this; + } + + public ModifyAclRuleAttributesRequest withSourcePort(String sourcePort) { + this.setSourcePort(sourcePort); + return this; + } + + public ModifyAclRuleAttributesRequest withDestinationPort(String destinationPort) { + this.setDestinationPort(destinationPort); + return this; + } + + public ModifyAclRuleAttributesRequest withPosition(int position) { + this.setPosition(position); + return this; + } + + public ModifyAclRuleAttributesRequest withAction(String action) { + this.setAction(action); + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/AihcInferenceClient.java b/src/main/java/com/baidubce/services/aihc/AihcInferenceClient.java new file mode 100644 index 00000000..9deb68e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/AihcInferenceClient.java @@ -0,0 +1,456 @@ +package com.baidubce.services.aihc; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; + +import com.baidubce.services.aihc.model.inference.AppChangeDetailRequest; +import com.baidubce.services.aihc.model.inference.AppChangeDetailResponse; +import com.baidubce.services.aihc.model.inference.AppDetailsRequest; +import com.baidubce.services.aihc.model.inference.AppDetailsResponse; +import com.baidubce.services.aihc.model.inference.BlockPodRequest; +import com.baidubce.services.aihc.model.inference.BlockPodResponse; +import com.baidubce.services.aihc.model.inference.CreateAppRequest; +import com.baidubce.services.aihc.model.inference.CreateAppResponse; +import com.baidubce.services.aihc.model.inference.DeleteAppRequest; +import com.baidubce.services.aihc.model.inference.DeleteAppResponse; +import com.baidubce.services.aihc.model.inference.DeletePodRequest; +import com.baidubce.services.aihc.model.inference.DeletePodResponse; +import com.baidubce.services.aihc.model.inference.ListAppRequest; +import com.baidubce.services.aihc.model.inference.ListAppResponse; +import com.baidubce.services.aihc.model.inference.ListChangeRequest; +import com.baidubce.services.aihc.model.inference.ListChangeResponse; +import com.baidubce.services.aihc.model.inference.ListPodRequest; +import com.baidubce.services.aihc.model.inference.ListPodResponse; +import com.baidubce.services.aihc.model.inference.ListResPoolBriefRequest; +import com.baidubce.services.aihc.model.inference.ListResPoolBriefResponse; +import com.baidubce.services.aihc.model.inference.ListStatsRequest; +import com.baidubce.services.aihc.model.inference.ListStatsResponse; +import com.baidubce.services.aihc.model.inference.PubAccessRequest; +import com.baidubce.services.aihc.model.inference.PubAccessResponse; +import com.baidubce.services.aihc.model.inference.ResPoolDetailRequest; +import com.baidubce.services.aihc.model.inference.ResPoolDetailResponse; +import com.baidubce.services.aihc.model.inference.ScaleAppRequest; +import com.baidubce.services.aihc.model.inference.ScaleAppResponse; +import com.baidubce.services.aihc.model.inference.UpdateAppRequest; +import com.baidubce.services.aihc.model.inference.UpdateAppResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; + +public class AihcInferenceClient extends AbstractBceClient { + + /** + * aihc inference API pathVersion + */ + private static final String APPPREFIX = "api/aihcpom/app"; + private static final String PODPREFIX = "api/aihcpom/pod"; + private static final String RESPOOLPREFIX = "api/aihcpom/respool"; + + private static final String VERSION = "v1"; + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static HttpResponseHandler[] aihcInferenceHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public AihcInferenceClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new InstanceClient to invoke service methods on eip instance. + * + * @param clientConfiguration The BCE client configuration options. + */ + public AihcInferenceClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, aihcInferenceHandlers); + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param region The region. + * @param prefix The prefix of URI. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest( + AbstractBceRequest bceRequest, HttpMethodName httpMethod, String region, String prefix, String... pathVariables) { + List path = new ArrayList(); + path.add(prefix); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + request.addHeader("X-Region", region); + + return request; + } + + /** + * Create an app with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for creating an app. + * @return created appId + */ + public CreateAppResponse createApp(CreateAppRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, region, APPPREFIX, "create"); + checkNotNull(request.getAppName(), "appName should not be null"); + checkNotNull(request.getChipType(), "chipType should not be null"); + if (request.getInsCount() <= 0) { + throw new IllegalArgumentException("insCount should be > 0"); + } + checkNotNull(request.getResPool(), "resPool should not be null"); + checkNotNull(request.getContainers(), "containers should not be null"); + checkNotNull(request.getAccess(), "access should not be null"); + checkNotNull(request.getLog(), "log should not be null"); + checkNotNull(request.getDeploy(), "deploy should not be null"); + + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateAppResponse.class); + } + + /** + * List apps with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for list an app. + * @return apps info + */ + public ListAppResponse listApp(ListAppRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, region, APPPREFIX, "list"); + if (request.getKeyword() != null) { + internalRequest.addParameter("keyword", request.getKeyword()); + } + if (request.getPageNo() < 0) { + throw new IllegalArgumentException("pageNo should be > 0"); + } + if (request.getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() < 0) { + throw new IllegalArgumentException("pageSize should be > 0"); + } + if (request.getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + if (request.getOrderBy() != null && request.getOrder() != null) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + internalRequest.addParameter("order", request.getOrder()); + } + + return invokeHttpClient(internalRequest, ListAppResponse.class); + } + + /** + * List app stats with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for list app stats. + * @return apps stats info + */ + public ListStatsResponse listStats(ListStatsRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, region, APPPREFIX, "stats"); + if (request.getAppIds().isEmpty()) { + throw new IllegalArgumentException("appId should not be null"); + } + + String appIds = String.join("#", request.getAppIds()); + internalRequest.addParameter("appIds", appIds); + return invokeHttpClient(internalRequest, ListStatsResponse.class); + } + + /** + * The details of app with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for app details. + * @return app details info + */ + public AppDetailsResponse appDetails(AppDetailsRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, region, APPPREFIX, "details"); + checkStringNotEmpty(request.getAppId(), "appId should not be empty"); + internalRequest.addParameter("appId", request.getAppId()); + return invokeHttpClient(internalRequest, AppDetailsResponse.class); + } + + /** + * Update app with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for update app. + * @return app Id + */ + public UpdateAppResponse updateApp(UpdateAppRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, region, APPPREFIX, "update"); + checkNotNull(request.getAppId(), "appId should not be null"); + + internalRequest.addParameter("appId", request.getAppId()); + if (request.getShortDesc() != null) { + internalRequest.addParameter("shortDesc", request.getShortDesc()); + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateAppResponse.class); + } + + /** + * Scale app with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for scale app. + * @return + */ + public ScaleAppResponse scaleApp(ScaleAppRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, region, APPPREFIX, "scale"); + checkNotNull(request.getAppId(), "appId should not be null"); + if (request.getInsCount() < 0) { + throw new IllegalArgumentException("insCount should be >= 0"); + } + + internalRequest.addParameter("appId", request.getAppId()); + internalRequest.addParameter("insCount", String.valueOf(request.getInsCount())); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ScaleAppResponse.class); + } + + /** + * Operate the public network with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for operate the public network. + * @return + */ + public PubAccessResponse pubAccess(PubAccessRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, region, APPPREFIX, "pubaccess"); + checkNotNull(request.getAppId(), "appId should not be null"); + internalRequest.addParameter("appId", request.getAppId()); + internalRequest.addParameter("publicAccess", String.valueOf(request.isPublicAccess())); + if (request.getEip() != null) { + internalRequest.addParameter("eip", request.getEip()); + } + + fillPayload(internalRequest, request); + + return invokeHttpClient(internalRequest, PubAccessResponse.class); + } + + /** + * List change with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for list change. + * @return change list info + */ + public ListChangeResponse listChange(ListChangeRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, region, APPPREFIX, "listchange"); + checkNotNull(request.getAppId(), "appId should not be null"); + internalRequest.addParameter("appId", request.getAppId()); + internalRequest.addParameter("changeType", String.valueOf(request.getChangeType())); + + if (request.getOrder() != null) { + internalRequest.addParameter("order", request.getOrder()); + } + if (request.getPageNo() < 0) { + throw new IllegalArgumentException("pageNo should be > 0"); + } + if (request.getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() < 0) { + throw new IllegalArgumentException("pageSize should be > 0"); + } + if (request.getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + if (request.getOrderBy() != null && request.getOrder() != null) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + internalRequest.addParameter("order", request.getOrder()); + } + + return invokeHttpClient(internalRequest, ListChangeResponse.class); + } + + /** + * change detail with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for change detail. + * @return change detail info + */ + public AppChangeDetailResponse appChangeDetail(AppChangeDetailRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, region, APPPREFIX, "changedetail"); + checkNotNull(request.getChangeId(), "changeId should not be null"); + internalRequest.addParameter("changeId", request.getChangeId()); + + return invokeHttpClient(internalRequest, AppChangeDetailResponse.class); + } + + /** + * delete app with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for delete app. + * @return + */ + public DeleteAppResponse deleteApp(DeleteAppRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, region, APPPREFIX, "delete"); + checkNotNull(request.getAppId(), "appId should not be null"); + + internalRequest.addParameter("appId", request.getAppId()); + fillPayload(internalRequest, request); + + return invokeHttpClient(internalRequest, DeleteAppResponse.class); + } + + /** + * List pod with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for list pod. + * @return pod info + */ + public ListPodResponse listPod(ListPodRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, region, PODPREFIX, "list"); + checkNotNull(request.getAppId(), "appId should not be null"); + internalRequest.addParameter("appId", request.getAppId()); + + return invokeHttpClient(internalRequest, ListPodResponse.class); + } + + /** + * block pod with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for block pod. + * @return + */ + public BlockPodResponse blockPod(BlockPodRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, region, PODPREFIX, "block"); + checkNotNull(request.getAppId(), "appId should not be null"); + checkNotNull(request.getInsID(), "insID should not be null"); + + internalRequest.addParameter("appId", request.getAppId()); + internalRequest.addParameter("insID", request.getInsID()); + internalRequest.addParameter("block", String.valueOf(request.isBlock())); + + fillPayload(internalRequest, request); + + return invokeHttpClient(internalRequest, BlockPodResponse.class); + } + + /** + * delete pod with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for delete pod. + * @return + */ + public DeletePodResponse deletePod(DeletePodRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, region, PODPREFIX, "delete"); + checkNotNull(request.getAppId(), "appId should not be null"); + checkNotNull(request.getInsID(), "insID should not be null"); + + internalRequest.addParameter("appId", request.getAppId()); + internalRequest.addParameter("insID", request.getInsID()); + fillPayload(internalRequest, request); + + return invokeHttpClient(internalRequest, DeletePodResponse.class); + } + + /** + * list resPool brief info with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for list resPool brief info. + * @return list resPool brief info + */ + public ListResPoolBriefResponse listResPoolBrief(ListResPoolBriefRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, region, RESPOOLPREFIX, "listbrief"); + if (request.getPageNo() < 0) { + throw new IllegalArgumentException("pageNo should be > 0"); + } + if (request.getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() < 0) { + throw new IllegalArgumentException("pageSize should be > 0"); + } + if (request.getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + + return invokeHttpClient(internalRequest, ListResPoolBriefResponse.class); + } + + /** + * list resPool brief info with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for list resPool brief info. + * @return list resPool brief info + */ + public ResPoolDetailResponse resPoolDetail(ResPoolDetailRequest request, String region) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, region, RESPOOLPREFIX, "detail"); + checkNotNull(request.getResPoolId(), "resPoolId should not be null"); + + internalRequest.addParameter("resPoolId", request.getResPoolId()); + + return invokeHttpClient(internalRequest, ResPoolDetailResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/AppChangeDetailRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/AppChangeDetailRequest.java new file mode 100644 index 00000000..7950333e --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/AppChangeDetailRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class AppChangeDetailRequest extends AbstractBceRequest { + + private String changeId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return AppDetailsRequest with credentials. + */ + public AppChangeDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/AppChangeDetailResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/AppChangeDetailResponse.java new file mode 100644 index 00000000..bc2d476e --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/AppChangeDetailResponse.java @@ -0,0 +1,47 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +public class AppChangeDetailResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { + private String changeId; + private String prev; + private int changeType; + private String shortDesc; + private String creator; + private int ctime; + private String snapshot; + } + + @Override + public String toString() { + return "AppChangeDetailResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/AppDetailsRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/AppDetailsRequest.java new file mode 100644 index 00000000..6f38caf3 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/AppDetailsRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class AppDetailsRequest extends AbstractBceRequest { + + private String appId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return AppDetailsRequest with credentials. + */ + public AppDetailsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/AppDetailsResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/AppDetailsResponse.java new file mode 100644 index 00000000..190dd082 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/AppDetailsResponse.java @@ -0,0 +1,283 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; +import java.util.Map; + +@Getter +@Setter +public class AppDetailsResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { + private AppConf app; + private AppStatus status; + private String creator; + private int ctime; + private int mtime; + } + + @Getter + @Setter + @ToString + public static class AppConf { + private String appName; + private String chipType; + private int insCount; + private ResPoolConf resPool; + private StorageConf storage; + private List containers; + private AccessConf access; + private LogConf log; + private DeployConf deploy; + private Misc misc; + } + + @Getter + @Setter + @ToString + public static class ResPoolConf { + private String resPoolId; + private String resPoolName; + private String queue; + private String subnetID; + private String vpcID; + } + + @Getter + @Setter + @ToString + public static class StorageConf { + private int shmSize; + private List volumns; + } + + @Getter + @Setter + @ToString + public static class ContainerConf { + private String name; + private int cpus; + private int memory; + private int cards; + private List runCmd; + private List runArgs; + private List ports; + private Map env; + private ImageConf image; + private List volumeMounts; + private ProbeConf startupsProbe; + private ProbeConf readinessProbe; + private ProbeConf livenessProbe; + private LifecycleHandlerConf postStart; + private LifecycleHandlerConf preStop; + } + + @Getter + @Setter + @ToString + public static class PortConf { + private String protocol; + private String name; + private int port; + } + + @Getter + @Setter + @ToString + public static class ImageConf { + private int imageType; + private String imageAddr; + private String imagePullUser; + private String imagePullPass; + } + + @Getter + @Setter + @ToString + public static class ProbeConf { + private int initialDelaySeconds; + private int timeoutSeconds; + private int periodSeconds; + private int successThreshold; + private int failureThreshold; + private ProbeHandlerConf handler; + } + + @Getter + @Setter + @ToString + public static class ProbeHandlerConf { + private ExecAction exec; + private HTTPGetAction httpGet; + private TCPSocketAction tcpSocketAction; + } + + @Getter + @Setter + @ToString + public static class LifecycleHandlerConf { + private ExecAction exec; + private HTTPGetAction httpGet; + private TCPSocketAction tcpSocket; + private int sleepSec; + } + + @Getter + @Setter + @ToString + public static class ExecAction { + private List command; + } + + @Getter + @Setter + @ToString + public static class HTTPGetAction { + private String path; + private int port; + } + + @Getter + @Setter + @ToString + public static class TCPSocketAction { + private int port; + } + + + @Getter + @Setter + @ToString + public static class VolumnMountConf { + private String volumnName; + private String dstPath; + private boolean readOnly; + } + + @Getter + @Setter + @ToString + public static class VolumnConf { + private String volumeType; + private String volumnName; + private PFSConfig pfs; + private HostPathConfig hostpath; + } + + @Getter + @Setter + @ToString + public static class PFSConfig { + private String instanceId; + private String instanceType; + private String hostMountPath; + private String posixMountTargets; + private String clusterIP; + private String clientID; + private String clusterPort; + private String srcPath; + } + + @Getter + @Setter + @ToString + public static class HostPathConfig { + @JsonProperty("SrcPath") + private String srcPath; + } + + @Getter + @Setter + @ToString + public static class AppStatus { + private AccessIPConf accessIPs; + private List accessPorts; + private String blbShortId; + } + + @Getter + @Setter + @ToString + public static class AccessIPConf { + private String internal; + private String external; + } + + @Getter + @Setter + @ToString + public static class AccessPortConf { + private String name; + private long containerPort; + private long servicePort; + } + + @Getter + @Setter + @ToString + public static class AccessConf { + private boolean publicAccess; + private String eip; + } + + @Getter + @Setter + @ToString + public static class LogConf { + private boolean persistent; + } + + @Getter + @Setter + @ToString + public static class DeployConf { + private CanaryStrategyConf canaryStrategy; + } + + @Getter + @Setter + @ToString + public static class CanaryStrategyConf { + private int maxSurge; + private int maxUnavailable; + } + + @Getter + @Setter + @ToString + public static class Misc { + private Map podLabels; + private Map podAnnotations; + private long gracePeriodSec; + } + + @Override + public String toString() { + return "AppDetailsResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/BlockPodRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/BlockPodRequest.java new file mode 100644 index 00000000..d26e3e8b --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/BlockPodRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class BlockPodRequest extends AbstractBceRequest { + + private String appId; + private String insID; + private boolean block; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BlockPodRequest with credentials. + */ + public BlockPodRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/BlockPodResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/BlockPodResponse.java new file mode 100644 index 00000000..ff967880 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/BlockPodResponse.java @@ -0,0 +1,28 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class BlockPodResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + + @Override + public String toString() { + return "BlockPodResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/CreateAppRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/CreateAppRequest.java new file mode 100644 index 00000000..2f80fd62 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/CreateAppRequest.java @@ -0,0 +1,317 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; +import java.util.Map; + +@Getter +@Setter +@ToString +public class CreateAppRequest extends AbstractBceRequest { + private String appName; + private String chipType; + private int insCount; + private ResPoolConf resPool; + private StorageConf storage; + private List containers; + private AccessConf access; + private LogConf log; + private DeployConf deploy; + private Misc misc; + + @Getter + @Setter + @ToString + public static class ResPoolConf { + private String resPoolId; + private String queue; + + public ResPoolConf(String resPoolId, String queue) { + this.resPoolId = resPoolId; + this.queue = queue; + } + } + + @Getter + @Setter + @ToString + public static class StorageConf { + private int shmSize; + private List volumns; + + public StorageConf(int shmSize, List volumns) { + this.shmSize = shmSize; + this.volumns = volumns; + } + } + + @Getter + @Setter + @ToString + public static class VolumnConf { + private String volumeType; + private String volumnName; + private PFSConfig pfs; + private HostPathConfig hostpath; + + public VolumnConf(String volumeType, String volumnName, PFSConfig pfs, HostPathConfig hostpath) { + this.volumeType = volumeType; + this.volumnName = volumnName; + this.pfs = pfs; + this.hostpath = hostpath; + } + } + + @Getter + @Setter + @ToString + public static class PFSConfig { + private String srcPath; + + public PFSConfig(String srcPath) { + this.srcPath = srcPath; + } + } + + @Getter + @Setter + @ToString + public static class HostPathConfig { + @JsonProperty("SrcPath") + private String srcPath; + + public HostPathConfig(String srcPath) { + this.srcPath = srcPath; + } + } + + @Getter + @Setter + @ToString + public static class AccessConf { + private boolean publicAccess; + private String eip; + + public AccessConf(boolean publicAccess, String eip) { + this.publicAccess = publicAccess; + this.eip = eip; + } + } + + @Getter + @Setter + @ToString + public static class LogConf { + private boolean persistent; + + public LogConf(boolean persistent) { + this.persistent = persistent; + } + } + + @Getter + @Setter + @ToString + public static class DeployConf { + private CanaryStrategyConf canaryStrategy; + + public DeployConf(CanaryStrategyConf canaryStrategy) { + this.canaryStrategy = canaryStrategy; + } + } + + @Getter + @Setter + @ToString + public static class CanaryStrategyConf { + private int maxSurge; + private int maxUnavailable; + + public CanaryStrategyConf(int maxSurge, int maxUnavailable) { + this.maxSurge = maxSurge; + this.maxUnavailable = maxUnavailable; + } + } + + @Getter + @Setter + @ToString + public static class Misc { + private Map podLabels; + private Map podAnnotations; + + public Misc(Map podLabels, Map podAnnotations) { + this.podLabels = podLabels; + this.podAnnotations = podAnnotations; + } + } + + @Getter + @Setter + @ToString + public static class ContainerConf { + private String name; + private int cpus; + private int memory; + private int cards; + private List runCmd; + private List runArgs; + private List ports; + private Map env; + private ImageConf image; + private List volumeMounts; + private ProbeConf startupsProbe; + private ProbeConf readinessProbe; + private ProbeConf livenessProbe; + + public ContainerConf(String name, int cpus, int memory, int cards, List runCmd, List runArgs, List ports + , Map env, ImageConf image, List volumeMounts, ProbeConf startupsProbe, ProbeConf readinessProbe + , ProbeConf livenessProbe) { + this.name = name; + this.cpus = cpus; + this.memory = memory; + this.cards = cards; + this.runCmd = runCmd; + this.runArgs = runArgs; + this.ports = ports; + this.env = env; + this.image = image; + this.volumeMounts = volumeMounts; + this.startupsProbe = startupsProbe; + this.readinessProbe = readinessProbe; + this.livenessProbe = livenessProbe; + } + } + + @Getter + @Setter + @ToString + public static class PortConf { + private int port; + + public PortConf(int port) { + this.port = port; + } + } + + @Getter + @Setter + @ToString + public static class ImageConf { + private int imageType; + private String imageAddr; + private String imagePullUser; + private String imagePullPass; + + public ImageConf(int imageType, String imageAddr, String imagePullUser, String imagePullPass) { + this.imageType = imageType; + this.imageAddr = imageAddr; + this.imagePullUser = imagePullUser; + this.imagePullPass = imagePullPass; + } + } + + @Getter + @Setter + @ToString + public static class VolumnMountConf { + private String volumnName; + private String dstPath; + private boolean readOnly; + + public VolumnMountConf(String volumnName, String dstPath, boolean readOnly) { + this.volumnName = volumnName; + this.dstPath = dstPath; + this.readOnly = readOnly; + } + } + + @Getter + @Setter + @ToString + public static class ProbeConf { + private int initialDelaySeconds; + private int timeoutSeconds; + private int periodSeconds; + private int successThreshold; + private int failureThreshold; + private ProbeHandlerConf handler; + + public ProbeConf(int initialDelaySeconds, int timeoutSeconds, int periodSeconds, int successThreshold, int failureThreshold, ProbeHandlerConf handler) { + this.initialDelaySeconds = initialDelaySeconds; + this.timeoutSeconds = timeoutSeconds; + this.periodSeconds = periodSeconds; + this.successThreshold = successThreshold; + this.failureThreshold = failureThreshold; + this.handler = handler; + } + } + + @Getter + @Setter + @ToString + public static class ProbeHandlerConf { + private ExecAction exec; + private HTTPGetAction httpGet; + private TCPSocketAction tcpSocketAction; + + public ProbeHandlerConf(ExecAction exec, HTTPGetAction httpGet, TCPSocketAction tcpSocketAction) { + this.exec = exec; + this.httpGet = httpGet; + this.tcpSocketAction = tcpSocketAction; + } + } + + @Getter + @Setter + @ToString + public static class ExecAction { + private List command; + + public ExecAction(List command) { + this.command = command; + } + } + + @Getter + @Setter + @ToString + public static class HTTPGetAction { + private String path; + private int port; + + public HTTPGetAction(String path, int port) { + this.path = path; + this.port = port; + } + } + + @Getter + @Setter + @ToString + public static class TCPSocketAction { + private int port; + + public TCPSocketAction(int port) { + this.port = port; + } + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateAppRequest with credentials. + */ + public CreateAppRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/CreateAppResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/CreateAppResponse.java new file mode 100644 index 00000000..3d79f29b --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/CreateAppResponse.java @@ -0,0 +1,41 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +public class CreateAppResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { + private String appId; + } + + @Override + public String toString() { + return "CreateAppResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/DeleteAppRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/DeleteAppRequest.java new file mode 100644 index 00000000..f39b48ec --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/DeleteAppRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class DeleteAppRequest extends AbstractBceRequest { + + private String appId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteAppRequest with credentials. + */ + public DeleteAppRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/DeleteAppResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/DeleteAppResponse.java new file mode 100644 index 00000000..9030ff0e --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/DeleteAppResponse.java @@ -0,0 +1,28 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class DeleteAppResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + + @Override + public String toString() { + return "DeleteAppResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/DeletePodRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/DeletePodRequest.java new file mode 100644 index 00000000..f431904e --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/DeletePodRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class DeletePodRequest extends AbstractBceRequest { + + private String appId; + private String insID; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeletePodRequest with credentials. + */ + public DeletePodRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/DeletePodResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/DeletePodResponse.java new file mode 100644 index 00000000..aa48cd58 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/DeletePodResponse.java @@ -0,0 +1,28 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class DeletePodResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + + @Override + public String toString() { + return "DeletePodResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListAppRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListAppRequest.java new file mode 100644 index 00000000..901e438c --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListAppRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Setter; +import lombok.Getter; + +@Getter +@Setter +public class ListAppRequest extends AbstractBceRequest { + + private int pageNo; + private int pageSize; + private String keyword; + private String order; + private String orderBy; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListAppRequest with credentials. + */ + public ListAppRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListAppResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListAppResponse.java new file mode 100644 index 00000000..f9fac042 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListAppResponse.java @@ -0,0 +1,82 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +@Getter +@Setter +public class ListAppResponse extends AbstractBceResponse { + + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { + /* + * 应用个数 + */ + private int count; + /* + * 应用列表具体内容 + */ + private List list; + } + + @Getter + @Setter + public static class AppModel { + private String appId; + private String appName; + private String creator; + private int ctime; + private int mtime; + private boolean publicAccess; + private String region; + private String resPoolId; + private String resPoolName; + private String resQueue; + + @Override + public String toString() { + return "AppModel{" + "\n" + + "\t\t appId = " + appId + "\n" + + "\t\t appName = " + appName + "\n" + + "\t\t creator = " + creator + "\n" + + "\t\t ctime = " + ctime + "\n" + + "\t\t mtime = " + mtime + "\n" + + "\t\t publicAccess = " + publicAccess + "\n" + + "\t\t region = " + region + "\n" + + "\t\t resPoolId = " + resPoolId + "\n" + + "\t\t resPoolName = " + resPoolName + "\n" + + "\t\t resQueue = " + resQueue + "\n" + + "\t }"; + } + } + + @Override + public String toString() { + return "LisAppResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListChangeRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListChangeRequest.java new file mode 100644 index 00000000..803883f4 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListChangeRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ListChangeRequest extends AbstractBceRequest { + + private String appId; + private int changeType; + private String order; + private String orderBy; + private int pageNo; + private int pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListChangeRequest with credentials. + */ + public ListChangeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListChangeResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListChangeResponse.java new file mode 100644 index 00000000..42f9e7d5 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListChangeResponse.java @@ -0,0 +1,73 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +@Getter +@Setter +public class ListChangeResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { + /* + * 应用个数 + */ + private int count; + /* + * 应用列表具体内容 + */ + private List list; + } + + @Getter + @Setter + public static class AppChangeRecord { + private String changeId; + private String prev; + private int changeType; + private String shortDesc; + private String creator; + private int ctime; + + @Override + public String toString() { + return "AppChangeRecord{" + "\n" + + "\t\t changeId = " + changeId + "\n" + + "\t\t prev = " + prev + "\n" + + "\t\t changeType = " + changeType + "\n" + + "\t\t shortDesc = " + shortDesc + "\n" + + "\t\t creator = " + creator + "\n" + + "\t\t ctime = " + ctime + "\n" + + "\t }"; + } + } + + @Override + public String toString() { + return "ListChangeResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListPodRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListPodRequest.java new file mode 100644 index 00000000..36c6bf91 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListPodRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ListPodRequest extends AbstractBceRequest { + + private String appId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListPodRequest with credentials. + */ + public ListPodRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListPodResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListPodResponse.java new file mode 100644 index 00000000..9093958e --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListPodResponse.java @@ -0,0 +1,228 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; +import java.util.Map; + +@Getter +@Setter +public class ListPodResponse extends AbstractBceResponse { + + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { +// private String resPoolId; +// private String resPoolName; +// private String queue; + private List list; + } + + @Getter + @Setter + public static class InsInfo { + private String insID; + private List containers; + private InsStatus status; + + @Override + public String toString() { + return "InsInfo{" + "\n" + + "\t\t insID = " + insID + "\n" + + "\t\t containers = " + containers + "\n" + + "\t\t status = " + status + "\n" + + "\t }"; + } + } + + @Getter + @Setter + public static class ContainerInfo { + private String containerId; + private ContainerConf container; + private ContainerStatus status; + + @Override + public String toString() { + return "ContainerInfo{" + "\n" + + "\t\t\t containerId = " + containerId + "\n" + + "\t\t\t container = " + container + "\n" + + "\t\t\t status = " + status + "\n" + + "\t\t }"; + } + } + + @Getter + @Setter + @ToString + public static class ContainerConf { + private String name; + private int cpus; + private int memory; + private int cards; + private List runCmd; + private List runArgs; + private List ports; + private Map env; + private ImageConf image; + private List volumeMounts; + private ProbeConf startupsProbe; + private ProbeConf readinessProbe; + private ProbeConf livenessProbe; + private LifecycleHandlerConf postStart; + private LifecycleHandlerConf preStop; + + @Override + public String toString() { + return "ContainerConf{" + "\n" + + "\t\t\t\t name = " + name + "\n" + + "\t\t\t\t cpus = " + cpus + "\n" + + "\t\t\t\t memory = " + memory + "\n" + + "\t\t\t\t cards = " + cards + "\n" + + "\t\t\t\t runCmd = " + runCmd + "\n" + + "\t\t\t\t runArgs = " + runArgs + "\n" + + "\t\t\t\t ports = " + ports + "\n" + + "\t\t\t\t env = " + env + "\n" + + "\t\t\t\t image = " + image + "\n" + + "\t\t\t\t volumeMounts = " + volumeMounts + "\n" + + "\t\t\t\t startupsProbe = " + startupsProbe + "\n" + + "\t\t\t\t readinessProbe = " + readinessProbe + "\n" + + "\t\t\t\t volumeMounts = " + livenessProbe + "\n" + + "\t\t\t\t startupsProbe = " + postStart + "\n" + + "\t\t\t\t readinessProbe = " + preStop + "\n" + + "\t\t\t }"; + } + } + + @Getter + @Setter + @ToString + public static class PortConf { + private String protocol; + private String name; + private int port; + } + + @Getter + @Setter + @ToString + public static class ImageConf { + private int imageType; + private String imageAddr; + private String imagePullUser; + private String imagePullPass; + } + + @Getter + @Setter + @ToString + public static class VolumnMountConf { + private String volumnName; + private String dstPath; + private boolean readOnly; + } + + @Getter + @Setter + @ToString + public static class ProbeConf { + private int initialDelaySeconds; + private int timeoutSeconds; + private int periodSeconds; + private int successThreshold; + private int failureThreshold; + private ProbeHandlerConf handler; + } + + @Getter + @Setter + @ToString + public static class ProbeHandlerConf { + private ExecAction exec; + private HTTPGetAction httpGet; + private TCPSocketAction tcpSocketAction; + } + + @Getter + @Setter + @ToString + public static class LifecycleHandlerConf { + private ExecAction exec; + private HTTPGetAction httpGet; + private TCPSocketAction tcpSocket; + private int sleepSec; + } + + @Getter + @Setter + @ToString + public static class ExecAction { + private List command; + } + + @Getter + @Setter + @ToString + public static class HTTPGetAction { + private String path; + private int port; + } + + @Getter + @Setter + @ToString + public static class TCPSocketAction { + private int port; + } + + + @Getter + @Setter + @ToString + public static class ContainerStatus { + private String containerStatus; + private int ctime; + private String reason; + } + + @Getter + @Setter + @ToString + public static class InsStatus { + private boolean blocked; + private String insStatus; + private int ctime; + private int availableContainers; + private int totalContainers; + private String podIP; + private String nodeIP; + } + + @Override + public String toString() { + return "ListPodResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListResPoolBriefRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListResPoolBriefRequest.java new file mode 100644 index 00000000..4541ab5f --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListResPoolBriefRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ListResPoolBriefRequest extends AbstractBceRequest { + + private int pageNo; + private int pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListResPoolBriefRequest with credentials. + */ + public ListResPoolBriefRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListResPoolBriefResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListResPoolBriefResponse.java new file mode 100644 index 00000000..651fca2c --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListResPoolBriefResponse.java @@ -0,0 +1,78 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +@Getter +@Setter +public class ListResPoolBriefResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { + private List resPools; + + @Getter + @Setter + public static class ResPoolBriefInfo { + private String resPoolId; + private String resPoolName; + private String associatedPfsID; + @JsonProperty("ClusterType") + private String clusterType; + @JsonProperty("Description") + private String description; + @JsonProperty("ForbidDelete") + private boolean forbidDelete; + @JsonProperty("K8sVersion") + private String k8sVersion; + private String createdAt; + private String updatedAt; + private String phase; + + @Override + public String toString() { + return "ResPoolBriefInfo{" + "\n" + + "\t\t resPoolId = " + resPoolId + "\n" + + "\t\t resPoolName = " + resPoolName + "\n" + + "\t\t associatedPfsID = " + associatedPfsID + "\n" + + "\t\t ClusterType = " + clusterType + "\n" + + "\t\t Description = " + description + "\n" + + "\t\t ForbidDelete = " + forbidDelete + "\n" + + "\t\t K8sVersion = " + k8sVersion + "\n" + + "\t\t createdAt = " + createdAt + "\n" + + "\t\t updatedAt = " + updatedAt + "\n" + + "\t\t phase = " + phase + "\n" + + "\t }"; + } + } + } + + @Override + public String toString() { + return "ListResPoolBriefResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListStatsRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListStatsRequest.java new file mode 100644 index 00000000..8a69018d --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListStatsRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Setter +@Getter +public class ListStatsRequest extends AbstractBceRequest { + + private List appIds; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListStatsRequest with credentials. + */ + public ListStatsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ListStatsResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/ListStatsResponse.java new file mode 100644 index 00000000..a1b5f69b --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ListStatsResponse.java @@ -0,0 +1,60 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +@Getter +@Setter +public class ListStatsResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { + private Map apps; + } + + @Getter + @Setter + public static class StatsModel { + private int status; + private int availableIns; + private int totalIns; + + @Override + public String toString() { + return "StatsModel{" + "\n" + + "\t\t status = " + status + "\n" + + "\t\t availableIns = " + availableIns + "\n" + + "\t\t totalIns = " + totalIns + "\n" + + "\t }"; + } + } + + @Override + public String toString() { + return "ListStatsResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/PubAccessRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/PubAccessRequest.java new file mode 100644 index 00000000..16938150 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/PubAccessRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class PubAccessRequest extends AbstractBceRequest { + + private String appId; + private boolean publicAccess; + private String eip; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return PubAccessRequest with credentials. + */ + public PubAccessRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/PubAccessResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/PubAccessResponse.java new file mode 100644 index 00000000..a36e0ebd --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/PubAccessResponse.java @@ -0,0 +1,28 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class PubAccessResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + + @Override + public String toString() { + return "PubAccessResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ResPoolDetailRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/ResPoolDetailRequest.java new file mode 100644 index 00000000..50d84961 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ResPoolDetailRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ResPoolDetailRequest extends AbstractBceRequest { + + private String resPoolId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ResPoolDetailRequest with credentials. + */ + public ResPoolDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ResPoolDetailResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/ResPoolDetailResponse.java new file mode 100644 index 00000000..3d233750 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ResPoolDetailResponse.java @@ -0,0 +1,113 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; +import java.util.Map; + +@Getter +@Setter +public class ResPoolDetailResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { + private ResPoolInfo resPool; + private List resQueue; + } + + @Getter + @Setter + @ToString + public static class ResQueueInfo { + private String name; + private String nameSpace; + private String parentQueue; + private String queueType; + private String state; + private boolean reclaimable; + private boolean preemptable; + private Map capability; + private Map allocated; + private boolean disableOversell; + private String createdTime; + } + + @Getter + @Setter + @ToString + public static class ResPoolInfo { + private ResPoolMeta meta; + private ResPoolSpec spec; + private ResPoolStatus status; + } + + @Getter + @Setter + @ToString + public static class ResPoolMeta { + private String resPoolId; + private String resPoolName; + private String createdAt; + private String updatedAt; + } + + @Getter + @Setter + @ToString + public static class ResPoolSpec { + private String k8sVersion; + private String associatedPfsID; + private String region; + private List associatedCpromIDs; + private String createdBy; + private String description; + private boolean forbidDelete; + } + + @Getter + @Setter + @ToString + public static class ResPoolStatus { + private String phase; + @JsonProperty("GPUCount") + private ResPoolCountInfo gpuCount; + @JsonProperty("NodeCount") + private ResPoolCountInfo nodeCount; + } + + @Getter + @Setter + @ToString + public static class ResPoolCountInfo { + private int total; + private int used; + } + + @Override + public String toString() { + return "ResPoolDetailResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ScaleAppRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/ScaleAppRequest.java new file mode 100644 index 00000000..e0534da6 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ScaleAppRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ScaleAppRequest extends AbstractBceRequest { + + private String appId; + private int insCount; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ScaleAppRequest with credentials. + */ + public ScaleAppRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/ScaleAppResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/ScaleAppResponse.java new file mode 100644 index 00000000..5800493b --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/ScaleAppResponse.java @@ -0,0 +1,28 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ScaleAppResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + + @Override + public String toString() { + return "ScaleAppResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/UpdateAppRequest.java b/src/main/java/com/baidubce/services/aihc/model/inference/UpdateAppRequest.java new file mode 100644 index 00000000..174214c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/UpdateAppRequest.java @@ -0,0 +1,37 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class UpdateAppRequest extends AbstractBceRequest { + + private String appId; + private String shortDesc; + private String appName; + private String chipType; + private int insCount; + private CreateAppRequest.ResPoolConf resPool; + private CreateAppRequest.StorageConf storage; + private List containers; + private CreateAppRequest.AccessConf access; + private CreateAppRequest.LogConf log; + private CreateAppRequest.DeployConf deploy; + private CreateAppRequest.Misc misc; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateAppRequest with credentials. + */ + public UpdateAppRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/aihc/model/inference/UpdateAppResponse.java b/src/main/java/com/baidubce/services/aihc/model/inference/UpdateAppResponse.java new file mode 100644 index 00000000..9c7c888e --- /dev/null +++ b/src/main/java/com/baidubce/services/aihc/model/inference/UpdateAppResponse.java @@ -0,0 +1,41 @@ +package com.baidubce.services.aihc.model.inference; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +public class UpdateAppResponse extends AbstractBceResponse { + /* + * 错误码 + */ + private int errno; + /* + * 访问id + */ + @JsonProperty("request_id") + private String requestId; + /* + * data数据 + */ + private Data data; + + @Getter + @Setter + @ToString + public static class Data { + private String appId; + } + + @Override + public String toString() { + return "UpdateAppResponse{" + "\n" + + "\t errno = " + errno + "," + "\n" + + "\t request_id = " + requestId + "," + "\n" + + "\t data = " + data + "\n" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/as/AsGroupClient.java b/src/main/java/com/baidubce/services/as/AsGroupClient.java new file mode 100644 index 00000000..82e668ef --- /dev/null +++ b/src/main/java/com/baidubce/services/as/AsGroupClient.java @@ -0,0 +1,431 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.as.model.asgroup.AsGroupBatchRequest; +import com.baidubce.services.as.model.asgroup.AsGroupDeleteResponse; +import com.baidubce.services.as.model.asgroup.GetAsGroupRequest; +import com.baidubce.services.as.model.asgroup.GetAsGroupResponse; +import com.baidubce.services.as.model.asgroup.GroupCreateRequest; +import com.baidubce.services.as.model.asgroup.GroupCreateResponse; +import com.baidubce.services.as.model.asgroup.ListAsGroupRequest; +import com.baidubce.services.as.model.asgroup.ListAsGroupResponse; +import com.baidubce.services.as.model.asgroup.ListAsNodeRequest; +import com.baidubce.services.as.model.asgroup.ListAsNodeResponse; +import com.baidubce.services.as.model.rule.RuleDelRequest; +import com.baidubce.services.as.model.rule.RuleListQuery; +import com.baidubce.services.as.model.rule.RuleQuery; +import com.baidubce.services.as.model.rule.RuleRequest; +import com.baidubce.services.as.model.rule.CreateRuleResult; +import com.baidubce.services.as.model.rule.RuleVOListResponse; +import com.baidubce.services.as.model.rule.RuleVOResponse; +import com.baidubce.services.as.model.task.DetachNodeRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import org.apache.directory.api.util.Strings; +import org.apache.commons.collections.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkPattern; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Auto Scaling Group(asGroup). + */ +public class AsGroupClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsGroupClient.class); + + private static final String VERSION = "v1"; + private static final String GROUP = "group"; + private static final String RULE = "rule"; + private static final String GROUP_ID = "groupId"; + + private static final String GROUP_IDS = "groupIds"; + private static final String DELETE = "delete"; + private static final String NODE = "node"; + private static final String GROUP_ID_V2 = "groupid"; + + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling httpResponses from all asGroup service calls. + */ + private static final HttpResponseHandler[] as_group_handlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on asGroup. + */ + public AsGroupClient() { + this(new AsGroupClientConfiguration()); + } + + /** + * Constructs a new asGroup client using the client configuration to access asGroup. + * + * @param clientConfiguration The as client configuration options controlling how this client + * connects to asGroup (e.g. proxy settings, retry counts, etc). + */ + public AsGroupClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, as_group_handlers); + } + + /** + * Creates and initializes a new request object for the specified asGroup resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * Detach nodes from the specified auto scaling group + * + * @param detachNodeRequest The request containing all options for detaching the specified nodes. + * The groupId and nodes are required. + */ + public void detachNode(DetachNodeRequest detachNodeRequest) { + checkNotNull(detachNodeRequest, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(detachNodeRequest.getGroupId(), checkEmptyExceptionMessageFormat(GROUP_ID)); + checkNotNull(detachNodeRequest.getNodes(), checkEmptyExceptionMessageFormat("nodes")); + InternalRequest internalRequest = + this.createRequest(detachNodeRequest, HttpMethodName.POST, GROUP, detachNodeRequest.getGroupId()); + internalRequest.addParameter("detachNode", null); + fillPayload(internalRequest, detachNodeRequest); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create a new rule + * + * @param ruleRequest The request containing all options for creating the specified rule. + * @return The ruleId + */ + public CreateRuleResult createRule(RuleRequest ruleRequest) { + checkNotNull(ruleRequest, REQUEST_NULL_ERROR_MESSAGE); + checkAsRuleRequest(ruleRequest); + InternalRequest internalRequest = + this.createRequest(ruleRequest, HttpMethodName.POST, RULE); + fillPayload(internalRequest, ruleRequest); + return invokeHttpClient(internalRequest, CreateRuleResult.class); + } + + /** + * Update the specified rule + * + * @param ruleRequest The request containing all options for updating the specified rule. + */ + public void updateRule(RuleRequest ruleRequest) { + checkNotNull(ruleRequest, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(ruleRequest.getRuleId(), checkEmptyExceptionMessageFormat("ruleId")); + checkAsRuleRequest(ruleRequest); + InternalRequest internalRequest = + this.createRequest(ruleRequest, HttpMethodName.PUT, RULE, ruleRequest.getRuleId()); + fillPayload(internalRequest, ruleRequest); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query the rule list + * + * @param ruleListQuery The request containing all options for querying the rule list. + * @return The rule list + */ + public RuleVOListResponse queryRuleList(RuleListQuery ruleListQuery) { + checkNotNull(ruleListQuery, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(ruleListQuery, HttpMethodName.GET, RULE); + checkAsRuleQuery(ruleListQuery, internalRequest); + return invokeHttpClient(internalRequest, RuleVOListResponse.class); + } + + /** + * Query the specified rule + * + * @param ruleQuery The request containing all options for querying the specified rule. + * @return The rule + */ + public RuleVOResponse getRule(RuleQuery ruleQuery) { + checkNotNull(ruleQuery, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(ruleQuery.getRuleId(), checkEmptyExceptionMessageFormat("ruleId")); + InternalRequest internalRequest = + this.createRequest(ruleQuery, HttpMethodName.GET, RULE, ruleQuery.getRuleId()); + return invokeHttpClient(internalRequest, RuleVOResponse.class); + } + + /** + * Delete the specified rule + * + * @param ruleDelRequest The request containing all options for deleting the specified rule. + */ + public void deleteRule(RuleDelRequest ruleDelRequest) { + checkNotNull(ruleDelRequest, REQUEST_NULL_ERROR_MESSAGE); + checkRuleDelRequest(ruleDelRequest); + InternalRequest internalRequest = + this.createRequest(ruleDelRequest, HttpMethodName.POST, RULE); + internalRequest.addParameter("delete", null); + fillPayload(internalRequest, ruleDelRequest); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + private void checkRuleDelRequest(RuleDelRequest ruleDelRequest) { + if ((CollectionUtils.isEmpty(ruleDelRequest.getRuleIds()) && + CollectionUtils.isEmpty(ruleDelRequest.getGroupIds()))) { + throw new IllegalArgumentException("ruleIds and groupIds cannot be empty at the same time"); + } + } + + private void checkAsRuleQuery(RuleListQuery ruleListQuery, InternalRequest internalRequest) { + checkStringNotEmpty(ruleListQuery.getGroupId(), checkEmptyExceptionMessageFormat(GROUP_ID)); + checkNotNull(ruleListQuery.getPageNo(), checkEmptyExceptionMessageFormat("pageNo")); + + if (Strings.isNotEmpty(ruleListQuery.getGroupId())) { + internalRequest.addParameter("groupid", ruleListQuery.getGroupId()); + } + if (Strings.isNotEmpty(ruleListQuery.getKeyword())) { + internalRequest.addParameter("keyword", ruleListQuery.getKeyword()); + } + if (Strings.isNotEmpty(ruleListQuery.getKeywordType())) { + internalRequest.addParameter("keywordType", ruleListQuery.getKeywordType()); + } + if (Strings.isNotEmpty(ruleListQuery.getOrder())) { + internalRequest.addParameter("order", ruleListQuery.getOrder()); + } + if (Strings.isNotEmpty(ruleListQuery.getOrderBy())) { + internalRequest.addParameter("orderBy", ruleListQuery.getOrderBy()); + } + if (ruleListQuery.getPageNo() != null) { + internalRequest.addParameter("pageNo", String.valueOf(ruleListQuery.getPageNo())); + } + if (ruleListQuery.getPageSize() != null) { + internalRequest.addParameter("pageSize", String.valueOf(ruleListQuery.getPageSize())); + } + } + + private void checkAsRuleRequest(RuleRequest ruleRequest) { + checkStringNotEmpty(ruleRequest.getRuleName(), checkEmptyExceptionMessageFormat("ruleName")); + checkStringNotEmpty(ruleRequest.getGroupId(), checkEmptyExceptionMessageFormat(GROUP_ID)); + checkNotNull(ruleRequest.getState(), checkEmptyExceptionMessageFormat("state")); + checkNotNull(ruleRequest.getType(), checkEmptyExceptionMessageFormat("type")); + checkNotNull(ruleRequest.getActionType(), checkEmptyExceptionMessageFormat("actionType")); + checkNotNull(ruleRequest.getActionNum(), checkEmptyExceptionMessageFormat("actionNum")); + checkNotNull(ruleRequest.getCooldownInSec(), checkEmptyExceptionMessageFormat("cooldownInSec")); + if (Strings.isNotEmpty(ruleRequest.getPeriodStartTime())) { + checkUTC(ruleRequest.getPeriodStartTime()); + } + if (Strings.isNotEmpty(ruleRequest.getPeriodEndTime())) { + checkUTC(ruleRequest.getPeriodEndTime()); + } + } + + private void checkUTC(String time) { + String utcPattern = "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"; + checkPattern(time, utcPattern, "time should be UTC format"); + } + + /** + * create new auto scaling group + * + * @param request The request containing all options for creating the specified asGroup. + * @return the groupId and orderId + */ + public GroupCreateResponse createAsGroup(GroupCreateRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, GROUP); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, GroupCreateResponse.class); + } + + public AsGroupDeleteResponse deleteAsGroup(AsGroupBatchRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getGroupIds(), checkEmptyExceptionMessageFormat(GROUP_IDS)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, GROUP, DELETE); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AsGroupDeleteResponse.class); + AsGroupDeleteResponse response = new AsGroupDeleteResponse(); + response.setGroupIds(request.getGroupIds()); + return response; + } + + + /** + * List detailed information of all auto scaling groups + * + * @param request The request containing all options for querying the asGroup list. + * @return auto scaling group list + */ + public ListAsGroupResponse listAsGroup(ListAsGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, GROUP); + checkAsGroupListQuery(request, internalRequest); + return invokeHttpClient(internalRequest, ListAsGroupResponse.class); + } + + private void checkAsGroupListQuery(ListAsGroupRequest request, InternalRequest internalRequest) { + checkNotNull(request.getPageNo(), checkEmptyExceptionMessageFormat("pageNo")); + if (Strings.isNotEmpty(request.getKeyword())) { + internalRequest.addParameter("keyword", request.getKeyword()); + } + if (Strings.isNotEmpty(request.getKeywordType())) { + internalRequest.addParameter("keywordType", request.getKeywordType()); + } + if (Strings.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + if (Strings.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + } + + /** + * Query detailed information about a single auto scaling group. + * + * @param request The request containing all options for querying the information of the specified asGroup. + */ + public GetAsGroupResponse getAsGroupDetail(GetAsGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getGroupId(), checkEmptyExceptionMessageFormat(GROUP_ID)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, GROUP, request.getGroupId()); + return invokeHttpClient(internalRequest, GetAsGroupResponse.class); + } + + /** + * Query the detailed information of the nodes in the specified auto scaling group. + * + * @param request The request containing all options for querying the asNode list. + * @return List of node details. + */ + public ListAsNodeResponse listAsNode(ListAsNodeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getGroupId(), checkEmptyExceptionMessageFormat(GROUP_ID)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, NODE); + checkAsGroupNodeListQuery(request, internalRequest); + internalRequest.addParameter(GROUP_ID_V2, request.getGroupId()); + + return invokeHttpClient(internalRequest, ListAsNodeResponse.class); + } + + private void checkAsGroupNodeListQuery(ListAsNodeRequest request, InternalRequest internalRequest) { + checkNotNull(request.getPageNo(), checkEmptyExceptionMessageFormat("pageNo")); + if (Strings.isNotEmpty(request.getKeyword())) { + internalRequest.addParameter("keyword", request.getKeyword()); + } + if (Strings.isNotEmpty(request.getKeywordType())) { + internalRequest.addParameter("keywordType", request.getKeywordType()); + } + if (Strings.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + if (Strings.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + } +} diff --git a/src/main/java/com/baidubce/services/as/AsGroupClientConfiguration.java b/src/main/java/com/baidubce/services/as/AsGroupClientConfiguration.java new file mode 100644 index 00000000..fc0c4ad8 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/AsGroupClientConfiguration.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for asGroup service. + */ +public class AsGroupClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/as/model/AsEipModel.java b/src/main/java/com/baidubce/services/as/model/AsEipModel.java new file mode 100644 index 00000000..0d4713d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/AsEipModel.java @@ -0,0 +1,75 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model; + +public class AsEipModel { + /** + * Maximum bandwidth in Mbps. + */ + private int bandwidthInMbps; + + /** + * Public IP. + */ + private String address; + + /** + * The status of EIP. + */ + private String eipStatus; + + /** + * Instance ID of Elastic public network IP + */ + private String eipAllocationId; + + public int getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getEipStatus() { + return eipStatus; + } + + public void setEipStatus(String eipStatus) { + this.eipStatus = eipStatus; + } + + public String getEipAllocationId() { + return eipAllocationId; + } + + public void setEipAllocationId(String eipAllocationId) { + this.eipAllocationId = eipAllocationId; + } + + @Override + public String toString() { + return "AsEipModel{" + + "bandwidthInMbps=" + bandwidthInMbps + + ", address='" + address + '\'' + + ", eipStatus='" + eipStatus + '\'' + + ", eipAllocationId='" + eipAllocationId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/NodeModel.java b/src/main/java/com/baidubce/services/as/model/NodeModel.java new file mode 100644 index 00000000..7a4bf0a0 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/NodeModel.java @@ -0,0 +1,205 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model; + +import com.baidubce.services.as.model.asgroup.TagInfo; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +public class NodeModel { + private String instanceId; + private String instanceName; + private String floatingIp; + private String internalIp; + private String status; + private String payment; + private int cpuCount; + private int memoryCapacityInGB; + private String instanceType; + private int sysDiskInGB; + private String subnetType; + @JsonProperty("isProtected") + private boolean protect; + private String createTime; + private String nodeType; + private AsEipModel eip; + private List tags; + private String groupId; + private boolean isManaged; + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public boolean isManaged() { + return isManaged; + } + + public void setManaged(boolean managed) { + isManaged = managed; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getFloatingIp() { + return floatingIp; + } + + public void setFloatingIp(String floatingIp) { + this.floatingIp = floatingIp; + } + + public String getInternalIp() { + return internalIp; + } + + public void setInternalIp(String internalIp) { + this.internalIp = internalIp; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPayment() { + return payment; + } + + public void setPayment(String payment) { + this.payment = payment; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public int getSysDiskInGB() { + return sysDiskInGB; + } + + public void setSysDiskInGB(int sysDiskInGB) { + this.sysDiskInGB = sysDiskInGB; + } + + public String getSubnetType() { + return subnetType; + } + + public void setSubnetType(String subnetType) { + this.subnetType = subnetType; + } + + public boolean isProtect() { + return protect; + } + + public void setProtect(boolean protect) { + this.protect = protect; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getNodeType() { + return nodeType; + } + + public void setNodeType(String nodeType) { + this.nodeType = nodeType; + } + + public AsEipModel getEip() { + return eip; + } + + public void setEip(AsEipModel eip) { + this.eip = eip; + } + + @Override + public String toString() { + return "NodeModel{" + + "instanceId='" + instanceId + '\'' + + ", instanceName='" + instanceName + '\'' + + ", floatingIp='" + floatingIp + '\'' + + ", internalIp='" + internalIp + '\'' + + ", status='" + status + '\'' + + ", payment='" + payment + '\'' + + ", cpuCount=" + cpuCount + + ", memoryCapacityInGB=" + memoryCapacityInGB + + ", instanceType='" + instanceType + '\'' + + ", sysDiskInGB=" + sysDiskInGB + + ", subnetType='" + subnetType + '\'' + + ", protect=" + protect + + ", createTime='" + createTime + '\'' + + ", nodeType='" + nodeType + '\'' + + ", eip=" + eip + + ", tags=" + tags + + ", groupId='" + groupId + '\'' + + ", isManaged=" + isManaged + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/AdjustAsGroupRequest.java b/src/main/java/com/baidubce/services/as/model/asgroup/AdjustAsGroupRequest.java new file mode 100644 index 00000000..aa2b2b62 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/AdjustAsGroupRequest.java @@ -0,0 +1,97 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for adjusting the asGroup. + */ +public class AdjustAsGroupRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The auto scaling group ID of the nodes to be adjusted + */ + @JsonIgnore + private String groupId; + + /** + * Number of nodes to be adjusted + */ + private int actionNum; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public int getActionNum() { + return actionNum; + } + + public void setActionNum(int actionNum) { + this.actionNum = actionNum; + } + + @Override + public String toString() { + return "AdjustAsGroupRequest{" + + "clientToken='" + clientToken + '\'' + + ", groupId='" + groupId + '\'' + + ", actionNum=" + actionNum + + '}'; + } + + public AdjustAsGroupRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public AdjustAsGroupRequest withGroupId(String groupId) { + this.groupId = groupId; + return this; + } + + public AdjustAsGroupRequest withActionNum(int actionNum) { + this.actionNum = actionNum; + return this; + } + + @Override + public AdjustAsGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/AdjustAsGroupResponse.java b/src/main/java/com/baidubce/services/as/model/asgroup/AdjustAsGroupResponse.java new file mode 100644 index 00000000..6034e30c --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/AdjustAsGroupResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of adjusting the asGroup. + */ +public class AdjustAsGroupResponse extends AbstractBceResponse { + /** + * The id of adjust task. + */ + private String taskId; + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + @Override + public String toString() { + return "AdjustAsGroupResponse{" + + "taskId='" + taskId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/AsGroup.java b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroup.java new file mode 100644 index 00000000..193cf25c --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroup.java @@ -0,0 +1,158 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.services.as.model.zone.ZoneInfo; + +import java.util.List; + +/** + * The information of the asGroup. + */ +public class AsGroup { + /** + * The id of specified auto scaling group. + */ + private String groupId; + + /** + * The name of specified auto scaling group. + */ + private String groupName; + + /** + * The region where the auto scaling group is located + */ + private String region; + + /** + * Current status of the auto scaling group + */ + private AsGroupStatus status; + + /** + * The if of vpc + */ + private String vpcId; + + /** + * Number of nodes in the auto scaling group + */ + private int nodeNum; + + + private String createTime; + + private List zoneInfo; + + /** + * The spec of auto scaling group + */ + private GroupConfig groupConfig; + + private String blbId; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public AsGroupStatus getStatus() { + return status; + } + + public void setStatus(AsGroupStatus status) { + this.status = status; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public int getNodeNum() { + return nodeNum; + } + + public void setNodeNum(int nodeNum) { + this.nodeNum = nodeNum; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public List getZoneInfo() { + return zoneInfo; + } + + public void setZoneInfo(List zoneInfo) { + this.zoneInfo = zoneInfo; + } + + public GroupConfig getGroupConfig() { + return groupConfig; + } + + public void setGroupConfig(GroupConfig groupConfig) { + this.groupConfig = groupConfig; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + @Override + public String toString() { + return "AsGroup{" + + "groupId='" + groupId + '\'' + + ", groupName='" + groupName + '\'' + + ", region='" + region + '\'' + + ", status=" + status + + ", vpcId='" + vpcId + '\'' + + ", nodeNum=" + nodeNum + + ", createTime='" + createTime + '\'' + + ", zoneInfo=" + zoneInfo + + ", groupConfig=" + groupConfig + + ", blbId='" + blbId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupAction.java b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupAction.java new file mode 100644 index 00000000..4bcd2edd --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupAction.java @@ -0,0 +1,23 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +/** + * The action for operating the asGroup. + */ +public enum AsGroupAction { + /** + * Add node under specified auto scaling group. + */ + increase, + decrease, + adjust, +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupBatchRequest.java b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupBatchRequest.java new file mode 100644 index 00000000..ad532605 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupBatchRequest.java @@ -0,0 +1,18 @@ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class AsGroupBatchRequest extends AbstractBceRequest { + private List groupIds; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupDeleteResponse.java b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupDeleteResponse.java new file mode 100644 index 00000000..bc6cc547 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupDeleteResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class AsGroupDeleteResponse extends AbstractBceResponse { + private List groupIds; +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupStatus.java b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupStatus.java new file mode 100644 index 00000000..ed704b3f --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/AsGroupStatus.java @@ -0,0 +1,29 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +/** + * The status of the asGroup. + */ +public enum AsGroupStatus { + CREATING, + RUNNING, + SCALING_UP, + SCALING_DOWN, + ATTACHING_NODE, + DETACHING_NODE, + DELETING, + BINDING_BLB, + UNBINDING_BLB, + COOLDOWN, + PAUSE, + DELETED +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/AssignTagInfo.java b/src/main/java/com/baidubce/services/as/model/asgroup/AssignTagInfo.java new file mode 100644 index 00000000..8b2e8203 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/AssignTagInfo.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.as.model.asgroup; + +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangzhongyang + * @Date 2020/12/2 3:47 下午 + */ +@Data +public class AssignTagInfo { + private boolean relationTag = false; + private List tags; +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/BccNameConfig.java b/src/main/java/com/baidubce/services/as/model/asgroup/BccNameConfig.java new file mode 100644 index 00000000..526725f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/BccNameConfig.java @@ -0,0 +1,11 @@ +package com.baidubce.services.as.model.asgroup; + +import lombok.Data; + +@Data +public class BccNameConfig { + private String bccName = ""; + private String bccHostname = ""; + private Boolean autoSeqSuffix = false; + private Boolean openHostnameDomain = false; +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/BillingInfo.java b/src/main/java/com/baidubce/services/as/model/asgroup/BillingInfo.java new file mode 100644 index 00000000..772f8857 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/BillingInfo.java @@ -0,0 +1,49 @@ +package com.baidubce.services.as.model.asgroup; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by xucongyang on 2018/06/25. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BillingInfo { + private String paymentTiming = "postpay"; + private Reservation reservation; + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public Reservation getReservation() { + return reservation; + } + + public void setReservation(Reservation reservation) { + this.reservation = reservation; + } + + public static class Reservation { + private int reservationLengthInMonth; + + public int getReservationLengthInMonth() { + return reservationLengthInMonth; + } + + public void setReservationLengthInMonth(int reservationLengthInMonth) { + this.reservationLengthInMonth = reservationLengthInMonth; + } + } + + @Override + public String toString() { + final StringBuffer sb = new StringBuffer("BillingInfo{"); + sb.append("paymentTiming='").append(paymentTiming).append('\''); + sb.append(", reservation=").append(reservation); + sb.append('}'); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/BlbInfo.java b/src/main/java/com/baidubce/services/as/model/asgroup/BlbInfo.java new file mode 100644 index 00000000..b2d6793c --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/BlbInfo.java @@ -0,0 +1,57 @@ +package com.baidubce.services.as.model.asgroup; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by xucongyang on 2018/06/25. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BlbInfo { + private String blbId; + private String blbName; + private String blbPublicIp; + private String blbType; + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public String getBlbName() { + return blbName; + } + + public void setBlbName(String blbName) { + this.blbName = blbName; + } + + public String getBlbType() { + return blbType; + } + + public void setBlbType(String blbType) { + this.blbType = blbType; + } + + public String getBlbPublicIp() { + return blbPublicIp; + } + + public void setBlbPublicIp(String blbPublicIp) { + this.blbPublicIp = blbPublicIp; + } + + @Override + public String toString() { + final StringBuffer sb = new StringBuffer("BlbInfo{"); + sb.append("blbId='").append(blbId).append('\''); + sb.append(", blbName='").append(blbName).append('\''); + sb.append(", blbType='").append(blbType).append('\''); + sb.append(", blbPublicIp='").append(blbPublicIp).append('\''); + sb.append('}'); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/CdsInfo.java b/src/main/java/com/baidubce/services/as/model/asgroup/CdsInfo.java new file mode 100644 index 00000000..cf825241 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/CdsInfo.java @@ -0,0 +1,59 @@ +package com.baidubce.services.as.model.asgroup; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * Created by xucongyang on 2018/06/25. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CdsInfo { + private String volumeType; + private int sizeInGB; + private String snapshotId; + private String snapshotName; + + public String getVolumeType() { + return volumeType; + } + + public void setVolumeType(String volumeType) { + this.volumeType = volumeType; + } + + public int getSizeInGB() { + return sizeInGB; + } + + public void setSizeInGB(int sizeInGB) { + this.sizeInGB = sizeInGB; + } + + public String getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + public String getSnapshotName() { + return snapshotName; + } + + public void setSnapshotName(String snapshotName) { + this.snapshotName = snapshotName; + } + + @Override + public String toString() { + final StringBuffer sb = new StringBuffer("CdsInfo{"); + sb.append("volumeType='").append(volumeType).append('\''); + sb.append(", sizeInGB=").append(sizeInGB); + sb.append(", snapshotId='").append(snapshotId).append('\''); + sb.append(", snapshotName='").append(snapshotName).append('\''); + sb.append('}'); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/CmdConfig.java b/src/main/java/com/baidubce/services/as/model/asgroup/CmdConfig.java new file mode 100644 index 00000000..43c5217f --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/CmdConfig.java @@ -0,0 +1,28 @@ +package com.baidubce.services.as.model.asgroup; + +import lombok.Data; + +@Data +public class CmdConfig { + // 是否配置缩容脚本 + private boolean hasDecreaseCmd; + // 缩容策略,失败暂停缩容、失败继续缩容:Proceed、Pause + private ExecCmdStrategyType decCmdStrategy = ExecCmdStrategyType.Proceed; + // 缩容脚本 + private String decCmdData = ""; + // 超时时间s + private int decCmdTimeout = 3600; + // 手动移出是否执行 + private boolean decCmdManual = false; + + // 是否配置扩容脚本 + private boolean hasIncreaseCmd; + // 扩容策略,失败暂停扩容、失败继续扩容:Proceed、Pause + private ExecCmdStrategyType incCmdStrategy; + // 扩容脚本 + private String incCmdData = ""; + // 超时时间s + private int incCmdTimeout = 3600; + // 手动移入是否执行 + private boolean incCmdManual = false; +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/DecreaseAsGroupRequest.java b/src/main/java/com/baidubce/services/as/model/asgroup/DecreaseAsGroupRequest.java new file mode 100644 index 00000000..b84c6a80 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/DecreaseAsGroupRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for decreasing the asGroup. + */ +public class DecreaseAsGroupRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The auto scaling group ID of the nodes to be decreased + */ + @JsonIgnore + private String groupId; + + /** + * Number of nodes to be decreased + */ + private int actionNum; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public int getActionNum() { + return actionNum; + } + + public void setActionNum(int actionNum) { + this.actionNum = actionNum; + } + + @Override + public String toString() { + return "DecreaseAsGroupRequest{" + + "clientToken='" + clientToken + '\'' + + ", groupId='" + groupId + '\'' + + ", actionNum=" + actionNum + + '}'; + } + + @Override + public DecreaseAsGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/DecreaseAsGroupResponse.java b/src/main/java/com/baidubce/services/as/model/asgroup/DecreaseAsGroupResponse.java new file mode 100644 index 00000000..40a9a8d0 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/DecreaseAsGroupResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of decreasing the asGroup. + */ +public class DecreaseAsGroupResponse extends AbstractBceResponse { + /** + * The id of decrease task. + */ + private String taskId; + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + @Override + public String toString() { + return "DecreaseAsGroupResponse{" + + "taskId='" + taskId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/EipInfo.java b/src/main/java/com/baidubce/services/as/model/asgroup/EipInfo.java new file mode 100644 index 00000000..278b17a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/EipInfo.java @@ -0,0 +1,58 @@ +package com.baidubce.services.as.model.asgroup; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by xucongyang on 2018/06/25. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class EipInfo { + private Boolean ifBindEip = false; + private int bandwidthInMbps; + private String eipProductType = ""; + // eip线路 + private String purchaseType = ""; + + public String getPurchaseType() { + return purchaseType; + } + + public void setPurchaseType(String purchaseType) { + this.purchaseType = purchaseType; + } + + public Boolean getIfBindEip() { + return ifBindEip; + } + + public void setIfBindEip(Boolean ifBindEip) { + this.ifBindEip = ifBindEip; + } + + public int getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + + public String getEipProductType() { + return eipProductType; + } + + public void setEipProductType(String eipProductType) { + this.eipProductType = eipProductType; + } + + @Override + public String toString() { + final StringBuffer sb = new StringBuffer("EipInfo{"); + sb.append("ifBindEip=").append(ifBindEip); + sb.append(", bandwidthInMbps=").append(bandwidthInMbps); + sb.append(", eipProductType='").append(eipProductType).append('\''); + sb.append(", purchaseType='").append(purchaseType).append('\''); + sb.append('}'); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/ExecCmdStrategyType.java b/src/main/java/com/baidubce/services/as/model/asgroup/ExecCmdStrategyType.java new file mode 100644 index 00000000..70d26a43 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/ExecCmdStrategyType.java @@ -0,0 +1,15 @@ +package com.baidubce.services.as.model.asgroup; + +/** + * Created by dongjiawei on 2023/8/1. + */ +public enum ExecCmdStrategyType { + /** + * 失败继续 + */ + Proceed, + /** + * 失败暂停 + */ + Pause, +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/ExpansionStrategyType.java b/src/main/java/com/baidubce/services/as/model/asgroup/ExpansionStrategyType.java new file mode 100644 index 00000000..51c391d6 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/ExpansionStrategyType.java @@ -0,0 +1,8 @@ +package com.baidubce.services.as.model.asgroup; + +public enum ExpansionStrategyType { + + Balanced, + + Priority +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/GetAsGroupRequest.java b/src/main/java/com/baidubce/services/as/model/asgroup/GetAsGroupRequest.java new file mode 100644 index 00000000..246e885f --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/GetAsGroupRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for getting the asGroup. + */ +public class GetAsGroupRequest extends AbstractBceRequest { + + /** + * The auto scaling group ID being queried + */ + @JsonIgnore + private String groupId; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + @Override + public String toString() { + return "GetAsGroupRequest{" + + "groupId='" + groupId + '\'' + + '}'; + } + + @Override + public GetAsGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/GetAsGroupResponse.java b/src/main/java/com/baidubce/services/as/model/asgroup/GetAsGroupResponse.java new file mode 100644 index 00000000..d17e43c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/GetAsGroupResponse.java @@ -0,0 +1,176 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.VpcInfo; +import com.baidubce.services.as.model.zone.ZoneInfo; +import java.util.List; + +/** + * The response of getting the asGroup. + */ +public class GetAsGroupResponse extends AbstractBceResponse { + private String groupId; + private String groupName; + private String region; + private AsGroupStatus status; + private VpcInfo vpcInfo; + private String rdsIds; + private String scsIds; + private String createTime; + private List zoneInfo; + private String blbId; + private int nodeNum; + private GroupConfig config; + private String expansionStrategy; + private String shrinkageStrategy; + + public GroupConfig getConfig() { + return config; + } + + public void setConfig(GroupConfig config) { + this.config = config; + } + + public String getExpansionStrategy() { + return expansionStrategy; + } + + public void setExpansionStrategy(String expansionStrategy) { + this.expansionStrategy = expansionStrategy; + } + + public String getShrinkageStrategy() { + return shrinkageStrategy; + } + + public void setShrinkageStrategy(String shrinkageStrategy) { + this.shrinkageStrategy = shrinkageStrategy; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public AsGroupStatus getStatus() { + return status; + } + + public void setStatus(AsGroupStatus status) { + this.status = status; + } + + public VpcInfo getVpcInfo() { + return vpcInfo; + } + + public void setVpcInfo(VpcInfo vpcInfo) { + this.vpcInfo = vpcInfo; + } + + public String getRdsIds() { + return rdsIds; + } + + public void setRdsIds(String rdsIds) { + this.rdsIds = rdsIds; + } + + public String getScsIds() { + return scsIds; + } + + public void setScsIds(String scsIds) { + this.scsIds = scsIds; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public List getZoneInfo() { + return zoneInfo; + } + + public void setZoneInfo(List zoneInfo) { + this.zoneInfo = zoneInfo; + } + + public GroupConfig getGroupConfig() { + return config; + } + + public void setGroupConfig(GroupConfig groupConfig) { + this.config = groupConfig; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public int getNodeNum() { + return nodeNum; + } + + public void setNodeNum(int nodeNum) { + this.nodeNum = nodeNum; + } + + @Override + public String toString() { + return "GetAsGroupResponse{" + + "groupId='" + groupId + '\'' + + ", groupName='" + groupName + '\'' + + ", region='" + region + '\'' + + ", status=" + status + + ", vpcInfo=" + vpcInfo + + ", rdsIds='" + rdsIds + '\'' + + ", scsIds='" + scsIds + '\'' + + ", createTime='" + createTime + '\'' + + ", zoneInfo=" + zoneInfo + + ", blbId='" + blbId + '\'' + + ", nodeNum=" + nodeNum + + ", config=" + config + + ", expansionStrategy='" + expansionStrategy + '\'' + + ", shrinkageStrategy='" + shrinkageStrategy + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/GroupConfig.java b/src/main/java/com/baidubce/services/as/model/asgroup/GroupConfig.java new file mode 100644 index 00000000..4e6ffa2d --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/GroupConfig.java @@ -0,0 +1,24 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import lombok.Data; + +/** + * The config of the group. + */ +@Data +public class GroupConfig { + private int minNodeNum; + private int maxNodeNum; + private int cooldownInSec; + private int expectNum = -1; +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/GroupCreateRequest.java b/src/main/java/com/baidubce/services/as/model/asgroup/GroupCreateRequest.java new file mode 100644 index 00000000..1c12ca0e --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/GroupCreateRequest.java @@ -0,0 +1,245 @@ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.as.model.zone.ZoneInfo; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * Created by xucongyang on 2018/06/20. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GroupCreateRequest extends AbstractBceRequest { + + @JsonIgnore + private String clientToken; + + private String groupName; + + private List zoneInfo; + + private GroupConfig config; + + private List blb; + + private NodeInfo node; + + private List cds; + + private EipInfo eip; + + private BillingInfo billing = new BillingInfo(); + + private List rds; + + private List scs; + + private HealthCheckConfig healthCheck; + + private String expansionStrategy = ExpansionStrategyType.Priority.name(); + + private String shrinkageStrategy = ShrinkageStrategyType.Earlier.name(); + + private AssignTagInfo assignTagInfo; + + private String keypairId = ""; + + private String keypairName = ""; + + private List nodes; + + private CmdConfig cmdConfig; + + private BccNameConfig bccNameConfig; + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + public String getKeypairName() { + return keypairName; + } + + public void setKeypairName(String keypairName) { + this.keypairName = keypairName; + } + + public List getNodes() { + return nodes; + } + + public void setNodes(List nodes) { + this.nodes = nodes; + } + + public CmdConfig getCmdConfig() { + return cmdConfig; + } + + public void setCmdConfig(CmdConfig cmdConfig) { + this.cmdConfig = cmdConfig; + } + + public BccNameConfig getBccNameConfig() { + return bccNameConfig; + } + + public void setBccNameConfig(BccNameConfig bccNameConfig) { + this.bccNameConfig = bccNameConfig; + } + + public AssignTagInfo getAssignTagInfo() { + return assignTagInfo; + } + + public void setAssignTagInfo(AssignTagInfo assignTagInfo) { + this.assignTagInfo = assignTagInfo; + } + + public List getScs() { + return scs; + } + + public void setScs(List scs) { + this.scs = scs; + } + + public List getRds() { + return rds; + } + + public void setRds(List rds) { + this.rds = rds; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public List getZoneInfo() { + return zoneInfo; + } + + public void setZoneInfo(List zoneInfo) { + this.zoneInfo = zoneInfo; + } + + public GroupConfig getConfig() { + return config; + } + + public void setConfig(GroupConfig config) { + this.config = config; + } + + public List getBlb() { + return blb; + } + + public void setBlb(List blb) { + this.blb = blb; + } + + public NodeInfo getNode() { + return node; + } + + public void setNode(NodeInfo node) { + this.node = node; + } + + public List getCds() { + return cds; + } + + public void setCds(List cds) { + this.cds = cds; + } + + public EipInfo getEip() { + return eip; + } + + public void setEip(EipInfo eip) { + this.eip = eip; + } + + public BillingInfo getBilling() { + return billing; + } + + public void setBilling(BillingInfo billing) { + this.billing = billing; + } + + public HealthCheckConfig getHealthCheck() { + return healthCheck; + } + + public void setHealthCheck(HealthCheckConfig healthCheck) { + this.healthCheck = healthCheck; + } + + public String getExpansionStrategy() { + return expansionStrategy; + } + + public void setExpansionStrategy(String expansionStrategy) { + this.expansionStrategy = expansionStrategy; + } + + public String getShrinkageStrategy() { + return shrinkageStrategy; + } + + public void setShrinkageStrategy(String shrinkageStrategy) { + this.shrinkageStrategy = shrinkageStrategy; + } + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public String toString() { + final StringBuffer sb = new StringBuffer("GroupCreateRequest{"); + sb.append("groupName='").append(groupName).append('\''); + sb.append(", zoneInfo=").append(zoneInfo); + sb.append(", config=").append(config); + sb.append(", blb=").append(blb); + sb.append(", node=").append(node); + sb.append(", assignTagInfo=").append(assignTagInfo); + sb.append(", cds=").append(cds); + sb.append(", eip=").append(eip); + sb.append(", billing=").append(billing); + sb.append(", rds=").append(rds); + sb.append(", scs=").append(scs); + sb.append(", healthCheck=").append(healthCheck); + sb.append(", expansionStrategy=").append(expansionStrategy); + sb.append(", shrinkageStrategy=").append(shrinkageStrategy); + sb.append('}'); + return sb.toString(); + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/GroupCreateResponse.java b/src/main/java/com/baidubce/services/as/model/asgroup/GroupCreateResponse.java new file mode 100644 index 00000000..35ecd089 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/GroupCreateResponse.java @@ -0,0 +1,47 @@ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Created by xucongyang on 2018/07/19. + */ +public class GroupCreateResponse extends AbstractBceResponse { + + private String groupId; + private List orderId; + + + public GroupCreateResponse() { + + } + public GroupCreateResponse(NodesCreateResult nodesCreateResult) { + groupId = nodesCreateResult.getGroupId(); + orderId = nodesCreateResult.getOrderId(); + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public List getOrderId() { + return orderId; + } + + public void setOrderId(List orderId) { + this.orderId = orderId; + } + + @Override + public String toString() { + return "GroupCreateResponse{" + + "groupId='" + groupId + '\'' + + ", orderId=" + orderId + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/HealthCheckConfig.java b/src/main/java/com/baidubce/services/as/model/asgroup/HealthCheckConfig.java new file mode 100644 index 00000000..5398c633 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/HealthCheckConfig.java @@ -0,0 +1,31 @@ +package com.baidubce.services.as.model.asgroup; + +public class HealthCheckConfig { + private int healthCheckInterval; + private int graceTime; + + public int getHealthCheckInterval() { + return healthCheckInterval; + } + + public void setHealthCheckInterval(int healthCheckInterval) { + this.healthCheckInterval = healthCheckInterval; + } + + public int getGraceTime() { + return graceTime; + } + + public void setGraceTime(int graceTime) { + this.graceTime = graceTime; + } + + @Override + public String toString() { + final StringBuffer sb = new StringBuffer("HeathCheckConfig{"); + sb.append("healthCheckInterval=").append(healthCheckInterval); + sb.append(", graceTime=").append(graceTime); + sb.append('}'); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/IncreaseAsGroupRequest.java b/src/main/java/com/baidubce/services/as/model/asgroup/IncreaseAsGroupRequest.java new file mode 100644 index 00000000..9252bfe5 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/IncreaseAsGroupRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for increasing the asGroup. + */ +public class IncreaseAsGroupRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The auto scaling group ID of the nodes to be added + */ + @JsonIgnore + private String groupId; + + /** + * Number of new nodes + */ + private int nodeCount; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public int getNodeCount() { + return nodeCount; + } + + public void setNodeCount(int nodeCount) { + this.nodeCount = nodeCount; + } + + @Override + public String toString() { + return "IncreaseAsGroupRequest{" + + "clientToken='" + clientToken + '\'' + + ", groupId='" + groupId + '\'' + + ", nodeCount=" + nodeCount + + '}'; + } + + @Override + public IncreaseAsGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/IncreaseAsGroupResponse.java b/src/main/java/com/baidubce/services/as/model/asgroup/IncreaseAsGroupResponse.java new file mode 100644 index 00000000..18f70efe --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/IncreaseAsGroupResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response of increasing the asGroup. + */ +public class IncreaseAsGroupResponse extends AbstractBceResponse { + + /** + * Auto scaling group id. + */ + private String groupId; + + /** + * List of newly added instance IDs in the auto scaling group. + */ + private List instanceId; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public List getInstanceId() { + return instanceId; + } + + public void setInstanceId(List instanceId) { + this.instanceId = instanceId; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/ListAsGroupRequest.java b/src/main/java/com/baidubce/services/as/model/asgroup/ListAsGroupRequest.java new file mode 100644 index 00000000..aca07455 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/ListAsGroupRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the asGroup list. + */ +@Data +public class ListAsGroupRequest extends AbstractBceRequest { + /** + * 过滤规则的关键词 + * */ + private String keyword; + /** + * 关键词的类型 + * */ + private String keywordType; + /** + * 规则的顺序,默认为"desc" + * */ + private String order; + /** + * 排序规则的字段,默认为"createTime" + * */ + private String orderBy; + /** + * 页码,默认为1 + * */ + private Integer pageNo; + /** + * 页面大小,默认为1000 + * */ + private Integer pageSize; + + + @Override + public ListAsGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/ListAsGroupResponse.java b/src/main/java/com/baidubce/services/as/model/asgroup/ListAsGroupResponse.java new file mode 100644 index 00000000..dd524d4f --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/ListAsGroupResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * The response of getting the asGroup list. + */ +@Data +public class ListAsGroupResponse extends AbstractBceResponse { + // 排序字段 + private String orderBy = ""; + // 升序asc 或 降序desc 排序 + private String order = ""; + // 页码 + private int pageNo = 1; + // 一页条目数量 + private int pageSize = 0; + // 总条目数量 + private int totalCount = 0; + // 返回的asGroup列表 + private List result; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/ListAsNodeRequest.java b/src/main/java/com/baidubce/services/as/model/asgroup/ListAsNodeRequest.java new file mode 100644 index 00000000..c6e7877b --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/ListAsNodeRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the asNode list. + */ +@Data +public class ListAsNodeRequest extends AbstractBceRequest { + /** + * The ID of auto scaling group. + */ + private String groupId; + + /** + * 过滤规则的关键词 + * */ + private String keyword; + /** + * 关键词的类型 + * */ + private String keywordType; + /** + * 规则的顺序,默认为"desc" + * */ + private String order; + /** + * 排序规则的字段,默认为"createTime" + * */ + private String orderBy; + /** + * 页码,默认为1 + * */ + private Integer pageNo; + /** + * 页面大小,默认为1000 + * */ + private Integer pageSize; + + @Override + public ListAsNodeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/ListAsNodeResponse.java b/src/main/java/com/baidubce/services/as/model/asgroup/ListAsNodeResponse.java new file mode 100644 index 00000000..f9fc1556 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/ListAsNodeResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.as.model.NodeModel; +import lombok.Data; + +import java.util.List; + +/** + * The response of getting the asNode list. + */ +@Data +public class ListAsNodeResponse extends AbstractBceResponse { + /** + * node information + */ + private List result; + + // 排序字段 + private String orderBy = ""; + // 升序asc 或 降序desc 排序 + private String order = ""; + // 页码 + private int pageNo = 1; + // 一页条目数量 + private int pageSize = 0; + // 总条目数量 + private int totalCount = 0; + +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/NodeInfo.java b/src/main/java/com/baidubce/services/as/model/asgroup/NodeInfo.java new file mode 100644 index 00000000..57fce442 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/NodeInfo.java @@ -0,0 +1,63 @@ +package com.baidubce.services.as.model.asgroup; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.ToString; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by xucongyang on 2018/06/25. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +@ToString +public class NodeInfo { + private String spec = ""; + private int cpuCount; + private int memoryCapacityInGB; + private String sysDiskType; + private int sysDiskInGB; + // 本地盘 + private List ephemeralDisks; + private int instanceType; + private String gpuCard = ""; + private int gpuCount; + // fpga卡的属性 + private String fpgaCard = ""; + // fpga卡的数量 + private int fpgaCount; + private Boolean containsFpga = false; + // 昆仑卡的属性 + private String kunlunCard = ""; + // 昆仑卡的数量 + private int kunlunCount; + private String imageType; + private String imageId; + private String osType; + private String osName; + private String osVersion; + private String osArch; + private String securityGroupId; + private String adminPass; + // 只用于VO 返回模版详情用. 密码类型: "0"(随机); "1"(用户自定义) + private String adminPassType; + private String securityGroupName; + private int totalCount; + private String aspId = ""; + private String productType ; + private int priorities; + private String zoneSubnet; + private String bidModel; + private double bidPrice; + + @Data + @ToString + public static class EphemeralDisk { + private String storageType; + private int sizeInGB; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/NodesCreateResult.java b/src/main/java/com/baidubce/services/as/model/asgroup/NodesCreateResult.java new file mode 100644 index 00000000..ce7a8fb7 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/NodesCreateResult.java @@ -0,0 +1,44 @@ +package com.baidubce.services.as.model.asgroup; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * Created by xucongyang on 2018/06/20. + */ +public class NodesCreateResult { + + private String groupId; + private List orderId; + private List instanceId; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public List getOrderId() { + return orderId; + } + + public void setOrderId(List orderId) { + this.orderId = orderId; + } + + public List getInstanceId() { + return instanceId; + } + + public void setInstanceId(List instanceId) { + this.instanceId = instanceId; + } + + public NodesCreateResult withGroupId(String groupId) { + this.groupId = groupId; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/ShrinkageStrategyType.java b/src/main/java/com/baidubce/services/as/model/asgroup/ShrinkageStrategyType.java new file mode 100644 index 00000000..d2f4a27e --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/ShrinkageStrategyType.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.as.model.asgroup; + +public enum ShrinkageStrategyType { + + Earlier("earlier"), + + Later("later"); + + private String value; + + ShrinkageStrategyType(String value) { + this.value = value; + } + + public static boolean contain(String value) { + ShrinkageStrategyType[] shrinkageStrategyTypes = values(); + for (ShrinkageStrategyType type : shrinkageStrategyTypes) { + if (type.value.equalsIgnoreCase(value)) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/TagInfo.java b/src/main/java/com/baidubce/services/as/model/asgroup/TagInfo.java new file mode 100644 index 00000000..0e3e5d83 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/TagInfo.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.as.model.asgroup; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.ToString; + +/** + * @Author zhangzhongyang + * @Date 2020/12/8 3:40 下午 + */ +@Data +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class TagInfo { + private String tagKey; + private String tagValue; +} diff --git a/src/main/java/com/baidubce/services/as/model/asgroup/TemplateUpdateRequest.java b/src/main/java/com/baidubce/services/as/model/asgroup/TemplateUpdateRequest.java new file mode 100644 index 00000000..e74642ff --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/asgroup/TemplateUpdateRequest.java @@ -0,0 +1,66 @@ +package com.baidubce.services.as.model.asgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.LinkedList; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class TemplateUpdateRequest extends AbstractBceRequest { + @JsonIgnore + private String clientToken; + private NodeInfo node; + private List cds; + + private EipInfo eip = new EipInfo(); + + public NodeInfo getNode() { + return node; + } + + public void setNode(NodeInfo node) { + this.node = node; + } + + public List getCds() { + return cds; + } + + public void setCds(List cds) { + this.cds = cds; + } + + public EipInfo getEip() { + return eip; + } + + public void setEip(EipInfo eip) { + this.eip = eip; + } + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public String toString() { + final StringBuffer sb = new StringBuffer("TemplateUpdateRequest{"); + sb.append(" node=").append(node); + sb.append(", cds=").append(cds); + sb.append(", eip=").append(eip); + sb.append('}'); + return sb.toString(); + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/ActionType.java b/src/main/java/com/baidubce/services/as/model/rule/ActionType.java new file mode 100644 index 00000000..357cb01d --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/ActionType.java @@ -0,0 +1,8 @@ +package com.baidubce.services.as.model.rule; + +/** + * Created by dongjiawei on 2023/12/13. + */ +public enum ActionType { + INCREASE, DECREASE, ADJUST +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/CreateRuleResult.java b/src/main/java/com/baidubce/services/as/model/rule/CreateRuleResult.java new file mode 100644 index 00000000..ba603ffd --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/CreateRuleResult.java @@ -0,0 +1,12 @@ +package com.baidubce.services.as.model.rule; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +public class CreateRuleResult extends AbstractBceResponse { + private String ruleId; +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/RuleDelRequest.java b/src/main/java/com/baidubce/services/as/model/rule/RuleDelRequest.java new file mode 100644 index 00000000..3c91cb46 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/RuleDelRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.as.model.rule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class RuleDelRequest extends AbstractBceRequest { + private List ruleIds; + private List groupIds; + + @Override + public RuleDelRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/RuleListQuery.java b/src/main/java/com/baidubce/services/as/model/rule/RuleListQuery.java new file mode 100644 index 00000000..f73d0371 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/RuleListQuery.java @@ -0,0 +1,46 @@ +package com.baidubce.services.as.model.rule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +public class RuleListQuery extends AbstractBceRequest { + /** + * 伸缩组ID + * */ + private String groupId; + /** + * 过滤规则的关键词 + * */ + private String keyword; + /** + * 关键词的类型 + * */ + private String keywordType; + /** + * 规则的顺序,默认为"desc" + * */ + private String order; + /** + * 排序规则的字段,默认为"createTime" + * */ + private String orderBy; + /** + * 页码,默认为1 + * */ + private Integer pageNo; + /** + * 页面大小,默认为1000 + * */ + private Integer pageSize; + + @Override + public RuleListQuery withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/RuleQuery.java b/src/main/java/com/baidubce/services/as/model/rule/RuleQuery.java new file mode 100644 index 00000000..dd42c0da --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/RuleQuery.java @@ -0,0 +1,19 @@ +package com.baidubce.services.as.model.rule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +public class RuleQuery extends AbstractBceRequest { + private String ruleId; + + @Override + public RuleQuery withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/RuleRequest.java b/src/main/java/com/baidubce/services/as/model/rule/RuleRequest.java new file mode 100644 index 00000000..df6d5ad1 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/RuleRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.as.model.rule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class RuleRequest extends AbstractBceRequest { + private String ruleId; + private String ruleName; + private String groupId; + private RuleState state; + private RuleType type; + private String targetType = ""; + private String targetId = ""; + private String indicator = ""; + private String threshold = "0"; + private String unit = ""; + private String comparisonOperator = ""; + private ActionType actionType; + private Integer actionNum; + private String cronTime = ""; // CRON表达式类型,传标准cron格式 + private Integer cooldownInSec; + private String periodType; // 周期单位 可选 DAY/WEEK/MONTH/CronExpression + private Integer periodValue; // 周期触发日期 1-7标识周1-周日 1-31表示1号到31号 和periodType有关 如果是DAY不用填 + private String periodStartTime; // 周期有效期开始时间 + private String periodEndTime; // 周期有效期结束时间 + + @Override + public RuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/RuleState.java b/src/main/java/com/baidubce/services/as/model/rule/RuleState.java new file mode 100644 index 00000000..6785c320 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/RuleState.java @@ -0,0 +1,8 @@ +package com.baidubce.services.as.model.rule; + +/** + * Created by dongjiawei on 2023/12/13. + */ +public enum RuleState { + ENABLE, DISABLE +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/RuleType.java b/src/main/java/com/baidubce/services/as/model/rule/RuleType.java new file mode 100644 index 00000000..aafed40d --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/RuleType.java @@ -0,0 +1,19 @@ +package com.baidubce.services.as.model.rule; + +/** + * Created by dongjiawei on 2023/12/13. + */ +public enum RuleType { + /** + * 定时伸缩 + * */ + CRONTAB, + /** + * 告警伸缩 + * */ + ALARM, + /** + * 周期伸缩 + * */ + PERIOD +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/RuleVO.java b/src/main/java/com/baidubce/services/as/model/rule/RuleVO.java new file mode 100644 index 00000000..5266bc75 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/RuleVO.java @@ -0,0 +1,38 @@ +package com.baidubce.services.as.model.rule; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.sql.Timestamp; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class RuleVO { + private String ruleId; + private String ruleName; + private String groupId; + private String accountId; + private String state; + private String type; + private String targetType; + private String targetId; + private String indicator; + private String threshold; + private String unit; + private String comparisonOperator; + private String cronTime; + private String actionType; + private int actionNum; + private int cooldownInSec; + private Timestamp createTime; + private Timestamp lastExecutionTime; + private Timestamp periodStartTime; // 周期生效开始时间 + private Timestamp periodEndTime; // 周期生效结束时间 + // 周期类型 DAY/WEEK/MONTH + private String periodType; + // 周几 几号 + private int periodValue; +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/RuleVOListResponse.java b/src/main/java/com/baidubce/services/as/model/rule/RuleVOListResponse.java new file mode 100644 index 00000000..7540c28d --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/RuleVOListResponse.java @@ -0,0 +1,25 @@ +package com.baidubce.services.as.model.rule; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +public class RuleVOListResponse extends AbstractBceResponse { + private String orderBy = ""; + // 升序asc 或 降序desc 排序 + private String order = ""; + // 页码 + private int pageNo = 1; + // 一页条目数量 + private int pageSize = 0; + // 总条目数量 + private int totalCount = 0; + // 返回结果 + private List result = new ArrayList(); +} diff --git a/src/main/java/com/baidubce/services/as/model/rule/RuleVOResponse.java b/src/main/java/com/baidubce/services/as/model/rule/RuleVOResponse.java new file mode 100644 index 00000000..a3a6189b --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/rule/RuleVOResponse.java @@ -0,0 +1,39 @@ +package com.baidubce.services.as.model.rule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.sql.Timestamp; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class RuleVOResponse extends AbstractBceResponse { + private String ruleId; + private String ruleName; + private String groupId; + private String accountId; + private String state; + private String type; + private String targetType; + private String targetId; + private String indicator; + private String threshold; + private String unit; + private String comparisonOperator; + private String cronTime; + private String actionType; + private int actionNum; + private int cooldownInSec; + private Timestamp createTime; + private Timestamp lastExecutionTime; + private Timestamp periodStartTime; // 周期生效开始时间 + private Timestamp periodEndTime; // 周期生效结束时间 + // 周期类型 DAY/WEEK/MONTH + private String periodType; + // 周几 几号 + private int periodValue; +} diff --git a/src/main/java/com/baidubce/services/as/model/task/DetachNodeRequest.java b/src/main/java/com/baidubce/services/as/model/task/DetachNodeRequest.java new file mode 100644 index 00000000..587a21e5 --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/task/DetachNodeRequest.java @@ -0,0 +1,22 @@ +package com.baidubce.services.as.model.task; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +public class DetachNodeRequest extends AbstractBceRequest { + private String groupId; + private List nodes; + + @Override + public DetachNodeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/as/model/zone/ZoneInfo.java b/src/main/java/com/baidubce/services/as/model/zone/ZoneInfo.java new file mode 100644 index 00000000..bb34070a --- /dev/null +++ b/src/main/java/com/baidubce/services/as/model/zone/ZoneInfo.java @@ -0,0 +1,79 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.as.model.zone; + +/** + * Availability zone and subnet info + */ +public class ZoneInfo { + + private String zone; + + /** + * The id of subnet. + */ + private String subnetId; + + private String subnetUuid; + private String subnetName; + private Short subnetType; + + public String getSubnetUuid() { + return subnetUuid; + } + + public void setSubnetUuid(String subnetUuid) { + this.subnetUuid = subnetUuid; + } + + public String getSubnetName() { + return subnetName; + } + + public void setSubnetName(String subnetName) { + this.subnetName = subnetName; + } + + public Short getSubnetType() { + return subnetType; + } + + public void setSubnetType(Short subnetType) { + this.subnetType = subnetType; + } + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + @Override + public String toString() { + return "ZoneInfo{" + + "zone='" + zone + '\'' + + ", subnetId='" + subnetId + '\'' + + ", subnetUuid='" + subnetUuid + '\'' + + ", subnetName='" + subnetName + '\'' + + ", subnetType=" + subnetType + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/BacnetClient.java b/src/main/java/com/baidubce/services/bacnet/BacnetClient.java new file mode 100644 index 00000000..4c9fea9b --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/BacnetClient.java @@ -0,0 +1,251 @@ +package com.baidubce.services.bacnet; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.bacnet.model.BacnetDevice; +import com.baidubce.services.bacnet.model.BacnetGateway; +import com.baidubce.services.bacnet.model.BacnetGatewayCredential; +import com.baidubce.services.bacnet.model.BacnetObject; +import com.baidubce.services.bacnet.model.CreateBacnetGatewayRequest; +import com.baidubce.services.bacnet.model.ListBacnetDeviceResponse; +import com.baidubce.services.bacnet.model.ListBacnetGatewayResponse; +import com.baidubce.services.bacnet.model.ListBacnetObjectResponse; +import com.baidubce.services.bacnet.model.ListObjectPresentValueRequest; +import com.baidubce.services.bacnet.model.ListObjectPresentValueResponse; +import com.baidubce.services.bacnet.model.ListRequest; +import com.baidubce.services.bacnet.model.SubBacnetObjectRequest; +import com.baidubce.services.bacnet.model.UpdateBacnetGatewayRequest; +import com.baidubce.services.bacnet.model.UpdateDestTopicsRequest; +import com.baidubce.services.bacnet.model.UpdateBacnetObjectPresentValueRequest; +import com.baidubce.services.iotalarm.model.CommonResponse; +import com.baidubce.services.bacnet.model.IdResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yuanyoujun on 2017/10/18. + */ +public class BacnetClient extends AbstractBceClient { + public static final String ENDPOINT_GZ = "parser.iot.gz.baidubce.com"; + public static final String ENDPOINT_BJ = "parser.iot.bj.baidubce.com"; + private static final String VERSION = "v1"; + private static final String BACNET = "bacnet"; + private static final String GATEWAY = "gateway"; + private static final String DEVICE = "device"; + private static final String OBJECT = "object"; + private static final String TYPE = "type"; + private static final String INST = "inst"; + private static final String SUB = "sub"; + private static final String UNSUB = "unsub"; + private static final String PRESENT_VALUE = "presentvalue"; + private static final String REFRESH = "refresh"; + private static final String CREDENTIAL = "credential"; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + + private static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; + + public BacnetClient(BceClientConfiguration config) { + super(config, HANDLERS); + } + + // gateways + public IdResponse createGateway(CreateBacnetGatewayRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.POST, BACNET, GATEWAY); + return this.invokeHttpClient(internalRequest, IdResponse.class); + } + + public BacnetGateway getGateway(long id) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.GET, BACNET, GATEWAY, String.valueOf(id)); + return this.invokeHttpClient(internalRequest, BacnetGateway.class); + } + + public BacnetGatewayCredential getGatewayCredential(long id) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.GET, BACNET, GATEWAY, String.valueOf(id), + CREDENTIAL); + return this.invokeHttpClient(internalRequest, BacnetGatewayCredential.class); + } + + public CommonResponse deleteGateway(long id) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, BACNET, GATEWAY, String.valueOf(id)); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse updateGateway(UpdateBacnetGatewayRequest request, long id) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.PUT, BACNET, GATEWAY, String.valueOf(id)); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public ListBacnetGatewayResponse listGateway(ListRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.GET, BACNET, GATEWAY); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + + return this.invokeHttpClient(internalRequest, ListBacnetGatewayResponse.class); + } + + // bacnet devices + + public BacnetDevice getDevice(long gatewayid, long instanceNumber) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.GET, BACNET, DEVICE, GATEWAY, + String.valueOf(gatewayid), DEVICE, String.valueOf(instanceNumber)); + return this.invokeHttpClient(internalRequest, BacnetDevice.class); + } + + public ListBacnetDeviceResponse listDevice(ListRequest request, long gatewayid) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.GET, BACNET, DEVICE, GATEWAY, String.valueOf(gatewayid), DEVICE); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + + return this.invokeHttpClient(internalRequest, ListBacnetDeviceResponse.class); + } + + public CommonResponse deleteDevice(long gatewayid, long instanceNumber) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, BACNET, DEVICE, GATEWAY, + String.valueOf(gatewayid), DEVICE, String.valueOf(instanceNumber)); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse updateDeviceDestTopic(UpdateDestTopicsRequest request, long gatewayid, long instanceNumber) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.PUT, BACNET, DEVICE, GATEWAY, + String.valueOf(gatewayid), DEVICE, String.valueOf(instanceNumber)); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse updateObjectDestTopic(UpdateDestTopicsRequest request, long gatewayid, long instanceNumber, + String objectType, int objectInstance) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.PUT, BACNET, OBJECT, GATEWAY, + String.valueOf(gatewayid), DEVICE, String.valueOf(instanceNumber), + TYPE, objectType, INST, String.valueOf(objectInstance)); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public BacnetObject getObject(long gatewayid, long instanceNumber, String objectType, int objectInstance) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.GET, BACNET, OBJECT, GATEWAY, + String.valueOf(gatewayid), DEVICE, String.valueOf(instanceNumber), + TYPE, objectType, INST, String.valueOf(objectInstance)); + return this.invokeHttpClient(internalRequest, BacnetObject.class); + } + + public ListBacnetObjectResponse listObject(ListRequest request, long gatewayid, long instanceNumber) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.GET, BACNET, OBJECT, GATEWAY, String.valueOf(gatewayid), + DEVICE, String.valueOf(instanceNumber)); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + + return this.invokeHttpClient(internalRequest, ListBacnetObjectResponse.class); + } + + public CommonResponse deleteObject(long gatewayid, long instanceNumber, String objectType, int objectInstance) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, BACNET, OBJECT, GATEWAY, + String.valueOf(gatewayid), DEVICE, String.valueOf(instanceNumber), + TYPE, objectType, INST, String.valueOf(objectInstance)); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public ListObjectPresentValueResponse listObjectPresentValue(ListObjectPresentValueRequest request, + long gatewayid) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.POST, BACNET, OBJECT, GATEWAY, + String.valueOf(gatewayid), PRESENT_VALUE); + return this.invokeHttpClient(internalRequest, ListObjectPresentValueResponse.class); + } + + public CommonResponse updateObjectPresentValue(UpdateBacnetObjectPresentValueRequest request, long gatewayid) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.PUT, BACNET, OBJECT, GATEWAY, + String.valueOf(gatewayid), PRESENT_VALUE); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse subObjectChanges(SubBacnetObjectRequest request, long gatewayid, int instance) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.POST, BACNET, OBJECT, GATEWAY, + String.valueOf(gatewayid), DEVICE, String.valueOf(instance), SUB); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse unsubObjectChanges(SubBacnetObjectRequest request, long gatewayid, int instance) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.POST, BACNET, OBJECT, GATEWAY, + String.valueOf(gatewayid), DEVICE, String.valueOf(instance), UNSUB); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse refreshObject(long gatewayid, long instanceNumber, String objectType, int objectInstance) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.PUT, BACNET, OBJECT, GATEWAY, + String.valueOf(gatewayid), DEVICE, String.valueOf(instanceNumber), + TYPE, objectType, INST, String.valueOf(objectInstance), REFRESH); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, request); + } + + return request; + } + + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/BacnetDevice.java b/src/main/java/com/baidubce/services/bacnet/model/BacnetDevice.java new file mode 100644 index 00000000..f62551af --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/BacnetDevice.java @@ -0,0 +1,121 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +/** + * Created by yuanyoujun on 2017/10/18. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BacnetDevice extends AbstractBceResponse { + private int instanceNumber; + private String name; + private String description; + private int vendorId; + private String vendorName; + private int revision; + private int version; + private String typesSupported; + private String servicesSupported; + private Date lastActiveTime; + private String destTopics; + private Date createTime; + + public int getInstanceNumber() { + return instanceNumber; + } + + public void setInstanceNumber(int instanceNumber) { + this.instanceNumber = instanceNumber; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getVendorId() { + return vendorId; + } + + public void setVendorId(int vendorId) { + this.vendorId = vendorId; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public int getRevision() { + return revision; + } + + public void setRevision(int revision) { + this.revision = revision; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public String getTypesSupported() { + return typesSupported; + } + + public void setTypesSupported(String typesSupported) { + this.typesSupported = typesSupported; + } + + public String getServicesSupported() { + return servicesSupported; + } + + public void setServicesSupported(String servicesSupported) { + this.servicesSupported = servicesSupported; + } + + public Date getLastActiveTime() { + return lastActiveTime; + } + + public void setLastActiveTime(Date lastActiveTime) { + this.lastActiveTime = lastActiveTime; + } + + public String getDestTopics() { + return destTopics; + } + + public void setDestTopics(String destTopics) { + this.destTopics = destTopics; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/BacnetGateway.java b/src/main/java/com/baidubce/services/bacnet/model/BacnetGateway.java new file mode 100644 index 00000000..a4bf42da --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/BacnetGateway.java @@ -0,0 +1,157 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +/** + * Created by yuanyoujun on 2017/10/18. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BacnetGateway extends AbstractBceResponse { + private long id; + private String name; + private String description; + private boolean useSsl; + private int instanceNumber; + private String ipOrInterface; + private int pollInterval; + private int pollIntervalCov; + private int whoIsInterval; + private int objectDiscoverInterval; + private int subscribeDuration; + private Date lastActiveTime; + private String subscribeType; + private double covIncrement; + private String destTopics; + private Date createTime; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isUseSsl() { + return useSsl; + } + + public void setUseSsl(boolean useSsl) { + this.useSsl = useSsl; + } + + public int getInstanceNumber() { + return instanceNumber; + } + + public void setInstanceNumber(int instanceNumber) { + this.instanceNumber = instanceNumber; + } + + public String getIpOrInterface() { + return ipOrInterface; + } + + public void setIpOrInterface(String ipOrInterface) { + this.ipOrInterface = ipOrInterface; + } + + public int getPollInterval() { + return pollInterval; + } + + public void setPollInterval(int pollInterval) { + this.pollInterval = pollInterval; + } + + public int getPollIntervalCov() { + return pollIntervalCov; + } + + public void setPollIntervalCov(int pollIntervalCov) { + this.pollIntervalCov = pollIntervalCov; + } + + public int getWhoIsInterval() { + return whoIsInterval; + } + + public void setWhoIsInterval(int whoIsInterval) { + this.whoIsInterval = whoIsInterval; + } + + public int getSubscribeDuration() { + return subscribeDuration; + } + + public void setSubscribeDuration(int subscribeDuration) { + this.subscribeDuration = subscribeDuration; + } + + public Date getLastActiveTime() { + return lastActiveTime; + } + + public void setLastActiveTime(Date lastActiveTime) { + this.lastActiveTime = lastActiveTime; + } + + public String getDestTopics() { + return destTopics; + } + + public void setDestTopics(String destTopics) { + this.destTopics = destTopics; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public int getObjectDiscoverInterval() { + return objectDiscoverInterval; + } + + public void setObjectDiscoverInterval(int objectDiscoverInterval) { + this.objectDiscoverInterval = objectDiscoverInterval; + } + + public String getSubscribeType() { + return subscribeType; + } + + public void setSubscribeType(String subscribeType) { + this.subscribeType = subscribeType; + } + + public double getCovIncrement() { + return covIncrement; + } + + public void setCovIncrement(double covIncrement) { + this.covIncrement = covIncrement; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/BacnetGatewayCredential.java b/src/main/java/com/baidubce/services/bacnet/model/BacnetGatewayCredential.java new file mode 100644 index 00000000..06477954 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/BacnetGatewayCredential.java @@ -0,0 +1,56 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/10/18. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BacnetGatewayCredential extends AbstractBceResponse { + private String endpoint; + private String username; + private String password; + private String cmdTopic; + private String dataTopic; + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getCmdTopic() { + return cmdTopic; + } + + public void setCmdTopic(String cmdTopic) { + this.cmdTopic = cmdTopic; + } + + public String getDataTopic() { + return dataTopic; + } + + public void setDataTopic(String dataTopic) { + this.dataTopic = dataTopic; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/BacnetObject.java b/src/main/java/com/baidubce/services/bacnet/model/BacnetObject.java new file mode 100644 index 00000000..b77a2a54 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/BacnetObject.java @@ -0,0 +1,76 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +/** + * Created by yuanyoujun on 2017/10/19. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BacnetObject extends AbstractBceResponse { + private String name; + private String objectType; + private int objectInstance; + private double presentValue; + private String destTopics; + private Date updateTime; + private Date createTime; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public int getObjectInstance() { + return objectInstance; + } + + public void setObjectInstance(int objectInstance) { + this.objectInstance = objectInstance; + } + + public double getPresentValue() { + return presentValue; + } + + public void setPresentValue(double presentValue) { + this.presentValue = presentValue; + } + + public String getDestTopics() { + return destTopics; + } + + public void setDestTopics(String destTopics) { + this.destTopics = destTopics; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/BacnetObjectId.java b/src/main/java/com/baidubce/services/bacnet/model/BacnetObjectId.java new file mode 100644 index 00000000..db58bf12 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/BacnetObjectId.java @@ -0,0 +1,34 @@ +package com.baidubce.services.bacnet.model; + +/** + * Created by yuanyoujun on 2017/10/19. + */ +public class BacnetObjectId { + private int instanceNumber; + private String objectType; + private int objectInstance; + + public int getInstanceNumber() { + return instanceNumber; + } + + public void setInstanceNumber(int instanceNumber) { + this.instanceNumber = instanceNumber; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public int getObjectInstance() { + return objectInstance; + } + + public void setObjectInstance(int objectInstance) { + this.objectInstance = objectInstance; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/BacnetObjectPresentValue.java b/src/main/java/com/baidubce/services/bacnet/model/BacnetObjectPresentValue.java new file mode 100644 index 00000000..d1be9ff5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/BacnetObjectPresentValue.java @@ -0,0 +1,46 @@ +package com.baidubce.services.bacnet.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/10/19. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BacnetObjectPresentValue { + private int instanceNumber; + private String objectType; + private int objectInstance; + private String presentValue; + + public int getInstanceNumber() { + return instanceNumber; + } + + public void setInstanceNumber(int instanceNumber) { + this.instanceNumber = instanceNumber; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public int getObjectInstance() { + return objectInstance; + } + + public void setObjectInstance(int objectInstance) { + this.objectInstance = objectInstance; + } + + public String getPresentValue() { + return presentValue; + } + + public void setPresentValue(String presentValue) { + this.presentValue = presentValue; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/CreateBacnetGatewayRequest.java b/src/main/java/com/baidubce/services/bacnet/model/CreateBacnetGatewayRequest.java new file mode 100644 index 00000000..1ee88360 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/CreateBacnetGatewayRequest.java @@ -0,0 +1,128 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.GenericAccountRequest; + + +/** + * Created by yuanyoujun on 2017/10/18. + */ +public class CreateBacnetGatewayRequest extends GenericAccountRequest { + private String name; + private String description; + private boolean useSsl; + private int instanceNumber; + private String ipOrInterface; + private int pollInterval; + private int pollIntervalCov; + private int whoIsInterval; + private int objectDiscoverInterval; + private int subscribeDuration; + private String subscribeType; + private double covIncrement; + private String destTopics; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isUseSsl() { + return useSsl; + } + + public void setUseSsl(boolean useSsl) { + this.useSsl = useSsl; + } + + public int getInstanceNumber() { + return instanceNumber; + } + + public void setInstanceNumber(int instanceNumber) { + this.instanceNumber = instanceNumber; + } + + public String getIpOrInterface() { + return ipOrInterface; + } + + public void setIpOrInterface(String ipOrInterface) { + this.ipOrInterface = ipOrInterface; + } + + public int getPollInterval() { + return pollInterval; + } + + public void setPollInterval(int pollInterval) { + this.pollInterval = pollInterval; + } + + public int getPollIntervalCov() { + return pollIntervalCov; + } + + public void setPollIntervalCov(int pollIntervalCov) { + this.pollIntervalCov = pollIntervalCov; + } + + public int getWhoIsInterval() { + return whoIsInterval; + } + + public void setWhoIsInterval(int whoIsInterval) { + this.whoIsInterval = whoIsInterval; + } + + public int getSubscribeDuration() { + return subscribeDuration; + } + + public void setSubscribeDuration(int subscribeDuration) { + this.subscribeDuration = subscribeDuration; + } + + public String getDestTopics() { + return destTopics; + } + + public void setDestTopics(String destTopics) { + this.destTopics = destTopics; + } + + public int getObjectDiscoverInterval() { + return objectDiscoverInterval; + } + + public void setObjectDiscoverInterval(int objectDiscoverInterval) { + this.objectDiscoverInterval = objectDiscoverInterval; + } + + + public double getCovIncrement() { + return covIncrement; + } + + public void setCovIncrement(double covIncrement) { + this.covIncrement = covIncrement; + } + + public String getSubscribeType() { + return subscribeType; + } + + public void setSubscribeType(String subscribeType) { + this.subscribeType = subscribeType; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/IdResponse.java b/src/main/java/com/baidubce/services/bacnet/model/IdResponse.java new file mode 100644 index 00000000..36b8a95b --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/IdResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/10/18. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class IdResponse extends AbstractBceResponse { + private long id; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/ListBacnetDeviceResponse.java b/src/main/java/com/baidubce/services/bacnet/model/ListBacnetDeviceResponse.java new file mode 100644 index 00000000..63f7fce4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/ListBacnetDeviceResponse.java @@ -0,0 +1,49 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/10/18. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListBacnetDeviceResponse extends AbstractBceResponse { + private List result; + private int totalCount; + private int pageNo; + private int pageSize; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/ListBacnetGatewayResponse.java b/src/main/java/com/baidubce/services/bacnet/model/ListBacnetGatewayResponse.java new file mode 100644 index 00000000..bd0c8b26 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/ListBacnetGatewayResponse.java @@ -0,0 +1,49 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/10/18. + */ +@JsonIgnoreProperties (ignoreUnknown = true) +public class ListBacnetGatewayResponse extends AbstractBceResponse { + private List result; + private int totalCount; + private int pageNo; + private int pageSize; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/ListBacnetObjectResponse.java b/src/main/java/com/baidubce/services/bacnet/model/ListBacnetObjectResponse.java new file mode 100644 index 00000000..d9e84b8e --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/ListBacnetObjectResponse.java @@ -0,0 +1,49 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/10/19. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListBacnetObjectResponse extends AbstractBceResponse { + private List result; + private int totalCount; + private int pageNo; + private int pageSize; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/ListObjectPresentValueRequest.java b/src/main/java/com/baidubce/services/bacnet/model/ListObjectPresentValueRequest.java new file mode 100644 index 00000000..462dca33 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/ListObjectPresentValueRequest.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.GenericAccountRequest; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/10/19. + */ +public class ListObjectPresentValueRequest extends GenericAccountRequest { + private List points; + + public List getPoints() { + return points; + } + + public void setPoints(List points) { + this.points = points; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/ListObjectPresentValueResponse.java b/src/main/java/com/baidubce/services/bacnet/model/ListObjectPresentValueResponse.java new file mode 100644 index 00000000..0c241891 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/ListObjectPresentValueResponse.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/10/19. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListObjectPresentValueResponse extends AbstractBceResponse { + private List points; + + public List getPoints() { + return points; + } + + public void setPoints(List points) { + this.points = points; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/ListRequest.java b/src/main/java/com/baidubce/services/bacnet/model/ListRequest.java new file mode 100644 index 00000000..7a994dd9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/ListRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * Created by yuanyoujun on 2017/10/18. + */ +public class ListRequest extends GenericAccountRequest { + private int pageNo = 1; + private int pageSize = 50; + + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bacnet/model/SubBacnetObjectRequest.java b/src/main/java/com/baidubce/services/bacnet/model/SubBacnetObjectRequest.java new file mode 100644 index 00000000..8faeeafa --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/SubBacnetObjectRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.GenericAccountRequest; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/10/19. + */ +public class SubBacnetObjectRequest extends GenericAccountRequest { + private String destTopic; + private List points; + + public String getDestTopic() { + return destTopic; + } + + public void setDestTopic(String destTopic) { + this.destTopic = destTopic; + } + + public List getPoints() { + return points; + } + + public void setPoints(List points) { + this.points = points; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/UpdateBacnetGatewayRequest.java b/src/main/java/com/baidubce/services/bacnet/model/UpdateBacnetGatewayRequest.java new file mode 100644 index 00000000..698cdce8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/UpdateBacnetGatewayRequest.java @@ -0,0 +1,118 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * Created by yuanyoujun on 2017/10/18. + */ +public class UpdateBacnetGatewayRequest extends GenericAccountRequest { + private String description; + private boolean useSsl; + private int instanceNumber; + private String ipOrInterface; + private int pollInterval; + private int pollIntervalCov; + private int whoIsInterval; + private int subscribeDuration; + private int objectDiscoverInterval; + private String subscribeType; + private double covIncrement; + private String destTopics; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isUseSsl() { + return useSsl; + } + + public void setUseSsl(boolean useSsl) { + this.useSsl = useSsl; + } + + public int getInstanceNumber() { + return instanceNumber; + } + + public void setInstanceNumber(int instanceNumber) { + this.instanceNumber = instanceNumber; + } + + public String getIpOrInterface() { + return ipOrInterface; + } + + public void setIpOrInterface(String ipOrInterface) { + this.ipOrInterface = ipOrInterface; + } + + public int getPollInterval() { + return pollInterval; + } + + public void setPollInterval(int pollInterval) { + this.pollInterval = pollInterval; + } + + public int getPollIntervalCov() { + return pollIntervalCov; + } + + public void setPollIntervalCov(int pollIntervalCov) { + this.pollIntervalCov = pollIntervalCov; + } + + public int getWhoIsInterval() { + return whoIsInterval; + } + + public void setWhoIsInterval(int whoIsInterval) { + this.whoIsInterval = whoIsInterval; + } + + public int getSubscribeDuration() { + return subscribeDuration; + } + + public void setSubscribeDuration(int subscribeDuration) { + this.subscribeDuration = subscribeDuration; + } + + public String getDestTopics() { + return destTopics; + } + + public void setDestTopics(String destTopics) { + this.destTopics = destTopics; + } + + public int getObjectDiscoverInterval() { + return objectDiscoverInterval; + } + + public void setObjectDiscoverInterval(int objectDiscoverInterval) { + this.objectDiscoverInterval = objectDiscoverInterval; + } + + public String getSubscribeType() { + return subscribeType; + } + + public void setSubscribeType(String subscribeType) { + this.subscribeType = subscribeType; + } + + public double getCovIncrement() { + return covIncrement; + } + + public void setCovIncrement(double covIncrement) { + this.covIncrement = covIncrement; + } + +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/UpdateBacnetObjectPresentValueRequest.java b/src/main/java/com/baidubce/services/bacnet/model/UpdateBacnetObjectPresentValueRequest.java new file mode 100644 index 00000000..6bcabe8c --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/UpdateBacnetObjectPresentValueRequest.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.GenericAccountRequest; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/10/19. + */ +public class UpdateBacnetObjectPresentValueRequest extends GenericAccountRequest { + private List points; + + public List getPoints() { + return points; + } + + public void setPoints(List points) { + this.points = points; + } +} diff --git a/src/main/java/com/baidubce/services/bacnet/model/UpdateDestTopicsRequest.java b/src/main/java/com/baidubce/services/bacnet/model/UpdateDestTopicsRequest.java new file mode 100644 index 00000000..8d93d2f5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/UpdateDestTopicsRequest.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bacnet.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * Created by yuanyoujun on 2017/10/19. + */ +public class UpdateDestTopicsRequest extends GenericAccountRequest { + private String destTopics; + + public String getDestTopics() { + return destTopics; + } + + public void setDestTopics(String destTopics) { + this.destTopics = destTopics; + } +} diff --git a/src/main/java/com/baidubce/services/batch/BatchClient.java b/src/main/java/com/baidubce/services/batch/BatchClient.java old mode 100644 new mode 100755 index c4ec5cf9..5c65414a --- a/src/main/java/com/baidubce/services/batch/BatchClient.java +++ b/src/main/java/com/baidubce/services/batch/BatchClient.java @@ -86,12 +86,12 @@ public BatchClient(BceClientConfiguration clientConfiguration) { /** * List Batch-Compute jobs owned by the authenticated user. *

- *

* Users must authenticate with a valid BCE Access Key ID, and the response * contains all the Batch-Compute jobs owned by the user. * * @param request The request containing valid query parameters. - * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the request. + * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the + * request. */ public ListJobsResponse listJobs(ListJobsRequest request) { checkNotNull(request, "request should not be null."); @@ -110,7 +110,8 @@ public ListJobsResponse listJobs(ListJobsRequest request) { /** * List Batch-Compute jobs owned by the authenticated user. * - * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the request. + * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the + * request. */ public ListJobsResponse listJobs() { return listJobs(new ListJobsRequest()); @@ -120,7 +121,8 @@ public ListJobsResponse listJobs() { * List Batch-Compute jobs owned by the authenticated user. * * @param maxKeys The maximum number of jobs returned. - * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the request. + * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the + * request. * And the size of list is limited below maxKeys. */ public ListJobsResponse listJobs(int maxKeys) { @@ -130,9 +132,10 @@ public ListJobsResponse listJobs(int maxKeys) { /** * List Batch-Compute jobs owned by the authenticated user. * - * @param marker The start record of jobs. + * @param marker The start record of jobs. * @param maxKeys The maximum number of jobs returned. - * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the request. + * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the + * request. * The jobs' records start from the marker and the size of list is limited below maxKeys. */ public ListJobsResponse listJobs(String marker, int maxKeys) { @@ -246,8 +249,8 @@ public void cancelJob(String jobId) { /** * Creates and initializes a new request object for the specified resource. * - * @param bceRequest The original BCE request created by the user. - * @param httpMethod The HTTP method to use when sending the request. + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. * @param pathVariables The optional variables used in the URI path. * @return A new request object populated with endpoint, resource path and specific * parameters to send. diff --git a/src/main/java/com/baidubce/services/batch/model/ListJobsRequest.java b/src/main/java/com/baidubce/services/batch/model/ListJobsRequest.java old mode 100644 new mode 100755 index 14e6eaa3..1cf87f5c --- a/src/main/java/com/baidubce/services/batch/model/ListJobsRequest.java +++ b/src/main/java/com/baidubce/services/batch/model/ListJobsRequest.java @@ -44,7 +44,7 @@ public void setMaxKeys(int maxKeys) { * Configure the marker for the query request. * The marker marks the starting point for the query. * - * @param marker + * @param marker the marker * @return ListJobsRequest */ public ListJobsRequest withMarker(String marker) { diff --git a/src/main/java/com/baidubce/services/bbc/BbcClient.java b/src/main/java/com/baidubce/services/bbc/BbcClient.java new file mode 100644 index 00000000..f2032215 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/BbcClient.java @@ -0,0 +1,806 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bbc.model.instance.BindBbcTagsRequest; +import com.baidubce.services.bbc.model.instance.CreateBbcImageRequest; +import com.baidubce.services.bbc.model.instance.CreateBbcImageResponse; +import com.baidubce.services.bbc.model.instance.CreateBbcInstanceRequest; +import com.baidubce.services.bbc.model.instance.CreateBbcInstanceResponse; +import com.baidubce.services.bbc.model.instance.GetBbcFlavorRaidResponse; +import com.baidubce.services.bbc.model.instance.GetBbcFlavorRequest; +import com.baidubce.services.bbc.model.instance.GetBbcFlavorResponse; +import com.baidubce.services.bbc.model.instance.GetBbcInstanceResponse; +import com.baidubce.services.bbc.model.instance.GetInstanceVpcRequest; +import com.baidubce.services.bbc.model.instance.GetInstanceVpcResponse; +import com.baidubce.services.bbc.model.instance.ListBbcFlavorResponse; +import com.baidubce.services.bbc.model.instance.ListBbcFlavorsRequest; +import com.baidubce.services.bbc.model.instance.ListBbcInstancesRequest; +import com.baidubce.services.bbc.model.instance.ListBbcInstancesResponse; +import com.baidubce.services.bbc.model.instance.ListOperationLogRequest; +import com.baidubce.services.bbc.model.instance.ListOperationLogResponse; +import com.baidubce.services.bbc.model.instance.RebuildBbcInstanceRequest; +import com.baidubce.services.bbc.model.instance.RenameBbcInstanceRequest; +import com.baidubce.services.bcc.BccClientConfiguration; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.bcc.model.image.DeleteImageRequest; +import com.baidubce.services.bcc.model.image.GetImageRequest; +import com.baidubce.services.bcc.model.image.GetImageResponse; +import com.baidubce.services.bcc.model.image.ListImagesRequest; +import com.baidubce.services.bcc.model.image.ListImagesResponse; +import com.baidubce.services.bcc.model.instance.GetInstanceRequest; +import com.baidubce.services.bcc.model.instance.InstanceAction; +import com.baidubce.services.bcc.model.instance.ModifyInstanceDescRequest; +import com.baidubce.services.bcc.model.instance.ModifyInstancePasswordRequest; +import com.baidubce.services.bcc.model.instance.RebootInstanceRequest; +import com.baidubce.services.bcc.model.instance.ReleaseInstanceRequest; +import com.baidubce.services.bcc.model.instance.StartInstanceRequest; +import com.baidubce.services.bcc.model.instance.StopInstanceRequest; +import com.baidubce.services.bcc.model.region.DescribeRegionsRequest; +import com.baidubce.services.bcc.model.region.DescribeRegionsResponse; +import com.baidubce.services.bcc.model.reversed.ReservedTagsRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.baidubce.util.Validate; +import com.google.common.base.Strings; +import org.apache.commons.codec.binary.Hex; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; +import org.apache.commons.collections.CollectionUtils; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkMultyParamsNotBothEmpty; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Created by fulinhua on 2019-02-18 + */ +public class BbcClient extends AbstractBceClient { + + private static final String VERSION = "v1"; + private static final String DELETE_VERSION = "v2"; + private static final String INSTANCE_PREFIX = "instance"; + private static final String REGION_PREFIX = "region"; + private static final String DESCRIBE_REGIONS = "describeRegions"; + private static final String FLAVOR_PREFIX = "flavor"; + private static final String FLAVOR_RAID_PREFIX = "flavorRaid"; + private static final String IMAGE_PREFIX = "image"; + private static final String OPERATION_LOG_PREFIX = "operationLog"; + private static final String TAG = "tag"; + private static final String VPC = "vpcSubnet"; + private static final String MARKER = "marker"; + private static final String MAX_KEYS = "maxKeys"; + private static final String INTERNAL_IP = "internalIp"; + private static final String IMAGE_TYPE = "imageType"; + private static final String START_TIME = "startTime"; + private static final String END_TIME = "endTime"; + private static final String CLIENT_TOKEN = "clientToken"; + private static final String POST_PAID = "Postpaid"; + private static final String BIND = "bind"; + private static final String UNBIND = "unbind"; + private static final String RESERVED_TAG_PREFIX = "bbc/reserved/tag"; + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String INSTANCEID_MESSAGE_KEY = "instanceId"; + private static final String FLAVORID_MESSAGE_KEY = "flavorId"; + private static final String TAGKEY_MESSAGE_KEY = "tagKey"; + private static final String RAID_MESSAGE_KEY = "raid"; + private static final String CHANGETAGS_NULL_ERROR_MESSAGE = "request changeTags should not be null."; + private static final String ADMINPASS_MESSAGE_KEY = "adminPass"; + private static final String BBC_ID_MESSAGE_KEY = "bbcId"; + private static final String NAME_MESSAGE_KEY = "name"; + private static final String DESC_MESSAGE_KEY = "desc"; + private static final String IMAGEID_MESSAGE_KEY = "imageId"; + private static final String IMAGENAME_MESSAGE_KEY = "imageName"; + + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling httpResponses from all bbc service calls. + */ + private static final HttpResponseHandler[] bbc_handlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new bbc client using the client configuration to access bbc. + * + * @param clientConfiguration The bcc client configuration options controlling how this client + * connects to bbc (e.g. proxy settings, retry counts, etc). + */ + public BbcClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, bbc_handlers); + } + + public BbcClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers, + boolean isHttpAsyncPutEnabled) { + super(config, responseHandlers, isHttpAsyncPutEnabled); + } + + public BbcClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers) { + super(config, responseHandlers); + } + + /** + * Constructs a new client to invoke service methods on bbc. + */ + public BbcClient() { + this(new BccClientConfiguration()); + } + + /** + * Creates and initializes a new request object for the specified bcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * Creates and initializes a new request object of V2 type operation. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createV2Request(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(DELETE_VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * Binding the bbc instance to specified list of tags. + * + * @param request The request containing all options for binding the instance to specified list of tags. + */ + public void bindInstanceTag(BindBbcTagsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + if (null != request.getChangeTags() && !request.getChangeTags().isEmpty()) { + for (TagModel tag : request.getChangeTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + } else { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + INSTANCE_PREFIX, request.getInstanceId(), TAG); + internalRequest.addParameter(BIND, null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Unbinding the bbc instance to specified list of tags. + * + * @param request The request containing all options for unbinding the instance to specified list of tags. + */ + public void unBindInstanceTag(BindBbcTagsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + if (null != request.getChangeTags() && !request.getChangeTags().isEmpty()) { + for (TagModel tag : request.getChangeTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + } else { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + INSTANCE_PREFIX, request.getInstanceId(), TAG); + internalRequest.addParameter(UNBIND, null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Modifying the password of the bbc instance. + *

+ * You can reboot the instance only when the instance is Running or Stopped , + * otherwise,it's will get 409 errorCode. + * + * @param request The request containing all options for modifying the bbc instance password. + * @throws BceClientException + */ + public void modifyBbcPassword(ModifyInstancePasswordRequest request) throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAdminPass(), checkEmptyExceptionMessageFormat(ADMINPASS_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.changePass.name(), null); + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Get the Vpc/Subnet information of specified bbc instance. + * + * @param request The request containing all options for getting the Vpc/Subnet information + * @return A List of Vpc/Subnet information + */ + public GetInstanceVpcResponse getInstanceVpcsubnet(GetInstanceVpcRequest request) throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (null != request.getBbcIds() && !request.getBbcIds().isEmpty()) { + for (String bbcId : request.getBbcIds()) { + checkStringNotEmpty(bbcId, checkEmptyExceptionMessageFormat(BBC_ID_MESSAGE_KEY)); + } + } else { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VPC); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, GetInstanceVpcResponse.class); + } + + /** + * Return a list of instances owned by the authenticated user. + * + * @param request The request containing all options for listing own's bcc Instance. + * @return The response containing a list of instances owned by the authenticated user. + */ + public ListBbcInstancesResponse listBbcInstances(ListBbcInstancesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, INSTANCE_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getInternalIp())) { + internalRequest.addParameter(INTERNAL_IP, request.getInternalIp()); + } + return invokeHttpClient(internalRequest, ListBbcInstancesResponse.class); + } + + /** + * Get the detail information of specified bbc instance. + * + * @param request The request containing all options for getting the instance info. + * @return A instance detail model for the instanceId. + */ + public GetBbcInstanceResponse getInstance(GetInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, INSTANCE_PREFIX, request.getInstanceId()); + return this.invokeHttpClient(internalRequest, GetBbcInstanceResponse.class); + } + + + /** + * Starting the bbc instance owned by the user. + *

+ * You can start the instance only when the instance is Stopped, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for starting the instance. + */ + public void startInstance(StartInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.start.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Stopping the bbc instance owned by the user. + *

+ * You can stop the instance only when the instance is Running, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for stopping the instance. + */ + public void stopInstance(StopInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.stop.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Rebooting the bbc instance owned by the user. + *

+ * You can reboot the instance only when the instance is Running, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for rebooting the instance. + */ + public void rebootInstance(RebootInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.reboot.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Modifying the special attribute to new value of the instance. + *

+ * You can reboot the instance only when the instance is Running or Stopped , + * otherwise,it's will get 409 errorCode. + * + * @param request The request containing all options for modifying the instance attribute. + */ + public void renameBbcInstance(RenameBbcInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.rename.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Modifying the special describe to new value of the instance. + * + * @param request The request containing all options for modifying the instance desc. + */ + public void modifyInstanceDesc(ModifyInstanceDescRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDesc(), checkEmptyExceptionMessageFormat(DESC_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.updateDesc.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Rebuilding the bbc instance owned by the user. + *

+ * After rebuilding the instance, + * all of snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be saved. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for rebuilding the instance. + * @throws BceClientException + */ + public void rebuildBbcInstance(RebuildBbcInstanceRequest request) throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAdminPass(), checkEmptyExceptionMessageFormat(ADMINPASS_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.rebuild.name(), null); + + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Releasing the instance owned by the user. + *

+ * Only the Postpaid instance or Prepaid which is expired can be released. + * After releasing the instance, + * all of the data will be deleted. + * all of volumes attached will be detached,but the volume snapshots will be saved. + * all of snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param request The request containing all options for releasing the instance. + */ + public void releaseBbcInstance(ReleaseInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createV2Request( + request, HttpMethodName.DELETE, INSTANCE_PREFIX, request.getInstanceId()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Listing all the flavors of the bbc instance + * @param request + * @return + */ + public ListBbcFlavorResponse listBbcFlavors(ListBbcFlavorsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, FLAVOR_PREFIX); + return this.invokeHttpClient(internalRequest, ListBbcFlavorResponse.class); + } + + /** + * Geting the flavor information of a flavor + * @param request The request containing all options for releasing the instance. + * @return + */ + public GetBbcFlavorResponse getBbcFlavor(GetBbcFlavorRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getFlavorId(), checkEmptyExceptionMessageFormat(FLAVORID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, FLAVOR_PREFIX, request.getFlavorId()); + return this.invokeHttpClient(internalRequest, GetBbcFlavorResponse.class); + } + /** + * Geting the flavor raid information of a raid + * @param request The request containing all options for releasing the instance. + * @return + */ + public GetBbcFlavorRaidResponse getBbcFlavorRaid(GetBbcFlavorRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getFlavorId(), checkEmptyExceptionMessageFormat(FLAVORID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, FLAVOR_RAID_PREFIX, request.getFlavorId()); + return this.invokeHttpClient(internalRequest, GetBbcFlavorRaidResponse.class); + } + + /** + * Creating a customized image which can be used for creating instance in the future. + * + *

+ * You can create an image from an instance or you can create from an snapshot. + * The parameters of instanceId and snapshotId can no be null simultaneously. + * when both instanceId and snapshotId are assigned,only instanceId will be used. + *

+ * While creating an image from an instance,the instance must be Running or Stopped, + * otherwise,it's will get 409 errorCode. + *

+ * You can create the image only from system snapshot. + * While creating an image from a system snapshot,the snapshot must be Available, + * otherwise,it's will get 409 errorCode. + * + * @param request The request containing all options for creating a new image. + * @return The response with id of image newly created. + */ + public CreateBbcImageResponse createBbcImage(CreateBbcImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getImageName(), checkEmptyExceptionMessageFormat(IMAGENAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, IMAGE_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBbcImageResponse.class); + } + + /** + * Listing bbc images owned by the authenticated user. + * + * @param request The request containing all options for listing images owned by user. + * @return The response with list of images. + */ + public ListImagesResponse listImages(ListImagesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, IMAGE_PREFIX); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getImageType())) { + internalRequest.addParameter(IMAGE_TYPE, request.getImageType()); + } + return invokeHttpClient(internalRequest, ListImagesResponse.class); + } + + /** + * Get the detail information of specified image. + * + * @param request The request containing all options for getting the detail information of specified image. + * @return The response with the image detail information. + */ + public GetImageResponse getImage(GetImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, IMAGE_PREFIX, request.getImageId()); + return invokeHttpClient(internalRequest, GetImageResponse.class); + } + + /** + * Deleting the specified image. + *

+ * Only the customized image can be deleted, + * otherwise,it's will get 403 errorCode. + * + * @param request The request containing all options for deleting the specified image. + */ + public void deleteImage(DeleteImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, IMAGE_PREFIX, request.getImageId()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * List all region's endpoint information. + *

+ * You can get specified region's endpoint information by specified region, + * if the region is not exist, it's will get 409 errorCode. + * + * Use global endpoint bbc.baidubce.com to get BBC's endpoint. + * @param request The request for getting endpoint of different regions. + * @return The response containing the detail region's endpoint information. + */ + public DescribeRegionsResponse describeRegions(DescribeRegionsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createV2Request(request, HttpMethodName.POST, REGION_PREFIX, DESCRIBE_REGIONS); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DescribeRegionsResponse.class); + } + + /** + * Listing the operation log of the bbc. + * The startTime and endTime means the time quantum that the log had taken. + * If the starTime or the endTime is empty,it means searching the operation log of today. + * @param request + * @return + */ + public ListOperationLogResponse listBbcOperationLog(ListOperationLogRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, OPERATION_LOG_PREFIX); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getStartTime())) { + internalRequest.addParameter(START_TIME, request.getStartTime()); + } + if (!Strings.isNullOrEmpty(request.getEndTime())) { + internalRequest.addParameter(END_TIME, request.getEndTime()); + } + return invokeHttpClient(internalRequest, ListOperationLogResponse.class); + } + + /** + * Create a bcc Instance with the specified options, + * see all the supported instance in {@link com.baidubce.services.bcc.model.instance.InstanceType} + * You must fill the field of clientToken,which is especially for keeping idempotent. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for creating a bcc Instance. + * @return List of instanceId newly created + * @throws BceClientException + */ + public CreateBbcInstanceResponse createInstance(CreateBbcInstanceRequest request) + throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + if (null != request.getTags() && !request.getTags().isEmpty()) { + for (TagModel tag : request.getTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + } + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getFlavorId(), checkEmptyExceptionMessageFormat(FLAVORID_MESSAGE_KEY)); + checkStringNotEmpty(request.getRaidId(), checkEmptyExceptionMessageFormat(RAID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + if (!Strings.isNullOrEmpty(request.getAdminPass())) { + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBbcInstanceResponse.class); + } + + /** + * The method to generate a default Billing which is Postpaid. + * + * @return The Billing object with Postpaid PaymentTiming. + */ + private Billing generateDefaultBilling() { + Billing billing = new Billing(); + billing.setPaymentTiming(POST_PAID); + return billing; + } + + + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + private String aes128WithFirst16Char(String content, String privateKey) throws GeneralSecurityException { + byte[] crypted = null; + SecretKeySpec skey = new SecretKeySpec(privateKey.substring(0, 16).getBytes(), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, skey); + crypted = cipher.doFinal(content.getBytes()); + return new String(Hex.encodeHex(crypted)); + } + + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + public void bindReservedInstanceToTags(ReservedTagsRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkMultyParamsNotBothEmpty(request.getReservedInstanceIds(), "reservedInstanceIds should NOT be null."); + if (CollectionUtils.isEmpty(request.getChangeTags())) { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + for (TagModel tag : request.getChangeTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + + InternalRequest internalRequest = this.createV2Request(request, HttpMethodName.PUT, + RESERVED_TAG_PREFIX); + internalRequest.addParameter(BIND, null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void unbindReservedInstanceFromTags(ReservedTagsRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkMultyParamsNotBothEmpty(request.getReservedInstanceIds(), "reservedInstanceIds should NOT be null."); + if (CollectionUtils.isEmpty(request.getChangeTags())) { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + for (TagModel tag : request.getChangeTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + + InternalRequest internalRequest = this.createV2Request(request, HttpMethodName.PUT, + RESERVED_TAG_PREFIX); + internalRequest.addParameter(UNBIND, null); + + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/bbc/BbcClientConfiguration.java b/src/main/java/com/baidubce/services/bbc/BbcClientConfiguration.java new file mode 100644 index 00000000..870a5f55 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/BbcClientConfiguration.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc; + +import com.baidubce.BceClientConfiguration; + +/** + * Created by fulinhua on 2019-02-18 + */ +public class BbcClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/BbcNetworkModel.java b/src/main/java/com/baidubce/services/bbc/model/instance/BbcNetworkModel.java new file mode 100644 index 00000000..d786ece5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/BbcNetworkModel.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + + +/** + * The detail model of vpc/subnet + */ +public class BbcNetworkModel { + + /** + * The id of bbc instance + */ + private String bbcId; + + /** + * The value of Vpc + */ + private VpcModel vpc; + + /** + * The value of subnet + */ + private SubnetModel subnet; + + public String getBbcId() { + return bbcId; + } + + public void setBbcId(String bbcId) { + this.bbcId = bbcId; + } + + public VpcModel getVpc() { + return vpc; + } + + public void setVpc(VpcModel vpc) { + this.vpc = vpc; + } + + public SubnetModel getSubnet() { + return subnet; + } + + public void setSubnet(SubnetModel subnet) { + this.subnet = subnet; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/BindBbcTagsRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/BindBbcTagsRequest.java new file mode 100644 index 00000000..64354811 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/BindBbcTagsRequest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * Created by fulinhua on 2019-02-18 + */ +public class BindBbcTagsRequest extends AbstractBceRequest { + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The list of tags. + */ + private List changeTags; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public List getChangeTags() { + return changeTags; + } + + public void setChangeTags(List changeTags) { + this.changeTags = changeTags; + } + + /** + * Configure the list of tags for the request. + * + * @param changeTags The list of tags. + * @return BindBbcTagsRequest with specified list of tags. + */ + public BindBbcTagsRequest withChangeTags(List changeTags) { + this.changeTags = changeTags; + return this; + } + + /** + * Configure the instance ID for the request. + * + * @param instanceId The id of instance which will be used to bind a list of tags. + * @return BindBbcTagsRequest with specified instance id. + */ + public BindBbcTagsRequest withInstanceId(String instanceId) { + this.setInstanceId(instanceId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindBbcTagsRequest with credentials. + */ + @Override + public BindBbcTagsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} + diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcImageRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcImageRequest.java new file mode 100644 index 00000000..f6b71d7e --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcImageRequest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for creating bbc image + */ +public class CreateBbcImageRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * The name of image + */ + private String imageName; + /** + * The id of instance + */ + private String instanceId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getImageName() { + return imageName; + } + + public void setImageName(String imageName) { + this.imageName = imageName; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public CreateBbcImageRequest withImageName(String imageName) { + this.imageName = imageName; + return this; + } + + public CreateBbcImageRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcImageResponse.java b/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcImageResponse.java new file mode 100644 index 00000000..1e6226f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcImageResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for creating bbc image + */ +public class CreateBbcImageResponse extends AbstractBceResponse { + /** + * The id of image which had been created + */ + private String imageId; + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcInstanceRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcInstanceRequest.java new file mode 100644 index 00000000..d22ca882 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcInstanceRequest.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for creating a bbc instance + */ +public class CreateBbcInstanceRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + + private String flavorId; + private String imageId; + private String raidId; + private int rootDiskSizeInGb; + private int purchaseCount; + private String zoneName; + private String subnetId; + private Billing billing; + private String name; + private String adminPass; + private List tags; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public String getRaidId() { + return raidId; + } + + public void setRaidId(String raidId) { + this.raidId = raidId; + } + + public int getRootDiskSizeInGb() { + return rootDiskSizeInGb; + } + + public void setRootDiskSizeInGb(int rootDiskSizeInGb) { + this.rootDiskSizeInGb = rootDiskSizeInGb; + } + + public int getPurchaseCount() { + return purchaseCount; + } + + public void setPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAdminPass() { + return adminPass; + } + + public void setAdminPass(String adminPass) { + this.adminPass = adminPass; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcInstanceResponse.java b/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcInstanceResponse.java new file mode 100644 index 00000000..3f4fba9c --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/CreateBbcInstanceResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for creating bbc instance + */ +public class CreateBbcInstanceResponse extends AbstractBceResponse { + /** + * The id list of instances which had been created + */ + private List instanceIds; + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/FlavorModel.java b/src/main/java/com/baidubce/services/bbc/model/instance/FlavorModel.java new file mode 100644 index 00000000..f6572afe --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/FlavorModel.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +/** + * The detail of flavor + */ +public class FlavorModel { + /** + * The id of flavor that belongs to bbc + */ + private String flavorId; + /** + * The cpu count + */ + private int cpuCount; + /** + * The type of CPU + */ + private String cpuType; + /** + * The memory capacity + */ + private int memoryCapacityInGB; + /** + * The disk information + */ + private String disk; + /** + * The network device information + */ + private String networkCard; + /** + * The other information of the flavor + */ + private String others; + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public String getCpuType() { + return cpuType; + } + + public void setCpuType(String cpuType) { + this.cpuType = cpuType; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + public String getDisk() { + return disk; + } + + public void setDisk(String disk) { + this.disk = disk; + } + + public String getNetworkCard() { + return networkCard; + } + + public void setNetworkCard(String networkCard) { + this.networkCard = networkCard; + } + + public String getOthers() { + return others; + } + + public void setOthers(String others) { + this.others = others; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcFlavorRaidResponse.java b/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcFlavorRaidResponse.java new file mode 100644 index 00000000..4b98501a --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcFlavorRaidResponse.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for bbc flavor raid + */ +public class GetBbcFlavorRaidResponse extends AbstractBceResponse { + + /** + * The id of flavor + */ + private String flavorId; + + /** + * The detail of flavor raid + */ + private List raids; + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public List getRaids() { + return raids; + } + + public void setRaids(List raids) { + this.raids = raids; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcFlavorRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcFlavorRequest.java new file mode 100644 index 00000000..4a46ff78 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcFlavorRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get bbc flavor + */ +public class GetBbcFlavorRequest extends AbstractBceRequest { + + /** + * The flavor id + */ + private String flavorId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public GetBbcFlavorRequest withFlavorId(String flavorId) { + this.flavorId = flavorId; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcFlavorResponse.java b/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcFlavorResponse.java new file mode 100644 index 00000000..166a5d1d --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcFlavorResponse.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for bbc flavor + */ +public class GetBbcFlavorResponse extends AbstractBceResponse { + /** + * The id of flavor that belongs to bbc + */ + private String flavorId; + /** + * The cpu count + */ + private int cpuCount; + /** + * The type of CPU + */ + private String cpuType; + /** + * The memory capacity + */ + private int memoryCapacityInGB; + /** + * The disk information + */ + private String disk; + /** + * The network device information + */ + private String networkCard; + /** + * The other information of the flavor + */ + private String others; + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public String getCpuType() { + return cpuType; + } + + public void setCpuType(String cpuType) { + this.cpuType = cpuType; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + public String getDisk() { + return disk; + } + + public void setDisk(String disk) { + this.disk = disk; + } + + public String getNetworkCard() { + return networkCard; + } + + public void setNetworkCard(String networkCard) { + this.networkCard = networkCard; + } + + public String getOthers() { + return others; + } + + public void setOthers(String others) { + this.others = others; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcInstanceResponse.java b/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcInstanceResponse.java new file mode 100644 index 00000000..6a3346f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/GetBbcInstanceResponse.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.TagModel; + +import java.util.List; + +/** + * The response of bbc instance + */ +public class GetBbcInstanceResponse extends AbstractBceResponse { + /** + * The id of instance + */ + private String id; + /** + * The name of instance + */ + private String name; + /** + * The working status of instance + */ + private String status; + /** + * The description of the instance. + */ + private String desc; + /** + * The payment method of purchasing the instance, + * see more detail in BCE API doc + */ + private String paymentTiming; + /** + * The time when the instance was created + */ + private String createTime; + /** + * The time when the instance will be expired. + * If it's Postpaid, it will not have expired time. + */ + private String expireTime; + /** + * The internal ip address for accessing. + */ + private String internalIp; + /** + * The public ip address for accessing. + */ + private String publicIp; + /** + * The id of flavor which belongs to instance + */ + private String flavorId; + /** + * The id which was used to build the instance. + */ + private String imageId; + /** + * The total bandwidth in Mbps for the instance. + */ + private int networkCapacityInMbps; + /** + * The region where the instance based on + */ + private String region; + /** + * The name of avaliable zone + */ + private String zone; + /** + * whether the instacne is auto renew or not + */ + private Boolean autoRenew; + + /** + * The list of bonded tags. + */ + private List tags; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getExpireTime() { + return expireTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + public String getInternalIp() { + return internalIp; + } + + public void setInternalIp(String internalIp) { + this.internalIp = internalIp; + } + + public String getPublicIp() { + return publicIp; + } + + public void setPublicIp(String publicIp) { + this.publicIp = publicIp; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public int getNetworkCapacityInMbps() { + return networkCapacityInMbps; + } + + public void setNetworkCapacityInMbps(int networkCapacityInMbps) { + this.networkCapacityInMbps = networkCapacityInMbps; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public Boolean getAutoRenew() { + return autoRenew; + } + + public void setAutoRenew(Boolean autoRenew) { + this.autoRenew = autoRenew; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/GetInstanceVpcRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/GetInstanceVpcRequest.java new file mode 100644 index 00000000..4a24dbb2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/GetInstanceVpcRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * The request for getting vpc/subnet of bbc instance + */ +public class GetInstanceVpcRequest extends AbstractBceRequest { + + /** + * The ids of bbc + */ + private List bbcIds; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public List getBbcIds() { + return bbcIds; + } + + /** + * Configure the bbc instanceId list for the request. + * + * @param bbcIds The id of instance. + * @return GetInstanceRequest with specified instanceId. + */ + public GetInstanceVpcRequest withBbcIds(List bbcIds) { + this.setBbcIds(bbcIds); + return this; + } + + public void setBbcIds(List bbcIds) { + this.bbcIds = bbcIds; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/GetInstanceVpcResponse.java b/src/main/java/com/baidubce/services/bbc/model/instance/GetInstanceVpcResponse.java new file mode 100644 index 00000000..56f89734 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/GetInstanceVpcResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for getting vpc/subnet of bbc instance + */ +public class GetInstanceVpcResponse extends AbstractBceResponse { + /** + * List of the vpc/subnet information + */ + private List networkInfo; + + public List getNetworkInfo() { + return networkInfo; + } + + public void setNetworkInfo(List networkInfo) { + this.networkInfo = networkInfo; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/InstanceModel.java b/src/main/java/com/baidubce/services/bbc/model/instance/InstanceModel.java new file mode 100644 index 00000000..9f234367 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/InstanceModel.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.services.bcc.model.TagModel; + +import java.util.List; + +/** + * The model of bbc instance + */ +public class InstanceModel { + private String id; + private String name; + private String status; + private String desc; + private String paymentTiming; + private String createTime; + private String expireTime; + private String internalIp; + private String publicIp; + private String flavorId; + private String imageId; + private int networkCapacityInMbps; + private String region; + private String zone; + private Boolean autoRenew; + private List tags; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getExpireTime() { + return expireTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + public String getInternalIp() { + return internalIp; + } + + public void setInternalIp(String internalIp) { + this.internalIp = internalIp; + } + + public String getPublicIp() { + return publicIp; + } + + public void setPublicIp(String publicIp) { + this.publicIp = publicIp; + } + + public String getFlavorId() { + return flavorId; + } + + public void setFlavorId(String flavorId) { + this.flavorId = flavorId; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public int getNetworkCapacityInMbps() { + return networkCapacityInMbps; + } + + public void setNetworkCapacityInMbps(int networkCapacityInMbps) { + this.networkCapacityInMbps = networkCapacityInMbps; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public Boolean getAutoRenew() { + return autoRenew; + } + + public void setAutoRenew(Boolean autoRenew) { + this.autoRenew = autoRenew; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcFlavorResponse.java b/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcFlavorResponse.java new file mode 100644 index 00000000..0dd37d0b --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcFlavorResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response of all bbc flavor + */ +public class ListBbcFlavorResponse extends AbstractBceResponse { + /** + * The return data of flavor list + */ + private List flavors; + + public List getFlavors() { + return flavors; + } + + public void setFlavors(List flavors) { + this.flavors = flavors; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcFlavorsRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcFlavorsRequest.java new file mode 100644 index 00000000..24d540a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcFlavorsRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request of getting bbc flavors + */ +public class ListBbcFlavorsRequest extends AbstractBceRequest { + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcInstancesRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcInstancesRequest.java new file mode 100644 index 00000000..e782b924 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcInstancesRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; + +/** + * Request for list bbc instance + */ +public class ListBbcInstancesRequest extends ListRequest { + + /** + * The identified internal ip of bbc instance. + */ + private String internalIp; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getInternalIp() { + return internalIp; + } + + public void setInternalIp(String internalIp) { + this.internalIp = internalIp; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcInstancesResponse.java b/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcInstancesResponse.java new file mode 100644 index 00000000..d43c3bc2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/ListBbcInstancesResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The model of list bbc instances + */ +public class ListBbcInstancesResponse extends ListResponse { + + /** + * The list of bbc instance + */ + private List instances; + + public List getInstances() { + return instances; + } + + public void setInstances(List instances) { + this.instances = instances; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/ListOperationLogRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/ListOperationLogRequest.java new file mode 100644 index 00000000..9aef095c --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/ListOperationLogRequest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; + +/** + * The request for list operation log + */ +public class ListOperationLogRequest extends ListRequest { + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * The start time of operation.If is empty,means the operation of today. + */ + private String startTime; + /** + * The end time of operation. + */ + private String endTime; + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/ListOperationLogResponse.java b/src/main/java/com/baidubce/services/bbc/model/instance/ListOperationLogResponse.java new file mode 100644 index 00000000..152e6cab --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/ListOperationLogResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response for operation log list + */ +public class ListOperationLogResponse extends ListResponse { + + /** + * The list of operation logs + */ + private List operationLogs; + + public List getOperationLogs() { + return operationLogs; + } + + public void setOperationLogs(List operationLogs) { + this.operationLogs = operationLogs; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/OperationLogModel.java b/src/main/java/com/baidubce/services/bbc/model/instance/OperationLogModel.java new file mode 100644 index 00000000..d959cf8f --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/OperationLogModel.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +/** + * The detail of Operation + */ +public class OperationLogModel { + + /** + * The status of operation,true means success,false means failure + */ + private Boolean operationStatus; + /** + * The time of operation + */ + private String operationTime; + /** + * The description of operation + */ + private String operationDesc; + /** + * The ip where the operation from. + */ + private String operationIp; + + public Boolean getOperationStatus() { + return operationStatus; + } + + public void setOperationStatus(Boolean operationStatus) { + this.operationStatus = operationStatus; + } + + public String getOperationTime() { + return operationTime; + } + + public void setOperationTime(String operationTime) { + this.operationTime = operationTime; + } + + public String getOperationDesc() { + return operationDesc; + } + + public void setOperationDesc(String operationDesc) { + this.operationDesc = operationDesc; + } + + public String getOperationIp() { + return operationIp; + } + + public void setOperationIp(String operationIp) { + this.operationIp = operationIp; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/RaidModel.java b/src/main/java/com/baidubce/services/bbc/model/instance/RaidModel.java new file mode 100644 index 00000000..10c3f356 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/RaidModel.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +/** + * The detail of flavor raid + */ +public class RaidModel { + /** + * The id of raid + */ + private String raidId; + /** + * The name of raid + */ + private String raid; + /** + * The system swap default size + */ + private int sysSwapSize; + /** + * The system root default size + */ + private int sysRootSize; + /** + * The system /home default size + */ + private int sysHomeSize; + /** + * The system disk total size + */ + private int sysDiskSize; + /** + * The data disk total size + */ + private int dataDiskSize; + + public String getRaidId() { + return raidId; + } + + public void setRaidId(String raidId) { + this.raidId = raidId; + } + + public String getRaid() { + return raid; + } + + public void setRaid(String raid) { + this.raid = raid; + } + + public int getSysSwapSize() { + return sysSwapSize; + } + + public void setSysSwapSize(int sysSwapSize) { + this.sysSwapSize = sysSwapSize; + } + + public int getSysRootSize() { + return sysRootSize; + } + + public void setSysRootSize(int sysRootSize) { + this.sysRootSize = sysRootSize; + } + + public int getSysHomeSize() { + return sysHomeSize; + } + + public void setSysHomeSize(int sysHomeSize) { + this.sysHomeSize = sysHomeSize; + } + + public int getSysDiskSize() { + return sysDiskSize; + } + + public void setSysDiskSize(int sysDiskSize) { + this.sysDiskSize = sysDiskSize; + } + + public int getDataDiskSize() { + return dataDiskSize; + } + + public void setDataDiskSize(int dataDiskSize) { + this.dataDiskSize = dataDiskSize; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/RebuildBbcInstanceRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/RebuildBbcInstanceRequest.java new file mode 100644 index 00000000..bb1f04b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/RebuildBbcInstanceRequest.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for rebuild bbc instance + */ +public class RebuildBbcInstanceRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The id which was used to build the instance. + */ + private String imageId; + + /** + * The admin password to login the instance. + *

+ * The admin password to login the instance. + * The adminPass will be encrypt in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * See more detail on + * + * BCE API doc + */ + private String adminPass; + /** + * Reserving the data or not. + * If the value is true,the raidId and sysRootSize are ineffective + */ + private Boolean isPreserveData; + /** + * The id of flavor raid. + * This value is ineffective when isPreserveData is true ,and is required when isPreserveData is false. + */ + private String raidId; + /** + * The size of system root + * This value is ineffective when isPreserveData is true ,and is required when isPreserveData is false. + */ + private int sysRootSize; + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public String getAdminPass() { + return adminPass; + } + + public void setAdminPass(String adminPass) { + this.adminPass = adminPass; + } + + public Boolean getIsPreserveData() { + return isPreserveData; + } + + public void setIsPreserveData(Boolean preserveData) { + isPreserveData = preserveData; + } + + public String getRaidId() { + return raidId; + } + + public void setRaidId(String raidId) { + this.raidId = raidId; + } + + public int getSysRootSize() { + return sysRootSize; + } + + public void setSysRootSize(int sysRootSize) { + this.sysRootSize = sysRootSize; + } + + public RebuildBbcInstanceRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public RebuildBbcInstanceRequest withAdminPass(String adminPass) { + this.adminPass = adminPass; + return this; + } + + public RebuildBbcInstanceRequest withImageId(String imageId) { + this.imageId = imageId; + return this; + } + + public RebuildBbcInstanceRequest isPreservedData(Boolean bool) { + this.isPreserveData = bool; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/RenameBbcInstanceRequest.java b/src/main/java/com/baidubce/services/bbc/model/instance/RenameBbcInstanceRequest.java new file mode 100644 index 00000000..b1238ce4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/RenameBbcInstanceRequest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request of rename bbc instance + */ +public class RenameBbcInstanceRequest extends AbstractBceRequest { + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The new value for instance's name. + */ + private String name; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getInstanceId() { + return instanceId; + } + + public RenameBbcInstanceRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public RenameBbcInstanceRequest withName(String name) { + this.name = name; + return this; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/SubnetModel.java b/src/main/java/com/baidubce/services/bbc/model/instance/SubnetModel.java new file mode 100644 index 00000000..64b90330 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/SubnetModel.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +/** + * The detail model of subnet + */ +public class SubnetModel { + /** + * The vpc id + */ + private String vpcId; + + /** + * The subnet name + */ + private String name; + + /** + * The subnet type + */ + private String subnetType; + + /** + * The subnet id + */ + private String subnetId; + + /** + * The cidr of subnet + */ + private String cidr; + + /** + * The zone name of subnet + */ + private String zoneName; + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSubnetType() { + return subnetType; + } + + public void setSubnetType(String subnetType) { + this.subnetType = subnetType; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getCidr() { + return cidr; + } + + public void setCidr(String cidr) { + this.cidr = cidr; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } +} diff --git a/src/main/java/com/baidubce/services/bbc/model/instance/VpcModel.java b/src/main/java/com/baidubce/services/bbc/model/instance/VpcModel.java new file mode 100644 index 00000000..e3d75ca8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bbc/model/instance/VpcModel.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bbc.model.instance; + +/** + * The detail model of Vpc + */ +public class VpcModel { + /** + * The id of Vpc + */ + private String vpcId; + + /** + * The cidr of Vpc + */ + private String cidr; + + /** + * The Vpc name + */ + private String name; + + /** + * Whether is the default Vpc + */ + private Boolean isDefault; + + /** + * The description of Vpc + */ + private String description; + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getCidr() { + return cidr; + } + + public void setCidr(String cidr) { + this.cidr = cidr; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getDefault() { + return isDefault; + } + + public void setDefault(Boolean aDefault) { + isDefault = aDefault; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/BccClient.java b/src/main/java/com/baidubce/services/bcc/BccClient.java new file mode 100644 index 00000000..cf1ae174 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/BccClient.java @@ -0,0 +1,4073 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.Reservation; +import com.baidubce.services.bcc.model.SecurityGroupModel; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.bcc.model.TagsOperationRequest; +import com.baidubce.services.bcc.model.asp.AspAction; +import com.baidubce.services.bcc.model.asp.AttachAspRequest; +import com.baidubce.services.bcc.model.asp.CreateAspRequest; +import com.baidubce.services.bcc.model.asp.CreateAspResponse; +import com.baidubce.services.bcc.model.asp.DeleteAspRequest; +import com.baidubce.services.bcc.model.asp.DetachAspRequest; +import com.baidubce.services.bcc.model.asp.GetAspRequest; +import com.baidubce.services.bcc.model.asp.GetAspResponse; +import com.baidubce.services.bcc.model.asp.ListAspsRequest; +import com.baidubce.services.bcc.model.asp.ListAspsResponse; +import com.baidubce.services.bcc.model.asp.UpdateAspRequest; +import com.baidubce.services.bcc.model.deployset.CreateDeploySetRequest; +import com.baidubce.services.bcc.model.deployset.CreateDeploySetResponse; +import com.baidubce.services.bcc.model.deployset.DeleteDeploySetRequest; +import com.baidubce.services.bcc.model.deployset.DeploySetAction; +import com.baidubce.services.bcc.model.deployset.ListDeploySetResponse; +import com.baidubce.services.bcc.model.deployset.UpdateDeploySetRequest; +import com.baidubce.services.bcc.model.flavor.ListBccBidFlavorResponse; +import com.baidubce.services.bcc.model.flavor.ListBccFlavorSpecResponse; +import com.baidubce.services.bcc.model.flavor.ListFlavorSpecRequest; +import com.baidubce.services.bcc.model.image.CancelRemoteCopyImageRequest; +import com.baidubce.services.bcc.model.image.CreateImageRequest; +import com.baidubce.services.bcc.model.image.CreateImageResponse; +import com.baidubce.services.bcc.model.image.DeleteImageRequest; +import com.baidubce.services.bcc.model.image.GetAvailableImagesBySpecRequest; +import com.baidubce.services.bcc.model.image.GetAvailableImagesBySpecResponse; +import com.baidubce.services.bcc.model.image.GetImageRequest; +import com.baidubce.services.bcc.model.image.GetImageResponse; +import com.baidubce.services.bcc.model.image.ImageAction; +import com.baidubce.services.bcc.model.image.ListImagesRequest; +import com.baidubce.services.bcc.model.image.ListImagesResponse; +import com.baidubce.services.bcc.model.image.ListOsRequest; +import com.baidubce.services.bcc.model.image.ListOsResponse; +import com.baidubce.services.bcc.model.image.ListSharedUserRequest; +import com.baidubce.services.bcc.model.image.ListSharedUserResponse; +import com.baidubce.services.bcc.model.image.RemoteCopyImageRequest; +import com.baidubce.services.bcc.model.image.ShareImageRequest; +import com.baidubce.services.bcc.model.image.UnShareImageRequest; +import com.baidubce.services.bcc.model.instance.BatchAddIpRequest; +import com.baidubce.services.bcc.model.instance.BatchAddIpResponse; +import com.baidubce.services.bcc.model.instance.BatchChangeToPrepaidRequest; +import com.baidubce.services.bcc.model.instance.BatchChangeToPrepaidResponse; +import com.baidubce.services.bcc.model.instance.BatchDeleteIpRequest; +import com.baidubce.services.bcc.model.instance.BatchRefundResourceRequest; +import com.baidubce.services.bcc.model.instance.BatchRefundResourceResponse; +import com.baidubce.services.bcc.model.instance.BatchStopInstanceRequest; +import com.baidubce.services.bcc.model.instance.BccAutoRenewRequest; +import com.baidubce.services.bcc.model.instance.BccPriceRequest; +import com.baidubce.services.bcc.model.instance.BccPriceResponse; +import com.baidubce.services.bcc.model.instance.BindSecurityGroupRequest; +import com.baidubce.services.bcc.model.instance.BindTagsRequest; +import com.baidubce.services.bcc.model.instance.CancelBidOrderRequest; +import com.baidubce.services.bcc.model.instance.CancelBidOrderResponse; +import com.baidubce.services.bcc.model.instance.ChangeInstanceSubnetRequest; +import com.baidubce.services.bcc.model.instance.ChangeToPrepaidRequest; +import com.baidubce.services.bcc.model.instance.ChangeToPrepaidResponse; +import com.baidubce.services.bcc.model.instance.ChangeVpcRequest; +import com.baidubce.services.bcc.model.instance.CreateEhcClusterRequest; +import com.baidubce.services.bcc.model.instance.CreateEhcClusterResponse; +import com.baidubce.services.bcc.model.instance.CreateInstanceRequest; +import com.baidubce.services.bcc.model.instance.CreateInstanceResponse; +import com.baidubce.services.bcc.model.instance.DeleteEhcClusterRequest; +import com.baidubce.services.bcc.model.instance.DeleteInstanceDeploysetRequest; +import com.baidubce.services.bcc.model.instance.DeleteRecycledInstanceRequest; +import com.baidubce.services.bcc.model.instance.DescribeEhcClusterListRequest; +import com.baidubce.services.bcc.model.instance.DescribeEhcClusterListResponse; +import com.baidubce.services.bcc.model.instance.FpgaCardType; +import com.baidubce.services.bcc.model.instance.GetBidInstancePriceRequest; +import com.baidubce.services.bcc.model.instance.GetBidInstancePriceResponse; +import com.baidubce.services.bcc.model.instance.GetInstanceRequest; +import com.baidubce.services.bcc.model.instance.GetInstanceResponse; +import com.baidubce.services.bcc.model.instance.GetInstanceVncRequest; +import com.baidubce.services.bcc.model.instance.GetInstanceVncResponse; +import com.baidubce.services.bcc.model.instance.GpuCardType; +import com.baidubce.services.bcc.model.instance.InstanceAction; +import com.baidubce.services.bcc.model.instance.InstanceAddIpv6Response; +import com.baidubce.services.bcc.model.instance.InstanceIpv6Request; +import com.baidubce.services.bcc.model.instance.InstanceType; +import com.baidubce.services.bcc.model.instance.ListAvailableResizeSpecRequest; +import com.baidubce.services.bcc.model.instance.ListAvailableResizeSpecResponse; +import com.baidubce.services.bcc.model.instance.ListGetInstanceNoChargeRequest; +import com.baidubce.services.bcc.model.instance.ListInstanceByIdsRequest; +import com.baidubce.services.bcc.model.instance.ListInstanceEnisRequest; +import com.baidubce.services.bcc.model.instance.ListInstanceEnisResponse; +import com.baidubce.services.bcc.model.instance.ListInstanceSpecsRequest; +import com.baidubce.services.bcc.model.instance.ListInstanceSpecsResponse; +import com.baidubce.services.bcc.model.instance.ListInstancesRequest; +import com.baidubce.services.bcc.model.instance.ListInstancesResponse; +import com.baidubce.services.bcc.model.instance.ListRecycleInstanceRequest; +import com.baidubce.services.bcc.model.instance.ListRecycleInstanceResponse; +import com.baidubce.services.bcc.model.instance.ModifyEhcClusterRequest; +import com.baidubce.services.bcc.model.instance.ModifyInstanceAttributesRequest; +import com.baidubce.services.bcc.model.instance.ModifyInstanceDescRequest; +import com.baidubce.services.bcc.model.instance.ModifyInstanceHostnameRequest; +import com.baidubce.services.bcc.model.instance.ModifyInstancePasswordRequest; +import com.baidubce.services.bcc.model.instance.PurchaseReservedInstanceRequeset; +import com.baidubce.services.bcc.model.instance.PurchaseReservedInstanceResponse; +import com.baidubce.services.bcc.model.instance.RebootInstanceRequest; +import com.baidubce.services.bcc.model.instance.RebuildBatchInstanceRequest; +import com.baidubce.services.bcc.model.instance.RebuildInstanceRequest; +import com.baidubce.services.bcc.model.instance.ReleaseInstanceByPostRequest; +import com.baidubce.services.bcc.model.instance.ReleaseInstanceRequest; +import com.baidubce.services.bcc.model.instance.ReleaseMultipleInstancesRequest; +import com.baidubce.services.bcc.model.instance.ReleasePrepaidInstanceRequest; +import com.baidubce.services.bcc.model.instance.ReleasePrepaidInstanceResponse; +import com.baidubce.services.bcc.model.instance.ResizeInstanceRequest; +import com.baidubce.services.bcc.model.instance.StartInstanceRequest; +import com.baidubce.services.bcc.model.instance.StopInstanceRequest; +import com.baidubce.services.bcc.model.instance.UnbindSecurityGroupRequest; +import com.baidubce.services.bcc.model.instance.UnbindTagsRequest; +import com.baidubce.services.bcc.model.keypair.KeypairAction; +import com.baidubce.services.bcc.model.keypair.KeypairAttachRequest; +import com.baidubce.services.bcc.model.keypair.KeypairCreateRequest; +import com.baidubce.services.bcc.model.keypair.KeypairCreateResponse; +import com.baidubce.services.bcc.model.keypair.KeypairDeleteRequest; +import com.baidubce.services.bcc.model.keypair.KeypairDetachRequest; +import com.baidubce.services.bcc.model.keypair.KeypairDetailRequest; +import com.baidubce.services.bcc.model.keypair.KeypairImportRequest; +import com.baidubce.services.bcc.model.keypair.KeypairListRequest; +import com.baidubce.services.bcc.model.keypair.KeypairListResponse; +import com.baidubce.services.bcc.model.keypair.KeypairModel; +import com.baidubce.services.bcc.model.keypair.KeypairRenameRequest; +import com.baidubce.services.bcc.model.keypair.KeypairResponse; +import com.baidubce.services.bcc.model.keypair.KeypairUpdateDescRequest; +import com.baidubce.services.bcc.model.region.DescribeRegionsRequest; +import com.baidubce.services.bcc.model.region.DescribeRegionsResponse; +import com.baidubce.services.bcc.model.reversed.CreateReservedInstanceResponse; +import com.baidubce.services.bcc.model.reversed.CreateReservedInstancesRequest; +import com.baidubce.services.bcc.model.reversed.ModifyReservedInstancesResponse; +import com.baidubce.services.bcc.model.reversed.ModifyReservedInstancesRequest; +import com.baidubce.services.bcc.model.reversed.ReservedTagsRequest; +import com.baidubce.services.bcc.model.securitygroup.CreateSecurityGroupRequest; +import com.baidubce.services.bcc.model.securitygroup.CreateSecurityGroupResponse; +import com.baidubce.services.bcc.model.securitygroup.DeleteSecurityGroupRequest; +import com.baidubce.services.bcc.model.securitygroup.DeleteSecurityGroupRuleRequest; +import com.baidubce.services.bcc.model.securitygroup.GetSecurityGroupRequest; +import com.baidubce.services.bcc.model.securitygroup.ListSecurityGroupsRequest; +import com.baidubce.services.bcc.model.securitygroup.ListSecurityGroupsResponse; +import com.baidubce.services.bcc.model.securitygroup.SecurityGroupAction; +import com.baidubce.services.bcc.model.securitygroup.SecurityGroupRuleOperateRequest; +import com.baidubce.services.bcc.model.securitygroup.UpdateSecurityGroupRuleRequest; +import com.baidubce.services.bcc.model.snapshot.CreateSnapshotRequest; +import com.baidubce.services.bcc.model.snapshot.CreateSnapshotResponse; +import com.baidubce.services.bcc.model.snapshot.DeleteSnapshotRequest; +import com.baidubce.services.bcc.model.snapshot.GetSnapshotRequest; +import com.baidubce.services.bcc.model.snapshot.GetSnapshotResponse; +import com.baidubce.services.bcc.model.snapshot.ListSnapchainRequest; +import com.baidubce.services.bcc.model.snapshot.ListSnapchainResponse; +import com.baidubce.services.bcc.model.snapshot.ListSnapshotsRequest; +import com.baidubce.services.bcc.model.snapshot.ListSnapshotsResponse; +import com.baidubce.services.bcc.model.volume.AttachVolumeRequest; +import com.baidubce.services.bcc.model.volume.AttachVolumeResponse; +import com.baidubce.services.bcc.model.volume.AutoRenewVolumeClusterRequest; +import com.baidubce.services.bcc.model.volume.AutoRenewVolumeRequest; +import com.baidubce.services.bcc.model.volume.CancelAutoRenewVolumeClusterRequest; +import com.baidubce.services.bcc.model.volume.CancelAutoRenewVolumeRequest; +import com.baidubce.services.bcc.model.volume.CreateVolumeClusterRequest; +import com.baidubce.services.bcc.model.volume.CreateVolumeClusterResponse; +import com.baidubce.services.bcc.model.volume.CreateVolumeRequest; +import com.baidubce.services.bcc.model.volume.CreateVolumeResponse; +import com.baidubce.services.bcc.model.volume.DetachVolumeRequest; +import com.baidubce.services.bcc.model.volume.GetVolumeClusterRequest; +import com.baidubce.services.bcc.model.volume.GetVolumeClusterResponse; +import com.baidubce.services.bcc.model.volume.GetVolumeRequest; +import com.baidubce.services.bcc.model.volume.GetVolumeResponse; +import com.baidubce.services.bcc.model.volume.ListVolumeClustersRequest; +import com.baidubce.services.bcc.model.volume.ListVolumeClustersResponse; +import com.baidubce.services.bcc.model.volume.ListVolumesRequest; +import com.baidubce.services.bcc.model.volume.ListVolumesResponse; +import com.baidubce.services.bcc.model.volume.ModifyCdsAttrRequest; +import com.baidubce.services.bcc.model.volume.ModifyVolumeChargeRequest; +import com.baidubce.services.bcc.model.volume.ModifyVolumeChargeTypeRequest; +import com.baidubce.services.bcc.model.volume.PurchaseReservedVolumeClusterRequest; +import com.baidubce.services.bcc.model.volume.PurchaseReservedVolumeRequest; +import com.baidubce.services.bcc.model.volume.ReleaseVolumeRequest; +import com.baidubce.services.bcc.model.volume.RenameVolumeRequest; +import com.baidubce.services.bcc.model.volume.ResizeVolumeClusterRequest; +import com.baidubce.services.bcc.model.volume.ResizeVolumeRequest; +import com.baidubce.services.bcc.model.volume.ResizeVolumeResponse; +import com.baidubce.services.bcc.model.volume.RollbackVolumeRequest; +import com.baidubce.services.bcc.model.volume.VolumeAction; +import com.baidubce.services.bcc.model.volume.VolumePriceRequest; +import com.baidubce.services.bcc.model.volume.VolumePriceResponse; +import com.baidubce.services.bcc.model.zone.ListZonesResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; +import org.apache.commons.codec.binary.Hex; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkIsTrue; +import static com.baidubce.util.Validate.checkMultyParamsNotBothEmpty; +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkResourceType; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkState; + + +/** + * Provides the client for accessing the Baidu Cloud Compute Service(bcc). + */ +public class BccClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(BccClient.class); + + private static final String VERSION = "v2"; + private static final String VERSION_V3 = "v3"; + private static final String INSTANCE_PREFIX = "instance"; + private static final String VPC_PREFIX = "vpc"; + private static final String ENI_PREFIX = "eni"; + private static final String CHANGE_VPC = "changeVpc"; + private static final String RECYCLE_INSTANCE = "recycle/instance"; + private static final String REGION_PREFIX = "region"; + private static final String DESCRIBE_REGIONS = "describeRegions"; + private static final String LIST_BY_INSTANCE_ID_PREFIX = "listByInstanceId"; + private static final String INSTANCE_BY_SPEC_PREFIX = "instanceBySpec"; + private static final String BID = "bid"; + private static final String FLAVOR_SPEC_PREFIX = "flavorSpec"; + private static final String VOLUME_PREFIX = "volume"; + private static final String IMAGE_PREFIX = "image"; + private static final String OS_PREFIX = "os"; + private static final String SECURITYGROUP_PREFIX = "securityGroup"; + private static final String SNAPSHOT_PREFIX = "snapshot"; + private static final String ZONE = "zone"; + private static final String TAG = "tag"; + private static final String ASP = "asp"; + private static final String KEYPAIR = "keypair"; + private static final String SHARED_USER = "sharedUsers"; + private static final String CLIENT_TOKEN = "clientToken"; + private static final String RELATED_RENEW_FLAG = "relatedRenewFlag"; + private static final String MARKER = "marker"; + private static final String MAX_KEYS = "maxKeys"; + private static final String ZONE_NAME = "zoneName"; + + private static final String EHC_CLUSTER_ID = "ehcClusterId"; + private static final String INTERNAL_IP = "internalIp"; + private static final String DEDICATED_HOST_ID = "dedicatedHostId"; + private static final String IMAGE_TYPE = "imageType"; + private static final String IMAGE_NAME = "imageName"; + private static final String VOLUME_NAME = "volumeName"; + private static final String VPC_ID = "vpcId"; + private static final String FLAVOR_SPEC = "flavorSpec"; + private static final String PRICE = "price"; + private static final String DEPLOYSET = "deployset"; + private static final String CHAIN = "chain"; + private static final String BID_FLAVOR = "bidFlavor"; + private static final String BID_PRICE = "bidPrice"; + private static final String CANCEL_BID_ORDER = "cancelBidOrder"; + private static final String NO_CHARGE = "noCharge"; + private static final String REBUILD = "rebuild"; + private static final String SUBNET_PREFIX = "subnet"; + private static final String CHANGE_SUBNET = "changeSubnet"; + private static final String DEL_RELATION = "delRelation"; + private static final String SECURITY_GROUP_RULE_PREFIX = "rule"; + private static final String SECURITY_GROUP_RULE_UPDATE_PREFIX = "update"; + private static final String SYNC_CREATE = "syncCreate"; + private static final String BATCH_DELETE = "batchDelete"; + + private static final String DELETE = "delete"; + private static final String RECYCLE = "recycle"; + private static final String ORDERBY = "orderBy"; + private static final String ORDER = "order"; + private static final String PAGENO = "pageNo"; + private static final String PAGESIZE = "pageSize"; + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String CHANGETAGS_NULL_ERROR_MESSAGE = "request changeTags should not be null."; + private static final String INSTANCEID_MESSAGE_KEY = "instanceId"; + private static final String INSTANCEIDLIST_MESSAGE_KEY = "instanceIdList"; + private static final String DEPLOYSET_MESSAGE_KEY = "deployId"; + private static final String INSTANCE_TYPE_MESSAGE_KEY = "instanceType"; + private static final String ORDER_ID_MESSAGE_KEY = "orderId"; + private static final String TAGKEY_MESSAGE_KEY = "tagKey"; + private static final String ADMINPASS_MESSAGE_KEY = "adminPass"; + private static final String IMAGEID_MESSAGE_KEY = "imageId"; + private static final String NAME_MESSAGE_KEY = "name"; + private static final String DESC_MESSAGE_KEY = "desc"; + private static final String SECURITYGROUPID_MESSAGE_KEY = "securityGroupId"; + private static final String VOLUMEID_MESSAGE_KEY = "volumeId"; + private static final String SNAPSHOTID_MESSAGE_KEY = "snapshotId"; + private static final String IMAGENAME_MESSAGE_KEY = "imageName"; + private static final String SNAPSHOTNAME_MESSAGE_KEY = "snapshotName"; + private static final String ASPNAME_MESSAGE_KEY = "aspName"; + private static final String ASPID_MESSAGE_KEY = "aspId"; + private static final String KEYPAIR_ID_MESSAGE_KEY = "keypair"; + private static final String SUBNETID_MESSAGE_KEY = "subnetId"; + private static final String SECURITY_GROUP_RULE_ID_MESSAGE_KEY = "securityGroupRuleId"; + private static final String CLUSTERID_MESSAGE_KEY = "clusterId"; + private static final String CLUSTER_NAME_MESSAGE_KEY = "clusterName"; + + private static final String ZONE_NAME_MESSAGE_KEY = "zoneName"; + private static final String VOLUME_CLUSTER_PREFIX = "volume/cluster"; + private static final String UUID_FLAG = "uuidFlag"; + private static final String GET_PRICE = "getPrice"; + private static final String CREATA_AUTO_RENEW_RULE = "batchCreateAutoRenewRules"; + private static final String DELETE_AUTO_RENEW_RULE = "batchDeleteAutoRenewRules"; + + private static final String BATCH_CHARGING = "batch/charging"; + + private static final String EHC_CLUSTER_CREATE = "ehc/cluster/create"; + + private static final String EHC_CLUSTER_LIST = "ehc/cluster/list"; + + public static final String EHC_CLUSTER_MODIFY = "ehc/cluster/modify"; + + private static final String EHC_CLUSTER_DELETE = "ehc/cluster/delete"; + + private static final String RESIZE_LIST = "resizeList"; + private static final String BCC_RESERVED_PREFIX = "instance/reserved"; + private static final String BCC_RESERVED_TAG_PREFIX = "bcc/reserved/tag"; + private static final String BBC_RESERVED_TAG_PREFIX = "bbc/reserved/tag"; + private static final String V3_TAG_PREFIX = "bcc/tag"; + private static final String BIND = "bind"; + private static final String UNBIND = "unbind"; + private static final String ACTION = "action"; + private static final String ATTACH = "AttachTags"; + private static final String DETACH = "DetachTags"; + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling httpResponses from all bcc service calls. + */ + private static final HttpResponseHandler[] bcc_handlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on bcc. + */ + public BccClient() { + this(new BccClientConfiguration()); + } + + /** + * Constructs a new bcc client using the client configuration to access bcc. + * + * @param clientConfiguration The bcc client configuration options controlling how this client + * connects to bcc (e.g. proxy settings, retry counts, etc). + */ + public BccClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, bcc_handlers); + } + + + /** + * Creates and initializes a new request object for the specified bcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + private InternalRequest createRequestV3(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION_V3); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * The encryption implement for AES-128 algorithm for BCE password encryption. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + *

+ * See more detail on + * + * BCE API doc + * + * @param content The content String to encrypt. + * @param privateKey The security key to encrypt. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + * @return The encrypted string of the original content with AES-128 algorithm. + * @throws GeneralSecurityException + */ + private String aes128WithFirst16Char(String content, String privateKey) throws GeneralSecurityException { + byte[] crypted = null; + SecretKeySpec skey = new SecretKeySpec(privateKey.substring(0, 16).getBytes(), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, skey); + crypted = cipher.doFinal(content.getBytes()); + return new String(Hex.encodeHex(crypted)); + } + + /** + * The method to generate a default Billing which is Postpaid. + * + * @return The Billing object with Postpaid PaymentTiming. + */ + private Billing generateDefaultBilling() { + Billing billing = new Billing(); + billing.setPaymentTiming("Postpaid"); + return billing; + } + + /** + * The method to generate a default Billing with default Reservation which default ReservationLength is 1. + * + * @return The Billing object with default Reservation which default ReservationLength is 1 + */ + private Billing generateDefaultBillingWithReservation() { + Billing billing = new Billing(); + billing.withReservation(new Reservation().withReservationLength(1)); + return billing; + } + + /** + * Create a bcc Instance with the specified options, + * see all the supported instance in {@link com.baidubce.services.bcc.model.instance.InstanceType} + * You must fill the field with clientToken,which is especially for keeping idempotent. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for creating a bcc Instance. + * @return List of instanceId newly created + * @throws BceClientException + */ + public CreateInstanceResponse createInstance(CreateInstanceRequest request) + throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + if (null != request.getTags() && !request.getTags().isEmpty()) { + for (TagModel tag : request.getTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + } + if (InstanceType.G1.name().equalsIgnoreCase(request.getInstanceType())) { + checkIsTrue(GpuCardType.isExists(request.getGpuCard()), "invalid gpgCard parameter"); + checkIsTrue(request.getCardCount() > 0, "invalid cardCount parameter"); + } + if (InstanceType.F1.name().equalsIgnoreCase(request.getInstanceType())) { + checkIsTrue(FpgaCardType.isExists(request.getFpgaCard()), "invalid fpgaCard parameter"); + checkIsTrue(request.getCardCount() > 0, "invalid cardCount parameter"); + } + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + if (!Strings.isNullOrEmpty(request.getAdminPass())) { + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateInstanceResponse.class); + } + + /** + * Create a bcc Instance by spec + * see all the supported instance in {@link com.baidubce.services.bcc.model.instance.InstanceType} + * You must fill the field with clientToken,which is especially for keeping idempotent. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for creating a bcc Instance. + * @return List of instanceId newly created + * @throws BceClientException + */ + public CreateInstanceResponse createInstanceBySpec(CreateInstanceRequest request) + throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + if (null != request.getTags() && !request.getTags().isEmpty()) { + for (TagModel tag : request.getTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + } + if (StringUtils.isEmpty(request.getSpec())) { + if (InstanceType.G1.name().equalsIgnoreCase(request.getInstanceType())) { + checkIsTrue(GpuCardType.isExists(request.getGpuCard()), "invalid gpgCard parameter"); + checkIsTrue(request.getCardCount() > 0, "invalid cardCount parameter"); + } + if (InstanceType.F1.name().equalsIgnoreCase(request.getInstanceType())) { + checkIsTrue(FpgaCardType.isExists(request.getFpgaCard()), "invalid fpgaCard parameter"); + checkIsTrue(request.getCardCount() > 0, "invalid cardCount parameter"); + } + } + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_BY_SPEC_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + if (!Strings.isNullOrEmpty(request.getAdminPass())) { + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateInstanceResponse.class); + } + + /** + * Create a bcc bidding Instance with the specified options, + * You must fill the field with clientToken,which is especially for keeping idempotent. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for creating a bcc bidding Instance. + * @return List of instanceId newly created + * @throws BceClientException + */ + public CreateInstanceResponse createBidInstance(CreateInstanceRequest request) + throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling().withPaymentTiming("bidding")); + } + if (null != request.getTags() && !request.getTags().isEmpty()) { + for (TagModel tag : request.getTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + } + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX, BID); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + if (!Strings.isNullOrEmpty(request.getAdminPass())) { + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateInstanceResponse.class); + } + + /** + * Get the price information of specified instance. + * + * @param request The request containing all options for get specified bcc price. + * @return specified bcc price model. + */ + public BccPriceResponse getPriceBySpec(BccPriceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX, PRICE); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + + return invokeHttpClient(internalRequest, BccPriceResponse.class); + } + + + /** + * Return a list of instances owned by the authenticated user. + * + * @return The response containing a list of instances owned by the authenticated user. + */ + public ListInstancesResponse listInstances() { + return this.listInstances(new ListInstancesRequest()); + } + + /** + * Return a list of instances owned by the authenticated user. + * + * @param request The request containing all options for listing owns bcc Instance. + * @return The response containing a list of instances owned by the authenticated user. + */ + public ListInstancesResponse listInstances(ListInstancesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, INSTANCE_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getInternalIp())) { + internalRequest.addParameter(INTERNAL_IP, request.getInternalIp()); + } + if (!Strings.isNullOrEmpty(request.getDedicatedHostId())) { + internalRequest.addParameter(DEDICATED_HOST_ID, request.getDedicatedHostId()); + } + if (!Strings.isNullOrEmpty(request.getZoneName())) { + internalRequest.addParameter(ZONE_NAME, request.getZoneName()); + } + if (!Strings.isNullOrEmpty(request.getEhcClusterId())) { + internalRequest.addParameter(EHC_CLUSTER_ID, request.getEhcClusterId()); + } + return invokeHttpClient(internalRequest, ListInstancesResponse.class); + } + + /** + * Return a list of instances owned by the authenticated user. + * + * @param request The request containing all options for listing owns bcc Instance. + * @return The response containing a list of instances owned by the authenticated user. + */ + public ListInstancesResponse listInstanceByIds(ListInstanceByIdsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + INSTANCE_PREFIX, + LIST_BY_INSTANCE_ID_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ListInstancesResponse.class); + } + + /** + * Return a list of flavorSpec owned by the authenticated user. + * + * @param request The request containing all options for listing owns flavor spec. + * @return The response containing a list of flavor spec owned by the authenticated user. + */ + public ListBccFlavorSpecResponse listFlavorSpec(ListFlavorSpecRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, INSTANCE_PREFIX, FLAVOR_SPEC); + if (!Strings.isNullOrEmpty(request.getZoneName())) { + internalRequest.addParameter(ZONE_NAME, request.getZoneName()); + } + return invokeHttpClient(internalRequest, ListBccFlavorSpecResponse.class); + } + + /** + * Return a list of bidFlavor owned by the authenticated user. + * + * @return The bidding instance flavor. + */ + public ListBccBidFlavorResponse listBidFlavor() { + return listBidFlavor(new AbstractBceRequest() { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + return null; + } + }); + } + + /** + * Return a list of bidFlavor owned by the authenticated user. + * + * @param request AbstractBceRequest + * @return The bidding instance flavor. + */ + private ListBccBidFlavorResponse listBidFlavor(AbstractBceRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX, BID_FLAVOR); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ListBccBidFlavorResponse.class); + } + + /** + * Query market price of bidding instance + * + * @param request The request containing all options for querying market price of bidding instance. + * @return GetBidInstancePriceResponse + * @throws BceClientException + */ + public GetBidInstancePriceResponse getBidInstancePrice(GetBidInstancePriceRequest request) + throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null != request.getTags() && !request.getTags().isEmpty()) { + for (TagModel tag : request.getTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + } + checkStringNotEmpty(request.getInstanceType(), checkEmptyExceptionMessageFormat(INSTANCE_TYPE_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX, BID_PRICE); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + if (!Strings.isNullOrEmpty(request.getAdminPass())) { + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, GetBidInstancePriceResponse.class); + } + + /** + * Cancel the bidding instance order. + * + * @param oderId The id of the order. + * @return The request containing the orderId which is canceled by the user. + */ + public CancelBidOrderResponse cancelBidOrder(String oderId) { + return this.cancelBidOrder(new CancelBidOrderRequest().withOrderId(oderId)); + } + + /** + * Cancel the bidding instance order. + * + * @param request The request containing the orderId which is the user wants to cancel. + * @return The request containing the orderId which is canceled by the user. + */ + public CancelBidOrderResponse cancelBidOrder(CancelBidOrderRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getOrderId(), checkEmptyExceptionMessageFormat(ORDER_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + INSTANCE_PREFIX, CANCEL_BID_ORDER); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CancelBidOrderResponse.class); + } + + /** + * Return a list of noCharge instances owned by the authenticated user. + * + * @param request The request containing all options for listing owns bcc noCharge Instance. + * @return The response containing a list of noCharge instances owned by the authenticated user. + */ + public ListInstancesResponse getInstanceNoChargeList(ListGetInstanceNoChargeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + INSTANCE_PREFIX, NO_CHARGE); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getInternalIp())) { + internalRequest.addParameter(INTERNAL_IP, request.getInternalIp()); + } + if (!Strings.isNullOrEmpty(request.getZoneName())) { + internalRequest.addParameter(ZONE_NAME, request.getZoneName()); + } + return invokeHttpClient(internalRequest, ListInstancesResponse.class); + } + + /** + * Get the detail information of specified instance. + * + * @param instanceId The id of the instance. + * @return A instance detail model for the instanceId. + */ + public GetInstanceResponse getInstance(String instanceId) { + return getInstance(new GetInstanceRequest().withInstanceId(instanceId)); + } + + /** + * Get the detail information of specified instance. + * + * @param request The request containing all options for getting the instance info. + * @return A instance detail model for the instanceId. + */ + public GetInstanceResponse getInstance(GetInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), + checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, INSTANCE_PREFIX, request.getInstanceId()); + return this.invokeHttpClient(internalRequest, GetInstanceResponse.class); + } + + /** + * Change the instance payment method to prepaid. + * + * @param request The request containing all options for changing the instance payment method to prepaid. + * @return The id of the order. + */ + public ChangeToPrepaidResponse changeToPrepaid(ChangeToPrepaidRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), + checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.toPrepay.name(), null); + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, ChangeToPrepaidResponse.class); + } + + /** + * Starting the instance owned by the user. + *

+ * You can start the instance only when the instance is Stopped, + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + */ + public void startInstance(String instanceId) { + this.startInstance(new StartInstanceRequest().withInstanceId(instanceId)); + } + + /** + * Starting the instance owned by the user. + *

+ * You can start the instance only when the instance is Stopped, + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for starting the instance. + */ + public void startInstance(StartInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.start.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Stopping the instance owned by the user. + *

+ * You can stop the instance only when the instance is Running, + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + */ + public void stopInstance(String instanceId) { + this.stopInstance(new StopInstanceRequest() + .withInstanceId(instanceId).withForceStop(false) + .withStopWithNoCharge(false)); + } + + /** + * Stopping the instance owned by the user. + *

+ * You can stop the instance only when the instance is Running, + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + * @param forceStop The optional parameter to stop the instance forcibly.If true, + * it will stop the instance just like power off immediately, + * and it may result in losing important data which have not been written to disk. + */ + public void stopInstance(String instanceId, boolean forceStop) { + this.stopInstance(new StopInstanceRequest() + .withInstanceId(instanceId).withForceStop(forceStop) + .withStopWithNoCharge(false)); + } + + /** + * Stopping the instance owned by the user. + *

+ * You can stop the instance only when the instance is Running, + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + * @param forceStop The optional parameter to stop the instance forcibly.If true, + * it will stop the instance just like power off immediately, + * and it may result in losing important data which have not been written to disk. + * @param stopWithNoCharge The optional parameter to indicate that whether the instance can be stopped + * with no charge or not, default value is false. + * If true, it means the instance can be stopped with no charge. + */ + public void stopInstance(String instanceId, boolean forceStop, boolean stopWithNoCharge) { + this.stopInstance(new StopInstanceRequest() + .withInstanceId(instanceId).withForceStop(forceStop) + .withStopWithNoCharge(stopWithNoCharge)); + } + + /** + * Stopping the instance owned by the user. + *

+ * You can stop the instance only when the instance is Running, + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for stopping the instance. + */ + public void stopInstance(StopInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.stop.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void batchStopInstance(BatchStopInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, "batchAction"); + internalRequest.addParameter(InstanceAction.stop.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Rebooting the instance owned by the user. + *

+ * You can reboot the instance only when the instance is Running, + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + */ + public void rebootInstance(String instanceId) { + this.rebootInstance(new RebootInstanceRequest().withInstanceId(instanceId).withForceStop(false)); + } + + /** + * Rebooting the instance owned by the user. + *

+ * You can reboot the instance only when the instance is Running, + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + * @param forceStop The option param to stop the instance forcibly.If true, + * it will stop the instance just like power off immediately, + * and it may result int losing important data which have not written to disk. + */ + public void rebootInstance(String instanceId, boolean forceStop) { + this.rebootInstance(new RebootInstanceRequest().withInstanceId(instanceId).withForceStop(forceStop)); + } + + /** + * Rebooting the instance owned by the user. + *

+ * You can reboot the instance only when the instance is Running, + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for rebooting the instance. + */ + public void rebootInstance(RebootInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.reboot.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Modifying the password of the instance. + *

+ * You can change the instance password only when the instance is Running or Stopped , + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + * @param adminPass The new password to update. + * The adminPass will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * @throws BceClientException + */ + public void modifyInstancePassword(String instanceId, String adminPass) throws BceClientException { + this.modifyInstancePassword(new ModifyInstancePasswordRequest() + .withInstanceId(instanceId).withAdminPass(adminPass)); + } + + /** + * Modifying the password of the instance. + *

+ * You can reboot the instance only when the instance is Running or Stopped , + * otherwise,it will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for modifying the instance password. + * @throws BceClientException + */ + public void modifyInstancePassword(ModifyInstancePasswordRequest request) throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAdminPass(), checkEmptyExceptionMessageFormat(ADMINPASS_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.changePass.name(), null); + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void modifyInstanceHostname(String instanceId, + String hostname, + boolean isReboot, + boolean isOpenHostnameDomain) throws BceClientException { + this.modifyInstanceHostname(new ModifyInstanceHostnameRequest() + .withInstanceId(instanceId) + .withHostname(hostname) + .withIsReboot(isReboot) + .withIsOpenHostnameDomain(isOpenHostnameDomain)); + } + + /** + * Modifying the hostname to new value of the instance. + * + * @param request The request containing all options for modifying the instance hostname. + */ + public void modifyInstanceHostname(ModifyInstanceHostnameRequest request) throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getHostname(), checkEmptyExceptionMessageFormat(ADMINPASS_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.changeHostname.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Modifying the special attribute to new value of the instance. + *

+ * You can reboot the instance only when the instance is Running or Stopped , + * otherwise,it will get 409 errorCode. + * + * @param request The request containing all options for modifying the instance attribute. + */ + public void modifyInstanceAttributes(ModifyInstanceAttributesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.modifyAttribute.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Modifying the special describe to new value of the instance. + * + * @param request The request containing all options for modifying the instance desc. + */ + public void modifyInstanceDesc(ModifyInstanceDescRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDesc(), checkEmptyExceptionMessageFormat(DESC_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.modifyDesc.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Rebuilding the instance owned by the user. + *

+ * After rebuilding the instance, + * all snapshots created from original instance system disk will be deleted, + * all of customized images will be saved for using in the future. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + * @param imageId The id of the image which is used to rebuild the instance. + * @param adminPass The admin password to login the instance. + * The admin password will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * See more detail on + * + * BCE API doc + * @throws BceClientException + */ + public void rebuildInstance(String instanceId, String imageId, String adminPass) throws BceClientException { + this.rebuildInstance(new RebuildInstanceRequest().withInstanceId(instanceId) + .withImageId(imageId).withAdminPass(adminPass)); + } + + /** + * Rebuilding the instance owned by the user. + *

+ * After rebuilding the instance, + * all snapshots created from original instance system disk will be deleted, + * all of customized images will be saved for using in the future. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + * @param imageId The id of the image which is used to rebuild the instance. + * @param adminPass The admin password to login the instance. + * The admin password will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * See more detail on + * + * BCE API doc + * @param keypairId The id of the keypair. + * @throws BceClientException + */ + public void rebuildInstance(String instanceId, String imageId, String adminPass, String keypairId) + throws BceClientException { + this.rebuildInstance(new RebuildInstanceRequest().withInstanceId(instanceId) + .withImageId(imageId).withAdminPass(adminPass).withKeypairId(keypairId)); + } + + /** + * Rebuilding the instance owned by the user. + *

+ * After rebuilding the instance, + * all snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be saved. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for rebuilding the instance. + * @throws BceClientException + */ + public void rebuildInstance(RebuildInstanceRequest request) throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAdminPass(), checkEmptyExceptionMessageFormat(ADMINPASS_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.rebuild.name(), null); + + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Rebuilding the instance owned by the user by batch. + *

+ * After rebuilding the instance, + * all snapshots created from original instance system disk will be deleted, + * all of customized images will be saved for using in the future. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceIds The ids of the instance. + * @param imageId The id of the image which is used to rebuild the instance. + * @param adminPass The admin password to login the instance. + * The admin password will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * See more detail on + * + * BCE API doc + * @throws BceClientException + */ + public void rebuildBatchInstance(List instanceIds, String imageId, String adminPass) + throws BceClientException { + this.rebuildBatchInstance(new RebuildBatchInstanceRequest().withInstanceIds(instanceIds) + .withImageId(imageId).withAdminPass(adminPass)); + } + + /** + * Rebuilding the instance owned by the user by batch. + *

+ * After rebuilding the instance, + * all snapshots created from original instance system disk will be deleted, + * all of customized images will be saved for using in the future. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceIds The ids of the instance. + * @param imageId The id of the image which is used to rebuild the instance. + * @param adminPass The admin password to login the instance. + * The admin password will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * See more detail on + * + * BCE API doc + * @param keypairId The id of the keypair. + * @throws BceClientException + */ + public void rebuildBatchInstance(List instanceIds, String imageId, String adminPass, String keypairId) + throws BceClientException { + this.rebuildBatchInstance(new RebuildBatchInstanceRequest().withInstanceIds(instanceIds) + .withImageId(imageId).withAdminPass(adminPass).withKeypairId(keypairId)); + } + + /** + * Rebuilding the instance owned by the user. + *

+ * After rebuilding the instance, + * all snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be saved. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for rebuilding the instance. + * @throws BceClientException + */ + public void rebuildBatchInstance(RebuildBatchInstanceRequest request) throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (request.getInstanceIds().size() == 0) { + throw new IllegalArgumentException("request instanceIds should not be empty."); + } + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAdminPass(), checkEmptyExceptionMessageFormat(ADMINPASS_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, REBUILD); + + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Releasing the instance owned by the user. + *

+ * Only the Postpaid instance or Prepaid which is expired can be released. + *

+ * After releasing the instance, + * all the data will be deleted. + * all volumes attached will be auto detached, but the volume snapshots will be saved. + * all snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param instanceId The id of the instance. + */ + public void releaseInstance(String instanceId) { + this.releaseInstance(new ReleaseInstanceRequest().withInstanceId(instanceId)); + } + + /** + * Releasing the recycled instance owned by the user. + *

+ * After releasing the instance, + * all the data will be deleted. + * + * @param instanceId The id of the instance. + */ + public void releaseRecycledInstance(String instanceId) { + this.releaseRecycledInstance(new ReleaseInstanceRequest().withInstanceId(instanceId)); + } + + /** + * Releasing the recycled instance owned by the user. + *

+ * Only the Postpaid instance or Prepaid which is expired can be released. + * After releasing the instance, + * all the data will be deleted. + * all volumes attached will be detached,but the volume snapshots will be saved. + * all snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param request The request containing all options for releasing the instance. + */ + public void releaseRecycledInstance(ReleaseInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, RECYCLE, INSTANCE_PREFIX, request.getInstanceId()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Releasing the instance owned by the user. + *

+ * Only the Postpaid instance or Prepaid which is expired can be released. + * After releasing the instance, + * all of the data will be deleted. + * all of volumes attached will be detached,but the volume snapshots will be saved. + * all of snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param request The request containing all options for releasing the instance. + */ + public void releaseInstance(ReleaseInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, INSTANCE_PREFIX, request.getInstanceId()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Releasing the instance owned by the user by POST. + *

+ * Only the Postpaid instance or Prepaid which is expired can be released. + *

+ * After releasing the instance, + * all of the data will be deleted. + * all of volumes attached will be auto detached, but the volume snapshots will be saved. + * all of snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param instanceId The id of the instance. + * @param relatedReleaseFlag Whether to release the EIP and the data disk attached to the instance + * at the current time in the same time. Iftrue, it means release, + * and the parameters deleteCdsSnapshotFlag works. Iffalse, it means + * not to release, and the parameters deleteCdsSnapshotFlag does not works. + * @param deleteCdsSnapshotFlag Whether to delete the CDS Snapshot. Iftrue, it means delete. + */ + public void releaseInstanceByPost(String instanceId, boolean relatedReleaseFlag, boolean deleteCdsSnapshotFlag) { + this.releaseInstanceByPost( + new ReleaseInstanceByPostRequest() + .withInstanceId(instanceId) + .withRelatedReleaseFlag(relatedReleaseFlag) + .withDeleteCdsSnapshotFlag(deleteCdsSnapshotFlag)); + } + + /** + * Releasing the instance owned by the user by POST. + *

+ * Only the Prepaid instance and the instance has not expired can be released. + *

+ * After releasing the instance, + * all the data will be deleted. + * all volumes attached will be auto detached, but the volume snapshots will be saved. + * all snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param instanceId The id of the instance. + * @param relatedReleaseFlag Whether to release the EIP and the data disk attached to the instance + * at the current time in the same time. Iftrue, it means release, + * and the parameters deleteCdsSnapshotFlag works. Iffalse, it means + * not to release, and the parameters deleteCdsSnapshotFlag does not work. + * @param deleteCdsSnapshotFlag Whether to delete the CDS Snapshot. Iftrue, it means delete. + * @param deleteRelatedEnisFlag Whether to delete the ENI. Iftrue, it means delete. + */ + public ReleasePrepaidInstanceResponse releasePrepaidInstanceByPost(String instanceId, + boolean relatedReleaseFlag, + boolean deleteCdsSnapshotFlag, + boolean deleteRelatedEnisFlag) { + return this.releasePrepaidInstanceByPost( + new ReleasePrepaidInstanceRequest() + .withInstanceId(instanceId) + .withRelatedReleaseFlag(relatedReleaseFlag) + .withDeleteCdsSnapshotFlag(deleteCdsSnapshotFlag) + .withDeleteRelatedEnisFlag(deleteRelatedEnisFlag)); + } + /** + * Releasing the instance owned by the user. + *

+ * Only the Prepaid instance and the instance has not expired can be released. + * After releasing the instance, + * all the data will be deleted. + * all volumes attached will be detached,but the volume snapshots will be saved. + * all snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param request The request containing all options for releasing the instance. + */ + public ReleasePrepaidInstanceResponse releasePrepaidInstanceByPost(ReleasePrepaidInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, INSTANCE_PREFIX, DELETE); + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, ReleasePrepaidInstanceResponse.class); + } + + /** + * Releasing the instance owned by the user by POST. + *

+ * Only the Postpaid instance or Prepaid which is expired can be released. + *

+ * After releasing the instance, + * all the data will be deleted. + * all volumes attached will be auto detached, but the volume snapshots will be saved. + * all snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param instanceIds The id of the instances. + * @param relatedReleaseFlag Whether to release the EIP and the data disk attached to the instance + * at the current time in the same time. Iftrue, it means release, + * and the parameters deleteCdsSnapshotFlag works. Iffalse, it means + * not to release, and the parameters deleteCdsSnapshotFlag does not work. + * @param deleteCdsSnapshotFlag Whether to delete the CDS Snapshot. Iftrue, it means delete. + * @param bccRecycleFlag Whether to recycle the bcc. Iftrue, it means recycle. + * @param deleteRelatedEnisFlag Whether to delete the ENI. Iftrue, it means delete. + */ + public void releaseMultipleInstancesByPost(List instanceIds, + boolean relatedReleaseFlag, + boolean deleteCdsSnapshotFlag, + boolean bccRecycleFlag, + boolean deleteRelatedEnisFlag) { + this.releaseMultipleInstanceByPost( + new ReleaseMultipleInstancesRequest() + .withInstanceIds(instanceIds) + .withRelatedReleaseFlag(relatedReleaseFlag) + .withDeleteCdsSnapshotFlag(deleteCdsSnapshotFlag) + .withBccRecycleFlag(bccRecycleFlag) + .withDeleteRelatedEnisFlag(deleteRelatedEnisFlag)); + } + + /** + * Releasing the instance owned by the user. + *

+ * Only the Postpaid instance or Prepaid which is expired can be released. + * After releasing the instance, + * all of the data will be deleted. + * all of volumes attached will be detached,but the volume snapshots will be saved. + * all of snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param request The request containing all options for releasing the instance. + */ + public void releaseInstanceByPost(ReleaseInstanceByPostRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, INSTANCE_PREFIX, request.getInstanceId()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Releasing the instance owned by the user. + *

+ * Only the Postpaid instance or Prepaid which is expired can be released. + * After releasing the instance, + * all the data will be deleted. + * all volumes attached will be detached,but the volume snapshots will be saved. + * all snapshots created from original instance system disk will be deleted, + * all of customized images created from original instance system disk will be reserved. + * + * @param request The request containing all options for releasing the instance. + */ + public void releaseMultipleInstanceByPost(ReleaseMultipleInstancesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, INSTANCE_PREFIX, BATCH_DELETE); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Changing the subnetId of the instance owned by the user. + * + * @param instanceId The id of instance. + * @param subnetId The id of subnet after changed. + * @param reboot Whether to reboot automatically or not. If true, it means reboot automatically. + */ + public void updateInstanceSubnet(String instanceId, String subnetId, boolean reboot) { + this.updateInstanceSubnet( + new ChangeInstanceSubnetRequest() + .withInstanceId(instanceId) + .withSubnetId(subnetId) + .withReboot(reboot)); + } + + /** + * Changing the subnetId of the instance owned by the user. + * + * @param request The request containing all options for changing the subnetId of the instance. + */ + public void updateInstanceSubnet(ChangeInstanceSubnetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getSubnetId(), checkEmptyExceptionMessageFormat(SUBNETID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, SUBNET_PREFIX, CHANGE_SUBNET); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteInstanceDeploySet(DeleteInstanceDeploysetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDeployId(), checkEmptyExceptionMessageFormat(DEPLOYSET_MESSAGE_KEY)); + checkNotNull(request.getInstanceIdList(), checkEmptyExceptionMessageFormat(INSTANCEIDLIST_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, INSTANCE_PREFIX, DEPLOYSET, DEL_RELATION); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteRecycledInstance(String instanceId) { + DeleteRecycledInstanceRequest request = new DeleteRecycledInstanceRequest(); + checkStringNotEmpty(instanceId, checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, RECYCLE_INSTANCE, instanceId); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Resizing the instance owned by the user. + *

+ * The Prepaid instance can not be downgrade. + * Only the Running/Stopped instance can be resized,otherwise,it's will get 409 errorCode. + * After resizing the instance,it will be reboot once. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for resizing the instance. + */ + public void resizeInstance(ResizeInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + if (request.getCpuCount() <= 0) { + throw new IllegalArgumentException("request cpuCount should be positive."); + } + if (request.getMemoryCapacityInGB() <= 0) { + throw new IllegalArgumentException("request memoryCapacityInGB should be positive."); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.resize.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Through spec Resizing the instance through the spec owned by the user. + *

+ * The Prepaid instance can not be downgrade. + * Only the Running/Stopped instance can be resized,otherwise,it's will get 409 errorCode. + * After resizing the instance,it will be reboot once. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for resizing the instance. + */ + public void resizeInstanceBySpec(ResizeInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_BY_SPEC_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.resize.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Binding the instance to specified securitygroup. + * + * @param instanceId The id of the instance. + * @param securityGroupId The id of the securitygroup. + */ + public void bindInstanceToSecurityGroup(String instanceId, String securityGroupId) { + this.bindInstanceToSecurityGroup(new BindSecurityGroupRequest() + .withInstanceId(instanceId).withSecurityGroupId(securityGroupId)); + } + + /** + * Binding the instance to specified securitygroup. + * + * @param request The request containing all options for binding the instance to specified securitygroup. + */ + public void bindInstanceToSecurityGroup(BindSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITYGROUPID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.bind.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Unbinding the instance from securitygroup. + * + * @param instanceId The id of the instance. + * @param securityGroupId The id of the securitygroup. + */ + public void unbindInstanceFromSecurityGroup(String instanceId, String securityGroupId) { + this.unbindInstanceFromSecurityGroup(new UnbindSecurityGroupRequest() + .withInstanceId(instanceId).withSecurityGroupId(securityGroupId)); + } + + + /** + * Unbinding the instance from securitygroup. + * + * @param request The request containing all options for unbinding the instance from securitygroup. + */ + public void unbindInstanceFromSecurityGroup(UnbindSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITYGROUPID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.unbind.name(), null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Binding the instance to specified list of tags. + * + * @param instanceId The id of the instance. + * @param changeTags The list of tags. + */ + public void bindInstanceToTags(String instanceId, List changeTags) { + this.bindInstanceToTags(new BindTagsRequest() + .withInstanceId(instanceId).withChangeTags(changeTags)); + } + + /** + * Binding the instance to specified list of tags. + * + * @param request The request containing all options for binding the instance to specified list of tags. + */ + public void bindInstanceToTags(BindTagsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + if (null != request.getChangeTags() && !request.getChangeTags().isEmpty()) { + for (TagModel tag : request.getChangeTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + } else { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + INSTANCE_PREFIX, request.getInstanceId(), TAG); + internalRequest.addParameter("bind", null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Unbinding the instance to specified list of tags. + * + * @param instanceId The id of the instance. + * @param changeTags The list of tags to be unbound. + */ + public void unbindInstanceFromTags(String instanceId, List changeTags) { + this.unbindInstanceFromTags(new UnbindTagsRequest() + .withInstanceId(instanceId).withChangeTags(changeTags)); + } + + /** + * Unbinding the instance to specified list of tags. + * + * @param request The request containing all options for unbinding the instance to specified list of tags. + */ + public void unbindInstanceFromTags(UnbindTagsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + if (null != request.getChangeTags() && !request.getChangeTags().isEmpty()) { + for (TagModel tag : request.getChangeTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + } else { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + INSTANCE_PREFIX, request.getInstanceId(), TAG); + internalRequest.addParameter("unbind", null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Getting the vnc url to access the instance. + *

+ * The vnc url can be used once. + * + * @param instanceId The id of the instance. + */ + public GetInstanceVncResponse getInstanceVnc(String instanceId) { + return this.getInstanceVnc(new GetInstanceVncRequest().withInstanceId(instanceId)); + } + + /** + * Getting the vnc url to access the instance. + *

+ * The vnc url can be used once. + * + * @param request The request containing all options for getting the vnc url. + */ + public GetInstanceVncResponse getInstanceVnc(GetInstanceVncRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, INSTANCE_PREFIX, request.getInstanceId(), "vnc"); + return this.invokeHttpClient(internalRequest, GetInstanceVncResponse.class); + } + + + /** + * PurchaseReserved the instance with fixed duration. + *

+ * You can not purchaseReserved the instance which is resizing. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + * @param reservationLength The fixed duration to purchaseReserved,available is [1,2,3,4,5,6,7,8,9,12,24,36] + * @param reservationTimeUnit The timeUnit to renew the instance,only support "month" now. + * @return The id of the order. + */ + public PurchaseReservedInstanceResponse purchaseReservedInstance(String instanceId, int reservationLength, String reservationTimeUnit) { + return this.purchaseReservedInstance(new PurchaseReservedInstanceRequeset() + .withInstanceId(instanceId) + .withBilling(new Billing().withReservation(new Reservation() + .withReservationLength(reservationLength) + .withReservationTimeUnit(reservationTimeUnit)))); + } + + /** + * PurchaseReserved the instance with fixed duration. + *

+ * You can not purchaseReserved the instance which is resizing. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param instanceId The id of the instance. + * @param reservationLength The fixed duration to purchaseReserved,available is [1,2,3,4,5,6,7,8,9,12,24,36] + * @param reservationTimeUnit The timeUnit to renew the instance,only support "month" now. + * @param relatedRenewFlagType The flag of instance related renew. + * see all of supported flag type in + * @return The id of the order. + * {@link com.baidubce.services.bcc.model.instance.RelatedRenewFlagType} + */ + public PurchaseReservedInstanceResponse purchaseReservedInstance(String instanceId, int reservationLength, String reservationTimeUnit, + String relatedRenewFlagType) { + return this.purchaseReservedInstance(new PurchaseReservedInstanceRequeset() + .withInstanceId(instanceId) + .withBilling(new Billing().withReservation(new Reservation() + .withReservationLength(reservationLength) + .withReservationTimeUnit(reservationTimeUnit))) + .withRelatedRenewFlag(relatedRenewFlagType)); + } + + /** + * Renewing the instance with fixed duration. + *

+ * You can not renew the instance which is resizing. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)} + * + * @param request The request containing all options for renewing the instance with fixed duration. + * @return The id of the order. + */ + public PurchaseReservedInstanceResponse purchaseReservedInstance(PurchaseReservedInstanceRequeset request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBillingWithReservation()); + } + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.purchaseReserved.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + internalRequest.addParameter(RELATED_RENEW_FLAG, request.getRelatedRenewFlag()); + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, PurchaseReservedInstanceResponse.class); + } + + /** + * The interface will be deprecated in the future, + * we suggest to use triad (instanceType,cpuCount,memoryCapacityInGB) to specified the instance configuration. + *

+ * Listing all of specification for instance resource to buy. + *

+ * See more detail on + * + * BCE API doc + * + * @return List of specification for instance resource to buy. + */ + @Deprecated + public ListInstanceSpecsResponse listInstanceSpecs() { + return this.listInstanceSpecs(new ListInstanceSpecsRequest()); + } + + /** + * The interface will be deprecated in the future, + * we suggest to use triad (instanceType,cpuCount,memoryCapacityInGB) to specified the instance configuration. + *

+ * Listing all of specification for instance resource to buy. + *

+ * See more detail on + * + * BCE API doc + * + * @param request The request containing all options for Listing all of specification for instance resource. + * @return List of specification for instance resource to buy. + */ + @Deprecated + public ListInstanceSpecsResponse listInstanceSpecs(ListInstanceSpecsRequest request) { + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, INSTANCE_PREFIX, "spec"); + return this.invokeHttpClient(internalRequest, ListInstanceSpecsResponse.class); + } + + /** + * Create a volume with the specified options. + *

+ * You can use this method to create a new empty volume by specified options + * or you can create a new volume from customized volume snapshot but not system disk snapshot. + * By using the cdsSizeInGB parameter you can create a newly empty volume. + * By using snapshotId parameter to create a volume form specific snapshot. + * + * @param request The request containing all options for creating a volume. + * @return The response with list of id of volumes newly created. + */ + public CreateVolumeResponse createVolume(CreateVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VOLUME_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateVolumeResponse.class); + } + + /** + * Sync create volume with the specified options. + * syncCreateVolume does not support snapshotId and Prepay + *

+ * You can use this method to create a new empty volume by specified options + * + * @param request The request containing all options for creating a volume. + * @return The response with list of id of volumes newly created. + */ + public CreateVolumeResponse syncCreateVolume(CreateVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (StringUtils.isNotEmpty(request.getSnapshotId())) { + throw new IllegalArgumentException("sync create does not support use snapshot!"); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + if (!"Postpaid".equalsIgnoreCase(request.getBilling().getPaymentTiming())) { + throw new IllegalArgumentException("sync create does only support Postpaid!"); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VOLUME_PREFIX, SYNC_CREATE); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateVolumeResponse.class); + } + + /** + * Listing volumes owned by the authenticated user. + * + * @return The response containing a list of volume owned by the authenticated user. + */ + public ListVolumesResponse listVolumes() { + return listVolumes(new ListVolumesRequest()); + } + + /** + * Listing volumes owned by the authenticated user. + * + * @param request The request containing all options for listing volumes owned by the authenticated user. + * @return The response containing a list of volume owned by the authenticated user. + */ + public ListVolumesResponse listVolumes(ListVolumesRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, VOLUME_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getInstanceId())) { + internalRequest.addParameter(INSTANCEID_MESSAGE_KEY, request.getInstanceId()); + } + if (!Strings.isNullOrEmpty(request.getZoneName())) { + internalRequest.addParameter(ZONE_NAME, request.getZoneName()); + } + return invokeHttpClient(internalRequest, ListVolumesResponse.class); + } + + /** + * Get the detail information of specified volume. + * + * @param volumeId The id of the volume. + * @return The response containing the detail information of specified volume. + */ + public GetVolumeResponse getVolume(String volumeId) { + return getVolume(new GetVolumeRequest().withVolumeId(volumeId)); + } + + /** + * Get the detail information of specified volume. + * + * @param request The request containing all options for getting the detail information of specified volume. + * @return The response containing the detail information of specified volume. + */ + public GetVolumeResponse getVolume(GetVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, VOLUME_PREFIX, request.getVolumeId()); + return invokeHttpClient(internalRequest, GetVolumeResponse.class); + } + + /** + * Attaching the specified volume to a specified instance. + *

+ * You can attach the specified volume to a specified instance only + * when the volume is Available and the instance is Running or Stopped , + * otherwise,it's will get 409 errorCode. + * + * @param volumeId The id of the volume which will be attached to specified instance. + * @param instanceId The id of the instance which will be attached with a volume. + * @return The response containing the volume-instance attach relation. + */ + public AttachVolumeResponse attachVolume(String volumeId, String instanceId) { + return attachVolume(new AttachVolumeRequest().withVolumeId(volumeId).withInstanceId(instanceId)); + } + + /** + * Attaching the specified volume to a specified instance. + *

+ * You can attach the specified volume to a specified instance only + * when the volume is Available and the instance is Running or Stopped , + * otherwise,it's will get 409 errorCode. + * + * @param request The request containing all options for attaching the specified volume to a specified instance. + * @return The response containing the volume-instance attach relation. + */ + public AttachVolumeResponse attachVolume(AttachVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_PREFIX, request.getVolumeId()); + internalRequest.addParameter(VolumeAction.attach.name(), null); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, AttachVolumeResponse.class); + } + + /** + * Detaching the specified volume from a specified instance. + *

+ * You can detach the specified volume from a specified instance only + * when the instance is Running or Stopped , + * otherwise,it's will get 409 errorCode. + * + * @param volumeId The id of the volume which has been attached to specified instance. + * @param instanceId The id of the instance which will be detached a volume. + */ + public void detachVolume(String volumeId, String instanceId) { + this.detachVolume(new DetachVolumeRequest().withVolumeId(volumeId).withInstanceId(instanceId)); + } + + /** + * Detaching the specified volume from a specified instance. + *

+ * You can detach the specified volume from a specified instance only + * when the instance is Running or Stopped , + * otherwise,it's will get 409 errorCode. + * + * @param request The request containing all options for detaching the specified volume from a specified instance. + */ + public void detachVolume(DetachVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_PREFIX, request.getVolumeId()); + internalRequest.addParameter(VolumeAction.detach.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * List all region's endpoint information. + *

+ * You can get specified region's endpoint information by specified region, + * if the region is not exist, it's will get 409 errorCode. + * + * Use global endpoint bcc.baidubce.com to get BCC's endpoint.(PS:endpoint of CDS and + * ReservedInstance is the same with BCC) + * @param request The request for getting endpoint of different regions. + * @return The response containing the detail region's endpoint information. + */ + public DescribeRegionsResponse describeRegions(DescribeRegionsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, REGION_PREFIX, DESCRIBE_REGIONS); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DescribeRegionsResponse.class); + } + + /** + * Releasing the specified volume owned by the user. + *

+ * You can release the specified volume only + * when the instance is among state of Available/Expired/Error, + * otherwise,it's will get 409 errorCode. + * + * @param volumeId The id of the volume which will be released. + */ + public void releaseVolume(String volumeId) { + this.releaseVolume(new ReleaseVolumeRequest().withVolumeId(volumeId)); + } + + /** + * Releasing the specified volume owned by the user. + *

+ * You can release the specified volume only + * when the volume is Available/Expired/Error, + * otherwise,it's will get 409 errorCode. + * + * @param request The request containing all options for releasing the specified volume. + */ + public void releaseVolume(ReleaseVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + + if (StringUtils.isEmpty(request.getAutoSnapshot()) + && StringUtils.isEmpty(request.getManualSnapshot())) { + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, VOLUME_PREFIX, request.getVolumeId()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } else { + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VOLUME_PREFIX, request.getVolumeId()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + } + + /** + * Change the volume's billing method. + * billingMethod can be set to 'prepay' or 'postpay'. when 'prepay' is used, reservationLength must be + * set to a positive integer which denotes how many month to buy this volume. + * + * @param request The request containing all options for modifying the billing method of the specified volume. + */ + public void modifyVolumeChargeType(ModifyVolumeChargeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + + ModifyVolumeChargeRequest.ModifyVolumeChargeModel requestModel = request.toModifyVolumeChargeModel(); + InternalRequest internalRequest = this.createRequest(requestModel, HttpMethodName.PUT, + VOLUME_PREFIX, request.getVolumeId()); + internalRequest.addParameter(VolumeAction.modifyChargeType.name(), null); + fillPayload(internalRequest, requestModel); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Change the volume's billing method. + * billingMethod can be set to 'prepay' or 'postpay'. when 'prepay' is used, reservationLength must be + * set to a positive integer which denotes how many month to buy this volume. + * + * @param request + */ + public void modifyVolumeChargeType(ModifyVolumeChargeTypeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + VOLUME_PREFIX, request.getVolumeId()); + internalRequest.addParameter(VolumeAction.modifyChargeType.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Resizing the specified volume with newly size. + *

+ * You can resize the specified volume only when the volume is Available, + * otherwise,it's will get 409 errorCode. + *

+ * The prepaid volume can not be downgrade. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getVolume(String)} + * + * @param volumeId The id of volume which you want to resize. + * @param newCdsSizeInGB The new volume size you want to resize in GB. + */ + public ResizeVolumeResponse resizeVolume(String volumeId, int newCdsSizeInGB) { + return this.resizeVolume(new ResizeVolumeRequest() + .withVolumeId(volumeId).withNewCdsSizeInGB(newCdsSizeInGB)); + } + + /** + * Resizing the specified volume with newly size. + *

+ * You can resize the specified volume only when the volume is Available, + * otherwise,it's will get 409 errorCode. + *

+ * The prepaid volume can not be downgrade. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getVolume(String)} + * + * @param request The request containing all options for resize the specified volume. + */ + public ResizeVolumeResponse resizeVolume(ResizeVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + checkState(request.getNewCdsSizeInGB() > 0, "request newCdsSizeInGB should greater than 0"); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_PREFIX, request.getVolumeId()); + internalRequest.addParameter(VolumeAction.resize.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ResizeVolumeResponse.class); + } + + /** + * Rollback the volume with the specified volume snapshot. + *

+ *

+ * You can rollback the specified volume only when the volume is Available, + * otherwise,it's will get 409 errorCode. + *

+ * The snapshot used to rollback must be created by the volume, + * otherwise,it's will get 404 errorCode. + *

+ * If rolling back the system volume,the instance must be Running or Stopped, + * otherwise,it's will get 409 errorCode.After rolling back the + * volume,all the system disk data will erase. + * + * @param volumeId The id of volume which will be rollback. + * @param snapshotId The id of snapshot which will be used to rollback the volume. + */ + public void rollbackVolume(String volumeId, String snapshotId) { + this.rollbackVolume(new RollbackVolumeRequest() + .withVolumeId(volumeId).withSnapshotId(snapshotId)); + } + + /** + * Rollback the volume with the specified volume snapshot. + *

+ * You can rollback the specified volume only when the volume is Available, + * otherwise,it's will get 409 errorCode. + *

+ * The snapshot used to rollback must be created by the volume, + * otherwise,it's will get 404 errorCode. + *

+ * If rolling back the system volume,the instance must be Running or Stopped, + * otherwise,it's will get 409 errorCode.After rolling back the + * volume,all the system disk data will erase. + * + * @param request The request containing all options for rolling back the specified volume. + */ + public void rollbackVolume(RollbackVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getSnapshotId(), checkEmptyExceptionMessageFormat(SNAPSHOTID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_PREFIX, request.getVolumeId()); + internalRequest.addParameter(VolumeAction.rollback.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * PurchaseReserved the instance with fixed duration. + *

+ * You can not purchaseReserved the instance which is resizing. + * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getVolume(String)} + * + * @param volumeId The id of volume which will be renew. + * @param reservationLength The fixed duration to renew,available is [1,2,3,4,5,6,7,8,9,12,24,36] + * @param reservationTimeUnit The timeUnit to renew the instance,only support "month" now. + */ + public void purchaseReservedVolume(String volumeId, int reservationLength, String reservationTimeUnit) { + this.purchaseReservedVolume(new PurchaseReservedVolumeRequest() + .withVolumeId(volumeId) + .withBilling(new Billing().withReservation(new Reservation() + .withReservationLength(reservationLength) + .withReservationTimeUnit(reservationTimeUnit)))); + } + + /** + * PurchaseReserved the instance with fixed duration. + *

+ * You can not purchaseReserved the instance which is resizing. + * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getVolume(String)} + * + * @param request The request containing all options for renew the specified volume. + */ + public void purchaseReservedVolume(PurchaseReservedVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBillingWithReservation()); + } + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_PREFIX, request.getVolumeId()); + internalRequest.addParameter(VolumeAction.purchaseReserved.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void autoRenewVolume(String volumeId, String renewTimeUnit, int renewTime) { + autoRenewVolume(new AutoRenewVolumeRequest().withVolumeId(volumeId). + withRenewTimeUnit(renewTimeUnit).withRenewTime(renewTime)); + } + + /** + * Enable auto renewal the specified volume + * + * @param request The request containing all options for renew the specified volume. + */ + public void autoRenewVolume(AutoRenewVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + if (request.getRenewTime() <= 0) { + throw new IllegalArgumentException("request renewTime should be a positive integer"); + } + + if (!request.getRenewTimeUnit().equalsIgnoreCase("month") && + !request.getRenewTimeUnit().equalsIgnoreCase("year")) { + throw new IllegalArgumentException("request renewTimeUnit only support \"month\" and \"year\""); + } + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VOLUME_PREFIX, VolumeAction.autoRenew.name()); + + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Disable auto renewal the volume + * + * @param request The request containing all options for disable auto renew the specified volume. + */ + public void cancelAutoRenewVolume(CancelAutoRenewVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VOLUME_PREFIX, VolumeAction.cancelAutoRenew.name()); + + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Rename the volume + * + * @param request The request containing all options for rename the specified volume. + */ + public void renameVolume(RenameVolumeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_PREFIX, request.getVolumeId()); + + internalRequest.addParameter(VolumeAction.rename.name(), null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * change cds volume's attribute。 + * this interface is used to change cds's attribute, currently Name/Desc attribute is supported. + * + * @param modifyCdsAttrRequest + */ + public void modifyCdsAttribute(ModifyCdsAttrRequest modifyCdsAttrRequest) { + checkNotNull(modifyCdsAttrRequest, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(modifyCdsAttrRequest.getCdsId(), + checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(modifyCdsAttrRequest, HttpMethodName.PUT, VOLUME_PREFIX, + modifyCdsAttrRequest.getCdsId()); + + internalRequest.addParameter(VolumeAction.modify.name(), null); + fillPayload(internalRequest, modifyCdsAttrRequest); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Creating a customized image from the instance.. + *

+ * While creating an image from an instance,the instance must be Running or Stopped, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getImage(GetImageRequest)} + * + * @param imageName The name of image that will be created. + * @param instanceId The id of instance which will be used to create image. + * @return The response with id of image newly created. + */ + public CreateImageResponse createImageFromInstance(String imageName, String instanceId) { + return createImage(new CreateImageRequest() + .withImageName(imageName).withInstanceId(instanceId).withRelateCds(false)); + } + + /** + * Creating a customized image from the instance.. + *

+ * While creating an image from an instance,the instance must be Running or Stopped, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getImage(GetImageRequest)} + * + * @param imageName The name of image that will be created. + * @param instanceId The id of instance which will be used to create image. + * @param relateCds Whether the image is related with cds. + * If true, it means the image is related with cds. + * @return The response with id of image newly created. + */ + public CreateImageResponse createImageFromInstanceWithRelateCds(String imageName, + String instanceId, boolean relateCds) { + return createImage(new CreateImageRequest() + .withImageName(imageName).withInstanceId(instanceId).withRelateCds(relateCds)); + } + + /** + * Creating a customized image from specified snapshot. + *

+ * You can create the image only from system snapshot. + * While creating an image from a system snapshot,the snapshot must be Available, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getImage(GetImageRequest)} + * + * @param imageName The name of image that will be created. + * @param snapshotId The id of snapshot which will be used to create image. + * @return The response with id of image newly created. + */ + public CreateImageResponse createImageFromSnapshot(String imageName, String snapshotId) { + return createImage(new CreateImageRequest() + .withImageName(imageName).withSnapshotId(snapshotId)); + } + + /** + * Creating a customized image which can be used for creating instance in the future. + *

+ * You can create an image from an instance or you can create from an snapshot. + * The parameters of instanceId and snapshotId can no be null simultaneously. + * when both instanceId and snapshotId are assigned,only instanceId will be used. + *

+ * While creating an image from an instance,the instance must be Running or Stopped, + * otherwise,it's will get 409 errorCode. + *

+ * You can create the image only from system snapshot. + * While creating an image from a system snapshot,the snapshot must be Available, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getImage(GetImageRequest)} + * + * @param request The request containing all options for creating a new image. + * @return The response with id of image newly created. + */ + public CreateImageResponse createImage(CreateImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getImageName(), checkEmptyExceptionMessageFormat(IMAGENAME_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getInstanceId()) && Strings.isNullOrEmpty(request.getSnapshotId())) { + throw new IllegalArgumentException("request instanceId or snapshotId should not be empty ."); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, IMAGE_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateImageResponse.class); + } + + /** + * Listing images owned by the authenticated user. + * + * @return The response with list of images. + */ + public ListImagesResponse listImages() { + return this.listImages(new ListImagesRequest()); + } + + /** + * Listing images owned by the authenticated user. + * + * @param request The request containing all options for listing images owned by user. + * @return The response with list of images. + */ + public ListImagesResponse listImages(ListImagesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, IMAGE_PREFIX); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getImageType())) { + internalRequest.addParameter(IMAGE_TYPE, request.getImageType()); + } + if (!Strings.isNullOrEmpty(request.getImageName())) { + internalRequest.addParameter(IMAGE_NAME, request.getImageName()); + } + return invokeHttpClient(internalRequest, ListImagesResponse.class); + } + + /** + * Get the detail information of specified image. + * + * @param imageId The id of image. + * @return The response with the image detail information. + */ + public GetImageResponse getImage(String imageId) { + return getImage(new GetImageRequest().withImageId(imageId)); + } + + /** + * Get the detail information of specified image. + * + * @param request The request containing all options for getting the detail information of specified image. + * @return The response with the image detail information. + */ + public GetImageResponse getImage(GetImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, IMAGE_PREFIX, request.getImageId()); + return invokeHttpClient(internalRequest, GetImageResponse.class); + } + + /** + * Deleting the specified image. + *

+ * Only the customized image can be deleted, + * otherwise,it's will get 403 errorCode. + * + * @param imageId The id of image. + */ + public void deleteImage(String imageId) { + deleteImage(new DeleteImageRequest().withImageId(imageId)); + } + + /** + * Deleting the specified image. + *

+ * Only the customized image can be deleted, + * otherwise,it's will get 403 errorCode. + * + * @param request The request containing all options for deleting the specified image. + */ + public void deleteImage(DeleteImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, IMAGE_PREFIX, request.getImageId()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Sharing the specified image. + *

+ * Only the customized image can be shared, + * otherwise,it's will get 403 errorCode. + * + * @param request The request containing all options for sharing the specified image. + */ + public void shareImage(ShareImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getAccount()) + && Strings.isNullOrEmpty(request.getAccountId())) { + throw new IllegalArgumentException("request account or accountId should not be empty ."); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, IMAGE_PREFIX, request.getImageId()); + internalRequest.addParameter(ImageAction.share.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * UnSharing the specified image. + *

+ * Only the customized and shared image can be unshared, + * otherwise,it's will get 403 errorCode. + * + * @param request The request containing all options for unsharing the specified image. + */ + public void unShareImage(UnShareImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getAccount()) + && Strings.isNullOrEmpty(request.getAccountId())) { + throw new IllegalArgumentException("request account or accountId should not be empty ."); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, IMAGE_PREFIX, request.getImageId()); + internalRequest.addParameter(ImageAction.unshare.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Listing sharedUsers by the authenticated imageId. + * + * @return The response with list of sharedUsers. + */ + public ListSharedUserResponse listSharedUser(String imageId) { + return this.listSharedUser(new ListSharedUserRequest().withImageId(imageId)); + } + + /** + * Listing sharedUsers by the authenticated imageId. + * + * @param request The request containing all options for Listing sharedUsers. + * @return The response with list of sharedUsers. + */ + public ListSharedUserResponse listSharedUser(ListSharedUserRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, IMAGE_PREFIX, request.getImageId(), SHARED_USER); + return this.invokeHttpClient(internalRequest, ListSharedUserResponse.class); + } + + /** + * Remote copy image. + * + * @param request The request containing all options for remote copy image. + */ + public void remoteCopyImage(RemoteCopyImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(IMAGENAME_MESSAGE_KEY)); + if (request.getDestRegion() == null || request.getDestRegion().size() == 0) { + throw new IllegalArgumentException("request destRegion should not be empty ."); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, IMAGE_PREFIX, request.getImageId()); + internalRequest.addParameter(ImageAction.remoteCopy.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Cancel remote copy image. + * + * @param imageId The id of image. + */ + public void cancelRemoteCopyImage(String imageId) { + this.cancelRemoteCopyImage(new CancelRemoteCopyImageRequest().withImageId(imageId)); + } + + /** + * Cancel remote copy image. + * + * @param request The request containing all options for cancel remote copy image. + */ + public void cancelRemoteCopyImage(CancelRemoteCopyImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGEID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, IMAGE_PREFIX, request.getImageId()); + internalRequest.addParameter(ImageAction.cancelRemoteCopy.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * list os by instanceIds. + * + * @param request The request containing instanceIds which to query. + * @return response ListOsResponse + */ + public ListOsResponse listOs(ListOsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (request.getInstanceIds().size() == 0) { + throw new IllegalArgumentException("request instanceIds should not be empty."); + } + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + IMAGE_PREFIX, OS_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ListOsResponse.class); + } + + /** + * Creating snapshot from specified volume. + *

+ * You can create snapshot from system volume and CDS volume. + * While creating snapshot from system volume,the instance must be Running or Stopped, + * otherwise,it's will get 409 errorCode. + * While creating snapshot from CDS volume,,the volume must be InUse or Available, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getSnapshot(GetSnapshotRequest)} + * + * @param volumeId The id of volume which will be used to create snapshot. + * @param snapshotName The name of snapshot will be created. + * @return The response with the id of snapshot created. + */ + public CreateSnapshotResponse createSnapshot(String volumeId, String snapshotName) { + return this.createSnapshot(new CreateSnapshotRequest().withVolumeId(volumeId).withSnapshotName(snapshotName)); + } + + + /** + * Creating snapshot from specified volume. + *

+ * You can create snapshot from system volume and CDS volume. + * While creating snapshot from system volume,the instance must be Running or Stopped, + * otherwise,it's will get 409 errorCode. + * While creating snapshot from CDS volume,,the volume must be InUs or Available, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getSnapshot(GetSnapshotRequest)} + * + * @param volumeId The id of volume which will be used to create snapshot. + * @param snapshotName The name of snapshot will be created. + * @param desc The optional parameter to describe the newly created snapshot. + * @return The response with the id of snapshot created. + */ + public CreateSnapshotResponse createSnapshot(String volumeId, String snapshotName, String desc) { + return this.createSnapshot(new CreateSnapshotRequest() + .withVolumeId(volumeId).withSnapshotName(snapshotName).withDesc(desc)); + } + + /** + * Creating snapshot from specified volume. + *

+ * You can create snapshot from system volume and CDS volume. + * While creating snapshot from system volume,the instance must be Running or Stopped, + * otherwise,it's will get 409 errorCode. + * While creating snapshot from CDS volume,,the volume must be InUs or Available, + * otherwise,it's will get 409 errorCode. + *

+ * This is an asynchronous interface, + * you can get the latest status by invoke {@link #getSnapshot(GetSnapshotRequest)} + * + * @param request The request containing all options for creating a new snapshot. + * @return The response with the id of snapshot created. + */ + public CreateSnapshotResponse createSnapshot(CreateSnapshotRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getVolumeId(), checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getSnapshotName(), checkEmptyExceptionMessageFormat(SNAPSHOTNAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, SNAPSHOT_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateSnapshotResponse.class); + } + + /** + * Listing snapshots owned by the authenticated user. + * + * @param request The request containing all options for listing snapshot. + * @return The response contains a list of snapshots owned by the user. + */ + public ListSnapshotsResponse listSnapshots(ListSnapshotsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, SNAPSHOT_PREFIX); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + + if (!Strings.isNullOrEmpty(request.getVolumeId())) { + internalRequest.addParameter(VOLUMEID_MESSAGE_KEY, request.getVolumeId()); + } + return invokeHttpClient(internalRequest, ListSnapshotsResponse.class); + } + + /** + * Get the detail information of specified snapshot. + * + * @param snapshotId The id of snapshot. + * @return The response with the snapshot detail information. + */ + public GetSnapshotResponse getSnapshot(String snapshotId) { + return this.getSnapshot(new GetSnapshotRequest().withSnapshotId(snapshotId)); + } + + /** + * Getting the detail information of specified snapshot. + * + * @param request The request containing all options for getting the detail information of specified snapshot. + * @return The response with the snapshot detail information. + */ + public GetSnapshotResponse getSnapshot(GetSnapshotRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSnapshotId(), checkEmptyExceptionMessageFormat(SNAPSHOTID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, SNAPSHOT_PREFIX, request.getSnapshotId()); + return invokeHttpClient(internalRequest, GetSnapshotResponse.class); + } + + /** + * Deleting the specified snapshot. + *

+ * Only when the snapshot is CreatedFailed or Available,the specified snapshot can be deleted. + * otherwise,it's will get 403 errorCode. + * + * @param snapshotId The id of snapshot. + */ + public void deleteSnapshot(String snapshotId) { + this.deleteSnapshot(new DeleteSnapshotRequest().withSnapshotId(snapshotId)); + } + + /** + * Deleting the specified snapshot. + *

+ * Only when the snapshot is CreatedFailed or Available,the specified snapshot can be deleted. + * otherwise,it's will get 403 errorCode. + * + * @param request The request containing all options for deleting the specified snapshot. + */ + public void deleteSnapshot(DeleteSnapshotRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSnapshotId(), checkEmptyExceptionMessageFormat(SNAPSHOTID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, SNAPSHOT_PREFIX, request.getSnapshotId()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query the list of user's snapshot chain information. + * + * @param request The request containing all options for querying the specified snapshot chain. + * @return Snapchain information, a collection of SnapchainModel + */ + public ListSnapchainResponse listSnapchain(ListSnapchainRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, SNAPSHOT_PREFIX, CHAIN); + if (!Strings.isNullOrEmpty(request.getOrderBy())) { + internalRequest.addParameter(ORDERBY, request.getOrderBy()); + } + if (!Strings.isNullOrEmpty(request.getOrder())) { + internalRequest.addParameter(ORDER, request.getOrder()); + } + if (request.getPageNo() > 0) { + internalRequest.addParameter(PAGENO, String.valueOf(request.getPageNo())); + } + if (request.getPageSize() > 0) { + internalRequest.addParameter(PAGESIZE, String.valueOf(request.getPageSize())); + } + if (!Strings.isNullOrEmpty(request.getVolumeId())) { + internalRequest.addParameter(VOLUMEID_MESSAGE_KEY, request.getVolumeId()); + } + return invokeHttpClient(internalRequest, ListSnapchainResponse.class); + } + + /** + * Creating autoSnapshotPolicy + * + * @param request contains params for creating a new asp + * @return response contains the id of new asp + */ + public CreateAspResponse createAsp(CreateAspRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(ASPNAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ASP); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateAspResponse.class); + } + + /** + * Deleting autoSnapshotPolicy + * + * @param request contains the id of asp for deleting + */ + public void deleteAsp(DeleteAspRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getAspId(), checkEmptyExceptionMessageFormat(ASPID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, ASP, request.getAspId()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Deleting autoSnapshotPolicy + * + * @param aspId for deleting + */ + public void deleteAsp(String aspId) { + this.deleteAsp(new DeleteAspRequest().withAspId(aspId)); + } + + /** + * Attaching the specified asp to volumes. + * + * @param request The request containing all options for attaching the specified asp to specified volumes. + */ + public void attachAsp(AttachAspRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getAspId(), checkEmptyExceptionMessageFormat(ASPID_MESSAGE_KEY)); + for (String volumeId : request.getVolumeIds()) { + checkStringNotEmpty(volumeId, checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, ASP, request.getAspId()); + internalRequest.addParameter(AspAction.attach.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Detaching the specified asp to volumes. + * + * @param request The request containing all options for detaching the specified asp to specified volumes. + */ + public void detachAsp(DetachAspRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getAspId(), checkEmptyExceptionMessageFormat(ASPID_MESSAGE_KEY)); + for (String volumeId : request.getVolumeIds()) { + checkStringNotEmpty(volumeId, checkEmptyExceptionMessageFormat(VOLUMEID_MESSAGE_KEY)); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, ASP, request.getAspId()); + internalRequest.addParameter(AspAction.detach.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Listing asps owned by the authenticated user. + * + * @param request The request containing all options for listing asps owned by user. + * @return The response with list of asps. + */ + public ListAspsResponse listAsps(ListAspsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ASP); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getAspName())) { + internalRequest.addParameter(ASPNAME_MESSAGE_KEY, request.getAspName()); + } + if (!Strings.isNullOrEmpty(request.getVolumeName())) { + internalRequest.addParameter(VOLUME_NAME, request.getVolumeName()); + } + return invokeHttpClient(internalRequest, ListAspsResponse.class); + } + + /** + * Getting the detail information of specified asp. + * + * @param request The request containing all options for getting the detail information of specified asp. + * @return The response with the asp detail information. + */ + public GetAspResponse getAsp(GetAspRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getAspId(), checkEmptyExceptionMessageFormat(ASPID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, ASP, request.getAspId()); + return invokeHttpClient(internalRequest, GetAspResponse.class); + } + + /** + * Get the detail information of specified asp. + * + * @param aspId The id of asp. + * @return The response with the asp detail information. + */ + public GetAspResponse getAsp(String aspId) { + return this.getAsp(new GetAspRequest().withAspId(aspId)); + } + + /** + * Updating autoSnapshotPolicy + * + * @param request contains params for creating a new asp + */ + public void updateAsp(UpdateAspRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(ASPNAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getAspId(), checkEmptyExceptionMessageFormat(ASPNAME_MESSAGE_KEY)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ASP, AspAction.update.name()); + + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Listing SecurityGroup owned by the authenticated user. + * + * @param request The request containing all options for listing SecurityGroup owned by user. + * @return The response with list of SecurityGroup which contains SecurityGroup rules owned by user. + */ + public ListSecurityGroupsResponse listSecurityGroups(ListSecurityGroupsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, SECURITYGROUP_PREFIX); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getInstanceId())) { + internalRequest.addParameter(INSTANCEID_MESSAGE_KEY, request.getInstanceId()); + } + if (!Strings.isNullOrEmpty(request.getVpcId())) { + internalRequest.addParameter(VPC_ID, request.getVpcId()); + } + return invokeHttpClient(internalRequest, ListSecurityGroupsResponse.class); + } + + /** + * Get the detail information of specified SecurityGroup. + * + * @param securityGroupId The id of the SecurityGroup. + * @return The SecurityGroup detail model for the securityGroupId. + */ + public SecurityGroupModel getSecurityGroup(String securityGroupId) { + return this.getSecurityGroup(new GetSecurityGroupRequest().withSecurityGroupId(securityGroupId)); + } + + /** + * Get the detail information of specified SecurityGroup. + * + * @param request The request containing all options for getting the SecurityGroup info. + * @return The SecurityGroup detail model for the securityGroupId. + */ + public SecurityGroupModel getSecurityGroup(GetSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITYGROUPID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, SECURITYGROUP_PREFIX, request.getSecurityGroupId()); + return invokeHttpClient(internalRequest, SecurityGroupModel.class); + } + + /** + * Creating a newly SecurityGroup with specified rules. + * + * @param request The request containing all options for creating a new SecurityGroup. + * @return The response with the id of SecurityGroup that was created newly. + */ + public CreateSecurityGroupResponse createSecurityGroup(CreateSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + if (null == request.getRules() || request.getRules().isEmpty()) { + throw new IllegalArgumentException("request rules should not be empty"); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, SECURITYGROUP_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateSecurityGroupResponse.class); + } + + /** + * authorizing a security group rule to a specified security group + * + * @param request The request containing all options for authorizing security group rule + */ + public void authorizeSecurityGroupRule(SecurityGroupRuleOperateRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITYGROUPID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getRule()) { + throw new IllegalArgumentException("request rule should not be null"); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, SECURITYGROUP_PREFIX, + request.getSecurityGroupId()); + internalRequest.addParameter(SecurityGroupAction.authorizeRule.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * revoking a security group rule from the specified security group + * + * @param request The request containing all options for revoking security group rule + */ + public void revokeSecurityGroupRule(SecurityGroupRuleOperateRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITYGROUPID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getRule()) { + throw new IllegalArgumentException("request rule should not be null"); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, SECURITYGROUP_PREFIX, + request.getSecurityGroupId()); + internalRequest.addParameter(SecurityGroupAction.revokeRule.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Deleting the specified SecurityGroup. + * + * @param securityGroupId The id of SecurityGroup that will be deleted. + */ + public void deleteSecurityGroup(String securityGroupId) { + deleteSecurityGroup(new DeleteSecurityGroupRequest().withSecurityGroupId(securityGroupId)); + } + + /** + * Deleting the specified SecurityGroup. + * + * @param request The request containing all options for deleting the specified SecurityGroup owned by user. + */ + public void deleteSecurityGroup(DeleteSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITYGROUPID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, SECURITYGROUP_PREFIX, request.getSecurityGroupId()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * listing zones within current region + * + * @return The response with list of zones + */ + public ListZonesResponse listZones() { + return listZones(new AbstractBceRequest() { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + return null; + } + }); + } + + /** + * listing zones within current region + * + * @param request use withRequestCredentials + * @return The response with list of zones + */ + public ListZonesResponse listZones(AbstractBceRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ZONE); + return invokeHttpClient(internalRequest, ListZonesResponse.class); + } + + /** + * create an keypair. + * + * @param request you can specify name and description in the request + * @return KeypairModel + */ + public KeypairModel createKeypair(KeypairCreateRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, KEYPAIR); + internalRequest.addParameter(KeypairAction.create.name(), null); + fillPayload(internalRequest, request); + KeypairCreateResponse response = invokeHttpClient(internalRequest, KeypairCreateResponse.class); + return response.getKeypair(); + } + + /** + * Import an keypair. + * User can import an keypair which is created manually. + * The imported keypair must support one of the following encrypt method: rsa/dsa/ssh-rsa/ssh-dss/ecdsa + * + * @param request KeypairImportRequest + */ + public KeypairModel importKeypair(KeypairImportRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, KEYPAIR); + fillPayload(internalRequest, request); + KeypairCreateResponse response = invokeHttpClient(internalRequest, KeypairCreateResponse.class); + return response.getKeypair(); + } + + /** + * Attach an keypair to one or more instances. + * + * @param request KeypairAttachRequest + */ + public void attachKeypair(KeypairAttachRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getKeypairId(), checkEmptyExceptionMessageFormat(KEYPAIR_ID_MESSAGE_KEY)); + if (request.getInstanceIds() == null || request.getInstanceIds().size() == 0) { + throw new IllegalArgumentException("keypair attach: instanceIds can not be empty"); + } + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, KEYPAIR, request.getKeypairId()); + internalRequest.addParameter(KeypairAction.attach.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Detach the keypair from one or more instances. + * if the keypair has not been attached to one instance, the operation will be ignored. + * + * @param request KeypairDetachRequest + */ + public void detachKeypair(KeypairDetachRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getKeypairId(), checkEmptyExceptionMessageFormat(KEYPAIR_ID_MESSAGE_KEY)); + if (request.getInstanceIds() == null || request.getInstanceIds().size() == 0) { + throw new IllegalArgumentException("keypair detach: instanceIds can not be empty"); + } + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, KEYPAIR, request.getKeypairId()); + internalRequest.addParameter(KeypairAction.detach.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete keypair. + * If the keypair is attached to one or more instances, then it can not be deleted. + * + * @param request KeypairDeleteRequest + */ + public void deleteKeypair(KeypairDeleteRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getKeypairId(), checkEmptyExceptionMessageFormat(KEYPAIR_ID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, KEYPAIR, request.getKeypairId()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query keypair's detail information. + * + * @param request KeypairDetailRequest + */ + public KeypairModel keypairDetail(KeypairDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getKeypairId(), checkEmptyExceptionMessageFormat(KEYPAIR_ID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, KEYPAIR, request.getKeypairId()); + KeypairResponse response = invokeHttpClient(internalRequest, KeypairResponse.class); + return response.getKeypair(); + } + + /** + * Query keypair's information from specifics range. + * + * @param request The request containing all options for querying the keypair list. + */ + public KeypairListResponse listKeypair(KeypairListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, KEYPAIR); + + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + + if (request.getName() != null && request.getName().length() > 0) { + internalRequest.addParameter(NAME_MESSAGE_KEY, request.getName()); + } + return invokeHttpClient(internalRequest, KeypairListResponse.class); + } + + /** + * Rename an keypair to instance. + * + * @param request The request containing all options for renaming the specified keypair. + */ + public void renameKeypair(KeypairRenameRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getKeypairId(), checkEmptyExceptionMessageFormat(KEYPAIR_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, KEYPAIR, request.getKeypairId()); + internalRequest.addParameter(KeypairAction.rename.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * update the description of the keypair to instance. + * + * @param request The request containing all options for updating the description of the keypair. + */ + public void updateKeypairDescription(KeypairUpdateDescRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getKeypairId(), checkEmptyExceptionMessageFormat(KEYPAIR_ID_MESSAGE_KEY)); + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, KEYPAIR, request.getKeypairId()); + internalRequest.addParameter(KeypairAction.updateDesc.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query the user's deploy set list + * + * @return List of deployment set info + */ + public ListDeploySetResponse listDeploySet() { + return listDeploySet(new AbstractBceRequest() { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + return null; + } + }); + } + + /** + * Query the user's deploy set list + * + * @param request The request containing all options for querying the deploy set list. + * @return List of deployment set info + */ + private ListDeploySetResponse listDeploySet(AbstractBceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, + INSTANCE_PREFIX, DEPLOYSET, DeploySetAction.list.name()); + + return invokeHttpClient(internalRequest, ListDeploySetResponse.class); + } + + /** + * Create a deploy set + * + * @param request The request containing all options for creating a deploy set. + * @return List of deploy set ids + */ + public CreateDeploySetResponse createDeploySet(CreateDeploySetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, + INSTANCE_PREFIX, DEPLOYSET, DeploySetAction.create.name()); + + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateDeploySetResponse.class); + } + + /** + * Delete a deploy set with deployId + * + * @param request The request containing all options for deleting the specified deploy set. + */ + public void deleteDeploySet(DeleteDeploySetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, INSTANCE_PREFIX, DEPLOYSET, request.getDeployId()); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update deploy set + * + * @param request The request containing all options for updating the specified deploy set. + */ + public void updateDeploySet(UpdateDeploySetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, INSTANCE_PREFIX, DEPLOYSET, request.getDeployId()); + + internalRequest.addParameter(DeploySetAction.modifyAttribute.name(), null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specific security group rule by the corresponding rule id. + * + * @param securityGroupRuleId the security group rule id to be deleted + */ + public void deleteSecurityGroupRule(String securityGroupRuleId) { + deleteSecurityGroupRule(new DeleteSecurityGroupRuleRequest().withSecurityGroupRuleId(securityGroupRuleId)); + } + + /** + * Delete the specific security group rule via params in the deleteSecurityGroupRuleRequest + * + * @param request the request for deleteSecurityGroupRule + */ + public void deleteSecurityGroupRule(DeleteSecurityGroupRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupRuleId(), + checkEmptyExceptionMessageFormat(SECURITY_GROUP_RULE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.DELETE, + SECURITYGROUP_PREFIX, + SECURITY_GROUP_RULE_PREFIX, + request.getSecurityGroupRuleId()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update the specific security group rule via params in the updateSecurityGroupRuleRequest + * + * @param request the request for updateSecurityGroupRule + */ + public void updateSecurityGroupRule(UpdateSecurityGroupRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupRuleId(), + checkEmptyExceptionMessageFormat(SECURITY_GROUP_RULE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, SECURITYGROUP_PREFIX, + SECURITY_GROUP_RULE_PREFIX, SECURITY_GROUP_RULE_UPDATE_PREFIX); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create a volume Cluster with the specified options. + * + * @param request The request containing all options for creating a volume cluster. + * @return The response with list of id of volumes newly created. + */ + public CreateVolumeClusterResponse createVolumeCluster(CreateVolumeClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VOLUME_CLUSTER_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + internalRequest.addParameter(UUID_FLAG, request.getUuidFlag()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateVolumeClusterResponse.class); + } + + /** + * Listing volumes owned by the authenticated user. + * + * @return The response containing a list of volume owned by the authenticated user. + */ + public ListVolumeClustersResponse listVolumeClusters() { + return listVolumeClusters(new ListVolumeClustersRequest()); + } + + /** + * Listing Cluster owned by the authenticated user. + * + * @param request The request containing all options for listing Clusters owned by the authenticated user. + * @return The response containing a list of Cluster owned by the authenticated user. + */ + public ListVolumeClustersResponse listVolumeClusters(ListVolumeClustersRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, VOLUME_CLUSTER_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getClusterName())) { + internalRequest.addParameter(CLUSTER_NAME_MESSAGE_KEY, request.getClusterName()); + } + if (!Strings.isNullOrEmpty(request.getZoneName())) { + internalRequest.addParameter(ZONE_NAME, request.getZoneName()); + } + return invokeHttpClient(internalRequest, ListVolumeClustersResponse.class); + } + + /** + * Get the detail information of specified cluster. + * + * @param clusterId The id of the volume. + * @return The response containing the detail information of specified volume. + */ + public GetVolumeClusterResponse getVolumeCluster(String clusterId) { + GetVolumeClusterRequest request = new GetVolumeClusterRequest(); + request.setClusterId(clusterId); + return getVolumeCluster(request); + } + + /** + * Get the detail information of specified cluster. + * + * @param request The request containing all options for getting the detail information of specified cluster. + * @return The response containing the detail information of specified cluster. + */ + public GetVolumeClusterResponse getVolumeCluster(GetVolumeClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, VOLUME_CLUSTER_PREFIX, request.getClusterId()); + return invokeHttpClient(internalRequest, GetVolumeClusterResponse.class); + } + + /** + * Resizing the specified cluster with newly size. + * + * @param clusterId The id of cluster which you want to resize. + * @param newClusterSizeInGB The new cluster size you want to resize in GB. + */ + public void resizeVolumeCluster(String clusterId, int newClusterSizeInGB) { + ResizeVolumeClusterRequest request = new ResizeVolumeClusterRequest(); + request.setClusterId(clusterId); + request.setNewClusterSizeInGB(newClusterSizeInGB); + this.resizeVolumeCluster(request); + } + + /** + * Resizing the specified cluster with newly size. + * + * @param request The request containing all options for resize the specified cluster. + */ + public void resizeVolumeCluster(ResizeVolumeClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkState(request.getNewClusterSizeInGB() > 0, + "request newClusterSizeInGB should greater than 0"); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_CLUSTER_PREFIX, request.getClusterId()); + internalRequest.addParameter(VolumeAction.resize.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * PurchaseReserved the cluster with fixed duration. + * + * @param clusterId The id of cluster which will be renew. + * @param reservationLength The fixed duration to renew,available is [6,12,24,36,60] + * @param reservationTimeUnit The timeUnit to renew the instance, support "month" now. + */ + public void purchaseReservedVolumeCluster(String clusterId, int reservationLength, String reservationTimeUnit) { + PurchaseReservedVolumeClusterRequest request = new PurchaseReservedVolumeClusterRequest(); + request.setClusterId(clusterId); + Billing billing = new Billing(); + Reservation reservation = new Reservation(); + reservation.setReservationLength(reservationLength); + reservation.setReservationTimeUnit(reservationTimeUnit); + billing.setReservation(reservation); + request.setBilling(billing); + this.purchaseReservedVolumeCluster(request); + } + + /** + * PurchaseReserved the cluster with fixed duration. + *

+ * You can not purchaseReserved the cluster which is resizing. + * + * @param request The request containing all options for renew the specified cluster. + */ + public void purchaseReservedVolumeCluster(PurchaseReservedVolumeClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_CLUSTER_PREFIX, request.getClusterId()); + internalRequest.addParameter(VolumeAction.purchaseReserved.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void autoRenewVolumeCluster(String clusterId, int renewTime, String renewTimeUnit) { + AutoRenewVolumeClusterRequest request = new AutoRenewVolumeClusterRequest(); + request.setClusterId(clusterId); + request.setRenewTime(renewTime); + request.setRenewTimeUnit(renewTimeUnit); + autoRenewVolumeCluster(request); + } + + /** + * Enable auto renewal the specified cluster + * + * @param request The request containing all options for renew the specified cluster. + */ + public void autoRenewVolumeCluster(AutoRenewVolumeClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + if (request.getRenewTime() <= 0) { + throw new IllegalArgumentException("request renewTime should be a positive integer"); + } + + if (!request.getRenewTimeUnit().equalsIgnoreCase("month") && + !request.getRenewTimeUnit().equalsIgnoreCase("year")) { + throw new IllegalArgumentException("request renewTimeUnit only support \"month\" and \"year\""); + } + + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VOLUME_CLUSTER_PREFIX, VolumeAction.autoRenew.name()); + + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Disable auto renewal the cluster + * + * @param request The request containing all options for disable auto renew the specified cluster. + */ + public void cancelAutoRenewVolumeCluster(CancelAutoRenewVolumeClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, VOLUME_CLUSTER_PREFIX, VolumeAction.cancelAutoRenew.name()); + + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * The cluster can be unsubscribed after six months of use. + * + * @param clusterId The id of the volume. + */ + public void refundVolumeCluster(String clusterId) { + GetVolumeClusterRequest request = new GetVolumeClusterRequest(); + request.setClusterId(clusterId); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, VOLUME_CLUSTER_PREFIX, request.getClusterId()); + invokeHttpClient(internalRequest, GetVolumeClusterResponse.class); + } + + public BatchRefundResourceResponse batchRefundResource(BatchRefundResourceRequest request) { + + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + INSTANCE_PREFIX, "batchRefundResource"); + + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchRefundResourceResponse.class); + } + + public void delIpv6(InstanceIpv6Request request) { + + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + INSTANCE_PREFIX, "delIpv6"); + + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public InstanceAddIpv6Response addIpv6(InstanceIpv6Request request) { + + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + INSTANCE_PREFIX, "addIpv6"); + + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, InstanceAddIpv6Response.class); + } + + public void batchDeleteIp(BatchDeleteIpRequest request) { + + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + INSTANCE_PREFIX, "batchDelIp"); + + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public BatchAddIpResponse batchAddIp(BatchAddIpRequest request) { + + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + INSTANCE_PREFIX, "batchAddIp"); + + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, BatchAddIpResponse.class); + } + + public GetAvailableImagesBySpecResponse getAvailableImagesBySpec( + GetAvailableImagesBySpecRequest request) { + + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + IMAGE_PREFIX, "getAvailableImagesBySpec"); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getSpec())) { + internalRequest.addParameter("spec", request.getSpec()); + } + if (!Strings.isNullOrEmpty(request.getOsName())) { + internalRequest.addParameter("osName", request.getOsName()); + } + + return invokeHttpClient(internalRequest, GetAvailableImagesBySpecResponse.class); + } + + public CreateReservedInstanceResponse createReservedInstances(CreateReservedInstancesRequest request) { + + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.POST, BCC_RESERVED_PREFIX, "create"); + + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, CreateReservedInstanceResponse.class); + } + + public ModifyReservedInstancesResponse modifyReservedInstances(ModifyReservedInstancesRequest request) { + + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.PUT, BCC_RESERVED_PREFIX, "modify"); + + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, ModifyReservedInstancesResponse.class); + } + + public void bindReservedInstanceToTags(ReservedTagsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkMultyParamsNotBothEmpty(request.getReservedInstanceIds(), "reservedInstanceIds should NOT be null."); + if (CollectionUtils.isEmpty(request.getChangeTags())) { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + for (TagModel tag : request.getChangeTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + BCC_RESERVED_TAG_PREFIX); + internalRequest.addParameter(BIND, null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void unbindReservedInstanceFromTags(ReservedTagsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkMultyParamsNotBothEmpty(request.getReservedInstanceIds(), "reservedInstanceIds should NOT be null."); + if (CollectionUtils.isEmpty(request.getChangeTags())) { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + for (TagModel tag : request.getChangeTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + BCC_RESERVED_TAG_PREFIX); + internalRequest.addParameter(UNBIND, null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void bindTagsBatchByResourceType(TagsOperationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkMultyParamsNotBothEmpty(request.getResourceIds(), "resourceIds should NOT be null."); + checkResourceType(request.getResourceType()); + if (CollectionUtils.isEmpty(request.getTags())) { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + for (TagModel tag : request.getTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + + InternalRequest internalRequest = this.createRequestV3(request, HttpMethodName.POST, + V3_TAG_PREFIX); + internalRequest.addParameter(ACTION, ATTACH); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public VolumePriceResponse getCdsPrice(VolumePriceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VOLUME_PREFIX, GET_PRICE); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + + return invokeHttpClient(internalRequest, VolumePriceResponse.class); + } + + public void createAutoRenewRule(BccAutoRenewRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, INSTANCE_PREFIX, CREATA_AUTO_RENEW_RULE); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void unbindTagsBatchByResourceType(TagsOperationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkMultyParamsNotBothEmpty(request.getResourceIds(), "resourceIds should NOT be null."); + checkResourceType(request.getResourceType()); + if (CollectionUtils.isEmpty(request.getTags())) { + throw new IllegalArgumentException(CHANGETAGS_NULL_ERROR_MESSAGE); + } + for (TagModel tag : request.getTags()) { + checkStringNotEmpty(tag.getTagKey(), checkEmptyExceptionMessageFormat(TAGKEY_MESSAGE_KEY)); + } + + InternalRequest internalRequest = this.createRequestV3(request, HttpMethodName.POST, + V3_TAG_PREFIX); + internalRequest.addParameter(ACTION, DETACH); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteAutoRenewRule(BccAutoRenewRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, INSTANCE_PREFIX, DELETE_AUTO_RENEW_RULE); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public BatchChangeToPrepaidResponse batchChangeToPrepaid(BatchChangeToPrepaidRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + INSTANCE_PREFIX, BATCH_CHARGING); + internalRequest.addParameter(InstanceAction.toPrepay.name(), null); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchChangeToPrepaidResponse.class); + } + + public ListRecycleInstanceResponse listRecycleInstance(ListRecycleInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (request.getMaxKeys() < 0) { + request.setMaxKeys(1000); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, RECYCLE_INSTANCE); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ListRecycleInstanceResponse.class); + } + + public ListAvailableResizeSpecResponse listAvailableResizeSpec(ListAvailableResizeSpecRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX); + internalRequest.addParameter(RESIZE_LIST, null); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ListAvailableResizeSpecResponse.class); + } + + public AbstractBceResponse changeVpc(ChangeVpcRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, VPC_PREFIX, CHANGE_VPC); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ListInstanceEnisResponse listInstanceEnis(ListInstanceEnisRequest request) { + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + ENI_PREFIX, request.getInstanceId()); + return invokeHttpClient(internalRequest, ListInstanceEnisResponse.class); + } + + public CreateEhcClusterResponse createEhcCluster(CreateEhcClusterRequest request) { + checkStringNotEmpty(request.getZoneName(), checkEmptyExceptionMessageFormat(ZONE_NAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX, + EHC_CLUSTER_CREATE); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEhcClusterResponse.class); + } + + public DescribeEhcClusterListResponse ehcClusterList(DescribeEhcClusterListRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX, + EHC_CLUSTER_LIST); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DescribeEhcClusterListResponse.class); + } + + public void modifyEhcCluster(ModifyEhcClusterRequest request) { + checkStringNotEmpty(request.getEhcClusterId(), checkEmptyExceptionMessageFormat(ZONE_NAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX, + EHC_CLUSTER_MODIFY); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteEhcCluster(DeleteEhcClusterRequest request) { + checkNotNull(request.getEhcClusterIdList(), checkEmptyExceptionMessageFormat(ZONE_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX, + EHC_CLUSTER_DELETE); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/bcc/BccClientConfiguration.java b/src/main/java/com/baidubce/services/bcc/BccClientConfiguration.java new file mode 100644 index 00000000..776693d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/BccClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for bcc service. + */ +public class BccClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/AutoSnapshotPolicyModel.java b/src/main/java/com/baidubce/services/bcc/model/AutoSnapshotPolicyModel.java new file mode 100644 index 00000000..628f74ab --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/AutoSnapshotPolicyModel.java @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +import java.util.Date; +import java.util.List; + +/** + * The model of autoSnapshotPolicy detail information + */ +public class AutoSnapshotPolicyModel { + /** + * id of the asp + */ + private String id; + + /** + * name of the asp + */ + private String name; + + /** + * Specifies the time point of creating an automatic snapshot . + * The smallest unit is the hour. + * There are 24 time points from 00:00 to 23:00. + * The number of parameters is 0 to 23. + * For example, 1 represents the time point at 01:00. + * Multiple time points can be selected. + * The parameter is a Json Array:[0, 1,... 23], at most 24 time points. + */ + private List timePoints; + + /** + * Specify a duplicate date for the automatic snapshot. + * Choose the date from Monday to Sunday when you need to create snapshots, + * with a number of parameters ranging from 1 to 7, + * such as: 1 for Monday. Multiple dates are allowed. + * The parameter is a Json Array:[1, 2... 7]. + */ + private List repeatWeekdays; + + /** + * Specify the retention time of the automatic snapshot in days. + * -1: Permanent preservation . + * 1-65536: specified number of days. + */ + private String retentionDays; + + /** + * status of asp + */ + private String status; + + /** + * create time of asp + */ + private Date createdTime; + + /** + * updated time of asp + */ + private Date updatedTime; + + /** + * deleted time of asp + */ + private Date deletedTime; + + /** + * last execute time of asp + */ + private Date lastExecuteTime; + + /** + * related volume's number + */ + private int volumeCount; + + private String autoSnapshotPolicyId; + + public AutoSnapshotPolicyModel withAutoSnapshotPolicyId(String autoSnapshotPolicyId) { + this.autoSnapshotPolicyId = autoSnapshotPolicyId; + return this; + } + + public String getAutoSnapshotPolicyId() { + return autoSnapshotPolicyId; + } + + public void setAutoSnapshotPolicyId(String autoSnapshotPolicyId) { + this.autoSnapshotPolicyId = autoSnapshotPolicyId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getTimePoints() { + return timePoints; + } + + public void setTimePoints(List timePoints) { + this.timePoints = timePoints; + } + + public List getRepeatWeekdays() { + return repeatWeekdays; + } + + public void setRepeatWeekdays(List repeatWeekdays) { + this.repeatWeekdays = repeatWeekdays; + } + + public String getRetentionDays() { + return retentionDays; + } + + public void setRetentionDays(String retentionDays) { + this.retentionDays = retentionDays; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Date createdTime) { + this.createdTime = createdTime; + } + + public Date getUpdatedTime() { + return updatedTime; + } + + public void setUpdatedTime(Date updatedTime) { + this.updatedTime = updatedTime; + } + + public Date getDeletedTime() { + return deletedTime; + } + + public void setDeletedTime(Date deletedTime) { + this.deletedTime = deletedTime; + } + + public Date getLastExecuteTime() { + return lastExecuteTime; + } + + public void setLastExecuteTime(Date lastExecuteTime) { + this.lastExecuteTime = lastExecuteTime; + } + + public int getVolumeCount() { + return volumeCount; + } + + public void setVolumeCount(int volumeCount) { + this.volumeCount = volumeCount; + } + + @Override + public String toString() { + return "AutoSnapshotPolicyModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", timePoints=" + timePoints + + ", repeatWeekdays=" + repeatWeekdays + + ", retentionDays='" + retentionDays + + '\'' + ", status='" + status + '\'' + + ", createdTime=" + createdTime + + ", updatedTime=" + updatedTime + + ", deletedTime=" + deletedTime + + ", lastExecuteTime=" + lastExecuteTime + + ", volumeCount=" + volumeCount + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/Billing.java b/src/main/java/com/baidubce/services/bcc/model/Billing.java new file mode 100644 index 00000000..c4eadfc7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/Billing.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * The model for billing. + */ +public class Billing { + + /** + * The pay time of the payment,the default value is "Postpaid". + * See more detail in BCE API doc + */ + private String paymentTiming; + + /** + * The reservation model to specify the detail to buy. + */ + private Reservation reservation; + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + /** + * Configure paymentTiming for the model. + * + * @param paymentTiming The pay time of the payment, see more detail in + * BCE API doc + * @return Billing with paymentTiming. + */ + public Billing withPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + return this; + } + + public Reservation getReservation() { + return reservation; + } + + public void setReservation(Reservation reservation) { + this.reservation = reservation; + } + + /** + * Configure reservation for the model. + * + * @param reservation The reservation model to specify the detail to buy. + * @return Billing with reservation. + */ + public Billing withReservation(Reservation reservation) { + this.reservation = reservation; + return this; + } + + @Override + public String toString() { + return "Billing{" + + "paymentTiming='" + paymentTiming + '\'' + + ", reservation=" + reservation + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/CreateCdsModel.java b/src/main/java/com/baidubce/services/bcc/model/CreateCdsModel.java new file mode 100644 index 00000000..e6eb0876 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/CreateCdsModel.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * The model which will be used in purchasing new volume. + */ +public class CreateCdsModel { + + /** + * The size of volume in GB. + */ + private int cdsSizeInGB; + + /** + * The storage type of volume, see more detail in + * BCE API doc + */ + private String storageType; + + /** + * The id of snapshot. + */ + private String snapshotId; + + /** + * encryption key + */ + private String encryptKey; + + public int getCdsSizeInGB() { + return cdsSizeInGB; + } + + public void setCdsSizeInGB(int cdsSizeInGB) { + this.cdsSizeInGB = cdsSizeInGB; + } + + + /** + * Configure cdsSizeInGB for the model. + * + * @param cdsSizeInGB The size of volume in GB. + * @return CreateCdsModel with cdsSizeInGB. + */ + public CreateCdsModel withCdsSizeInGB(int cdsSizeInGB) { + this.cdsSizeInGB = cdsSizeInGB; + return this; + } + + public String getStorageType() { + return storageType; + } + + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * Configure storageType for the model. + * + * @param storageType The storage type of volume, see more detail in + * BCE API doc + * @return CreateCdsModel with storageType. + */ + public CreateCdsModel withStorageType(String storageType) { + this.storageType = storageType; + return this; + } + + public String getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + /** + * Configure snapshotId for the model. + * + * @param snapshotId The id of snapshot. + * @return CreateCdsModel with snapshotId. + */ + public CreateCdsModel withSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + return this; + } + + + public String getEncryptKey() { + return encryptKey; + } + + public void setEncryptKey(String encryptKey) { + this.encryptKey = encryptKey; + } + + /** + * Configure encryptKey for the model. + * + * @param encryptKey encryption key + * @return CreateCdsModel with encryptKey. + */ + public CreateCdsModel withEncryptKey(String encryptKey) { + this.encryptKey = encryptKey; + return this; + } + + @Override + public String toString() { + return "CreateCdsModel{" + + "cdsSizeInGB=" + cdsSizeInGB + + ", storageType='" + storageType + '\'' + + ", snapshotId='" + snapshotId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/DeploySetModel.java b/src/main/java/com/baidubce/services/bcc/model/DeploySetModel.java new file mode 100644 index 00000000..ca0512f5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/DeploySetModel.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcc.model; + +import lombok.Data; + +@Data +public class DeploySetModel { + private String deploysetId; + private String name; + private String description; + private int concurrency; + private String strategy; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/ImageModel.java b/src/main/java/com/baidubce/services/bcc/model/ImageModel.java new file mode 100644 index 00000000..9a4e51f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/ImageModel.java @@ -0,0 +1,256 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Date; + +/** + * The model of image detail information + */ +public class ImageModel { + + /** + * The id of the image. + */ + private String id; + + /** + * The name of the image. + */ + private String name; + + /** + * The type of the image, + * see more detail on BCE API doc + */ + private String type; + + /** + * Type of the operating system used in the image,like linux,windows etc. + */ + private String osType; + + /** + * The version of the operating system used in the image. + */ + private String osVersion; + + /** + * The architecture of the operating system used in the image. + */ + private String osArch; + + /** + * The name of the operating system used in the image. + */ + private String osName; + + /** + * The built version of the operating system used in the image. + */ + private String osBuild; + + /** + * The create time of the image + */ + private Date createTime; + + /** + * The status of the image. + * see more detail on BCE API doc + */ + private String status; + + /** + * The description of the image. + */ + private String desc; + + /** + * The special version information of the operating system. + */ + private String specialVersion; + + /** + * The language of the operation system. CHS means Chinese, ENG means English. + */ + private String osLang; + + /** + * Whether the image is big or not. The default value is false. If true, it means it is the big image. + */ + @JsonProperty("package") + private boolean packaged; + + /** + * Limit on the number of users that can be shared. + */ + private int shareToUserNumLimit; + + /** + * The number of users shared. + */ + private int sharedToUserNum; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getOsType() { + return osType; + } + + public void setOsType(String osType) { + this.osType = osType; + } + + public String getOsVersion() { + return osVersion; + } + + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } + + public String getOsArch() { + return osArch; + } + + public void setOsArch(String osArch) { + this.osArch = osArch; + } + + public String getOsName() { + return osName; + } + + public void setOsName(String osName) { + this.osName = osName; + } + + public String getOsBuild() { + return osBuild; + } + + public void setOsBuild(String osBuild) { + this.osBuild = osBuild; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getSpecialVersion() { + return specialVersion; + } + + public void setSpecialVersion(String specialVersion) { + this.specialVersion = specialVersion; + } + + public String getOsLang() { + return osLang; + } + + public void setOsLang(String osLang) { + this.osLang = osLang; + } + + public boolean isPackaged() { + return packaged; + } + + public void setPackaged(boolean packaged) { + this.packaged = packaged; + } + + public int getShareToUserNumLimit() { + return shareToUserNumLimit; + } + + public void setShareToUserNumLimit(int shareToUserNumLimit) { + this.shareToUserNumLimit = shareToUserNumLimit; + } + + public int getSharedToUserNum() { + return sharedToUserNum; + } + + public void setSharedToUserNum(int sharedToUserNum) { + this.sharedToUserNum = sharedToUserNum; + } + + @Override + public String toString() { + return "ImageModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", type='" + type + '\'' + + ", osType='" + osType + '\'' + + ", osVersion='" + osVersion + '\'' + + ", osArch='" + osArch + '\'' + + ", osName='" + osName + '\'' + + ", osBuild='" + osBuild + '\'' + + ", createTime='" + createTime + '\'' + + ", status='" + status + '\'' + + ", desc='" + desc + '\'' + + ", specialVersion='" + specialVersion + '\'' + + ", osLang='" + osLang + '\'' + + ", package='" + packaged + '\'' + + ", shareToUserNumLimit='" + shareToUserNumLimit + '\'' + + ", sharedToUserNum='" + sharedToUserNum + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/InstanceModel.java b/src/main/java/com/baidubce/services/bcc/model/InstanceModel.java new file mode 100644 index 00000000..600224e5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/InstanceModel.java @@ -0,0 +1,625 @@ +/* + * Copyright (c) 2018-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +import lombok.ToString; +import java.util.Date; +import java.util.List; + +/** + * instance detail info model + */ +@ToString +public class InstanceModel { + + /** + * The identified id of the instance + */ + private String id; + + /** + * The name of the instance. + */ + private String name; + + /** + * The hostname of the instance. + */ + private String hostname; + + /** + * The status of the instance, + * see more detail on BCE API doc + */ + private String status; + + /** + * The description of the instance. + */ + private String desc; + + /** + * The payment method of purchasing the instance, + * see more detail in BCE API doc + */ + private String paymentTiming; + + /** + * The time when the instance was created + */ + private Date createTime; + + /** + * The time when the instance will be expired. + * If it's Postpaid, it will not have expired time. + */ + private Date expireTime; + + /** + * The internal ip address for accessing. + */ + private String internalIp; + + /** + * The public ip address for accessing. + */ + private String publicIp; + + /** + * The available count of CPU within the instance + */ + private int cpuCount; + + /** + * The total size of memory in GB for the instance. + */ + private int memoryCapacityInGB; + + /** + * The total size of temporary volume in GB,exclude the system volume. + */ + private int localDiskSizeInGB; + + /** + * The id which was used to build the instance. + */ + private String imageId; + + /** + * The total bandwidth in Mbps for the instance. + */ + private int networkCapacityInMbps; + + /** + * the name of available zone + */ + private String zoneName; + + /** + * The list of bonded tags. + */ + private List tags; + + /** + * The list of resource group. + */ + private List resGroupInfos; + + /** + * The policy of the instance placement + * when "default",the instance has been placed by system auto, while "dedicatedHost", stands for been placed at dcc + */ + private String placementPolicy; + + private String subnetId; + + private String vpcId; + + /** + * The parameter to specified which kind of instance created. + * see all of supported instance type in {@link com.baidubce.services.bcc.model.instance.InstanceType} + */ + private String instanceType; + + /** + * The gpu card info for creating gpu instance. + */ + private String gpuCard; + + /** + * The fpag card info for creating fpga instance. + */ + private String fpgaCard; + + /** + * The card count for creating GPU/FPGA instance + */ + private int cardCount; + + /** + * The id of the keypair + */ + private String keypairId; + + /** + * The name of the keypair + */ + private String keypairName; + + /** + * specified id of dedicated host when creating dedicated instance + */ + private String dedicatedHostId; + + /** + * whether the instacne is auto renew or not + */ + private boolean autoRenew; + + /** + * The address of the ipv6 + */ + private String ipv6; + + private Boolean enableJumboFrame; + + private Integer netEthQueueCount; + + /** + * The instance of spec. + */ + private String spec; + private String roleName; + private String createdFrom; + private String isomerismCard; + private String npuVideoMemory; + private String imageName; + private String imageType; + private String hostId; + private String switchId; + private String rackId; + private String deploysetId; + private String osVersion; + private String osArch; + private String osName; + private String hosteyeType; + + private String flavorSubType; + private List deploysetList; + private NicInfo nicInfo; + private Integer deletionProtection; + private List volumes; + private String ehcClusterId; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getExpireTime() { + return expireTime; + } + + public void setExpireTime(Date expireTime) { + this.expireTime = expireTime; + } + + public String getInternalIp() { + return internalIp; + } + + public void setInternalIp(String internalIp) { + this.internalIp = internalIp; + } + + public String getPublicIp() { + return publicIp; + } + + public void setPublicIp(String publicIp) { + this.publicIp = publicIp; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + public int getLocalDiskSizeInGB() { + return localDiskSizeInGB; + } + + public void setLocalDiskSizeInGB(int localDiskSizeInGB) { + this.localDiskSizeInGB = localDiskSizeInGB; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public int getNetworkCapacityInMbps() { + return networkCapacityInMbps; + } + + public void setNetworkCapacityInMbps(int networkCapacityInMbps) { + this.networkCapacityInMbps = networkCapacityInMbps; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public String getPlacementPolicy() { + return placementPolicy; + } + + public void setPlacementPolicy(String placementPolicy) { + this.placementPolicy = placementPolicy; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public String getGpuCard() { + return gpuCard; + } + + public void setGpuCard(String gpuCard) { + this.gpuCard = gpuCard; + } + + public String getFpgaCard() { + return fpgaCard; + } + + public void setFpgaCard(String fpgaCard) { + this.fpgaCard = fpgaCard; + } + + public int getCardCount() { + return cardCount; + } + + public void setCardCount(int cardCount) { + this.cardCount = cardCount; + } + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + public String getKeypairName() { + return keypairName; + } + + public void setKeypairName(String keypairName) { + this.keypairName = keypairName; + } + + public String getDedicatedHostId() { + return dedicatedHostId; + } + + public void setDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + } + + public boolean isAutoRenew() { + return autoRenew; + } + + public void setAutoRenew(boolean autoRenew) { + this.autoRenew = autoRenew; + } + + public String getIpv6() { + return ipv6; + } + + public void setIpv6(String ipv6) { + this.ipv6 = ipv6; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public Integer getNetEthQueueCount() { + return netEthQueueCount; + } + + public void setNetEthQueueCount(Integer netEthQueueCount) { + this.netEthQueueCount = netEthQueueCount; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public String getCreatedFrom() { + return createdFrom; + } + + public void setCreatedFrom(String createdFrom) { + this.createdFrom = createdFrom; + } + + public String getIsomerismCard() { + return isomerismCard; + } + + public void setIsomerismCard(String isomerismCard) { + this.isomerismCard = isomerismCard; + } + + public String getNpuVideoMemory() { + return npuVideoMemory; + } + + public void setNpuVideoMemory(String npuVideoMemory) { + this.npuVideoMemory = npuVideoMemory; + } + + public String getImageName() { + return imageName; + } + + public void setImageName(String imageName) { + this.imageName = imageName; + } + + public String getImageType() { + return imageType; + } + + public void setImageType(String imageType) { + this.imageType = imageType; + } + + public String getHostId() { + return hostId; + } + + public void setHostId(String hostId) { + this.hostId = hostId; + } + + public String getSwitchId() { + return switchId; + } + + public void setSwitchId(String switchId) { + this.switchId = switchId; + } + + public String getRackId() { + return rackId; + } + + public void setRackId(String rackId) { + this.rackId = rackId; + } + + public String getDeploysetId() { + return deploysetId; + } + + public void setDeploysetId(String deploysetId) { + this.deploysetId = deploysetId; + } + + public String getOsVersion() { + return osVersion; + } + + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } + + public String getOsArch() { + return osArch; + } + + public void setOsArch(String osArch) { + this.osArch = osArch; + } + + public String getOsName() { + return osName; + } + + public void setOsName(String osName) { + this.osName = osName; + } + + public String getHosteyeType() { + return hosteyeType; + } + + public void setHosteyeType(String hosteyeType) { + this.hosteyeType = hosteyeType; + } + + public List getDeploysetList() { + return deploysetList; + } + + public void setDeploysetList(List deploysetList) { + this.deploysetList = deploysetList; + } + + public NicInfo getNicInfo() { + return nicInfo; + } + + public void setNicInfo(NicInfo nicInfo) { + this.nicInfo = nicInfo; + } + + public Integer getDeletionProtection() { + return deletionProtection; + } + + public void setDeletionProtection(Integer deletionProtection) { + this.deletionProtection = deletionProtection; + } + + public List getVolumes() { + return volumes; + } + + public void setVolumes(List volumes) { + this.volumes = volumes; + } + + public Boolean getEnableJumboFrame() { + return enableJumboFrame; + } + + public void setEnableJumboFrame(Boolean enableJumboFrame) { + this.enableJumboFrame = enableJumboFrame; + } + + public String getFlavorSubType() { + return flavorSubType; + } + + public void setFlavorSubType(String flavorSubType) { + this.flavorSubType = flavorSubType; + } + public List getResGroupInfos() { + return resGroupInfos; + } + public void setResGroupInfos(List resGroupInfos) { + this.resGroupInfos = resGroupInfos; + } + + public String getEhcClusterId() { + return ehcClusterId; + } + + public void setEhcClusterId(String ehcClusterId) { + this.ehcClusterId = ehcClusterId; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/InstanceTypeModel.java b/src/main/java/com/baidubce/services/bcc/model/InstanceTypeModel.java new file mode 100644 index 00000000..ad6f123f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/InstanceTypeModel.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * The Specifications detail model for purchasing instance. + * See more detail on + * + * BCE API doc + */ +public class InstanceTypeModel { + + /** + * The general type defined by the Specification + */ + private String type; + + /** + * The name of the Specification which will be used when purchasing new instance. + */ + private String name; + + /** + * The total count of available CPU in this Specification. + */ + private int cpuCount; + + /** + * The total size of available memory in BG in this Specification. + */ + private int memorySizeInGB; + + /** + * The total size of available temporary volume in BG in this Specification. + */ + private int localDiskSizeInGB; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getMemorySizeInGB() { + return memorySizeInGB; + } + + public void setMemorySizeInGB(int memorySizeInGB) { + this.memorySizeInGB = memorySizeInGB; + } + + public int getLocalDiskSizeInGB() { + return localDiskSizeInGB; + } + + public void setLocalDiskSizeInGB(int localDiskSizeInGB) { + this.localDiskSizeInGB = localDiskSizeInGB; + } + + @Override + public String toString() { + return "InstanceTypeModel{" + + "type='" + type + '\'' + + ", name='" + name + '\'' + + ", cpuCount=" + cpuCount + + ", memorySizeInGB=" + memorySizeInGB + + ", localDiskSizeInGB=" + localDiskSizeInGB + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/NicInfo.java b/src/main/java/com/baidubce/services/bcc/model/NicInfo.java new file mode 100644 index 00000000..16a3f466 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/NicInfo.java @@ -0,0 +1,52 @@ +package com.baidubce.services.bcc.model; + +import com.baidubce.services.eni.model.Eni; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class NicInfo { + private String eniId; + private String eniUuid; + private String name; + private String type; + private String subnetId; + private String subnetType; + private String az; + private String description; + private String deviceId; + private String status; + private List ips; + private List ipv6s; + private String macAddress; + private String vpcId; + private List securityGroups; + private List privateIpSet; + private String createdTime; + private int eniNum; + private int eriNum; + private List eriInfos; + private List eniInfos; + private String zoneName; + private String instanceId; + private List securityGroupIds; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class IpInfo { + private String privateIp; + private String eip; + private boolean primary; + private String eipId; + private String eipAllocationId; + private Integer eipSize; + private String eipStatus; + private String eipGroupId; + private String publicIpAddress; + private String privateIpAddress; + private String ipv6Address; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/OsModel.java b/src/main/java/com/baidubce/services/bcc/model/OsModel.java new file mode 100644 index 00000000..5e1ddac2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/OsModel.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * The Specifications detail model for os. + * See more detail on + * + * BCE API doc + */ +public class OsModel { + /** + * short id of instance + */ + private String instanceId; + + /** + * arch of os, eg: x86_64 (64bit) + */ + private String osArch; + + /** + * name of os, eg:CentOS + */ + private String osName; + + /** + * version of os, eg:6.5 + */ + private String osVersion; + + /** + * type of os, eg:linux + */ + private String osType; + + /** + * The language of the operating system. CHS means Chinese, ENG means English. + */ + private String osLang; + + /** + * The special version information of the operating system. + */ + private String specialVersion; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getOsArch() { + return osArch; + } + + public void setOsArch(String osArch) { + this.osArch = osArch; + } + + public String getOsName() { + return osName; + } + + public void setOsName(String osName) { + this.osName = osName; + } + + public String getOsVersion() { + return osVersion; + } + + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } + + public String getOsType() { + return osType; + } + + public void setOsType(String osType) { + this.osType = osType; + } + + public String getOsLang() { + return osLang; + } + + public void setOsLang(String osLang) { + this.osLang = osLang; + } + + public String getSpecialVersion() { + return specialVersion; + } + + public void setSpecialVersion(String specialVersion) { + this.specialVersion = specialVersion; + } + + @Override + public String toString() { + return "OsModel{" + + "instanceId='" + instanceId + '\'' + + ", osArch='" + osArch + '\'' + + ", osName='" + osName + '\'' + + ", osVersion='" + osVersion + '\'' + + ", osType='" + osType + '\'' + + ", osLang='" + osLang + '\'' + + ", specialVersion='" + specialVersion + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/RecycleInstanceModel.java b/src/main/java/com/baidubce/services/bcc/model/RecycleInstanceModel.java new file mode 100644 index 00000000..01c63d0b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/RecycleInstanceModel.java @@ -0,0 +1,32 @@ +package com.baidubce.services.bcc.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.ToString; +import java.util.Date; +import java.util.List; + +@Data +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class RecycleInstanceModel { + private String id; + private String serialNumber; + private Date recycleTime; + private Date deleteTime; + private String serviceName; + private String serviceType; + private ConfigItem configItem; + private List configItems; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class ConfigItem { + private int cpu; + private int memory; + private String type; + private String specId; + private String spec; + private String zoneName; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/Reservation.java b/src/main/java/com/baidubce/services/bcc/model/Reservation.java new file mode 100644 index 00000000..cde9976a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/Reservation.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * The reservation model to specify the detail to buy. + */ +public class Reservation { + /** + * The duration to buy in specified time unit, + * available values are [1,2,3,4,5,6,7,8,9,12,24,36] now. + */ + private int reservationLength; + + /** + * The time unit to specify the duration ,only "Month" can be used now. + */ + private String reservationTimeUnit = "Month"; + + public int getReservationLength() { + return reservationLength; + } + + public void setReservationLength(int reservationLength) { + this.reservationLength = reservationLength; + } + + /** + * Configure reservationLength for the model. + * + * @param reservationLength The duration to buy in specified time unit, + * available values are [1,2,3,4,5,6,7,8,9,12,24,36] now. + * @return Reservation with specified reservationLength. + */ + public Reservation withReservationLength(int reservationLength) { + this.reservationLength = reservationLength; + return this; + } + + public String getReservationTimeUnit() { + return reservationTimeUnit; + } + + public void setReservationTimeUnit(String reservationTimeUnit) { + this.reservationTimeUnit = reservationTimeUnit; + } + + + /** + * Configure reservationTimeUnit for the model. + * + * @param reservationTimeUnit The time unit to specify the duration ,only "Month" can be used now. + * @return Reservation with specified reservationTimeUnit. + */ + public Reservation withReservationTimeUnit(String reservationTimeUnit) { + this.reservationTimeUnit = reservationTimeUnit; + return this; + } + + @Override + public String toString() { + return "Reservation{" + + "reservationLength=" + reservationLength + + ", reservationTimeUnit='" + reservationTimeUnit + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/ResourceGroupModel.java b/src/main/java/com/baidubce/services/bcc/model/ResourceGroupModel.java new file mode 100644 index 00000000..915d1612 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/ResourceGroupModel.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * The detail model of the resource group. + */ +public class ResourceGroupModel { + + /** + * The id of group. + */ + private String groupId; + + /** + * The name of group. + */ + private String groupName; + + public String getGroupId() { + return this.groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return this.groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/SecurityGroupModel.java b/src/main/java/com/baidubce/services/bcc/model/SecurityGroupModel.java new file mode 100644 index 00000000..43755f33 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/SecurityGroupModel.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The list model for describing SecurityGroup. + */ +public class SecurityGroupModel extends AbstractBceResponse { + + /** + * The id of the SecurityGroup. + */ + private String id; + + /** + * The name of the SecurityGroup. + */ + private String name; + + /** + * The id of vpc where the SecurityGroup in. + */ + private String vpcId; + + /** + * The description of the SecurityGroup. + */ + private String desc; + + /** + * The number of instances which bind to the SecurityGroup. + */ + private Integer bindInstanceNum; + + /** + * The creation time of the SecurityGroup. + */ + private String createdTime; + + /** + * List of rules which describe how the SecurityGroup works. + */ + private List rules; + + /** + * The list of tags. + */ + private List tags; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public Integer getBindInstanceNum() { + return bindInstanceNum; + } + + public void setBindInstanceNum(Integer bindInstanceNum) { + this.bindInstanceNum = bindInstanceNum; + } + + public String getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + @Override + public String toString() { + return "SecurityGroupModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", vpcId='" + vpcId + '\'' + + ", desc='" + desc + '\'' + + ", bindInstanceNum='" + bindInstanceNum + '\'' + + ", createdTime='" + createdTime + '\'' + + ", rules=" + rules + + ", tags=" + tags + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/SecurityGroupRuleModel.java b/src/main/java/com/baidubce/services/bcc/model/SecurityGroupRuleModel.java new file mode 100644 index 00000000..e416bca2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/SecurityGroupRuleModel.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * The model about the rule of the securitygroup. + * The tuple of (remark, protocol, direction, portRange, sourceIp|destIp, sourceGroupId|destGroupId) must be unique. + */ +public class SecurityGroupRuleModel { + + /** + * The remark for the rule + */ + private String remark; + + /** + * The parameter to define the rule direction,available value are "ingress/egress" + */ + private String direction; + + /** + * The ethernet protocol + */ + private String ethertype; + + /** + * The port range to specify the port which the rule will work on. + * Available range is rang [0, 65535],"" for all port. + */ + private String portRange; + + /** + * The parameter specify which protocol will the rule work on, the fault value is "" for all protocol. + * Available protocol are tcp,udp and icmp. + */ + private String protocol = ""; + + /** + * The id of source securitygroup. + * Only works for direction = "ingress" + */ + private String sourceGroupId; + + /** + * The source ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "ingress" + */ + private String sourceIp; + + /** + * The id of destination securitygroup. + * Only works for direction = "egress" + */ + private String destGroupId; + + /** + * The destination ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "egress" + */ + private String destIp; + + /** + * The id of the securitygroup for the rule. + */ + private String securityGroupId; + + /** + * The id of the specified security group rule + */ + private String securityGroupRuleId; + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + public SecurityGroupRuleModel withRemark(String remark) { + this.remark = remark; + return this; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public SecurityGroupRuleModel withDirection(String direction) { + this.direction = direction; + return this; + } + + public String getEthertype() { + return ethertype; + } + + public void setEthertype(String ethertype) { + this.ethertype = ethertype; + } + + public SecurityGroupRuleModel withEthertype(String ethertype) { + this.ethertype = ethertype; + return this; + } + + public String getPortRange() { + return portRange; + } + + public void setPortRange(String portRange) { + this.portRange = portRange; + } + + public SecurityGroupRuleModel withPortRange(String portRange) { + this.portRange = portRange; + return this; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public SecurityGroupRuleModel withProtocol(String protocol) { + this.protocol = protocol; + return this; + } + + public String getSourceGroupId() { + return sourceGroupId; + } + + public void setSourceGroupId(String sourceGroupId) { + this.sourceGroupId = sourceGroupId; + } + + public SecurityGroupRuleModel withSourceGroupId(String sourceGroupId) { + this.sourceGroupId = sourceGroupId; + return this; + } + + public String getSourceIp() { + return sourceIp; + } + + public void setSourceIp(String sourceIp) { + this.sourceIp = sourceIp; + } + + public SecurityGroupRuleModel withSourceIp(String sourceIp) { + this.sourceIp = sourceIp; + return this; + } + + public String getDestGroupId() { + return destGroupId; + } + + public void setDestGroupId(String destGroupId) { + this.destGroupId = destGroupId; + } + + public SecurityGroupRuleModel withDestGroupId(String destGroupId) { + this.destGroupId = destGroupId; + return this; + } + + public String getDestIp() { + return destIp; + } + + public void setDestIp(String destIp) { + this.destIp = destIp; + } + + public SecurityGroupRuleModel withDestIp(String destIp) { + this.destIp = destIp; + return this; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + public String getSecurityGroupRuleId() { + return this.securityGroupRuleId; + } + + public void setSecurityGroupRuleId(String securityGroupRuleId) { + this.securityGroupRuleId = securityGroupRuleId; + } + + public SecurityGroupRuleModel withSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + @Override + public String toString() { + return "SecurityGroupRuleModel{" + + "remark='" + remark + '\'' + + ", direction='" + direction + '\'' + + ", ethertype='" + ethertype + '\'' + + ", portRange='" + portRange + '\'' + + ", protocol='" + protocol + '\'' + + ", sourceGroupId='" + sourceGroupId + '\'' + + ", sourceIp='" + sourceIp + '\'' + + ", destGroupId='" + destGroupId + '\'' + + ", destIp='" + destIp + '\'' + + ", securityGroupId='" + securityGroupId + '\'' + + ", securityGroupRuleId='" + securityGroupRuleId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/SharedUserModel.java b/src/main/java/com/baidubce/services/bcc/model/SharedUserModel.java new file mode 100644 index 00000000..fc84b916 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/SharedUserModel.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * The detail model of the sharedUser. + */ +public class SharedUserModel { + + /** + * The name of account for sharing image + */ + private String account; + + /** + * The id of account for sharing image + */ + private String accountId; + + /** + * The account of uc for sharing image + */ + private String ucAccount; + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getUcAccount() { + return ucAccount; + } + + public void setUcAccount(String ucAccount) { + this.ucAccount = ucAccount; + } + + @Override + public String toString() { + return "SharedUserModel{" + + "account='" + account + '\'' + + ", accountId='" + accountId + '\'' + + ", ucAccount='" + ucAccount + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/SnapshotModel.java b/src/main/java/com/baidubce/services/bcc/model/SnapshotModel.java new file mode 100644 index 00000000..cf728e00 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/SnapshotModel.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Date; + +/** + * The detail model of the snapshot. + */ +public class SnapshotModel { + + /** + * The id of the snapshot. + */ + private String id; + + /** + * The name of the snapshot. + */ + private String name; + + /** + * The size of the snapshot in GB + */ + private int sizeInGB; + + /** + * The time when the snapshot was created. + */ + private Date createTime; + + /** + * The status of the snapshot. + * see more detail on BCE API doc + */ + private String status; + + /** + * The method to describe how the snapshot was created, available values are "MANUAL/MIGRATION/auto". + * When the snapshot was created manually,the createMethod will be "MANUAL"; + * When the snapshot was migrated from other,the createMethod will be "MIGRATION"; + * When the snapshot was created by time schedule task,the createMethod will be "auto"; + */ + private String createMethod; + + /** + * The id of the volume. + */ + private String volumeId; + + /** + * The description of the snapshot. + */ + private String desc; + + /** + * The time when the snapshot will be expired. + */ + private Date expireTime; + + /** + * The snapId of the instance. + */ + private String insnapId; + + /** + * Whether the image is big or not. The default value is false. If true, it means it is the big image. + */ + @JsonProperty("package") + private boolean packaged; + + /** + * The id of image which is defined by user. + */ + @JsonProperty("templateId") + private String imageId; + + /** + * Whether the snapshot is encrypted. + */ + private boolean encrypted; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getSizeInGB() { + return sizeInGB; + } + + public void setSizeInGB(int sizeInGB) { + this.sizeInGB = sizeInGB; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateMethod() { + return createMethod; + } + + public void setCreateMethod(String createMethod) { + this.createMethod = createMethod; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public Date getExpireTime() { + return expireTime; + } + + public void setExpireTime(Date expireTime) { + this.expireTime = expireTime; + } + + public String getInsnapId() { + return insnapId; + } + + public void setInsnapId(String insnapId) { + this.insnapId = insnapId; + } + + public boolean isPackaged() { + return packaged; + } + + public void setPackaged(boolean packaged) { + this.packaged = packaged; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public boolean isEncrypted() { + return encrypted; + } + + public void setEncrypted(boolean encrypted) { + this.encrypted = encrypted; + } + + @Override + public String toString() { + return "SnapshotModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", sizeInGB=" + sizeInGB + + ", createTime='" + createTime + '\'' + + ", status='" + status + '\'' + + ", createMethod='" + createMethod + '\'' + + ", volumeId='" + volumeId + '\'' + + ", desc='" + desc + '\'' + + ", expireTime='" + expireTime + '\'' + + ", insnapId='" + insnapId + '\'' + + ", package='" + packaged + '\'' + + ", templateId='" + imageId + '\'' + + ", encrypted='" + encrypted + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/StorageType.java b/src/main/java/com/baidubce/services/bcc/model/StorageType.java new file mode 100644 index 00000000..13d4f8ed --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/StorageType.java @@ -0,0 +1,21 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +public enum StorageType { + std1, + hp1, + cloud_hp1, + hdd, + local, + sata, + ssd +} diff --git a/src/main/java/com/baidubce/services/bcc/model/TagModel.java b/src/main/java/com/baidubce/services/bcc/model/TagModel.java new file mode 100644 index 00000000..e7cc20ff --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/TagModel.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * The detail model of the tag. + */ +public class TagModel { + + /** + * The key of tag. + */ + private String tagKey ; + + /** + * The value of tag. + */ + private String tagValue; + + public String getTagKey() { + return tagKey; + } + + public void setTagKey(String tagKey) { + this.tagKey = tagKey; + } + + /** + * Configure tagKey for the model. + * + * @param tagKey The key of tag. + * @return TagModel with tagKey. + */ + public TagModel withTagKey(String tagKey) { + this.tagKey = tagKey; + return this; + } + + public String getTagValue() { + return tagValue; + } + + public void setTagValue(String tagValue) { + this.tagValue = tagValue; + } + + /** + * Configure tagValue for the model. + * + * @param tagValue The value of tag. + * @return TagModel with tagValue. + */ + public TagModel withTagValue(String tagValue) { + this.tagValue = tagValue; + return this; + } + + @Override + public String toString() { + return "TagModel{" + + ", tagKey='" + tagKey + '\'' + + ", tagValue='" + tagValue + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/TagsOperationRequest.java b/src/main/java/com/baidubce/services/bcc/model/TagsOperationRequest.java new file mode 100644 index 00000000..56bb1258 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/TagsOperationRequest.java @@ -0,0 +1,35 @@ +package com.baidubce.services.bcc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import java.util.List; +import lombok.Data; + +@Data +public class TagsOperationRequest extends AbstractBceRequest { + /** + * 操作资源类型:bcc/cds/image/snapshot/snapshotchain/bccri + */ + private String resourceType; + + /** + * 资源ID列表 + */ + + private List resourceIds; + + + /** + * 待绑定标签列表 + */ + private List tags; + /** + * 关联资源绑定标签 + */ + private Boolean isRelationTag = false; + @Override + public TagsOperationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/Volume.java b/src/main/java/com/baidubce/services/bcc/model/Volume.java new file mode 100644 index 00000000..e21ff460 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/Volume.java @@ -0,0 +1,10 @@ +package com.baidubce.services.bcc.model; + +import lombok.Data; + +@Data +public class Volume { + private Boolean isSystemVolume; + private Integer diskSizeInGB; + private String volumeId; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/VolumeAttachmentModel.java b/src/main/java/com/baidubce/services/bcc/model/VolumeAttachmentModel.java new file mode 100644 index 00000000..f3ff6d83 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/VolumeAttachmentModel.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * volume attach info model which describes where the volume will attach to. + */ +public class VolumeAttachmentModel { + + /** + * The id of volume + */ + private String volumeId; + + /** + * The id of instance. + */ + private String instanceId; + + /** + * The mounting path where the volume attached to the instance. + */ + private String device; + + /** + * The serial number of Volume. + */ + private String serial; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getDevice() { + return device; + } + + public void setDevice(String device) { + this.device = device; + } + + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial = serial; + } + + @Override + public String toString() { + return "VolumeAttachmentModel{" + + "volumeId='" + volumeId + '\'' + + ", instanceId='" + instanceId + '\'' + + ", device='" + device + '\'' + + ", serial='" + serial + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/VolumeClusterModel.java b/src/main/java/com/baidubce/services/bcc/model/VolumeClusterModel.java new file mode 100644 index 00000000..b8ca5992 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/VolumeClusterModel.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +/** + * volume detail info model + */ +public class VolumeClusterModel { + + /** + * The id of the cluster + */ + private String clusterId; + + /** + * The name of the cluster + */ + private String clusterName; + + /** + * The payment method of purchasing the volume, + * see more detail in BCE API doc + */ + private String productType; + + /** + * The time when the cluster was created. + */ + private String createdTime; + + /** + * The time when the cluster will be expired. + */ + private String expiredTime; + + /** + * The status of the volume, + * see more detail on BCE API doc + */ + private String status; + + private String clusterType; + + /** + * the name of available zone + */ + private String logicalZone; + + private int totalCapacity; + + private int usedCapacity; + + private int availableCapacity; + + private int expandingCapacity; + + private int createdVolumeNum; + + private Boolean enableAutoRenew = false; + + private String renewTimeUnit; + + private Integer renewTime; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + this.productType = productType; + } + + public String getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + public String getExpiredTime() { + return expiredTime; + } + + public void setExpiredTime(String expiredTime) { + this.expiredTime = expiredTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getClusterType() { + return clusterType; + } + + public void setClusterType(String clusterType) { + this.clusterType = clusterType; + } + + public String getLogicalZone() { + return logicalZone; + } + + public void setLogicalZone(String logicalZone) { + this.logicalZone = logicalZone; + } + + public int getTotalCapacity() { + return totalCapacity; + } + + public void setTotalCapacity(int totalCapacity) { + this.totalCapacity = totalCapacity; + } + + public int getUsedCapacity() { + return usedCapacity; + } + + public void setUsedCapacity(int usedCapacity) { + this.usedCapacity = usedCapacity; + } + + public int getAvailableCapacity() { + return availableCapacity; + } + + public void setAvailableCapacity(int availableCapacity) { + this.availableCapacity = availableCapacity; + } + + public int getExpandingCapacity() { + return expandingCapacity; + } + + public void setExpandingCapacity(int expandingCapacity) { + this.expandingCapacity = expandingCapacity; + } + + public int getCreatedVolumeNum() { + return createdVolumeNum; + } + + public void setCreatedVolumeNum(int createdVolumeNum) { + this.createdVolumeNum = createdVolumeNum; + } + + public Boolean getEnableAutoRenew() { + return enableAutoRenew; + } + + public void setEnableAutoRenew(Boolean enableAutoRenew) { + this.enableAutoRenew = enableAutoRenew; + } + + public String getRenewTimeUnit() { + return renewTimeUnit; + } + + public void setRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + } + + public Integer getRenewTime() { + return renewTime; + } + + public void setRenewTime(Integer renewTime) { + this.renewTime = renewTime; + } + + @Override + public String toString() { + return "VolumeClusterModel{" + + "clusterId='" + clusterId + '\'' + + ", clusterName='" + clusterName + '\'' + + ", productType='" + productType + '\'' + + ", createdTime='" + createdTime + '\'' + + ", expiredTime='" + expiredTime + '\'' + + ", status='" + status + '\'' + + ", clusterType='" + clusterType + '\'' + + ", logicalZone='" + logicalZone + '\'' + + ", totalCapacity=" + totalCapacity + + ", usedCapacity=" + usedCapacity + + ", availableCapacity=" + availableCapacity + + ", expandingCapacity=" + expandingCapacity + + ", createdVolumeNum=" + createdVolumeNum + + ", enableAutoRenew=" + enableAutoRenew + + ", renewTimeUnit='" + renewTimeUnit + '\'' + + ", renewTime=" + renewTime + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/VolumeModel.java b/src/main/java/com/baidubce/services/bcc/model/VolumeModel.java new file mode 100644 index 00000000..86a02d59 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/VolumeModel.java @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +import java.util.Date; +import java.util.List; + +/** + * volume detail info model + */ +public class VolumeModel { + + /** + * The id of the volume + */ + private String id; + + /** + * The name of the volume + */ + private String name; + + /** + * The total size of the volume in GB. + */ + private int diskSizeInGB; + + /** + * The payment method of purchasing the volume, + * see more detail in BCE API doc + */ + private String paymentTiming; + + /** + * The time when the volume was created. + */ + private Date createTime; + + /** + * The time when the volume will be expired. + * If it's Postpaid, it will not have expired time. + */ + private Date expireTime; + + /** + * The status of the volume, + * see more detail on BCE API doc + */ + private String status; + + /** + * The type to describe the volume . + * see more detail on BCE API doc + */ + private String type; + + /** + * The storage type of volume, see more detail in + * BCE API doc + */ + private String storageType; + + /** + * The description of the volume. + */ + private String desc; + + /** + * The list of detail info to describe where the volume will attach to. + * If the volume has not been mounted, it will be null. + */ + private List attachments; + + /** + * the name of available zone + */ + private String zoneName; + + /** + * The id of region + */ + private String regionId; + + /** + * The count of snapshots on the disk + */ + private String snapshotNum; + + /** + * The snapshotId for creating the volume + */ + private String sourceSnapshotId; + + /** + * The snapshotPolicy of the volume + */ + private AutoSnapshotPolicyModel autoSnapshotPolicy; + + /** + * The list of bonded tags. + */ + private List tags; + + /** + * Whether to encrypt + */ + private boolean encrypted; + + /** + * The id of dedicated. + * If it is not empty, this volume belongs to a dedicated cluster + */ + private String clusterId; + + /* + * whether enable auto-renew + */ + private boolean enableAutoRenew; + + /* + * time for auto-renew + */ + private int autoRenewTime; + + /* + * mark for system volume + */ + private boolean isSystemVolume; + + /** + * the name of ebc disk size + */ + private int ebcDiskSize; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getDiskSizeInGB() { + return diskSizeInGB; + } + + public void setDiskSizeInGB(int diskSizeInGB) { + this.diskSizeInGB = diskSizeInGB; + } + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getExpireTime() { + return expireTime; + } + + public void setExpireTime(Date expireTime) { + this.expireTime = expireTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getStorageType() { + return storageType; + } + + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public List getAttachments() { + return attachments; + } + + public void setAttachments(List attachments) { + this.attachments = attachments; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getRegionId() { + return regionId; + } + + public void setRegionId(String regionId) { + this.regionId = regionId; + } + + public String getSnapshotNum() { + return snapshotNum; + } + + public void setSnapshotNum(String snapshotNum) { + this.snapshotNum = snapshotNum; + } + + public String getSourceSnapshotId() { + return sourceSnapshotId; + } + + public void setSourceSnapshotId(String sourceSnapshotId) { + this.sourceSnapshotId = sourceSnapshotId; + } + + public AutoSnapshotPolicyModel getAutoSnapshotPolicy() { + return autoSnapshotPolicy; + } + + public void setAutoSnapshotPolicy(AutoSnapshotPolicyModel autoSnapshotPolicy) { + this.autoSnapshotPolicy = autoSnapshotPolicy; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public boolean isEncrypted() { + return encrypted; + } + + public void setEncrypted(boolean encrypted) { + this.encrypted = encrypted; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public void setEnableAutoRenew(boolean enableAutoRenew) { + this.enableAutoRenew = enableAutoRenew; + } + + public boolean isEnableAutoRenew() { + return enableAutoRenew; + } + + public void setAutoRenewTime(int autoRenewTime) { + this.autoRenewTime = autoRenewTime; + } + + public int getAutoRenewTime() { + return autoRenewTime; + } + + public void setIsSystemVolume(boolean isSystemVolume) { + this.isSystemVolume = isSystemVolume; + } + + public boolean getIsSystemVolume() { + return isSystemVolume; + } + + public int getEbcDiskSize() { + return ebcDiskSize; + } + + public void setEbcDiskSize(int ebcDiskSize) { + this.ebcDiskSize = ebcDiskSize; + } + + @Override + public String toString() { + return "VolumeModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", diskSizeInGB=" + diskSizeInGB + + ", paymentTiming='" + paymentTiming + '\'' + + ", createTime='" + createTime + '\'' + + ", expireTime='" + expireTime + '\'' + + ", status=" + status + + ", type=" + type + + ", storageType=" + storageType + + ", desc='" + desc + '\'' + + ", attachments=" + attachments + + ", zoneName='" + zoneName + '\'' + + ", regionId='" + regionId + '\'' + + ", snapshotNum='" + snapshotNum + '\'' + + ", sourceSnapshotId='" + sourceSnapshotId + '\'' + + ", autoSnapshotPolicy=" + autoSnapshotPolicy + + ", tags=" + tags + + ", encrypted=" + encrypted + + ", clusterId=" + clusterId + + ", enableAutoRenew=" + enableAutoRenew + + ", autoRenewTime=" + autoRenewTime + + ", isSystemVolume=" + isSystemVolume + + ", ebcDiskSize=" + ebcDiskSize + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/VpcInfo.java b/src/main/java/com/baidubce/services/bcc/model/VpcInfo.java new file mode 100644 index 00000000..1e73bb4e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/VpcInfo.java @@ -0,0 +1,48 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model; + +public class VpcInfo { + + /** + * The id specified in VPC. + */ + private String vpcId; + + /** + * The name of VPC. + */ + private String vpcName; + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getVpcName() { + return vpcName; + } + + public void setVpcName(String vpcName) { + this.vpcName = vpcName; + } + + @Override + public String toString() { + return "VpcInfo{" + + "vpcId='" + vpcId + '\'' + + ", vpcName='" + vpcName + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/AspAction.java b/src/main/java/com/baidubce/services/bcc/model/asp/AspAction.java new file mode 100644 index 00000000..6b4332a6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/AspAction.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +/** + * The action for operating the asp. + */ +public enum AspAction { + /** + * The action to attach the asp. + */ + attach, + + /** + * The action to detach the asp. + */ + detach, + + /** + * The action to update the asp. + */ + update +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/AttachAspRequest.java b/src/main/java/com/baidubce/services/bcc/model/asp/AttachAspRequest.java new file mode 100644 index 00000000..76e54603 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/AttachAspRequest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * The request for attaching autoSnapshotPolicy. + */ +public class AttachAspRequest extends AbstractBceRequest { + /** + * The id of asp to attach. + */ + private String aspId; + + /** + * ids of volumes which will be attached. + */ + private List volumeIds; + + public String getAspId() { + return aspId; + } + + public void setAspId(String aspId) { + this.aspId = aspId; + } + + public List getVolumeIds() { + return volumeIds; + } + + public void setVolumeIds(List volumeIds) { + this.volumeIds = volumeIds; + } + + public AttachAspRequest withAspId(String aspId) { + this.aspId = aspId; + return this; + } + + public AttachAspRequest withVolumeIds(List volumeIds) { + this.volumeIds = volumeIds; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return AttachAspRequest with credentials. + */ + @Override + public AttachAspRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/CreateAspRequest.java b/src/main/java/com/baidubce/services/bcc/model/asp/CreateAspRequest.java new file mode 100644 index 00000000..81fdac5e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/CreateAspRequest.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for creating new autoSnapshotPolicy. + */ +public class CreateAspRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * name of the asp + */ + private String name; + + /** + * Specifies the time point of creating an automatic snapshot . + * The smallest unit is the hour. + * There are 24 time points from 00:00 to 23:00. + * The number of parameters is 0 to 23. + * For example, 1 represents the time point at 01:00. + * Multiple time points can be selected. + * The parameter is a Json Array:[0, 1,... 23], at most 24 time points. + */ + private List timePoints; + + /** + * Specify a duplicate date for the automatic snapshot. + * Choose the date from Monday to Sunday when you need to create snapshots, + * with a number of parameters ranging from 1 to 7, + * such as: 1 for Monday. Multiple dates are allowed. + * The parameter is a Json Array:[1, 2... 7]. + */ + private List repeatWeekdays; + + /** + * Specify the retention time of the automatic snapshot in days. + * -1: Permanent preservation . + * 1-65536: specified number of days. + */ + private String retentionDays; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getTimePoints() { + return timePoints; + } + + public void setTimePoints(List timePoints) { + this.timePoints = timePoints; + } + + public List getRepeatWeekdays() { + return repeatWeekdays; + } + + public void setRepeatWeekdays(List repeatWeekdays) { + this.repeatWeekdays = repeatWeekdays; + } + + public String getRetentionDays() { + return retentionDays; + } + + public void setRetentionDays(String retentionDays) { + this.retentionDays = retentionDays; + } + + public CreateAspRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public CreateAspRequest withName(String name) { + this.name = name; + return this; + } + + public CreateAspRequest withTimePoints(List timePoints) { + this.timePoints = timePoints; + return this; + } + + public CreateAspRequest withRepeatWeekdays(List repeatWeekdays) { + this.repeatWeekdays = repeatWeekdays; + return this; + } + + public CreateAspRequest withRetentionDays(String retentionDays) { + this.retentionDays = retentionDays; + return this; + } + + @Override + public CreateAspRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/CreateAspResponse.java b/src/main/java/com/baidubce/services/bcc/model/asp/CreateAspResponse.java new file mode 100644 index 00000000..2be42403 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/CreateAspResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for CreateAspRequest. + */ +public class CreateAspResponse extends AbstractBceResponse { + /** + * The id of asp. + */ + private String aspId; + + public String getAspId() { + return aspId; + } + + public void setAspId(String aspId) { + this.aspId = aspId; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/DeleteAspRequest.java b/src/main/java/com/baidubce/services/bcc/model/asp/DeleteAspRequest.java new file mode 100644 index 00000000..613b00e3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/DeleteAspRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for deleting autoSnapshotPolicy. + */ +public class DeleteAspRequest extends AbstractBceRequest { + /** + * The id of asp. + */ + private String aspId; + + public String getAspId() { + return aspId; + } + + public void setAspId(String aspId) { + this.aspId = aspId; + } + + /** + * Configure aspId for the request. + * + * @param aspId The id of asp that will be deleted. + * @return DeleteAspRequest with aspId. + */ + public DeleteAspRequest withAspId(String aspId) { + this.aspId = aspId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteAspRequest with credentials. + */ + @Override + public DeleteAspRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/DetachAspRequest.java b/src/main/java/com/baidubce/services/bcc/model/asp/DetachAspRequest.java new file mode 100644 index 00000000..cbe2f188 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/DetachAspRequest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * The request for detaching autoSnapshotPolicy. + */ +public class DetachAspRequest extends AbstractBceRequest { + /** + * The id of asp to detach. + */ + private String aspId; + + /** + * ids of volumes which will be detach. + */ + private List volumeIds; + + public String getAspId() { + return aspId; + } + + public void setAspId(String aspId) { + this.aspId = aspId; + } + + public List getVolumeIds() { + return volumeIds; + } + + public void setVolumeIds(List volumeIds) { + this.volumeIds = volumeIds; + } + + public DetachAspRequest withAspId(String aspId) { + this.aspId = aspId; + return this; + } + + public DetachAspRequest withVolumeIds(List volumeIds) { + this.volumeIds = volumeIds; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return AttachAspRequest with credentials. + */ + @Override + public DetachAspRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/GetAspRequest.java b/src/main/java/com/baidubce/services/bcc/model/asp/GetAspRequest.java new file mode 100644 index 00000000..7f413c97 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/GetAspRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting detail of the autoSnapshotPolicy. + */ +public class GetAspRequest extends AbstractBceRequest { + /** + * The id of asp. + */ + private String aspId; + + public String getAspId() { + return aspId; + } + + public void setAspId(String aspId) { + this.aspId = aspId; + } + + /** + * Configure aspId for the request. + * + * @param aspId The id of asp. + * @return GetAspRequest with aspId. + */ + public GetAspRequest withAspId(String aspId) { + this.aspId = aspId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetSnapshotRequest with credentials. + */ + @Override + public GetAspRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/GetAspResponse.java b/src/main/java/com/baidubce/services/bcc/model/asp/GetAspResponse.java new file mode 100644 index 00000000..99d3d9a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/GetAspResponse.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.AutoSnapshotPolicyModel; + +/** + * The response for GetAspRequest. + */ +public class GetAspResponse extends AbstractBceResponse { + /** + * model of asp + */ + private AutoSnapshotPolicyModel autoSnapshotPolicy; + + public AutoSnapshotPolicyModel getAutoSnapshotPolicy() { + return autoSnapshotPolicy; + } + + public void setAutoSnapshotPolicy(AutoSnapshotPolicyModel autoSnapshotPolicy) { + this.autoSnapshotPolicy = autoSnapshotPolicy; + } + + @Override + public String toString() { + return "GetAspResponse{" + + "autoSnapshotPolicy=" + autoSnapshotPolicy + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/ListAspsRequest.java b/src/main/java/com/baidubce/services/bcc/model/asp/ListAspsRequest.java new file mode 100644 index 00000000..ec12d3c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/ListAspsRequest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for listing autoSnapshotPolicies. + */ +public class ListAspsRequest extends ListRequest { + /** + * The optional parameter to filter asp to list + */ + private String aspName; + + /** + * The optional parameter to filter asp to list + */ + private String volumeName; + + public String getAspName() { + return aspName; + } + + public void setAspName(String aspName) { + this.aspName = aspName; + } + + public String getVolumeName() { + return volumeName; + } + + public void setVolumeName(String volumeName) { + this.volumeName = volumeName; + } + + /** + * Configure the request with specified aspName. + * + * @param aspName The optional parameter to filter asp to list + * @return ListAspsRequest with specified aspName. + */ + public ListAspsRequest withAspName(String aspName) { + this.aspName = aspName; + return this; + } + + /** + * Configure the request with specified aspName. + * + * @param volumeName The optional parameter to filter asp to list + * @return ListAspsRequest with specified volumeName. + */ + public ListAspsRequest withVolumeName(String volumeName) { + this.volumeName = volumeName; + return this; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListAspsRequest with specified marker. + */ + @Override + public ListAspsRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListAspsRequest with specified maxKeys. + */ + @Override + public ListAspsRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListAspsRequest with credentials. + */ + @Override + public ListAspsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/ListAspsResponse.java b/src/main/java/com/baidubce/services/bcc/model/asp/ListAspsResponse.java new file mode 100644 index 00000000..43836f29 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/ListAspsResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.model.ListResponse; +import com.baidubce.services.bcc.model.AutoSnapshotPolicyModel; + +import java.util.List; + +/** + * The response for ListAspsRequest. + */ +public class ListAspsResponse extends ListResponse { + /** + * List of asps detail model. + */ + private List autoSnapshotPolicys; + + public List getAutoSnapshotPolicys() { + return autoSnapshotPolicys; + } + + public void setAutoSnapshotPolicys(List autoSnapshotPolicys) { + this.autoSnapshotPolicys = autoSnapshotPolicys; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/asp/UpdateAspRequest.java b/src/main/java/com/baidubce/services/bcc/model/asp/UpdateAspRequest.java new file mode 100644 index 00000000..d13608be --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/asp/UpdateAspRequest.java @@ -0,0 +1,135 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.asp; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for updating autoSnapshotPolicy. + */ +public class UpdateAspRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * name of the asp + */ + private String name; + + /** + * Specifies the time point of creating an automatic snapshot . + * The smallest unit is the hour. + * There are 24 time points from 00:00 to 23:00. + * The number of parameters is 0 to 23. + * For example, "1" represents the time point at 01:00. + * Multiple time points can be selected. + * The parameter is a Json Array:["0", "1",... "23"], at most 24 time points. + */ + private List timePoints; + + /** + * Specify a duplicate date for the automatic snapshot. + * Choose the date from Monday to Sunday when you need to create snapshots, + * with a number of parameters ranging from 1 to 7, + * such as: "1" for Monday. Multiple dates are allowed. + * The parameter is a Json Array:["1", "2"... "7"]. + */ + private List repeatWeekdays; + + /** + * Specify the retention time of the automatic snapshot in days. + * -1: Permanent preservation . + * 1-65536: specified number of days. + */ + private String retentionDays; + + /** + * The id of asp. + */ + private String aspId; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getTimePoints() { + return timePoints; + } + + public void setTimePoints(List timePoints) { + this.timePoints = timePoints; + } + + public List getRepeatWeekdays() { + return repeatWeekdays; + } + + public void setRepeatWeekdays(List repeatWeekdays) { + this.repeatWeekdays = repeatWeekdays; + } + + public String getRetentionDays() { + return retentionDays; + } + + public void setRetentionDays(String retentionDays) { + this.retentionDays = retentionDays; + } + + public String getAspId() { + return aspId; + } + + public void setAspId(String aspId) { + this.aspId = aspId; + } + + @Override + public String toString() { + return "UpdateAspRequest{" + + "clientToken='" + clientToken + '\'' + + ", name='" + name + '\'' + + ", timePoints=" + timePoints + + ", repeatWeekdays=" + repeatWeekdays + + ", retentionDays='" + retentionDays + '\'' + + '}'; + } + + @Override + public UpdateAspRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/deployset/AzInstanceStatis.java b/src/main/java/com/baidubce/services/bcc/model/deployset/AzInstanceStatis.java new file mode 100644 index 00000000..70c7d721 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/deployset/AzInstanceStatis.java @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.deployset; + +/** + * The response for getting the deploy set list. + */ +public class AzInstanceStatis { + + private int instanceCount; + + private int instanceTotal; + + private String zoneName; + + public int getInstanceCount() { + return instanceCount; + } + + public void setInstanceCount(int instanceCount) { + this.instanceCount = instanceCount; + } + + public int getInstanceTotal() { + return instanceTotal; + } + + public void setInstanceTotal(int instanceTotal) { + this.instanceTotal = instanceTotal; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + @Override + public String toString() { + return "AzInstanceStatis{" + + "instanceCount=" + instanceCount + + ", instanceTotal=" + instanceTotal + + ", zoneName='" + zoneName + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/deployset/CreateDeploySetRequest.java b/src/main/java/com/baidubce/services/bcc/model/deployset/CreateDeploySetRequest.java new file mode 100644 index 00000000..2f25b98f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/deployset/CreateDeploySetRequest.java @@ -0,0 +1,110 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for creating the deploy set. + */ +public class CreateDeploySetRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Deploy set name. + */ + private String name; + + /** + * Deploy set description. include HOST_HA, RACK_HA, TOR_HA + */ + private String desc; + + /** + * Deploy set strategy. + */ + private String strategy; + + /** + * num of instances can be created in one location + * definition of location: for HOST_HA is host, for RACK_HA is rack, for TOR_HA is tor + */ + private int concurrency = 1; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getStrategy() { + return strategy; + } + + public void setStrategy(String strategy) { + this.strategy = strategy; + } + + public int getConcurrency() { + return concurrency; + } + + public void setConcurrency(int concurrency) { + this.concurrency = concurrency; + } + + @Override + public String toString() { + return "CreateDeploySetRequest{" + + "clientToken='" + clientToken + '\'' + + ", name='" + name + '\'' + + ", desc='" + desc + '\'' + + ", strategy='" + strategy + '\'' + + ", concurrency='" + concurrency + '\'' + + '}'; + } + + @Override + public CreateDeploySetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/deployset/CreateDeploySetResponse.java b/src/main/java/com/baidubce/services/bcc/model/deployset/CreateDeploySetResponse.java new file mode 100644 index 00000000..f099959b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/deployset/CreateDeploySetResponse.java @@ -0,0 +1,41 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.deployset; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response of creating deploy set. + */ +public class CreateDeploySetResponse extends AbstractBceResponse { + + /** + * The list of deploy set + */ + private List deploySetIds; + + public List getDeploySetIds() { + return deploySetIds; + } + + public void setDeploySetIds(List deploySetIds) { + this.deploySetIds = deploySetIds; + } + + @Override + public String toString() { + return "CreateDeploySetResponse{" + + "deploySetIds=" + deploySetIds + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/deployset/DeleteDeploySetRequest.java b/src/main/java/com/baidubce/services/bcc/model/deployset/DeleteDeploySetRequest.java new file mode 100644 index 00000000..e5741758 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/deployset/DeleteDeploySetRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for deleting the deploy set. + */ +public class DeleteDeploySetRequest extends AbstractBceRequest { + + /** + * The id of a specific deploy set. + */ + @JsonIgnore + private String deployId; + + public String getDeployId() { + return deployId; + } + + public void setDeployId(String deployId) { + this.deployId = deployId; + } + + @Override + public String toString() { + return "DeleteDeploySetRequest{" + + "deployId='" + deployId + '\'' + + '}'; + } + + @Override + public DeleteDeploySetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/deployset/DeploySetAction.java b/src/main/java/com/baidubce/services/bcc/model/deployset/DeploySetAction.java new file mode 100644 index 00000000..4cc90f96 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/deployset/DeploySetAction.java @@ -0,0 +1,31 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.deployset; + +/** + * The action for operating the deploy set. + */ +public enum DeploySetAction { + /** + * Query the user's deployment set list + */ + list, + + /** + * Create a deploy set + */ + create, + + /** + * Delete a deploy set with deployId + */ + modifyAttribute +} diff --git a/src/main/java/com/baidubce/services/bcc/model/deployset/DeploySetInfo.java b/src/main/java/com/baidubce/services/bcc/model/deployset/DeploySetInfo.java new file mode 100644 index 00000000..640fbdce --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/deployset/DeploySetInfo.java @@ -0,0 +1,91 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.deployset; + +import java.util.List; + +/** + * The information of the deploy set. + */ +public class DeploySetInfo { + + private String instanceCount; + + private String name; + + private String strategy; + + private String deploysetId; + + private String desc; + + private List azIntstanceStatisList; + + public String getInstanceCount() { + return instanceCount; + } + + public void setInstanceCount(String instanceCount) { + this.instanceCount = instanceCount; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStrategy() { + return strategy; + } + + public void setStrategy(String strategy) { + this.strategy = strategy; + } + + public String getDeploysetId() { + return deploysetId; + } + + public void setDeploysetId(String deploysetId) { + this.deploysetId = deploysetId; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public List getAzIntstanceStatisList() { + return azIntstanceStatisList; + } + + public void setAzIntstanceStatisList(List azIntstanceStatisList) { + this.azIntstanceStatisList = azIntstanceStatisList; + } + + @Override + public String toString() { + return "DeploySetInfo{" + + "instanceCount='" + instanceCount + '\'' + + ", name='" + name + '\'' + + ", strategy='" + strategy + '\'' + + ", deploysetId='" + deploysetId + '\'' + + ", desc='" + desc + '\'' + + ", azIntstanceStatisList=" + azIntstanceStatisList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/deployset/ListDeploySetResponse.java b/src/main/java/com/baidubce/services/bcc/model/deployset/ListDeploySetResponse.java new file mode 100644 index 00000000..ec3bbbdb --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/deployset/ListDeploySetResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.deployset; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response of the deploy set owned by the user. + */ +public class ListDeploySetResponse extends AbstractBceResponse { + + private List deploySets; + + public List getDeploySets() { + return deploySets; + } + + public void setDeploySets(List deploySets) { + this.deploySets = deploySets; + } + + @Override + public String toString() { + return "ListDeploySetResponse{" + + "deploySets=" + deploySets + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/deployset/UpdateDeploySetRequest.java b/src/main/java/com/baidubce/services/bcc/model/deployset/UpdateDeploySetRequest.java new file mode 100644 index 00000000..2c7a14c9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/deployset/UpdateDeploySetRequest.java @@ -0,0 +1,76 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for updating the deploy set. + */ +public class UpdateDeploySetRequest extends AbstractBceRequest { + + /** + * The id of a specific deploy set. + */ + @JsonIgnore + private String deployId; + + /** + * The name of a specific deploy set. + */ + private String name; + + /** + * The description of a specific deploy set. + */ + private String desc; + + public String getDeployId() { + return deployId; + } + + public void setDeployId(String deployId) { + this.deployId = deployId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + @Override + public String toString() { + return "UpdateDeploySetRequest{" + + "deployId='" + deployId + '\'' + + ", name='" + name + '\'' + + ", desc='" + desc + '\'' + + '}'; + } + + @Override + public UpdateDeploySetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/flavor/BccBidFlavor.java b/src/main/java/com/baidubce/services/bcc/model/flavor/BccBidFlavor.java new file mode 100644 index 00000000..0985bc33 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/flavor/BccBidFlavor.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.flavor; + +/** + * TThe information of the BCC bidding flavor. + */ +public class BccBidFlavor { + + private int cpuCount; + private int memoryCapacityInGB; + private String productType; + private String spec; + private String specId; + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + this.productType = productType; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public String getSpecId() { + return specId; + } + + public void setSpecId(String specId) { + this.specId = specId; + } + + @Override + public String toString() { + return "BccFlavor{" + + "cpuCount=" + cpuCount + + ", memoryCapacityInGB=" + memoryCapacityInGB + + ", productType='" + productType + '\'' + + ", spec='" + spec + '\'' + + ", specId='" + specId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/flavor/BccBidResources.java b/src/main/java/com/baidubce/services/bcc/model/flavor/BccBidResources.java new file mode 100644 index 00000000..62a48ed2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/flavor/BccBidResources.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.flavor; + +import java.util.ArrayList; +import java.util.List; + +/** + * The information of the BCC bidding instance resource. + */ +public class BccBidResources { + + /** + * The parameter to specified which kind of instance is return. + * see all of supported instance type in {@link com.baidubce.services.bcc.model.instance.InstanceType} + */ + private String instanceType; + + private List flavors = new ArrayList(); + + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public List getFlavors() { + return flavors; + } + + public void setFlavors(List flavors) { + this.flavors = flavors; + } + + @Override + public String toString() { + return "BccResources{" + + "instanceType='" + instanceType + "\'" + + "flavors=" + flavors + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/flavor/BccFlavor.java b/src/main/java/com/baidubce/services/bcc/model/flavor/BccFlavor.java new file mode 100644 index 00000000..1788e751 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/flavor/BccFlavor.java @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.flavor; + +public class BccFlavor { + + private int cpuCount; + private int memoryCapacityInGB; + private Integer ephemeralDiskInGb; + private Integer ephemeralDiskCount = 1; + private String ephemeralDiskType; + private String gpuCardType; + private Integer gpuCardCount; + private String fpgaCardType; + private Integer fpgaCardCount; + private String productType; + private String spec; + private String specId; + + private String flavorSubType; + private String cpuModel; + private String cpuGHz; + private String networkBandwidth; + private String networkPackage; + + private Integer netEthQueueCount; + + private Boolean enableJumboFrame; + + private Integer netEthMaxQueueCount; + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + public Integer getEphemeralDiskInGb() { + return ephemeralDiskInGb; + } + + public void setEphemeralDiskInGb(Integer ephemeralDiskInGb) { + this.ephemeralDiskInGb = ephemeralDiskInGb; + } + + public Integer getEphemeralDiskCount() { + return ephemeralDiskCount; + } + + public void setEphemeralDiskCount(Integer ephemeralDiskCount) { + this.ephemeralDiskCount = ephemeralDiskCount; + } + + public String getEphemeralDiskType() { + return ephemeralDiskType; + } + + public void setEphemeralDiskType(String ephemeralDiskType) { + this.ephemeralDiskType = ephemeralDiskType; + } + + public String getGpuCardType() { + return gpuCardType; + } + + public void setGpuCardType(String gpuCardType) { + this.gpuCardType = gpuCardType; + } + + public Integer getGpuCardCount() { + return gpuCardCount; + } + + public void setGpuCardCount(Integer gpuCardCount) { + this.gpuCardCount = gpuCardCount; + } + + public String getFpgaCardType() { + return fpgaCardType; + } + + public void setFpgaCardType(String fpgaCardType) { + this.fpgaCardType = fpgaCardType; + } + + public Integer getFpgaCardCount() { + return fpgaCardCount; + } + + public void setFpgaCardCount(Integer fpgaCardCount) { + this.fpgaCardCount = fpgaCardCount; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + this.productType = productType; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public String getSpecId() { + return specId; + } + + public void setSpecId(String specId) { + this.specId = specId; + } + + public String getCpuModel() { + return cpuModel; + } + + public void setCpuModel(String cpuModel) { + this.cpuModel = cpuModel; + } + + public String getCpuGHz() { + return cpuGHz; + } + + public void setCpuGHz(String cpuGHz) { + this.cpuGHz = cpuGHz; + } + + public String getNetworkBandwidth() { + return networkBandwidth; + } + + public void setNetworkBandwidth(String networkBandwidth) { + this.networkBandwidth = networkBandwidth; + } + + public String getNetworkPackage() { + return networkPackage; + } + + public void setNetworkPackage(String networkPackage) { + this.networkPackage = networkPackage; + } + + public Integer getNetEthQueueCount() { + return netEthQueueCount; + } + + public void setNetEthQueueCount(Integer netEthQueueCount) { + this.netEthQueueCount = netEthQueueCount; + } + + public Integer getNetEthMaxQueueCount() { + return netEthMaxQueueCount; + } + + public void setNetEthMaxQueueCount(Integer netEthMaxQueueCount) { + this.netEthMaxQueueCount = netEthMaxQueueCount; + } + + public Boolean getEnableJumboFrame() { + return enableJumboFrame; + } + + public void setEnableJumboFrame(Boolean enableJumboFrame) { + this.enableJumboFrame = enableJumboFrame; + } + + public String getFlavorSubType() { + return flavorSubType; + } + + public void setFlavorSubType(String flavorSubType) { + this.flavorSubType = flavorSubType; + } + + @Override + public String toString() { + return "BccFlavor{" + + "cpuCount=" + cpuCount + + ", memoryCapacityInGB=" + memoryCapacityInGB + + ", ephemeralDiskInGb=" + ephemeralDiskInGb + + ", ephemeralDiskCount=" + ephemeralDiskCount + + ", ephemeralDiskType='" + ephemeralDiskType + '\'' + + ", gpuCardType='" + gpuCardType + '\'' + + ", gpuCardCount=" + gpuCardCount + + ", fpgaCardType='" + fpgaCardType + '\'' + + ", fpgaCardCount=" + fpgaCardCount + + ", productType='" + productType + '\'' + + ", spec='" + spec + '\'' + + ", specId='" + specId + '\'' + + ", cpuModel='" + cpuModel + '\'' + + ", cpuGHz='" + cpuGHz + '\'' + + ", networkBandwidth='" + networkBandwidth + '\'' + + ", networkPackage='" + networkPackage + '\'' + + ", netEthQueueCount=" + netEthQueueCount + + ", netEthMaxQueueCount=" + netEthMaxQueueCount + + ", flavorSubType=" + flavorSubType + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/flavor/BccResources.java b/src/main/java/com/baidubce/services/bcc/model/flavor/BccResources.java new file mode 100644 index 00000000..0c5e55ac --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/flavor/BccResources.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.flavor; + +import java.util.ArrayList; +import java.util.List; + +public class BccResources { + + private List flavorGroups; + + public List getFlavorGroups() { + return flavorGroups; + } + + public void setFlavorGroups(List flavorGroups) { + this.flavorGroups = flavorGroups; + } + + @Override + public String toString() { + return "BccResources{" + + "flavorGroups=" + flavorGroups + + '}'; + } + + public static class FlavorGroup { + + private String groupId; + private List flavors = new ArrayList(); + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public List getFlavors() { + return flavors; + } + + public void setFlavors(List flavors) { + this.flavors = flavors; + } + + @Override + public String toString() { + return "FlavorGroup{" + + "groupId='" + groupId + '\'' + + ", flavors=" + flavors + + '}'; + } + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/flavor/ListBccBidFlavorResponse.java b/src/main/java/com/baidubce/services/bcc/model/flavor/ListBccBidFlavorResponse.java new file mode 100644 index 00000000..5f7b45e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/flavor/ListBccBidFlavorResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.flavor; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response of getting the bcc bidding flavor list. + */ +public class ListBccBidFlavorResponse extends ListResponse { + private List zoneResources; + + public List getZoneResources() { + return zoneResources; + } + + public void setZoneResources(List zoneResources) { + this.zoneResources = zoneResources; + } + + @Override + public String toString() { + return "ListBccBidFlavorResponse{" + + "zoneResources=" + zoneResources + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/flavor/ListBccFlavorSpecResponse.java b/src/main/java/com/baidubce/services/bcc/model/flavor/ListBccFlavorSpecResponse.java new file mode 100644 index 00000000..0f7755ea --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/flavor/ListBccFlavorSpecResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.flavor; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +public class ListBccFlavorSpecResponse extends ListResponse { + + private List zoneResources; + + public List getZoneResources() { + return zoneResources; + } + + public void setZoneResources(List zoneResources) { + this.zoneResources = zoneResources; + } + + @Override + public String toString() { + return "ListBccFlavorSpecResponse{" + + "zoneResources=" + zoneResources + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/flavor/ListFlavorSpecRequest.java b/src/main/java/com/baidubce/services/bcc/model/flavor/ListFlavorSpecRequest.java new file mode 100644 index 00000000..8790f967 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/flavor/ListFlavorSpecRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.flavor; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * request model to query flavor list + */ +public class ListFlavorSpecRequest extends AbstractBceRequest { + + /** + * the name of available zone + */ + private String zoneName; + + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public ListFlavorSpecRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + return null; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/flavor/ZoneResource.java b/src/main/java/com/baidubce/services/bcc/model/flavor/ZoneResource.java new file mode 100644 index 00000000..717bc1af --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/flavor/ZoneResource.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.flavor; + +import java.util.List; + +/** + * The information of the zone resource. + */ +public class ZoneResource { + private String zoneName; + + private List bccResources; + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public List getBccResources() { + return bccResources; + } + + public void setBccResources(List bccResources) { + this.bccResources = bccResources; + } + + @Override + public String toString() { + return "ZoneResource{" + + "zoneName='" + zoneName + "\'" + + ", bccResources=" + bccResources + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/flavor/ZoneResourceDetailSpec.java b/src/main/java/com/baidubce/services/bcc/model/flavor/ZoneResourceDetailSpec.java new file mode 100644 index 00000000..4babb726 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/flavor/ZoneResourceDetailSpec.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.flavor; + +public class ZoneResourceDetailSpec { + + private String zoneName; + + private BccResources bccResources; + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public BccResources getBccResources() { + return bccResources; + } + + public void setBccResources(BccResources bccResources) { + this.bccResources = bccResources; + } + + @Override + public String toString() { + return "ZoneResourceDetailSpec{" + + "zoneName='" + zoneName + '\'' + + ", bccResources=" + bccResources + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/CancelRemoteCopyImageRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/CancelRemoteCopyImageRequest.java new file mode 100644 index 00000000..6082ef42 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/CancelRemoteCopyImageRequest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for cancel remote copy image. + * + */ +public class CancelRemoteCopyImageRequest extends AbstractBceRequest { + + /** + * The id of image. + */ + private String imageId; + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + /** + * Configure imageId for the request. + * + * @param imageId The id of image. + * @return CancelRemoteCopyImageRequest with imageId. + */ + public CancelRemoteCopyImageRequest withImageId(String imageId) { + this.setImageId(imageId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CancelRemoteCopyImageRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/CreateImageRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/CreateImageRequest.java new file mode 100644 index 00000000..12bd75b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/CreateImageRequest.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for creating new image. + * + */ +public class CreateImageRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The name for the image that will be created. + * The name length from 1 to 65,only contains letters,digital and underline. + */ + private String imageName; + + /** + * The optional parameter specify the id of the instance which will be used to create the new image. + * When instanceId and snapshotId are specified ,only instanceId will be used. + */ + private String instanceId; + + /** + * The optional parameter specify the id of the snapshot which will be used to create the new image. + * When instanceId and snapshotId are specified ,only instanceId will be used. + */ + private String snapshotId; + + /** + * Whether is related with CDS. If true, it means the image is related with CDS. + */ + private boolean relateCds; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return CreateImageRequest with specific clientToken + */ + public CreateImageRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public String getImageName() { + return imageName; + } + + public void setImageName(String imageName) { + this.imageName = imageName; + } + + /** + * Configure imageName for the request. + * + * @param imageName The name for the image that will be created. + * The name length from 1 to 65,only contains letters,digital and underline. + * @return CreateImageRequest with imageName. + */ + public CreateImageRequest withImageName(String imageName) { + this.imageName = imageName; + return this; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The optional parameter specify the id of the instance + * which will be used to create the new image. + * When instanceId and snapshotId are specified ,only instanceId will be used. + * @return CreateImageRequest with instanceId. + */ + public CreateImageRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + /** + * Configure snapshotId for the request. + * + * @param snapshotId The optional parameter specify the id of the snapshot + * which will be used to create the new image. + * When instanceId and snapshotId are specified ,only instanceId will be used. + * @return CreateImageRequest with snapshotId. + */ + public CreateImageRequest withSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + return this; + } + + public boolean isRelateCds() { + return relateCds; + } + + public void setRelateCds(boolean relateCds) { + this.relateCds = relateCds; + } + + /** + * Configure relateCds for the request. + * + * @param relateCds Whether is related with CDS. If true, it means the image is related with CDS. + * @return CreateImageRequest with relateCds. + */ + public CreateImageRequest withRelateCds(boolean relateCds) { + this.relateCds = relateCds; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateImageRequest with credentials. + */ + @Override + public CreateImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/CreateImageResponse.java b/src/main/java/com/baidubce/services/bcc/model/image/CreateImageResponse.java new file mode 100644 index 00000000..5fe064b4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/CreateImageResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for CreateImageRequest. + */ +public class CreateImageResponse extends AbstractBceResponse { + + /** + * The id of image created. + */ + private String imageId; + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/DeleteImageRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/DeleteImageRequest.java new file mode 100644 index 00000000..18a52200 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/DeleteImageRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for deleting the specified image. + */ +public class DeleteImageRequest extends AbstractBceRequest { + /** + * The id of image. + */ + private String imageId; + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + /** + * Configure imageId for the request. + * + * @param imageId The id of image that will be deleted. + * @return DeleteImageRequest with imageId. + */ + public DeleteImageRequest withImageId(String imageId) { + this.imageId = imageId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteImageRequest with credentials. + */ + @Override + public DeleteImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/GetAvailableImagesBySpecRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/GetAvailableImagesBySpecRequest.java new file mode 100644 index 00000000..7b829ad0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/GetAvailableImagesBySpecRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author: lilu24 + * @Date: 2023-09-05 + */ + +@Data +public class GetAvailableImagesBySpecRequest extends AbstractBceRequest { + + private String marker = "-1"; + + + private Integer maxKeys = 10; + + private String spec; + + private String osName; + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/GetAvailableImagesBySpecResponse.java b/src/main/java/com/baidubce/services/bcc/model/image/GetAvailableImagesBySpecResponse.java new file mode 100644 index 00000000..4bec38fa --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/GetAvailableImagesBySpecResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.model.ListResponse; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2023-09-04 + */ + +@Data +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public class GetAvailableImagesBySpecResponse extends ListResponse { + + + + private List images; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/GetImageRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/GetImageRequest.java new file mode 100644 index 00000000..daf34e41 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/GetImageRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting the detail information of the specified image. + */ +public class GetImageRequest extends AbstractBceRequest { + + /** + * The id of image. + */ + private String imageId; + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + /** + * Configure imageId for the request. + * + * @param imageId The id of image. + * @return GetImageRequest with imageId. + */ + public GetImageRequest withImageId(String imageId) { + this.imageId = imageId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetImageRequest with credentials. + */ + @Override + public GetImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/GetImageResponse.java b/src/main/java/com/baidubce/services/bcc/model/image/GetImageResponse.java new file mode 100644 index 00000000..a9d9c526 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/GetImageResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.ImageModel; + +/** + * The response for GetImageRequest. + */ +public class GetImageResponse extends AbstractBceResponse { + + /** + * The image detail model. + */ + private ImageModel image; + + public ImageModel getImage() { + return image; + } + + public void setImage(ImageModel image) { + this.image = image; + } + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/ImageAction.java b/src/main/java/com/baidubce/services/bcc/model/image/ImageAction.java new file mode 100644 index 00000000..a50b0151 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/ImageAction.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +/** + * The action for operating the image. + */ +public enum ImageAction { + + /** + * The action to share the image. + */ + share, + + /** + * The action to unshare the image. + */ + unshare, + + /** + * The action to remoteCopy the image. + */ + remoteCopy, + + /** + * The action to cancelRemoteCopy the image. + */ + cancelRemoteCopy +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/ListImagesRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/ListImagesRequest.java new file mode 100644 index 00000000..59274111 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/ListImagesRequest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for listing the images. + */ +public class ListImagesRequest extends ListRequest { + /** + * The optional parameter to filter image to list, + * see more detail on BCE API doc + */ + private String imageType; + + private String imageName; + + public String getImageType() { + return imageType; + } + + public void setImageType(String imageType) { + this.imageType = imageType; + } + + /** + * Configure the request with specified imageType. + * + * @param imageType The optional parameter to filter image to list, see more detail on + * BCE API doc + * @return ListInstancesRequest with specified imageType. + */ + public ListImagesRequest withImageType(String imageType) { + this.imageType = imageType; + return this; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListInstancesRequest with specified marker. + */ + @Override + public ListImagesRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListInstancesRequest with specified maxKeys. + */ + @Override + public ListImagesRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListImagesRequest with credentials. + */ + @Override + public ListImagesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getImageName() { + return imageName; + } + + public void setImageName(String imageName) { + this.imageName = imageName; + } + + /** + * Configure the request with specified imageName. + * + * @param imageName The optional parameter to filter image to list + * @return ListInstancesRequest with specified imageName. + */ + public ListImagesRequest withImageName(String imageName) { + this.imageName = imageName; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/ListImagesResponse.java b/src/main/java/com/baidubce/services/bcc/model/image/ListImagesResponse.java new file mode 100644 index 00000000..185d98fc --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/ListImagesResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.model.ListResponse; +import com.baidubce.services.bcc.model.ImageModel; + +import java.util.List; + +/** + * The response for ListImagesRequest. + */ +public class ListImagesResponse extends ListResponse { + + /** + * List of image detail model. + */ + private List images; + + public List getImages() { + return images; + } + + public void setImages(List images) { + this.images = images; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/ListOsRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/ListOsRequest.java new file mode 100644 index 00000000..e082b762 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/ListOsRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for listing the os. + */ +public class ListOsRequest extends AbstractBceRequest { + /** + * instance ids for query + */ + private List instanceIds; + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public ListOsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/ListOsResponse.java b/src/main/java/com/baidubce/services/bcc/model/image/ListOsResponse.java new file mode 100644 index 00000000..be0cb96a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/ListOsResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.OsModel; + +import java.util.List; + +/** + * The response for ListOsRequest. + */ +public class ListOsResponse extends AbstractBceResponse { + /** + * List of os detail model. + */ + private List osInfo; + + public List getOsInfo() { + return osInfo; + } + + public void setOsInfo(List osInfo) { + this.osInfo = osInfo; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/ListSharedUserRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/ListSharedUserRequest.java new file mode 100644 index 00000000..771e1e38 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/ListSharedUserRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class ListSharedUserRequest extends AbstractBceRequest { + + /** + * The id of image. + */ + private String imageId; + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + /** + * Configure imageId for the request. + * + * @param imageId The id of image. + * @return ListSharedUserRequest with imageId. + */ + public ListSharedUserRequest withImageId (String imageId) { + this.setImageId(imageId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListSharedUserRequest with credentials. + */ + @Override + public ListSharedUserRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/ListSharedUserResponse.java b/src/main/java/com/baidubce/services/bcc/model/image/ListSharedUserResponse.java new file mode 100644 index 00000000..0aeddb8b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/ListSharedUserResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.model.ListResponse; +import com.baidubce.services.bcc.model.SharedUserModel; + +import java.util.List; + +/** + * The response for ListSharedUserRequest. + */ +public class ListSharedUserResponse extends ListResponse { + + /** + * List of sharedUser detail model. + */ + private List users; + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/RemoteCopyImageRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/RemoteCopyImageRequest.java new file mode 100644 index 00000000..eead4b0e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/RemoteCopyImageRequest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +public class RemoteCopyImageRequest extends AbstractBceRequest { + + /** + * The id of image. + */ + @JsonIgnore + private String imageId; + + /** + * The name of image. + */ + private String name; + + /** + * The id of destRegion. + */ + private List destRegion; + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getDestRegion() { + return destRegion; + } + + public void setDestRegion(List destRegion) { + this.destRegion = destRegion; + } + + /** + * Configure imageId for the request. + * + * @param imageId The id of image. + * @return RemoteCopyImageRequest with imageId. + */ + public RemoteCopyImageRequest withImageId(String imageId) { + this.setImageId(imageId); + return this; + } + + /** + * Configure name for the request. + * + * @param name The name of image. + * @return RemoteCopyImageRequest with name. + */ + public RemoteCopyImageRequest withname(String name) { + this.setName(name); + return this; + } + + /** + * Configure imageId for the request. + * + * @param destRegion The id of destRegion. + * @return RemoteCopyImageRequest with destRegion. + */ + public RemoteCopyImageRequest withDestRegion(List destRegion) { + this.setDestRegion(destRegion); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return RemoteCopyImageRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/ShareImageRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/ShareImageRequest.java new file mode 100644 index 00000000..a793fa25 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/ShareImageRequest.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for share image. + * + */ +public class ShareImageRequest extends AbstractBceRequest { + + /** + * The id of image. + */ + @JsonIgnore + private String imageId; + + /** + * The accout name of user + */ + private String account; + + /** + * The account id of user + */ + private String accountId; + + /** + * The account of uc. + */ + private String ucAccount; + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getUcAccount() { + return ucAccount; + } + + public void setUcAccount(String ucAccount) { + this.ucAccount = ucAccount; + } + + /** + * Configure imageId for the request. + * + * @param imageId The id of image. + * @return ShareImageRequest with imageId. + */ + public ShareImageRequest withImageId(String imageId) { + this.imageId = imageId; + return this; + } + + /** + * Configure account for the request. + * + * @param account The id of image. + * @return ShareImageRequest with account. + */ + public ShareImageRequest withAccount(String account) { + this.account = account; + return this; + } + + /** + * Configure accountId for the request. + * + * @param accountId The id of image. + * @return ShareImageRequest with accountId. + */ + public ShareImageRequest withAccountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Configure ucAccount for the request. + * + * @param ucAccount The account of uc. + * @return ShareImageRequest with ucAccount. + */ + public ShareImageRequest withUcAccount(String ucAccount) { + this.ucAccount = ucAccount; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ShareImageRequest with credentials. + */ + @Override + public ShareImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/SystemImageModel.java b/src/main/java/com/baidubce/services/bcc/model/image/SystemImageModel.java new file mode 100644 index 00000000..83d99f85 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/SystemImageModel.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bcc.model.image; + +import lombok.Data; + +/** + * @Author: lilu24 + * @Date: 2023-09-04 + */ + +@Data +public class SystemImageModel { + + private String imageId; + private String imageName; + private String osType; + private String osVersion; + private String osArch; + private String osName; + private String osLang; + private int minSizeInGiB; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/image/UnShareImageRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/UnShareImageRequest.java new file mode 100644 index 00000000..a207e18c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/UnShareImageRequest.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for unshare image. + * + */ +public class UnShareImageRequest extends AbstractBceRequest { + + /** + * The id of image. + */ + @JsonIgnore + private String imageId; + + /** + * The accout name of user + */ + private String account; + + /** + * The accout id of user + */ + private String accountId; + + /** + * The account of uc. + */ + private String ucAccount; + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getUcAccount() { + return ucAccount; + } + + public void setUcAccount(String ucAccount) { + this.ucAccount = ucAccount; + } + + /** + * Configure imageId for the request. + * + * @param imageId The id of image. + * @return ShareImageRequest with imageId. + */ + public UnShareImageRequest withImageId(String imageId) { + this.imageId = imageId; + return this; + } + + /** + * Configure account for the request. + * + * @param account The id of image. + * @return ShareImageRequest with account. + */ + public UnShareImageRequest withAccount(String account) { + this.account = account; + return this; + } + + /** + * Configure accountId for the request. + * + * @param accountId The id of image. + * @return ShareImageRequest with accountId. + */ + public UnShareImageRequest withAccountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Configure ucAccount for the request. + * + * @param ucAccount The account of uc. + * @return ShareImageRequest with ucAccount. + */ + public UnShareImageRequest withUcAccount(String ucAccount) { + this.ucAccount = ucAccount; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ShareImageRequest with credentials. + */ + @Override + public UnShareImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BatchAddIpRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/BatchAddIpRequest.java new file mode 100644 index 00000000..ec46507c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BatchAddIpRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-12 + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BatchAddIpRequest extends AbstractBceRequest { + + private boolean allocateMultiIpv6Addr; + private String instanceId; + private List privateIps; + private long secondaryPrivateIpAddressCount; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BatchAddIpResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/BatchAddIpResponse.java new file mode 100644 index 00000000..8f6e3e9a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BatchAddIpResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-12 + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BatchAddIpResponse extends AbstractBceResponse { + + + private List privateIps; + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BatchChangeToPrepaidRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/BatchChangeToPrepaidRequest.java new file mode 100644 index 00000000..5564d327 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BatchChangeToPrepaidRequest.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; +import java.util.List; + +@Data +public class BatchChangeToPrepaidRequest extends AbstractBceRequest { + private List config; + + public BatchChangeToPrepaidRequest withConfig(List config){ + this.config = config; + return this; + } + public BatchChangeToPrepaidRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BatchChangeToPrepaidResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/BatchChangeToPrepaidResponse.java new file mode 100644 index 00000000..4912eeb5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BatchChangeToPrepaidResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BatchChangeToPrepaidResponse extends AbstractBceResponse { + private String orderId; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BatchDeleteIpRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/BatchDeleteIpRequest.java new file mode 100644 index 00000000..fefa34bd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BatchDeleteIpRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-12 + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BatchDeleteIpRequest extends AbstractBceRequest { + + + private String instanceId; + private List privateIps; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BatchRefundResourceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/BatchRefundResourceRequest.java new file mode 100644 index 00000000..a439073c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BatchRefundResourceRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * The request for releasing the instance by post. + */ +public class BatchRefundResourceRequest extends AbstractBceRequest { + + + private List instanceIds; + + /** + * Whether to release the EIP and the data disk attached to the instance at the current time + * in the same time. Iftrue, it means release, and the parameters deleteCdsSnapshotFlag works. + * Iffalse, it means not to release, and the parameters deleteCdsSnapshotFlag does not works. + */ + private boolean relatedReleaseFlag; + + /** + * Whether to delete the CDS Snapshot. Iftrue, it means delete. + */ + private boolean deleteCdsSnapshotFlag; + + + /** + * Whether to delete the ENI. Iftrue, it means delete. + */ + private boolean deleteRelatedEnisFlag; + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceId(List instanceIds) { + this.instanceIds = instanceIds; + } + + public boolean isRelatedReleaseFlag() { + return relatedReleaseFlag; + } + + public void setRelatedReleaseFlag(boolean relatedReleaseFlag) { + this.relatedReleaseFlag = relatedReleaseFlag; + } + + public boolean isDeleteCdsSnapshotFlag() { + return deleteCdsSnapshotFlag; + } + + public void setDeleteCdsSnapshotFlag(boolean deleteCdsSnapshotFlag) { + this.deleteCdsSnapshotFlag = deleteCdsSnapshotFlag; + } + + public boolean isDeleteRelatedEnisFlag() { + return deleteRelatedEnisFlag; + } + + public void setDeleteRelatedEnisFlag(boolean deleteRelatedEnisFlag) { + this.deleteRelatedEnisFlag = deleteRelatedEnisFlag; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BatchRefundResourceResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/BatchRefundResourceResponse.java new file mode 100644 index 00000000..493fc244 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BatchRefundResourceResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response of changing the instance payment to prepaid. + */ +public class BatchRefundResourceResponse extends AbstractBceResponse { + + /** + * The list of failed instance id. + */ + private List failedInstanceIds; + + public List getFailedInstanceIds() { + return failedInstanceIds; + } + + public void setFailedInstanceIds(List failedInstanceIds) { + this.failedInstanceIds = failedInstanceIds; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BatchStopInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/BatchStopInstanceRequest.java new file mode 100644 index 00000000..adb19a55 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BatchStopInstanceRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-12 + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BatchStopInstanceRequest extends AbstractBceRequest { + + private List instanceIds; + + private boolean forceStop; + + private boolean stopWithNoCharge; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BccAutoRenewRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/BccAutoRenewRequest.java new file mode 100644 index 00000000..04dce692 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BccAutoRenewRequest.java @@ -0,0 +1,88 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class BccAutoRenewRequest extends AbstractBceRequest { + + private String instanceId; + + private String renewTimeUnit; + + private Integer renewTime; + + private boolean renewEip = true; + + private boolean renewCds = true; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public BccAutoRenewRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getRenewTimeUnit() { + return renewTimeUnit; + } + + public void setRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + } + + public BccAutoRenewRequest withRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + return this; + } + + public Integer getRenewTime() { + return renewTime; + } + + public void setRenewTime(Integer renewTime) { + this.renewTime = renewTime; + } + + public BccAutoRenewRequest withRenewTime(Integer renewTime) { + this.renewTime = renewTime; + return this; + } + + public boolean isRenewEip() { + return renewEip; + } + + public void setRenewEip(boolean renewEip) { + this.renewEip = renewEip; + } + + public BccAutoRenewRequest withRenewEip(boolean renewEip) { + this.renewEip = renewEip; + return this; + } + + public boolean isRenewCds() { + return renewCds; + } + + public void setRenewCds(boolean renewCds) { + this.renewCds = renewCds; + } + + public BccAutoRenewRequest withRenewCds(boolean renewCds) { + this.renewCds = renewCds; + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BccPriceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/BccPriceRequest.java new file mode 100644 index 00000000..bf1ea589 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BccPriceRequest.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for get price + */ +public class BccPriceRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + * When creating the storage optimized instance, one ephemeral disk must be created together. + */ + @JsonIgnore + private String clientToken; + + /** + * The instance of specId. + */ + private String specId; + + /** + * The instance of spec. + */ + private String spec; + + /** + * the name of available zone + */ + private String zoneName; + + /** + * The pay time of the payment. + */ + private String paymentTiming; + + /** + * The length of purchase to buy, the default value is 1. + */ + private int purchaseLength = 1; + + /** + * The number of instance to buy, the default value is 1. + */ + private int purchaseCount = 1; + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return CreateInstanceRequest with specific clientToken + */ + public BccPriceRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public BccPriceRequest withSpecId(String specId) { + this.setSpecId(specId); + return this; + } + + public String getSpecId() { + return specId; + } + + public void setSpecId(String specId) { + this.specId = specId; + } + + public BccPriceRequest withSpec(String spec) { + this.setSpec(spec); + return this; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public BccPriceRequest withZoneName(String zoneName) { + this.setZoneName(zoneName); + return this; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public BccPriceRequest withPaymentTiming(String paymentTiming) { + this.setPaymentTiming(paymentTiming); + return this; + } + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public BccPriceRequest withPurchaseLength(int purchaseLength) { + this.setPurchaseLength(purchaseLength); + return this; + } + + public int getPurchaseLength() { + return purchaseLength; + } + + public void setPurchaseLength(int purchaseLength) { + this.purchaseLength = purchaseLength; + } + + public BccPriceRequest withPurchaseCount(int purchaseCount) { + this.setPurchaseCount(purchaseCount); + return this; + } + + public int getPurchaseCount() { + return purchaseCount; + } + + public void setPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateInstanceRequest with credentials. + */ + public BccPriceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BccPriceResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/BccPriceResponse.java new file mode 100644 index 00000000..56376150 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BccPriceResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +public class BccPriceResponse extends AbstractBceResponse { + private List price; + + public List getPrice() { + return price; + } + + public void setPrice(List price) { + this.price = price; + } + + @Override + public String toString() { + return "BccPriceResponse{" + + "price=" + price + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BindSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/BindSecurityGroupRequest.java new file mode 100644 index 00000000..e41fcc1c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BindSecurityGroupRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * request for binding securitygroup to specified instance. + */ +public class BindSecurityGroupRequest extends AbstractBceRequest { + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The id of securitygroup. + */ + private String securityGroupId; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + /** + * Configure the instance ID for the request. + * + * @param securityGroupId The id of SecurityGroup. + * @return BindSecurityGroupRequest with specified SecurityGroup id. + */ + public BindSecurityGroupRequest withSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + /** + * Configure the instance ID for the request. + * + * @param instanceId The id of instance which will be used to bind a securitygroup. + * @return BindSecurityGroupRequest with specified instance id. + */ + public BindSecurityGroupRequest withInstanceId(String instanceId) { + this.setInstanceId(instanceId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindSecurityGroupRequest with credentials. + */ + @Override + public BindSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/BindTagsRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/BindTagsRequest.java new file mode 100644 index 00000000..87352900 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/BindTagsRequest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * request for binding tags to specified instance. + */ +public class BindTagsRequest extends AbstractBceRequest { + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The list of tags. + */ + private List changeTags; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public List getChangeTags() { + return changeTags; + } + + public void setChangeTags(List changeTags) { + this.changeTags = changeTags; + } + + /** + * Configure the list of tags for the request. + * + * @param changeTags The list of tags. + * @return BindTagsRequest with specified list of tags. + */ + public BindTagsRequest withChangeTags(List changeTags) { + this.changeTags = changeTags; + return this; + } + + /** + * Configure the instance ID for the request. + * + * @param instanceId The id of instance which will be used to bind a list of tags. + * @return BindTagsRequest with specified instance id. + */ + public BindTagsRequest withInstanceId(String instanceId) { + this.setInstanceId(instanceId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public BindTagsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/CancelBidOrderRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/CancelBidOrderRequest.java new file mode 100644 index 00000000..317cd2b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/CancelBidOrderRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for canceling bid order. + */ +public class CancelBidOrderRequest extends AbstractBceRequest { + + /** + * The id of the bidding order + */ + private String orderId; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + * When creating the storage optimized instance, one ephemeral disk must be created together. + */ + @JsonIgnore + private String clientToken; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public CancelBidOrderRequest withOrderId(String orderId) { + this.orderId = orderId; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public CancelBidOrderRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public CancelBidOrderRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/CancelBidOrderResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/CancelBidOrderResponse.java new file mode 100644 index 00000000..202ac6ea --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/CancelBidOrderResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of canceling the bid order. + */ +public class CancelBidOrderResponse extends AbstractBceResponse { + + /** + * The id of bidding order which is be canceled. + */ + private String orderId; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + @Override + public String toString() { + return "CancelBidOrderResponse{" + + "orderId=" + orderId + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ChangeInstanceSubnetRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ChangeInstanceSubnetRequest.java new file mode 100644 index 00000000..1a8029ba --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ChangeInstanceSubnetRequest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import java.util.List; + +/** + * The request for changing the instance subnet. + */ +public class ChangeInstanceSubnetRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + private String instanceId; + + /** + * The id of subnet after changed. + */ + private String subnetId; + + /** + * Whether to reboot automatically or not. If true, it means reboot automatically. + */ + private boolean reboot; + + private List securityGroupIds; + + public List getSecurityGroupIds() { + return securityGroupIds; + } + + public void setSecurityGroupIds(List securityGroupIds) { + this.securityGroupIds = securityGroupIds; + } + + public List getEnterpriseSecurityGroupIds() { + return enterpriseSecurityGroupIds; + } + + public void setEnterpriseSecurityGroupIds(List enterpriseSecurityGroupIds) { + this.enterpriseSecurityGroupIds = enterpriseSecurityGroupIds; + } + + private List enterpriseSecurityGroupIds; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public ChangeInstanceSubnetRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public ChangeInstanceSubnetRequest withSubnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + public boolean isReboot() { + return reboot; + } + + public void setReboot(boolean reboot) { + this.reboot = reboot; + } + + public ChangeInstanceSubnetRequest withReboot(boolean reboot) { + this.reboot = reboot; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ChangeInstanceSubnetRequest with credentials. + */ + public ChangeInstanceSubnetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public ChangeInstanceSubnetRequest withEnterpriseSecurityGroupIds(List enterpriseSecurityGroupIds) { + this.enterpriseSecurityGroupIds = enterpriseSecurityGroupIds; + return this; + } + + public ChangeInstanceSubnetRequest withSecurityGroupIds(List securityGroupIds) { + this.securityGroupIds = securityGroupIds; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ChangeToPrepaidRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ChangeToPrepaidRequest.java new file mode 100644 index 00000000..8ced7a57 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ChangeToPrepaidRequest.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for changing the instance payment to prepaid. + */ +public class ChangeToPrepaidRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + private String instanceId; + + /** + * Purchase duration, the unit is month. + */ + private int duration; + + /** + * Whether is change the related CDS or not. + */ + private boolean relationCds = true; + + private Boolean autoPay; + + private Boolean autoRenew = false; + + private Integer autoRenewPeriod = 1; + + public ChangeToPrepaidRequest withAutoPay(boolean autoPay) { + this.autoPay = autoPay; + return this; + } + + public Boolean getAutoPay() { + return autoPay; + } + + public void setAutoPay(Boolean autoPay) { + this.autoPay = autoPay; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public ChangeToPrepaidRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public ChangeToPrepaidRequest withDuration(int duration) { + this.duration = duration; + return this; + } + + public boolean isRelationCds() { + return relationCds; + } + + public void setRelationCds(boolean relationCds) { + this.relationCds = relationCds; + } + + public ChangeToPrepaidRequest withRelationCds(boolean relationCds) { + this.relationCds = relationCds; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ChangeToPrepaidRequest with credentials. + */ + @Override + public ChangeToPrepaidRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public ChangeToPrepaidRequest withAutoRenew(Boolean autoRenew) { + this.autoRenew = autoRenew; + return this; + } + + public Boolean getAutoRenew() { + return autoRenew; + } + + public void setAutoRenew(Boolean autoRenew) { + this.autoRenew = autoRenew; + } + + public ChangeToPrepaidRequest withAutoRenewPeriod(Integer autoRenewPeriod) { + this.autoRenewPeriod = autoRenewPeriod; + return this; + } + + public Integer getAutoRenewPeriod() { + return autoRenewPeriod; + } + + public void setAutoRenewPeriod(Integer autoRenewPeriod) { + this.autoRenewPeriod = autoRenewPeriod; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ChangeToPrepaidResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/ChangeToPrepaidResponse.java new file mode 100644 index 00000000..5b1f3d06 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ChangeToPrepaidResponse.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of changing the instance payment to prepaid. + */ +public class ChangeToPrepaidResponse extends AbstractBceResponse { + + /** + * The id of the order. + */ + private String orderId; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + @Override + public String toString() { + return "ChangeToPrepaidResponse{" + + "orderId=" + orderId + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ChangeVpcRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ChangeVpcRequest.java new file mode 100644 index 00000000..ad493900 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ChangeVpcRequest.java @@ -0,0 +1,46 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; +import java.util.List; + +@Data +public class ChangeVpcRequest extends AbstractBceRequest { + private String instanceId; + private String subnetId; + private String internalIp; + private List securityGroupIds; + private List enterpriseSecurityGroupIds; + + public ChangeVpcRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public ChangeVpcRequest withSubnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + public ChangeVpcRequest withInternalIp(String internalIp) { + this.internalIp = internalIp; + return this; + } + + public ChangeVpcRequest withSecurityGroupIds(List securityGroupIds) { + this.securityGroupIds = securityGroupIds; + return this; + } + + public ChangeVpcRequest withEnterpriseSecurityGroupIds(List enterpriseSecurityGroupIds) { + this.enterpriseSecurityGroupIds = enterpriseSecurityGroupIds; + return this; + } + + @Override + public ChangeVpcRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/CreateEhcClusterRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/CreateEhcClusterRequest.java new file mode 100644 index 00000000..4a5a4e7e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/CreateEhcClusterRequest.java @@ -0,0 +1,42 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class CreateEhcClusterRequest extends AbstractBceRequest { + /** + * The name of the ehcCluster. + */ + private String name; + /** + * the name of available zone + */ + private String zoneName; + /** + * The description of the instance. + */ + private String description; + + public CreateEhcClusterRequest withName(String name) { + this.name = name; + return this; + } + + public CreateEhcClusterRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + public CreateEhcClusterRequest withDescription(String description) { + this.description = description; + return this; + } + + @Override + public CreateEhcClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/CreateEhcClusterResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/CreateEhcClusterResponse.java new file mode 100644 index 00000000..51e77eb4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/CreateEhcClusterResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class CreateEhcClusterResponse extends AbstractBceResponse { + /** + * The id of ehcCluster. + */ + private String ehcClusterId; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceRequest.java new file mode 100644 index 00000000..1824df73 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceRequest.java @@ -0,0 +1,987 @@ +/* + * Copyright (c) 2018-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.CreateCdsModel; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.bcc.model.volume.EphemeralDisk; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for creating a newly instance. + */ +public class CreateInstanceRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + * When creating the storage optimized instance, one ephemeral disk must be created together. + */ + @JsonIgnore + private String clientToken; + + /** + * The parameter to specified which kind of instance to create, there is default value when null. + * see all of supported instance type in {@link com.baidubce.services.bcc.model.instance.InstanceType} + */ + private String instanceType; + + /** + * The instance of spec. + */ + private String spec; + + /** + * The parameter to specified the cpu core to create the instance. + */ + private int cpuCount; + + /** + * The parameter to specified the capacity of memory in GB to create the instance. + */ + private int memoryCapacityInGB; + + + /** + * The parameter to specify the root disk size in GB.The root disk excludes the system disk, available is 40-500GB. + * + */ + private int rootDiskSizeInGb; + + /** + * The parameter to specify the root disk storage type. Default use of HP1 cloud disk. + * + */ + private String rootDiskStorageType; + + /** + * The optional parameter to specify the ephemeral disk list + * + * When creating the storage optimized instance, one ephemeral disk must be created together. + * + * When creating the gpu instance, one ephemeral disk must be created together, the optional ephemeral disk size + * see + * The optional ephemeral disk size for gpu instance + * + * When creating the fpga instance, one ephemeral disk must be created together, the optional ephemeral disk size + * see + * The optional ephemeral disk size for gpu instance + * + */ + private List ephemeralDisks; + + /** + * The optional parameter to specify the ephemeral disk size in GB. + * + * The ephemeral disk excludes the system disk, available is 0-500GB + * + * This parameter will be deprecated in the future, we suggest using the ephemeralDisks param instead. + */ + @Deprecated + private int localDiskSizeInGB; + + /** + * The optional list of volume detail info to create. + */ + private List createCdsList; + + /** + * The id of image,list all available image + * in {@link com.baidubce.services.bcc.BccClient#listImages()} + */ + private String imageId; + + /** + * The optional parameter to specify the bandwidth in Mbps for the new instance. + * + * It must among 0 and 200,default value is 0. + * If it's specified to 0, it will get the internal ip address only. + */ + private int networkCapacityInMbps = 0; + + /** + * The number of instance to buy, the default value is 1. + */ + private int purchaseCount = 1; + + /** + * The optional parameter to desc the instance that will be created. + */ + private String name; + + /** + * The optional parameter to desc the hostname of instance that will be created. + */ + private String hostname; + + /** + * Indicates whether automatic generation of ordered suffixes + */ + private boolean autoSeqSuffix; + + /** + * The optional parameter to specify the password for the instance. + * + * If specify the adminPass,the adminPass must be a 8-16 characters String which must + * contains letters,numbers and symbols. The symbols only contains "!@#$%^*()". + * The adminPass will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * + * If not specify the adminPass, it will be specified by an random string. + * See more detail on + * + * BCE API doc + */ + private String adminPass; + + /** + * The detail model to specify the billing info. + */ + private Billing billing; + + /** + * Indicates whether the tag is bound to all relation instances. + */ + private boolean relationTag; + + /** + * The list of tag to be bonded. + */ + private List tags; + + /** + * specified id of dedicated host when creating dedicated instance + */ + private String dedicatedHostId; + + /** + * the name of available zone, optional param + * through listZones, we can get all available zone info at current region + * e.g. "cn-gz-a" "cn-gz-b" + */ + private String zoneName; + + /** + * the id of subnet from vpc, optional param, default value is default subnet from default vpc + */ + private String subnetId; + + /** + * specify the securityGroupId of creating instance, optional param + * vpcId of the securityGroupId must be the same as the vpcId of subnetId + * through listSecurityGroups, we can get all securityGroup info at current region + */ + private String securityGroupId; + + /** + * specify the gpuCard info of creating GPU instance, + * see all of supported gpu card type in {@link com.baidubce.services.bcc.model.instance.GpuCardType} + */ + private GpuCardType gpuCard; + + /** + * specify the gpuCard info of creating FPGA instance, + * see all of supported fpga card type in {@link com.baidubce.services.bcc.model.instance.FpgaCardType} + */ + private FpgaCardType fpgaCard; + + /** + * specify the card count for creating GPU/FPGA instance + */ + private int cardCount = 1; + + /** + * The id of asp + */ + private String aspId; + + /** + * specifying auto renew time length. + */ + private int autoRenewTime; + + /** + * specifying auto renew time unit + */ + private String autoRenewTimeUnit; + + /** + * Whether the cds is auto renew or not + */ + private boolean cdsAutoRenew; + + /** + * The id of the deploymentSet + */ + private String deployId; + + /** + * Whether SN is automatically hidden + */ + private boolean disableRootDiskSerial; + + /** + * Specified the internet charge type + */ + private String internetChargeType; + + /** + * The id of the keypair + */ + private String keypairId; + + /** + * Specified the bidding model + */ + private String bidModel; + + /** + * Specified the bidding price + */ + private String bidPrice; + + /** + * If the instance meets the limit of using instance custom data, you can pass in the UserData information. + */ + private String userData; + + /** + * The list of internal ips. + */ + private List internalIps; + + /** + * Specified the resource group id of creating instance, optional param + */ + private String resGroupId; + + + private boolean enableJumboFrame = false; + + /** + * The id of ehcCluster. + */ + private String ehcClusterId; + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return CreateInstanceRequest with specific clientToken + */ + public CreateInstanceRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure instanceType for the request. + * + * @param instanceType The specified Specification to create the instance. + * See more detail on + * + * BCE API doc + * @return CreateInstanceRequest with specific instanceType + */ + public CreateInstanceRequest withInstanceType(String instanceType) { + this.setInstanceType(instanceType); + return this; + } + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public CreateInstanceRequest withSpec(String Spec) { + this.setSpec(Spec); + return this; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public CreateInstanceRequest withCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + return this; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public CreateInstanceRequest withMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + return this; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + public CreateInstanceRequest withEphemeralDisks(List ephemeralDisks) { + this.ephemeralDisks = ephemeralDisks; + return this; + } + public CreateInstanceRequest withRootDiskSizeInGb(int rootDiskSizeInGb) { + this.rootDiskSizeInGb = rootDiskSizeInGb; + return this; + } + + public int getRootDiskSizeInGb() { + return rootDiskSizeInGb; + } + + public void setRootDiskSizeInGb(int rootDiskSizeInGb) { + this.rootDiskSizeInGb = rootDiskSizeInGb; + } + + public CreateInstanceRequest withRootDiskStorageType(String rootDiskStorageType) { + this.rootDiskStorageType = rootDiskStorageType; + return this; + } + public String getRootDiskStorageType() { + return rootDiskStorageType; + } + + public void setRootDiskStorageType(String rootDiskStorageType) { + this.rootDiskStorageType = rootDiskStorageType; + } + + public List getEphemeralDisks() { + return ephemeralDisks; + } + + public void setEphemeralDisks(List ephemeralDisks) { + this.ephemeralDisks = ephemeralDisks; + } + + /** + * Configure imageId for the request. + * + * @param imageId The specified image id to create the instance. + * @return CreateInstanceRequest with specific imageId + */ + public CreateInstanceRequest withImageId(String imageId) { + this.setImageId(imageId); + return this; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + @Deprecated + public int getLocalDiskSizeInGB() { + return localDiskSizeInGB; + } + + @Deprecated + public void setLocalDiskSizeInGB(int localDiskSizeInGB) { + this.localDiskSizeInGB = localDiskSizeInGB; + } + + /** + * Configure localDiskSizeInGB for the request. + * + * @param localDiskSizeInGB The optional parameter to specify the temporary disk size in GB. + * @return CreateInstanceRequest with specific localDiskSizeInGB + */ + @Deprecated + public CreateInstanceRequest withLocalDiskSizeInGB(int localDiskSizeInGB) { + this.localDiskSizeInGB = localDiskSizeInGB; + return this; + } + + public List getCreateCdsList() { + return createCdsList; + } + + public void setCreateCdsList(List createCdsList) { + this.createCdsList = createCdsList; + } + + + /** + * Configure createCdsList for the request. + * + * @param createCdsList The optional list of volume detail info to create. + * @return CreateInstanceRequest with specific createCdsList + */ + public CreateInstanceRequest withCreateCdsList(List createCdsList) { + this.createCdsList = createCdsList; + return this; + } + + public int getNetworkCapacityInMbps() { + return networkCapacityInMbps; + } + + public void setNetworkCapacityInMbps(int networkCapacityInMbps) { + this.networkCapacityInMbps = networkCapacityInMbps; + } + + /** + * Configure networkCapacityInMbps for the request. + * + * @param networkCapacityInMbps The optional parameter to specify the bandwidth in Mbps for the new instance. + * @return CreateInstanceRequest with specific networkCapacityInMbps + */ + public CreateInstanceRequest withNetworkCapacityInMbps(int networkCapacityInMbps) { + this.networkCapacityInMbps = networkCapacityInMbps; + return this; + } + + public int getPurchaseCount() { + return purchaseCount; + } + + public void setPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + } + + /** + * Configure purchaseCount for the request. + * + * @param purchaseCount The number of instance to buy, the default value is 1. + * @return CreateInstanceRequest with specific purchaseCount + */ + public CreateInstanceRequest withPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public CreateInstanceRequest withHostname(String hostname) { + this.hostname = hostname; + return this; + } + + public boolean isAutoSeqSuffix() { + return autoSeqSuffix; + } + + public void setAutoSeqSuffix(boolean autoSeqSuffix) { + this.autoSeqSuffix = autoSeqSuffix; + } + + public CreateInstanceRequest withAutoSeqSuffix(boolean autoSeqSuffix) { + this.autoSeqSuffix = autoSeqSuffix; + return this; + } + + /** + * Configure name for the request. + * + * @param name The optional parameter to desc the instance that will be created. + * @return CreateInstanceRequest with specific name + */ + public CreateInstanceRequest withName(String name) { + this.name = name; + return this; + } + + public String getAdminPass() { + return adminPass; + } + + public void setAdminPass(String adminPass) { + this.adminPass = adminPass; + } + + /** + * Configure adminPass for the request. + * + * @param adminPass The optional parameter to specify the password for the instance. + * The adminPass will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * See more detail on + * + * BCE API doc + * @return CreateInstanceRequest with specific adminPass + */ + public CreateInstanceRequest withAdminPass(String adminPass) { + this.adminPass = adminPass; + return this; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + /** + * Configure billing for the request. + * + * @param billing The detail model to specify the billing. + * @return CreateInstanceRequest with specific billing + */ + public CreateInstanceRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + public boolean isRelationTag() { + return relationTag; + } + + public void setRelationTag(boolean relationTag) { + this.relationTag = relationTag; + } + + /** + * Configure relationTag for the request. + * + * @param relationTag Indicates whether the tag is bound to all relation instances. + * @return CreateInstanceRequest with specific relationTag + */ + public CreateInstanceRequest withRelationTag(boolean relationTag) { + this.relationTag = relationTag; + return this; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + /** + * Configure tags for the request. + * + * @param tags The list of tag to be bonded. + * @return CreateInstanceRequest with specific tags + */ + public CreateInstanceRequest withTags(List tags) { + this.tags = tags; + return this; + } + + public CreateInstanceRequest withDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + return this; + } + + public String getDedicatedHostId() { + return dedicatedHostId; + } + + public void setDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + } + + /** + * Configure the zone name for the request + * @param zoneName + * @return CreateInstanceRequest with specified zone name + */ + public CreateInstanceRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + /** + * Configure the subnetId for the request + * @param subnetId + * @return CreateInstanceRequest with specified subnetId + */ + public CreateInstanceRequest withSubnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + /** + * Configure the securityGroupId for the request + * @param securityGroupId + * @return CreateInstanceRequest with specified securityGroupId + */ + public CreateInstanceRequest withSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + + public GpuCardType getGpuCard() { + return gpuCard; + } + + public void setGpuCard(GpuCardType gpuCard) { + this.gpuCard = gpuCard; + } + + /** + * Configure the gpuCard for the request, + * see all of supported gpu card type in {@link com.baidubce.services.bcc.model.instance.GpuCardType} + * @param gpuCard + * @return CreateInstanceRequest with specified gpuCard + */ + public CreateInstanceRequest withGpuCard(GpuCardType gpuCard) { + this.gpuCard = gpuCard; + return this; + } + + public FpgaCardType getFpgaCard() { + return fpgaCard; + } + + public void setFpgaCard(FpgaCardType fpgaCard) { + this.fpgaCard = fpgaCard; + } + + /** + * Configure the fpgaCard for the request, + * see all of supported fpga card type in {@link com.baidubce.services.bcc.model.instance.FpgaCardType} + * @param fpgaCard + * @return CreateInstanceRequest with specified fpgaCard + */ + public CreateInstanceRequest withFpgaCard(FpgaCardType fpgaCard) { + this.fpgaCard = fpgaCard; + return this; + } + + public int getCardCount() { + return cardCount; + } + + public void setCardCount(int cardCount) { + this.cardCount = cardCount; + } + + /** + * Configure the card count of gpuCardType or gpgaCardType for the request, + * if creating gpu / fpga instance, one or more card count must be specified. + * @param cardCount + * @return CreateInstanceRequest with card count of gpuCardType or gpgaCardTyp. + */ + public CreateInstanceRequest withCardCount(int cardCount) { + this.cardCount = cardCount; + return this; + } + + public String getAspId() { + return aspId; + } + + public void setAspId(String aspId) { + this.aspId = aspId; + } + + /** + * Configure the aspId for the request + * @param aspId The id of the asp. + * @return CreateInstanceRequest with specified aspId + */ + public CreateInstanceRequest withAspId(String aspId) { + this.aspId = aspId; + return this; + } + + public int getAutoRenewTime() { + return autoRenewTime; + } + + public void setAutoRenewTime(int autoRenewTime) { + this.autoRenewTime = autoRenewTime; + } + + /** + * Configure the autoRenewTime for the request + * @param autoRenewTime The specified auto renew time length. + * @return CreateInstanceRequest with specified autoRenewTime + */ + public CreateInstanceRequest withAutoRenewTime(int autoRenewTime) { + this.autoRenewTime = autoRenewTime; + return this; + } + + public String getAutoRenewTimeUnit() { + return autoRenewTimeUnit; + } + + public void setAutoRenewTimeUnit(String autoRenewTimeUnit) { + this.autoRenewTimeUnit = autoRenewTimeUnit; + } + + /** + * Configure the autoRenewTimeUnit for the request + * @param autoRenewTimeUnit The specified auto renew time unit. The unit can be "month" or "year". + * @return CreateInstanceRequest with specified autoRenewTimeUnit + */ + public CreateInstanceRequest withAutoRenewTimeUnit(String autoRenewTimeUnit) { + this.autoRenewTimeUnit = autoRenewTimeUnit; + return this; + } + + public boolean isCdsAutoRenew() { + return cdsAutoRenew; + } + + public void setCdsAutoRenew(boolean cdsAutoRenew) { + this.cdsAutoRenew = cdsAutoRenew; + } + + /** + * Configure the cdsAutoRenew for the request + * @param cdsAutoRenew The option param to indicate that whether the cds is auto renew or not. + * If true, it means the instance is auto renew. + * @return CreateInstanceRequest with specified cdsAutoRenew + */ + public CreateInstanceRequest withCdsAutoRenew(boolean cdsAutoRenew) { + this.cdsAutoRenew = cdsAutoRenew; + return this; + } + + public String getDeployId() { + return deployId; + } + + public void setDeployId(String deployId) { + this.deployId = deployId; + } + + /** + * Configure the deployId for the request + * @param deployId The specified deployment set id. + * @return CreateInstanceRequest with specified deployId + */ + public CreateInstanceRequest withDeployId(String deployId) { + this.deployId = deployId; + return this; + } + + public boolean isDisableRootDiskSerial() { + return disableRootDiskSerial; + } + + public void setDisableRootDiskSerial(boolean disableRootDiskSerial) { + this.disableRootDiskSerial = disableRootDiskSerial; + } + + public String getInternetChargeType() { + return internetChargeType; + } + + public void setInternetChargeType(String internetChargeType) { + this.internetChargeType = internetChargeType; + } + + /** + * Configure the internetChargeType for the request + * @param internetChargeType The specified internet charge type. + * @return CreateInstanceRequest with specified internetChargeType + */ + public CreateInstanceRequest withInternetChargeType(String internetChargeType) { + this.internetChargeType = internetChargeType; + return this; + } + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + /** + * Configure the keypairId for the request + * @param keypairId The specified keypair id. + * @return CreateInstanceRequest with specified keypairId + */ + public CreateInstanceRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + public String getBidModel() { + return bidModel; + } + + public void setBidModel(String bidModel) { + this.bidModel = bidModel; + } + + /** + * Configure the bidModel for the request + * @param bidModel The specified bidModel. The value can be "market" or "custom". + * @return CreateInstanceRequest with specified bidModel + */ + public CreateInstanceRequest withBidModel(String bidModel) { + this.bidModel = bidModel; + return this; + } + + public String getBidPrice() { + return bidPrice; + } + + public void setBidPrice(String bidPrice) { + this.bidPrice = bidPrice; + } + + public String getUserData() { + return userData; + } + + public void setUserData(String userData) { + this.userData = userData; + } + + /** + * Configure the bidPrice for the request + * @param bidPrice The specified bidPrice. Only the value of bidModel is custom, the param works. + * @return CreateInstanceRequest with specified bidPrice + */ + public CreateInstanceRequest withBidPrice(String bidPrice) { + this.bidPrice = bidPrice; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateInstanceRequest with credentials. + */ + public CreateInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public boolean getEnableJumboFrame() { + return enableJumboFrame; + } + + public void setEnableJumboFrame(boolean enableJumboFrame) { + this.enableJumboFrame = enableJumboFrame; + } + + public List getInternalIps() { + return internalIps; + } + + public void setInternalIps(List internalIps) { + this.internalIps = internalIps; + } + + public String getResGroupId() { + return resGroupId; + } + + public void setResGroupId(String resGroupId) { + this.resGroupId = resGroupId; + } + + public CreateInstanceRequest withResGroupId(String resGroupId) { + this.setResGroupId(resGroupId); + return this; + } + + public String getEhcClusterId() { + return ehcClusterId; + } + + public void setEhcClusterId(String ehcClusterId) { + this.ehcClusterId = ehcClusterId; + } + + public CreateInstanceRequest withEhcClusterId(String ehcClusterId) { + this.setEhcClusterId(ehcClusterId); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceResponse.java new file mode 100644 index 00000000..f0115a7a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * The response for CreateInstanceRequest. + */ +@Data +public class CreateInstanceResponse extends AbstractBceResponse { + /** + * List of id of instances created. + */ + private List instanceIds; + + private List warningList; + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + } + + @Override + public String toString() { + return "CreateInstanceResponse{" + + "instanceIds=" + instanceIds + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/DeleteEhcClusterRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/DeleteEhcClusterRequest.java new file mode 100644 index 00000000..2c5e670f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/DeleteEhcClusterRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class DeleteEhcClusterRequest extends AbstractBceRequest { + /** + * List of id of ehcCluster. + */ + private List ehcClusterIdList; + + public DeleteEhcClusterRequest withEhcClusterIdList(List ehcClusterIdList) { + this.ehcClusterIdList = ehcClusterIdList; + return this; + } + + @Override + public DeleteEhcClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/DeleteInstanceDeploysetRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/DeleteInstanceDeploysetRequest.java new file mode 100644 index 00000000..94984a78 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/DeleteInstanceDeploysetRequest.java @@ -0,0 +1,42 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import java.util.List; + +public class DeleteInstanceDeploysetRequest extends AbstractBceRequest { + private String deployId; + private List instanceIdList; + + public String getDeployId() { + return deployId; + } + + public void setDeployId(String deployId) { + this.deployId = deployId; + } + + public List getInstanceIdList() { + return instanceIdList; + } + + public void setInstanceIdList(List instanceIdList) { + this.instanceIdList = instanceIdList; + } + + public DeleteInstanceDeploysetRequest withDeployId(String deployId) { + this.deployId = deployId; + return this; + } + + public DeleteInstanceDeploysetRequest withInstanceIdList(List instanceIdList) { + this.instanceIdList = instanceIdList; + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/DeleteRecycledInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/DeleteRecycledInstanceRequest.java new file mode 100644 index 00000000..c06aaa02 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/DeleteRecycledInstanceRequest.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class DeleteRecycledInstanceRequest extends AbstractBceRequest { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/DescribeEhcClusterListRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/DescribeEhcClusterListRequest.java new file mode 100644 index 00000000..5b32bcd0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/DescribeEhcClusterListRequest.java @@ -0,0 +1,44 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class DescribeEhcClusterListRequest extends AbstractBceRequest { + /** + * List of id of ehcCluster. + */ + private List ehcClusterIdList; + /** + * List of name of ehcCluster. + */ + private List nameList; + /** + * the name of available zone + */ + private String zoneName; + + public DescribeEhcClusterListRequest withEhcClusterIdList(List ehcClusterIdList) { + this.ehcClusterIdList = ehcClusterIdList; + return this; + } + + public DescribeEhcClusterListRequest withNameList(List nameList) { + this.nameList = nameList; + return this; + } + + public DescribeEhcClusterListRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + @Override + public DescribeEhcClusterListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/DescribeEhcClusterListResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/DescribeEhcClusterListResponse.java new file mode 100644 index 00000000..6b51a8e3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/DescribeEhcClusterListResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class DescribeEhcClusterListResponse extends AbstractBceResponse { + /** + * List of instance info + */ + private List ehcClusters; + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/EhcCluster.java b/src/main/java/com/baidubce/services/bcc/model/instance/EhcCluster.java new file mode 100644 index 00000000..c6cf746e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/EhcCluster.java @@ -0,0 +1,38 @@ +package com.baidubce.services.bcc.model.instance; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class EhcCluster { + /** + * The id of ehcCluster. + */ + private String ehcClusterId; + /** + * The name of the ehcCluster. + */ + private String name; + /** + * The description of the instance. + */ + private String description; + /** + * the name of available zone + */ + private String zoneName; + /** + * The time when the instance was created + */ + private Date createdTime; + /** + * List of id of instances created. + */ + private List instanceIds; + /** + * List of id of reserved created. + */ + private List reservedInstanceIds; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/FpgaCardType.java b/src/main/java/com/baidubce/services/bcc/model/instance/FpgaCardType.java new file mode 100644 index 00000000..7e78ae7d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/FpgaCardType.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +/** + * The optional fpga card type for fpga instance. + */ +public enum FpgaCardType { + // fpga card of xilinx ku115 + KU115; + + public static boolean isExists(FpgaCardType fpgaCardType) { + if (null == fpgaCardType) { + return false; + } + for (FpgaCardType cardType : values()) { + if (cardType == fpgaCardType) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/GetBidInstancePriceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/GetBidInstancePriceRequest.java new file mode 100644 index 00000000..d0e78896 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/GetBidInstancePriceRequest.java @@ -0,0 +1,508 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.CreateCdsModel; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for getting bid instance price. + */ +public class GetBidInstancePriceRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + * When creating the storage optimized instance, one ephemeral disk must be created together. + */ + @JsonIgnore + private String clientToken; + + /** + * The parameter to specified which kind of instance to be queried, there is default value when null. + * see all of supported instance type in {@link com.baidubce.services.bcc.model.instance.InstanceType} + */ + private String instanceType; + + /** + * The parameter to specified the cpu core to the instance which is to be queried. + */ + private int cpuCount; + + /** + * The parameter to specified the capacity of memory in GB to the instance which is to be queried. + */ + private int memoryCapacityInGB; + + /** + * The parameter to specify the root disk size in GB.The root disk excludes the system disk, available is 40-500GB. + */ + private int rootDiskSizeInGb; + + /** + * The parameter to specify the root disk storage type. Default use of HP1 cloud disk. + */ + private String rootDiskStorageType; + + /** + * The optional list of volume detail info to query. + */ + private List createCdsList; + + /** + * The number of instance to query, the default value is 1. + */ + private int purchaseCount = 1; + + /** + * The optional parameter to desc the instance that will be query. + */ + private String name; + + /** + * The optional parameter to specify the password for the instance. + *

+ * If specify the adminPass,the adminPass must be a 8-16 characters String which must + * contains letters,numbers and symbols. The symbols only contains "!@#$%^*()". + * The adminPass will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + *

+ * If not specify the adminPass, it will be specified by an random string. + * See more detail on + * + * BCE API doc + */ + private String adminPass; + + /** + * The id of the keypair + */ + private String keypairId; + + /** + * The id of asp + */ + private String aspId; + + /** + * The id of image,list all available image + * in {@link com.baidubce.services.bcc.BccClient#listImages()} + */ + private String imageId; + + /** + * Specified the bidding model + */ + private String bidModel; + + /** + * Specified the bidding price + */ + private String bidPrice; + + /** + * The optional parameter to specify the bandwidth in Mbps for the instance to be queried. + *

+ * It must among 0 and 200,default value is 0. + * If it's specified to 0, it will get the internal ip address only. + */ + private int networkCapacityInMbps = 0; + + /** + * Indicates whether the tag is bound to all relation instances. + */ + private boolean relationTag; + + /** + * The list of tag to be bonded. + */ + private List tags; + + /** + * specify the securityGroupId of the instance to be queried, optional param + * vpcId of the securityGroupId must be the same as the vpcId of subnetId + * through listSecurityGroups, we can get all securityGroup info at current region + */ + private String securityGroupId; + + /** + * the id of subnet from vpc, optional param, default value is default subnet from default vpc + */ + private String subnetId; + + /** + * the name of available zone, optional param + * through listZones, we can get all available zone info at current region + * e.g. "cn-gz-a" "cn-gz-b" + */ + private String zoneName; + + /** + * Specified the internet charge type + */ + private String internetChargeType; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return GetBidInstancePriceRequest with specific clientToken + */ + public GetBidInstancePriceRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + /** + * Configure instanceType for the request. + * + * @param instanceType The specified Specification to create the instance. + * See more detail on + * + * BCE API doc + * @return GetBidInstancePriceRequest with specific instanceType + */ + public GetBidInstancePriceRequest withInstanceType(String instanceType) { + this.instanceType = instanceType; + return this; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + /** + * Configure cpuCount for the request. + * + * @param cpuCount The parameter to specified the cpu core to the instance which is to be queried. + * @return GetBidInstancePriceRequest with specific cpuCount + */ + public GetBidInstancePriceRequest withCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + return this; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + /** + * Configure memoryCapacityInGB for the request. + * + * @param memoryCapacityInGB The parameter to specified the capacity of memory in GB to the instance + * which is to be queried. + * @return GetBidInstancePriceRequest with specific memoryCapacityInGB + */ + public GetBidInstancePriceRequest withMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + return this; + } + + public int getRootDiskSizeInGb() { + return rootDiskSizeInGb; + } + + public void setRootDiskSizeInGb(int rootDiskSizeInGb) { + this.rootDiskSizeInGb = rootDiskSizeInGb; + } + + /** + * Configure rootDiskSizeInGb for the request. + * + * @param rootDiskSizeInGb The parameter to specify the root disk size in GB. + * The root disk excludes the system disk, available is 40-500GB. + * @return GetBidInstancePriceRequest with specific rootDiskSizeInGb + */ + public GetBidInstancePriceRequest withRootDiskSizeInGb(int rootDiskSizeInGb) { + this.rootDiskSizeInGb = rootDiskSizeInGb; + return this; + } + + public String getRootDiskStorageType() { + return rootDiskStorageType; + } + + public void setRootDiskStorageType(String rootDiskStorageType) { + this.rootDiskStorageType = rootDiskStorageType; + } + + /** + * Configure rootDiskStorageType for the request. + * + * @param rootDiskStorageType The parameter to specify the root disk storage type. + * Default use of HP1 cloud disk. + * @return GetBidInstancePriceRequest with specific rootDiskStorageType + */ + public GetBidInstancePriceRequest withRootDiskStorageType(String rootDiskStorageType) { + this.rootDiskStorageType = rootDiskStorageType; + return this; + } + + public List getCreateCdsList() { + return createCdsList; + } + + public void setCreateCdsList(List createCdsList) { + this.createCdsList = createCdsList; + } + + public GetBidInstancePriceRequest withCreateCdsList(List createCdsList) { + this.createCdsList = createCdsList; + return this; + } + + public int getPurchaseCount() { + return purchaseCount; + } + + public void setPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + } + + public GetBidInstancePriceRequest withPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public GetBidInstancePriceRequest withName(String name) { + this.name = name; + return this; + } + + public String getAdminPass() { + return adminPass; + } + + public void setAdminPass(String adminPass) { + this.adminPass = adminPass; + } + + public GetBidInstancePriceRequest withAdminPass(String adminPass) { + this.adminPass = adminPass; + return this; + } + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + public GetBidInstancePriceRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + public String getAspId() { + return aspId; + } + + public void setAspId(String aspId) { + this.aspId = aspId; + } + + public GetBidInstancePriceRequest withAspId(String aspId) { + this.aspId = aspId; + return this; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public GetBidInstancePriceRequest withImageId(String imageId) { + this.imageId = imageId; + return this; + } + + public String getBidModel() { + return bidModel; + } + + public void setBidModel(String bidModel) { + this.bidModel = bidModel; + } + + public GetBidInstancePriceRequest withBidModel(String bidModel) { + this.bidModel = bidModel; + return this; + } + + public String getBidPrice() { + return bidPrice; + } + + public void setBidPrice(String bidPrice) { + this.bidPrice = bidPrice; + } + + public GetBidInstancePriceRequest withBidPrice(String bidPrice) { + this.bidPrice = bidPrice; + return this; + } + + public int getNetworkCapacityInMbps() { + return networkCapacityInMbps; + } + + public void setNetworkCapacityInMbps(int networkCapacityInMbps) { + this.networkCapacityInMbps = networkCapacityInMbps; + } + + public GetBidInstancePriceRequest withNetworkCapacityInMbps(int networkCapacityInMbps) { + this.networkCapacityInMbps = networkCapacityInMbps; + return this; + } + + public boolean isRelationTag() { + return relationTag; + } + + public void setRelationTag(boolean relationTag) { + this.relationTag = relationTag; + } + + public GetBidInstancePriceRequest withRelationTag(boolean relationTag) { + this.relationTag = relationTag; + return this; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public GetBidInstancePriceRequest withTags(List tags) { + this.tags = tags; + return this; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + public GetBidInstancePriceRequest withSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public GetBidInstancePriceRequest withSubnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public GetBidInstancePriceRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + public String getInternetChargeType() { + return internetChargeType; + } + + public void setInternetChargeType(String internetChargeType) { + this.internetChargeType = internetChargeType; + } + + public GetBidInstancePriceRequest withInternetChargeType(String internetChargeType) { + this.internetChargeType = internetChargeType; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBidInstancePriceRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/GetBidInstancePriceResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/GetBidInstancePriceResponse.java new file mode 100644 index 00000000..0817cd3d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/GetBidInstancePriceResponse.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of getting bid instance price. + */ +public class GetBidInstancePriceResponse extends AbstractBceResponse { + + /** + * The total money + */ + private String money; + + /** + * The count of purchase + */ + private String count; + + /** + * The unit-price + */ + private String perMoney; + + public String getMoney() { + return money; + } + + public void setMoney(String money) { + this.money = money; + } + + public String getCount() { + return count; + } + + public void setCount(String count) { + this.count = count; + } + + public String getPerMoney() { + return perMoney; + } + + public void setPerMoney(String perMoney) { + this.perMoney = perMoney; + } + + @Override + public String toString() { + return "BccPriceResponse{" + + "money=" + money + + ", count=" + count + + ", perMoney=" + perMoney + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceRequest.java new file mode 100644 index 00000000..6bc59a49 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for getting instance detail + */ +public class GetInstanceRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure the instanceId for the request. + * + * @param instanceId The id of instance. + * @return GetInstanceRequest with specified instanceId. + */ + public GetInstanceRequest withInstanceId(String instanceId) { + this.setInstanceId(instanceId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public GetInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceResponse.java new file mode 100644 index 00000000..cea10c4a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.InstanceModel; + +/** + * response for getting instance detail + */ +public class GetInstanceResponse extends AbstractBceResponse { + /** + * An instance detail model contains all of the information of specific instance. + */ + private InstanceModel instance; + + public InstanceModel getInstance() { + return instance; + } + + public void setInstance(InstanceModel instance) { + this.instance = instance; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceVncRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceVncRequest.java new file mode 100644 index 00000000..b472b8b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceVncRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting the instance vnc url. + */ +public class GetInstanceVncRequest extends AbstractBceRequest { + /** + * The id of instance. + */ + private String instanceId; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure request instanceId for the request. + * + * @param instanceId The id of the instance. + * @return GetInstanceVncRequest with specified instanceId. + */ + public GetInstanceVncRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceVncRequest with specified credentials. + */ + @Override + public GetInstanceVncRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceVncResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceVncResponse.java new file mode 100644 index 00000000..efb0978e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceVncResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for GetInstanceVncRequest. + */ +public class GetInstanceVncResponse extends AbstractBceResponse { + + /** + * The url for accessing the instance. + * The vnc url will be available in 10 min and can be used once time. + */ + private String vncUrl; + + public String getVncUrl() { + return vncUrl; + } + + public void setVncUrl(String vncUrl) { + this.vncUrl = vncUrl; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/GpuCardType.java b/src/main/java/com/baidubce/services/bcc/model/instance/GpuCardType.java new file mode 100644 index 00000000..0d90f82b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/GpuCardType.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +/** + * The optional gpu card type for gpu instance. + */ +public enum GpuCardType { + // NVIDIA Tesla P4 + P4, + + // NVIDIA Tesla P40 + P40, + + // NVIDIA Tesla K40 + K40, + + // NVIDIA Deep Learning Development Card + DLCard; + + + public static boolean isExists(GpuCardType gpuCardType) { + if (null == gpuCardType) { + return false; + } + for (GpuCardType cardType : values()) { + if (cardType == gpuCardType) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/InstanceAction.java b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceAction.java new file mode 100644 index 00000000..f641f11a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceAction.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +/** + * The action for operating the instance. + */ +public enum InstanceAction { + /** + * The action to start the instance. + */ + start, + + /** + * The action to stop the instance. + */ + stop, + + /** + * The action to reboot the instance. + */ + reboot, + + /** + * The action to change the admin password of the instance. + */ + changePass, + + /** + * The action to modify the attribute of the instance. + */ + modifyAttribute, + + /** + * The action to rename the bbc instance + */ + rename, + + /** + * The action to modify the desc of the instance. + */ + modifyDesc, + + /** + * The action to rebuild the instance. + */ + rebuild, + + /** + * The action to resize the instance. + */ + resize, + + /** + * The action to bind the instance to specified securitygroup. + */ + bind, + + /** + * The action to unbind the instance from securitygroup. + */ + unbind, + + /** + * The action to purchaseReserved the instance. + */ + purchaseReserved, + + /** + * The action to update bcc desc + */ + updateDesc, + + /** + * The action to change instance to be prepaid. + */ + toPrepay, + + /** + * The action to change the hostname of the instance. + */ + changeHostname +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/InstanceAddIpv6Response.java b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceAddIpv6Response.java new file mode 100644 index 00000000..07fbe5f2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceAddIpv6Response.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +/** + * @Author: lilu24 + * @Date: 2024-06-12 + */ + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class InstanceAddIpv6Response extends AbstractBceResponse { + + private String ipv6Address; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/InstanceIpv6Request.java b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceIpv6Request.java new file mode 100644 index 00000000..fab1af66 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceIpv6Request.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +/** + * @Author: lilu24 + * @Date: 2024-06-12 + */ + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class InstanceIpv6Request extends AbstractBceRequest { + + private String instanceId; + private String ipv6Address; + private boolean reboot; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/InstanceType.java b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceType.java new file mode 100644 index 00000000..632277f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceType.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +/** + * The enum class to enumerate all the supported instance type in SDK. + */ +public enum InstanceType { + /** + * The instance of normal purpose. + */ + N1, + + /** + * The second Enhanced instance of normal purpose for {@link InstanceType#N1}. + */ + N2, + + /** + * The third Enhanced instance of normal purpose using Intel Skylake. + */ + N3, + + /** + * The compute optimized instance. + * See more information on + * + * introduction for Compute optimized BCC + * + */ + C1, + + /** + * The storage optimized instance. + * See more information on + * + * introduction for Storage optimized BCC + * + * When creating the storage optimized instance, one ephemeral disk must be created together. + */ + S1, + + /** + * The gpu instance. + * See more information on + * + * introduction for gpu BCC + * + * When creating the gpu instance, one or more gpu card info must be created. + * More gpu specification see document on + * + * the specification for gpu instance + * + */ + G1, + + /** + * The fpga instance. + * See more information on + * + * introduction for fpga BCC + * + * When creating the fpga instance, one or more fpga card info must be created. + * More fpga specification see document on + * + * the specification for fpga instance + * + */ + F1 + + + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListAvailableResizeSpecRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListAvailableResizeSpecRequest.java new file mode 100644 index 00000000..fd72c5b8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListAvailableResizeSpecRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; +import java.util.List; + +@Data +public class ListAvailableResizeSpecRequest extends AbstractBceRequest { + private String spec; + private String specId; + private String zone; + private List instanceIdList; + + public ListAvailableResizeSpecRequest withSpec(String spec) { + this.spec = spec; + return this; + } + + public ListAvailableResizeSpecRequest withSpecId(String specId) { + this.specId = specId; + return this; + } + + public ListAvailableResizeSpecRequest withZone(String logicalZone) { + this.zone = logicalZone; + return this; + } + + public ListAvailableResizeSpecRequest withInstanceIdList(List instanceIdList) { + this.instanceIdList = instanceIdList; + return this; + } + @Override + public ListAvailableResizeSpecRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListAvailableResizeSpecResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListAvailableResizeSpecResponse.java new file mode 100644 index 00000000..f883ff08 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListAvailableResizeSpecResponse.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.ToString; + +import java.util.List; +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class ListAvailableResizeSpecResponse extends AbstractBceResponse { + private List specList; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListGetInstanceNoChargeRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListGetInstanceNoChargeRequest.java new file mode 100644 index 00000000..7edd076c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListGetInstanceNoChargeRequest.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request fot getting the list of no-charge instance. + */ +public class ListGetInstanceNoChargeRequest extends ListRequest { + + /** + * The identified internal ip of instance. + */ + private String internalIp; + + /** + * The id of the keypair + */ + private String keypairId; + + /** + * the name of available zone + */ + private String zoneName; + + public String getInternalIp() { + return internalIp; + } + + public void setInternalIp(String internalIp) { + this.internalIp = internalIp; + } + + /** + * Configure internalIp for the request. + * + * @param internalIp The internal ip address for accessing the instance. + * @return ListGetInstanceNoChargeRequest with internalIp. + */ + public ListGetInstanceNoChargeRequest withInternalIp(String internalIp) { + this.internalIp = internalIp; + return this; + } + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + /** + * Configure the request with specified keypairId. + * + * @param keypairId The specified keypair id. + * @return ListGetInstanceNoChargeRequest with specified keypairId. + */ + public ListGetInstanceNoChargeRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + /** + * Configure the request with specified zoneName. + * + * @param zoneName The specified zoneName. + * @return ListGetInstanceNoChargeRequest with specified zoneName. + */ + public ListGetInstanceNoChargeRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListGetInstanceNoChargeRequest with specified marker. + */ + @Override + public ListGetInstanceNoChargeRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListGetInstanceNoChargeRequest with specified maxKeys. + */ + @Override + public ListGetInstanceNoChargeRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListGetInstanceNoChargeRequest with credentials. + */ + @Override + public ListGetInstanceNoChargeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceByIdsRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceByIdsRequest.java new file mode 100644 index 00000000..546dc4d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceByIdsRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; + +import java.util.List; + +/** + * request model to query instance list + */ +public class ListInstanceByIdsRequest extends ListRequest { + + /** + * instance id list + */ + List instanceIds; + + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + } + + public ListInstanceByIdsRequest withInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceEnisRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceEnisRequest.java new file mode 100644 index 00000000..3046fed3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceEnisRequest.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class ListInstanceEnisRequest extends AbstractBceRequest { + private String instanceId; + + public ListInstanceEnisRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + @Override + public ListInstanceEnisRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceEnisResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceEnisResponse.java new file mode 100644 index 00000000..1a5aac50 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceEnisResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bcc.model.instance; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.NicInfo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.ToString; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class ListInstanceEnisResponse extends AbstractBceResponse { + private List enis; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceSpecsRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceSpecsRequest.java new file mode 100644 index 00000000..0492a0c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceSpecsRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list all of the available specifications of creating instance. + */ +public class ListInstanceSpecsRequest extends AbstractBceRequest { + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListInstanceSpecsRequest with specified BceCredentials + */ + @Override + public ListInstanceSpecsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceSpecsResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceSpecsResponse.java new file mode 100644 index 00000000..1bf4b1e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceSpecsResponse.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.InstanceTypeModel; + +import java.util.List; + +/** + * The response for getting all of Specifications. + */ +public class ListInstanceSpecsResponse extends AbstractBceResponse { + + /** + * List of Specifications which will be used to purchasing new instance. + */ + private List instanceTypes; + + public List getInstanceTypes() { + return instanceTypes; + } + + public void setInstanceTypes(List instanceTypes) { + this.instanceTypes = instanceTypes; + } + + @Override + public String toString() { + return "ListInstanceSpecsResponse{" + + "instanceTypes=" + instanceTypes + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesRequest.java new file mode 100644 index 00000000..8a5bb857 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesRequest.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * request model to query instance list + */ +public class ListInstancesRequest extends ListRequest { + /** + * The identified internal ip of instance. + */ + private String internalIp; + + /** + * specified id of dedicated host which instance be placed + */ + private String dedicatedHostId; + + /** + * the name of available zone + */ + private String zoneName; + + /** + * The id of the keypair + */ + private String keypairId; + + /** + * whether the instance is auto renew or not + */ + private boolean autoRenew; + + /** + * The id of ehcCluster. + */ + private String ehcClusterId; + + public String getInternalIp() { + return internalIp; + } + + public void setInternalIp(String internalIp) { + this.internalIp = internalIp; + } + + public String getDedicatedHostId() { + return dedicatedHostId; + } + + public void setDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public ListInstancesRequest withDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + return this; + } + + public ListInstancesRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + /** + * Configure internalIp for the request. + * + * @param internalIp The internal ip address for accessing the instance. + * @return ListInstancesRequest with internalIp. + */ + public ListInstancesRequest withInternalIp(String internalIp) { + this.internalIp = internalIp; + return this; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListInstancesRequest with specified marker. + */ + @Override + public ListInstancesRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListInstancesRequest with specified maxKeys. + */ + @Override + public ListInstancesRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + /** + * Configure the request with specified keypairId. + * @param keypairId The specified keypair id. + * @return ListInstancesRequest with specified keypairId. + */ + public ListInstancesRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + public boolean isAutoRenew() { + return autoRenew; + } + + public void setAutoRenew(boolean autoRenew) { + this.autoRenew = autoRenew; + } + + /** + * Configure the request with specified autoRenew. + * @param autoRenew Whether the instance is auto renew or not. If true, it means the instance + * is auto renew. + * @return ListInstancesRequest with specified autoRenew. + */ + public ListInstancesRequest withAutoRenew(boolean autoRenew) { + this.autoRenew = autoRenew; + return this; + } + + public String getEhcClusterId() { + return ehcClusterId; + } + + public void setEhcClusterId(String ehcClusterId) { + this.ehcClusterId = ehcClusterId; + } + + public ListInstancesRequest withEhcClusterId(String ehcClusterId) { + this.ehcClusterId = ehcClusterId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListInstancesRequest with credentials. + */ + @Override + public ListInstancesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesResponse.java new file mode 100644 index 00000000..666e55ab --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.ListResponse; +import com.baidubce.services.bcc.model.InstanceModel; +import lombok.ToString; + +import java.util.List; + +/** + * response model for query instance list + */ +@ToString +public class ListInstancesResponse extends ListResponse { + + /** + * List of instance info + */ + private List instances; + + public List getInstances() { + return instances; + } + + public void setInstances(List instances) { + this.instances = instances; + } + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListRecycleInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListRecycleInstanceRequest.java new file mode 100644 index 00000000..8294bd6c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListRecycleInstanceRequest.java @@ -0,0 +1,58 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonFormat.Shape; +import lombok.Data; + +import java.util.Date; + +@Data +public class ListRecycleInstanceRequest extends ListRequest { + private String instanceId; + private String name; + private PaymentTiming paymentTiming; + @JsonFormat( + shape = Shape.STRING, + pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", + timezone = "Asia/Shanghai" + ) + private Date recycleBegin; + @JsonFormat( + shape = Shape.STRING, + pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", + timezone = "Asia/Shanghai" + ) + private Date recycleEnd; + + public ListRecycleInstanceRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public ListRecycleInstanceRequest withName(String name) { + this.name = name; + return this; + } + + public ListRecycleInstanceRequest withPaymentTiming(PaymentTiming paymentTiming) { + this.paymentTiming = paymentTiming; + return this; + } + + public ListRecycleInstanceRequest withRecycleBegin(Date recycleBegin) { + this.recycleBegin = recycleBegin; + return this; + } + + public ListRecycleInstanceRequest withRecycleEnd(Date recycleEnd) { + this.recycleEnd = recycleEnd; + return this; + } + @Override + public ListRecycleInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ListRecycleInstanceResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/ListRecycleInstanceResponse.java new file mode 100644 index 00000000..bfb47f6b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListRecycleInstanceResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.ListResponse; +import com.baidubce.services.bcc.model.RecycleInstanceModel; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.ToString; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +@Data +public class ListRecycleInstanceResponse extends ListResponse { + private List instances; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ModifyEhcClusterRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyEhcClusterRequest.java new file mode 100644 index 00000000..19d2ea32 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyEhcClusterRequest.java @@ -0,0 +1,42 @@ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class ModifyEhcClusterRequest extends AbstractBceRequest { + /** + * The id of ehcCluster. + */ + private String ehcClusterId; + /** + * The new value for ehcCluster's name. + */ + private String name; + /** + * The new value for ehcCluster's description. + */ + private String description; + + public ModifyEhcClusterRequest withEhcClusterId(String ehcClusterId) { + this.ehcClusterId = ehcClusterId; + return this; + } + + public ModifyEhcClusterRequest withName(String name) { + this.name = name; + return this; + } + + public ModifyEhcClusterRequest withDescription(String description) { + this.description = description; + return this; + } + + @Override + public ModifyEhcClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceAttributesRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceAttributesRequest.java new file mode 100644 index 00000000..51806ce5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceAttributesRequest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for modifying the attribute of the instance. + */ +public class ModifyInstanceAttributesRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The new value for instance's name. + */ + private String name; + + private Integer netEthQueueCount; + + private Boolean enableJumboFrame; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of the instance. + * @return ModifyInstanceAttributesRequest with specified instanceId. + */ + public ModifyInstanceAttributesRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Configure name for the request. + * + * @param name The new value for instance's name. + * @return ModifyInstanceAttributesRequest with name. + */ + public ModifyInstanceAttributesRequest withName(String name) { + this.name = name; + return this; + } + + public Integer getNetEthQueueCount() { + return netEthQueueCount; + } + + public void setNetEthQueueCount(Integer netEthQueueCount) { + this.netEthQueueCount = netEthQueueCount; + } + + public ModifyInstanceAttributesRequest withNetEthQueueCount(Integer netEthQueueCount) { + this.netEthQueueCount = netEthQueueCount; + return this; + } + + public Boolean getEnableJumboFrame() { + return enableJumboFrame; + } + + public void setEnableJumboFrame(Boolean enableJumboFrame) { + this.enableJumboFrame = enableJumboFrame; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ModifyInstanceAttributesRequest with credentials. + */ + @Override + public ModifyInstanceAttributesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceDescRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceDescRequest.java new file mode 100644 index 00000000..88b7b008 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceDescRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for modifying the desc of the instance. + */ +public class ModifyInstanceDescRequest extends AbstractBceRequest { + /** + * The id of instance. + */ + private String instanceId; + + /** + * The new value for instance's desc. + */ + private String desc; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of the instance. + * @return ModifyInstanceDescRequest with specified instanceId. + */ + public ModifyInstanceDescRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + /** + * Configure desc for the request. + * + * @param desc The new value for instance's desc. + * @return ModifyInstanceAttributesRequest with desc. + */ + public ModifyInstanceDescRequest withDesc(String desc) { + this.desc = desc; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ModifyInstanceAttributesRequest with credentials. + */ + @Override + public ModifyInstanceDescRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceHostnameRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceHostnameRequest.java new file mode 100644 index 00000000..49070805 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceHostnameRequest.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * request for changing the instance with a new hostname. + */ +public class ModifyInstanceHostnameRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The optional parameter to desc the hostname of instance that will be created. + */ + private String hostname; + + /** + * Indicates whether automatic reboot + */ + private boolean isReboot; + + + /** + * Indicates whether open hostname domain + */ + @JsonProperty("isOpenHostnameDomain") + private boolean isOpenHostnameDomain; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of instance. + * @return ModifyInstancePasswordRequest with instanceId. + */ + public ModifyInstanceHostnameRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public ModifyInstanceHostnameRequest withHostname(String hostname) { + this.hostname = hostname; + return this; + } + + public boolean isReboot() { + return isReboot; + } + + public void setReboot(boolean reboot) { + isReboot = reboot; + } + + public ModifyInstanceHostnameRequest withIsReboot(boolean isReboot) { + this.isReboot = isReboot; + return this; + } + + @JsonIgnore + public boolean isOpenHostnameDomain() { + return isOpenHostnameDomain; + } + + public void setOpenHostnameDomain(boolean isOpenHostnameDomain) { + this.isOpenHostnameDomain = isOpenHostnameDomain; + } + + public ModifyInstanceHostnameRequest withIsOpenHostnameDomain(boolean isOpenHostnameDomain) { + this.isOpenHostnameDomain = isOpenHostnameDomain; + return this; + } + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ModifyInstancePasswordRequest with credentials. + */ + @Override + public ModifyInstanceHostnameRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstancePasswordRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstancePasswordRequest.java new file mode 100644 index 00000000..6c323a68 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstancePasswordRequest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * request for changing the instance with a new password. + */ +public class ModifyInstancePasswordRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * An 8-16 characters String which must contains letters,numbers and symbols. + * The symbols only contains "!@#$%^*()". + * + * The new password will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * + * See more detail on + * + * BCE API doc + */ + private String adminPass; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of instance. + * @return ModifyInstancePasswordRequest with instanceId. + */ + public ModifyInstancePasswordRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getAdminPass() { + return adminPass; + } + + public void setAdminPass(String adminPass) { + this.adminPass = adminPass; + } + + /** + * Configure adminPass for the request. + * + * @param adminPass The new password string. + * An 8-16 characters String which must contains letters,numbers and symbols . + * The symbols only contains "!@#$%^*()". + * The adminPass will be encrypted in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * See more detail on + * + * BCE API doc + * @return ModifyInstancePasswordRequest with new adminPass. + */ + public ModifyInstancePasswordRequest withAdminPass(String adminPass) { + this.adminPass = adminPass; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ModifyInstancePasswordRequest with credentials. + */ + @Override + public ModifyInstancePasswordRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/PaymentTiming.java b/src/main/java/com/baidubce/services/bcc/model/instance/PaymentTiming.java new file mode 100644 index 00000000..e4e39c46 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/PaymentTiming.java @@ -0,0 +1,6 @@ +package com.baidubce.services.bcc.model.instance; + +public enum PaymentTiming { + Prepaid, + Postpaid +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/PurchaseReservedInstanceRequeset.java b/src/main/java/com/baidubce/services/bcc/model/instance/PurchaseReservedInstanceRequeset.java new file mode 100644 index 00000000..52ab2c18 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/PurchaseReservedInstanceRequeset.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for renewing the instance. + */ +public class PurchaseReservedInstanceRequeset extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The detail model to specify the billing. + */ + private Billing billing; + + /** + * The flag of instance related renew. + * see all of supported flag type in {@link com.baidubce.services.bcc.model.instance.RelatedRenewFlagType} + */ + private String relatedRenewFlag; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return PurchaseReservedInstanceRequeset with specific clientToken + */ + public PurchaseReservedInstanceRequeset withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of the instance. + * @return PurchaseReservedInstanceRequeset with instanceId. + */ + public PurchaseReservedInstanceRequeset withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + /** + * Configure billing for the request. + * + * @param billing The detail model to specify the billing. + * @return PurchaseReservedInstanceRequeset with specific billing + */ + public PurchaseReservedInstanceRequeset withBilling(Billing billing) { + this.billing = billing; + return this; + } + + public String getRelatedRenewFlag() { + return relatedRenewFlag; + } + + public void setRelatedRenewFlag(String relatedRenewFlag) { + this.relatedRenewFlag = relatedRenewFlag; + } + + /** + * Configure relatedRenewFlag for the request. + * see all of supported flag type in {@link com.baidubce.services.bcc.model.instance.RelatedRenewFlagType} + * + * @param relatedRenewFlag The flag of instance related renew. + * @return PurchaseReservedInstanceRequeset with specific relatedRenewFlag + */ + public PurchaseReservedInstanceRequeset withRelatedRenewFlag(String relatedRenewFlag) { + this.relatedRenewFlag = relatedRenewFlag; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return PurchaseReservedInstanceRequeset with credentials. + */ + @Override + public PurchaseReservedInstanceRequeset withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/PurchaseReservedInstanceResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/PurchaseReservedInstanceResponse.java new file mode 100644 index 00000000..e02e0f65 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/PurchaseReservedInstanceResponse.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for renewing the instance. + */ +public class PurchaseReservedInstanceResponse extends AbstractBceResponse { + + /** + * The id of the order. + */ + private String orderId; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + @Override + public String toString() { + return "PurchaseReservedInstanceResponse{" + + "orderId=" + orderId + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/RebootInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/RebootInstanceRequest.java new file mode 100644 index 00000000..dd7702ad --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/RebootInstanceRequest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for rebooting the instance. + */ +public class RebootInstanceRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The option param to reboot the instance forcibly, default value is false. + * If true, it will stop the instance just like power off immediately + * and it may result int losing important data which have not written to disk. + */ + private boolean forceStop = false; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of the instance. + * @return RebootInstanceRequest with instanceId. + */ + public RebootInstanceRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + + public boolean isForceStop() { + return forceStop; + } + + public void setForceStop(boolean forceStop) { + this.forceStop = forceStop; + } + + /** + * Configure forceStop for the request. + * + * @param forceStop The option param to reboot the instance forcibly, default value is false. + * If true, it will stop the instance just like power off immediately + * and it may result int losing important data which have not written to disk. + * @return RebootInstanceRequest with forceStop. + */ + public RebootInstanceRequest withForceStop(boolean forceStop) { + this.forceStop = forceStop; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return RebootInstanceRequest with credentials. + */ + @Override + public RebootInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/RebuildBatchInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/RebuildBatchInstanceRequest.java new file mode 100644 index 00000000..e3bc926c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/RebuildBatchInstanceRequest.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * The request for rebuilding the instance, you adminPass is needed. + */ +public class RebuildBatchInstanceRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + private List instanceIds; + + /** + * The id of image. + */ + private String imageId; + + /** + * The id of the keypair + */ + private String keypairId; + + /** + * The admin password to login the instance. + * + * The admin password to login the instance. + * The adminPass will be encrypt in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * See more detail on + * + * BCE API doc + */ + private String adminPass; + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceId(List instanceIds) { + this.instanceIds = instanceIds; + } + + public void setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + } + + /** + * Configure instanceIds for the request. + * + * @param instanceIds The id of the instance which will be rebuild. + * @return RebuildBatchInstanceRequest with instanceId. + */ + public RebuildBatchInstanceRequest withInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + return this; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public String getAdminPass() { + return adminPass; + } + + public void setAdminPass(String adminPass) { + this.adminPass = adminPass; + } + + /** + * Configure adminPass for the request. + * + * @param adminPass The admin password to login the instance.It must be encrypt in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey.See more detail on + * + * BCE API doc + * @return RebuildBatchInstanceRequest with adminPass. + */ + public RebuildBatchInstanceRequest withAdminPass(String adminPass) { + this.adminPass = adminPass; + return this; + } + + /** + * Configure imageId for the request. + * + * @param imageId The id of the image which will be used to rebuild the instance. + * @return RebuildBatchInstanceRequest with imageId. + */ + public RebuildBatchInstanceRequest withImageId(String imageId) { + this.imageId = imageId; + return this; + } + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + /** + * Configure keypairId for the request. + * @param keypairId The id of the keypair which will be used to rebuild the instance. + * @return RebuildBatchInstanceRequest with keypairId. + */ + public RebuildBatchInstanceRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return RebuildBatchInstanceRequest with credentials. + */ + @Override + public RebuildBatchInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/RebuildInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/RebuildInstanceRequest.java new file mode 100644 index 00000000..d77ecb2e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/RebuildInstanceRequest.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for rebuilding the instance, you adminPass is needed. + */ +public class RebuildInstanceRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The id of image. + */ + private String imageId; + + /** + * The id of the keypair + */ + private String keypairId; + + /** + * The admin password to login the instance. + * + * The admin password to login the instance. + * The adminPass will be encrypt in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey. + * See more detail on + * + * BCE API doc + */ + private String adminPass; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of the instance which will be rebuild. + * @return RebuildInstanceRequest with instanceId. + */ + public RebuildInstanceRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public String getAdminPass() { + return adminPass; + } + + public void setAdminPass(String adminPass) { + this.adminPass = adminPass; + } + + /** + * Configure adminPass for the request. + * + * @param adminPass The admin password to login the instance.It must be encrypt in AES-128 algorithm + * with the substring of the former 16 characters of user SecretKey.See more detail on + * + * BCE API doc + * @return RebuildInstanceRequest with adminPass. + */ + public RebuildInstanceRequest withAdminPass(String adminPass) { + this.adminPass = adminPass; + return this; + } + + /** + * Configure imageId for the request. + * + * @param imageId The id of the image which will be used to rebuild the instance. + * @return RebuildInstanceRequest with imageId. + */ + public RebuildInstanceRequest withImageId(String imageId) { + this.imageId = imageId; + return this; + } + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + /** + * Configure keypairId for the request. + * @param keypairId The id of the keypair which will be used to rebuild the instance. + * @return RebuildInstanceRequest with keypairId. + */ + public RebuildInstanceRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return RebuildInstanceRequest with credentials. + */ + @Override + public RebuildInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/RelatedRenewFlagType.java b/src/main/java/com/baidubce/services/bcc/model/instance/RelatedRenewFlagType.java new file mode 100644 index 00000000..64b6b2cb --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/RelatedRenewFlagType.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +/** + * The optional flag for instance related renew. + */ +public enum RelatedRenewFlagType { + + /** + * Only renew the prepaid CDS which is associated with the BCC instance. + */ + CDS, + + /** + * Only renew the prepaid EIP which is associated with the BCC instance. + */ + EIP, + + /** + * Only renew the prepaid MKT which is associated with the BCC instance. + */ + MKT, + + /** + * Only renew the prepaid CDS、EIP which are associated with the BCC instance. + */ + CDS_EIP, + + /** + * Only renew the prepaid CDS、MKT which are associated with the BCC instance. + */ + CDS_MKT, + + /** + * Only renew the prepaid EIP、MKT which are associated with the BCC instance. + */ + EIP_MKT, + + /** + * Only renew the prepaid CDS、EIP、MKT which are associated with the BCC instance. + */ + CDS_EIP_MKT; + + public static boolean isExists(RelatedRenewFlagType relatedRenewFlagType) { + if (null == relatedRenewFlagType) { + return false; + } + for (RelatedRenewFlagType unitType : values()) { + if (unitType == relatedRenewFlagType) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ReleaseInstanceByPostRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ReleaseInstanceByPostRequest.java new file mode 100644 index 00000000..c758d2c9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ReleaseInstanceByPostRequest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for releasing the instance by post. + */ +public class ReleaseInstanceByPostRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * Whether to release the EIP and the data disk attached to the instance at the current time + * in the same time. Iftrue, it means release, and the parameters deleteCdsSnapshotFlag works. + * Iffalse, it means not to release, and the parameters deleteCdsSnapshotFlag does not works. + */ + private boolean relatedReleaseFlag; + + /** + * Whether to delete the CDS Snapshot. Iftrue, it means delete. + */ + private boolean deleteCdsSnapshotFlag; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public ReleaseInstanceByPostRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public boolean isRelatedReleaseFlag() { + return relatedReleaseFlag; + } + + public void setRelatedReleaseFlag(boolean relatedReleaseFlag) { + this.relatedReleaseFlag = relatedReleaseFlag; + } + + public ReleaseInstanceByPostRequest withRelatedReleaseFlag(boolean relatedReleaseFlag) { + this.relatedReleaseFlag = relatedReleaseFlag; + return this; + } + + public boolean isDeleteCdsSnapshotFlag() { + return deleteCdsSnapshotFlag; + } + + public void setDeleteCdsSnapshotFlag(boolean deleteCdsSnapshotFlag) { + this.deleteCdsSnapshotFlag = deleteCdsSnapshotFlag; + } + + public ReleaseInstanceByPostRequest withDeleteCdsSnapshotFlag(boolean deleteCdsSnapshotFlag) { + this.deleteCdsSnapshotFlag = deleteCdsSnapshotFlag; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ReleaseInstanceByPostRequest with credentials. + */ + public ReleaseInstanceByPostRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ReleaseInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ReleaseInstanceRequest.java new file mode 100644 index 00000000..31d7345b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ReleaseInstanceRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for releasing instance + */ +public class ReleaseInstanceRequest extends AbstractBceRequest { + /** + * The id of instance. + */ + private String instanceId; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure the instance ID for the request. + * + * @param instanceId The identified of the instance. + * @return ReleaseInstanceRequest with specified instanceId. + */ + public ReleaseInstanceRequest withInstanceId(String instanceId) { + this.setInstanceId(instanceId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ReleaseInstanceRequest with credentials. + */ + @Override + public ReleaseInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ReleaseMultipleInstancesRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ReleaseMultipleInstancesRequest.java new file mode 100644 index 00000000..4285b2b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ReleaseMultipleInstancesRequest.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * The request for releasing the instance by post. + */ +public class ReleaseMultipleInstancesRequest extends AbstractBceRequest { + + /** + * The id of instances. + */ + private List instanceIds; + + /** + * Whether to release the EIP and the data disk attached to the instance at the current time + * in the same time. Iftrue, it means release, and the parameters deleteCdsSnapshotFlag works. + * Iffalse, it means not to release, and the parameters deleteCdsSnapshotFlag does not works. + */ + private boolean relatedReleaseFlag; + + /** + * Whether to delete the CDS Snapshot. Iftrue, it means delete. + */ + private boolean deleteCdsSnapshotFlag; + + /** + * Whether to recycle the bcc. Iftrue, it means recycle. + */ + private boolean bccRecycleFlag; + + /** + * Whether to delete the ENI. Iftrue, it means delete. + */ + private boolean deleteRelatedEnisFlag; + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + } + + public ReleaseMultipleInstancesRequest withInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + return this; + } + + public boolean isRelatedReleaseFlag() { + return relatedReleaseFlag; + } + + public void setRelatedReleaseFlag(boolean relatedReleaseFlag) { + this.relatedReleaseFlag = relatedReleaseFlag; + } + + public ReleaseMultipleInstancesRequest withRelatedReleaseFlag(boolean relatedReleaseFlag) { + this.relatedReleaseFlag = relatedReleaseFlag; + return this; + } + + public boolean isDeleteCdsSnapshotFlag() { + return deleteCdsSnapshotFlag; + } + + public void setDeleteCdsSnapshotFlag(boolean deleteCdsSnapshotFlag) { + this.deleteCdsSnapshotFlag = deleteCdsSnapshotFlag; + } + + public ReleaseMultipleInstancesRequest withDeleteCdsSnapshotFlag(boolean deleteCdsSnapshotFlag) { + this.deleteCdsSnapshotFlag = deleteCdsSnapshotFlag; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ReleaseInstanceByPostRequest with credentials. + */ + public ReleaseMultipleInstancesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public boolean isBccRecycleFlag() { + return bccRecycleFlag; + } + + public void setBccRecycleFlag(boolean bccRecycleFlag) { + this.bccRecycleFlag = bccRecycleFlag; + } + + public ReleaseMultipleInstancesRequest withBccRecycleFlag(boolean bccRecycleFlag) { + this.bccRecycleFlag = bccRecycleFlag; + return this; + } + + public boolean isDeleteRelatedEnisFlag() { + return deleteRelatedEnisFlag; + } + + public void setDeleteRelatedEnisFlag(boolean deleteRelatedEnisFlag) { + this.deleteRelatedEnisFlag = deleteRelatedEnisFlag; + } + + public ReleaseMultipleInstancesRequest withDeleteRelatedEnisFlag(boolean deleteRelatedEnisFlag) { + this.deleteRelatedEnisFlag = deleteRelatedEnisFlag; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ReleasePrepaidInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ReleasePrepaidInstanceRequest.java new file mode 100644 index 00000000..b8bb4142 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ReleasePrepaidInstanceRequest.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for releasing instance + */ +public class ReleasePrepaidInstanceRequest extends AbstractBceRequest { + /** + * The id of instances. + */ + private String instanceId; + + /** + * Whether to release the EIP and the data disk attached to the instance at the current time + * in the same time. Iftrue, it means release, and the parameters deleteCdsSnapshotFlag works. + * Iffalse, it means not to release, and the parameters deleteCdsSnapshotFlag does not works. + */ + private boolean relatedReleaseFlag; + + /** + * Whether to delete the CDS Snapshot. Iftrue, it means delete. + */ + private boolean deleteCdsSnapshotFlag; + + /** + * Whether to delete the ENI. Iftrue, it means delete. + */ + private boolean deleteRelatedEnisFlag; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + + public ReleasePrepaidInstanceRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public boolean isRelatedReleaseFlag() { + return relatedReleaseFlag; + } + + public void setRelatedReleaseFlag(boolean relatedReleaseFlag) { + this.relatedReleaseFlag = relatedReleaseFlag; + } + + public ReleasePrepaidInstanceRequest withRelatedReleaseFlag(boolean relatedReleaseFlag) { + this.relatedReleaseFlag = relatedReleaseFlag; + return this; + } + + public boolean isDeleteCdsSnapshotFlag() { + return deleteCdsSnapshotFlag; + } + + public void setDeleteCdsSnapshotFlag(boolean deleteCdsSnapshotFlag) { + this.deleteCdsSnapshotFlag = deleteCdsSnapshotFlag; + } + + public ReleasePrepaidInstanceRequest withDeleteCdsSnapshotFlag(boolean deleteCdsSnapshotFlag) { + this.deleteCdsSnapshotFlag = deleteCdsSnapshotFlag; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ReleaseInstanceByPostRequest with credentials. + */ + public ReleasePrepaidInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + + public boolean isDeleteRelatedEnisFlag() { + return deleteRelatedEnisFlag; + } + + public void setDeleteRelatedEnisFlag(boolean deleteRelatedEnisFlag) { + this.deleteRelatedEnisFlag = deleteRelatedEnisFlag; + } + + public ReleasePrepaidInstanceRequest withDeleteRelatedEnisFlag(boolean deleteRelatedEnisFlag) { + this.deleteRelatedEnisFlag = deleteRelatedEnisFlag; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ReleasePrepaidInstanceResponse.java b/src/main/java/com/baidubce/services/bcc/model/instance/ReleasePrepaidInstanceResponse.java new file mode 100644 index 00000000..7692cdbe --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ReleasePrepaidInstanceResponse.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import java.util.List; + +/** + * The response of changing the instance payment to prepaid. + */ +public class ReleasePrepaidInstanceResponse extends AbstractBceResponse { + /** + * Details of failed resource release. + */ + private InstanceDeleteResultModel successResources; + /** + * Details of successfully released resources. + */ + private InstanceDeleteResultModel failResources; + /** + * Instance release result identifier. Iftrue, Release successful. + */ + private Boolean instanceRefundFlag ; + + public InstanceDeleteResultModel getSuccessResources() { + return successResources; + } + + public void setSuccessResources(InstanceDeleteResultModel successResources) { + this.successResources = successResources; + } + + public InstanceDeleteResultModel getFailResources() { + return failResources; + } + + public void setFailResources(InstanceDeleteResultModel failResources) { + this.failResources = failResources; + } + + public boolean isInstanceRefundFlag() { + return instanceRefundFlag; + } + + public void setInstanceRefundFlag(boolean instanceRefundFlag) { + this.instanceRefundFlag = instanceRefundFlag; + } + + @Override + public String toString() { + return "ReleasePrepaidInstanceResponse{" + + "successResources=" + successResources + + ", failResources=" + failResources + + ", instanceRefundFlag=" + instanceRefundFlag + + ", metadata=" + metadata + + '}'; + } + + static class InstanceDeleteResultModel { + /** + * instanceId. + */ + private String instanceId ; + /** + * eip. + */ + private String eip ; + /** + * instance snapshotId list. + */ + private List insnapIds; + /** + * snapshotId list. + */ + private List snapshotIds; + /** + * volumeId list + */ + private List volumeIds; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + public List getInsnapIds() { + return insnapIds; + } + + public void setInsnapIds(List insnapIds) { + this.insnapIds = insnapIds; + } + + public List getSnapshotIds() { + return snapshotIds; + } + + public void setSnapshotIds(List snapshotIds) { + this.snapshotIds = snapshotIds; + } + + public List getVolumeIds() { + return volumeIds; + } + + public void setVolumeIds(List volumeIds) { + this.volumeIds = volumeIds; + } + + + @Override + public String toString() { + return "InstanceDeleteResultModel{" + + "instanceId='" + instanceId + '\'' + + ", eip='" + eip + '\'' + + ", insnapIds=" + insnapIds + + ", snapshotIds=" + snapshotIds + + ", volumeIds=" + volumeIds + + '}'; + } + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/ResizeInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ResizeInstanceRequest.java new file mode 100644 index 00000000..aaf39f74 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ResizeInstanceRequest.java @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.volume.EphemeralDisk; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for resizing instance. + */ +public class ResizeInstanceRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The spec of instance + */ + private String spec; + + /** + * The parameter of specified the cpu core to resize the instance. + */ + private int cpuCount; + + /** + * The parameter of specified the capacity of memory in GB to resize the instance. + */ + private int memoryCapacityInGB; + + + /** + * The parameter of ephemeral disk capacity. Currently, this parameter only supports the DCC instances + * of storage type. And the capacity will be deducted from the corresponding capacity of the DCC flavor. + */ + private List ephemeralDisks; + + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure the instanceId for the request. + * + * @param instanceId The id of instance. + * @return ResizeInstanceRequest with specific instanceId. + */ + public ResizeInstanceRequest withInstanceId(String instanceId) { + this.setInstanceId(instanceId); + return this; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public ResizeInstanceRequest withSpec(String spec) { + this.setSpec(spec); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return ResizeInstanceRequest with specific clientToken + */ + public ResizeInstanceRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + /** + * Configure request cpuCount for the request. + * + * @param cpuCount The parameter of specified the cpu core to resize the instance. + * @return ResizeInstanceRequest with cpuCount. + */ + public ResizeInstanceRequest withCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + return this; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + /** + * Configure request memoryCapacityInGB for the request. + * + * @param memoryCapacityInGB The parameter of specified the capacity of memory in GB to resize the instance. + * @return ResizeInstanceRequest with memoryCapacityInGB. + */ + public ResizeInstanceRequest withMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + return this; + } + + public List getEphemeralDisks() { + return ephemeralDisks; + } + + public void setEphemeralDisks(List ephemeralDisks) { + this.ephemeralDisks = ephemeralDisks; + } + + /** + * Configure request ephemeralDisks for the request. + * + * @param ephemeralDisks The parameter of ephemeral disk capacity. Currently, this parameter only supports + * the DCC instances of storage type. And the capacity will be deducted from + * the corresponding capacity of the DCC flavor. + * @return ResizeInstanceRequest with ephemeralDisks. + */ + public ResizeInstanceRequest withEphemeralDisks(List ephemeralDisks) { + this.ephemeralDisks = ephemeralDisks; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ResizeInstanceRequest with credentials. + */ + @Override + public ResizeInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/SpecIdPrice.java b/src/main/java/com/baidubce/services/bcc/model/instance/SpecIdPrice.java new file mode 100644 index 00000000..317e9816 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/SpecIdPrice.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import java.util.List; + +public class SpecIdPrice { + private String specId; + private List specPrices; + + public String getSpecId() { + return specId; + } + + public void setSpecId(String specId) { + this.specId = specId; + } + + public List getSpecPrices() { + return specPrices; + } + + public void setSpecPrices(List specPrices) { + this.specPrices = specPrices; + } + + @Override + public String toString() { + return "SpecIdPrice{" + + "specId='" + specId + '\'' + + ", specPrices=" + specPrices + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/SpecPrice.java b/src/main/java/com/baidubce/services/bcc/model/instance/SpecPrice.java new file mode 100644 index 00000000..60f3c4f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/SpecPrice.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +public class SpecPrice { + private String spec; + private String specPrice; + private String status; + private String tradePrice; + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public String getSpecPrice() { + return specPrice; + } + + public void setSpecPrice(String specPrice) { + this.specPrice = specPrice; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTradePrice() { + return tradePrice; + } + + public void setTradePrice(String tradePrice) { + this.tradePrice = tradePrice; + } + + @Override + public String toString() { + return "SpecPrice{" + + "spec='" + spec + '\'' + + ", specPrice='" + specPrice + '\'' + + ", status='" + status + '\'' + + ", tradePrice='" + tradePrice + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/StartInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/StartInstanceRequest.java new file mode 100644 index 00000000..14740834 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/StartInstanceRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for starting the instance. + */ +public class StartInstanceRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of instance. + * @return StartInstanceRequest with instanceId. + */ + public StartInstanceRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return StartInstanceRequest with credentials. + */ + @Override + public StartInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/StopInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/StopInstanceRequest.java new file mode 100644 index 00000000..706c17f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/StopInstanceRequest.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for stopping the instance. + */ +public class StopInstanceRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The option param to stop the instance forcibly, default value is false. + * If true, it will stop the instance just like power off immediately + * and it may result int losing important data which have not written to disk. + */ + private boolean forceStop = false; + + /** + * The option param to indicate that whether the instance can be stopped with no charge or not, + * default value is false. If true, it means the instance can be stopped with no charge. + */ + private boolean stopWithNoCharge; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of the instance. + * @return StopInstanceRequest with instanceId. + */ + public StopInstanceRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + + public boolean isForceStop() { + return forceStop; + } + + public void setForceStop(boolean forceStop) { + this.forceStop = forceStop; + } + + /** + * Configure forceStop for the request. + * + * @param forceStop The option param to stop the instance forcibly, default value is false. + * If true, it will stop the instance just like power off immediately + * and it may result int losing important data which have not written to disk. + * @return StopInstanceRequest with forceStop. + */ + public StopInstanceRequest withForceStop(boolean forceStop) { + this.forceStop = forceStop; + return this; + } + + public boolean isStopWithNoCharge() { + return stopWithNoCharge; + } + + public void setStopWithNoCharge(boolean stopWithNoCharge) { + this.stopWithNoCharge = stopWithNoCharge; + } + + /** + * Configure stopWithNoCharge for the request. + * @param stopWithNoCharge The option param to indicate that whether the instance can be stopped + * with no charge or not, default value is false. If true, + * it means the instance can be stopped with no charge. + * @return StopInstanceRequest with stopWithNoCharge. + */ + public StopInstanceRequest withStopWithNoCharge(boolean stopWithNoCharge) { + this.stopWithNoCharge = stopWithNoCharge; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return StopInstanceRequest with credentials. + */ + @Override + public StopInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/UnbindSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/UnbindSecurityGroupRequest.java new file mode 100644 index 00000000..b8741456 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/UnbindSecurityGroupRequest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * request for bind securitygroup to instance + */ +public class UnbindSecurityGroupRequest extends AbstractBceRequest { + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The id of securitygroup. + */ + private String securityGroupId; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + /** + * Configure the securityGroupId for the request. + * + * @param securityGroupId The id of the securitygroup. + * @return UnbindSecurityGroupRequest with specified securityGroupId. + */ + public UnbindSecurityGroupRequest withSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + /** + * Configure the instanceId for the request. + * + * @param instanceId The id of the instance. + * @return UnbindSecurityGroupRequest with specified instanceId. + */ + public UnbindSecurityGroupRequest withInstanceId(String instanceId) { + this.setInstanceId(instanceId); + return this; + } + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UnbindSecurityGroupRequest with credentials. + */ + @Override + public UnbindSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/instance/UnbindTagsRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/UnbindTagsRequest.java new file mode 100644 index 00000000..31d8b92d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/UnbindTagsRequest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.instance; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * request for unbinding tags to specified instance. + */ +public class UnbindTagsRequest extends AbstractBceRequest { + /** + * The id of instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The list of tags to be unbound. + */ + private List changeTags; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public List getChangeTags() { + return changeTags; + } + + public void setChangeTags(List changeTags) { + this.changeTags = changeTags; + } + + /** + * Configure the list of tags to be unbound for the request. + * + * @param changeTags The list of tags to be unbound. + * @return UnbindTagsRequest with specified list of tags to be unbound. + */ + public UnbindTagsRequest withChangeTags(List changeTags) { + this.changeTags = changeTags; + return this; + } + + /** + * Configure the instance ID for the request. + * + * @param instanceId The id of instance which will be used to unbind a list of tags. + * @return UnbindTagsRequest with specified instance id. + */ + public UnbindTagsRequest withInstanceId(String instanceId) { + this.setInstanceId(instanceId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UnbindTagsRequest with credentials. + */ + @Override + public UnbindTagsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairAction.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairAction.java new file mode 100644 index 00000000..6d7200ce --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairAction.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +/** + * The action for operating keypair + */ +public enum KeypairAction { + + /** + * The action to create the keypair. + */ + create, + + /** + * The action to attach the keypair to instances. + */ + attach, + + /** + * The action to detach keypair from instances. + */ + detach, + + /** + * The action to rename the keypair of instances. + */ + rename, + + /** + * The action to update the description keypair of instances. + */ + updateDesc + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairAttachRequest.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairAttachRequest.java new file mode 100644 index 00000000..e4bbc1fd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairAttachRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.ArrayList; +import java.util.List; + +/** + * The request class used for attaching keypair to instances + */ +public class KeypairAttachRequest extends AbstractBceRequest { + + /** + * The short id of the keypair + */ + @JsonIgnore + private String keypairId; + + /** + * The list of instance ids, specify which instances should the keypair been attached to + */ + private List instanceIds; + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + } + + public KeypairAttachRequest addInstance(String instanceId) { + if (null == this.instanceIds) { + this.instanceIds = new ArrayList(); + } + + this.instanceIds.add(instanceId); + return this; + } + + public KeypairAttachRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairCreateRequest.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairCreateRequest.java new file mode 100644 index 00000000..a61758cd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairCreateRequest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request class of keypair creating + */ +public class KeypairCreateRequest extends AbstractBceRequest { + + /** + * The name of the keypair to be created + */ + private String name; + + /** + * The description of the keypair to be created + */ + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public KeypairCreateRequest withName(String name) { + this.name = name; + return this; + } + + public KeypairCreateRequest withDesctiption(String description) { + this.description = description; + return this; + } + + @Override + public String toString() { + return "KeypairCreateRequest{name='" + name + + "', description='" + description + + "'}"; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairCreateResponse.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairCreateResponse.java new file mode 100644 index 00000000..05c681e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairCreateResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response class when creating an keypair. + */ +public class KeypairCreateResponse extends AbstractBceResponse { + + /** + * The keypair been created. + */ + KeypairModel keypair; + + public KeypairModel getKeypair() { + return keypair; + } + + public void setKeypair(KeypairModel keypair) { + this.keypair = keypair; + } + + @Override + public String toString() { + return "KeypairCreateResponse{ keypair=" + keypair + "}"; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairDeleteRequest.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairDeleteRequest.java new file mode 100644 index 00000000..b1dd8797 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairDeleteRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request class used for deleting keypair. + */ +public class KeypairDeleteRequest extends AbstractBceRequest { + + /** + * Specifying the keypair to be deleted. + */ + @JsonIgnore + private String keypairId; + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + public KeypairDeleteRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + @Override + public String toString() { + return "KeypairDeleteRequest{" + keypairId + "}"; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairDetachRequest.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairDetachRequest.java new file mode 100644 index 00000000..194efeb5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairDetachRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * The request class when detaching keypair from instances + */ +public class KeypairDetachRequest extends AbstractBceRequest { + + /** + * keypair id + */ + @JsonIgnore + private String keypairId; + + /** + * The list of instance ids, specify the instances whose keypair will be detached. + */ + private List instanceIds; + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + } + + public KeypairDetachRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + public KeypairDetachRequest addInstance(String instanceId) { + if (this.instanceIds == null) { + this.instanceIds = new ArrayList(); + } + + this.instanceIds.add(instanceId); + return this; + } + + @Override + public String toString() { + return "KeypairDetachRequest{keypairId='" + keypairId + + "', instanceIds=" + Arrays.toString(instanceIds.toArray()) + + "}"; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairDetailRequest.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairDetailRequest.java new file mode 100644 index 00000000..b8f9ac15 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairDetailRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request class used for querying detail information of keypair. + */ +public class KeypairDetailRequest extends AbstractBceRequest { + + /** + * keypair id + */ + @JsonIgnore + private String keypairId; + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + public KeypairDetailRequest withKeypairId(String keypairId) { + this.keypairId = keypairId; + return this; + } + + @Override + public String toString() { + return "KeypairDetailRequest{" + keypairId + "}"; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairImportRequest.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairImportRequest.java new file mode 100644 index 00000000..69a03545 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairImportRequest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request class for importing keypair + */ +public class KeypairImportRequest extends AbstractBceRequest { + + /** + * the name of the keypair to be imported. + */ + private String name; + + /** + * the desctiption of the keypair to be imported. + */ + private String description; + + /** + * the public key to be imported. + */ + private String publicKey; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getPublicKey() { + return publicKey; + } + + public void setPublicKey(String publicKey) { + this.publicKey = publicKey; + } + + + public KeypairImportRequest withName(String name) { + this.name = name; + return this; + } + + public KeypairImportRequest withDescription(String description) { + this.description = description; + return this; + } + + public KeypairImportRequest withPublicKey(String publicKey) { + this.publicKey = publicKey; + return this; + } + + @Override + public String toString() { + return "KeypairImportRequest{name='" + name + + "', description='" + description + + "', publicKey='" + publicKey + "'}"; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairListRequest.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairListRequest.java new file mode 100644 index 00000000..7069a81e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairListRequest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for getting the keypair list. + */ +public class KeypairListRequest extends ListRequest { + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "KeypairListResponse{" + + "maker='" + this.getMarker() + '\'' + + ", maxKeys=" + this.getMaxKeys() + + ", name='" + this.getName() + '\'' + + '}'; + } + + @Override + public KeypairListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairListResponse.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairListResponse.java new file mode 100644 index 00000000..e13b9b28 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairListResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response of getting the keypair list. + */ +public class KeypairListResponse extends ListResponse { + + /** + * The keypairs represent the list of keypair + */ + private List keypairs; + + + public List getKeypairs() { + return keypairs; + } + + public void setKeypairs(List keypairs) { + this.keypairs = keypairs; + } + + @Override + public String toString() { + return "KeypairListResponse{" + + "marker='" + this.getMarker() + '\'' + + ", isTruncated=" + this.getIsTruncated() + + ", nextMarker='" + this.getNextMarker() + '\'' + + ", maxKeys=" + this.getMaxKeys() + + ", keypairs=" + keypairs + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairModel.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairModel.java new file mode 100644 index 00000000..2996e69e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairModel.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import java.util.Date; + +/** + * KeypairModel denotes an keypair been created + */ +public class KeypairModel { + + /** + * The Number of instances which uses this keypair + */ + private int instanceCount; + + /** + * The name of the keypair + */ + private String name; + + /** + * The description of the keypair + */ + private String description; + + /** + * The create time of the keypair + */ + private Date createdTime; + + /** + * Public key of the keypair + */ + private String publicKey; + + /** + * Finger print as its name implies + */ + private String fingerPrint; + + /** + * Private key of the keypair + */ + private String privateKey; + + /** + * The region of the keypair + */ + private String regionId; + + /** + * The id of the keypair + */ + private String keypairId; + + public int getInstanceCount() { + return instanceCount; + } + + public void setInstanceCount(int instanceCount) { + this.instanceCount = instanceCount; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Date createdTime) { + this.createdTime = createdTime; + } + + public String getPublicKey() { + return publicKey; + } + + public void setPublicKey(String publicKey) { + this.publicKey = publicKey; + } + + public String getFingerPrint() { + return fingerPrint; + } + + public void setFingerPrint(String fingerPrint) { + this.fingerPrint = fingerPrint; + } + + public String getPrivateKey() { + return privateKey; + } + + public void setPrivateKey(String privateKey) { + this.privateKey = privateKey; + } + + public String getRegionId() { + return regionId; + } + + public void setRegionId(String regionId) { + this.regionId = regionId; + } + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + @Override + public String toString() { + return "KeypairModel{name='" + name + + "', description='" + description + + "', createdTime='" + createdTime + + "', publicKey='" + publicKey + + "', fingerPrint='" + fingerPrint + + "', privateKey='" + privateKey + + "', regionId='" + regionId + + "', keypairId='" + keypairId + + "', instanceCount=" + instanceCount + + "}"; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairRenameRequest.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairRenameRequest.java new file mode 100644 index 00000000..b89b33d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairRenameRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for renaming the keypair. + */ +public class KeypairRenameRequest extends AbstractBceRequest { + + /** + * The short id of the keypair + */ + @JsonIgnore + private String keypairId; + + /** + * the new name of the keypair to be renamed. + */ + private String name; + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public KeypairRenameRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "KeypairRenameRequest{" + + "keypairId='" + keypairId + '\'' + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairResponse.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairResponse.java new file mode 100644 index 00000000..40db1b40 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The class contains keypair information + */ +public class KeypairResponse extends AbstractBceResponse { + + /** + * The keypair model + */ + private KeypairModel keypair; + + public KeypairModel getKeypair() { + return keypair; + } + + public void setKeypair(KeypairModel keypair) { + this.keypair = keypair; + } + + @Override + public String toString() { + return "KeypairResponse{keypair=" + keypair + "}"; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairUpdateDescRequest.java b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairUpdateDescRequest.java new file mode 100644 index 00000000..c67f9484 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/keypair/KeypairUpdateDescRequest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.keypair; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request fot updating the description of the keypair. + */ +public class KeypairUpdateDescRequest extends AbstractBceRequest { + /** + * The short id of the keypair + */ + @JsonIgnore + private String keypairId; + + /** + * the description of the keypair to be update. + */ + private String description; + + public String getKeypairId() { + return keypairId; + } + + public void setKeypairId(String keypairId) { + this.keypairId = keypairId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "KeypairUpdateDescRequest{" + + "keypairId='" + keypairId + '\'' + + ", description='" + description + '\'' + + '}'; + } + + @Override + public KeypairUpdateDescRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/region/DescribeRegionsRequest.java b/src/main/java/com/baidubce/services/bcc/model/region/DescribeRegionsRequest.java new file mode 100644 index 00000000..a5b807af --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/region/DescribeRegionsRequest.java @@ -0,0 +1,38 @@ +package com.baidubce.services.bcc.model.region; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * The request for getting endpoint of different regions. + */ +@Data +public class DescribeRegionsRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The region + */ + private String region; + + /** + * Configure request credential for the request. + * @param credentials a valid instance of BceCredentials. + * @return DescribeRegionsRequest with credentials. + */ + @Override + public DescribeRegionsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/region/DescribeRegionsResponse.java b/src/main/java/com/baidubce/services/bcc/model/region/DescribeRegionsResponse.java new file mode 100644 index 00000000..aa1dff54 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/region/DescribeRegionsResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcc.model.region; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * The response for DescribeRegionsRequest. + */ +@Data +public class DescribeRegionsResponse extends AbstractBceResponse { + /** + * The list of the model which is region's endpoint detail information. + */ + private List regions; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/region/RegionModel.java b/src/main/java/com/baidubce/services/bcc/model/region/RegionModel.java new file mode 100644 index 00000000..cb05ade9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/region/RegionModel.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bcc.model.region; + +import lombok.Data; + +/** + * The model of region's endpoint detail information + */ +@Data +public class RegionModel { + /** + * The id of region. + */ + private String regionId; + /** + * The name of region. + */ + private String regionName; + /** + * The endpoint of region. + */ + private String regionEndpoint; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/CreateReservedInstanceResponse.java b/src/main/java/com/baidubce/services/bcc/model/reversed/CreateReservedInstanceResponse.java new file mode 100644 index 00000000..65355832 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/CreateReservedInstanceResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcc.model.reversed; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-20 + */ + + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateReservedInstanceResponse extends AbstractBceResponse { + + private List reservedInstanceIds; + + private String orderId; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/CreateReservedInstancesRequest.java b/src/main/java/com/baidubce/services/bcc/model/reversed/CreateReservedInstancesRequest.java new file mode 100644 index 00000000..26e3d1f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/CreateReservedInstancesRequest.java @@ -0,0 +1,62 @@ +package com.baidubce.services.bcc.model.reversed; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-20 + */ + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateReservedInstancesRequest extends AbstractBceRequest { + + + private String reservedInstanceName; + + private String scope; + + private String zoneName; + + private String spec; + + private String offeringType; + + private int instanceCount; + + private int reservedInstanceCount; + + private int reservedInstanceTime; + + private String reservedInstanceTimeUnit; + + private String autoRenewTimeUnit; + + private int autoRenewTime; + + private boolean autoRenew; + + private LocalDateTime effectiveTime; + + private List tags; + + private String ehcClusterId; + + private String ticketId; + + @Override + public CreateReservedInstancesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} + diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/DescribeReservedInstancesRequest.java b/src/main/java/com/baidubce/services/bcc/model/reversed/DescribeReservedInstancesRequest.java new file mode 100644 index 00000000..1d00edaa --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/DescribeReservedInstancesRequest.java @@ -0,0 +1,58 @@ +package com.baidubce.services.bcc.model.reversed; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-20 + */ + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class DescribeReservedInstancesRequest extends AbstractBceRequest { + + private List reservedInstanceIds; + + private String reservedInstanceName; + + private String zoneName; + + private String reservedInstanceStatus; + + private String spec; + + private String offeringType; + + private String osType; + + private String instanceId; + + private String instanceName; + + private Boolean isDeduct; + + private String ehcClusterId; + + /** + * 排序字段 + */ + private String sortKey; + + private String sortDir; + + private String reservedType; + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/DescribeReservedInstancesResponse.java b/src/main/java/com/baidubce/services/bcc/model/reversed/DescribeReservedInstancesResponse.java new file mode 100644 index 00000000..80f420fb --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/DescribeReservedInstancesResponse.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcc.model.reversed; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-20 + */ + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class DescribeReservedInstancesResponse extends AbstractBceResponse { + + @JsonProperty("totalCount") + private Integer totalCount; + + @JsonProperty("reservedInstances") + private List reservedInstances; + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/ModifyReservedInstancesRequest.java b/src/main/java/com/baidubce/services/bcc/model/reversed/ModifyReservedInstancesRequest.java new file mode 100644 index 00000000..a1cceb59 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/ModifyReservedInstancesRequest.java @@ -0,0 +1,44 @@ +package com.baidubce.services.bcc.model.reversed; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-20 + */ + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ModifyReservedInstancesRequest extends AbstractBceRequest { + + + private List reservedInstances; + + @JsonIgnoreProperties(ignoreUnknown = true) + @NoArgsConstructor + @Data + public static class ReservedInstance { + + private String reservedInstanceId; + + private String zoneName; + + + private String reservedInstanceName; + + private String ehcClusterId; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/ModifyReservedInstancesResponse.java b/src/main/java/com/baidubce/services/bcc/model/reversed/ModifyReservedInstancesResponse.java new file mode 100644 index 00000000..e7ed5b1f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/ModifyReservedInstancesResponse.java @@ -0,0 +1,41 @@ +package com.baidubce.services.bcc.model.reversed; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author xubinghao + * @date 2023-02-22 + */ + +/** + * @Author: lilu24 + * @Date: 2024-06-20 + */ + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ModifyReservedInstancesResponse extends AbstractBceResponse { + + private List modifyReservedInstanceOrders; + + @JsonIgnoreProperties(ignoreUnknown = true) + @NoArgsConstructor + @Data + public static class ModifyReservedInstanceOrder { + + private String reservedInstanceId; + + private String orderId; + + private boolean success; + + private String exception; + + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/ReservedInstanceDetail.java b/src/main/java/com/baidubce/services/bcc/model/reversed/ReservedInstanceDetail.java new file mode 100644 index 00000000..261d477d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/ReservedInstanceDetail.java @@ -0,0 +1,66 @@ +package com.baidubce.services.bcc.model.reversed; + +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @Author: lilu24 + * @Date: 2024-06-20 + */ + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ReservedInstanceDetail { + + private String reservedInstanceId; + + private String reservedInstanceUuid; + + private String reservedInstanceName; + + private String scope; + + private String zoneName; + + private String spec; + + private String reservedType; + + private String offeringType; + + private String osType; + + private String reservedInstanceStatus; + + private Integer instanceCount; + + private String instanceId; + + private String instanceName; + + private LocalDateTime effectiveTime; + + private LocalDateTime expireTime; + + private boolean autoRenew; + + private String renewTimeUnit; + + private Integer renewTime; + + private LocalDateTime nextRenewTime; + + private String flavorSubType; + + private List tags; + + @JsonProperty("isNeedEhcCluster") + private boolean isNeedEhcCluster; +} diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/ReservedTagsRequest.java b/src/main/java/com/baidubce/services/bcc/model/reversed/ReservedTagsRequest.java new file mode 100644 index 00000000..e5fd111b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/ReservedTagsRequest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.reversed; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import java.util.List; + +/** + * request for binding tags to specified reserved. + */ +public class ReservedTagsRequest extends AbstractBceRequest { + public List getReservedInstanceIds() { + return reservedInstanceIds; + } + + public void setReservedInstanceIds(List reservedInstanceIds) { + this.reservedInstanceIds = reservedInstanceIds; + } + + /** + * The reserved ids. + */ + private List reservedInstanceIds; + + /** + * The list of tags. + */ + private List changeTags; + + + public List getChangeTags() { + return changeTags; + } + + public void setChangeTags(List changeTags) { + this.changeTags = changeTags; + } + + /** + * Configure the list of tags for the request. + * + * @param changeTags The list of tags. + * @return BindTagsRequest with specified list of tags. + */ + public ReservedTagsRequest withChangeTags(List changeTags) { + this.changeTags = changeTags; + return this; + } + + /** + * Configure the reserved IDs for the request. + * + * @param reservedInstanceIds The reserved ids which will be used to bind a list of tags. + * @return BindTagsRequest with specified instance id. + */ + public ReservedTagsRequest withInstanceIds(List reservedInstanceIds) { + this.reservedInstanceIds = reservedInstanceIds; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public ReservedTagsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/SortDir.java b/src/main/java/com/baidubce/services/bcc/model/reversed/SortDir.java new file mode 100644 index 00000000..46083fc5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/SortDir.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcc.model.reversed; + +import lombok.Getter; + +/** + * 排序 + */ +@Getter +public enum SortDir { + + /** + * 升序 + */ + ASC("asc"), + + /** + * 降序 + */ + DESC("desc"); + + SortDir(String value) { + this.value = value; + } + + private final String value; + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/reversed/SortKey.java b/src/main/java/com/baidubce/services/bcc/model/reversed/SortKey.java new file mode 100644 index 00000000..730cc1d6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/reversed/SortKey.java @@ -0,0 +1,29 @@ +package com.baidubce.services.bcc.model.reversed; + +import lombok.Getter; + +/** + * osType|purchaseCount|effectiveTime|expireTime + * 排序key + */ +@Getter +public enum SortKey { + + osType("os_type"), + + instanceCount("purchase_count"), + + effectiveTime("effective_time"), + + expireTime("expire_time"); + + SortKey(String value) { + this.value = value; + } + + private final String value; + + public String getValue() { + return value; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupRequest.java new file mode 100644 index 00000000..9c493070 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupRequest.java @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.SecurityGroupRuleModel; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for creating new SecurityGroup. + */ +public class CreateSecurityGroupRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The name of SecurityGroup that will be created. + */ + private String name; + + /** + * the id specified in VPC, optional param + */ + private String vpcId; + + /** + * The optional parameter to describe the SecurityGroup that will be created. + */ + private String desc; + + /** + * The list of rules which define how the SecurityGroup works. + */ + private List rules; + + /** + * The list of tags. + */ + private List tags; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return CreateSecurityGroupRequest with specific clientToken + */ + public CreateSecurityGroupRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public CreateSecurityGroupRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + /** + * Configure name for the request. + * + * @param name The name of SecurityGroup that will be created. + * @return CreateSecurityGroupRequest with name. + */ + public CreateSecurityGroupRequest withName(String name) { + this.name = name; + return this; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + /** + * Configure desc for the request. + * + * @param desc The optional parameter to describe the SecurityGroup that will be created. + * @return CreateSecurityGroupRequest with desc. + */ + public CreateSecurityGroupRequest withDesc(String desc) { + this.desc = desc; + return this; + } + + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + } + + /** + * Configure rules for the request. + * + * @param rules The list of rules which define how the SecurityGroup works. + * @return CreateSecurityGroupRequest with rules. + */ + public CreateSecurityGroupRequest withRules(List rules) { + this.rules = rules; + return this; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + /** + * Configure tags for the request. + * + * @param tags The list of tags which define how the SecurityGroup works. + * @return CreateSecurityGroupRequest with tags. + */ + public CreateSecurityGroupRequest withTags(List tags) { + this.tags = tags; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateSecurityGroupRequest with credentials. + */ + @Override + public CreateSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupResponse.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupResponse.java new file mode 100644 index 00000000..fcde45e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupResponse.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.securitygroup; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for CreateSecurityGroupRequest. + */ +public class CreateSecurityGroupResponse extends AbstractBceResponse { + + /** + * The id of securitygroup. + */ + private String securityGroupId; + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + @Override + public String toString() { + return "CreateSecurityGroupResponse{" + + "securityGroupId='" + securityGroupId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/DeleteSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/DeleteSecurityGroupRequest.java new file mode 100644 index 00000000..4684dfd5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/DeleteSecurityGroupRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for deleting the specified SecurityGroup + */ +public class DeleteSecurityGroupRequest extends AbstractBceRequest { + + /** + * The id of securitygroup. + */ + private String securityGroupId; + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + /** + * Configure securityGroupId for the request. + * + * @param securityGroupId The id of securitygroup. + * @return DeleteSecurityGroupRequest with securityGroupId. + */ + public DeleteSecurityGroupRequest withSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteSecurityGroupRequest with credentials. + */ + @Override + public DeleteSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/DeleteSecurityGroupRuleRequest.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/DeleteSecurityGroupRuleRequest.java new file mode 100644 index 00000000..a6a00d02 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/DeleteSecurityGroupRuleRequest.java @@ -0,0 +1,42 @@ +package com.baidubce.services.bcc.model.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +/** + * The request for delete SecurityGroupRule + */ +public class DeleteSecurityGroupRuleRequest extends AbstractBceRequest { + + /** + * The id of the security group rule + */ + private String securityGroupRuleId; + + /** + * Configure security group rule id for the request. + * + * @param securityGroupRuleId The rule id of the security group to be deleted. + * @return DeleteSecurityGroupRuleRequest with security group rule id. + */ + public DeleteSecurityGroupRuleRequest withSecurityGroupRuleId(String securityGroupRuleId) { + this.securityGroupRuleId = securityGroupRuleId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteSecurityGroupRuleRequest with credentials. + */ + @Override + public DeleteSecurityGroupRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/GetSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/GetSecurityGroupRequest.java new file mode 100644 index 00000000..d38a5780 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/GetSecurityGroupRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.bcc.model.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get securityGroup + */ +public class GetSecurityGroupRequest extends AbstractBceRequest { + /** + * The id of securitygroup. + */ + private String securityGroupId; + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + /** + * Configure securityGroupId for the request. + * + * @param securityGroupId The id of securitygroup. + * @return GetSecurityGroupRequest with securityGroupId. + */ + public GetSecurityGroupRequest withSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetSecurityGroupRequest with credentials. + */ + @Override + public GetSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/ListSecurityGroupsRequest.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/ListSecurityGroupsRequest.java new file mode 100644 index 00000000..849f0484 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/ListSecurityGroupsRequest.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for listing the SecurityGroup owned by the user. + */ +public class ListSecurityGroupsRequest extends ListRequest { + + /** + * The id of instance. + * The optional parameter to list the SecurityGroup. + * If it's specified,only the SecurityGroup related to the specified instance will be listed. + */ + private String instanceId; + + /** + * filter by vpcId, optional parameter + */ + private String vpcId; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure the request with specified instanceId. + * @param instanceId The id of instance. + */ + public ListSecurityGroupsRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public ListSecurityGroupsRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListSecurityGroupsRequest with specified marker. + */ + @Override + public ListSecurityGroupsRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListInstancesRequest with specified maxKeys. + */ + @Override + public ListSecurityGroupsRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListSecurityGroupsRequest with credentials. + */ + @Override + public ListSecurityGroupsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/ListSecurityGroupsResponse.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/ListSecurityGroupsResponse.java new file mode 100644 index 00000000..9e64d67b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/ListSecurityGroupsResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.securitygroup; + +import com.baidubce.model.ListResponse; +import com.baidubce.services.bcc.model.SecurityGroupModel; + +import java.util.List; + +/** + * The response for ListSecurityGroupsRequest. + */ +public class ListSecurityGroupsResponse extends ListResponse { + + /** + * The list of SecurityGroup detail model. + */ + private List securityGroups; + + public List getSecurityGroups() { + return securityGroups; + } + + public void setSecurityGroups(List securityGroups) { + this.securityGroups = securityGroups; + } + + @Override + public String toString() { + return "ListSecurityGroupsResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "securityGroups=" + securityGroups + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/SecurityGroupAction.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/SecurityGroupAction.java new file mode 100644 index 00000000..07d56dbb --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/SecurityGroupAction.java @@ -0,0 +1,26 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.securitygroup; + +/** + * The action for operating the security group. + */ +public enum SecurityGroupAction { + /** + * authorizing a security group rule to a security group + */ + authorizeRule, + + /** + * revoking a security group rule from the security group + */ + revokeRule +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/SecurityGroupRuleOperateRequest.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/SecurityGroupRuleOperateRequest.java new file mode 100644 index 00000000..99a90fa6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/SecurityGroupRuleOperateRequest.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.SecurityGroupRuleModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * request model to authorize security group rule + */ +public class SecurityGroupRuleOperateRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the id of security group which will be authorized/revoked to + */ + @JsonIgnore + private String securityGroupId; + + /** + * security group rule info + * through protocol/portRange/direction/sourceIp/sourceGroupId, we can confirmed one rule which will be updated + */ + private SecurityGroupRuleModel rule; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public SecurityGroupRuleOperateRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + public SecurityGroupRuleOperateRequest withSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + public SecurityGroupRuleModel getRule() { + return rule; + } + + public void setRule(SecurityGroupRuleModel rule) { + this.rule = rule; + } + + public SecurityGroupRuleOperateRequest withRule(SecurityGroupRuleModel rule) { + this.rule = rule; + return this; + } + + @Override + public SecurityGroupRuleOperateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/securitygroup/UpdateSecurityGroupRuleRequest.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/UpdateSecurityGroupRuleRequest.java new file mode 100644 index 00000000..09eb86ae --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/UpdateSecurityGroupRuleRequest.java @@ -0,0 +1,66 @@ +package com.baidubce.services.bcc.model.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +/** + * The request for updateSecurityGroupRule + */ +public class UpdateSecurityGroupRuleRequest extends AbstractBceRequest { + + /** + * The id of the security group rule to be updated + */ + private String securityGroupRuleId; + + /** + * The remark of the security group rule + */ + private String remark; + + /** + * The port range of the security group rule + */ + private String portRange; + + /** + * The source ip of the security group rule + */ + private String sourceIp; + + /** + * The id of the source security group + */ + private String sourceGroupId; + + /** + * The destination ip address + */ + private String destIp; + + /** + * The id of the destination security group + */ + private String destGroupId; + + /** + * The protocol type + */ + private String protocol; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateSecurityGroupRuleRequest with credentials. + */ + @Override + public UpdateSecurityGroupRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/CreateSnapshotRequest.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/CreateSnapshotRequest.java new file mode 100644 index 00000000..6162f1c4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/CreateSnapshotRequest.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for creating a new snapshot. + */ +public class CreateSnapshotRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id which specify where the snapshot will be created from. + * If you want to create an snapshot from a customized volume,a id of the volume will be set. + * If you want to create an snapshot from a system volume,a id of the instance will be set. + */ + private String volumeId; + + /** + * The name for the snapshot that will be created. + * The name length from 1 to 65,only contains letters,digital and underline. + */ + private String snapshotName; + + /** + * The optional parameter to describe the information of the new snapshot. + */ + private String desc; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return CreateSnapshotRequest with specific clientToken + */ + public CreateSnapshotRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + /** + * Configure volumeId for the request. + * + * @param volumeId The id which specify where the snapshot will be created from. + * If you want to create an snapshot from a customized volume,a id of the volume will be set. + * If you want to create an snapshot from a system volume,a id of the instance will be set. + * @return CreateSnapshotRequest with volumeId. + */ + public CreateSnapshotRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public String getSnapshotName() { + return snapshotName; + } + + public void setSnapshotName(String snapshotName) { + this.snapshotName = snapshotName; + } + + /** + * Configure snapshotName for the request. + * + * @param snapshotName The name for the snapshot that will be created. + * The name length from 1 to 65,only contains letters,digital and underline. + * @return CreateSnapshotRequest with snapshotName. + */ + public CreateSnapshotRequest withSnapshotName(String snapshotName) { + this.snapshotName = snapshotName; + return this; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + /** + * Configure desc for the request. + * + * @param desc The optional parameter to describe the information of the new snapshot. + * @return CreateSnapshotRequest with desc. + */ + public CreateSnapshotRequest withDesc(String desc) { + this.desc = desc; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateSnapshotRequest with credentials. + */ + @Override + public CreateSnapshotRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/CreateSnapshotResponse.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/CreateSnapshotResponse.java new file mode 100644 index 00000000..3dd6493e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/CreateSnapshotResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for CreateSnapshotRequest. + */ +public class CreateSnapshotResponse extends AbstractBceResponse { + /** + * The id of snapshot. + */ + private String snapshotId; + + public String getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + @Override + public String toString() { + return "CreateSnapshotResponse{" + + "snapshotId='" + snapshotId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/DeleteSnapshotRequest.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/DeleteSnapshotRequest.java new file mode 100644 index 00000000..385d608b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/DeleteSnapshotRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for deleting the specified snapshot. + */ +public class DeleteSnapshotRequest extends AbstractBceRequest { + + /** + * The id of snapshot. + */ + private String snapshotId; + + public String getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + /** + * Configure snapshotId for the request. + * + * @param snapshotId The id of snapshot which will be deleted. + * @return DeleteSnapshotRequest with snapshotId. + */ + public DeleteSnapshotRequest withSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteSnapshotRequest with credentials. + */ + @Override + public DeleteSnapshotRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/GetSnapshotRequest.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/GetSnapshotRequest.java new file mode 100644 index 00000000..d14346fa --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/GetSnapshotRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting the specified snapshot detail information. + */ +public class GetSnapshotRequest extends AbstractBceRequest { + /** + * The id of snapshot. + */ + private String snapshotId; + + public String getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + /** + * Configure snapshotId for the request. + * + * @param snapshotId The id of snapshot which wil be deleted. + * @return GetSnapshotRequest with snapshotId. + */ + public GetSnapshotRequest withSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetSnapshotRequest with credentials. + */ + @Override + public GetSnapshotRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/GetSnapshotResponse.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/GetSnapshotResponse.java new file mode 100644 index 00000000..4c8e289d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/GetSnapshotResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.SnapshotModel; + +/** + * The response for GetSnapshotRequest. + */ +public class GetSnapshotResponse extends AbstractBceResponse { + + /** + * The detail model of the snapshot. + */ + private SnapshotModel snapshot; + + public SnapshotModel getSnapshot() { + return snapshot; + } + + public void setSnapshot(SnapshotModel snapshot) { + this.snapshot = snapshot; + } + + @Override + public String toString() { + return "GetSnapshotResponse{" + + "snapshot=" + snapshot + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapchainRequest.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapchainRequest.java new file mode 100644 index 00000000..8b1b2884 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapchainRequest.java @@ -0,0 +1,101 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting the snap chain list; + */ +public class ListSnapchainRequest extends AbstractBceRequest { + + /** + * Sorting properties, optional: chainId (snapshot chain id, default), + * chainSize (snapshot chain size), volumeSize (disk size) + */ + private String orderBy = "chainId"; + + /** + * Sorting method Optional: asc (positive order, default), desc (reverse order) + */ + private String order = "asc"; + + /** + * The number of each page, the default value is 1000. + */ + private int pageSize = 1000; + + private int pageNo = 1; + + /** + * Disk id, if this field is not empty, + * only the snapshot chain information of this disk will be returned + */ + private String volumeId; + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + @Override + public String toString() { + return "ListSnapchainRequest{" + + "orderBy='" + orderBy + '\'' + + ", order='" + order + '\'' + + ", pageSize=" + pageSize + + ", pageNo=" + pageNo + + ", volumeId='" + volumeId + '\'' + + '}'; + } + + @Override + public ListSnapchainRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapchainResponse.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapchainResponse.java new file mode 100644 index 00000000..5285ac7d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapchainResponse.java @@ -0,0 +1,87 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response of getting the snap chain list. + */ +public class ListSnapchainResponse extends AbstractBceResponse { + private String orderBy; + private int totalCount; + private int pageSize; + private int pageNo; + private boolean isTruncated; + private List snapchains; + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public boolean isTruncated() { + return isTruncated; + } + + public void setTruncated(boolean truncated) { + isTruncated = truncated; + } + + public List getSnapchains() { + return snapchains; + } + + public void setSnapchains(List snapchains) { + this.snapchains = snapchains; + } + + @Override + public String toString() { + return "ListSnapchainResponse{" + + "orderBy='" + orderBy + '\'' + + ", totalCount=" + totalCount + + ", pageSize=" + pageSize + + ", pageNo=" + pageNo + + ", isTruncated=" + isTruncated + + ", snapchains=" + snapchains + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapshotsRequest.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapshotsRequest.java new file mode 100644 index 00000000..2dc04433 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapshotsRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for listing snapshots owned by used. + */ +public class ListSnapshotsRequest extends ListRequest { + /** + * The id of volume. + */ + private String volumeId; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + /** + * Configure the request with specified volumeId. + * + * @param volumeId The id of the volume. + * @return ListSnapshotsRequest with specified volumeId. + */ + public ListSnapshotsRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListSnapshotsRequest with specified marker. + */ + @Override + public ListSnapshotsRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListSnapshotsRequest with specified maxKeys. + */ + @Override + public ListSnapshotsRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListSnapshotsRequest with credentials. + */ + @Override + public ListSnapshotsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapshotsResponse.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapshotsResponse.java new file mode 100644 index 00000000..09ba010d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapshotsResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +import com.baidubce.model.ListResponse; +import com.baidubce.services.bcc.model.SnapshotModel; + +import java.util.List; + +/** + * The response for ListSnapshotsRequest. + */ +public class ListSnapshotsResponse extends ListResponse { + + /** + * List of snapshot detail model + */ + private List snapshots; + + public List getSnapshots() { + return snapshots; + } + + public void setSnapshots(List snapshots) { + this.snapshots = snapshots; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/SnapchainModel.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/SnapchainModel.java new file mode 100644 index 00000000..db45a20f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/SnapchainModel.java @@ -0,0 +1,131 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +/** + * The model of snap chain. + */ +public class SnapchainModel { + + private String status; + + private String chainSize; + private String chainId; + private String instanceId; + + private String userId; + + private String volumeId; + + private int volumeSize; + + private int manualSnapCount; + + private int autoSnapCount; + + private String createTime; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getChainSize() { + return chainSize; + } + + public void setChainSize(String chainSize) { + this.chainSize = chainSize; + } + + public String getChainId() { + return chainId; + } + + public void setChainId(String chainId) { + this.chainId = chainId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public int getVolumeSize() { + return volumeSize; + } + + public void setVolumeSize(int volumeSize) { + this.volumeSize = volumeSize; + } + + public int getManualSnapCount() { + return manualSnapCount; + } + + public void setManualSnapCount(int manualSnapCount) { + this.manualSnapCount = manualSnapCount; + } + + public int getAutoSnapCount() { + return autoSnapCount; + } + + public void setAutoSnapCount(int autoSnapCount) { + this.autoSnapCount = autoSnapCount; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + @Override + public String toString() { + return "SnapchainModel{" + + "status='" + status + '\'' + + ", chainSize='" + chainSize + '\'' + + ", chainId='" + chainId + '\'' + + ", instanceId='" + instanceId + '\'' + + ", userId='" + userId + '\'' + + ", volumeId='" + volumeId + '\'' + + ", volumeSize=" + volumeSize + + ", manualSnapCount=" + manualSnapCount + + ", autoSnapCount=" + autoSnapCount + + ", createTime='" + createTime + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/snapshot/SnapshotStatus.java b/src/main/java/com/baidubce/services/bcc/model/snapshot/SnapshotStatus.java new file mode 100644 index 00000000..3f6c2a4b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/snapshot/SnapshotStatus.java @@ -0,0 +1,21 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.snapshot; + +/** + * The status of the snapshot. + */ +public enum SnapshotStatus { + Creating, + CreatedFailed, + Available, + NotAvailable +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/AttachVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/AttachVolumeRequest.java new file mode 100644 index 00000000..ba5bd8e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/AttachVolumeRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for attaching the specified volume to the instance. + */ +public class AttachVolumeRequest extends AbstractBceRequest { + /** + * The id of volume. + */ + private String volumeId; + + /** + * The id of instance. + */ + private String instanceId; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + /** + * Configure volumeId for the request. + * + * @param volumeId The id of volume. + * @return AttachVolumeRequest with volumeId. + */ + public AttachVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of instance. + * @return AttachVolumeRequest with instanceId. + */ + public AttachVolumeRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return AttachVolumeRequest with credentials. + */ + @Override + public AttachVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/AttachVolumeResponse.java b/src/main/java/com/baidubce/services/bcc/model/volume/AttachVolumeResponse.java new file mode 100644 index 00000000..9b21b490 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/AttachVolumeResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.VolumeAttachmentModel; +import lombok.Data; + +import java.util.List; + +/** + * The response for AttachVolumeRequest. + */ +@Data +public class AttachVolumeResponse extends AbstractBceResponse { + + /** + * The detail model which describe where the volume will attach to. + */ + private VolumeAttachmentModel volumeAttachment; + + private List warningList; + + public VolumeAttachmentModel getVolumeAttachment() { + return volumeAttachment; + } + + public void setVolumeAttachment(VolumeAttachmentModel volumeAttachment) { + this.volumeAttachment = volumeAttachment; + } + + @Override + public String toString() { + return "AttachVolumeResponse{" + + "volumeAttachment=" + volumeAttachment + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/AutoRenewVolumeClusterRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/AutoRenewVolumeClusterRequest.java new file mode 100644 index 00000000..b8e5100f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/AutoRenewVolumeClusterRequest.java @@ -0,0 +1,114 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for auto renewing the volume. + */ +public class AutoRenewVolumeClusterRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * The time unit to auto renew, support "year" and "month" + */ + private String renewTimeUnit; + + /** + * The number of time unit, [1,9] when unit in "month" and [1,3] when unit in "year" + */ + private int renewTime; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + + + public AutoRenewVolumeClusterRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + + public String getRenewTimeUnit() { + return renewTimeUnit; + } + + public void setRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + } + + public AutoRenewVolumeClusterRequest withRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + return this; + } + + public int getRenewTime() { + return renewTime; + } + + public void setRenewTime(int renewTime) { + this.renewTime = renewTime; + } + + public AutoRenewVolumeClusterRequest withRenewTime(int renewTime) { + this.renewTime = renewTime; + return this; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + @Override + public AutoRenewVolumeClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "AutoRenewVolumeClusterRequest{" + + "clientToken='" + clientToken + '\'' + + ", clusterId='" + clusterId + '\'' + + ", renewTimeUnit='" + renewTimeUnit + '\'' + + ", renewTime=" + renewTime + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/AutoRenewVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/AutoRenewVolumeRequest.java new file mode 100644 index 00000000..51eeef91 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/AutoRenewVolumeRequest.java @@ -0,0 +1,116 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for auto renewing the volume. + */ +public class AutoRenewVolumeRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of volume. + */ + private String volumeId; + + /** + * The time unit to auto renew, support "year" and "month" + */ + private String renewTimeUnit; + + /** + * The number of time unit, [1,9] when unit in "month" and [1,3] when unit in "year" + */ + private int renewTime; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public AutoRenewVolumeRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public AutoRenewVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public String getRenewTimeUnit() { + return renewTimeUnit; + } + + public void setRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + } + + public AutoRenewVolumeRequest withRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + return this; + } + + public int getRenewTime() { + return renewTime; + } + + public void setRenewTime(int renewTime) { + this.renewTime = renewTime; + } + + public AutoRenewVolumeRequest withRenewTime(int renewTime) { + this.renewTime = renewTime; + return this; + } + + @Override + public String toString() { + return "AutoRenewVolumeRequest{" + + "clientToken='" + clientToken + '\'' + + ", volumeId='" + volumeId + '\'' + + ", renewTimeUnit='" + renewTimeUnit + '\'' + + ", renewTime=" + renewTime + + '}'; + } + + @Override + public AutoRenewVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/CancelAutoRenewVolumeClusterRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/CancelAutoRenewVolumeClusterRequest.java new file mode 100644 index 00000000..249a4a91 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/CancelAutoRenewVolumeClusterRequest.java @@ -0,0 +1,64 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for canceling auto renew the volume. + */ +public class CancelAutoRenewVolumeClusterRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of cluster + */ + private String clusterId; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public CancelAutoRenewVolumeClusterRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + @Override + public CancelAutoRenewVolumeClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/CancelAutoRenewVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/CancelAutoRenewVolumeRequest.java new file mode 100644 index 00000000..62537dd3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/CancelAutoRenewVolumeRequest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for canceling auto renew the volume. + */ +public class CancelAutoRenewVolumeRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of volume. + */ + private String volumeId; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public CancelAutoRenewVolumeRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public CancelAutoRenewVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + @Override + public CancelAutoRenewVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeClusterRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeClusterRequest.java new file mode 100644 index 00000000..506e9ff6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeClusterRequest.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for creating a new volume. + */ +public class CreateVolumeClusterRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The optional parameter to specify how many volumes to buy, default value is 1. + * The maximum to create for one time is 5. + */ + private int purchaseCount = 1; + + /** + * The size of volume to create in GB. + * By specifying the snapshotId, + * it will create volume from the specified snapshot and the parameter cdsSizeInGB will be ignored. + */ + private int clusterSizeInGB; + + /** + * The storage type of volume, see more detail in + * BCE API doc + */ + private String storageType; + + /** + * The detail model to specify the billing. + */ + private Billing billing; + + /** + * the name of available zone, optional param + * through listZones, we can get all available zone info at current region + * e.g. "cn-gz-a" "cn-gz-b" + */ + private String zoneName; + + private String clusterName; + + private String renewTimeUnit; + + private int renewTime; + + private String uuidFlag; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return CreateVolumeRequest with specific clientToken + */ + public CreateVolumeClusterRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public int getPurchaseCount() { + return purchaseCount; + } + + public void setPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + } + + /** + * Configure purchaseCount for the request. + * + * @param purchaseCount The number of volume to buy, the default value is 1. + * @return CreateVolumeRequest with specific purchaseCount + */ + public CreateVolumeClusterRequest withPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + return this; + } + + public String getStorageType() { + return storageType; + } + + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * Configure storageType for the request. + * + * @param storageType The storage type of volume, see more detail in + * BCE API doc + * @return CreateVolumeRequest with storageType. + */ + public CreateVolumeClusterRequest withStorageType(String storageType) { + this.storageType = storageType; + return this; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + /** + * Configure billing for the request. + * + * @param billing The detail model to specify the billing. + * @return CreateVolumeRequest with specific billing + */ + public CreateVolumeClusterRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public CreateVolumeClusterRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + public int getClusterSizeInGB() { + return clusterSizeInGB; + } + + public void setClusterSizeInGB(int clusterSizeInGB) { + this.clusterSizeInGB = clusterSizeInGB; + } + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public String getRenewTimeUnit() { + return renewTimeUnit; + } + + public void setRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + } + + public int getRenewTime() { + return renewTime; + } + + public void setRenewTime(int renewTime) { + this.renewTime = renewTime; + } + + public String getUuidFlag() { + return uuidFlag; + } + + public void setUuidFlag(String uuidFlag) { + this.uuidFlag = uuidFlag; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateVolumeRequest with credentials. + */ + @Override + public CreateVolumeClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeClusterResponse.java b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeClusterResponse.java new file mode 100644 index 00000000..104beb24 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeClusterResponse.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The request for creating new volume cluster. + */ +public class CreateVolumeClusterResponse extends AbstractBceResponse { + + private List clusterIds; + + private List clusterUuids; + + public List getClusterIds() { + return clusterIds; + } + + public void setClusterIds(List clusterIds) { + this.clusterIds = clusterIds; + } + + public List getClusterUuids() { + return clusterUuids; + } + + public void setClusterUuids(List clusterUuids) { + this.clusterUuids = clusterUuids; + } + + @Override + public String toString() { + return "CreateVolumeClusterResponse{" + + "clusterIds=" + clusterIds + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeRequest.java new file mode 100644 index 00000000..dfaade78 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeRequest.java @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.AutoSnapshotPolicyModel; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import java.util.List; +/** + * The request for creating a new volume. + */ +@Data +public class CreateVolumeRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The optional parameter to specify how many volumes to buy, default value is 1. + * The maximum to create for one time is 5. + */ + private int purchaseCount = 1; + + /** + * The size of volume to create in GB. + * By specifying the snapshotId, + * it will create volume from the specified snapshot and the parameter cdsSizeInGB will be ignored. + */ + private int cdsSizeInGB; + + /** + * The storage type of volume, see more detail in + * BCE API doc + */ + private String storageType; + + /** + * The detail model to specify the billing. + */ + @Deprecated + private Billing billing; + + /** + * The id of snapshot. + * By specifying the snapshotId, + * it will create volume from the specified snapshot and the parameter cdsSizeInGB will be ignored. + */ + private String snapshotId; + + /** + * the name of available zone, optional param + * through listZones, we can get all available zone info at current region + * e.g. "cn-gz-a" "cn-gz-b" + */ + private String zoneName; + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * The optional parameter to specify the payment for the volume. + * The billing type and payment method, including Prepaid and Postpaid, + * need to be specified only when the instanceId is not empty and the corresponding instance type is prepaid. + * If instanceId is empty: + * create a post payment type CDS; + * If the instanceId is not empty: + * If the instance is prepaid, a chargeType needs to be specified; + * If the instance is post paid, create a post paid CDS + */ + private String chargeType; + + private int cdsExtraIo; + + private String instanceId; + + private String encryptKey; + + private String name; + + private String description; + + private int renewTime; + + private String renewTimeUnit; + + private Boolean relationTag; + + private List tags; + + private List resGroupIds; + + private AutoSnapshotPolicyModel autoSnapshotPolicy; + + public CreateVolumeRequest withCdsExtraIo(int cdsExtraIo) { + this.cdsExtraIo = cdsExtraIo; + return this; + } + + public CreateVolumeRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public CreateVolumeRequest withName(String name) { + this.name = name; + return this; + } + + public CreateVolumeRequest withDescription(String description) { + this.description = description; + return this; + } + + public CreateVolumeRequest withRenewTime(int renewTime) { + this.renewTime = renewTime; + return this; + } + + public CreateVolumeRequest withRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + return this; + } + + public CreateVolumeRequest withRelationTag(Boolean relationTag) { + this.relationTag = relationTag; + return this; + } + + public CreateVolumeRequest withTags(List tags) { + this.tags = tags; + return this; + } + + public CreateVolumeRequest withResGroupIds(List resGroupIds) { + this.resGroupIds = resGroupIds; + return this; + } + + public CreateVolumeRequest withAutoSnapshotPolicy(AutoSnapshotPolicyModel autoSnapshotPolicy) { + this.autoSnapshotPolicy = autoSnapshotPolicy; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return CreateVolumeRequest with specific clientToken + */ + public CreateVolumeRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public int getPurchaseCount() { + return purchaseCount; + } + + public void setPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + } + + /** + * Configure purchaseCount for the request. + * + * @param purchaseCount The number of volume to buy, the default value is 1. + * @return CreateVolumeRequest with specific purchaseCount + */ + public CreateVolumeRequest withPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + return this; + } + + public int getCdsSizeInGB() { + return cdsSizeInGB; + } + + public void setCdsSizeInGB(int cdsSizeInGB) { + this.cdsSizeInGB = cdsSizeInGB; + } + + /** + * Configure cdsSizeInGB for the request. + * + * @param cdsSizeInGB The size of volume to create in GB. By specifying the snapshotId, + * it will create volume from the specified snapshot and the parameter cdsSizeInGB will be ignored. + * @return CreateVolumeRequest with cdsSizeInGB. + */ + public CreateVolumeRequest withCdsSizeInGB(int cdsSizeInGB) { + this.cdsSizeInGB = cdsSizeInGB; + return this; + } + + public String getStorageType() { + return storageType; + } + + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * Configure storageType for the request. + * + * @param storageType The storage type of volume, see more detail in + * BCE API doc + * @return CreateVolumeRequest with storageType. + */ + public CreateVolumeRequest withStorageType(String storageType) { + this.storageType = storageType; + return this; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + /** + * Configure billing for the request. + * + * @param billing The detail model to specify the billing. + * @return CreateVolumeRequest with specific billing + */ + public CreateVolumeRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + public String getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + /** + * Configure snapshotId for the request. + * + * @param snapshotId The id of snapshot.By specifying the snapshotId, + * it will create volume from the specified snapshot and the parameter cdsSizeInGB will be ignored. + * @return CreateVolumeRequest with snapshotId. + */ + public CreateVolumeRequest withSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + return this; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public CreateVolumeRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public CreateVolumeRequest withClusterId(String clusterId) { + this.clusterId = clusterId; + return this; + } + + public String getChargeType() { + return chargeType; + } + + public void setChargeType(String chargeType) { + this.chargeType = chargeType; + } + + public CreateVolumeRequest withChargeType(String chargeType) { + this.chargeType = chargeType; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateVolumeRequest with credentials. + */ + @Override + public CreateVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeResponse.java b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeResponse.java new file mode 100644 index 00000000..6dd444e1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * The request for creating new volume. + */ +@Data +public class CreateVolumeResponse extends AbstractBceResponse { + /** + * List of the id of volumes created. + */ + private List volumeIds; + + private List volumes; + + private List warningList; + + @Data + public static class Volume { + private String volumeId; + private String volumeUuid; + private String name; + private Integer sizeGb; + } + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/DetachVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/DetachVolumeRequest.java new file mode 100644 index 00000000..ab462136 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/DetachVolumeRequest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for detaching the specified volume from the instance. + */ +public class DetachVolumeRequest extends AbstractBceRequest { + + /** + * The id of volume. + */ + @JsonIgnore + private String volumeId; + + /** + * The id of instance. + */ + private String instanceId; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + /** + * Configure volumeId for the request. + * + * @param volumeId The id of volume. + * @return DetachVolumeRequest with volumeId. + */ + public DetachVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure instanceId for the request. + * + * @param instanceId The id of instance. + * @return DetachVolumeRequest with instanceId. + */ + public DetachVolumeRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DetachVolumeRequest with credentials. + */ + @Override + public DetachVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/EphemeralDisk.java b/src/main/java/com/baidubce/services/bcc/model/volume/EphemeralDisk.java new file mode 100644 index 00000000..8b05f77a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/EphemeralDisk.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +/** + * ephemeral disk info. + */ +public class EphemeralDisk { + /** + * The storage type of volume, see more detail in + * BCE API doc + */ + private String storageType; + + /** + * capacity of volume + */ + private int sizeInGB; + + /** + * free capacity of volume + */ + private int freeSizeInGB; + + public EphemeralDisk withStorageType(String storageType) { + this.setStorageType(storageType); + return this; + } + + public String getStorageType() { + return storageType; + } + + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + public EphemeralDisk withSizeInGB(int sizeInGB) { + this.setSizeInGB(sizeInGB); + return this; + } + + public int getSizeInGB() { + return sizeInGB; + } + + public void setSizeInGB(int sizeInGB) { + this.sizeInGB = sizeInGB; + } + + public int getFreeSizeInGB() { + return freeSizeInGB; + } + + public void setFreeSizeInGB(int freeSizeInGB) { + this.freeSizeInGB = freeSizeInGB; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeClusterRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeClusterRequest.java new file mode 100644 index 00000000..2686cf9b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeClusterRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting the specified volume detail information. + */ +public class GetVolumeClusterRequest extends AbstractBceRequest { + + /** + * The id of volume. + */ + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetVolumeRequest with credentials. + */ + @Override + public GetVolumeClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeClusterResponse.java b/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeClusterResponse.java new file mode 100644 index 00000000..ad6f2385 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeClusterResponse.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for GetVolumeClusterRequest. + */ +public class GetVolumeClusterResponse extends AbstractBceResponse { + + /** + * The id of the cluster + */ + private String clusterId; + + /** + * The name of the cluster + */ + private String clusterName; + + /** + * The payment method of purchasing the volume, + * see more detail in BCE API doc + */ + private String productType; + + /** + * The time when the cluster was created. + */ + private String createdTime; + + /** + * The time when the cluster will be expired. + */ + private String expiredTime; + + /** + * The status of the volume, + * see more detail on BCE API doc + */ + private String status; + + private String clusterType; + + /** + * the name of available zone + */ + private String logicalZone; + + private int totalCapacity; + + private int usedCapacity; + + private int availableCapacity; + + private int expandingCapacity; + + private int createdVolumeNum; + + private List affiliatedCDSNumber; + + private Boolean enableAutoRenew = false; + private String renewTimeUnit; + + private Integer renewTime; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + this.productType = productType; + } + + public String getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + public String getExpiredTime() { + return expiredTime; + } + + public void setExpiredTime(String expiredTime) { + this.expiredTime = expiredTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getClusterType() { + return clusterType; + } + + public void setClusterType(String clusterType) { + this.clusterType = clusterType; + } + + public String getLogicalZone() { + return logicalZone; + } + + public void setLogicalZone(String logicalZone) { + this.logicalZone = logicalZone; + } + + public int getTotalCapacity() { + return totalCapacity; + } + + public void setTotalCapacity(int totalCapacity) { + this.totalCapacity = totalCapacity; + } + + public int getUsedCapacity() { + return usedCapacity; + } + + public void setUsedCapacity(int usedCapacity) { + this.usedCapacity = usedCapacity; + } + + public int getAvailableCapacity() { + return availableCapacity; + } + + public void setAvailableCapacity(int availableCapacity) { + this.availableCapacity = availableCapacity; + } + + public int getExpandingCapacity() { + return expandingCapacity; + } + + public void setExpandingCapacity(int expandingCapacity) { + this.expandingCapacity = expandingCapacity; + } + + public int getCreatedVolumeNum() { + return createdVolumeNum; + } + + public void setCreatedVolumeNum(int createdVolumeNum) { + this.createdVolumeNum = createdVolumeNum; + } + + public List getAffiliatedCDSNumber() { + return affiliatedCDSNumber; + } + + public void setAffiliatedCDSNumber(List affiliatedCDSNumber) { + this.affiliatedCDSNumber = affiliatedCDSNumber; + } + + public Boolean getEnableAutoRenew() { + return enableAutoRenew; + } + + public void setEnableAutoRenew(Boolean enableAutoRenew) { + this.enableAutoRenew = enableAutoRenew; + } + + public String getRenewTimeUnit() { + return renewTimeUnit; + } + + public void setRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + } + + public Integer getRenewTime() { + return renewTime; + } + + public void setRenewTime(Integer renewTime) { + this.renewTime = renewTime; + } + + @Override + public String toString() { + return "GetVolumeClusterResponse{" + + "clusterId='" + clusterId + '\'' + + ", clusterName='" + clusterName + '\'' + + ", productType='" + productType + '\'' + + ", createdTime='" + createdTime + '\'' + + ", expiredTime='" + expiredTime + '\'' + + ", status='" + status + '\'' + + ", clusterType='" + clusterType + '\'' + + ", logicalZone='" + logicalZone + '\'' + + ", totalCapacity=" + totalCapacity + + ", usedCapacity=" + usedCapacity + + ", availableCapacity=" + availableCapacity + + ", expandingCapacity=" + expandingCapacity + + ", createdVolumeNum=" + createdVolumeNum + + ", affiliatedCDSNumber=" + affiliatedCDSNumber + + ", enableAutoRenew=" + enableAutoRenew + + ", renewTimeUnit='" + renewTimeUnit + '\'' + + ", renewTime=" + renewTime + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeRequest.java new file mode 100644 index 00000000..1c59b473 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting the specified volume detail information. + */ +public class GetVolumeRequest extends AbstractBceRequest { + + /** + * The id of volume. + */ + private String volumeId; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + /** + * Configure volumeId for the request. + * + * @param volumeId The id of volume. + * @return GetVolumeRequest with volumeId. + */ + public GetVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetVolumeRequest with credentials. + */ + @Override + public GetVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeResponse.java b/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeResponse.java new file mode 100644 index 00000000..765bd414 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.VolumeModel; + +/** + * The response for GetVolumeRequest. + */ +public class GetVolumeResponse extends AbstractBceResponse { + + /** + * The detail model of the volume. + */ + private VolumeModel volume; + + public VolumeModel getVolume() { + return volume; + } + + public void setVolume(VolumeModel volume) { + this.volume = volume; + } + + @Override + public String toString() { + return "GetVolumeResponse{" + + "volume=" + volume + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumeClustersRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumeClustersRequest.java new file mode 100644 index 00000000..a4bc444f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumeClustersRequest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for listing volume owned by the user. + */ +public class ListVolumeClustersRequest extends ListRequest { + + private String clusterName; + + /** + * the name of available zone + */ + private String zoneName; + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public ListVolumeClustersRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListInstancesRequest with specified marker. + */ + @Override + public ListVolumeClustersRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListInstancesRequest with specified maxKeys. + */ + @Override + public ListVolumeClustersRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListVolumesRequest with credentials. + */ + @Override + public ListVolumeClustersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumeClustersResponse.java b/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumeClustersResponse.java new file mode 100644 index 00000000..2940c5cf --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumeClustersResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.model.ListResponse; +import com.baidubce.services.bcc.model.VolumeClusterModel; + +import java.util.List; + +/** + * The response for ListVolumesRequest. + */ +public class ListVolumeClustersResponse extends ListResponse { + + /** + * List of volume detail model + */ + private List result; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumesRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumesRequest.java new file mode 100644 index 00000000..b18cbe29 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumesRequest.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for listing volume owned by the user. + */ +public class ListVolumesRequest extends ListRequest { + + /** + * The id of instance. + * The optional parameter to list the volume. + * If it's specified,only the volumes attached to the specified instance will be listed. + */ + private String instanceId; + + /** + * the name of available zone + */ + private String zoneName; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + /** + * Configure the request with specified instanceId. + * @param instanceId The id of instance. + */ + public ListVolumesRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public ListVolumesRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListInstancesRequest with specified marker. + */ + @Override + public ListVolumesRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListInstancesRequest with specified maxKeys. + */ + @Override + public ListVolumesRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListVolumesRequest with credentials. + */ + @Override + public ListVolumesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumesResponse.java b/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumesResponse.java new file mode 100644 index 00000000..c472bbf7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ListVolumesResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.model.ListResponse; +import com.baidubce.services.bcc.model.VolumeModel; + +import java.util.List; + +/** + * The response for ListVolumesRequest. + */ +public class ListVolumesResponse extends ListResponse { + + /** + * List of volume detail model + */ + private List volumes; + + public List getVolumes() { + return volumes; + } + + public void setVolumes(List volumes) { + this.volumes = volumes; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ModifyCdsAttrRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/ModifyCdsAttrRequest.java new file mode 100644 index 00000000..1440f393 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ModifyCdsAttrRequest.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * the request for changing cds's attribute + */ +public class ModifyCdsAttrRequest extends AbstractBceRequest { + + /** + * specify the cds's id + */ + private String cdsId; + + /** + * specify the cds's new name + */ + private String cdsName; + + /** + * cds's new description + */ + private String desc; + + /** + * configure cds's id for the request + * + * @param cdsId String cds's id + * @return ModifyCdsAttrRequest + */ + public ModifyCdsAttrRequest withCdsId(String cdsId) { + this.cdsId = cdsId; + return this; + } + + /** + * configure cds's name for the request + * @param cdsName String + * @return ModifyCdsAttrRequest + */ + public ModifyCdsAttrRequest withCdsName(String cdsName) { + this.cdsName = cdsName; + return this; + } + + /** + * configure cds's description for the request + * @param desc String + * @return ModifyCdsAttrRequest + */ + public ModifyCdsAttrRequest withDesc(String desc) { + this.desc = desc; + return this; + } + + public String getCdsName() { + return cdsName; + } + + public void setCdsName(String cdsName) { + this.cdsName = cdsName; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getCdsId() { + return cdsId; + } + + public void setCdsId(String cdsId) { + this.cdsId = cdsId; + } + + @Override + public String toString() { + return "ModifyCdsAttrRequest{cdsName='" + cdsName + + "', desc='" + desc + + "', cdsId='" + cdsId + + "'}"; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ModifyCdsAttrRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ModifyVolumeChargeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/ModifyVolumeChargeRequest.java new file mode 100644 index 00000000..4017708a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ModifyVolumeChargeRequest.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.Reservation; + +/** + * the request for changing volume's billing method + */ +public class ModifyVolumeChargeRequest extends AbstractBceRequest { + /** + * specify the volume to change billing method + */ + private String volumeId; + + /** + * specify the billing method, can only be set to 'postpay' or 'prepay' + */ + private String billingMethod; + + /** + * this field is used to specify how many month to buy this volume. only used when billingMethod is 'prepay' + */ + private int reservationLength; + + public ModifyVolumeChargeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public ModifyVolumeChargeRequest withBillingMethod(String billingMethod) { + if (!"prepay".equals(billingMethod) && !"postpay".equals(billingMethod)) { + throw new IllegalArgumentException("billingMethod can only be set to 'prepay' or 'postpay'"); + } + this.billingMethod = billingMethod; + return this; + } + + public ModifyVolumeChargeRequest withReservationLength(int reservationLength) { + if (reservationLength < 0) { + throw new IllegalArgumentException("reservationLength can not be negative integer"); + } + this.reservationLength = reservationLength; + return this; + } + + public String getBillingMethod() { + return billingMethod; + } + + public void setBillingMethod(String billingMethod) { + if (!"prepay".equals(billingMethod) && !"postpay".equals(billingMethod)) { + throw new IllegalArgumentException("billingMethod can only be set to 'prepay' or 'postpay'"); + } + this.billingMethod = billingMethod; + } + + public int getReservationLength() { + return reservationLength; + } + + public void setReservationLength(int reservationLength) { + if (reservationLength < 0) { + throw new IllegalArgumentException("reservationLength can not be negative integer"); + } + this.reservationLength = reservationLength; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * convert user request to internal request model + * + * @return ModifyVolumeChargeModel + */ + public ModifyVolumeChargeModel toModifyVolumeChargeModel() { + ModifyVolumeChargeModel modifyVolumeChargeModel = new ModifyVolumeChargeModel(); + Reservation reservation = new Reservation(); + Billing billing = new Billing(); + if ("prepay".equals(billingMethod)) { + reservation.withReservationLength(reservationLength); + billing.withReservation(reservation); + } else if ("postpay".equals(billingMethod)) { + reservation.withReservationLength(0); + billing.withReservation(reservation); + } else { + throw new IllegalArgumentException("billingMethod can only be set to 'prepay' or 'postpay'"); + } + modifyVolumeChargeModel.setBilling(billing); + return modifyVolumeChargeModel; + } + + /** + * internal request class + */ + public static class ModifyVolumeChargeModel extends AbstractBceRequest { + private Billing billing; + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ModifyVolumeChargeTypeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/ModifyVolumeChargeTypeRequest.java new file mode 100644 index 00000000..383a9505 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ModifyVolumeChargeTypeRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * the request for changing volume's billing method + */ +public class ModifyVolumeChargeTypeRequest extends AbstractBceRequest { + + /** + * specify the volume to change billing method + */ + @JsonIgnore + private String volumeId; + + /** + * Payment Information + */ + private Billing billing; + + + public ModifyVolumeChargeTypeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public ModifyVolumeChargeTypeRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + @Override + public String toString() { + return "ModifyVolumeChargeRequest{" + + "volumeId='" + volumeId + '\'' + + ", billing=" + billing + + '}'; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/PurchaseReservedVolumeClusterRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/PurchaseReservedVolumeClusterRequest.java new file mode 100644 index 00000000..185dd3c2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/PurchaseReservedVolumeClusterRequest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for renewing the volume. + */ +public class PurchaseReservedVolumeClusterRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of cluster. + */ + @JsonIgnore + private String clusterId; + + /** + * The detail model to specify the billing. + */ + private Billing billing; + + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return PurchaseReservedVolumeRequest with specific clientToken + */ + public PurchaseReservedVolumeClusterRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return PurchaseReservedVolumeRequest with credentials. + */ + @Override + public PurchaseReservedVolumeClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/PurchaseReservedVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/PurchaseReservedVolumeRequest.java new file mode 100644 index 00000000..73033cf4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/PurchaseReservedVolumeRequest.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for renewing the volume. + */ +public class PurchaseReservedVolumeRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of volume. + */ + @JsonIgnore + private String volumeId; + + /** + * The detail model to specify the billing. + */ + private Billing billing; + + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return PurchaseReservedVolumeRequest with specific clientToken + */ + public PurchaseReservedVolumeRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + /** + * Configure volumeId for the request. + * + * @param volumeId The id of volume which will be renew. + * @return PurchaseReservedVolumeRequest with specific volumeId + */ + public PurchaseReservedVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + /** + * Configure billing for the request. + * + * @param billing The detail model to specify the billing. + * @return PurchaseReservedVolumeRequest with specific billing + */ + public PurchaseReservedVolumeRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return PurchaseReservedVolumeRequest with credentials. + */ + @Override + public PurchaseReservedVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ReleaseVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/ReleaseVolumeRequest.java new file mode 100644 index 00000000..2ce75a06 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ReleaseVolumeRequest.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for Releasing volume. + */ +public class ReleaseVolumeRequest extends AbstractBceRequest { + + /** + * The id of volume. + */ + private String volumeId; + + /** + * whether release auto created snapshot of the volume + */ + private String autoSnapshot; + + /** + * whether release manually created snapshot of the volume + */ + private String manualSnapshot; + + /** + * whether recycle the volume, value can be on, off. default on + */ + private String recycle; + + public String getAutoSnapshot() { + return autoSnapshot; + } + + public void setAutoSnapshot(String autoSnapshot) { + this.autoSnapshot = autoSnapshot; + } + + public String getManualSnapshot() { + return manualSnapshot; + } + + public void setManualSnapshot(String manualSnapshot) { + this.manualSnapshot = manualSnapshot; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public ReleaseVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public String getRecycle() { + return recycle; + } + + public void setRecycle(String recycle) { + this.recycle = recycle; + } + + public ReleaseVolumeRequest withRecycle(String recycle) { + if (!"on".equals(recycle) && !"off".equals(recycle)) { + throw new IllegalArgumentException("recycle can only be set to 'on' or 'off'"); + } + this.recycle = recycle; + return this; + } + + public ReleaseVolumeRequest withAutoSnapshot(String autoSnapshot) { + if (!"on".equals(autoSnapshot) && !"off".equals(autoSnapshot)) { + throw new IllegalArgumentException("autoSnapshot can only be set to 'on' or 'off'"); + } + this.autoSnapshot = autoSnapshot; + return this; + } + + public ReleaseVolumeRequest withManualSnapshot(String manualSnapshot) { + if (!"on".equals(manualSnapshot) && !"off".equals(manualSnapshot)) { + throw new IllegalArgumentException("manualSnapshot can only be set to 'on' or 'off'"); + } + this.manualSnapshot = manualSnapshot; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ReleaseVolumeRequest with credentials. + */ + @Override + public ReleaseVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/RenameVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/RenameVolumeRequest.java new file mode 100644 index 00000000..8158e861 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/RenameVolumeRequest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for renaming the volume. + */ +public class RenameVolumeRequest extends AbstractBceRequest { + /** + * The id of volume. + */ + private String volumeId; + + /** + * The new name of the volume. + */ + private String name; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "RenameVolumeRequest{" + + "volumeId='" + volumeId + '\'' + + ", name='" + name + '\'' + + '}'; + } + + public RenameVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public RenameVolumeRequest withName(String name) { + this.name = name; + return this; + } + + @Override + public RenameVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeClusterRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeClusterRequest.java new file mode 100644 index 00000000..13117743 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeClusterRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for resizing specified volume. + */ +public class ResizeVolumeClusterRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of ClusterId. + */ + @JsonIgnore + private String clusterId; + + private int newClusterSizeInGB; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public int getNewClusterSizeInGB() { + return newClusterSizeInGB; + } + + public void setNewClusterSizeInGB(int newClusterSizeInGB) { + this.newClusterSizeInGB = newClusterSizeInGB; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ResizeVolumeRequest with credentials. + */ + @Override + public ResizeVolumeClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeRequest.java new file mode 100644 index 00000000..a10ba285 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeRequest.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for resizing specified volume. + */ +public class ResizeVolumeRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of volume. + */ + @JsonIgnore + private String volumeId; + + /** + * The new volume size in GB, available size is 0-5120 GB + */ + private int newCdsSizeInGB; + + /** + * The new volumeType + */ + private String newVolumeType; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * + * @param clientToken An ASCII string whose length is less than 64. + * See more detail at + * + * BCE API doc + * @return ResizeVolumeRequest with specific clientToken + */ + public ResizeVolumeRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + /** + * Configure volumeId for the request. + * + * @param volumeId The id of volume which will be resize. + * @return ResizeVolumeRequest with volumeId. + */ + public ResizeVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public int getNewCdsSizeInGB() { + return newCdsSizeInGB; + } + + public void setNewCdsSizeInGB(int newCdsSizeInGB) { + this.newCdsSizeInGB = newCdsSizeInGB; + } + + /** + * Configure newCdsSizeInGB for the request. + * + * @param newCdsSizeInGB The new volume size in GB, available size is 0-5120 GB + * @return ResizeVolumeRequest with newCdsSizeInGB. + */ + public ResizeVolumeRequest withNewCdsSizeInGB(int newCdsSizeInGB) { + this.newCdsSizeInGB = newCdsSizeInGB; + return this; + } + + public String getNewVolumeType() { + return newVolumeType; + } + + public void setNewVolumeType(String newVolumeType) { + this.newVolumeType = newVolumeType; + } + + public ResizeVolumeRequest withNewVolumeType(String newVolumeType) { + this.newVolumeType = newVolumeType; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ResizeVolumeRequest with credentials. + */ + @Override + public ResizeVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeResponse.java b/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeResponse.java new file mode 100644 index 00000000..c8af110a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ResizeVolumeResponse extends AbstractBceResponse { + + private List warningList; + +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/RollbackVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/RollbackVolumeRequest.java new file mode 100644 index 00000000..c866cedd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/RollbackVolumeRequest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for Rolling back the specified volume. + */ +public class RollbackVolumeRequest extends AbstractBceRequest { + + /** + * The id of volume. + */ + @JsonIgnore + private String volumeId; + + /** + * The id which specify where the volume will be rolled back from. + * If you want to rollback the volume from a customized volume,a id of the volume will be set. + * If you want to rollback the volume from a system volume,a id of the instance will be set. + */ + private String snapshotId; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + /** + * Configure volumeId for the request. + * + * @param volumeId The id of volume which will be rolled back. + * @return RollbackVolumeRequest with volumeId. + */ + public RollbackVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + return this; + } + + public String getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + /** + * Configure snapshotId for the request. + * + * @param snapshotId The id which specify where the volume will be rolled back from. + * If you want to rollback the volume from a customized volume,a id of the volume will be set. + * If you want to rollback the volume from a system volume,a id of the instance will be set. + * @return RollbackVolumeRequest with snapshotId. + */ + public RollbackVolumeRequest withSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return RollbackVolumeRequest with credentials. + */ + @Override + public RollbackVolumeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/VolumeAction.java b/src/main/java/com/baidubce/services/bcc/model/volume/VolumeAction.java new file mode 100644 index 00000000..ddfcbcd3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/VolumeAction.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +/** + * The action for operating the volume. + */ +public enum VolumeAction { + + /** + * The action to attach the volume. + */ + attach, + + /** + * The action to detach the volume. + */ + detach, + + /** + * The action to resize the volume. + */ + resize, + + /** + * The action to rollback the volume. + */ + rollback, + + /** + * The action to purchaseReserved the volume. + */ + purchaseReserved, + + /** + * The action to modify the attribute of the volume. + */ + modify, + + /** + * The action to modify charge type of the volume. + */ + modifyChargeType, + + /** + * The action to enable auto renewal to volume + */ + autoRenew, + + /** + * The action to disable auto renewal to volume + */ + cancelAutoRenew, + + /** + * The action to rename the volume + */ + rename +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/VolumePriceRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/VolumePriceRequest.java new file mode 100644 index 00000000..2c7a261e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/VolumePriceRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +@Data +public class VolumePriceRequest extends AbstractBceRequest { + + @JsonIgnore + private String clientToken; + + private Integer purchaseLength; + private String paymentTiming; + private String storageType; + private Integer cdsSizeInGB; + private Integer purchaseCount; + private String zoneName; + + + @Override + public VolumePriceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/VolumePriceResponse.java b/src/main/java/com/baidubce/services/bcc/model/volume/VolumePriceResponse.java new file mode 100644 index 00000000..63668e64 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/VolumePriceResponse.java @@ -0,0 +1,19 @@ +package com.baidubce.services.bcc.model.volume; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class VolumePriceResponse extends AbstractBceResponse { + private List price; + + @Data + public static class Price { + private String storageType; + private Integer cdsSizeInGB; + private double price; + private String unit; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/VolumeStatus.java b/src/main/java/com/baidubce/services/bcc/model/volume/VolumeStatus.java new file mode 100644 index 00000000..e8b17314 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/VolumeStatus.java @@ -0,0 +1,31 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +/** + * The status of the volume. + */ +public enum VolumeStatus { + Creating, + Available, + Attaching, + NotAvailable, + InUse, + Detaching, + Deleting, + Deleted, + Scaling, + Expired, + Error, + SnapshotProcessing, + ImageProcessing, + Recharging +} diff --git a/src/main/java/com/baidubce/services/bcc/model/volume/VolumeType.java b/src/main/java/com/baidubce/services/bcc/model/volume/VolumeType.java new file mode 100644 index 00000000..05cba03e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/VolumeType.java @@ -0,0 +1,20 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.volume; + +/** + * The type of the volume. + */ +public enum VolumeType { + System, + Ephemeral, + Cds +} diff --git a/src/main/java/com/baidubce/services/bcc/model/zone/ListZonesResponse.java b/src/main/java/com/baidubce/services/bcc/model/zone/ListZonesResponse.java new file mode 100644 index 00000000..96c18dca --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/zone/ListZonesResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.zone; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for listing zones. + */ +public class ListZonesResponse extends AbstractBceResponse { + /** + * The list of zone detail model. + */ + private List zones; + + public List getZones() { + return zones; + } + + public void setZones(List zones) { + this.zones = zones; + } + + @Override + public String toString() { + return "ListZoneResponse{" + + "zones='" + zones + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcc/model/zone/ZoneModel.java b/src/main/java/com/baidubce/services/bcc/model/zone/ZoneModel.java new file mode 100644 index 00000000..47ed0ee2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/zone/ZoneModel.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcc.model.zone; + +/** + * zone info model + */ +public class ZoneModel { + /** + * the name of available zone + */ + private String zoneName; + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + @Override + public String toString() { + return "ZoneModel{" + + "zoneName='" + zoneName + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/BcdClient.java b/src/main/java/com/baidubce/services/bcd/BcdClient.java new file mode 100644 index 00000000..1d497694 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/BcdClient.java @@ -0,0 +1,590 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcd.model.AddDomainResolveRequest; +import com.baidubce.services.bcd.model.AuditTemplateInfoRequest; +import com.baidubce.services.bcd.model.ChangeDnsRequest; +import com.baidubce.services.bcd.model.CheckOrderRequest; +import com.baidubce.services.bcd.model.CheckOrderResponse; +import com.baidubce.services.bcd.model.DeleteDomainResolveRequest; +import com.baidubce.services.bcd.model.DeleteTemplateInfoRequest; +import com.baidubce.services.bcd.model.DomainOrderResponse; +import com.baidubce.services.bcd.model.GetDomainAuditRequest; +import com.baidubce.services.bcd.model.GetDomainAuditResponse; +import com.baidubce.services.bcd.model.GetDomainDetailRequest; +import com.baidubce.services.bcd.model.GetDomainDetailResponse; +import com.baidubce.services.bcd.model.GetDomainPriceRequest; +import com.baidubce.services.bcd.model.GetDomainPriceResponse; +import com.baidubce.services.bcd.model.GetTemplateInfoRequest; +import com.baidubce.services.bcd.model.GetTemplateInfoResponse; +import com.baidubce.services.bcd.model.ListDomainResolveRequest; +import com.baidubce.services.bcd.model.ListDomainResolveResponse; +import com.baidubce.services.bcd.model.ListTemplateInfoRequest; +import com.baidubce.services.bcd.model.ListTemplateInfoResponse; +import com.baidubce.services.bcd.model.ModifyTemplateInfoRequest; +import com.baidubce.services.bcd.model.ModifyTemplateInfoResponse; +import com.baidubce.services.bcd.model.OrderPageListRequest; +import com.baidubce.services.bcd.model.PageListRequest; +import com.baidubce.services.bcd.model.RegisterDomainRequest; +import com.baidubce.services.bcd.model.RegisterDomainResponse; +import com.baidubce.services.bcd.model.RenewDomainRequest; +import com.baidubce.services.bcd.model.RenewDomainResponse; +import com.baidubce.services.bcd.model.SearchDomainRequest; +import com.baidubce.services.bcd.model.SearchDomainResponse; +import com.baidubce.services.bcd.model.TemplateRegisterDomainRequest; +import com.baidubce.services.bcd.model.TemplateUpdateOwnerRequest; +import com.baidubce.services.bcd.model.UpdateContactRequest; +import com.baidubce.services.bcd.model.UpdateDomainResolveRequest; +import com.baidubce.services.bcd.model.UpdateOwnerRequest; +import com.baidubce.services.bcd.model.UploadAuditDataRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; + +import org.apache.commons.lang3.StringUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +/** + * @author yangzhensheng + * @date 2021/5/26 + * @desc Provides the client for accessing the Baidu Domain Service. + */ +public class BcdClient extends AbstractBceClient { + + private static final String VERSION_ONE = "v1"; + private static final String VERSION_TWO = "v2"; + private static final String TEMPLATE_URI_PREFIX = "/contact/template"; + private static final String DOMAIN_RESOLVE_URI_PREFIX = "/domain/resolve"; + private static final String RESOLVE_ADD = "/add"; + private static final String RESOLVE_DELETE = "/delete"; + private static final String RESOLVE_EDIT = "/edit"; + private static final String RESOLVE_LIST = "/list"; + private static final String DOMAIN_AUDIT = "/domain/audit"; + private static final String OWNER_EDIT = "/domain/owner/edit"; + private static final String CONTACT_EDIT = "/domain/contact/edit"; + private static final String CONTACT_EDIT_SUFFIX = "/contact"; + private static final String CHANGE_DNS = "/domain/changeDns"; + private static final String DOMAIN_DETAIL = "/domain/detail"; + private static final String DOMAIN_API_PREFIX = "/domain"; + private static final String DOMAIN_SEARCH = "/domain/search"; + private static final String DOMAIN_PRICE = "/domain/price"; + private static final String DOMAIN_REGISTER = "/domain/register"; + private static final String DOMAIN_TEMPLATE_REGISTER = "/domain/registerByTemplate"; + private static final String DOMAIN_ASYNC_REGISTER = "/domain/register_async"; + private static final String DOMAIN_ASYNC_TEMPLATE_REGISTER = "/domain/register_asyncByTemplate"; + private static final String DOMAIN_RENEW = "/domain/renew"; + private static final String DOMAIN_ASYNC_RENEW = "/domain/renew_async"; + private static final String CHECK_DOMAIN_ORDER = "/order/check"; + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling httpResponses from all bcd service calls. + */ + private static final HttpResponseHandler[] BCD_HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on bcd. + */ + public BcdClient() { + this(new BcdClientConfiguration()); + } + + /** + * Constructs a new bcd client using the client configuration to access bcd. + * + * @param clientConfiguration The bcd client configuration options controlling how this client + * connects to bcd (e.g. proxy settings, retry counts, etc). + */ + public BcdClient(BcdClientConfiguration clientConfiguration) { + super(clientConfiguration, BCD_HANDLERS); + } + + /** + * get all contact template infos through filter params + * + * @param request the request param contains a map which define the filter condition to get the template infos. + * @return a list response object contain the total record count and the detail info about template infos. + */ + public ListTemplateInfoResponse listTemplateInfo(ListTemplateInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, VERSION_TWO, TEMPLATE_URI_PREFIX); + addOrderPageListParamIfNotNull(request, internalRequest); + addParamsIfNotNull("userType", request.getUserType(), internalRequest); + addParamsIfNotNull("email", request.getEmail(), internalRequest); + return this.invokeHttpClient(internalRequest, ListTemplateInfoResponse.class); + } + + /** + * add a contact template info into the user account + * + * @param request the object contain some field to build a complete contact template info. + * @return return a result templateId. + */ + public ModifyTemplateInfoResponse addTemplateInfo(ModifyTemplateInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_TWO, TEMPLATE_URI_PREFIX); + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, ModifyTemplateInfoResponse.class); + } + + /** + * get a contact template info by the templateId + * + * @param request the object contain a templateId to get a contact template info. + * @return the detail info about a contact template. + */ + public GetTemplateInfoResponse getTemplateInfo(GetTemplateInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, VERSION_TWO, TEMPLATE_URI_PREFIX, + request.getTemplateId()); + return this.invokeHttpClient(internalRequest, GetTemplateInfoResponse.class); + } + + /** + * delete a contact template info by templateId + * + * @param request the object contain a templateId to delete a contact template info. + */ + public void deleteTemplateInfo(DeleteTemplateInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, VERSION_TWO, TEMPLATE_URI_PREFIX, + request.getTemplateId()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * update a contact template info + * + * @param request the object contain some new field info to update a complete contact template info. attention the + * templateId is must. + */ + public void updateTemplateInfo(ModifyTemplateInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VERSION_TWO, TEMPLATE_URI_PREFIX, + request.getTemplateId()); + internalRequest.addParameter("update", null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * audit a contact template info + * + * @param request the object contain a templateId define which template to audit, and contain a audit info object. + */ + public void auditTemplateInfo(AuditTemplateInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VERSION_TWO, TEMPLATE_URI_PREFIX, + request.getTemplateId()); + internalRequest.addParameter("audit", null); + fillPayload(internalRequest, request.getAuditInfo()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * add domain resolve record + * + * @param request the object contain some field to build a domain resolve record. + */ + public void addDomainResolve(AddDomainResolveRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDomain(), checkEmptyExceptionMessageFormat("domain")); + checkStringNotEmpty(request.getView(), checkEmptyExceptionMessageFormat("view")); + checkStringNotEmpty(request.getRdType(), checkEmptyExceptionMessageFormat("rdType")); + Preconditions.checkArgument(request.getTtl() >= 60 && request.getTtl() <= 3600, + checkEmptyExceptionMessageFormat("ttl")); + checkStringNotEmpty(request.getRdata(), checkEmptyExceptionMessageFormat("rdata")); + checkStringNotEmpty(request.getZoneName(), checkEmptyExceptionMessageFormat("zoneName")); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_RESOLVE_URI_PREFIX, RESOLVE_ADD); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * delete domain resolve record by recordId and zoneName + * + * @param request the object contain a recordId and a zoneName define which domain resolve to delete + */ + public void deleteDomainResolve(DeleteDomainResolveRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getRecordId(), checkEmptyExceptionMessageFormat("recordId")); + checkStringNotEmpty(request.getZoneName(), checkEmptyExceptionMessageFormat("zoneName")); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_RESOLVE_URI_PREFIX, + RESOLVE_DELETE); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * update a domain resolve record info + * + * @param request the object contain some new field info to update a domain resolve record. attention the + * recordId is must. + */ + public void updateDomainResolve(UpdateDomainResolveRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDomain(), checkEmptyExceptionMessageFormat("domain")); + checkStringNotEmpty(request.getView(), checkEmptyExceptionMessageFormat("view")); + checkStringNotEmpty(request.getRdType(), checkEmptyExceptionMessageFormat("rdType")); + Preconditions.checkArgument(request.getTtl() >= 60 && request.getTtl() <= 3600, + checkEmptyExceptionMessageFormat("ttl")); + checkStringNotEmpty(request.getRdata(), checkEmptyExceptionMessageFormat("rdata")); + checkStringNotEmpty(request.getZoneName(), checkEmptyExceptionMessageFormat("zoneName")); + Preconditions.checkNotNull(request.getRecordId(), checkEmptyExceptionMessageFormat("recordId")); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_RESOLVE_URI_PREFIX, RESOLVE_EDIT); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * get all the domain resolve record list. + * + * @param request the request param contain some field which define the filter condition to get the record infos, + * which the domain field is necessary. + * @return a list response object contain the total record count and the detail info about domain record. + */ + public ListDomainResolveResponse listDomainResolve(ListDomainResolveRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_RESOLVE_URI_PREFIX, RESOLVE_LIST); + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, ListDomainResolveResponse.class); + } + + /** + * change the owner info the domain + * + * @param request the request object contain the change information to modify + */ + public void updateOwner(UpdateOwnerRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VERSION_ONE, OWNER_EDIT); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * change the owner info the domain by template + * + * @param request the request object contain the templates + */ + public void updateOwnerByTemplate(TemplateUpdateOwnerRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getDomain(), "param domain should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, VERSION_TWO, + DOMAIN_API_PREFIX, request.getDomain(), CONTACT_EDIT_SUFFIX); + internalRequest.addParameter("update", ""); + addParamsIfNotNull("templateId", request.getTemplateId(), internalRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * change the contact info the domain + * + * @param request the request object contain the change information to modify + */ + public void updateContact(UpdateContactRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VERSION_ONE, CONTACT_EDIT); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * get the audit status about the domain + * + * @param request the request object contain which domain audit status to get. + * @return the response object contain the description and audit status about the request domain. + */ + public GetDomainAuditResponse getDomainAudit(GetDomainAuditRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkArgument(StringUtils.isNotBlank(request.getDomain()), "domain should not be null"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, VERSION_ONE, DOMAIN_AUDIT); + internalRequest.addParameter("domain", request.getDomain()); + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, GetDomainAuditResponse.class); + } + + /** + * change the dns configuration of request domain + * + * @param request the request object contain which domain audit status to get. + * @return the response object contain the description and audit status about the request domain. + */ + public void changeDns(ChangeDnsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VERSION_ONE, CHANGE_DNS); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * get the detail info about request domain + * + * @param request the request object contain which domain info to get. + * @return the response object contain the detail info about the request domain. + */ + public GetDomainDetailResponse getDomainDetail(GetDomainDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, VERSION_ONE, DOMAIN_DETAIL); + internalRequest.addParameter("domain", request.getDomain()); + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, GetDomainDetailResponse.class); + } + + /** + * audit a domain info + * + * @param request the object contain some filed to audit the request domain to a normal state. + */ + public void uploadAudit(UploadAuditDataRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_AUDIT); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * search domain register + * + * @param request contains the domain to search. + */ + public SearchDomainResponse searchDomain(SearchDomainRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, VERSION_ONE, DOMAIN_SEARCH); + addParamsIfNotNull("domain", request.getDomain(), internalRequest); + return invokeHttpClient(internalRequest, SearchDomainResponse.class); + } + + /** + * get domain price + * + * @param request contains the domain to get price. + */ + public GetDomainPriceResponse getDomainPrice(GetDomainPriceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, VERSION_ONE, DOMAIN_PRICE); + addParamsIfNotNull("domain", request.getDomain(), internalRequest); + return invokeHttpClient(internalRequest, GetDomainPriceResponse.class); + } + + /** + * register domain + * + * @param request domain register detail + */ + public RegisterDomainResponse registerDomain(RegisterDomainRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_REGISTER); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, RegisterDomainResponse.class); + } + + /** + * async register domain + * + * @param request domain register detail + */ + public DomainOrderResponse asyncRegisterDomain(RegisterDomainRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_ASYNC_REGISTER); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DomainOrderResponse.class); + } + + /** + * register domain by template id + * + * @param request domain register detail and template id + */ + public RegisterDomainResponse registerDomainByTemplate(TemplateRegisterDomainRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_TEMPLATE_REGISTER); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, RegisterDomainResponse.class); + } + + /** + * async register domain by template id + * + * @param request domain register detail and template id + */ + public DomainOrderResponse asyncRegisterDomainByTemplate(TemplateRegisterDomainRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_ASYNC_TEMPLATE_REGISTER); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DomainOrderResponse.class); + } + + /** + * check order status after async register domain + * + * @param request + */ + public CheckOrderResponse checkOrderStatus(CheckOrderRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, VERSION_ONE, CHECK_DOMAIN_ORDER); + addParamsIfNotNull("bceOrderId", request.getBceOrderId(), internalRequest); + return invokeHttpClient(internalRequest, CheckOrderResponse.class); + } + + /** + * renew domain + * + * @param request domain renew detail + */ + public RenewDomainResponse renewDomain(RenewDomainRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_RENEW); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, RenewDomainResponse.class); + } + + /** + * renew domain async + * + * @param request domain renew detail + */ + public DomainOrderResponse asyncRenewDomain(RenewDomainRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, VERSION_ONE, DOMAIN_ASYNC_RENEW); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DomainOrderResponse.class); + } + + /** + * Creates and initializes a new request object for the specified bcd resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param version the version which the service method to invoke + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, String version, + String... pathVariables) { + List path = Lists.newArrayList(); + + path.add(version); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + private void addOrderPageListParamIfNotNull(OrderPageListRequest request, InternalRequest internalRequest) { + addPageListParamIfNotNull(request, internalRequest); + addParamsIfNotNull("order", request.getOrder(), internalRequest); + addParamsIfNotNull("orderBy", request.getOrderBy(), internalRequest); + } + + private void addPageListParamIfNotNull(PageListRequest request, InternalRequest internalRequest) { + addParamsIfNotNull("pageNo", request.getPageNo(), internalRequest); + addParamsIfNotNull("pageSize", request.getPageSize(), internalRequest); + } + + private void addParamsIfNotNull(String name, Object value, InternalRequest internalRequest) { + if (value == null) { + return; + } + internalRequest.addParameter(name, value.toString()); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcd/BcdClientConfiguration.java b/src/main/java/com/baidubce/services/bcd/BcdClientConfiguration.java new file mode 100644 index 00000000..a1874b13 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/BcdClientConfiguration.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd; + +import com.baidubce.BceClientConfiguration; + +/** + * @author yangzhensheng + * @date 2021/5/26 + * @desc Extended client configuration for bcd service. + */ +public class BcdClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/bcd/model/AddDomainResolveRequest.java b/src/main/java/com/baidubce/services/bcd/model/AddDomainResolveRequest.java new file mode 100644 index 00000000..362ae1f5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/AddDomainResolveRequest.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/5/26 + * + * @desc the object to create a domain resolve record + */ +public class AddDomainResolveRequest extends AbstractBceRequest { + + /** + * the record domain info + */ + private String domain; + + /** + * the record routine. the default value is (DEFAULT) some others like + * 移动(CMNET), 联通(CNC), 教育(EDU), 百度搜索引擎(SEARCH) and so on. + */ + private String view; + + /** + * the record type,such as A, AAAA, CNAME, NS, TXT, MX + */ + private String rdType; + + /** + * the record alive time + */ + private Integer ttl; + + /** + * the record data + */ + private String rdata; + + /** + * the zone such as 'baidu.com'. + */ + private String zoneName; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getView() { + return view; + } + + public void setView(String view) { + this.view = view; + } + + public String getRdType() { + return rdType; + } + + public void setRdType(String rdType) { + this.rdType = rdType; + } + + public Integer getTtl() { + return ttl; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public String getRdata() { + return rdata; + } + + public void setRdata(String rdata) { + this.rdata = rdata; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("domain", domain) + .add("view", view) + .add("rdType", rdType) + .add("ttl", ttl) + .add("rdata", rdata) + .add("zoneName", zoneName) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/AuditInfo.java b/src/main/java/com/baidubce/services/bcd/model/AuditInfo.java new file mode 100644 index 00000000..4d6da3ef --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/AuditInfo.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * the object contain detail audit info. + */ +public class AuditInfo extends AbstractBceRequest { + + /** + * the card No. + */ + private String ownerCode; + + /** + * the card data + */ + private String auditFile; + + /** + * the card type + */ + private String certType; + + public String getOwnerCode() { + return ownerCode; + } + + public void setOwnerCode(String ownerCode) { + this.ownerCode = ownerCode; + } + + public String getAuditFile() { + return auditFile; + } + + public void setAuditFile(String auditFile) { + this.auditFile = auditFile; + } + + public String getCertType() { + return certType; + } + + public void setCertType(String certType) { + this.certType = certType; + } + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("ownerCode", ownerCode) + .add("auditFile", auditFile) + .add("certType", certType) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/AuditTemplateInfoRequest.java b/src/main/java/com/baidubce/services/bcd/model/AuditTemplateInfoRequest.java new file mode 100644 index 00000000..04a9ea04 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/AuditTemplateInfoRequest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/5/26 + * @desc the object to audit a contact template info + */ +public class AuditTemplateInfoRequest extends AbstractBceRequest { + + /** + * the templateId define which template to audit + */ + private String templateId; + + /** + * the detail audit info + */ + private AuditInfo auditInfo; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public AuditInfo getAuditInfo() { + return auditInfo; + } + + public void setAuditInfo(AuditInfo auditInfo) { + this.auditInfo = auditInfo; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("templateId", templateId) + .add("auditInfo", auditInfo) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/ChangeDnsRequest.java b/src/main/java/com/baidubce/services/bcd/model/ChangeDnsRequest.java new file mode 100644 index 00000000..d82fc081 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/ChangeDnsRequest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/6/18 + * @desc change the dns configuration of domain object + */ +public class ChangeDnsRequest extends AbstractBceRequest { + + private String domain; + + /** + * the dns configutation + */ + private String[] dns; + + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String[] getDns() { + return dns; + } + + public void setDns(String[] dns) { + this.dns = dns; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("domain", domain) + .add("dns", dns) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/CheckOrderRequest.java b/src/main/java/com/baidubce/services/bcd/model/CheckOrderRequest.java new file mode 100644 index 00000000..532b5093 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/CheckOrderRequest.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class CheckOrderRequest extends AbstractBceRequest { + private String bceOrderId; + + public String getBceOrderId() { + return bceOrderId; + } + + public void setBceOrderId(String bceOrderId) { + this.bceOrderId = bceOrderId; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/CheckOrderResponse.java b/src/main/java/com/baidubce/services/bcd/model/CheckOrderResponse.java new file mode 100644 index 00000000..201ce6ca --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/CheckOrderResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CheckOrderResponse extends AbstractBceResponse { + List list; + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/DeleteDomainResolveRequest.java b/src/main/java/com/baidubce/services/bcd/model/DeleteDomainResolveRequest.java new file mode 100644 index 00000000..e87e5485 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/DeleteDomainResolveRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/5/26 + * @desc the object to delete a contact template + */ +public class DeleteDomainResolveRequest extends AbstractBceRequest { + + /** + * the zone info about a domain resolve record. + */ + private String zoneName; + + /** + * the unique info about a domain resolve record. + */ + private Integer recordId; + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public Integer getRecordId() { + return recordId; + } + + public void setRecordId(Integer recordId) { + this.recordId = recordId; + } + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("zoneName", zoneName) + .add("recordId", recordId) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/DeleteTemplateInfoRequest.java b/src/main/java/com/baidubce/services/bcd/model/DeleteTemplateInfoRequest.java new file mode 100644 index 00000000..34c15b78 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/DeleteTemplateInfoRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/5/26 + * @desc the object define which the contact template info to be deleted. + */ +public class DeleteTemplateInfoRequest extends AbstractBceRequest { + + /** + * the templateId define which the contact template info to be deleted. + */ + private String templateId; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public DeleteTemplateInfoRequest withTemplateId(String templateId) { + this.templateId = templateId; + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("templateId", templateId) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/DomainOrderResponse.java b/src/main/java/com/baidubce/services/bcd/model/DomainOrderResponse.java new file mode 100644 index 00000000..98f51cbd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/DomainOrderResponse.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DomainOrderResponse extends AbstractBceResponse { + private String bceOrderId; + + public String getBceOrderId() { + return bceOrderId; + } + + public void setBceOrderId(String bceOrderId) { + this.bceOrderId = bceOrderId; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/DomainRecord.java b/src/main/java/com/baidubce/services/bcd/model/DomainRecord.java new file mode 100644 index 00000000..8f3c0009 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/DomainRecord.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/6/17 + * @desc the domain resolve record. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class DomainRecord { + + @JsonProperty("recordId") + private int recordId; + + @JsonProperty("domain") + private String domain; + + @JsonProperty("view") + private String view; + + /** + * A、AAAA、CNAME、TXT、NS、MX、SOA、SRV + */ + @JsonProperty("rdtype") + private String rdType; + + /** + * time to live + */ + @JsonProperty("ttl") + private int timeToLive; + + /** + * the raw data could be cname or ip address + */ + @JsonProperty("rdata") + private String rawData; + + /** + * the zone name for this domain record + */ + @JsonProperty("zoneName") + private String zone; + + /** + * RUNNING、STOPPED + */ + @JsonProperty("status") + private String status; + + public int getRecordId() { + return recordId; + } + + public void setRecordId(int recordId) { + this.recordId = recordId; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getView() { + return view; + } + + public void setView(String view) { + this.view = view; + } + + public String getRdType() { + return rdType; + } + + public void setRdType(String rdType) { + this.rdType = rdType; + } + + public int getTimeToLive() { + return timeToLive; + } + + public void setTimeToLive(int timeToLive) { + this.timeToLive = timeToLive; + } + + public String getRawData() { + return rawData; + } + + public void setRawData(String rawData) { + this.rawData = rawData; + } + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("recordId", recordId) + .add("domain", domain) + .add("view", view) + .add("rdType", rdType) + .add("timeToLive", timeToLive) + .add("rawData", rawData) + .add("zone", zone) + .add("status", status) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/DomainStatusResult.java b/src/main/java/com/baidubce/services/bcd/model/DomainStatusResult.java new file mode 100644 index 00000000..dd24743e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/DomainStatusResult.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DomainStatusResult { + private String domainName; + private String status; + + public String getDomainName() { + return domainName; + } + + public void setDomainName(String domainName) { + this.domainName = domainName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/GetDomainAuditRequest.java b/src/main/java/com/baidubce/services/bcd/model/GetDomainAuditRequest.java new file mode 100644 index 00000000..407be0af --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/GetDomainAuditRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/6/17 + * @desc get the domain audit status object + */ +public class GetDomainAuditRequest extends AbstractBceRequest { + + private String domain; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("domain", domain) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/GetDomainAuditResponse.java b/src/main/java/com/baidubce/services/bcd/model/GetDomainAuditResponse.java new file mode 100644 index 00000000..be945212 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/GetDomainAuditResponse.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/6/17 + * @desc the domain status and description response object. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetDomainAuditResponse extends AbstractBceResponse { + + private String domain; + + /** + * the domian audit status,such as: NORMAL,NONVERIFY,AUDIT,REFUND and so on. + */ + private String verifyStatus; + + /** + * the description about the domain + */ + private String description; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getVerifyStatus() { + return verifyStatus; + } + + public void setVerifyStatus(String verifyStatus) { + this.verifyStatus = verifyStatus; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("domain", domain) + .add("verifyStatus", verifyStatus) + .add("description", description) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/GetDomainDetailRequest.java b/src/main/java/com/baidubce/services/bcd/model/GetDomainDetailRequest.java new file mode 100644 index 00000000..0d1399ff --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/GetDomainDetailRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/6/18 + * @desc the request to get the detail infomation about the domain. + */ +public class GetDomainDetailRequest extends AbstractBceRequest { + + private String domain; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("domain", domain) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/GetDomainDetailResponse.java b/src/main/java/com/baidubce/services/bcd/model/GetDomainDetailResponse.java new file mode 100644 index 00000000..f1149138 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/GetDomainDetailResponse.java @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.google.common.base.Objects; + +import java.sql.Timestamp; +import java.util.Date; +import java.util.List; + +/** + * @author yangzhensheng + * @date 2021/6/18 + * @desc the detail infomation about the domain. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetDomainDetailResponse extends AbstractBceResponse { + + private String domain; + private Timestamp registerTime; + private Date expireTime; + private long expireTimestamp; + private String userType; + private String contactId; + private String ownerChinese; + private String ownerEnglish; + private String contactChinese; + private String contactEnglish; + private String email; + private Region region; + private String addressChinese; + private String addressEnglish; + private String postalCode; + private String mobilePhone; + private String countryCode; + private String areaCode; + private String phoneNumber; + private Boolean privacy; + private Boolean supportPrivacy; + private String status; + private String verifyStatus; + private List dns; + private Boolean enableRecharge; + private String noRechargeReason; + private String namingStatus; + + public String getContactId() { + return contactId; + } + + public void setContactId(String contactId) { + this.contactId = contactId; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public Timestamp getRegisterTime() { + return registerTime; + } + + public void setRegisterTime(Timestamp registerTime) { + this.registerTime = registerTime; + } + + public Date getExpireTime() { + return expireTime; + } + + public void setExpireTime(Date expireTime) { + this.expireTime = expireTime; + } + + public long getExpireTimestamp() { + return expireTimestamp; + } + + public void setExpireTimestamp(long expireTimestamp) { + this.expireTimestamp = expireTimestamp; + } + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + public String getOwnerChinese() { + return ownerChinese; + } + + public void setOwnerChinese(String ownerChinese) { + this.ownerChinese = ownerChinese; + } + + public String getOwnerEnglish() { + return ownerEnglish; + } + + public void setOwnerEnglish(String ownerEnglish) { + this.ownerEnglish = ownerEnglish; + } + + public String getContactChinese() { + return contactChinese; + } + + public void setContactChinese(String contactChinese) { + this.contactChinese = contactChinese; + } + + public String getContactEnglish() { + return contactEnglish; + } + + public void setContactEnglish(String contactEnglish) { + this.contactEnglish = contactEnglish; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Region getRegion() { + return region; + } + + public void setRegion(Region region) { + this.region = region; + } + + public String getAddressChinese() { + return addressChinese; + } + + public void setAddressChinese(String addressChinese) { + this.addressChinese = addressChinese; + } + + public String getAddressEnglish() { + return addressEnglish; + } + + public void setAddressEnglish(String addressEnglish) { + this.addressEnglish = addressEnglish; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public Boolean getPrivacy() { + return privacy; + } + + public void setPrivacy(Boolean privacy) { + this.privacy = privacy; + } + + public Boolean getSupportPrivacy() { + return supportPrivacy; + } + + public void setSupportPrivacy(Boolean supportPrivacy) { + this.supportPrivacy = supportPrivacy; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getVerifyStatus() { + return verifyStatus; + } + + public void setVerifyStatus(String verifyStatus) { + this.verifyStatus = verifyStatus; + } + + public List getDns() { + return dns; + } + + public void setDns(List dns) { + this.dns = dns; + } + + public Boolean getEnableRecharge() { + return enableRecharge; + } + + public void setEnableRecharge(Boolean enableRecharge) { + this.enableRecharge = enableRecharge; + } + + public String getNoRechargeReason() { + return noRechargeReason; + } + + public void setNoRechargeReason(String noRechargeReason) { + this.noRechargeReason = noRechargeReason; + } + + public String getNamingStatus() { + return namingStatus; + } + + public void setNamingStatus(String namingStatus) { + this.namingStatus = namingStatus; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("domain", domain) + .add("registerTime", registerTime) + .add("expireTime", expireTime) + .add("expireTimestamp", expireTimestamp) + .add("userType", userType) + .add("ownerChinese", ownerChinese) + .add("ownerEnglish", ownerEnglish) + .add("contactChinese", contactChinese) + .add("contactEnglish", contactEnglish) + .add("email", email) + .add("region", region) + .add("addressChinese", addressChinese) + .add("addressEnglish", addressEnglish) + .add("postalCode", postalCode) + .add("mobilePhone", mobilePhone) + .add("countryCode", countryCode) + .add("areaCode", areaCode) + .add("phoneNumber", phoneNumber) + .add("privacy", privacy) + .add("supportPrivacy", supportPrivacy) + .add("status", status) + .add("verifyStatus", verifyStatus) + .add("dns", dns) + .add("enableRecharge", enableRecharge) + .add("noRechargeReason", noRechargeReason) + .add("namingStatus", namingStatus) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/GetDomainPriceRequest.java b/src/main/java/com/baidubce/services/bcd/model/GetDomainPriceRequest.java new file mode 100644 index 00000000..70f78067 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/GetDomainPriceRequest.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class GetDomainPriceRequest extends AbstractBceRequest { + private String domain; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/GetDomainPriceResponse.java b/src/main/java/com/baidubce/services/bcd/model/GetDomainPriceResponse.java new file mode 100644 index 00000000..44ff680f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/GetDomainPriceResponse.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetDomainPriceResponse extends AbstractBceResponse { + private String domain; + private String originPrice; + private String price; + private String rechargePrice; + private String transferInPrice; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getOriginPrice() { + return originPrice; + } + + public void setOriginPrice(String originPrice) { + this.originPrice = originPrice; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + + public String getRechargePrice() { + return rechargePrice; + } + + public void setRechargePrice(String rechargePrice) { + this.rechargePrice = rechargePrice; + } + + public String getTransferInPrice() { + return transferInPrice; + } + + public void setTransferInPrice(String transferInPrice) { + this.transferInPrice = transferInPrice; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/GetTemplateInfoRequest.java b/src/main/java/com/baidubce/services/bcd/model/GetTemplateInfoRequest.java new file mode 100644 index 00000000..8e7c7d63 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/GetTemplateInfoRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/5/26 + * @desc get a contact template info request object. + */ +public class GetTemplateInfoRequest extends AbstractBceRequest{ + + /** + * the templateId define which contatc template info to get. + */ + private String templateId; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public GetTemplateInfoRequest withTemplateId(String templateId) { + this.templateId = templateId; + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("templateId", templateId) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/GetTemplateInfoResponse.java b/src/main/java/com/baidubce/services/bcd/model/GetTemplateInfoResponse.java new file mode 100644 index 00000000..d5a9d53c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/GetTemplateInfoResponse.java @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.google.common.base.Objects; + +import java.util.Date; +import java.util.List; + +/** + * @author yangzhensheng + * @date 2021/5/29 + * + * @desc get a contact template info response object + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetTemplateInfoResponse extends AbstractBceResponse { + + /** + * the user type such as INDIVIDUAL or ENTERPRISE + */ + private String userType; + + /** + * the Chinese owner name + */ + private String ownerChinese; + + /** + * the Chinese owner's English name + */ + private String ownerEnglish; + + /** + * the Chinese contact name + */ + private String contactChinese; + + /** + * the Chinese contact's English name + */ + private String contactEnglish; + + /** + * the email + */ + private String email; + + /** + * Chinses address + */ + private String addressChinese; + + /** + * English address + */ + private String addressEnglish; + + /** + * the post code + */ + private String postalCode; + + /** + * the mobile phone number + */ + private String mobilePhone; + + /** + * the country code,such as the code of China is 086 + */ + private String countryCode; + + /** + * the area code represent the place + */ + private String areaCode; + + /** + * the phone number + */ + private String phoneNumber; + + /** + * the contact template's templateId + */ + private String templateId; + + /** + * the card number of the contact template owner + */ + private String ownerCode; + + /** + * the audit file + */ + private String auditFile; + + /** + * the contact template's audit status + */ + private String auditStatus; + + private List auditDetails; + + /** + * the start time of domain audit + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") + private Date auditStartTime; + + /** + * represent the contact template is complete or incomplete. + */ + private Boolean complete; + + private String remark; + + private Region region; + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + public String getOwnerChinese() { + return ownerChinese; + } + + public void setOwnerChinese(String ownerChinese) { + this.ownerChinese = ownerChinese; + } + + public String getOwnerEnglish() { + return ownerEnglish; + } + + public void setOwnerEnglish(String ownerEnglish) { + this.ownerEnglish = ownerEnglish; + } + + public String getContactChinese() { + return contactChinese; + } + + public void setContactChinese(String contactChinese) { + this.contactChinese = contactChinese; + } + + public String getContactEnglish() { + return contactEnglish; + } + + public void setContactEnglish(String contactEnglish) { + this.contactEnglish = contactEnglish; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getAddressChinese() { + return addressChinese; + } + + public void setAddressChinese(String addressChinese) { + this.addressChinese = addressChinese; + } + + public String getAddressEnglish() { + return addressEnglish; + } + + public void setAddressEnglish(String addressEnglish) { + this.addressEnglish = addressEnglish; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public String getOwnerCode() { + return ownerCode; + } + + public void setOwnerCode(String ownerCode) { + this.ownerCode = ownerCode; + } + + public String getAuditFile() { + return auditFile; + } + + public void setAuditFile(String auditFile) { + this.auditFile = auditFile; + } + + public String getAuditStatus() { + return auditStatus; + } + + public void setAuditStatus(String auditStatus) { + this.auditStatus = auditStatus; + } + + public List getAuditDetails() { + return auditDetails; + } + + public void setAuditDetails(List auditDetails) { + this.auditDetails = auditDetails; + } + + public Date getAuditStartTime() { + return auditStartTime; + } + + public void setAuditStartTime(Date auditStartTime) { + this.auditStartTime = auditStartTime; + } + + public Boolean getComplete() { + return complete; + } + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Region getRegion() { + return region; + } + + public void setRegion(Region region) { + this.region = region; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("userType", userType) + .add("ownerChinese", ownerChinese) + .add("ownerEnglish", ownerEnglish) + .add("contactChinese", contactChinese) + .add("contactEnglish", contactEnglish) + .add("email", email) + .add("addressChinese", addressChinese) + .add("addressEnglish", addressEnglish) + .add("postalCode", postalCode) + .add("mobilePhone", mobilePhone) + .add("countryCode", countryCode) + .add("areaCode", areaCode) + .add("phoneNumber", phoneNumber) + .add("templateId", templateId) + .add("ownerCode", ownerCode) + .add("auditFile", auditFile) + .add("auditStatus", auditStatus) + .add("auditDetails", auditDetails) + .add("auditStartTime", auditStartTime) + .add("complete", complete) + .add("remark", remark) + .add("region", region) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/ListDomainResolveRequest.java b/src/main/java/com/baidubce/services/bcd/model/ListDomainResolveRequest.java new file mode 100644 index 00000000..fe44065d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/ListDomainResolveRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/6/17 + * @desc the request object to get all domain resolve records. + */ +public class ListDomainResolveRequest extends OrderPageListRequest { + + private String domain; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("domain", domain) + .add("order", order) + .add("orderBy", orderBy) + .add("pageNo", pageNo) + .add("pageSize", pageSize) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/ListDomainResolveResponse.java b/src/main/java/com/baidubce/services/bcd/model/ListDomainResolveResponse.java new file mode 100644 index 00000000..5044daf2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/ListDomainResolveResponse.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.google.common.base.Objects; + +import java.util.List; + +/** + * @author yangzhensheng + * @date 2021/6/17 + * @desc the domain resolve record result list. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListDomainResolveResponse extends AbstractBceResponse { + + private String orderBy = ""; + + private String order = ""; + + private int pageNo = 1; + + private int pageSize = 0; + + private int totalCount = 0; + + private List result; + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("orderBy", orderBy) + .add("order", order) + .add("pageNo", pageNo) + .add("pageSize", pageSize) + .add("totalCount", totalCount) + .add("result", result) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/ListTemplateInfoRequest.java b/src/main/java/com/baidubce/services/bcd/model/ListTemplateInfoRequest.java new file mode 100644 index 00000000..77d6b8cf --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/ListTemplateInfoRequest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +/** + * @author yangzhensheng + * @date 2021/5/27 + * @desc get the template infos request object + */ +public class ListTemplateInfoRequest extends OrderPageListRequest { + private String userType; + private String email; + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/ListTemplateInfoResponse.java b/src/main/java/com/baidubce/services/bcd/model/ListTemplateInfoResponse.java new file mode 100644 index 00000000..fa01e188 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/ListTemplateInfoResponse.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.google.common.base.Objects; + +import java.util.List; + +/** + * @author yangzhensheng + * @date 2021/5/28 + * @desc get the contact template infos response object + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListTemplateInfoResponse extends AbstractBceResponse { + + /** + * the total result count num about the contact template infos. + */ + private int totalCount; + + /** + * the detail infos + */ + private List result; + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("totalCount", totalCount) + .add("result", result) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/ModifyTemplateInfoRequest.java b/src/main/java/com/baidubce/services/bcd/model/ModifyTemplateInfoRequest.java new file mode 100644 index 00000000..51fcfdf6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/ModifyTemplateInfoRequest.java @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/5/27 + * + * @desc the request object contain some filed info to add or update a domain resolve record. + */ +public class ModifyTemplateInfoRequest extends AbstractBceRequest { + + /** + * the templateId is must when the update action. + */ + private String templateId; + + /** + * the user type such as INDIVIDUAL or ENTERPRISE + */ + private String userType; + + /** + * the Chinese owner name + */ + private String ownerChinese; + + /** + * the Chinese owner's English name + */ + private String ownerEnglish; + + /** + * the Chinese contact name + */ + private String contactChinese; + + /** + * the Chinese contact's English name + */ + private String contactEnglish; + + /** + * the email + */ + private String email; + + /** + * Chinses address + */ + private String addressChinese; + + /** + * English address + */ + private String addressEnglish; + + /** + * the post code + */ + private String postalCode; + + /** + * the mobile phone number + */ + private String mobilePhone; + + /** + * the country code,such as the code of China is 086 + */ + private String countryCode; + + /** + * the area code represent the place + */ + private String areaCode; + + /** + * the phone number + */ + private String phoneNumber; + + private Region region; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + public String getOwnerChinese() { + return ownerChinese; + } + + public void setOwnerChinese(String ownerChinese) { + this.ownerChinese = ownerChinese; + } + + public String getOwnerEnglish() { + return ownerEnglish; + } + + public void setOwnerEnglish(String ownerEnglish) { + this.ownerEnglish = ownerEnglish; + } + + public String getContactChinese() { + return contactChinese; + } + + public void setContactChinese(String contactChinese) { + this.contactChinese = contactChinese; + } + + public String getContactEnglish() { + return contactEnglish; + } + + public void setContactEnglish(String contactEnglish) { + this.contactEnglish = contactEnglish; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getAddressChinese() { + return addressChinese; + } + + public void setAddressChinese(String addressChinese) { + this.addressChinese = addressChinese; + } + + public String getAddressEnglish() { + return addressEnglish; + } + + public void setAddressEnglish(String addressEnglish) { + this.addressEnglish = addressEnglish; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public Region getRegion() { + return region; + } + + public void setRegion(Region region) { + this.region = region; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("templateId", templateId) + .add("userType", userType) + .add("ownerChinese", ownerChinese) + .add("ownerEnglish", ownerEnglish) + .add("contactChinese", contactChinese) + .add("contactEnglish", contactEnglish) + .add("email", email) + .add("addressChinese", addressChinese) + .add("addressEnglish", addressEnglish) + .add("postalCode", postalCode) + .add("mobilePhone", mobilePhone) + .add("countryCode", countryCode) + .add("areaCode", areaCode) + .add("phoneNumber", phoneNumber) + .add("region", region) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/ModifyTemplateInfoResponse.java b/src/main/java/com/baidubce/services/bcd/model/ModifyTemplateInfoResponse.java new file mode 100644 index 00000000..2936eec6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/ModifyTemplateInfoResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/5/27 + * @desc + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ModifyTemplateInfoResponse extends AbstractBceResponse { + + /** + * the result templateId when add or update a domain resolve record. + */ + private String templateId; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("templateId", templateId) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/OrderInfo.java b/src/main/java/com/baidubce/services/bcd/model/OrderInfo.java new file mode 100644 index 00000000..2a549e49 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/OrderInfo.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class OrderInfo { + private String resourceId; + private String status; + private Date createTime; + private Date updateTime; + private String failReason; + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getFailReason() { + return failReason; + } + + public void setFailReason(String failReason) { + this.failReason = failReason; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/OrderPageListRequest.java b/src/main/java/com/baidubce/services/bcd/model/OrderPageListRequest.java new file mode 100644 index 00000000..62d74115 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/OrderPageListRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +public class OrderPageListRequest extends PageListRequest { + protected String order; + + protected String orderBy; + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcd/model/PageListRequest.java b/src/main/java/com/baidubce/services/bcd/model/PageListRequest.java new file mode 100644 index 00000000..c91e1b8c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/PageListRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class PageListRequest extends AbstractBceRequest { + protected Integer pageNo; + protected Integer pageSize; + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcd/model/Region.java b/src/main/java/com/baidubce/services/bcd/model/Region.java new file mode 100644 index 00000000..9f5f6c65 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/Region.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/6/18 + * @desc the region info. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class Region { + + private String province; + + private String city; + + private String country; + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("province", province) + .add("city", city) + .add("country", country) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/RegisterDomainRequest.java b/src/main/java/com/baidubce/services/bcd/model/RegisterDomainRequest.java new file mode 100644 index 00000000..9435f39f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/RegisterDomainRequest.java @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +public class RegisterDomainRequest extends AbstractBceRequest { + private String domain; + private String userType; + private String ownerChinese; + private String ownerEnglish; + private String contactChinese; + private String contactEnglish; + private String email; + private Integer years; + private String addressChinese; + private String addressEnglish; + private String postalCode; + private String mobilePhone; + private String areaCode; + private String phoneNumber; + private Region region; + private Boolean privacy; + private List dns; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + public String getOwnerChinese() { + return ownerChinese; + } + + public void setOwnerChinese(String ownerChinese) { + this.ownerChinese = ownerChinese; + } + + public String getOwnerEnglish() { + return ownerEnglish; + } + + public void setOwnerEnglish(String ownerEnglish) { + this.ownerEnglish = ownerEnglish; + } + + public String getContactChinese() { + return contactChinese; + } + + public void setContactChinese(String contactChinese) { + this.contactChinese = contactChinese; + } + + public String getContactEnglish() { + return contactEnglish; + } + + public void setContactEnglish(String contactEnglish) { + this.contactEnglish = contactEnglish; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Integer getYears() { + return years; + } + + public void setYears(Integer years) { + this.years = years; + } + + public String getAddressChinese() { + return addressChinese; + } + + public void setAddressChinese(String addressChinese) { + this.addressChinese = addressChinese; + } + + public String getAddressEnglish() { + return addressEnglish; + } + + public void setAddressEnglish(String addressEnglish) { + this.addressEnglish = addressEnglish; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public Region getRegion() { + return region; + } + + public void setRegion(Region region) { + this.region = region; + } + + public Boolean getPrivacy() { + return privacy; + } + + public void setPrivacy(Boolean privacy) { + this.privacy = privacy; + } + + public List getDns() { + return dns; + } + + public void setDns(List dns) { + this.dns = dns; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public static class Region { + private String province; + private String city; + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/RegisterDomainResponse.java b/src/main/java/com/baidubce/services/bcd/model/RegisterDomainResponse.java new file mode 100644 index 00000000..ec9288d0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/RegisterDomainResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class RegisterDomainResponse extends AbstractBceResponse { + private String bceOrderId; + private String domain; + private boolean registerResult; + + public String getBceOrderId() { + return bceOrderId; + } + + public void setBceOrderId(String bceOrderId) { + this.bceOrderId = bceOrderId; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public boolean isRegisterResult() { + return registerResult; + } + + public void setRegisterResult(boolean registerResult) { + this.registerResult = registerResult; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/RenewDomainRequest.java b/src/main/java/com/baidubce/services/bcd/model/RenewDomainRequest.java new file mode 100644 index 00000000..b63450cc --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/RenewDomainRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class RenewDomainRequest extends AbstractBceRequest { + private String domain; + private Integer years; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public Integer getYears() { + return years; + } + + public void setYears(Integer years) { + this.years = years; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bcd/model/RenewDomainResponse.java b/src/main/java/com/baidubce/services/bcd/model/RenewDomainResponse.java new file mode 100644 index 00000000..ed21098f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/RenewDomainResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class RenewDomainResponse extends AbstractBceResponse { + private String bceOrderId; + private Boolean renewResult; + + public String getBceOrderId() { + return bceOrderId; + } + + public void setBceOrderId(String bceOrderId) { + this.bceOrderId = bceOrderId; + } + + public Boolean getRenewResult() { + return renewResult; + } + + public void setRenewResult(Boolean renewResult) { + this.renewResult = renewResult; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/SearchDomainRequest.java b/src/main/java/com/baidubce/services/bcd/model/SearchDomainRequest.java new file mode 100644 index 00000000..ff8b4d44 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/SearchDomainRequest.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class SearchDomainRequest extends AbstractBceRequest { + private String domain; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/SearchDomainResponse.java b/src/main/java/com/baidubce/services/bcd/model/SearchDomainResponse.java new file mode 100644 index 00000000..31bb2766 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/SearchDomainResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class SearchDomainResponse extends AbstractBceResponse { + private List domainBasicInfoList; + + public List getDomainBasicInfoList() { + return domainBasicInfoList; + } + + public void setDomainBasicInfoList(List domainBasicInfoList) { + this.domainBasicInfoList = domainBasicInfoList; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/TemplateRegisterDomainRequest.java b/src/main/java/com/baidubce/services/bcd/model/TemplateRegisterDomainRequest.java new file mode 100644 index 00000000..f4a5def1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/TemplateRegisterDomainRequest.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +public class TemplateRegisterDomainRequest extends AbstractBceRequest { + private String templateId; + private String domain; + private int years; + private Boolean privacy; + private List dns; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public int getYears() { + return years; + } + + public void setYears(int years) { + this.years = years; + } + + public Boolean getPrivacy() { + return privacy; + } + + public void setPrivacy(Boolean privacy) { + this.privacy = privacy; + } + + public List getDns() { + return dns; + } + + public void setDns(List dns) { + this.dns = dns; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/TemplateUpdateOwnerRequest.java b/src/main/java/com/baidubce/services/bcd/model/TemplateUpdateOwnerRequest.java new file mode 100644 index 00000000..a0fdb83d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/TemplateUpdateOwnerRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class TemplateUpdateOwnerRequest extends AbstractBceRequest { + private String domain; + private String templateId; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bcd/model/UpdateContactRequest.java b/src/main/java/com/baidubce/services/bcd/model/UpdateContactRequest.java new file mode 100644 index 00000000..6aba37e5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/UpdateContactRequest.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yangzhensheng + * @date 2021/6/17 + * @desc the object update the contact info about the domain. + */ +public class UpdateContactRequest extends AbstractBceRequest { + + private String domain; + + private String userType; + + private String contactChinese; + + private String contactEnglish; + + private String email; + + private String addressChinese; + + private String addressEnglish; + + private String postalCode; + + private String mobilePhone; + + private String countryCode; + + private String areaCode; + + private String phoneNumber; + + private Region region; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + public String getContactChinese() { + return contactChinese; + } + + public void setContactChinese(String contactChinese) { + this.contactChinese = contactChinese; + } + + public String getContactEnglish() { + return contactEnglish; + } + + public void setContactEnglish(String contactEnglish) { + this.contactEnglish = contactEnglish; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getAddressChinese() { + return addressChinese; + } + + public void setAddressChinese(String addressChinese) { + this.addressChinese = addressChinese; + } + + public String getAddressEnglish() { + return addressEnglish; + } + + public void setAddressEnglish(String addressEnglish) { + this.addressEnglish = addressEnglish; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public Region getRegion() { + return region; + } + + public void setRegion(Region region) { + this.region = region; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/UpdateDomainResolveRequest.java b/src/main/java/com/baidubce/services/bcd/model/UpdateDomainResolveRequest.java new file mode 100644 index 00000000..fc185385 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/UpdateDomainResolveRequest.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/5/26 + * + * @desc the request object to update a domain resolve record. + */ +public class UpdateDomainResolveRequest extends AbstractBceRequest { + + /** + * the record domain info + */ + private String domain; + + /** + * the record routine. the default value is (DEFAULT) some others like + * 移动(CMNET), 联通(CNC), 教育(EDU), 百度搜索引擎(SEARCH) and so on. + */ + private String view; + + /** + * the record type,such as A, AAAA, CNAME, NS, TXT, MX + */ + private String rdType; + + /** + * the record alive time + */ + private Integer ttl; + + /** + * the record data + */ + private String rdata; + + /** + * the zone such as 'baidu.com'. + */ + private String zoneName; + + /** + * the unique info about a domain resolve record. + */ + private Integer recordId; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getView() { + return view; + } + + public void setView(String view) { + this.view = view; + } + + public String getRdType() { + return rdType; + } + + public void setRdType(String rdType) { + this.rdType = rdType; + } + + public Integer getTtl() { + return ttl; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public String getRdata() { + return rdata; + } + + public void setRdata(String rdata) { + this.rdata = rdata; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public Integer getRecordId() { + return recordId; + } + + public void setRecordId(Integer recordId) { + this.recordId = recordId; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("domain", domain) + .add("view", view) + .add("rdType", rdType) + .add("ttl", ttl) + .add("rdata", rdata) + .add("zoneName", zoneName) + .add("recordId", recordId) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/UpdateOwnerRequest.java b/src/main/java/com/baidubce/services/bcd/model/UpdateOwnerRequest.java new file mode 100644 index 00000000..d92b6e50 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/UpdateOwnerRequest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/6/17 + * @desc the object update the owner info about the domain. + */ +public class UpdateOwnerRequest extends AbstractBceRequest { + + private String domain; + + private String userType; + + private String ownerChinese; + + private String ownerEnglish; + + private String contactChinese; + + private String contactEnglish; + + private String email; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + public String getOwnerChinese() { + return ownerChinese; + } + + public void setOwnerChinese(String ownerChinese) { + this.ownerChinese = ownerChinese; + } + + public String getOwnerEnglish() { + return ownerEnglish; + } + + public void setOwnerEnglish(String ownerEnglish) { + this.ownerEnglish = ownerEnglish; + } + + public String getContactChinese() { + return contactChinese; + } + + public void setContactChinese(String contactChinese) { + this.contactChinese = contactChinese; + } + + public String getContactEnglish() { + return contactEnglish; + } + + public void setContactEnglish(String contactEnglish) { + this.contactEnglish = contactEnglish; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("domain", domain) + .add("userType", userType) + .add("ownerChinese", ownerChinese) + .add("ownerEnglish", ownerEnglish) + .add("contactChinese", contactChinese) + .add("contactEnglish", contactEnglish) + .add("email", email) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bcd/model/UploadAuditDataRequest.java b/src/main/java/com/baidubce/services/bcd/model/UploadAuditDataRequest.java new file mode 100644 index 00000000..d4064f30 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcd/model/UploadAuditDataRequest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcd.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.google.common.base.Objects; + +/** + * @author yangzhensheng + * @date 2021/6/18 + * @desc the object to audit a domain to NORMAL domain status. + */ +public class UploadAuditDataRequest extends AbstractBceRequest { + + /** + * the audit file name + */ + private String file; + + /** + * the file No. + */ + private String certificationNo; + + /** + * which domain to audit. + */ + private String domain; + + public String getFile() { + return file; + } + + public void setFile(String file) { + this.file = file; + } + + public String getCertificationNo() { + return certificationNo; + } + + public void setCertificationNo(String certificationNo) { + this.certificationNo = certificationNo; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("file", file) + .add("certificationNo", certificationNo) + .add("domain", domain) + .toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bci/BciClient.java b/src/main/java/com/baidubce/services/bci/BciClient.java new file mode 100644 index 00000000..dc11c540 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/BciClient.java @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bci; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import com.baidubce.services.bci.model.instance.CreateInstanceRequest; +import com.baidubce.services.bci.model.instance.CreateInstanceResponse; +import com.baidubce.services.bci.model.instance.DeleteInstanceRequest; +import com.baidubce.services.bci.model.instance.DeleteInstanceResponse; + +import com.baidubce.services.bci.model.instance.GetInstanceRequest; +import com.baidubce.services.bci.model.instance.GetInstanceResponse; +import com.baidubce.services.bci.model.instance.ListInstancesRequest; +import com.baidubce.services.bci.model.instance.ListInstancesResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; + +/** + * Provides the client for accessing the Baidu Cloud network Service bci part. + */ +public class BciClient extends AbstractBceClient { + + /** + * The logger for this class. + */ + private static final Logger LOGGER = LoggerFactory.getLogger(BciClient.class); + + + private static final String MARKER = "marker"; + private static final String MAX_KEYS = "maxKeys"; + private static final String KEYWORD_TYPE = "keywordType"; + private static final String KEYWORD = "keyword"; + + /** + * The version of bci service. + */ + private static final String VERSION = "v2"; + + /** + * The prefix of bci service. + */ + private static final String BCI_PREFIX = "instance"; + + /** + * The prefix of bci batch del. + */ + private static final String BATCH_DEL = "batchDel"; + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String INSTANCE_ID_MESSAGE_KEY = "instanceId"; + + /** + * Responsible for handling httpResponses from all network service calls. + */ + private static final HttpResponseHandler[] BCI_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on network. + */ + public BciClient() { + this(new BciClientConfiguration()); + } + + /** + * Constructs a new network client using the client configuration to access network. + * + * @param clientConfiguration The network client configuration options controlling how this client + * connects to network (e.g. proxy settings, retry counts, etc). + */ + public BciClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, BCI_HANDLERS); + } + + /** + * Creates and initializes a new request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT ) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * Create a bci instance with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + *

+ * + * @param request The request containing all options for creating a bci instance. + * @return List of bci instanceId newly created + * @throws BceClientException + */ + public CreateInstanceResponse createInstance(CreateInstanceRequest request) + throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, BCI_PREFIX); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateInstanceResponse.class); + } + + /** + * Describe a bci instance with the specified options. + * @param instanceId + * @return DeleteInstanceResponse + * @throws BceClientException + */ + public DeleteInstanceResponse deleteInstance(String instanceId) throws BceClientException { + return deleteInstance(instanceId, false); + } + + /** + * Delete a bci instance with the specified options. + * @param instanceId + * @param relatedReleaseFlag + * @return DeleteInstanceResponse + * @throws BceClientException + */ + public DeleteInstanceResponse deleteInstance(String instanceId, Boolean relatedReleaseFlag) + throws BceClientException { + checkStringNotEmpty(instanceId, checkEmptyExceptionMessageFormat(INSTANCE_ID_MESSAGE_KEY)); + checkNotNull(relatedReleaseFlag, "relatedReleaseFlag should not be null."); + DeleteInstanceRequest request = new DeleteInstanceRequest(); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, BCI_PREFIX, instanceId); + internalRequest.addParameter("relatedReleaseFlag", relatedReleaseFlag.toString()); + internalRequest.addParameter("clientToken", request.getClientToken()); + return invokeHttpClient(internalRequest, DeleteInstanceResponse.class); + } + + /** + * batch delete bci instance with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param request The request containing all options for batch deleting bci instance. + * @return List of bci instanceId newly deleted DeleteInstanceResponse void + * @throws BceClientException + */ + public DeleteInstanceResponse batchDeleteInstance(DeleteInstanceRequest request) + throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getInstanceIds(), "instanceId should not be null."); + checkNotNull(request.getRelatedReleaseFlag(), "relatedReleaseFlag should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, BCI_PREFIX, BATCH_DEL); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DeleteInstanceResponse.class); + } + + /** + * Get the bci instance with the specified options. + * @param String instanceId + * @return GetInstanceResponse + * @throws BceClientException + */ + public GetInstanceResponse getInstance(String instanceId) throws BceClientException { + return getInstance(new GetInstanceRequest().setInstanceId(instanceId)); + } + + /** + * Get the bci instance with the specified options. + * @param GetInstanceRequest request + * @return GetInstanceResponse + * @throws BceClientException + */ + public GetInstanceResponse getInstance(GetInstanceRequest request) throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, BCI_PREFIX, request.getInstanceId()); + return invokeHttpClient(internalRequest, GetInstanceResponse.class); + } + + /** + * Get the bci instance with the specified options. + * @param String instanceId + * @return GetInstanceResponse + * @throws BceClientException + */ + public ListInstancesResponse listInstances() throws BceClientException { + return listInstances(new ListInstancesRequest()); + } + + /** + * Get the bci instance with the specified options. + * @param ListInstancesRequest request + * @return GetInstanceResponse + * @throws BceClientException + */ + public ListInstancesResponse listInstances(ListInstancesRequest request) throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, BCI_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (request.getKeywordType() != null) { + internalRequest.addParameter(KEYWORD_TYPE, request.getKeywordType()); + } + if (request.getKeyword() != null) { + internalRequest.addParameter(KEYWORD, request.getKeyword()); + } + return invokeHttpClient(internalRequest, ListInstancesResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/bci/BciClientConfiguration.java b/src/main/java/com/baidubce/services/bci/BciClientConfiguration.java new file mode 100644 index 00000000..112615d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/BciClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bci; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for bci service. + */ +public class BciClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/bci/model/common/Environment.java b/src/main/java/com/baidubce/services/bci/model/common/Environment.java new file mode 100644 index 00000000..f483b290 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/Environment.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +/** + * The environment variable of container + */ +public class Environment { + + /** + * The key of environment variable + */ + private String key; + + /** + * The value of environment variable + */ + private String value; + + public Environment() { + + } + + public Environment(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public Environment setKey(String key) { + this.key = key; + return this; + } + + public String getValue() { + return value; + } + + public Environment setValue(String value) { + this.value = value; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/common/ExecAction.java b/src/main/java/com/baidubce/services/bci/model/common/ExecAction.java new file mode 100644 index 00000000..e6adb3b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/ExecAction.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +import java.util.List; + +/** + * The exec action of container + */ +public class ExecAction { + + /** + * The command to execute + */ + private List command; + + /** + * The constructor of ExecAction. + */ + public ExecAction() { + + } + + /** + * The constructor of ExecAction. + * + * @param command The command to execute + */ + public ExecAction(List command) { + this.command = command; + } + + public List getCommand() { + return command; + } + + public void setCommand(List command) { + this.command = command; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/common/GRPCAction.java b/src/main/java/com/baidubce/services/bci/model/common/GRPCAction.java new file mode 100644 index 00000000..51622c0d --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/GRPCAction.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +/** + * The grpc action of container + */ +public class GRPCAction { + /** + * The port of grpc service + */ + private int port; + /** + * The name of grpc service + */ + private String service; + + /** + * The constructor of GRPCAction + */ + public GRPCAction() { + + } + + /** + * The constructor of GRPCAction + * @param port The port of grpc service + * @param service The name of grpc service + */ + public GRPCAction(int port, String service) { + this.port = port; + this.service = service; + } + + public int getPort() { + return port; + } + + public GRPCAction setPort(int port) { + this.port = port; + return this; + } + + public String getService() { + return service; + } + + public GRPCAction setService(String service) { + this.service = service; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/common/HTTPGetAction.java b/src/main/java/com/baidubce/services/bci/model/common/HTTPGetAction.java new file mode 100644 index 00000000..dcc5299f --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/HTTPGetAction.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +import java.util.List; + +/** + * HTTPGetAction describes an action based on HTTP Get requests. + */ +public class HTTPGetAction { + /** + * The path to access on the HTTP server + */ + private String path; + + /** + * The port of the container to send the HTTP request + */ + private int port; + + /** + * The host name to connect to, defaults to the pod IP + */ + private String host; + + /** + * The scheme to use for connecting to the host + */ + private String scheme; + + /** + * Custom headers to set in the request + */ + private List httpHeaders; + + /** + * The constructor of HTTPGetAction. + */ + public HTTPGetAction() { + + } + + /** + * The constructor of HTTPGetAction. + * + * @param path The path to access on the HTTP server + * @param port The port of the container to send the HTTP request + * @param host The host name to connect to, defaults to the pod IP + * @param scheme The scheme to use for connecting to the host + * @param httpHeaders Custom headers to set in the request + */ + public HTTPGetAction(String path, int port, String host, String scheme, List httpHeaders) { + this.path = path; + this.port = port; + this.host = host; + this.scheme = scheme; + this.httpHeaders = httpHeaders; + } + + public String getPath() { + return path; + } + + public HTTPGetAction setPath(String path) { + this.path = path; + return this; + } + + public int getPort() { + return port; + } + + public HTTPGetAction setPort(int port) { + this.port = port; + return this; + } + + public String getHost() { + return host; + } + + public HTTPGetAction setHost(String host) { + this.host = host; + return this; + } + + public String getScheme() { + return scheme; + } + + public HTTPGetAction setScheme(String scheme) { + this.scheme = scheme; + return this; + } + + public List getHttpHeaders() { + return httpHeaders; + } + + public HTTPGetAction setHttpHeaders(List httpHeaders) { + this.httpHeaders = httpHeaders; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/common/HTTPHeader.java b/src/main/java/com/baidubce/services/bci/model/common/HTTPHeader.java new file mode 100644 index 00000000..a6d286d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/HTTPHeader.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +/** + * The http header of http action + */ +public class HTTPHeader { + + /** + * The name of http header + */ + private String name; + + /** + * The value of http header + */ + private String value; + + /** + * Construct a new HTTPHeader object. + */ + public HTTPHeader() { + + } + + /** + * Construct a new HTTPHeader object. + * + * @param name The name of http header + * @param value The value of http header + */ + public HTTPHeader(String name, String value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public HTTPHeader setName(String name) { + this.name = name; + return this; + } + + public String getValue() { + return value; + } + + public HTTPHeader setValue(String value) { + this.value = value; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/common/ImageRegistryCredential.java b/src/main/java/com/baidubce/services/bci/model/common/ImageRegistryCredential.java new file mode 100644 index 00000000..f8213735 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/ImageRegistryCredential.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +/** + * The credential of image registry + */ +public class ImageRegistryCredential { + + /** + * The server of image registry + */ + private String server; + + /** + * The user name of image registry + */ + private String userName; + + /** + * The password of image registry + */ + private String password; + + /** + * Construct a new ImageRegistryCredential object. + */ + public ImageRegistryCredential() { + + } + + /** + * Construct a new ImageRegistryCredential object. + * + * @param server The server of image registry + * @param userName The user name of image registry + * @param password The password of image registry + */ + public ImageRegistryCredential(String server, String userName, String password) { + this.server = server; + this.userName = userName; + this.password = password; + } + + public String getServer() { + return server; + } + + public ImageRegistryCredential setServer(String server) { + this.server = server; + return this; + } + + public String getUserName() { + return userName; + } + + public ImageRegistryCredential setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getPassword() { + return password; + } + + public ImageRegistryCredential setPassword(String password) { + this.password = password; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/common/Port.java b/src/main/java/com/baidubce/services/bci/model/common/Port.java new file mode 100644 index 00000000..ceeb7c8a --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/Port.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +/** + * The port of container + */ +public class Port { + + /** + * The port of protocol + */ + private int port; + + /** + * The protocol of port + */ + private String protocol; + + /** + * The name of port + */ + private String name; + + /** + * The constructor of Port + */ + public Port() { + + } + + /** + * The constructor of Port + * @param port The port of protocol + * @param protocol The protocol of port + * @param name The name of port + */ + public Port(int port, String protocol, String name) { + this.port = port; + this.protocol = protocol; + this.name = name; + } + + public int getPort() { + return port; + } + + public Port setPort(int port) { + this.port = port; + return this; + } + + public String getProtocol() { + return protocol; + } + + public Port setProtocol(String protocol) { + this.protocol = protocol; + return this; + } + + public String getName() { + return name; + } + + public Port setName(String name) { + this.name = name; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/common/Probe.java b/src/main/java/com/baidubce/services/bci/model/common/Probe.java new file mode 100644 index 00000000..b2540c3d --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/Probe.java @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +/** + * The probe of container + */ +public class Probe { + + /** + * The exec action of probe + */ + private ExecAction exec; + + /** + * The http get action of probe + */ + private HTTPGetAction httpGet; + + /** + * The tcp socket action of probe + */ + private TCPSocketAction tcpSocket; + + /** + * The grpc action of probe + */ + private GRPCAction grpc; + + /** + * The initial delay seconds of probe + */ + private int initialDelaySeconds; + + /** + * The timeout seconds of probe + */ + private int timeoutSeconds; + + /** + * The period seconds of probe + */ + private int periodSeconds; + + /** + * The success threshold of probe + */ + private int successThreshold; + + /** + * The failure threshold of probe + */ + private int failureThreshold; + + /** + * The termination grace period seconds of probe + */ + private long terminationGracePeriodSeconds; + + /** + * The constructor of Probe + */ + public Probe() { + + } + + /** + * The constructor of Probe + * @param exec The exec action of probe + * @param httpGet The http get action of probe + * @param tcpSocket The tcp socket action of probe + * @param grpc The grpc action of probe + * @param initialDelaySeconds The initial delay seconds of probe + * @param timeoutSeconds The timeout seconds of probe + * @param periodSeconds The period seconds of probe + * @param successThreshold The success threshold of probe + * @param failureThreshold The failure threshold of probe + * @param terminationGracePeriodSeconds The termination grace period seconds of probe + */ + public Probe(ExecAction exec, HTTPGetAction httpGet, TCPSocketAction tcpSocket, GRPCAction grpc, + int initialDelaySeconds, int timeoutSeconds, int periodSeconds, int successThreshold, + int failureThreshold, long terminationGracePeriodSeconds) { + this.exec = exec; + this.httpGet = httpGet; + this.tcpSocket = tcpSocket; + this.grpc = grpc; + this.initialDelaySeconds = initialDelaySeconds; + this.timeoutSeconds = timeoutSeconds; + this.periodSeconds = periodSeconds; + this.successThreshold = successThreshold; + this.failureThreshold = failureThreshold; + this.terminationGracePeriodSeconds = terminationGracePeriodSeconds; + } + + public ExecAction getExec() { + return exec; + } + + public Probe setExec(ExecAction exec) { + this.exec = exec; + return this; + } + + public HTTPGetAction getHttpGet() { + return httpGet; + } + + public Probe setHttpGet(HTTPGetAction httpGet) { + this.httpGet = httpGet; + return this; + } + + public TCPSocketAction getTcpSocket() { + return tcpSocket; + } + + public Probe setTcpSocket(TCPSocketAction tcpSocket) { + this.tcpSocket = tcpSocket; + return this; + } + + public GRPCAction getGrpc() { + return grpc; + } + + public Probe setGrpc(GRPCAction grpc) { + this.grpc = grpc; + return this; + } + + public int getInitialDelaySeconds() { + return initialDelaySeconds; + } + + public Probe setInitialDelaySeconds(int initialDelaySeconds) { + this.initialDelaySeconds = initialDelaySeconds; + return this; + } + + public int getTimeoutSeconds() { + return timeoutSeconds; + } + + public Probe setTimeoutSeconds(int timeoutSeconds) { + this.timeoutSeconds = timeoutSeconds; + return this; + } + + public int getPeriodSeconds() { + return periodSeconds; + } + + public Probe setPeriodSeconds(int periodSeconds) { + this.periodSeconds = periodSeconds; + return this; + } + + public int getSuccessThreshold() { + return successThreshold; + } + + public Probe setSuccessThreshold(int successThreshold) { + this.successThreshold = successThreshold; + return this; + } + + public int getFailureThreshold() { + return failureThreshold; + } + + public Probe setFailureThreshold(int failureThreshold) { + this.failureThreshold = failureThreshold; + return this; + } + + public long getTerminationGracePeriodSeconds() { + return terminationGracePeriodSeconds; + } + + public Probe setTerminationGracePeriodSeconds(long terminationGracePeriodSeconds) { + this.terminationGracePeriodSeconds = terminationGracePeriodSeconds; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/common/TCPSocketAction.java b/src/main/java/com/baidubce/services/bci/model/common/TCPSocketAction.java new file mode 100644 index 00000000..4f706845 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/TCPSocketAction.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +/** + * The tcp socket action of container + */ +public class TCPSocketAction { + + /** + * The port of tcp socket + */ + private int port; + + /** + * The host of tcp socket + */ + private String host; + + /** + * The constructor of TCPSocketAction + */ + public TCPSocketAction() { + + } + + /** + * The constructor of TCPSocketAction + * @param port The port of tcp socket + * @param host The host of tcp socket + */ + public TCPSocketAction(int port, String host) { + this.port = port; + this.host = host; + } + + public int getPort() { + return port; + } + + public TCPSocketAction setPort(int port) { + this.port = port; + return this; + } + + public String getHost() { + return host; + } + + public TCPSocketAction setHost(String host) { + this.host = host; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/common/Tag.java b/src/main/java/com/baidubce/services/bci/model/common/Tag.java new file mode 100644 index 00000000..1b5ce6c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/common/Tag.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.common; + +/** + * The tag of resource + */ +public class Tag { + + /** + * The key of tag + */ + private String tagKey; + + /** + * The value of tag + */ + private String tagValue; + + /** + * Construct a new Tag object. + */ + public Tag() { + } + + /** + * Construct a new Tag object. + * + * @param tagKey The key of tag + * @param tagValue The value of tag + */ + public Tag(String tagKey, String tagValue) { + this.tagKey = tagKey; + this.tagValue = tagValue; + } + + public String getTagKey() { + return tagKey; + } + + public Tag setTagKey(String tagKey) { + this.tagKey = tagKey; + return this; + } + + public String getTagValue() { + return tagValue; + } + + public Tag setTagValue(String tagValue) { + this.tagValue = tagValue; + return this; + } + + @Override + public String toString() { + return "Tag{" + + "tagKey='" + tagKey + '\'' + + ", tagValue='" + tagValue + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Tag tag = (Tag) o; + + if (tagKey != null ? !tagKey.equals(tag.tagKey) : tag.tagKey != null) { + return false; + } + return tagValue != null ? tagValue.equals(tag.tagValue) : tag.tagValue == null; + } + + @Override + public int hashCode() { + int result = tagKey != null ? tagKey.hashCode() : 0; + result = 31 * result + (tagValue != null ? tagValue.hashCode() : 0); + return result; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/container/Container.java b/src/main/java/com/baidubce/services/bci/model/container/Container.java new file mode 100644 index 00000000..48da473a --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/container/Container.java @@ -0,0 +1,303 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.container; + +import com.baidubce.services.bci.model.common.Environment; +import com.baidubce.services.bci.model.common.Port; +import com.baidubce.services.bci.model.common.Probe; +import com.baidubce.services.bci.model.volume.VolumeMount; +import com.baidubce.services.bci.model.securitycontext.ContainerSecurityContext; + +import java.util.List; + +/** + * The container of pod + */ +public class Container { + + /** + * The name of container + */ + private String name; + + /** + * The image of container + */ + private String image; + + /** + * The cpu count of container + */ + private float cpu; + + /** + * The gpu count of container + */ + private float gpu; + + /** + * The memory of container + */ + private float memory; + + /** + * The working directory of container + */ + private String workingDir; + + /** + * The image pull policy of container + */ + private String imagePullPolicy; + + /** + * The commands of container + */ + private List commands; + + /** + * The arguments of container + */ + private List args; + + /** + * The volume Mount of container + */ + private List volumeMounts; + + /** + * The Ports of container + */ + private List ports; + + /** + * The environment variables of container + */ + private List environmentVars; + + /** + * The readiness probe of container + */ + private Probe readinessProbe; + + /** + * The liveness probe of container + */ + private Probe livenessProbe; + + /** + * The startup probe of container + */ + private Probe startupProbe; + + /** + * Whether the container should allocate a buffer for stdin in the container runtime. + * If this is not set, reads from stdin in the container will always result in EOF. + * Default is false. + */ + private Boolean stdin = false; + + /** + * Whether the container runtime should close the stdin channel after it has been opened by a single attach. + * When stdin is true the stdin stream will remain open across multiple attach sessions. + * If stdinOnce is set to true, stdin is opened on container start, + * is empty until the first client attaches to stdin, and then remains open and accepts + * data until the client disconnects, at which time stdin is closed and remains closed until the container is + * restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. + * Default is false + */ + private Boolean stdinOnce = false; + + /** + * Whether the container should allocate a TTY for itself, also requires 'stdin' to be true. + * Default is false. + */ + private Boolean tty = false; + + /** + * The security context of container + */ + private ContainerSecurityContext securityContext; + + public String getName() { + return name; + } + + public Container setName(String name) { + this.name = name; + return this; + } + + public String getImage() { + return image; + } + + public Container setImage(String image) { + this.image = image; + return this; + } + + public float getCpu() { + return cpu; + } + + public Container setCpu(float cpu) { + this.cpu = cpu; + return this; + } + + public float getGpu() { + return gpu; + } + + public Container setGpu(float gpu) { + this.gpu = gpu; + return this; + } + + public float getMemory() { + return memory; + } + + public Container setMemory(float memory) { + this.memory = memory; + return this; + } + + public String getWorkingDir() { + return workingDir; + } + + public Container setWorkingDir(String workingDir) { + this.workingDir = workingDir; + return this; + } + + public String getImagePullPolicy() { + return imagePullPolicy; + } + + public Container setImagePullPolicy(String imagePullPolicy) { + this.imagePullPolicy = imagePullPolicy; + return this; + } + + public List getCommands() { + return commands; + } + + public Container setCommands(List commands) { + this.commands = commands; + return this; + } + + public List getArgs() { + return args; + } + + public Container setArgs(List args) { + this.args = args; + return this; + } + + public List getVolumeMounts() { + return volumeMounts; + } + + public Container setVolumeMounts(List volumeMounts) { + this.volumeMounts = volumeMounts; + return this; + } + + public List getPorts() { + return ports; + } + + public Container setPorts(List ports) { + this.ports = ports; + return this; + } + + public List getEnvironmentVars() { + return environmentVars; + } + + public Container setEnvironmentVars(List environmentVars) { + this.environmentVars = environmentVars; + return this; + } + + public Probe getReadinessProbe() { + return readinessProbe; + } + + public Container setReadinessProbe(Probe readinessProbe) { + this.readinessProbe = readinessProbe; + return this; + } + + public Probe getLivenessProbe() { + return livenessProbe; + } + + public Container setLivenessProbe(Probe livenessProbe) { + this.livenessProbe = livenessProbe; + return this; + } + + public Probe getStartupProbe() { + return startupProbe; + } + + public Container setStartupProbe(Probe startupProbe) { + this.startupProbe = startupProbe; + return this; + } + + public Boolean getStdin() { + return stdin; + } + + public Container setStdin(Boolean stdin) { + this.stdin = stdin; + return this; + } + + public Boolean getStdinOnce() { + return stdinOnce; + } + + public Container setStdinOnce(Boolean stdinOnce) { + this.stdinOnce = stdinOnce; + return this; + } + + public Boolean getTty() { + return tty; + } + + public Container setTty(Boolean tty) { + this.tty = tty; + return this; + } + + public ContainerSecurityContext getSecurityContext() { + return securityContext; + } + + public Container setSecurityContext(ContainerSecurityContext securityContext) { + this.securityContext = securityContext; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/container/ContainerDetailModel.java b/src/main/java/com/baidubce/services/bci/model/container/ContainerDetailModel.java new file mode 100644 index 00000000..376b7620 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/container/ContainerDetailModel.java @@ -0,0 +1,405 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.container; + +import com.baidubce.BceConstants; +import com.baidubce.services.bci.model.common.Environment; +import com.baidubce.services.bci.model.common.Port; +import com.baidubce.services.bci.model.volume.VolumeMount; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.sql.Timestamp; +import java.util.Date; +import java.util.List; + +/** + * The container of pod + */ +public class ContainerDetailModel { + + /** + * The name of container + */ + private String name; + + /** + * The image of container + */ + private String image; + + /** + * The cpu count of container + */ + private float cpu; + + /** + * The memory of container + */ + private float memory; + + /** + * The gpu count of container + */ + private float gpu; + + /** + * The working directory of container + */ + private String workingDir; + + /** + * The image pull policy of container + */ + private String imagePullPolicy; + + /** + * The commands of container + */ + private List commands; + + /** + * The arguments of container + */ + private List args; + + /** + * The ports of container + */ + private List ports; + + /** + * The volume mounts of container + */ + private List volumeMounts; + + /** + * The environment of container + */ + private List envs; + + /** + * The createTime of container + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + private Timestamp createTime; + + /** + * The updateTime of container + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + private Timestamp updateTime; + + /** + * The deleteTime of container + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + private Timestamp deleteTime; + + /** + * The currentStatus of container + */ + private ContainerStatus currentState; + + /** + * The previousStatus of container + */ + private ContainerStatus previousState; + + /** + * The ready of container + */ + private Boolean ready; + + /** + * The restartCount of container + */ + private int restartCount; + + /** + * The ContainerStatus of container + */ + public class ContainerStatus { + + /** + * The state of container + */ + private String state; + + /** + * The reason of container + */ + private String reason; + + /** + * The message of container + */ + private String message; + + /** + * The startTime of container + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + private Date startTime; + + /** + * The finishTime of container + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + private Date finishTime; + + /** + * The detailStatus of container + */ + private String detailStatus; + + /** + * The exitCode of container + */ + private int exitCode; + + public String getState() { + return state; + } + + public ContainerStatus setState(String state) { + this.state = state; + return this; + } + + public String getReason() { + return reason; + } + + public ContainerStatus setReason(String reason) { + this.reason = reason; + return this; + } + + public String getMessage() { + return message; + } + + public ContainerStatus setMessage(String message) { + this.message = message; + return this; + } + + public Date getStartTime() { + return startTime; + } + + public ContainerStatus setStartTime(Date startTime) { + this.startTime = startTime; + return this; + } + + public Date getFinishTime() { + return finishTime; + } + + public ContainerStatus setFinishTime(Date finishTime) { + this.finishTime = finishTime; + return this; + } + + public String getDetailStatus() { + return detailStatus; + } + + public ContainerStatus setDetailStatus(String detailStatus) { + this.detailStatus = detailStatus; + return this; + } + + public int getExitCode() { + return exitCode; + } + + public ContainerStatus setExitCode(int exitCode) { + this.exitCode = exitCode; + return this; + } + } + + public String getName() { + return name; + } + + public ContainerDetailModel setName(String name) { + this.name = name; + return this; + } + + public String getImage() { + return image; + } + + public ContainerDetailModel setImage(String image) { + this.image = image; + return this; + } + + public float getCpu() { + return cpu; + } + + public ContainerDetailModel setCpu(float cpu) { + this.cpu = cpu; + return this; + } + + public float getMemory() { + return memory; + } + + public ContainerDetailModel setMemory(float memory) { + this.memory = memory; + return this; + } + + public float getGpu() { + return gpu; + } + + public ContainerDetailModel setGpu(float gpu) { + this.gpu = gpu; + return this; + } + + public String getWorkingDir() { + return workingDir; + } + + public ContainerDetailModel setWorkingDir(String workingDir) { + this.workingDir = workingDir; + return this; + } + + public String getImagePullPolicy() { + return imagePullPolicy; + } + + public ContainerDetailModel setImagePullPolicy(String imagePullPolicy) { + this.imagePullPolicy = imagePullPolicy; + return this; + } + + public List getCommands() { + return commands; + } + + public ContainerDetailModel setCommands(List commands) { + this.commands = commands; + return this; + } + + public List getArgs() { + return args; + } + + public ContainerDetailModel setArgs(List args) { + this.args = args; + return this; + } + + public List getPorts() { + return ports; + } + + public ContainerDetailModel setPorts(List ports) { + this.ports = ports; + return this; + } + + public List getVolumeMounts() { + return volumeMounts; + } + + public ContainerDetailModel setVolumeMounts(List volumeMounts) { + this.volumeMounts = volumeMounts; + return this; + } + + public List getEnvs() { + return envs; + } + + public ContainerDetailModel setEnvs(List envs) { + this.envs = envs; + return this; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public ContainerDetailModel setCreateTime(Timestamp createTime) { + this.createTime = createTime; + return this; + } + + public Timestamp getUpdateTime() { + return updateTime; + } + + public ContainerDetailModel setUpdateTime(Timestamp updateTime) { + this.updateTime = updateTime; + return this; + } + + public Timestamp getDeleteTime() { + return deleteTime; + } + + public ContainerDetailModel setDeleteTime(Timestamp deleteTime) { + this.deleteTime = deleteTime; + return this; + } + + public ContainerStatus getCurrentState() { + return currentState; + } + + public ContainerDetailModel setCurrentState(ContainerStatus currentState) { + this.currentState = currentState; + return this; + } + + public ContainerStatus getPreviousState() { + return previousState; + } + + public ContainerDetailModel setPreviousState(ContainerStatus previousState) { + this.previousState = previousState; + return this; + } + + public Boolean getReady() { + return ready; + } + + public ContainerDetailModel setReady(Boolean ready) { + this.ready = ready; + return this; + } + + public int getRestartCount() { + return restartCount; + } + + public ContainerDetailModel setRestartCount(int restartCount) { + this.restartCount = restartCount; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/instance/CreateInstanceRequest.java b/src/main/java/com/baidubce/services/bci/model/instance/CreateInstanceRequest.java new file mode 100644 index 00000000..2e90efc4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/CreateInstanceRequest.java @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; + +import com.baidubce.services.bci.model.common.Tag; +import com.baidubce.services.bci.model.common.ImageRegistryCredential; +import com.baidubce.services.bci.model.container.Container; +import com.baidubce.services.bci.model.volume.Volume; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * The request for creating instance + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateInstanceRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + *

+ */ + @JsonIgnore + private String clientToken; + + /** + * The name of instance + */ + private String name = ""; + + /** + * The zone id of instance + */ + private String zoneName = ""; + + /** + * The security group id of instance + */ + private List securityGroupIds; + + /** + * The subnet id of instance + */ + private List subnetIds; + + /** + * The restart policy of instance + */ + private String restartPolicy = ""; + + /** + * The elastic ip of instance + */ + private String eipIp = ""; + + /** + * The elastic ip name of instance + */ + private String eipName = "eip"; + + /** + * The elastic ip auto create of instance + */ + private Boolean autoCreateEip = false; + + /** + * The elastic ip route type of instance + * BGP(default) or BGP_S + */ + private String eipRouteType = "BGP"; + + /** + * The elastic ip bandwidth of instance + * BGP: 1~500 + * BGP_S: 100~5000 + */ + private Integer eipBandwidthInMbps = 100; + + /** + * The elastic ip payment timing of instance + * Postpaid(default) or Prepaid + */ + private String eipPaymentTiming = "Postpaid"; + + /** + * The elastic ip billing method of instance + * ByTraffic(default) or ByBandwidth or ByPeak95 + */ + private String eipBillingMethod = "ByTraffic"; + + /** + * The gpu type of instance + * Supported types: + * Nvidia A10 PCIE + */ + private String gpuType; + + /** + * The grace period of instance + */ + private Long terminationGracePeriodSeconds; + + /** + * The host name of instance + */ + private String hostName = ""; + + /** + * The tags of the instance. + */ + private List tags; + + /** + * The image registry credentials of the instance. + */ + private List imageRegistryCredentials; + + /** + * The containers of the instance. + */ + private List containers; + + /** + * The init containers of the instance. + */ + private List initContainers; + + /** + * The volumes of the instance. + */ + private Volume volume; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateInstanceRequest with credentials. + */ + public CreateInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public CreateInstanceRequest setClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public String getName() { + return name; + } + + public CreateInstanceRequest setName(String name) { + this.name = name; + return this; + } + + public String getZoneName() { + return zoneName; + } + + public CreateInstanceRequest setZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + public List getSecurityGroupIds() { + return securityGroupIds; + } + + public CreateInstanceRequest setSecurityGroupIds(List securityGroupIds) { + this.securityGroupIds = securityGroupIds; + return this; + } + + public List getSubnetIds() { + return subnetIds; + } + + public CreateInstanceRequest setSubnetIds(List subnetIds) { + this.subnetIds = subnetIds; + return this; + } + + public String getRestartPolicy() { + return restartPolicy; + } + + public CreateInstanceRequest setRestartPolicy(String restartPolicy) { + this.restartPolicy = restartPolicy; + return this; + } + + public String getEipIp() { + return eipIp; + } + + public CreateInstanceRequest setEipIp(String eipIp) { + this.eipIp = eipIp; + return this; + } + + public String getEipName() { + return eipName; + } + + public CreateInstanceRequest setEipName(String eipName) { + this.eipName = eipName; + return this; + } + + public Boolean getAutoCreateEip() { + return autoCreateEip; + } + + public CreateInstanceRequest setAutoCreateEip(Boolean autoCreateEip) { + this.autoCreateEip = autoCreateEip; + return this; + } + + public String getEipRouteType() { + return eipRouteType; + } + + public CreateInstanceRequest setEipRouteType(String eipRouteType) { + this.eipRouteType = eipRouteType; + return this; + } + + public Integer getEipBandwidthInMbps() { + return eipBandwidthInMbps; + } + + public CreateInstanceRequest setEipBandwidthInMbps(Integer eipBandwidthInMbps) { + this.eipBandwidthInMbps = eipBandwidthInMbps; + return this; + } + + public String getEipPaymentTiming() { + return eipPaymentTiming; + } + + public String getEipBillingMethod() { + return eipBillingMethod; + } + + public CreateInstanceRequest setEipBillingMethod(String eipBillingMethod) { + this.eipBillingMethod = eipBillingMethod; + return this; + } + + public String getGpuType() { + return gpuType; + } + + public CreateInstanceRequest setGpuType(String gpuType) { + this.gpuType = gpuType; + return this; + } + + public Long getTerminationGracePeriodSeconds() { + return terminationGracePeriodSeconds; + } + + public CreateInstanceRequest setTerminationGracePeriodSeconds(Long terminationGracePeriodSeconds) { + this.terminationGracePeriodSeconds = terminationGracePeriodSeconds; + return this; + } + + public String getHostName() { + return hostName; + } + + public CreateInstanceRequest setHostName(String hostName) { + this.hostName = hostName; + return this; + } + + public List getTags() { + return tags; + } + + public CreateInstanceRequest setTags(List tags) { + this.tags = tags; + return this; + } + + public List getImageRegistryCredentials() { + return imageRegistryCredentials; + } + + public CreateInstanceRequest setImageRegistryCredentials(List imageRegistryCredentials) { + this.imageRegistryCredentials = imageRegistryCredentials; + return this; + } + + public List getContainers() { + return containers; + } + + public CreateInstanceRequest setContainers(List containers) { + this.containers = containers; + return this; + } + + public List getInitContainers() { + return initContainers; + } + + public CreateInstanceRequest setInitContainers(List initContainers) { + this.initContainers = initContainers; + return this; + } + + public Volume getVolume() { + return volume; + } + + public CreateInstanceRequest setVolume(Volume volume) { + this.volume = volume; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/instance/CreateInstanceResponse.java b/src/main/java/com/baidubce/services/bci/model/instance/CreateInstanceResponse.java new file mode 100644 index 00000000..6b4c5588 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/CreateInstanceResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for create instance + */ +public class CreateInstanceResponse extends AbstractBceResponse { + + /** + * The id of instance + */ + private String instanceId; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/instance/DeleteInstanceRequest.java b/src/main/java/com/baidubce/services/bci/model/instance/DeleteInstanceRequest.java new file mode 100644 index 00000000..023b12fb --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/DeleteInstanceRequest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * The request for delete instance + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeleteInstanceRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + *

+ */ + @JsonIgnore + private String clientToken; + + /** + * The id of instance + */ + private List instanceIds; + + /** + * The flag of release related resources + */ + private Boolean relatedReleaseFlag = Boolean.FALSE; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateInstanceRequest with credentials. + */ + public DeleteInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public DeleteInstanceRequest setClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public List getInstanceIds() { + return instanceIds; + } + + public DeleteInstanceRequest setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + return this; + } + + public Boolean getRelatedReleaseFlag() { + return relatedReleaseFlag; + } + + public DeleteInstanceRequest setRelatedReleaseFlag(Boolean relatedReleaseFlag) { + this.relatedReleaseFlag = relatedReleaseFlag; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/instance/DeleteInstanceResponse.java b/src/main/java/com/baidubce/services/bci/model/instance/DeleteInstanceResponse.java new file mode 100644 index 00000000..2dbbe90a --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/DeleteInstanceResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for delete instance + */ +public class DeleteInstanceResponse extends AbstractBceResponse { + +} diff --git a/src/main/java/com/baidubce/services/bci/model/instance/GetInstanceRequest.java b/src/main/java/com/baidubce/services/bci/model/instance/GetInstanceRequest.java new file mode 100644 index 00000000..df9f2416 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/GetInstanceRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get instance + */ +public class GetInstanceRequest extends AbstractBceRequest { + + /** + * The id of instance + */ + private String instanceId; + + public String getInstanceId() { + return instanceId; + } + + public GetInstanceRequest setInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return getInstanceRequest with credentials. + */ + public GetInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/instance/GetInstanceResponse.java b/src/main/java/com/baidubce/services/bci/model/instance/GetInstanceResponse.java new file mode 100644 index 00000000..82f64a37 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/GetInstanceResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for get instance + */ +public class GetInstanceResponse extends AbstractBceResponse { + + /** + * The instance of bci + */ + private InstanceDetailModel instance; + + public InstanceDetailModel getInstance() { + return instance; + } + + public void setInstance(InstanceDetailModel instance) { + this.instance = instance; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/instance/InstanceDetailModel.java b/src/main/java/com/baidubce/services/bci/model/instance/InstanceDetailModel.java new file mode 100644 index 00000000..722b6642 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/InstanceDetailModel.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; + +import com.baidubce.services.bci.model.container.ContainerDetailModel; +import com.baidubce.services.bci.model.volume.Volume; +import com.baidubce.services.bci.model.vpc.SecurityGroupModel; +import com.baidubce.services.bci.model.vpc.SubnetModel; +import com.baidubce.services.bci.model.vpc.VpcModel; + +import java.util.List; + +/** + * The instance of bci + */ +public class InstanceDetailModel extends InstanceModel { + + /** + * The volume of instance + */ + private Volume volume; + + /** + * The containers of instance + */ + private List containers; + + /** + * The initContainers of instance + */ + private List initContainers; + + /** + * The securityGroups of instance + */ + private List securityGroups; + + /** + * The vpc of instance + */ + private VpcModel vpc; + + /** + * The subnet of instance + */ + private SubnetModel subnet; + + public Volume getVolume() { + return volume; + } + + public InstanceDetailModel setVolume(Volume volume) { + this.volume = volume; + return this; + } + + public List getContainers() { + return containers; + } + + public InstanceDetailModel setContainers(List containers) { + this.containers = containers; + return this; + } + + public List getInitContainers() { + return initContainers; + } + + public InstanceDetailModel setInitContainers(List initContainers) { + this.initContainers = initContainers; + return this; + } + + public List getSecurityGroups() { + return securityGroups; + } + + public InstanceDetailModel setSecurityGroups(List securityGroups) { + this.securityGroups = securityGroups; + return this; + } + + public VpcModel getVpc() { + return vpc; + } + + public InstanceDetailModel setVpc(VpcModel vpc) { + this.vpc = vpc; + return this; + } + + public SubnetModel getSubnet() { + return subnet; + } + + public InstanceDetailModel setSubnet(SubnetModel subnet) { + this.subnet = subnet; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/instance/InstanceModel.java b/src/main/java/com/baidubce/services/bci/model/instance/InstanceModel.java new file mode 100644 index 00000000..1ba8df0e --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/InstanceModel.java @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; + +import com.baidubce.BceConstants; +import com.baidubce.services.bci.model.common.Tag; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.sql.Timestamp; +import java.util.List; + +/** + * The response for get instance + */ +public class InstanceModel { + + /** + * The id of the instance + */ + private String instanceId; + + /** + * The name of the instance + */ + private String instanceName; + + /** + * The status of the instance + */ + private String status; + + /** + * The zoneName of the instance + */ + private String zoneName; + + /** + * The cpuType of the instance + */ + private String cpuType; + + /** + * The gpuType of the instance + */ + private String gpuType; + + /** + * The cpu count of the instance + */ + private float cpu; + + /** + * The memory count of the instance + */ + private float memory; + + /** + * The bandwidthInMbps of the instance eip + */ + private Integer bandwidthInMbps; + + /** + * The publicIp of the instance + */ + private String publicIp; + + /** + * The internalIp of the instance + */ + private String internalIp; + + /** + * The createTime of the instance + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + private Timestamp createTime; + + /** + * The updateTime of the instance + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + private Timestamp updateTime; + + /** + * The deleteTime of the instance + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + private Timestamp deleteTime; + + /** + * The restartPolicy of the instance + */ + private String restartPolicy; + + /** + * The tags of the instance + */ + private List tags; + + public String getInstanceId() { + return instanceId; + } + + public InstanceModel setInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public String getInstanceName() { + return instanceName; + } + + public InstanceModel setInstanceName(String instanceName) { + this.instanceName = instanceName; + return this; + } + + public String getStatus() { + return status; + } + + public InstanceModel setStatus(String status) { + this.status = status; + return this; + } + + public String getZoneName() { + return zoneName; + } + + public InstanceModel setZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + public String getCpuType() { + return cpuType; + } + + public InstanceModel setCpuType(String cpuType) { + this.cpuType = cpuType; + return this; + } + + public String getGpuType() { + return gpuType; + } + + public InstanceModel setGpuType(String gpuType) { + this.gpuType = gpuType; + return this; + } + + public float getCpu() { + return cpu; + } + + public InstanceModel setCpu(float cpu) { + this.cpu = cpu; + return this; + } + + public float getMemory() { + return memory; + } + + public InstanceModel setMemory(float memory) { + this.memory = memory; + return this; + } + + public Integer getBandwidthInMbps() { + return bandwidthInMbps; + } + + public InstanceModel setBandwidthInMbps(Integer bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + return this; + } + + public String getPublicIp() { + return publicIp; + } + + public InstanceModel setPublicIp(String publicIp) { + this.publicIp = publicIp; + return this; + } + + public String getInternalIp() { + return internalIp; + } + + public InstanceModel setInternalIp(String internalIp) { + this.internalIp = internalIp; + return this; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public InstanceModel setCreateTime(Timestamp createTime) { + this.createTime = createTime; + return this; + } + + public Timestamp getUpdateTime() { + return updateTime; + } + + public InstanceModel setUpdateTime(Timestamp updateTime) { + this.updateTime = updateTime; + return this; + } + + public Timestamp getDeleteTime() { + return deleteTime; + } + + public InstanceModel setDeleteTime(Timestamp deleteTime) { + this.deleteTime = deleteTime; + return this; + } + + public String getRestartPolicy() { + return restartPolicy; + } + + public InstanceModel setRestartPolicy(String restartPolicy) { + this.restartPolicy = restartPolicy; + return this; + } + + public List getTags() { + return tags; + } + + public InstanceModel setTags(List tags) { + this.tags = tags; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/instance/ListInstancesRequest.java b/src/main/java/com/baidubce/services/bci/model/instance/ListInstancesRequest.java new file mode 100644 index 00000000..921e8345 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/ListInstancesRequest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list instances + */ +public class ListInstancesRequest extends ListRequest { + + /** + * The type of keyword, support name, podId + */ + private String keywordType; + + /** + * The keyword to search + */ + private String keyword; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListInstancesRequest with credentials. + */ + @Override + public ListInstancesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getKeywordType() { + return keywordType; + } + + public ListInstancesRequest setKeywordType(String keywordType) { + this.keywordType = keywordType; + return this; + } + + public String getKeyword() { + return keyword; + } + + public ListInstancesRequest setKeyword(String keyword) { + this.keyword = keyword; + return this; + } + + /** + * Configure the request with specified marker. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * @return ListInstancesRequest with specified marker. + */ + @Override + public ListInstancesRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the request with specified maxKeys. + * + * @param maxKeys The optional parameter to specifies the max number of list result to return. + * The default value is 1000. + * @return ListInstancesRequest with specified maxKeys. + */ + @Override + public ListInstancesRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/instance/ListInstancesResponse.java b/src/main/java/com/baidubce/services/bci/model/instance/ListInstancesResponse.java new file mode 100644 index 00000000..4e1dcbef --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/instance/ListInstancesResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.instance; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response for list instance + */ +public class ListInstancesResponse extends ListResponse { + + /** + * The list of instance + */ + private List result; + + public List getResult() { + return result; + } + + public ListInstancesResponse setResult(List result) { + this.result = result; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/securitycontext/Capabilities.java b/src/main/java/com/baidubce/services/bci/model/securitycontext/Capabilities.java new file mode 100644 index 00000000..8ce21c23 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/securitycontext/Capabilities.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.securitycontext; + +import java.util.List; +/** + * The capabilities of container + */ +public class Capabilities { + + /** + * The add of capabilities + */ + private List add; + + /** + * The drop of capabilities + */ + private List drop; + + /** + * The constructor of Capabilities + */ + public Capabilities() { + + } + + /** + * The constructor of Capabilities + * @param add The add of capabilities + * @param drop The drop of capabilities + */ + public Capabilities(List add, List drop) { + this.add = add; + this.drop = drop; + } + + public List getAdd() { + return add; + } + + public Capabilities setAdd(List add) { + this.add = add; + return this; + } + + public List getDrop() { + return drop; + } + + public Capabilities setDrop(List drop) { + this.drop = drop; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/securitycontext/ContainerSecurityContext.java b/src/main/java/com/baidubce/services/bci/model/securitycontext/ContainerSecurityContext.java new file mode 100644 index 00000000..da08e7ea --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/securitycontext/ContainerSecurityContext.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.securitycontext; + +/** + * The security context of container + */ +public class ContainerSecurityContext { + + // The capabilities to add/drop when running containers. + // Defaults to the default set of capabilities granted by the container runtime. + // Note that this field cannot be set when spec.os.name is windows. + // +optional + private Capabilities capabilities; + + // The UID to run the entrypoint of the container process. + // Defaults to user specified in image metadata if unspecified. + // May also be set in PodSecurityContext. If set in both SecurityContext and + // PodSecurityContext, the value specified in SecurityContext takes precedence. + // Note that this field cannot be set when spec.os.name is windows. + // +optional + private Long runAsUser; + + // The GID to run the entrypoint of the container process. + // Uses runtime default if unset. + // May also be set in PodSecurityContext. If set in both SecurityContext and + // PodSecurityContext, the value specified in SecurityContext takes precedence. + // Note that this field cannot be set when spec.os.name is windows. + // +optional + private Long runAsGroup; + + // Indicates that the container must run as a non-root user. + // If true, the Kubelet will validate the image at runtime to ensure that it + // does not run as UID 0 (root) and fail to start the container if it does. + // If unset or false, no such validation will be performed. + // May also be set in PodSecurityContext. If set in both SecurityContext and + // PodSecurityContext, the value specified in SecurityContext takes precedence. + // +optional + private Boolean runAsNonRoot; + + // Whether this container has a read-only root filesystem. + // Default is false. + // Note that this field cannot be set when spec.os.name is windows. + // +optional + private Boolean readOnlyRootFilesystem; + + /** + * The constructor of ContainerSecurityContext + */ + public ContainerSecurityContext() { + + } + + /** + * The constructor of ContainerSecurityContext + * @param capabilities The capabilities to add/drop when running containers. + * @param runAsUser The UID to run the entrypoint of the container process. + * @param runAsGroup The GID to run the entrypoint of the container process. + * @param runAsNonRoot Indicates that the container must run as a non-root user. + * @param readOnlyRootFilesystem Whether this container has a read-only root filesystem. + */ + public ContainerSecurityContext(Capabilities capabilities, Long runAsUser, Long runAsGroup, + Boolean runAsNonRoot, Boolean readOnlyRootFilesystem) { + this.capabilities = capabilities; + this.runAsUser = runAsUser; + this.runAsGroup = runAsGroup; + this.runAsNonRoot = runAsNonRoot; + this.readOnlyRootFilesystem = readOnlyRootFilesystem; + } + + public Capabilities getCapabilities() { + return capabilities; + } + + public ContainerSecurityContext setCapabilities(Capabilities capabilities) { + this.capabilities = capabilities; + return this; + } + + public Long getRunAsUser() { + return runAsUser; + } + + public ContainerSecurityContext setRunAsUser(Long runAsUser) { + this.runAsUser = runAsUser; + return this; + } + + public Long getRunAsGroup() { + return runAsGroup; + } + + public ContainerSecurityContext setRunAsGroup(Long runAsGroup) { + this.runAsGroup = runAsGroup; + return this; + } + + public Boolean getRunAsNonRoot() { + return runAsNonRoot; + } + + public ContainerSecurityContext setRunAsNonRoot(Boolean runAsNonRoot) { + this.runAsNonRoot = runAsNonRoot; + return this; + } + + public Boolean getReadOnlyRootFilesystem() { + return readOnlyRootFilesystem; + } + + public ContainerSecurityContext setReadOnlyRootFilesystem(Boolean readOnlyRootFilesystem) { + this.readOnlyRootFilesystem = readOnlyRootFilesystem; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/volume/BaseVolume.java b/src/main/java/com/baidubce/services/bci/model/volume/BaseVolume.java new file mode 100644 index 00000000..81fd251d --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/volume/BaseVolume.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.volume; + +/** + * The base volume of container + */ +public class BaseVolume { + + /** + * The name of volume + */ + protected String name; + + /** + * The constructor of BaseVolume + */ + public BaseVolume() { + + } + + /** + * The constructor of BaseVolume + * @param name The name of volume + */ + public BaseVolume(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public BaseVolume setName(String name) { + this.name = name; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/volume/ConfigFileDetail.java b/src/main/java/com/baidubce/services/bci/model/volume/ConfigFileDetail.java new file mode 100644 index 00000000..9c97d809 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/volume/ConfigFileDetail.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.volume; + +/** + * The config file detail of container + */ +public class ConfigFileDetail { + + /** + * The path of config file + */ + private String path; + + /** + * The file of config file + */ + private String file; + + /** + * The constructor of ConfigFileDetail + */ + public ConfigFileDetail() { + super(); + } + + /** + * The constructor of ConfigFileDetail + * @param path The path of config file + * @param file The file of config file + */ + public ConfigFileDetail(String path, String file) { + this.path = path; + this.file = file; + } + + public String getPath() { + return path; + } + + public ConfigFileDetail setPath(String path) { + this.path = path; + return this; + } + + public String getFile() { + return file; + } + + public ConfigFileDetail setFile(String file) { + this.file = file; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/volume/ConfigFileVolume.java b/src/main/java/com/baidubce/services/bci/model/volume/ConfigFileVolume.java new file mode 100644 index 00000000..d33e912b --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/volume/ConfigFileVolume.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.volume; + +import java.util.List; + +/** + * The config file volume of container + */ +public class ConfigFileVolume extends BaseVolume { + + /** + * The config files of volume + */ + private List configFiles; + + /** + * The default mode of volume + */ + private Integer defaultMode; + + /** + * The constructor of ConfigFileVolume + */ + public ConfigFileVolume() { + super(); + } + + /** + * The constructor of ConfigFileVolume + * @param name The name of volume + * @param configFiles The config files of volume + * @param defaultMode The default mode of volume + */ + public ConfigFileVolume(String name, List configFiles, Integer defaultMode) { + super(name); + this.configFiles = configFiles; + this.defaultMode = defaultMode; + } + + public List getConfigFiles() { + return configFiles; + } + + public ConfigFileVolume setConfigFiles(List configFiles) { + this.configFiles = configFiles; + return this; + } + + public Integer getDefaultMode() { + return defaultMode; + } + + public ConfigFileVolume setDefaultMode(Integer defaultMode) { + this.defaultMode = defaultMode; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bci/model/volume/EmptyDirVolume.java b/src/main/java/com/baidubce/services/bci/model/volume/EmptyDirVolume.java new file mode 100644 index 00000000..ceef6dbf --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/volume/EmptyDirVolume.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.volume; + +/** + * The empty dir volume of container + */ +public class EmptyDirVolume extends BaseVolume { + + /** + * The medium of volume + */ + private String medium; + + /** + * The size limit of volume + */ + private Float sizeLimit; + + /** + * The constructor of EmptyDirVolume + */ + public EmptyDirVolume() { + super(); + } + + /** + * The constructor of EmptyDirVolume + * @param name The name of volume + * @param medium The medium of volume + * @param sizeLimit The size limit of volume + */ + public EmptyDirVolume(String name, String medium, Float sizeLimit) { + super(name); + this.medium = medium; + this.sizeLimit = sizeLimit; + } + + public String getMedium() { + return medium; + } + + public EmptyDirVolume setMedium(String medium) { + this.medium = medium; + return this; + } + + public Float getSizeLimit() { + return sizeLimit; + } + + public EmptyDirVolume setSizeLimit(Float sizeLimit) { + this.sizeLimit = sizeLimit; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/volume/NfsVolume.java b/src/main/java/com/baidubce/services/bci/model/volume/NfsVolume.java new file mode 100644 index 00000000..f702030b --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/volume/NfsVolume.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.volume; + +/** + * The nfs volume of container + */ +public class NfsVolume extends BaseVolume { + + /** + * The server of nfs volume + */ + private String server; + + /** + * The path of nfs volume + */ + private String path; + + /** + * The read only of nfs volume + */ + private Boolean readOnly = false; + + /** + * The constructor of NfsVolume + */ + public NfsVolume() { + super(); + } + + /** + * The constructor of NfsVolume + * @param name The name of volume + * @param server The server of nfs volume + * @param path The path of nfs volume + */ + public NfsVolume(String name, String server, String path) { + super(name); + this.server = server; + this.path = path; + } + + public String getServer() { + return server; + } + + public NfsVolume setServer(String server) { + this.server = server; + return this; + } + + public String getPath() { + return path; + } + + public NfsVolume setPath(String path) { + this.path = path; + return this; + } + + public Boolean getReadOnly() { + return readOnly; + } + + public NfsVolume setReadOnly(Boolean readOnly) { + this.readOnly = readOnly; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/volume/Volume.java b/src/main/java/com/baidubce/services/bci/model/volume/Volume.java new file mode 100644 index 00000000..8ecde19e --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/volume/Volume.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.volume; + +import java.util.List; +/** + * The volume of container + */ +public class Volume { + + /** + * The nfs of volume + */ + private List nfs; + + /** + * The empty dir of volume + */ + private List emptyDir; + + /** + * The config file of volume + */ + private List configFile; + + /** + * The constructor of Volume + */ + public Volume() { + + } + + /** + * The constructor of Volume + * @param nfs The nfs of volume + * @param emptyDir The empty dir of volume + * @param configFile The config file of volume + */ + public Volume(List nfs, List emptyDir, List configFile) { + this.nfs = nfs; + this.emptyDir = emptyDir; + this.configFile = configFile; + } + + public List getNfs() { + return nfs; + } + + public Volume setNfs(List nfs) { + this.nfs = nfs; + return this; + } + + public List getEmptyDir() { + return emptyDir; + } + + public Volume setEmptyDir(List emptyDir) { + this.emptyDir = emptyDir; + return this; + } + + public List getConfigFile() { + return configFile; + } + + public Volume setConfigFile(List configFile) { + this.configFile = configFile; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/volume/VolumeMount.java b/src/main/java/com/baidubce/services/bci/model/volume/VolumeMount.java new file mode 100644 index 00000000..a5f0b971 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/volume/VolumeMount.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.volume; + +/** + * The volume mount of container + */ +public class VolumeMount { + + /** + * The name of volume + */ + private String name; + + /** + * The type of volume + */ + private String type; + + /** + * The mount path of volume + */ + private String mountPath; + + /** + * The read only of volume + */ + private Boolean readOnly = false; + + /** + * The constructor of VolumeMount + */ + public VolumeMount() { + + } + + /** + * The constructor of VolumeMount + * @param name The name of volume + * @param type The type of volume + * @param mountPath The mount path of volume + * @param readOnly The read only of volume + */ + public VolumeMount(String name, String type, String mountPath, Boolean readOnly) { + this.name = name; + this.type = type; + this.mountPath = mountPath; + this.readOnly = readOnly; + } + + public String getName() { + return name; + } + + public VolumeMount setName(String name) { + this.name = name; + return this; + } + + public String getType() { + return type; + } + + public VolumeMount setType(String type) { + this.type = type; + return this; + } + + public String getMountPath() { + return mountPath; + } + + public VolumeMount setMountPath(String mountPath) { + this.mountPath = mountPath; + return this; + } + + public Boolean getReadOnly() { + return readOnly; + } + + public VolumeMount setReadOnly(Boolean readOnly) { + this.readOnly = readOnly; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/vpc/SecurityGroupModel.java b/src/main/java/com/baidubce/services/bci/model/vpc/SecurityGroupModel.java new file mode 100644 index 00000000..1dc2360c --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/vpc/SecurityGroupModel.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.vpc; + +/** + * The model for security group + */ +public class SecurityGroupModel { + + /** + * The id of security group + */ + private String securityGroupId; + + /** + * The name of security group + */ + private String name; + + /** + * The description of security group + */ + private String description; + + /** + * The vpcId of security group + */ + private String vpcId; + + /** + * The constructor of SecurityGroupModel + */ + public SecurityGroupModel() { + + } + + /** + * The constructor of SecurityGroupModel + * @param securityGroupId The id of security group + * @param name The name of security group + * @param description The description of security group + * @param vpcId The vpcId of security group + */ + public SecurityGroupModel(String securityGroupId, String name, String description, String vpcId) { + this.securityGroupId = securityGroupId; + this.name = name; + this.description = description; + this.vpcId = vpcId; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public SecurityGroupModel setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + public String getName() { + return name; + } + + public SecurityGroupModel setName(String name) { + this.name = name; + return this; + } + + public String getDescription() { + return description; + } + + public SecurityGroupModel setDescription(String description) { + this.description = description; + return this; + } + + public String getVpcId() { + return vpcId; + } + + public SecurityGroupModel setVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/vpc/SubnetModel.java b/src/main/java/com/baidubce/services/bci/model/vpc/SubnetModel.java new file mode 100644 index 00000000..7c285ce7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/vpc/SubnetModel.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.vpc; + +/** + * The model for subnet + */ +public class SubnetModel { + + /** + * The id of subnet + */ + private String subnetId; + + /** + * The name of subnet + */ + private String name; + + /** + * The cidr of subnet + */ + private String cidr; + + /** + * The vpcId of subnet + */ + private String vpcId; + + /** + * The subnetType of subnet + */ + private String subnetType; + + /** + * The createTime of subnet + */ + private String description; + + /** + * The createTime of subnet + */ + private String createTime; + + /** + * The constructor of SubnetModel + */ + public SubnetModel() { + + } + + /** + * The constructor of SubnetModel + * @param subnetId The id of subnet + * @param name The name of subnet + * @param cidr The cidr of subnet + * @param vpcId The vpcId of subnet + * @param subnetType The subnetType of subnet + * @param description The description of subnet + * @param createTime The createTime of subnet + */ + public SubnetModel(String subnetId, String name, String cidr, String vpcId, String subnetType, String description, + String createTime) { + this.subnetId = subnetId; + this.name = name; + this.cidr = cidr; + this.vpcId = vpcId; + this.subnetType = subnetType; + this.description = description; + this.createTime = createTime; + } + + public String getSubnetId() { + return subnetId; + } + + public SubnetModel setSubnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + public String getName() { + return name; + } + + public SubnetModel setName(String name) { + this.name = name; + return this; + } + + public String getCidr() { + return cidr; + } + + public SubnetModel setCidr(String cidr) { + this.cidr = cidr; + return this; + } + + public String getVpcId() { + return vpcId; + } + + public SubnetModel setVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + public String getSubnetType() { + return subnetType; + } + + public SubnetModel setSubnetType(String subnetType) { + this.subnetType = subnetType; + return this; + } + + public String getDescription() { + return description; + } + + public SubnetModel setDescription(String description) { + this.description = description; + return this; + } + + public String getCreateTime() { + return createTime; + } + + public SubnetModel setCreateTime(String createTime) { + this.createTime = createTime; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bci/model/vpc/VpcModel.java b/src/main/java/com/baidubce/services/bci/model/vpc/VpcModel.java new file mode 100644 index 00000000..06ef3e66 --- /dev/null +++ b/src/main/java/com/baidubce/services/bci/model/vpc/VpcModel.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bci.model.vpc; + +/** + * The model for vpc + */ +public class VpcModel { + + /** + * The id of vpc + */ + private String vpcId; + + /** + * The name of vpc + */ + private String name; + + /** + * The cidr of vpc + */ + private String cidr; + + /** + * The createTime of vpc + */ + private String createTime; + + /** + * The description of vpc + */ + private String description; + + /** + * The isDefault of vpc + */ + private Boolean isDefault; + + /** + * The constructor of VpcModel + */ + public VpcModel() { + + } + + /** + * The constructor of VpcModel + * @param vpcId The id of vpc + * @param name The name of vpc + * @param cidr The cidr of vpc + * @param createTime The createTime of vpc + * @param description The description of vpc + * @param isDefault The isDefault of vpc + */ + public VpcModel(String vpcId, String name, String cidr, String createTime, String description, Boolean isDefault) { + this.vpcId = vpcId; + this.name = name; + this.cidr = cidr; + this.createTime = createTime; + this.description = description; + this.isDefault = isDefault; + } + + public String getVpcId() { + return vpcId; + } + + public VpcModel setVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + public String getName() { + return name; + } + + public VpcModel setName(String name) { + this.name = name; + return this; + } + + public String getCidr() { + return cidr; + } + + public VpcModel setCidr(String cidr) { + this.cidr = cidr; + return this; + } + + public String getCreateTime() { + return createTime; + } + + public VpcModel setCreateTime(String createTime) { + this.createTime = createTime; + return this; + } + + public String getDescription() { + return description; + } + + public VpcModel setDescription(String description) { + this.description = description; + return this; + } + + public Boolean getDefault() { + return isDefault; + } + + public VpcModel setDefault(Boolean aDefault) { + isDefault = aDefault; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/BcmClient.java b/src/main/java/com/baidubce/services/bcm/BcmClient.java new file mode 100644 index 00000000..10910916 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/BcmClient.java @@ -0,0 +1,3723 @@ +package com.baidubce.services.bcm; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcm.handler.BcmJsonResponseHandler; +import com.baidubce.services.bcm.model.Dimension; +import com.baidubce.services.bcm.model.EmptyResponse; +import com.baidubce.services.bcm.model.ListMetricDataRequest; +import com.baidubce.services.bcm.model.ListMetricDataResponse; +import com.baidubce.services.bcm.model.ListResponse; +import com.baidubce.services.bcm.model.MapListResponse; +import com.baidubce.services.bcm.model.MetricDataRequest; +import com.baidubce.services.bcm.model.MetricDataResponse; +import com.baidubce.services.bcm.model.Page; +import com.baidubce.services.bcm.model.PushCustomMetricDataRequest; +import com.baidubce.services.bcm.model.PushMetricDataResponse; +import com.baidubce.services.bcm.model.Statistics; +import com.baidubce.services.bcm.model.action.CreateAndUpdateActionRequest; +import com.baidubce.services.bcm.model.action.DeleteActionRequest; +import com.baidubce.services.bcm.model.action.ListActionsRequest; +import com.baidubce.services.bcm.model.action.ListActionsResponse; +import com.baidubce.services.bcm.model.action.ListNotifyGroupsResponse; +import com.baidubce.services.bcm.model.action.ListNotifyPartiesResponse; +import com.baidubce.services.bcm.model.action.NotifyRequest; +import com.baidubce.services.bcm.model.alarm.AlarmConfig; +import com.baidubce.services.bcm.model.alarm.AlarmConfigV2; +import com.baidubce.services.bcm.model.alarm.AlarmMetric; +import com.baidubce.services.bcm.model.alarm.TargetType; +import com.baidubce.services.bcm.model.alarm.request.CommonAlarmConfigRequest; +import com.baidubce.services.bcm.model.alarm.request.CreateOrUpdateAlarmConfigRequest; +import com.baidubce.services.bcm.model.alarm.request.CreateOrUpdateAlarmConfigV2Request; +import com.baidubce.services.bcm.model.alarm.request.ListAlarmMetricsRequest; +import com.baidubce.services.bcm.model.alarm.request.ListSingleInstanceAlarmConfigsRequest; +import com.baidubce.services.bcm.model.alarm.response.CreateAlarmConfigV2Response; +import com.baidubce.services.bcm.model.alarmhouse.AlarmDetailRequest; +import com.baidubce.services.bcm.model.alarmhouse.AlarmDetailResponse; +import com.baidubce.services.bcm.model.alarmhouse.AlarmListRequest; +import com.baidubce.services.bcm.model.alarmhouse.AlarmListResponse; +import com.baidubce.services.bcm.model.application.ApplicationAlarmConfig; +import com.baidubce.services.bcm.model.application.ApplicationDataListRequest; +import com.baidubce.services.bcm.model.application.ApplicationDataListResponse; +import com.baidubce.services.bcm.model.application.ApplicationDimensionTableDeleteRequest; +import com.baidubce.services.bcm.model.application.ApplicationDimensionTableInfoRequest; +import com.baidubce.services.bcm.model.application.ApplicationDimensionTableInfoResponse; +import com.baidubce.services.bcm.model.application.ApplicationDimensionTableListRequest; +import com.baidubce.services.bcm.model.application.ApplicationInfoDetaleRequest; +import com.baidubce.services.bcm.model.application.ApplicationInfoRequest; +import com.baidubce.services.bcm.model.application.ApplicationInfoResponse; +import com.baidubce.services.bcm.model.application.ApplicationInfoUpdateRequest; +import com.baidubce.services.bcm.model.application.ApplicationInfoUpdateResponse; +import com.baidubce.services.bcm.model.application.ApplicationInstanceCreateRequest; +import com.baidubce.services.bcm.model.application.ApplicationInstanceCreatedListRequest; +import com.baidubce.services.bcm.model.application.ApplicationInstanceDeleteRequest; +import com.baidubce.services.bcm.model.application.ApplicationInstanceListRequest; +import com.baidubce.services.bcm.model.application.ApplicationInstanceListResponse; +import com.baidubce.services.bcm.model.application.ApplicationMetric; +import com.baidubce.services.bcm.model.application.ApplicationMonitorResponse; +import com.baidubce.services.bcm.model.application.ApplicationMonitorTaskDeleteRequest; +import com.baidubce.services.bcm.model.application.ApplicationMonitorTaskDetailRequest; +import com.baidubce.services.bcm.model.application.ApplicationMonitorTaskInfoRequest; +import com.baidubce.services.bcm.model.application.ApplicationMonitorTaskListRequest; +import com.baidubce.services.bcm.model.application.ApplicationMonitorTaskResponse; +import com.baidubce.services.bcm.model.application.CreateOrUpdateAlarmConfigForApplicationRequest; +import com.baidubce.services.bcm.model.application.DeleteAlarmConfigForApplicationRequest; +import com.baidubce.services.bcm.model.application.GetAlarmConfigForApplicationRequest; +import com.baidubce.services.bcm.model.application.GetMetricDataForApplicationRequest; +import com.baidubce.services.bcm.model.application.GetMetricMetaForApplicationRequest; +import com.baidubce.services.bcm.model.application.ListAlarmConfigForApplicationRequest; +import com.baidubce.services.bcm.model.application.ListAlarmMetricsForApplicationRequest; +import com.baidubce.services.bcm.model.application.LogExtractRequest; +import com.baidubce.services.bcm.model.application.LogExtractResult; +import com.baidubce.services.bcm.model.application.MetricDataForApplication; +import com.baidubce.services.bcm.model.application.MonitorObjectType; +import com.baidubce.services.bcm.model.custom.AlarmPolicyBatch; +import com.baidubce.services.bcm.model.custom.AlarmPolicyBatchListRequest; +import com.baidubce.services.bcm.model.custom.BatchDeleteNamespaceEventsRequest; +import com.baidubce.services.bcm.model.custom.BatchDeleteNamespaceMetricsRequest; +import com.baidubce.services.bcm.model.custom.BatchDeleteNamespacesRequest; +import com.baidubce.services.bcm.model.custom.CustomAlarmConfigRequest; +import com.baidubce.services.bcm.model.custom.CustomAlarmConfigResponse; +import com.baidubce.services.bcm.model.custom.CustomAlarmRule; +import com.baidubce.services.bcm.model.custom.CustomMonitorResponse; +import com.baidubce.services.bcm.model.custom.DetailCustomAlarmConfigRequest; +import com.baidubce.services.bcm.model.custom.GetCustomEventRequest; +import com.baidubce.services.bcm.model.custom.GetCustomEventResponse; +import com.baidubce.services.bcm.model.custom.GetCustomMetricRequest; +import com.baidubce.services.bcm.model.custom.GetCustomMetricResponse; +import com.baidubce.services.bcm.model.custom.ListCustomAlarmConfigRequest; +import com.baidubce.services.bcm.model.custom.ListCustomConfigResponse; +import com.baidubce.services.bcm.model.custom.ListNamespaceEventsRequest; +import com.baidubce.services.bcm.model.custom.ListNamespaceEventsResponse; +import com.baidubce.services.bcm.model.custom.ListNamespaceMetricsRequest; +import com.baidubce.services.bcm.model.custom.ListNamespaceMetricsResponse; +import com.baidubce.services.bcm.model.custom.ListNamespacesRequest; +import com.baidubce.services.bcm.model.custom.ListNamespacesResponse; +import com.baidubce.services.bcm.model.custom.NamespaceEventRequest; +import com.baidubce.services.bcm.model.custom.NamespaceMetricDimension; +import com.baidubce.services.bcm.model.custom.NamespaceMetricRequest; +import com.baidubce.services.bcm.model.custom.NamespaceRequest; +import com.baidubce.services.bcm.model.dashboard.DashboardBaseRequest; +import com.baidubce.services.bcm.model.dashboard.DashboardBillboardDataResponse; +import com.baidubce.services.bcm.model.dashboard.DashboardCreateResponse; +import com.baidubce.services.bcm.model.dashboard.DashboardDataRequest; +import com.baidubce.services.bcm.model.dashboard.DashboardDimensionsRequest; +import com.baidubce.services.bcm.model.dashboard.DashboardReportDataResponse; +import com.baidubce.services.bcm.model.dashboard.DashboardResponse; +import com.baidubce.services.bcm.model.dashboard.DashboardTrendDataResponse; +import com.baidubce.services.bcm.model.dashboard.DashboardTrendSeniorDataResponse; +import com.baidubce.services.bcm.model.dashboard.DashboardWidgetRequest; +import com.baidubce.services.bcm.model.event.CloudEventResponse; +import com.baidubce.services.bcm.model.event.EventDataRequest; +import com.baidubce.services.bcm.model.event.EventFilter; +import com.baidubce.services.bcm.model.event.EventLevel; +import com.baidubce.services.bcm.model.event.EventPolicy; +import com.baidubce.services.bcm.model.event.EventPolicyResponse; +import com.baidubce.services.bcm.model.event.EventResourceFilter; +import com.baidubce.services.bcm.model.event.EventType; +import com.baidubce.services.bcm.model.event.PlatformEventResponse; +import com.baidubce.services.bcm.model.group.IGInstanceListResponse; +import com.baidubce.services.bcm.model.group.IGInstanceQuery; +import com.baidubce.services.bcm.model.group.IGInstanceQueryType; +import com.baidubce.services.bcm.model.group.InstanceGroup; +import com.baidubce.services.bcm.model.group.InstanceGroupBase; +import com.baidubce.services.bcm.model.group.InstanceGroupListResponse; +import com.baidubce.services.bcm.model.group.InstanceGroupQuery; +import com.baidubce.services.bcm.model.group.InstanceGroupResponse; +import com.baidubce.services.bcm.model.group.MergedGroup; +import com.baidubce.services.bcm.model.metrics.MultiDimensionalMetricsRequest; +import com.baidubce.services.bcm.model.metrics.PartialDimensionsMetricsRequest; +import com.baidubce.services.bcm.model.metrics.TsdbDimensionTopQuery; +import com.baidubce.services.bcm.model.metrics.TsdbDimensionTopResult; +import com.baidubce.services.bcm.model.metrics.TsdbMetricAllDataResult; +import com.baidubce.services.bcm.model.metrics.TsdbMetricResult; +import com.baidubce.services.bcm.model.metrics.TsdbQueryMetaData; +import com.baidubce.services.bcm.model.site.DnsTaskRequest; +import com.baidubce.services.bcm.model.site.DnsTaskResponse; +import com.baidubce.services.bcm.model.site.FtpTaskRequest; +import com.baidubce.services.bcm.model.site.FtpTaskResponse; +import com.baidubce.services.bcm.model.site.HttpTaskRequest; +import com.baidubce.services.bcm.model.site.HttpTaskResponse; +import com.baidubce.services.bcm.model.site.HttpsTaskRequest; +import com.baidubce.services.bcm.model.site.HttpsTaskResponse; +import com.baidubce.services.bcm.model.site.IdcIspResponse; +import com.baidubce.services.bcm.model.site.PageData; +import com.baidubce.services.bcm.model.site.PageResultResponse; +import com.baidubce.services.bcm.model.site.PingTaskRequest; +import com.baidubce.services.bcm.model.site.PingTaskResponse; +import com.baidubce.services.bcm.model.site.SiteAgentRequest; +import com.baidubce.services.bcm.model.site.SiteAgentResponse; +import com.baidubce.services.bcm.model.site.SiteAlarmConfigDetailResponse; +import com.baidubce.services.bcm.model.site.SiteAlarmConfigListRequest; +import com.baidubce.services.bcm.model.site.SiteAlarmConfigRequest; +import com.baidubce.services.bcm.model.site.SiteAlarmRule; +import com.baidubce.services.bcm.model.site.SiteAlarmUserIdRequest; +import com.baidubce.services.bcm.model.site.SiteBasicResponse; +import com.baidubce.services.bcm.model.site.SiteInfoResponse; +import com.baidubce.services.bcm.model.site.SiteMetricDataQueryRequest; +import com.baidubce.services.bcm.model.site.SiteMetricDataQueryResponse; +import com.baidubce.services.bcm.model.site.SiteTaskIspRequest; +import com.baidubce.services.bcm.model.site.SiteTaskRequest; +import com.baidubce.services.bcm.model.site.SiteViewResponse; +import com.baidubce.services.bcm.model.site.TaskDetailRequest; +import com.baidubce.services.bcm.model.site.TaskResponse; +import com.baidubce.services.bcm.model.site.TaskSummaryRequest; +import com.baidubce.services.bcm.model.site.TaskSummaryResponse; +import com.baidubce.services.bcm.model.site.TcpTaskRequest; +import com.baidubce.services.bcm.model.site.TcpTaskResponse; +import com.baidubce.services.bcm.model.site.UdpTaskRequest; +import com.baidubce.services.bcm.model.site.UdpTaskResponse; +import com.baidubce.services.bcm.model.siteonce.EmptyRequest; +import com.baidubce.services.bcm.model.siteonce.HttpResponseWrapper; +import com.baidubce.services.bcm.model.siteonce.SiteOnceAgent; +import com.baidubce.services.bcm.model.siteonce.SiteOnceGroupTask; +import com.baidubce.services.bcm.model.siteonce.SiteOnceRequest; +import com.baidubce.services.bcm.model.siteonce.SiteOnceTaskList; +import com.baidubce.services.bcm.model.siteonce.SiteOnceTaskRequest; +import com.baidubce.services.bcm.model.siteonce.SiteOnceTaskResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.directory.api.util.Strings; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.StringFormatUtils.stringFormat; +import static com.baidubce.util.Validate.checkIsTrue; +import static com.baidubce.util.Validate.checkListSizeInRange; +import static com.baidubce.util.Validate.checkPattern; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Baidu Cloud Compute Service(bcm). + */ +public class BcmClient extends AbstractBceClient { + + /** + * Parameters + */ + private static final String PREFIX = "json-api"; + private static final String V1 = "v1"; + private static final String V3 = "v3"; + private static final String METRIC_DATA = "metricdata"; + private static final String METRIC_NAME = "metricName"; + private static final String USER_ID = "userId"; + private static final String NAME = "name"; + private static final String NAMESPACE = "namespace"; + private static final String PAGE_NO = "pageNo"; + private static final String PAGE_SIZE = "pageSize"; + private static final String EVENT_NAME = "eventName"; + private static final String EVENT_LEVEL = "eventLevel"; + private static final Integer MAX_DIMENSIONS_SIZE = 100; + + private static final String PUSH_CUSTOM_METRIC_DATA_FORMAT = "/csm/api/v1/userId/%s/custom/data"; + private static final String CREATE_NAMESPACE = "/csm/api/v1/userId/%s/custom/namespaces/create"; + private static final String BATCH_DELETE_NAMESPACES = "/csm/api/v1/userId/%s/custom/namespaces/delete"; + private static final String UPDATE_NAMESPACE = "/csm/api/v1/userId/%s/custom/namespaces/update"; + private static final String LIST_NAMESPACES = "/csm/api/v1/userId/%s/custom/namespaces/list"; + private static final String CREATE_NAMESPACE_METRIC = "/csm/api/v1/userId/%s/custom/namespaces/%s/metrics/create"; + private static final String BATCH_DELETE_NAMESPACE_METRICS = "/csm/api/v1/userId/%s/custom/namespaces/%s/metrics/delete"; + private static final String UPDATE_NAMESPACE_METRIC = "/csm/api/v1/userId/%s/custom/namespaces/%s/metrics/%s"; + private static final String LIST_NAMESPACE_METRICS = "/csm/api/v1/userId/%s/custom/namespaces/metrics"; + private static final String GET_CUSTOM_METRIC = "/csm/api/v1/userId/%s/custom/namespaces/%s/metrics/%s"; + private static final String CREATE_NAMESPACE_EVENT = "/csm/api/v1/custom/event/configs/create"; + private static final String BATCH_DELETE_NAMESPACE_EVENTS = "/csm/api/v1/custom/event/configs/delete"; + private static final String UPDATE_NAMESPACE_EVENT = "/csm/api/v1/custom/event/configs/update"; + private static final String LIST_NAMESPACE_EVENTS = "/csm/api/v1/custom/event/configs/list"; + private static final String GET_CUSTOM_EVENT = "/csm/api/v1/custom/event/configs/detail"; + + private static final String CREATE_DASHBOARD_PATH = "/csm/api/v1/dashboard/products/%s/dashboards"; + private static final String DASHBOARD_PATH = "/csm/api/v1/dashboard/products/%s/dashboards/%s"; + private static final String DUPLICATE_DASHBOARD_PATH = "/csm/api/v1/dashboard/products/%s/dashboards/%s/duplicate"; + private static final String DASHBOARD_WIDGET_PATH = "/csm/api/v1/dashboard/products/%s/dashboards/%s/widgets/%s"; + private static final String CREATE_DASHBOARD_WIDGET_PATH = "/csm/api/v1/dashboard/products/%s/dashboards/%s/widgets"; + private static final String DUPLICATE_DASHBOARD_WIDGET_PATH = + "/csm/api/v1/dashboard/products/%s/dashboards/%s/widgets/%s/duplicate"; + private static final String DASHBOARD_REPORT_DATA_PATH = "/csm/api/v1/dashboard/metric/report"; + private static final String DASHBOARD_TREND_DATA_PATH = "/csm/api/v1/dashboard/metric/trend"; + private static final String DASHBOARD_GAUGE_CHART_DATA_PATH = "/csm/api/v1/dashboard/metric/gaugechart"; + private static final String DASHBOARD_BILLBOARD_DATA_PATH = "/csm/api/v1/dashboard/metric/billboard"; + private static final String DASHBOARD_TREND_SENIOR_DATA_PATH = "/csm/api/v1/dashboard/metric/trend/senior"; + private static final String DASHBOARD_DIMENSIONS_PATH = "/csm/api/v1/userId/%s/services/%s/region/%s/metric/dimensions"; + + private static final String CLOUD_EVENT_LIST_PATH = "/event-api/v1/bce-event/list"; + + private static final String PLATFORM_EVENT_LIST_PATH = "/event-api/v1/platform-event/list"; + + private static final String EVENT_POLICY_PATH = "/event-api/v1/accounts/%s/services/%s/alarm-policies"; + + private static final String INSTANCE_GROUP_PATH = "/csm/api/v1/userId/%s/instance-group"; + + private static final String INSTANCE_GROUP_ID_PATH = "/csm/api/v1/userId/%s/instance-group/%s"; + + private static final String INSTANCE_GROUP_LIST_PATH = "/csm/api/v1/userId/%s/instance-group/list"; + + private static final String IG_INSTANCE_ADD = "/csm/api/v1/userId/%s/instance-group/%s/instance/add"; + + private static final String IG_INSTANCE_REMOVE = "/csm/api/v1/userId/%s/instance-group/%s/instance/remove"; + + private static final String IG_INSTANCE_LIST = "/csm/api/v1/userId/%s/instance-group/instance/list"; + + private static final String IG_QUERY_INSTANCE_LIST = "/csm/api/v1/userId/%s/instance/list"; + + private static final String IG_QUERY_INSTANCE_LIST_FILTER = "/csm/api/v1/userId/%s/instance/filteredList"; + + private static final String SITE_CREATE_HTTP_TASK_PATH = "/csm/api/v1/userId/%s/site/http/create"; + private static final String SITE_UPDATE_HTTP_TASK_PATH = "/csm/api/v1/userId/%s/site/http/update"; + private static final String SITE_GET_HTTP_TASK_PATH = "/csm/api/v1/userId/%s/site/http/detail"; + private static final String SITE_CREATE_HTTPS_TASK_PATH = "/csm/api/v1/userId/%s/site/https/create"; + private static final String SITE_UPDATE_HTTPS_TASK_PATH = "/csm/api/v1/userId/%s/site/https/update"; + private static final String SITE_GET_HTTPS_TASK_PATH = "/csm/api/v1/userId/%s/site/https/detail"; + private static final String SITE_CREATE_PING_TASK_PATH = "/csm/api/v1/userId/%s/site/ping/create"; + private static final String SITE_UPDATE_PING_TASK_PATH = "/csm/api/v1/userId/%s/site/ping/update"; + private static final String SITE_GET_PING_TASK_PATH = "/csm/api/v1/userId/%s/site/ping/detail"; + private static final String SITE_CREATE_TCP_TASK_PATH = "/csm/api/v1/userId/%s/site/tcp/create"; + private static final String SITE_UPDATE_TCP_TASK_PATH = "/csm/api/v1/userId/%s/site/tcp/update"; + private static final String SITE_GET_TCP_TASK_PATH = "/csm/api/v1/userId/%s/site/tcp/detail"; + private static final String SITE_CREATE_UDP_TASK_PATH = "/csm/api/v1/userId/%s/site/udp/create"; + private static final String SITE_UPDATE_UDP_TASK_PATH = "/csm/api/v1/userId/%s/site/udp/update"; + private static final String SITE_GET_UDP_TASK_PATH = "/csm/api/v1/userId/%s/site/udp/detail"; + private static final String SITE_CREATE_FTP_TASK_PATH = "/csm/api/v1/userId/%s/site/ftp/create"; + private static final String SITE_UPDATE_FTP_TASK_PATH = "/csm/api/v1/userId/%s/site/ftp/update"; + private static final String SITE_GET_FTP_TASK_PATH = "/csm/api/v1/userId/%s/site/ftp/detail"; + private static final String SITE_CREATE_DNS_TASK_PATH = "/csm/api/v1/userId/%s/site/dns/create"; + private static final String SITE_UPDATE_DNS_TASK_PATH = "/csm/api/v1/userId/%s/site/dns/update"; + private static final String SITE_GET_DNS_TASK_PATH = "/csm/api/v1/userId/%s/site/dns/detail"; + private static final String SITE_GET_TASK_LIST_PATH = "/csm/api/v1/userId/%s/site/list"; + private static final String SITE_DELETE_TASK_PATH = "/csm/api/v1/userId/%s/site/delete"; + private static final String SITE_GET_TASK_DETAIL_PATH = "/csm/api/v1/userId/%s/site/%s"; + private static final String SITE_CREATE_ALARM_CONFIG_PATH = "/csm/api/v1/userId/%s/site/alarm/config/create"; + private static final String SITE_UPDATE_ALARM_CONFIG_PATH = "/csm/api/v1/userId/%s/site/alarm/config/update"; + private static final String SITE_DELETE_ALARM_CONFIG_PATH = "/csm/api/v1/userId/%s/site/alarm/config/delete"; + private static final String SITE_GET_ALARM_CONFIG_DETAIL_PATH = "/csm/api/v1/userId/%s/site/alarm/config/detail"; + private static final String SITE_GE_TALARM_CONFIG_LIST_PATH = "/csm/api/v1/userId/%s/site/alarm/config/list"; + private static final String SITE_ALARM_BLOCK_PATH = "/csm/api/v1/userId/%s/site/alarm/config/block"; + private static final String SITE_ALARM_UNBLOCK_PATH = "/csm/api/v1/userId/%s/site/alarm/config/unblock"; + private static final String SITE_GET_TASK_BY_ALARMNAME_PATH = "/csm/api/v1/userId/%s/site/alarm/config/%s"; + private static final String SITE_GET_METRIC_DATA_PATH = "/csm/api/v1/userId/%s/site/metricSiteData"; + private static final String SITE_GET_OVERALL_VIEW_PATH = "/csm/api/v1/userId/%s/site/idc/overallView"; + private static final String SITE_GET_PROVINCIAL_VIEW_PATH = "/csm/api/v1/userId/%s/site/idc/provincialView"; + private static final String SITE_AGENT_LIST_PATH = "/csm/api/v1/userId/%s/site/agent/list"; + private static final String SITE_GET_AGENT_BY_TASKID_PATH = "/csm/api/v1/userId/%s/site/agent/idcIsp"; + + private static final String APPLICATION_INFO_PATH = "/csm/api/v1/userId/%s/application"; + private static final String APPLICATION_INFO_DELETE_PATH = "/csm/api/v1/userId/%s/application/%s/delete"; + private static final String APPLICATION_INFO_LIST_PATH = "/csm/api/v1/userId/%s/instances/all"; + private static final String APPLICATION_INSTANCE_CREATE_PATH = "/csm/api/v1/userId/%s/application/instance/bind"; + private static final String APPLICATION_INSTANCE_CREATED_LIST_PATH = "/csm/api/v1/userId/%s/application/%s/instance/list"; + private static final String APPLICATION_INSTANCE_DELETE_PATH = "/csm/api/v1/userId/%s/application/%s/instance/%s/delete"; + private static final String APPLICATION_TASK_CREATE_PATH = "/csm/api/v1/userId/%s/application/task/create"; + private static final String APPLICATION_TASK_DETAIL_PATH = "/csm/api/v1/userId/%s/application/%s/task/%s"; + private static final String APPLICATION_TASK_LIST_PATH = "/csm/api/v1/userId/%s/application/%s/task/list"; + private static final String APPLICATION_TASK_DELETE_PATH = "/csm/api/v1/userId/%s/application/%s/task/%s/delete"; + private static final String APPLICATION_TASK_UPDATE_PATH = "/csm/api/v1/userId/%s/application/task/update"; + private static final String APPLICATION_DIMENSION_TABLE_CREATE_PATH = "/csm/api/v1/userId/%s/application/dimensionMap/create"; + private static final String APPLICATION_DIMENSION_TABLE_LIST_PATH = "/csm/api/v1/userId/%s/application/%s/dimensionMap/list"; + private static final String APPLICATION_DIMENSION_TABLE_DELETE_PATH = "/csm/api/v1/userId/%s/application/%s/dimensionMap/%s/delete"; + private static final String APPLICATION_DIMENSION_TABLE_UPDATE_PATH = "/csm/api/v1/userId/%s/application/dimensionMap/update"; + private static final String MULTI_DIMENSIONAL_LATEST_METRICS_PATH = "/csm/api/v2/userId/%s/services/%s/data/metricData/latest/batch"; + private static final String METRICS_BY_PARTIAL_DIMENSIONS_PATH = "/csm/api/v2/userId/%s/services/%s/data/metricData/PartialDimension"; + private static final String BATCH_GET_METRICS_PATH = "/csm/api/v2/data/metricAllData/batch"; + private static final String ALL_DATA_METRIC_V2_PATH = "/csm/api/v2/data/metricAllData"; + private static final String TOPN_PATH = "/csm/api/v2/dimensions/top"; + private static final String TOPN_DATA_PATH = "/csm/api/v2/dimensions/top/data"; + private static final String ALARM_HOUSE_ALARM_LIST = "/ah-api/v1/alarmhouse/alarm/list"; + private static final String ALARM_HOUSE_ALARM_DETAIL = "/ah-api/v1/alarmhouse/alarm"; + /** + * Exceptions + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String USER_NULL_ERROR_MESSAGE = "userId should not be null"; + private static final String REQUEST_PARAM_NULL_ERROR_MESSAGE = "param %s should not be null"; + private static final String PERIOD_ERROR_MESSAGE = "request %s should be a multiple of 60."; + private static final String USER_ID_MESSAGE_KEY = "userId"; + private static final String ACCOUNT_ID_MESSAGE_KEY = "accountId"; + private static final String PAGE_NO_MESSAGE_KEY = "pageNo"; + private static final String PAGE_SIZE_MESSAGE_KEY = "pageSize"; + private static final String SCOPE_MESSAGE_KEY = "scope"; + private static final String STATISTICS_ARR_MESSAGE_KEY = "statistics[]"; + private static final String START_TIME_MESSAGE_KEY = "startTime"; + private static final String END_TIME_MESSAGE_KEY = "endTime"; + private static final String TIMESTAMP_MESSAGE_KEY = "timestamp"; + private static final String PERIOD_MESSAGE_KEY = "periodInSecond"; + + private static final String DIMENSIONS_MESSAGE_KEY = "dimensions"; + private static final String METRIC_NAME_MESSAGE_KEY = "metricName"; + private static final String METRIC_NAMES_MESSAGE_KEY = "metricName[]"; + private static final String NAMESPACE_MESSAGE_KEY = "namespace"; + private static final String NAME_MESSAGE_KEY = "name"; + + private static final String TITLE = "title"; + private static final String CONFIGURE = "configure"; + private static final String TYPE = "type"; + private static final String DASHBOARD_NAME = "dashboardName"; + private static final String WIDGET_NAME = "widgetName"; + + private static final String REGION = "region"; + private static final String SERVICE = "service"; + private static final String SHOW_ID = "showId"; + + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling httpResponses from all bcm service calls. + */ + private static final HttpResponseHandler[] BCM_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BcmJsonResponseHandler() + }; + + + /** + * Constructs a new client to invoke service methods on bcm. + */ + public BcmClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new bbc client using the client configuration to access bcm. + * + * @param clientConfiguration The bcc client configuration options controlling how this client + * connects to bbc (e.g. proxy settings, retry counts, etc). + */ + public BcmClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, BCM_HANDLERS); + } + + /** + * Creates and initializes a new request object for the specified bcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(PREFIX); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * create get request with url + * + * @param bceRequest request body object + * @param httpMethod method name,such as put, post, delete et + * @param url method url + * @return InternalRequest + */ + private InternalRequest createRequestWithUrl(AbstractBceRequest bceRequest, HttpMethodName httpMethod, String url) { + URI uri = HttpUtils.appendUri(this.getEndpoint(), url); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * create request with json format body + * + * @param bceRequest request body object + * @param httpMethod method name,such as put, post, delete et + * @param url method url + * @return InternalRequest + */ + private InternalRequest createBodyRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, String url) { + URI uri = HttpUtils.appendUri(this.getEndpoint(), url); + InternalRequest request = new InternalRequest(httpMethod, uri); + fillPayload(request, bceRequest); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT + || internalRequest.getHttpMethod() == HttpMethodName.PATCH) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * check v1 request and warp + * + * @param request + */ + private void checkV1Request(AbstractBceRequest request, InternalRequest internalRequest, + String userId, String scope, + Statistics[] statistics, String startTime, String endTime, Integer periodInSecond) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(userId, checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check service + checkStringNotEmpty(scope, checkEmptyExceptionMessageFormat(SCOPE_MESSAGE_KEY)); + // check statistics + checkNotNull(statistics, checkEmptyExceptionMessageFormat(STATISTICS_ARR_MESSAGE_KEY)); + checkArgument(statistics.length != 0, checkEmptyExceptionMessageFormat(STATISTICS_ARR_MESSAGE_KEY)); + // check startTime + checkStringNotEmpty(startTime, checkEmptyExceptionMessageFormat(START_TIME_MESSAGE_KEY)); + // check endTime + checkStringNotEmpty(endTime, checkEmptyExceptionMessageFormat(END_TIME_MESSAGE_KEY)); + // check periodInSecond + checkNotNull(periodInSecond, checkEmptyExceptionMessageFormat(PERIOD_MESSAGE_KEY)); + checkArgument((periodInSecond / 60) != 0, stringFormat(PERIOD_ERROR_MESSAGE, PERIOD_MESSAGE_KEY)); + // warp parameters + internalRequest.addParameter(STATISTICS_ARR_MESSAGE_KEY, StringUtils.join(statistics, ",")); + internalRequest.addParameter(START_TIME_MESSAGE_KEY, startTime); + internalRequest.addParameter(END_TIME_MESSAGE_KEY, endTime); + internalRequest.addParameter(PERIOD_MESSAGE_KEY, String.valueOf(periodInSecond)); + } + + /** + * Get Metric Data. + * + * @param request metric data request. + * @return + */ + public MetricDataResponse getMetricData(MetricDataRequest request) { + // check metricName + checkStringNotEmpty(request.getMetricName(), checkEmptyExceptionMessageFormat(METRIC_NAME_MESSAGE_KEY)); + // Internal Request + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, V1, METRIC_DATA, + request.getUserId(), request.getScope(), request.getMetricName()); + checkV1Request(request, internalRequest, request.getUserId(), request.getScope(), request.getStatistics(), + request.getStartTime(), request.getEndTime(), request.getPeriodInSecond()); + // check dimensions + checkStringNotEmpty(request.getDimensions(), checkEmptyExceptionMessageFormat(DIMENSIONS_MESSAGE_KEY)); + internalRequest.addParameter(DIMENSIONS_MESSAGE_KEY, request.getDimensions()); + return invokeHttpClient(internalRequest, MetricDataResponse.class); + } + + /** + * Get List Metric Data. + * + * @param request List Metric Data request. + * @return + */ + public ListMetricDataResponse getMetricData(ListMetricDataRequest request) { + // Internal Request + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, V1, METRIC_DATA, + METRIC_NAME, request.getUserId(), request.getScope()); + checkV1Request(request, internalRequest, request.getUserId(), request.getScope(), request.getStatistics(), + request.getStartTime(), request.getEndTime(), request.getPeriodInSecond()); + // check metricName + checkNotNull(request.getMetricNames(), checkEmptyExceptionMessageFormat(METRIC_NAMES_MESSAGE_KEY)); + checkArgument(request.getMetricNames().length != 0, + checkEmptyExceptionMessageFormat(METRIC_NAMES_MESSAGE_KEY)); + internalRequest.addParameter(METRIC_NAMES_MESSAGE_KEY, StringUtils.join(request.getMetricNames(), ",")); + // check dimensions + checkStringNotEmpty(request.getDimensions(), checkEmptyExceptionMessageFormat(DIMENSIONS_MESSAGE_KEY)); + internalRequest.addParameter(DIMENSIONS_MESSAGE_KEY, request.getDimensions()); + return invokeHttpClient(internalRequest, ListMetricDataResponse.class); + } + + /** + * push custom monitor metric data api + * + * @param request request + * @return PushMetricDataResponse + */ + public PushMetricDataResponse pushCustomMonitorMetricData(PushCustomMetricDataRequest request) { + checkAndFormatPushCustomMetricDataRequest(request); + String url = String.format(PUSH_CUSTOM_METRIC_DATA_FORMAT, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, PushMetricDataResponse.class); + } + + /** + * check and format request + * + * @param request push custom metric reqeuest + */ + private void checkAndFormatPushCustomMetricDataRequest(PushCustomMetricDataRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getTimestamp(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + // check metric name + checkStringNotEmpty(request.getMetricName(), checkEmptyExceptionMessageFormat(METRIC_NAME_MESSAGE_KEY)); + // check timestamp + checkStringNotEmpty(request.getTimestamp(), checkEmptyExceptionMessageFormat(TIMESTAMP_MESSAGE_KEY)); + // check value + if (null == request.getValue() && null == request.getStatisticValues()) { + throw new IllegalArgumentException("value and statistics all should not be null."); + } + + if (null == request.getDimensions()) { + request.setDimensions(Collections.emptyList()); + } + } + + /** + * 创建自定义空间 + * + * @param request 请求对象 + * @return CustomMonitorResponse + */ + public CustomMonitorResponse createNamespace(NamespaceRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check name + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + + String url = String.format(CREATE_NAMESPACE, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, CustomMonitorResponse.class); + } + + /** + * 批量删除自定义空间 + * + * @param request 请求对象 + * @return CustomMonitorResponse + */ + public CustomMonitorResponse batchDeleteNamespaces(BatchDeleteNamespacesRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check name + checkIsTrue(CollectionUtils.isNotEmpty(request.getNames()), "names should not be empty"); + + String url = String.format(BATCH_DELETE_NAMESPACES, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, CustomMonitorResponse.class); + } + + /** + * 更新自定义空间 + * + * @param request 请求对象 + * @return CustomMonitorResponse + */ + public CustomMonitorResponse updateNamespace(NamespaceRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check name + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + + String url = String.format(UPDATE_NAMESPACE, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, CustomMonitorResponse.class); + } + + /** + * 获取或者搜索自定义空间 + * + * @param request 请求对象 + * @return ListNamespacesResponse + */ + public ListNamespacesResponse listNamespaces(ListNamespacesRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + if (null == request.getPageNo() || request.getPageNo() <= 0) { + request.setPageNo(1); + } + if (null == request.getPageSize() || request.getPageSize() <= 0) { + request.setPageSize(10); + } + + String url = String.format(LIST_NAMESPACES, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("name", request.getName()); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + return invokeHttpClient(internalRequest, ListNamespacesResponse.class); + } + + /** + * 创建自定义指标 + * + * @param request 请求对象 + * @return CustomMonitorResponse + */ + public CustomMonitorResponse createNamespaceMetric(NamespaceMetricRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + // check metricName + checkStringNotEmpty(request.getMetricName(), checkEmptyExceptionMessageFormat(METRIC_NAME)); + // check name + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (CollectionUtils.isEmpty(request.getDimensions())) { + request.setDimensions(Collections.emptyList()); + } + + String url = String.format(CREATE_NAMESPACE_METRIC, request.getUserId(), request.getNamespace()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, CustomMonitorResponse.class); + } + + /** + * 批量删除自定义指标 + * + * @param request 请求对象 + * @return CustomMonitorResponse + */ + public CustomMonitorResponse batchDeleteNamespaceMetrics(BatchDeleteNamespaceMetricsRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check ids + checkIsTrue(CollectionUtils.isNotEmpty(request.getIds()), "ids should not be empty"); + + String url = String.format(BATCH_DELETE_NAMESPACE_METRICS, request.getUserId(), request.getNamespace()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, CustomMonitorResponse.class); + } + + /** + * 更新自定义指标 + * + * @param request 请求对象 + * @return CustomMonitorResponse + */ + public CustomMonitorResponse updateNamespaceMetric(NamespaceMetricRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + // check metricName + checkStringNotEmpty(request.getMetricName(), checkEmptyExceptionMessageFormat(METRIC_NAME)); + // check cycle + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (CollectionUtils.isEmpty(request.getDimensions())) { + request.setDimensions(Collections.emptyList()); + } + + String url = String.format(UPDATE_NAMESPACE_METRIC, + request.getUserId(), request.getNamespace(), request.getMetricName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, CustomMonitorResponse.class); + } + + /** + * 获取或者搜索自定义指标 + * + * @param request 请求对象 + * @return ListNamespaceMetricsResponse + */ + public ListNamespaceMetricsResponse listNamespaceMetrics(ListNamespaceMetricsRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + if (null == request.getPageNo() || request.getPageNo() <= 0) { + request.setPageNo(1); + } + if (null == request.getPageSize() || request.getPageSize() <= 0) { + request.setPageSize(10); + } + + String url = String.format(LIST_NAMESPACE_METRICS, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("namespace", request.getNamespace()); + internalRequest.addParameter("metricName", request.getMetricName()); + internalRequest.addParameter("metricAlias", request.getMetricAlias()); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + return invokeHttpClient(internalRequest, ListNamespaceMetricsResponse.class); + } + + /** + * 获取某个自定义指标 + * + * @param request 请求对象 + * @return GetCustomMetricResponse + */ + public GetCustomMetricResponse getCustomMetric(GetCustomMetricRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + // check metricName + checkStringNotEmpty(request.getMetricName(), checkEmptyExceptionMessageFormat(METRIC_NAME)); + + String url = String.format(GET_CUSTOM_METRIC, + request.getUserId(), request.getNamespace(), request.getMetricName()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, GetCustomMetricResponse.class); + } + + /** + * 创建自定义事件 + * + * @param request 请求对象 + * @return CustomMonitorResponse + */ + public CustomMonitorResponse createNamespaceEvent(NamespaceEventRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + // check eventName + checkStringNotEmpty(request.getEventName(), checkEmptyExceptionMessageFormat(EVENT_NAME)); + // check event level + checkNotNull(request.getEventLevel(), "eventLevel should not be null"); + + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, CREATE_NAMESPACE_EVENT); + return invokeHttpClient(internalRequest, CustomMonitorResponse.class); + } + + /** + * 批量删除自定义事件 + * + * @param request 请求对象 + * @return CustomMonitorResponse + */ + public CustomMonitorResponse batchDeleteNamespaceEvents(BatchDeleteNamespaceEventsRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + // check names + checkIsTrue(CollectionUtils.isNotEmpty(request.getNames()), "names should not be empty"); + + InternalRequest internalRequest = this.createBodyRequest( + request, HttpMethodName.POST, BATCH_DELETE_NAMESPACE_EVENTS); + return invokeHttpClient(internalRequest, CustomMonitorResponse.class); + } + + /** + * 更新自定义事件 + * + * @param request 请求对象 + * @return CustomMonitorResponse + */ + public CustomMonitorResponse updateNamespaceEvent(NamespaceEventRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + // check eventName + checkStringNotEmpty(request.getEventName(), checkEmptyExceptionMessageFormat(EVENT_NAME)); + // check event level + checkNotNull(request.getEventLevel(), "eventLevel should not be null"); + + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, UPDATE_NAMESPACE_EVENT); + return invokeHttpClient(internalRequest, CustomMonitorResponse.class); + } + + /** + * 获取或者搜索自定义事件 + * + * @param request 请求对象 + * @return ListNamespaceEventsResponse + */ + public ListNamespaceEventsResponse listNamespaceEvents(ListNamespaceEventsRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + if (null == request.getPageNo() || request.getPageNo() <= 0) { + request.setPageNo(1); + } + if (null == request.getPageSize() || request.getPageSize() <= 0) { + request.setPageSize(10); + } + + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, LIST_NAMESPACE_EVENTS); + internalRequest.addParameter(USER_ID, request.getUserId()); + internalRequest.addParameter(NAMESPACE, request.getNamespace()); + internalRequest.addParameter(NAME, request.getName()); + if (null != request.getEventLevel()) { + internalRequest.addParameter(EVENT_LEVEL, request.getEventLevel().name()); + } + internalRequest.addParameter(PAGE_NO, String.valueOf(request.getPageNo())); + internalRequest.addParameter(PAGE_SIZE, String.valueOf(request.getPageSize())); + return invokeHttpClient(internalRequest, ListNamespaceEventsResponse.class); + } + + /** + * 获取某个自定义事件 + * + * @param request 请求对象 + * @return GetCustomEventResponse + */ + public GetCustomEventResponse getCustomEvent(GetCustomEventRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check namespace + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat(NAMESPACE_MESSAGE_KEY)); + // check eventName + checkStringNotEmpty(request.getEventName(), checkEmptyExceptionMessageFormat(EVENT_NAME)); + + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, GET_CUSTOM_EVENT); + internalRequest.addParameter(USER_ID, request.getUserId()); + internalRequest.addParameter(NAMESPACE, request.getNamespace()); + internalRequest.addParameter(EVENT_NAME, request.getEventName()); + return invokeHttpClient(internalRequest, GetCustomEventResponse.class); + } + + /** + * 创建仪表盘 + * + * @param request 创建仪表盘请求参数对象 + * @return 创建仪表盘返回结果对象 + */ + public DashboardCreateResponse createDashboard(DashboardBaseRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTitle(), checkEmptyExceptionMessageFormat(TITLE)); + checkStringNotEmpty(request.getConfigure(), checkEmptyExceptionMessageFormat(CONFIGURE)); + checkStringNotEmpty(request.getType(), checkEmptyExceptionMessageFormat(TYPE)); + + String url = String.format(CREATE_DASHBOARD_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, DashboardCreateResponse.class); + } + + /** + * 获取仪表盘 + * + * @param request 仪表盘请求对象 + * @return DashboardCreateResponse 仪表盘创建响应对象 + * @throws NullPointerException 如果request为null,抛出NullPointerException异常 + * @throws IllegalArgumentException 如果request中的userId或dashboardName为空,抛出IllegalArgumentException异常 + */ + public DashboardCreateResponse getDashboard(DashboardBaseRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDashboardName(), checkEmptyExceptionMessageFormat(DASHBOARD_NAME)); + + String url = String.format(DASHBOARD_PATH, request.getUserId(), request.getDashboardName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, DashboardCreateResponse.class); + } + + /** + * 更新仪表盘 + * + * @param request 更新仪表盘请求参数 + * @return 更新仪表盘返回结果 + */ + public DashboardResponse updateDashboard(DashboardBaseRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDashboardName(), checkEmptyExceptionMessageFormat(DASHBOARD_NAME)); + checkStringNotEmpty(request.getConfigure(), checkEmptyExceptionMessageFormat(CONFIGURE)); + String url = String.format(DASHBOARD_PATH, request.getUserId(), request.getDashboardName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, DashboardResponse.class); + } + + /** + * 删除仪表盘 + * + * @param request 仪表盘请求对象 + * @return 返回删除结果 + */ + public DashboardResponse deleteDashboard(DashboardBaseRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDashboardName(), checkEmptyExceptionMessageFormat(DASHBOARD_NAME)); + String url = String.format(DASHBOARD_PATH, request.getUserId(), request.getDashboardName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.DELETE, url); + return invokeHttpClient(internalRequest, DashboardResponse.class); + } + + /** + * 复制仪表盘 + * + * @param request 仪表盘复制请求对象 + * @return 复制后的仪表盘响应对象 + * @throws NullPointerException 如果request为null,抛出NullPointerException异常 + * @throws IllegalArgumentException 如果userId或dashboardName为空,抛出IllegalArgumentException异常 + */ + public DashboardResponse duplicateDashboard(DashboardBaseRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDashboardName(), checkEmptyExceptionMessageFormat(DASHBOARD_NAME)); + String url = String.format(DUPLICATE_DASHBOARD_PATH, request.getUserId(), request.getDashboardName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, DashboardResponse.class); + } + + /** + * 获取仪表盘组件 + * + * @param request 仪表盘组件请求对象 + * @return 获取仪表盘组件的响应对象 + * @throws NullPointerException 如果请求对象为空,则抛出该异常 + * @throws IllegalArgumentException 如果用户ID、仪表盘名称或组件名称为空,则抛出该异常 + */ + public DashboardCreateResponse getDashboardWidget(DashboardWidgetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDashboardName(), checkEmptyExceptionMessageFormat(DASHBOARD_NAME)); + checkStringNotEmpty(request.getWidgetName(), checkEmptyExceptionMessageFormat(WIDGET_NAME)); + String url = String.format(DASHBOARD_WIDGET_PATH, + request.getUserId(), request.getDashboardName(), request.getWidgetName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, DashboardCreateResponse.class); + } + + /** + * 创建仪表盘组件 + * + * @param request 包含创建组件请求信息的对象 + * @return 包含创建组件响应信息的对象 + * @throws NullPointerException 如果请求对象为空,抛出此异常 + * @throws IllegalArgumentException 如果用户ID或仪表盘名为空,抛出此异常 + */ + public DashboardResponse createDashboardWidget(DashboardBaseRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDashboardName(), checkEmptyExceptionMessageFormat(DASHBOARD_NAME)); + String url = String.format(CREATE_DASHBOARD_WIDGET_PATH, request.getUserId(), request.getDashboardName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, DashboardResponse.class); + } + + /** + * 更新仪表盘组件 + * + * @param request 更新组件请求 + * @return 更新后的仪表盘响应 + * @throws NullPointerException 如果请求为空,则抛出此异常 + * @throws IllegalArgumentException 如果用户ID、仪表盘名称或组件名称是空的,则抛出此异常 + */ + public DashboardResponse updateDashboardWidget(DashboardWidgetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDashboardName(), checkEmptyExceptionMessageFormat(DASHBOARD_NAME)); + checkStringNotEmpty(request.getWidgetName(), checkEmptyExceptionMessageFormat(WIDGET_NAME)); + String url = String.format(DASHBOARD_WIDGET_PATH, + request.getUserId(), request.getDashboardName(), request.getWidgetName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, DashboardResponse.class); + } + + /** + * 删除仪表盘组件 + * + * @param request 包含用户ID、仪表盘名称和组件名称的请求对象 + * @return 返回操作结果 + * @throws IllegalArgumentException 如果请求对象为空,抛出异常并提示错误信息 + * @throws IllegalArgumentException 如果用户ID、仪表盘名称或组件名称不为空,抛出异常并提示错误信息 + */ + public DashboardResponse deleteDashboardWidget(DashboardWidgetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDashboardName(), checkEmptyExceptionMessageFormat(DASHBOARD_NAME)); + checkStringNotEmpty(request.getWidgetName(), checkEmptyExceptionMessageFormat(WIDGET_NAME)); + String url = String.format(DASHBOARD_WIDGET_PATH, + request.getUserId(), request.getDashboardName(), request.getWidgetName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.DELETE, url); + return invokeHttpClient(internalRequest, DashboardResponse.class); + } + + /** + * 复制仪表盘组件 + * + * @param request 复制请求 + * @return 复制后的仪表盘组件响应 + * @throws NullPointerException 如果请求为空,则抛出此异常 + * @throws IllegalArgumentException 如果用户ID、仪表盘名称或组件名称为空,则抛出此异常 + */ + public DashboardResponse duplicateDashboardWidget(DashboardWidgetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDashboardName(), checkEmptyExceptionMessageFormat(DASHBOARD_NAME)); + checkStringNotEmpty(request.getWidgetName(), checkEmptyExceptionMessageFormat(WIDGET_NAME)); + String url = String.format(DUPLICATE_DASHBOARD_WIDGET_PATH, + request.getUserId(), request.getDashboardName(), request.getWidgetName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, DashboardResponse.class); + } + + /** + * 获取仪表盘报告数据 + * + * @param request 获取仪表盘报告数据请求参数 + * @return 返回获取仪表盘报告数据响应结果 + */ + public DashboardReportDataResponse getDashboardReportData(DashboardDataRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createBodyRequest(request, HttpMethodName.POST, DASHBOARD_REPORT_DATA_PATH); + return invokeHttpClient(internalRequest, DashboardReportDataResponse.class); + } + + /** + * 获取仪表盘趋势数据 + * + * @param request 获取趋势数据请求参数 + * @return DashboardTrendDataResponse 返回仪表盘趋势数据响应对象 + * @throws NullPointerException 如果request为null,抛出该异常 + */ + public DashboardTrendDataResponse getDashboardTrendData(DashboardDataRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createBodyRequest(request, HttpMethodName.POST, DASHBOARD_TREND_DATA_PATH); + return invokeHttpClient(internalRequest, DashboardTrendDataResponse.class); + } + + /** + * 获取仪表盘仪表图数据 + * + * @param request 数据请求对象 + * @return DashboardBillboardDataResponse 返回仪表盘数据响应对象 + * @throws NullPointerException 如果request为null,则抛出空指针异常 + */ + public DashboardBillboardDataResponse getDashboardGaugeChartData(DashboardDataRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createBodyRequest(request, HttpMethodName.POST, DASHBOARD_GAUGE_CHART_DATA_PATH); + return invokeHttpClient(internalRequest, DashboardBillboardDataResponse.class); + } + + /** + * 获取仪表盘数据面板数据 + * + * @param request 获取数据的请求参数 + * @return DashboardBillboardDataResponse 包含数据面板数据的响应对象 + * @throws NullPointerException 如果请求参数为空,则抛出此异常 + */ + public DashboardBillboardDataResponse getDashboardBillboardData(DashboardDataRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createBodyRequest(request, HttpMethodName.POST, DASHBOARD_BILLBOARD_DATA_PATH); + return invokeHttpClient(internalRequest, DashboardBillboardDataResponse.class); + } + + /** + * 获取仪表盘趋势高级数据响应 + * + * @param request 仪表盘数据请求 + * @return DashboardTrendSeniorDataResponse 仪表盘趋势高级数据响应对象 + */ + public DashboardTrendSeniorDataResponse getDashboardTrendSeniorData(DashboardDataRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = + this.createBodyRequest(request, HttpMethodName.POST, DASHBOARD_TREND_SENIOR_DATA_PATH); + return invokeHttpClient(internalRequest, DashboardTrendSeniorDataResponse.class); + } + + /** + * 获取仪表盘维度 + * + * @param request 包含用户ID的请求对象 + * @return 包含仪表盘维度的响应对象 + * @throws NullPointerException 如果请求对象为空,抛出该异常 + */ + public Map> getDashboardDimensions(DashboardDimensionsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + String url = String.format(DASHBOARD_DIMENSIONS_PATH, + request.getUserId(), request.getService(), request.getRegion()); + InternalRequest internalRequest = + this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter(DIMENSIONS_MESSAGE_KEY, request.getDimensions()); + internalRequest.addParameter(METRIC_NAME, request.getMetricName()); + internalRequest.addParameter(REGION, request.getRegion()); + internalRequest.addParameter(SERVICE, request.getService()); + internalRequest.addParameter(SHOW_ID, request.getShowId()); + return invokeHttpClient(internalRequest, MapListResponse.class).getResult(); + } + + /** + * 查询用户组列表 + * + * @param request + * @return + */ + public ListNotifyGroupsResponse listNotifyGroups(NotifyRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/json-api/v1/alarm/notify/group/list"); + return invokeHttpClient(internalRequest, ListNotifyGroupsResponse.class); + } + + /** + * 查询用户列表 + * + * @param request + * @return + */ + public ListNotifyPartiesResponse listNotifyParties(NotifyRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/json-api/v1/alarm/notify/party/list"); + return invokeHttpClient(internalRequest, ListNotifyPartiesResponse.class); + } + + /** + * 新建通知模版 + * + * @param request + */ + public void createAction(CreateAndUpdateActionRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkNotNull(request.getMembers(), checkEmptyExceptionMessageFormat("members")); + checkStringNotEmpty(request.getAlias(), checkEmptyExceptionMessageFormat("alias")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getNotifications()), + checkEmptyExceptionMessageFormat("notifications")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + String.format("/csm/api/v1/userId/%s/action/create", request.getUserId())); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 删除通知模版 + * + * @param request + */ + public void deleteAction(DeleteActionRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat("name")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.DELETE, + String.format("/csm/api/v1/userId/%s/action/delete", request.getUserId())); + internalRequest.addParameter("name", request.getName()); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 编辑通知模版 + * + * @param request + */ + public void updateAction(CreateAndUpdateActionRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + request.setProductName(request.getUserId()); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkNotNull(request.getMembers(), checkEmptyExceptionMessageFormat("members")); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat("name")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getNotifications()), + checkEmptyExceptionMessageFormat("notifications")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, + String.format("/csm/api/v1/userId/%s/action/update", request.getUserId())); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 查询通知模版列表 + * + * @param request + * @return + */ + public ListActionsResponse listActions(ListActionsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkIsTrue(request.getPageNo() > 0, "pageNo should be greater than 0"); + checkIsTrue(request.getPageSize() > 0, "pageSize should be greater than 0"); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + String.format("/csm/api/v1/userId/%s/action/actionList", request.getUserId())); + return invokeHttpClient(internalRequest, ListActionsResponse.class); + } + + /** + * 日志提取 + * + * @param request + * @return + */ + public List logExtract(LogExtractRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getExtractRule(), checkEmptyExceptionMessageFormat("extractRule")); + checkStringNotEmpty(request.getLogExample(), checkEmptyExceptionMessageFormat("logExample")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + String.format("/csm/api/v1/userId/%s/application/logextract", request.getUserId())); + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * 应用监控数据查询接口-维度值查询接口 + * + * @param request + * @return + */ + public Map> getMetricMetaForApplication(GetMetricMetaForApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAppName(), checkEmptyExceptionMessageFormat("appName")); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getMetricName(), checkEmptyExceptionMessageFormat("metricName")); + checkIsTrue(request.getInstances() != null && !request.getInstances().isEmpty(), + "instances should not be empty"); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + String.format("/csm/api/v1/userId/%s/application/%s/task/%s/metricMeta", request.getUserId(), + request.getAppName(), request.getTaskName())); + internalRequest.addParameter("metricName", request.getMetricName()); + internalRequest.addParameter("instances", StringUtils.join(request.getInstances(), ",")); + internalRequest.addParameter("dimensionKeys", StringUtils.join(request.getDimensionKeys(), ",")); + return invokeHttpClient(internalRequest, MapListResponse.class).getResult(); + } + + /** + * 应用监控监控数据查询接口-多监控对象,单指标查询接口 + * + * @param request + * @return + */ + public List getMetricDataForApplication(GetMetricDataForApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAppName(), checkEmptyExceptionMessageFormat("appName")); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getMetricName(), checkEmptyExceptionMessageFormat("metricName")); + checkStringNotEmpty(request.getStartTime(), checkEmptyExceptionMessageFormat("startTime")); + checkStringNotEmpty(request.getEndTime(), checkEmptyExceptionMessageFormat("endtTime")); + checkIsTrue(!(CollectionUtils.isEmpty(request.getInstances()) && BooleanUtils.isNotTrue(request.getAggrData())), + "instances can't be empty when aggrData is false or default"); + + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + String.format("/csm/api/v1/userId/%s/application/%s/task/%s/metricData", request.getUserId(), + request.getAppName(), request.getTaskName())); + Map params = new HashMap(); + params.put("startTime", request.getStartTime()); + params.put("endTime", request.getEndTime()); + params.put("metricName", request.getMetricName()); + if (CollectionUtils.isNotEmpty(request.getInstances())) { + params.put("instances", StringUtils.join(request.getInstances(), ",")); + } + if (request.getCycle() > 0) { + params.put("cycle", String.valueOf(request.getCycle())); + } + if (request.getAggrData()) { + params.put("aggrData", String.valueOf(true)); + } + if (null != request.getStatistics()) { + params.put("statistics", request.getStatistics().name()); + } + if (MapUtils.isNotEmpty(request.getDimensions())) { + List dimensions = new ArrayList(); + for (String key : request.getDimensions().keySet()) { + List values = request.getDimensions().get(key); + dimensions.add("key" + ":" + StringUtils.join(values, "___")); + } + params.put("dimensions", StringUtils.join(dimensions, ",")); + } + internalRequest.setParameters(params); + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * 报警策略创建接口 + * + * @param request + * @return + */ + public ApplicationAlarmConfig createAlarmConfigForApplication(CreateOrUpdateAlarmConfigForApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAppName(), checkEmptyExceptionMessageFormat("appName")); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkIsTrue(request.getMonitorObjectType() == MonitorObjectType.APP + || request.getMonitorObjectType() == MonitorObjectType.SERVICE, "monitorObjectType error"); + checkNotNull(request.getMonitorObject(), "monitor object should not be null"); + checkNotNull(request.getType(), "type should not be null"); + checkNotNull(request.getLevel(), "level should not be null"); + checkNotNull(request.getActionEnabled(), "actionEnabled should not be null"); + checkIsTrue(CollectionUtils.isNotEmpty(request.getRules()), "rules should not be null"); + checkStringNotEmpty(request.getSrcName(), checkEmptyExceptionMessageFormat("srcName")); + checkStringNotEmpty(request.getSrcType(), checkEmptyExceptionMessageFormat("srcType")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + String.format("/csm/api/v1/userId/%s/application/alarm/config/create", request.getUserId())); + return invokeHttpClient(internalRequest, ApplicationAlarmConfig.class); + } + + /** + * 报警策略更新接口 + * + * @param request + * @return + */ + public ApplicationAlarmConfig updateAlarmConfigForApplication(CreateOrUpdateAlarmConfigForApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAppName(), checkEmptyExceptionMessageFormat("appName")); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkIsTrue(request.getMonitorObjectType() == MonitorObjectType.APP + || request.getMonitorObjectType() == MonitorObjectType.SERVICE, "monitorObjectType error"); + checkNotNull(request.getMonitorObject(), "monitor object should not be null"); + checkNotNull(request.getType(), "type should not be null"); + checkNotNull(request.getLevel(), "level should not be null"); + checkNotNull(request.getActionEnabled(), "actionEnabled should not be null"); + checkIsTrue(CollectionUtils.isNotEmpty(request.getRules()), "rules should not be null"); + checkStringNotEmpty(request.getSrcName(), checkEmptyExceptionMessageFormat("srcName")); + checkStringNotEmpty(request.getSrcType(), checkEmptyExceptionMessageFormat("srcType")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, + String.format("/csm/api/v1/userId/%s/application/alarm/config/update", request.getUserId())); + return invokeHttpClient(internalRequest, ApplicationAlarmConfig.class); + } + + /** + * 报警策略列表接口 + * + * @param request + * @return + */ + public Page listAlarmConfigForApplication(ListAlarmConfigForApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkIsTrue(request.getPageNo() > 0, "pageNo should be greater than 0"); + Map params = new HashMap(); + params.put("appName", request.getAppName()); + params.put("alarmName", request.getAlarmName()); + params.put("actionEnabled", BooleanUtils.toString(request.getActionEnabled(), "true", "false", "")); + params.put("srcType", request.getSrcType()); + params.put("taskName", request.getTaskName()); + params.put("pageNo", String.valueOf(request.getPageNo())); + params.put("pageSize", String.valueOf(request.getPageSize())); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + String.format("/csm/api/v1/userId/%s/application/alarm/config/list", request.getUserId())); + internalRequest.setParameters(params); + return invokeHttpClient(internalRequest, Page.class); + } + + /** + * 报警策略删除接口 + * + * @param request + */ + public void deleteAlarmConfigForApplication(DeleteAlarmConfigForApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAppName(), checkEmptyExceptionMessageFormat("appName")); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.DELETE, + String.format("/csm/api/v1/userId/%s/application/alarm/config/delete", request.getUserId())); + internalRequest.addParameter("appName", request.getAppName()); + internalRequest.addParameter("alarmName", request.getAlarmName()); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 报警策略详情接口 + * + * @param request + * @return + */ + public ApplicationAlarmConfig getAlarmConfigForApplication(GetAlarmConfigForApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAppName(), checkEmptyExceptionMessageFormat("appName")); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + String.format("/csm/api/v1/userId/%s/application/alarm/%s/config/", request.getUserId(), + request.getAlarmName())); + internalRequest.addParameter("appName", request.getAppName()); + return invokeHttpClient(internalRequest, ApplicationAlarmConfig.class); + } + + /** + * 报警指标列表接口 + * + * @param request + * @return + */ + public List listAlarmMetricsForApplication(ListAlarmMetricsForApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAppName(), checkEmptyExceptionMessageFormat("appName")); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + String.format("/csm/api/v1/userId/%s/application/%s/%s/alarm/metrics", request.getUserId(), + request.getAppName(), request.getTaskName())); + if (null != request.getSearchName()) { + internalRequest.addParameter("searchName", request.getSearchName()); + } + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * 创建报警策略接口 + * + * @param request + * @return + */ + public void createAlarmConfig(CreateOrUpdateAlarmConfigRequest request) { + checkCreateOrUpdateAlarmConfigRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/services/alarm/config/create"); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 更新报警策略接口 + * + * @param request + * @return + */ + public void updateAlarmConfig(CreateOrUpdateAlarmConfigRequest request) { + checkCreateOrUpdateAlarmConfigRequest(request); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/services/alarm/config/update"); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 删除报警策略接口 + * + * @param request + * @return + */ + public void deleteAlarmConfig(CommonAlarmConfigRequest request) { + checkCommonAlarmConfigRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/services/alarm/config/delete"); + internalRequest.addParameter("userId", request.getUserId()); + internalRequest.addParameter("scope", request.getScope()); + internalRequest.addParameter("alarmName", request.getAlarmName()); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 屏蔽报警策略接口 + * + * @param request + * @return + */ + public void blockAlarmConfig(CommonAlarmConfigRequest request) { + checkCommonAlarmConfigRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/services/alarm/config/block"); + internalRequest.addParameter("userId", request.getUserId()); + internalRequest.addParameter("scope", request.getScope()); + internalRequest.addParameter("alarmName", request.getAlarmName()); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 接触屏蔽报警策略接口 + * + * @param request + * @return + */ + public void unblockAlarmConfig(CommonAlarmConfigRequest request) { + checkCommonAlarmConfigRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/services/alarm/config/unblock"); + internalRequest.addParameter("userId", request.getUserId()); + internalRequest.addParameter("scope", request.getScope()); + internalRequest.addParameter("alarmName", request.getAlarmName()); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 获取报警策略详情接口 + * + * @param request + * @return + */ + public AlarmConfig getAlarmConfigDetail(CommonAlarmConfigRequest request) { + checkCommonAlarmConfigRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + "/csm/api/v1/services/alarm/config"); + internalRequest.addParameter("userId", request.getUserId()); + internalRequest.addParameter("scope", request.getScope()); + internalRequest.addParameter("alarmName", request.getAlarmName()); + return invokeHttpClient(internalRequest, AlarmConfig.class); + } + + /** + * 获取单一实例报警策略列表接口 + * + * @param request + * @return + */ + public Page listSingleInstanceAlarmConfigs(ListSingleInstanceAlarmConfigsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getScope(), checkEmptyExceptionMessageFormat(SCOPE_MESSAGE_KEY)); + checkIsTrue(request.getPageNo() > 0, "pageNo should be greater than 0"); + checkIsTrue(request.getPageSize() > 0, "pageSize should be greater than 0"); + if (StringUtils.isEmpty(request.getRegion())) { + request.setRegion("bj"); + } + if (StringUtils.isEmpty(request.getOrder())) { + request.setOrder("desc"); + } + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + "/csm/api/v1/services/alarm/config/list"); + Map params = new HashMap(); + params.put("userId", request.getUserId()); + params.put("scope", request.getScope()); + params.put("region", request.getRegion()); + params.put("dimensions", request.getDimensions()); + params.put("order", request.getOrder()); + params.put("alarmNamePrefix", request.getAlarmNamePrefix()); + params.put("pageNo", String.valueOf(request.getPageNo())); + params.put("pageSize", String.valueOf(request.getPageSize())); + if (null != request.getActionEnabled()) { + params.put("actionEnabled", String.valueOf(request.getActionEnabled())); + } + internalRequest.setParameters(params); + return invokeHttpClient(internalRequest, Page.class); + } + + /** + * 获取监控项列表接口 + * + * @param request + * @return + */ + public List listAlarmMetrics(ListAlarmMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getScope(), checkEmptyExceptionMessageFormat(SCOPE_MESSAGE_KEY)); + checkStringNotEmpty(request.getRegion(), "region should not be empty"); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + "/csm/api/v1/services/alarm/config/metrics"); + Map params = new HashMap(); + params.put("userId", request.getUserId()); + params.put("scope", request.getScope()); + params.put("region", request.getRegion()); + params.put("dimensions", request.getDimensions()); + params.put("type", request.getType()); + params.put("locale", request.getLocale()); + internalRequest.setParameters(params); + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * 创建报警策略v2接口 + * + * @param request + * @return + */ + public CreateAlarmConfigV2Response createAlarmPolicyV2(CreateOrUpdateAlarmConfigV2Request request) { + checkCreateOrUpdateAlarmConfigV2Request(request); + + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + String.format("/csm/api/v2/userId/%s/services/%s/alarm/config/create", + request.getUserId(), request.getScope())); + return invokeHttpClient(internalRequest, CreateAlarmConfigV2Response.class); + } + + /** + * 更新报警策略v2接口 + * + * @param request + * @return + */ + public void updateAlarmPolicyV2(CreateOrUpdateAlarmConfigV2Request request) { + checkCreateOrUpdateAlarmConfigV2Request(request); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, + String.format("/csm/api/v2/userId/%s/services/%s/alarm/config/update", + request.getUserId(), request.getScope())); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 屏蔽报警策略v2接口 + * + * @param request + * @return + */ + public void blockAlarmConfigV2(CommonAlarmConfigRequest request) { + checkCommonAlarmConfigRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + String.format("/csm/api/v2/userId/%s/services/%s/alarm/config/block", + request.getUserId(), request.getScope())); + internalRequest.addParameter("alarmName", request.getAlarmName()); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 解除屏蔽报警策略v2接口 + * + * @param request + * @return + */ + public void unblockAlarmConfigV2(CommonAlarmConfigRequest request) { + checkCommonAlarmConfigRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + String.format("/csm/api/v2/userId/%s/services/%s/alarm/config/unblock", + request.getUserId(), request.getScope())); + internalRequest.addParameter("alarmName", request.getAlarmName()); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 获取报警策略详情v2接口 + * + * @param request + * @return + */ + public AlarmConfigV2 getAlarmPolicyDetailV2(CommonAlarmConfigRequest request) { + checkCommonAlarmConfigRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + String.format("/csm/api/v2/userId/%s/services/%s/alarm/config", + request.getUserId(), request.getScope())); + internalRequest.addParameter("alarmName", request.getAlarmName()); + return invokeHttpClient(internalRequest, AlarmConfigV2.class); + } + + private void checkCreateOrUpdateAlarmConfigV2Request(CreateOrUpdateAlarmConfigV2Request request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getScope(), checkEmptyExceptionMessageFormat(SCOPE_MESSAGE_KEY)); + checkStringNotEmpty(request.getAliasName(), checkEmptyExceptionMessageFormat("aliasName")); + TargetType targetType = request.getTargetType(); + checkIsTrue(TargetType.TARGET_TYPE_ALL_INSTANCES == targetType || + TargetType.TARGET_TYPE_INSTANCE_GROUP == targetType || + TargetType.TARGET_TYPE_MULTI_INSTANCES == targetType || + TargetType.TARGET_TYPE_INSTANCE_TAGS == targetType, "targetType is invalid"); + if (TargetType.TARGET_TYPE_INSTANCE_GROUP == targetType) { + checkIsTrue(CollectionUtils.isNotEmpty(request.getTargetInstanceGroups()), + "targetInstanceGroups should not be empty"); + } + if (TargetType.TARGET_TYPE_MULTI_INSTANCES == targetType) { + checkIsTrue(CollectionUtils.isNotEmpty(request.getTargetInstances()), + "targetInstances should not be empty"); + } + if (TargetType.TARGET_TYPE_INSTANCE_TAGS == targetType) { + checkIsTrue(CollectionUtils.isNotEmpty(request.getTargetInstanceTags()), + "targetInstanceTags should not be empty"); + } + checkIsTrue(CollectionUtils.isNotEmpty(request.getPolicies()), "policies should not be empty"); + checkIsTrue(CollectionUtils.isNotEmpty(request.getActions()), "actions should not be empty"); + } + + private void checkCreateOrUpdateAlarmConfigRequest(CreateOrUpdateAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getScope(), checkEmptyExceptionMessageFormat(SCOPE_MESSAGE_KEY)); + checkStringNotEmpty(request.getAliasName(), checkEmptyExceptionMessageFormat("aliasName")); + checkNotNull(request.getMonitorObject(), "monitorObject should not be null"); + checkIsTrue(CollectionUtils.isNotEmpty(request.getAlarmActions()), "alarmActions should not be empty"); + checkIsTrue(CollectionUtils.isNotEmpty(request.getRules()), "rules should not be empty"); + } + + private void checkCommonAlarmConfigRequest(CommonAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getScope(), checkEmptyExceptionMessageFormat(SCOPE_MESSAGE_KEY)); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + } + + + /** + * Get Cloud Event Data. + * + * @param request Event Data Request. + * @return CloudEventResponse + */ + public CloudEventResponse getCloudEventData(EventDataRequest request) { + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, CLOUD_EVENT_LIST_PATH); + // check request params + checkEventDataRequest(request, internalRequest, EventType.Cloud); + return invokeHttpClient(internalRequest, CloudEventResponse.class); + } + + /** + * Get Platform Event Data. + * + * @param request Event Data Request. + * @return PlatformEventResponse + */ + public PlatformEventResponse getPlatformEventData(EventDataRequest request) { + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, PLATFORM_EVENT_LIST_PATH); + // check request params + checkEventDataRequest(request, internalRequest, EventType.Platform); + return invokeHttpClient(internalRequest, PlatformEventResponse.class); + } + + /** + * Create Event Policy. + * + * @param eventPolicy Event Policy. + * @return EventPolicyResponse + */ + public EventPolicyResponse createEventPolicy(EventPolicy eventPolicy) { + checkEventPolicy(eventPolicy); + String url = String.format(EVENT_POLICY_PATH, eventPolicy.getAccountId(), eventPolicy.getServiceName()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(eventPolicy, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, EventPolicyResponse.class); + } + + + /** + * Create Instance Group. + * + * @param mergedGroup Merged Group. + * @return InstanceGroupResponse + */ + public InstanceGroupResponse instanceGroupCreate(MergedGroup mergedGroup) { + checkMergedGroup(mergedGroup); + String url = String.format(INSTANCE_GROUP_PATH, mergedGroup.getUserId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(mergedGroup, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, InstanceGroupResponse.class); + } + + /** + * Update Instance Group. + * + * @param instanceGroup Instance Group. + * @return InstanceGroupResponse + */ + public InstanceGroupResponse instanceGroupUpdate(InstanceGroup instanceGroup) { + checkInstanceGroup(instanceGroup); + String url = String.format(INSTANCE_GROUP_PATH, instanceGroup.getUserId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(instanceGroup, HttpMethodName.PATCH, url); + return invokeHttpClient(internalRequest, InstanceGroupResponse.class); + } + + /** + * Delete Instance Group. + * + * @param instanceGroupBase Instance Group Base. + * @return InstanceGroupResponse + */ + public InstanceGroupResponse instanceGroupDelete(InstanceGroupBase instanceGroupBase) { + checkInstanceGroupBase(instanceGroupBase); + String url = String.format(INSTANCE_GROUP_ID_PATH, instanceGroupBase.getUserId(), instanceGroupBase.getId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(instanceGroupBase, HttpMethodName.DELETE, url); + return invokeHttpClient(internalRequest, InstanceGroupResponse.class); + } + + /** + * Get Instance Group Detail. + * + * @param instanceGroupBase Instance Group Base. + * @return InstanceGroupResponse + */ + public InstanceGroupResponse instanceGroupGet(InstanceGroupBase instanceGroupBase) { + checkInstanceGroupBase(instanceGroupBase); + String url = String.format(INSTANCE_GROUP_ID_PATH, instanceGroupBase.getUserId(), instanceGroupBase.getId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(instanceGroupBase, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, InstanceGroupResponse.class); + } + + /** + * Get Instance Group List. + * + * @param instanceGroupQuery Instance Group Query. + * @return InstanceGroupResponse + */ + public InstanceGroupListResponse instanceGroupList(InstanceGroupQuery instanceGroupQuery) { + checkInstanceGroupQuery(instanceGroupQuery); + String url = String.format(INSTANCE_GROUP_LIST_PATH, instanceGroupQuery.getUserId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(instanceGroupQuery, HttpMethodName.GET, url); + buildInstanceGroupQueryParams(instanceGroupQuery, internalRequest); + return invokeHttpClient(internalRequest, InstanceGroupListResponse.class); + } + + /** + * Add Instance to Instance Group. + * + * @param mergedGroup Merged Group. + * @return InstanceGroupResponse Instance Group Response. + */ + public InstanceGroupResponse instanceGroupAddInstance(MergedGroup mergedGroup) { + checkMergedGroup(mergedGroup); + String url = String.format(IG_INSTANCE_ADD, mergedGroup.getUserId(), mergedGroup.getId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(mergedGroup, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, InstanceGroupResponse.class); + } + + /** + * Remove Instance from Instance Group. + * + * @param mergedGroup Merged Group. + * @return InstanceGroupResponse Instance Group Response. + */ + public InstanceGroupResponse instanceGroupRemoveInstance(MergedGroup mergedGroup) { + checkMergedGroup(mergedGroup); + String url = String.format(IG_INSTANCE_REMOVE, mergedGroup.getUserId(), mergedGroup.getId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(mergedGroup, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, InstanceGroupResponse.class); + } + + /** + * Get Instance List from Instance Group. + * + * @param igInstanceQuery Instance Group Instance Query. + * @return InstanceGroupResponse Instance Group Response. + */ + public IGInstanceListResponse instanceGroupGetInstanceList(IGInstanceQuery igInstanceQuery) { + checkIGInstanceQuery(igInstanceQuery, IGInstanceQueryType.INCLUDE); + String url = String.format(IG_INSTANCE_LIST, igInstanceQuery.getUserId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(igInstanceQuery, HttpMethodName.GET, url); + buildIGInstanceQueryParams(igInstanceQuery, internalRequest, IGInstanceQueryType.INCLUDE); + return invokeHttpClient(internalRequest, IGInstanceListResponse.class); + } + + /** + * Get Instance List. + * + * @param igInstanceQuery Instance Group Instance Query. + * @return InstanceGroupResponse Instance Group Response. + */ + public IGInstanceListResponse instanceGroupQueryInstanceList(IGInstanceQuery igInstanceQuery) { + checkIGInstanceQuery(igInstanceQuery, IGInstanceQueryType.ALL); + String url = String.format(IG_QUERY_INSTANCE_LIST, igInstanceQuery.getUserId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(igInstanceQuery, HttpMethodName.GET, url); + buildIGInstanceQueryParams(igInstanceQuery, internalRequest, IGInstanceQueryType.ALL); + return invokeHttpClient(internalRequest, IGInstanceListResponse.class); + } + + /** + * Get Filter Instance List. + * + * @param igInstanceQuery Instance Group Instance Query. + * @return InstanceGroupResponse Instance Group Response. + */ + public IGInstanceListResponse instanceGroupQueryInstanceListFilter(IGInstanceQuery igInstanceQuery) { + checkIGInstanceQuery(igInstanceQuery, IGInstanceQueryType.FILTER); + String url = String.format(IG_QUERY_INSTANCE_LIST_FILTER, igInstanceQuery.getUserId()); + // Internal Request + InternalRequest internalRequest = this.createBodyRequest(igInstanceQuery, HttpMethodName.GET, url); + buildIGInstanceQueryParams(igInstanceQuery, internalRequest, IGInstanceQueryType.FILTER); + return invokeHttpClient(internalRequest, IGInstanceListResponse.class); + } + + private void checkIGInstanceQuery(IGInstanceQuery igInstanceQuery, IGInstanceQueryType type) { + // check not null + checkNotNull(igInstanceQuery, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(igInstanceQuery.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check pageNo and pageSize + checkNotNull(igInstanceQuery.getPageNo(), checkEmptyExceptionMessageFormat(PAGE_NO_MESSAGE_KEY)); + checkNotNull(igInstanceQuery.getPageSize(), checkEmptyExceptionMessageFormat(PAGE_SIZE_MESSAGE_KEY)); + + // check serviceName + checkStringNotEmpty(igInstanceQuery.getServiceName(), checkEmptyExceptionMessageFormat("serviceName")); + // check typeName + checkStringNotEmpty(igInstanceQuery.getTypeName(), checkEmptyExceptionMessageFormat("typeName")); + // check region + checkStringNotEmpty(igInstanceQuery.getRegion(), checkEmptyExceptionMessageFormat("region")); + // check viewType + checkNotNull(igInstanceQuery.getViewType(), checkEmptyExceptionMessageFormat("viewType")); + + if (IGInstanceQueryType.INCLUDE.equals(type)) { + // check id + checkNotNull(igInstanceQuery.getId(), checkEmptyExceptionMessageFormat("id")); + } + if (IGInstanceQueryType.FILTER.equals(type)) { + // check id + checkNotNull(igInstanceQuery.getId(), checkEmptyExceptionMessageFormat("id")); + // check uuid + checkStringNotEmpty(igInstanceQuery.getUuid(), checkEmptyExceptionMessageFormat("uuid")); + } + + } + + private void buildIGInstanceQueryParams( + IGInstanceQuery igInstanceQuery, InternalRequest internalRequest, IGInstanceQueryType type) { + internalRequest.addParameter(PAGE_NO_MESSAGE_KEY, String.valueOf(igInstanceQuery.getPageNo())); + internalRequest.addParameter(PAGE_SIZE_MESSAGE_KEY, String.valueOf(igInstanceQuery.getPageSize())); + internalRequest.addParameter("serviceName", igInstanceQuery.getServiceName()); + internalRequest.addParameter("typeName", igInstanceQuery.getTypeName()); + internalRequest.addParameter("region", igInstanceQuery.getRegion()); + internalRequest.addParameter("viewType", igInstanceQuery.getViewType().toString()); + if (IGInstanceQueryType.INCLUDE.equals(type)) { + internalRequest.addParameter("id", String.valueOf(igInstanceQuery.getId())); + } + if (IGInstanceQueryType.ALL.equals(type)) { + internalRequest.addParameter("keywordType", igInstanceQuery.getKeywordType()); + internalRequest.addParameter("keyword", igInstanceQuery.getKeyword()); + } + if (IGInstanceQueryType.FILTER.equals(type)) { + internalRequest.addParameter("keywordType", igInstanceQuery.getKeywordType()); + internalRequest.addParameter("keyword", igInstanceQuery.getKeyword()); + internalRequest.addParameter("id", String.valueOf(igInstanceQuery.getId())); + internalRequest.addParameter("uuid", igInstanceQuery.getUuid()); + } + } + + private void checkInstanceGroupQuery(InstanceGroupQuery instanceGroupQuery) { + // check not null + checkNotNull(instanceGroupQuery, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(instanceGroupQuery.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check pageNo and pageSize + checkNotNull(instanceGroupQuery.getPageNo(), checkEmptyExceptionMessageFormat(PAGE_NO_MESSAGE_KEY)); + checkNotNull(instanceGroupQuery.getPageSize(), checkEmptyExceptionMessageFormat(PAGE_SIZE_MESSAGE_KEY)); + } + + private void buildInstanceGroupQueryParams(InstanceGroupQuery instanceGroupQuery, InternalRequest + internalRequest) { + internalRequest.addParameter(PAGE_NO_MESSAGE_KEY, String.valueOf(instanceGroupQuery.getPageNo())); + internalRequest.addParameter(PAGE_SIZE_MESSAGE_KEY, String.valueOf(instanceGroupQuery.getPageSize())); + if (Strings.isNotEmpty(instanceGroupQuery.getName())) { + internalRequest.addParameter("name", instanceGroupQuery.getName()); + } + if (Strings.isNotEmpty(instanceGroupQuery.getServiceName())) { + internalRequest.addParameter("serviceName", instanceGroupQuery.getServiceName()); + } + if (Strings.isNotEmpty(instanceGroupQuery.getRegion())) { + internalRequest.addParameter("region", instanceGroupQuery.getRegion()); + } + if (Strings.isNotEmpty(instanceGroupQuery.getTypeName())) { + internalRequest.addParameter("typeName", instanceGroupQuery.getTypeName()); + } + } + + private void checkInstanceGroupBase(InstanceGroupBase instanceGroupBase) { + // check not null + checkNotNull(instanceGroupBase, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(instanceGroupBase.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check id + checkStringNotEmpty(instanceGroupBase.getId(), checkEmptyExceptionMessageFormat("id")); + } + + private void checkInstanceGroup(InstanceGroup instanceGroup) { + // check not null + checkNotNull(instanceGroup, REQUEST_NULL_ERROR_MESSAGE); + // check id + checkNotNull(instanceGroup.getId(), checkEmptyExceptionMessageFormat("id")); + // check name + checkStringNotEmpty(instanceGroup.getName(), checkEmptyExceptionMessageFormat("name")); + // check serviceName + checkStringNotEmpty(instanceGroup.getServiceName(), checkEmptyExceptionMessageFormat("serviceName")); + // check typeName + checkStringNotEmpty(instanceGroup.getTypeName(), checkEmptyExceptionMessageFormat("typeName")); + // check region + checkStringNotEmpty(instanceGroup.getRegion(), checkEmptyExceptionMessageFormat("region")); + } + + private void checkMergedGroup(MergedGroup mergedGroup) { + // check not null + checkNotNull(mergedGroup, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(mergedGroup.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + // check region + checkStringNotEmpty(mergedGroup.getRegion(), checkEmptyExceptionMessageFormat("region")); + // check serviceName + checkStringNotEmpty(mergedGroup.getServiceName(), checkEmptyExceptionMessageFormat("serviceName")); + // check typeName + checkStringNotEmpty(mergedGroup.getTypeName(), checkEmptyExceptionMessageFormat("typeName")); + // check name + checkStringNotEmpty(mergedGroup.getName(), checkEmptyExceptionMessageFormat("name")); + } + + private void checkEventPolicy(EventPolicy eventPolicy) { + // check not null + checkNotNull(eventPolicy, REQUEST_NULL_ERROR_MESSAGE); + // check userId + checkStringNotEmpty(eventPolicy.getAccountId(), checkEmptyExceptionMessageFormat(ACCOUNT_ID_MESSAGE_KEY)); + // check serviceName + checkStringNotEmpty(eventPolicy.getServiceName(), checkEmptyExceptionMessageFormat("serviceName")); + // check name + checkStringNotEmpty(eventPolicy.getName(), checkEmptyExceptionMessageFormat("name")); + // check blockStatus + checkNotNull(eventPolicy.getBlockStatus(), checkEmptyExceptionMessageFormat("blockStatus")); + + // check eventFilter + EventFilter eventFilter = eventPolicy.getEventFilter(); + checkNotNull(eventFilter, checkEmptyExceptionMessageFormat("eventFilter")); + checkNotNull(eventFilter.getEventLevel(), checkEmptyExceptionMessageFormat("eventLevel")); + // check eventFilter.eventName + checkNotNull(eventFilter.getEventTypeList(), checkEmptyExceptionMessageFormat("eventTypeList")); + checkArgument(eventFilter.getEventTypeList().size() != 0, + checkEmptyExceptionMessageFormat("eventTypeList")); + + // check resource + EventResourceFilter resource = eventPolicy.getResource(); + checkNotNull(resource, checkEmptyExceptionMessageFormat("resource")); + checkStringNotEmpty(resource.getRegion(), checkEmptyExceptionMessageFormat("resource.region")); + checkStringNotEmpty(resource.getType(), checkEmptyExceptionMessageFormat("resource.type")); + + // check incidentActions + checkNotNull(eventPolicy.getIncidentActions(), checkEmptyExceptionMessageFormat("incidentActions")); + checkArgument(eventPolicy.getIncidentActions().size() != 0, + checkEmptyExceptionMessageFormat("incidentActions")); + } + + private void checkEventDataRequest(EventDataRequest request, InternalRequest internalRequest, EventType type) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + // check pageNo and pageSize + checkNotNull(request.getPageNo(), checkEmptyExceptionMessageFormat(PAGE_NO_MESSAGE_KEY)); + checkNotNull(request.getPageSize(), checkEmptyExceptionMessageFormat(PAGE_SIZE_MESSAGE_KEY)); + // check userId + checkStringNotEmpty(request.getAccountId(), checkEmptyExceptionMessageFormat(ACCOUNT_ID_MESSAGE_KEY)); + // check startTime and endTime + checkStringNotEmpty(request.getStartTime(), checkEmptyExceptionMessageFormat(START_TIME_MESSAGE_KEY)); + checkStringNotEmpty(request.getEndTime(), checkEmptyExceptionMessageFormat(END_TIME_MESSAGE_KEY)); + checkUTC(request.getStartTime()); + checkUTC(request.getEndTime()); + + // build request params + internalRequest.addParameter(PAGE_NO_MESSAGE_KEY, String.valueOf(request.getPageNo())); + internalRequest.addParameter(PAGE_SIZE_MESSAGE_KEY, String.valueOf(request.getPageSize())); + internalRequest.addParameter(ACCOUNT_ID_MESSAGE_KEY, request.getAccountId()); + internalRequest.addParameter(START_TIME_MESSAGE_KEY, request.getStartTime()); + internalRequest.addParameter(END_TIME_MESSAGE_KEY, request.getEndTime()); + if (request.getAscending() != null) { + internalRequest.addParameter("ascending", String.valueOf(request.getAscending())); + } + if (EventType.Cloud.equals(type) && Strings.isNotEmpty(request.getScope())) { + internalRequest.addParameter(SCOPE_MESSAGE_KEY, request.getScope()); + } + if (Strings.isNotEmpty(request.getRegion())) { + internalRequest.addParameter("region", request.getRegion()); + } + if (request.getEventLevel() != null && EventLevel.ALL != request.getEventLevel()) { + internalRequest.addParameter("eventLevel", request.getEventLevel().getName()); + } + if (EventType.Cloud.equals(type) && Strings.isNotEmpty(request.getResourceType())) { + internalRequest.addParameter("resourceType", request.getResourceType()); + } + if (EventType.Cloud.equals(type) && Strings.isNotEmpty(request.getResourceId())) { + internalRequest.addParameter("resourceId", request.getResourceId()); + } + if (Strings.isNotEmpty(request.getEventName())) { + internalRequest.addParameter("eventName", request.getEventName()); + } + if (Strings.isNotEmpty(request.getEventAlias())) { + internalRequest.addParameter("eventAlias", request.getEventAlias()); + } + if (Strings.isNotEmpty(request.getEventId())) { + internalRequest.addParameter("eventId", request.getEventId()); + } + } + + private void checkUTC(String time) { + String utcPattern = "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"; + checkPattern(time, utcPattern, "time should be UTC format"); + } + + + /** + * 创建http类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse createHttpSiteTask(HttpTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getMethod(), checkEmptyExceptionMessageFormat("method")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + + String url = String.format(SITE_CREATE_HTTP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 更新http类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse updateHttpSiteTask(HttpTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getMethod(), checkEmptyExceptionMessageFormat("method")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + + String url = String.format(SITE_UPDATE_HTTP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 查询http类型的站点探测任务详情 + * + * @param request 请求对象 + * @return HttpTaskResponse + */ + public HttpTaskResponse getHttpSiteTask(TaskDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + + String url = String.format(SITE_GET_HTTP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, HttpTaskResponse.class); + } + + /** + * 创建https类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse createHttpsSiteTask(HttpsTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getMethod(), checkEmptyExceptionMessageFormat("method")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + + String url = String.format(SITE_CREATE_HTTPS_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 更新https类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse updateHttpsSiteTask(HttpsTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getMethod(), checkEmptyExceptionMessageFormat("method")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + + String url = String.format(SITE_UPDATE_HTTPS_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 查询https类型的站点探测任务详情 + * + * @param request 请求对象 + * @return HttpTaskResponse + */ + public HttpsTaskResponse getHttpsSiteTask(TaskDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + + String url = String.format(SITE_GET_HTTPS_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, HttpsTaskResponse.class); + } + + /** + * 创建ping类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse createPingSiteTask(PingTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + + String url = String.format(SITE_CREATE_PING_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 更新ping类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse updatePingSiteTask(PingTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + String url = String.format(SITE_UPDATE_PING_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 查询ping类型的站点探测任务详情 + * + * @param request 请求对象 + * @return PingTaskResponse + */ + public PingTaskResponse getPingSiteTask(TaskDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + + String url = String.format(SITE_GET_PING_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, PingTaskResponse.class); + } + + /** + * 创建udp类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse createTcpSiteTask(TcpTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (request.getPort() <= 0) { + throw new IllegalArgumentException("port should not greater 0"); + } + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + + String url = String.format(SITE_CREATE_TCP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 更新udp类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse updateTcpSiteTask(TcpTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (request.getPort() <= 0) { + throw new IllegalArgumentException("port should not greater 0"); + } + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + String url = String.format(SITE_UPDATE_TCP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 查询tcp类型的站点探测任务详情 + * + * @param request 请求对象 + * @return TcpTaskResponse + */ + public TcpTaskResponse getTcpSiteTask(TaskDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + + String url = String.format(SITE_GET_TCP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, TcpTaskResponse.class); + } + + /** + * 创建udp类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse createUdpSiteTask(UdpTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (request.getPort() <= 0) { + throw new IllegalArgumentException("port should not greater 0"); + } + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + + String url = String.format(SITE_CREATE_UDP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 更新udp类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse updateUdpSiteTask(UdpTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (request.getPort() <= 0) { + throw new IllegalArgumentException("port should not greater 0"); + } + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + String url = String.format(SITE_UPDATE_UDP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 查询udp类型的站点探测任务详情 + * + * @param request 请求对象 + * @return UdpTaskResponse + */ + public UdpTaskResponse getUdpSiteTask(TaskDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + + String url = String.format(SITE_GET_UDP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, UdpTaskResponse.class); + } + + /** + * 创建ftp类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse createFtpSiteTask(FtpTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (request.getPort() <= 0) { + throw new IllegalArgumentException("port should not greater 0"); + } + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + + String url = String.format(SITE_CREATE_FTP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 更新ftp类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse updateFtpSiteTask(FtpTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (request.getPort() <= 0) { + throw new IllegalArgumentException("port should not greater 0"); + } + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + String url = String.format(SITE_UPDATE_FTP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 查询ftp类型的站点探测任务详情 + * + * @param request 请求对象 + * @return FtpTaskResponse + */ + public FtpTaskResponse getFtpSiteTask(TaskDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + + String url = String.format(SITE_GET_FTP_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, FtpTaskResponse.class); + } + + /** + * 创建dns类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse createDnsSiteTask(DnsTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + + String url = String.format(SITE_CREATE_DNS_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 更新dns类型的站点探测任务 + * + * @param request 请求对象 + * @return TaskResponse + */ + public TaskResponse updateDnsSiteTask(DnsTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskName(), checkEmptyExceptionMessageFormat("taskName")); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (null == request.getCycle() || request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + if (request.getTimeout() <= 0) { + throw new IllegalArgumentException("timeout should not greater 0"); + } + String url = String.format(SITE_UPDATE_DNS_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, TaskResponse.class); + } + + /** + * 查询dns类型的站点探测任务详情 + * + * @param request 请求对象 + * @return DnsTaskResponse + */ + public DnsTaskResponse getDnsSiteTask(TaskDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + + String url = String.format(SITE_GET_DNS_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, DnsTaskResponse.class); + } + + + /** + * 查询站点监控任务列表 + * + * @param request + * @return PageData + */ + public PageData getSiteTaskList(TaskSummaryRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + if (request.getPageNo() <= 0) { + throw new IllegalArgumentException("pageNo should not greater 0"); + } + if (request.getPageSize() <= 0) { + throw new IllegalArgumentException("pageSize should not greater 0"); + } + String url = String.format(SITE_GET_TASK_LIST_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + Map params = new HashMap(); + params.put("pageNo", String.valueOf(request.getPageNo())); + params.put("pageSize", String.valueOf(request.getPageSize())); + params.put("query", request.getQuery()); + internalRequest.setParameters(params); + return invokeHttpClient(internalRequest, PageData.class); + } + + /** + * 删除站点监控任务 + * + * @param request + * @return SiteBasicResponse + */ + public SiteBasicResponse deleteSiteTask(SiteTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + String url = String.format(SITE_DELETE_TASK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.DELETE, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, SiteBasicResponse.class); + } + + /** + * 站点监控任务查询 + * + * @param request + * @return SiteInfoResponse + */ + public SiteInfoResponse getSiteInfo(SiteTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + String url = String.format(SITE_GET_TASK_DETAIL_PATH, request.getUserId(), request.getTaskId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, SiteInfoResponse.class); + } + + /** + * 创建站点监控报警策略 + * + * @param request + */ + public void createSiteAlarmConfig(SiteAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAliasName(), checkEmptyExceptionMessageFormat("aliasName")); + checkNotNull(request.getLevel(), "level should not be null"); + checkArgument(request.getRules().size() != 0, checkEmptyExceptionMessageFormat("rules")); + List rules = request.getRules(); + for (SiteAlarmRule rule : rules) { + if (CollectionUtils.isEmpty(rule.getActOnIdcs()) && CollectionUtils.isEmpty(rule.getActOnIsps())) { + checkStringNotEmpty(null, checkEmptyExceptionMessageFormat("idc or isp")); + } + } + String url = String.format(SITE_CREATE_ALARM_CONFIG_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 更新站点监控报警策略 + * + * @param request + */ + public void updateSiteAlarmConfig(SiteAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkStringNotEmpty(request.getAliasName(), checkEmptyExceptionMessageFormat("aliasName")); + checkNotNull(request.getLevel(), "level should not be null"); + checkArgument(request.getRules().size() != 0, checkEmptyExceptionMessageFormat("rules")); + List rules = request.getRules(); + for (SiteAlarmRule rule : rules) { + if (CollectionUtils.isEmpty(rule.getActOnIdcs()) && CollectionUtils.isEmpty(rule.getActOnIsps())) { + checkStringNotEmpty(null, checkEmptyExceptionMessageFormat("idc or isp")); + } + } + String url = String.format(SITE_UPDATE_ALARM_CONFIG_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 查询站点报警策略详情 + * + * @param request + * @return SiteAlarmConfigDetailResponse + */ + public SiteAlarmConfigDetailResponse getSiteAlarmConfigDetail(SiteAlarmUserIdRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + String url = String.format(SITE_GET_ALARM_CONFIG_DETAIL_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("alarmName", request.getAlarmName()); + return invokeHttpClient(internalRequest, SiteAlarmConfigDetailResponse.class); + } + + /** + * 查询站点报警策略详情 + * + * @param request + * @return SiteAlarmConfigDetailResponse + */ + public PageResultResponse getSiteAlarmConfigList(SiteAlarmConfigListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + if (request.getPageNo() <= 0) { + throw new IllegalArgumentException("pageNo should not greater 0"); + } + if (request.getPageSize() <= 0) { + throw new IllegalArgumentException("pageSize should not greater 0"); + } + String url = String.format(SITE_GE_TALARM_CONFIG_LIST_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + if (!StringUtils.isEmpty(request.getAliasName())) { + internalRequest.addParameter("aliasName", request.getAliasName()); + } + if (!StringUtils.isEmpty(request.getTaskId())) { + internalRequest.addParameter("taskId", request.getTaskId()); + } + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + internalRequest.addParameter("actionEnabled", String.valueOf(request.isActionEnabled())); + return invokeHttpClient(internalRequest, PageResultResponse.class); + } + + /** + * 屏蔽站点监控报警策略 + * + * @param request + */ + public void blockSiteAlarmConfig(SiteAlarmUserIdRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat("namespace")); + String url = String.format(SITE_ALARM_BLOCK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.POST, url); + internalRequest.addParameter("alarmName", request.getAlarmName()); + internalRequest.addParameter("namespace", request.getNamespace()); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 开启站点监控报警策略 + * + * @param request + */ + public void unblockSiteAlarmConfig(SiteAlarmUserIdRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat("namespace")); + String url = String.format(SITE_ALARM_UNBLOCK_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.POST, url); + internalRequest.addParameter("alarmName", request.getAlarmName()); + internalRequest.addParameter("namespace", request.getNamespace()); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 通过报警策略名获得站点任务信息 + * + * @param request + */ + public SiteInfoResponse getSiteConfigByAlarmName(SiteAlarmUserIdRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + String url = String.format(SITE_GET_TASK_BY_ALARMNAME_PATH, request.getUserId(), request.getAlarmName()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, SiteInfoResponse.class); + } + + /** + * 查询整体/探测点/运营商趋势图 + * + * @param request + */ + public List getSiteMetricSiteData(SiteMetricDataQueryRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getMetricName(), checkEmptyExceptionMessageFormat("metricName")); + checkStringNotEmpty(request.getStartTime(), checkEmptyExceptionMessageFormat("startTime")); + checkStringNotEmpty(request.getEndTime(), checkEmptyExceptionMessageFormat("endTime")); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + checkNotNull(request.getStatistics(), checkEmptyExceptionMessageFormat("statistics")); + if (request.getCycle() <= 0) { + throw new IllegalArgumentException("cycle should not greater 0"); + } + String url = String.format(SITE_GET_METRIC_DATA_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("metricName", request.getMetricName()); + internalRequest.addParameter("taskId", request.getTaskId()); + internalRequest.addParameter("statistics", StringUtils.join(request.getStatistics(), ",")); + internalRequest.addParameter("startTime", request.getStartTime()); + internalRequest.addParameter("endTime", request.getEndTime()); + internalRequest.addParameter("cycle", String.valueOf(request.getCycle())); + if (!StringUtils.isEmpty(request.getDimensions())) { + internalRequest.addParameter("dimensions", request.getDimensions()); + } + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * 查询整体视图 + * + * @param request + * @return List + */ + public List getSiteOverallView(SiteTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + String url = String.format(SITE_GET_OVERALL_VIEW_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * 查询分省视图 + * + * @param request + * @return List + */ + public List getSiteProvincialView(SiteTaskIspRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTaskId(), checkEmptyExceptionMessageFormat("taskId")); + checkStringNotEmpty(request.getIsp(), checkEmptyExceptionMessageFormat("isp")); + String url = String.format(SITE_GET_PROVINCIAL_VIEW_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + internalRequest.addParameter("isp", request.getIsp()); + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * 查询所有探测点 + * + * @param request + * @return Set + */ + public List getSiteAgentList(SiteAgentRequest request) { + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + String url = String.format(SITE_AGENT_LIST_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * 查询所有探测点 + * + * @param request + * @return List + */ + public IdcIspResponse getSiteAgentListByTaskId(SiteTaskRequest request) { + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + String url = String.format(SITE_GET_AGENT_BY_TASKID_PATH, request.getUserId()); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, url); + internalRequest.addParameter("taskId", request.getTaskId()); + return invokeHttpClient(internalRequest, IdcIspResponse.class); + } + + /** + * 创建自定义报警策略 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public void createCustomAlarmConfig(CustomAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkIsTrue(request.getActionEnabled() != null, "actionEnabled should not be null"); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat("namespace")); + checkIsTrue(request.getLevel() != null, "level should not be null"); + checkIsTrue(request.getRules() != null, "rules should not be null"); + for (CustomAlarmRule rule : request.getRules()) { + checkCustomAlarmRule(rule); + } + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/custom/alarm/configs/create"); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + private void checkCustomAlarmRule(CustomAlarmRule rule) { + checkStringNotEmpty(rule.getMetricName(), checkEmptyExceptionMessageFormat("metricName")); + checkIsTrue(rule.getCycle() > 0, "cycle need large 0"); + checkStringNotEmpty(rule.getStatistics(), checkEmptyExceptionMessageFormat("statistics")); + checkStringNotEmpty(rule.getComparisonOperator(), checkEmptyExceptionMessageFormat("comparisonOperator")); + checkStringNotEmpty(rule.getFunction(), checkEmptyExceptionMessageFormat("comparisonOperator")); + checkIsTrue(rule.getFunction() == "THRESHOLD", "function should be THRESHOLD"); + } + + /** + * 删除自定义报警策略 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public void deleteCustomAlarmConfig(AlarmPolicyBatchListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getCustomAlarmList(), "customAlarmList should not be null"); + for (AlarmPolicyBatch config : request.getCustomAlarmList()) { + checkStringNotEmpty(config.getUserId(), checkEmptyExceptionMessageFormat(USER_ID)); + checkStringNotEmpty(config.getScope(), checkEmptyExceptionMessageFormat(SCOPE_MESSAGE_KEY)); + checkIsTrue(config.getAlarmName() != null, "alarmName should not be null"); + } + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/custom/alarm/configs/delete"); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 更新自定义报警策略 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public void updateCustomAlarmConfig(CustomAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + checkIsTrue(request.getActionEnabled() != null, "actionEnabled should not be null"); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat("namespace")); + checkIsTrue(request.getLevel() != null, "level should not be null"); + checkIsTrue(request.getRules() != null, "rules should not be null"); + for (CustomAlarmRule rule : request.getRules()) { + checkCustomAlarmRule(rule); + } + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, + "/csm/api/v1/custom/alarm/configs/update"); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 搜索自定义报警策略 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public ListCustomConfigResponse listCustomAlarmConfig(ListCustomAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat(USER_ID)); + if (request.getPageNo() == 0) { + request.setPageNo(1); + } + if (request.getPageSize() == 0) { + request.setPageSize(10); + } + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + "/csm/api/v1/custom/alarm/configs/list"); + Map params = new HashMap(); + params.put("userId", request.getUserId()); + if (null != request.getAlarmName()) { + params.put("alarmName", request.getAlarmName()); + } + if (null != request.getNamespace()) { + params.put("namespace", request.getNamespace()); + } + params.put("pageNo", String.valueOf(request.getPageNo())); + params.put("pageSize", String.valueOf(request.getPageSize())); + if (null != request.getActionEnabled()) { + params.put("actionEnabled", String.valueOf(request.getActionEnabled())); + } + internalRequest.setParameters(params); + return invokeHttpClient(internalRequest, ListCustomConfigResponse.class); + } + + /** + * 查看自定义报警策略 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public CustomAlarmConfigResponse detailCustomAlarmConfig(DetailCustomAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat("userId")); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat("namespace")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, + "/csm/api/v1/custom/alarm/configs/detail"); + Map params = new HashMap(); + params.put("userId", request.getUserId()); + params.put("alarmName", request.getAlarmName()); + params.put("namespace", request.getNamespace()); + internalRequest.setParameters(params); + ; + return invokeHttpClient(internalRequest, CustomAlarmConfigResponse.class); + } + + /** + * 关闭自定义报警策略 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public void blockCustomAlarmConfig(DetailCustomAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat("userId")); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat("namespace")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/custom/alarm/configs/block"); + Map params = new HashMap(); + params.put("userId", request.getUserId()); + params.put("alarmName", request.getAlarmName()); + params.put("namespace", request.getNamespace()); + internalRequest.setParameters(params); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 打开定义报警策略 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public void unblockCustomAlarmConfig(DetailCustomAlarmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat("userId")); + checkStringNotEmpty(request.getAlarmName(), checkEmptyExceptionMessageFormat("alarmName")); + checkStringNotEmpty(request.getNamespace(), checkEmptyExceptionMessageFormat("namespace")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/custom/alarm/configs/unblock"); + Map params = new HashMap(); + params.put("userId", request.getUserId()); + params.put("alarmName", request.getAlarmName()); + params.put("namespace", request.getNamespace()); + internalRequest.setParameters(params); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * 创建探测任务 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public HttpResponseWrapper createSiteOnceTask(String type, SiteOnceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getOnceConfig(), "onceConfig is not null"); + checkIsTrue(checkSiteOnceType(type), "type is wrong, provide HTTP/HTTPS/PING/FTP/TCP/UDP/DNS."); + checkIsTrue(checkSiteOnceType(String.valueOf(request.getProtocolType())), "protocolType is wrong, provide HTTP/HTTPS/PING/FTP/TCP/UDP/DNS."); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat("userId")); + checkStringNotEmpty(request.getAddress(), checkEmptyExceptionMessageFormat("address")); + checkIsTrue(request.getIpType() != null && (request.getIpType().equals("ipv6") || request.getIpType().equals("ipv4")), "ipType is ipv6 or ipv4"); + checkStringNotEmpty(request.getIdc(), checkEmptyExceptionMessageFormat("idc")); + if (request.getTimeout() < 0) { + request.setTimeout(60); + } + String url = String.format("/csm/api/v1/site/once/%s/taskCreate", type); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, HttpResponseWrapper.class); + } + + private boolean checkSiteOnceType(String type) { + if ("HTTP".equals(type) || "HTTPS".equals(type) + || "PING".equals(type) || "FTP".equals(type) + || "TCP".equals(type) || "UDP".equals(type) + || "DNS".equals(type) + ) { + return true; + } + return false; + } + + /** + * 探测历史记录 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public HttpResponseWrapper listSiteOnceHistory(SiteOnceTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (request.getPageNo() <= 0) { + request.setPageNo(1); + } + if (request.getPageSize() <= 0) { + request.setPageSize(10); + } + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/site/once/taskList"); + + return invokeHttpClient(internalRequest, HttpResponseWrapper.class); + } + + /** + * 删除探测记录 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public HttpResponseWrapper deleteSiteOnceRecord(SiteOnceTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat("userId")); + checkStringNotEmpty(request.getSiteId(), checkEmptyExceptionMessageFormat("siteId")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/site/once/taskDelete"); + return invokeHttpClient(internalRequest, HttpResponseWrapper.class); + } + + /** + * 探测任务结果 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public HttpResponseWrapper detailSiteOnceResult(SiteOnceTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat("userId")); + checkStringNotEmpty(request.getSiteId(), checkEmptyExceptionMessageFormat("siteId")); + if (request.getPageNo() <= 0) { + request.setPageNo(1); + } + if (request.getPageSize() <= 0) { + request.setPageSize(10); + } + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/site/once/loadData"); + return invokeHttpClient(internalRequest, HttpResponseWrapper.class); + } + + /** + * 探测详情 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public HttpResponseWrapper detailSiteOnce(SiteOnceTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat("userId")); + if (request.getPageNo() <= 0) { + request.setPageNo(1); + } + if (request.getPageSize() <= 0) { + request.setPageSize(10); + } + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/site/once/groupTask"); + return invokeHttpClient(internalRequest, HttpResponseWrapper.class); + } + + /** + * 重新探测 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public HttpResponseWrapper againExecSiteOnce(SiteOnceTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), checkEmptyExceptionMessageFormat("userId")); + checkStringNotEmpty(request.getSiteId(), checkEmptyExceptionMessageFormat("siteId")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/site/once/createFromTask"); + return invokeHttpClient(internalRequest, HttpResponseWrapper.class); + } + + /** + * 历史探测列表 + * + * @param request 请求参数 + * @return 返回响应结果 + */ + public HttpResponseWrapper listSiteOnceTaskHistory(SiteOnceTaskRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/csm/api/v1/site/once/groupTaskList"); + + return invokeHttpClient(internalRequest, HttpResponseWrapper.class); + } + + + /** + * 获取站点代理 + * + * @param userId 用户ID + * @param ipType IP类型,值为"ipv4"或"ipv6" + * @return 返回响应结果 + */ + public HttpResponseWrapper getSiteAgent(String userId, String ipType) { + checkStringNotEmpty(userId, checkEmptyExceptionMessageFormat("userId")); + checkIsTrue(ipType != null && ("ipv6".equals(ipType) || "ipv4".equals(ipType)), "ipType is ipv6 or ipv4"); + + InternalRequest internalRequest = this.createBodyRequest(new EmptyRequest(), HttpMethodName.GET, + "/csm/api/v1/site/once/siteAgent"); + internalRequest.addParameter("userId", userId); + internalRequest.addParameter("ipType", ipType); + return invokeHttpClient(internalRequest, HttpResponseWrapper.class); + } + + + /** + * create application data + * + * @param request + * @return ApplicationInfoResponse + */ + public ApplicationInfoResponse createApplicationData(ApplicationInfoRequest request) { + // check not null + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "name")); + checkStringNotEmpty(request.getType(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "type")); + checkStringNotEmpty(request.getUserId(), USER_NULL_ERROR_MESSAGE); + String url = String.format(APPLICATION_INFO_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, ApplicationInfoResponse.class); + } + + /** + * get application data + * + * @param userId + * @param request + * @return ApplicationDataListResponse + */ + public ApplicationDataListResponse getApplicationDataList(String userId, ApplicationDataListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(userId, USER_NULL_ERROR_MESSAGE); + String url = String.format(APPLICATION_INFO_PATH, userId); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, ApplicationDataListResponse.class); + } + + /** + * update application data + * + * @param request + * @return ApplicationInfoUpdateResponse + */ + public ApplicationInfoUpdateResponse updateApplicationData(ApplicationInfoUpdateRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), USER_NULL_ERROR_MESSAGE); + checkStringNotEmpty(String.valueOf(request.getId()), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "id")); + checkStringNotEmpty(request.getType(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "type")); + checkStringNotEmpty(request.getName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "name")); + String url = String.format(APPLICATION_INFO_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, ApplicationInfoUpdateResponse.class); + } + + /** + * delete application data + * + * @param userId + * @param request + * @return ApplicationMonitorResponse + */ + public void deleteApplicationData(String userId, ApplicationInfoDetaleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "name")); + checkStringNotEmpty(userId, String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + String url = String.format(APPLICATION_INFO_DELETE_PATH, userId, request.getName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.DELETE, url); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * get application instance list + * + * @param userId + * @param request + * @return ApplicationInstanceListResponse + */ + public ApplicationInstanceListResponse getApplicationInstanceList(String userId, ApplicationInstanceListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(userId, String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userId")); + checkStringNotEmpty(request.getRegion(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "region")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + if (StringUtils.isEmpty(String.valueOf(request.getPageSize())) || StringUtils.isEmpty(String.valueOf(request.getPageNo()))) { + request.setPageSize(10); + request.setPageNo(1); + } + String url = String.format(APPLICATION_INFO_LIST_PATH, userId); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, ApplicationInstanceListResponse.class); + } + + /** + * create application instance + * + * @param request + * @return ApplicationMonitorResponse + */ + public ApplicationMonitorResponse createApplicationInstance(ApplicationInstanceCreateRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getHostList(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "instanceList")); + String url = String.format(APPLICATION_INSTANCE_CREATE_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, ApplicationMonitorResponse.class); + } + + /** + * get application created instance list + * + * @param request + * @return ApplicationInstanceListResponse + */ + public ApplicationInstanceListResponse getApplicationInstanceCreatedList(ApplicationInstanceCreatedListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + String url = String.format(APPLICATION_INSTANCE_CREATED_LIST_PATH, request.getUserId(), request.getAppName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, ApplicationInstanceListResponse.class); + } + + /** + * delete application instance + * + * @param userId + * @param request + * @return ApplicationMonitorResponse + */ + public void deleteApplicationInstance(String userId, ApplicationInstanceDeleteRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(userId, String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userId")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + checkStringNotEmpty(request.getId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "id")); + String url = String.format(APPLICATION_INSTANCE_DELETE_PATH, userId, request.getAppName(), request.getId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.DELETE, url); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * create application instance task + * + * @param userId + * @param request + * @return ApplicationMonitorTaskResponse + */ + public ApplicationMonitorTaskResponse createApplicationInstanceTask(String userId, ApplicationMonitorTaskInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(userId, String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + String url = String.format(APPLICATION_TASK_CREATE_PATH, userId); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, ApplicationMonitorTaskResponse.class); + } + + /** + * get application monitor task detail + * + * @param request + * @return ApplicationMonitorTaskResponse + */ + public ApplicationMonitorTaskResponse getApplicationMonitorTaskDetail(ApplicationMonitorTaskDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + checkStringNotEmpty(request.getTaskName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "taskName")); + String url = String.format(APPLICATION_TASK_DETAIL_PATH, request.getUserId(), request.getAppName(), request.getTaskName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.GET, url); + return invokeHttpClient(internalRequest, ApplicationMonitorTaskResponse.class); + } + + /** + * get application monitor task list + * + * @param request + * @return + */ + public List getApplicationMonitorTaskList(ApplicationMonitorTaskListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + String url = String.format(APPLICATION_TASK_LIST_PATH, request.getUserId(), request.getAppName()); + InternalRequest internalRequest = createRequestWithUrl(request, HttpMethodName.GET, url); + if (null != request.getType() && StringUtils.isNotEmpty(request.getType())) { + internalRequest.addParameter("type", request.getType()); + } + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * update application monitor task + * + * @param userId + * @param request + * @return ApplicationMonitorTaskResponse + */ + public ApplicationMonitorTaskResponse updateApplicationMonitorTask(String userId, ApplicationMonitorTaskInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(userId, String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + checkStringNotEmpty(request.getName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "name")); + checkStringNotEmpty(request.getAliasName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "aliasName")); + checkStringNotEmpty(request.getTarget(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "target")); + if (request.getType() < 0 || request.getType() > 3) { + throw new IllegalArgumentException("type must be in [0,1,2,3]"); + } + String url = String.format(APPLICATION_TASK_UPDATE_PATH, userId); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, ApplicationMonitorTaskResponse.class); + + } + + /** + * delete application monitor task + * + * @param request + * @return ApplicationMonitorResponse + */ + public void deleteApplicationMonitorTask(ApplicationMonitorTaskDeleteRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + checkStringNotEmpty(request.getName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "name")); + String url = String.format(APPLICATION_TASK_DELETE_PATH, request.getUserId(), request.getAppName(), request.getName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.DELETE, url); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + /** + * create application dimension table + * + * @param request + * @return ApplicationDimensionTableInfoResponse + */ + public ApplicationDimensionTableInfoResponse createApplicationDimensionTable(ApplicationDimensionTableInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + checkStringNotEmpty(request.getTableName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "tableName")); + checkStringNotEmpty(request.getMapContentJson(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "mapContentJson")); + String url = String.format(APPLICATION_DIMENSION_TABLE_CREATE_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, ApplicationDimensionTableInfoResponse.class); + } + + /** + * get application dimension table list + * + * @param request + * @return ApplicationDimensionTableListResponse + */ + public List getApplicationDimensionTableList(ApplicationDimensionTableListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + String url = String.format(APPLICATION_DIMENSION_TABLE_LIST_PATH, request.getUserId(), request.getAppName()); + InternalRequest internalRequest = createRequestWithUrl(request, HttpMethodName.GET, url); + if (null != request.getSearchName() && StringUtils.isNotEmpty(request.getSearchName())) { + internalRequest.addParameter("searchName", request.getSearchName()); + } + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * update application dimension table + * + * @param request + * @return ApplicationMonitorResponse + */ + public ApplicationMonitorResponse updateApplicationDimensionTable(ApplicationDimensionTableInfoRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + checkStringNotEmpty(request.getTableName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "tableName")); + checkStringNotEmpty(request.getMapContentJson(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "mapContentJson")); + String url = String.format(APPLICATION_DIMENSION_TABLE_UPDATE_PATH, request.getUserId()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, url); + return invokeHttpClient(internalRequest, ApplicationMonitorResponse.class); + } + + /** + * delete application dimension table + * + * @param request + * @return ApplicationMonitorResponse + */ + public void deleteApplicationDimensionTable(ApplicationDimensionTableDeleteRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getAppName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "appName")); + checkStringNotEmpty(request.getTableName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "tableName")); + String url = String.format(APPLICATION_DIMENSION_TABLE_DELETE_PATH, request.getUserId(), + request.getAppName(), request.getTableName()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.DELETE, url); + invokeHttpClient(internalRequest, EmptyResponse.class); + } + + public MultiDimensionalLatestMetricsResponse getMultiDimensionalLatestMetrics(MultiDimensionalLatestMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getScope(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "scope")); + checkListSizeInRange(request.getDimensions(), MAX_DIMENSIONS_SIZE, "the max size of dimensions is " + MAX_DIMENSIONS_SIZE); + String url = String.format(MULTI_DIMENSIONAL_LATEST_METRICS_PATH, request.getUserId(), request.getScope()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + return invokeHttpClient(internalRequest, MultiDimensionalLatestMetricsResponse.class); + } + + /** + * @Description: + * 根据部分维度获取指标数据,返回包装了 PageResultResponse 的 TsdbMetricResult。 + * 请求参数中的 userID、scope、startTime、endTime、metricName 不能为空字符串, + * 否则将抛出 IllegalArgumentException。 + * 如果 statistics 列表为空,也将抛出 IllegalArgumentException。 + * 维度的最大长度为 MAX_DIMENSIONS_SIZE(默认值为10),超过该限制将抛出 IllegalArgumentException。 + * + * @Param request PartialDimensionsMetricsRequest 请求参数,包含用户ID、范围、开始时间、结束时间、指标名称和统计方式等信息。 + * + * @Return TsdbMetricResult> 返回包装了 PageResultResponse 的 TsdbMetricResult, + * 其中 result 是一个包含 TsdbMetricAllDataResult.AllDataMetric 对象的 PageResultResponse。 + * + * @Throws IllegalArgumentException 当请求参数中的 userID、scope、startTime、endTime、metricName 为空字符串或者 statistics 列表为空时抛出。 + * @Throws IllegalArgumentException 当维度的最大长度超过 MAX_DIMENSIONS_SIZE(默认值为10)时抛出。 + */ + public TsdbMetricResult> getMetricsByPartialDimensions(PartialDimensionsMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getScope(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "scope")); + checkStringNotEmpty(request.getStartTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "startTime")); + checkStringNotEmpty(request.getEndTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "endTime")); + checkStringNotEmpty(request.getMetricName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "metricName")); + if (CollectionUtils.isEmpty(request.getStatistics())) { + throw new IllegalArgumentException("param statistics should not be null"); + } + checkListSizeInRange(request.getDimensions(), MAX_DIMENSIONS_SIZE, "the max size of dimensions is " + MAX_DIMENSIONS_SIZE); + String url = String.format(METRICS_BY_PARTIAL_DIMENSIONS_PATH, request.getUserId(), request.getScope()); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, url); + // 嵌套泛型运行时会丢失类型信息,需要手动转换 + TsdbMetricResult> tsdbMetricResult = + invokeHttpClient(internalRequest, TsdbMetricResult.class); + ObjectMapper objectMapper = new ObjectMapper(); + tsdbMetricResult.setResult(objectMapper.convertValue(tsdbMetricResult.getResult(), + new TypeReference>() { + })); + return tsdbMetricResult; + } + + public TsdbMetricAllDataResult batchGetMetricsAllDataV2(MultiDimensionalMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getScope(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "scope")); + checkStringNotEmpty(request.getRegion(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "region")); + checkStringNotEmpty(request.getStartTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "startTime")); + checkStringNotEmpty(request.getEndTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "endTime")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getMetricNames()), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "metricNames")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getStatistics()), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "statistics")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getDimensions()), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "dimensions")); + checkListSizeInRange(request.getDimensions(), MAX_DIMENSIONS_SIZE, "the max size of dimensions is " + MAX_DIMENSIONS_SIZE); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, BATCH_GET_METRICS_PATH); + return invokeHttpClient(internalRequest, TsdbMetricAllDataResult.class); + } + + public TsdbMetricAllDataResult getAllDataMetricV2(MultiDimensionalMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getScope(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "scope")); + checkStringNotEmpty(request.getRegion(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "region")); + checkStringNotEmpty(request.getStartTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "startTime")); + checkStringNotEmpty(request.getEndTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "endTime")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getMetricNames()), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "metricNames")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getStatistics()), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "statistics")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getDimensions()), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "dimensions")); + checkListSizeInRange(request.getDimensions(), MAX_DIMENSIONS_SIZE, "the max size of dimensions is " + MAX_DIMENSIONS_SIZE); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, ALL_DATA_METRIC_V2_PATH); + return invokeHttpClient(internalRequest, TsdbMetricAllDataResult.class); + } + + public TsdbDimensionTopResult getMetricDimensionTop(TsdbDimensionTopQuery request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getScope(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "scope")); + checkStringNotEmpty(request.getRegion(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "region")); + checkStringNotEmpty(request.getStartTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "startTime")); + checkStringNotEmpty(request.getEndTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "endTime")); + checkStringNotEmpty(request.getMetricName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "metricName")); + checkIsTrue(request.getDimensions().size() > 0, String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "dimensions")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getLabels()), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "labels")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, TOPN_PATH); + return invokeHttpClient(internalRequest, TsdbDimensionTopResult.class); + } + + public List getMetricDimensionTopData(TsdbDimensionTopQuery request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getScope(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "scope")); + checkStringNotEmpty(request.getRegion(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "region")); + checkStringNotEmpty(request.getStartTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "startTime")); + checkStringNotEmpty(request.getEndTime(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "endTime")); + checkStringNotEmpty(request.getMetricName(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "metricName")); + checkIsTrue(request.getDimensions().size() > 0, String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "dimensions")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getLabels()), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "labels")); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, TOPN_DATA_PATH); + return invokeHttpClient(internalRequest, ListResponse.class).getResult(); + } + + /** + * @Description: 获取报警列表,包含用户ID、报警类型、分页信息等参数。返回值为AlarmListResponse对象。 + * @param request AlarmListRequest对象,包含用户ID、报警类型、分页信息等参数。不能为空。 + * @return AlarmListResponse AlarmListResponse对象,包含报警列表和分页信息等。 + * @throws IllegalArgumentException 当request中的userId或alarmType为空字符串时抛出此异常。 + * @throws RuntimeException 当pageNo小于等于0或pageSize小于等于0时抛出RuntimeException。 + */ + public AlarmListResponse getAlarmList(AlarmListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userID")); + checkStringNotEmpty(request.getAlarmType(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "alarmType")); + if (request.getPageNo() <= 0) { + request.setPageNo(1); + } + if (request.getPageSize() <= 0) { + request.setPageSize(10); + } + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, ALARM_HOUSE_ALARM_LIST); + return invokeHttpClient(internalRequest, AlarmListResponse.class); + } + + /** + * {@literal} + * 获取报警详情信息 + * + * @param request AlarmDetailRequest类型,包含alarmId(必传)和userId(必传)两个参数 + * @return AlarmDetailResponse类型,包含报警详情信息 + * @throws BceClientException 请求参数为空或者不符合要求时抛出此异常 + */ + public AlarmDetailResponse getAlarmDetail(AlarmDetailRequest request) { + checkStringNotEmpty(request.getAlarmId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "alarmId")); + checkStringNotEmpty(request.getUserId(), String.format(REQUEST_PARAM_NULL_ERROR_MESSAGE, "userId")); + InternalRequest internalRequest = + this.createRequestWithUrl(request, HttpMethodName.GET, ALARM_HOUSE_ALARM_DETAIL); + + internalRequest.addParameter("alarmId", request.getAlarmId()); + internalRequest.addParameter("userId", request.getUserId()); + return invokeHttpClient(internalRequest, AlarmDetailResponse.class); + } + + + +} diff --git a/src/main/java/com/baidubce/services/bcm/BcmClientConfiguration.java b/src/main/java/com/baidubce/services/bcm/BcmClientConfiguration.java new file mode 100644 index 00000000..c7b0cda8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/BcmClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bcm; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for bcm service. + */ +public class BcmClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/bcm/MultiDimensionalLatestMetricsRequest.java b/src/main/java/com/baidubce/services/bcm/MultiDimensionalLatestMetricsRequest.java new file mode 100644 index 00000000..96b5691d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/MultiDimensionalLatestMetricsRequest.java @@ -0,0 +1,50 @@ +package com.baidubce.services.bcm; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcm.model.Dimension; +import com.fasterxml.jackson.annotation.JsonAlias; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +/** + * @author gongjiaming + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MultiDimensionalLatestMetricsRequest extends AbstractBceRequest { + @NotNull + private String userId; + @NotNull + private String scope; + + private String region; + + /* 子类型 */ + @JsonAlias(value = {"typename", "resourceType", "type"}) + private String typename; + + private List metricNames; + + private List statistics; + + private List dimensions = new ArrayList(); + + private String timestamp; + + private int cycle = 60; + + @Override + public MultiDimensionalLatestMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/MultiDimensionalLatestMetricsResponse.java b/src/main/java/com/baidubce/services/bcm/MultiDimensionalLatestMetricsResponse.java new file mode 100644 index 00000000..6cb9714a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/MultiDimensionalLatestMetricsResponse.java @@ -0,0 +1,48 @@ +package com.baidubce.services.bcm; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.DataPoint; +import com.baidubce.services.bcm.model.Dimension; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author gongjiaming + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class MultiDimensionalLatestMetricsResponse extends AbstractBceResponse { + + private String requestId; + + private String code; + + private String message; + + private List metrics; + + + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class DataMetric { + + private String region; + + private String scope; + + private String userId; + + private String resourceId; + + private String metricName; + /** 维度信息 */ + private List dimensions; + /** 数据点,按照时间顺序排列的 */ + private List dataPoints; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/handler/BcmJsonResponseHandler.java b/src/main/java/com/baidubce/services/bcm/handler/BcmJsonResponseHandler.java new file mode 100644 index 00000000..6d2d518a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/handler/BcmJsonResponseHandler.java @@ -0,0 +1,104 @@ +package com.baidubce.services.bcm.handler; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.EmptyResponse; +import com.baidubce.services.bcm.model.ListResponse; +import com.baidubce.services.bcm.model.MapListResponse; +import com.baidubce.services.bcm.model.application.ApplicationMonitorResponse; +import com.baidubce.services.bcm.model.custom.CustomMonitorResponse; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * HTTP body json response handler for Baidu BCM responses. + * + * @Author: wanglu51 + * @Date: 2023/12/7 10:42 + */ +public class BcmJsonResponseHandler extends BceJsonResponseHandler { + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + static { + OBJECT_MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + OBJECT_MAPPER.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); + } + + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + // 在定义监控中,成功的返回没有body,不需要反序列化,否则报错 + if (response instanceof CustomMonitorResponse) { + CustomMonitorResponse customMonitorResponse = (CustomMonitorResponse) response; + customMonitorResponse.setCode("OK"); + customMonitorResponse.setMessage(""); + if (null != response.getMetadata()) { + customMonitorResponse.setRequestId(response.getMetadata().getBceRequestId()); + } + + // 如果为空,可以支持重复读,从而不会由于空流导致报错 + ByteArrayOutputStream bos = toByteArrayOutputStream(httpResponse.getContent()); + if (bos.size() > 0) { + OBJECT_MAPPER.readerForUpdating(customMonitorResponse).readValue(bos.toByteArray()); + } + return true; + } + // 某些response返回序列化需要特殊处理 + if (response instanceof EmptyResponse || response instanceof ListResponse + || response instanceof MapListResponse) { + InputStream content = httpResponse.getContent(); + if (content != null) { + if (response.getMetadata().getContentLength() > 0 + || "chunked".equalsIgnoreCase(response.getMetadata().getTransferEncoding())) { + if (response instanceof ListResponse) { + JsonUtils.load(content, ((ListResponse) response).getResult()); + } else if (response instanceof MapListResponse) { + JsonUtils.load(content, ((MapListResponse) response).getResult()); + } + } + content.close(); + } + return true; + } + + if (response instanceof ApplicationMonitorResponse) { + ApplicationMonitorResponse applicationMonitorResponse = (ApplicationMonitorResponse) response; + applicationMonitorResponse.setCode("OK"); + applicationMonitorResponse.setMessage(""); + if (null != response.getMetadata()) { + applicationMonitorResponse.setRequestId(response.getMetadata().getBceRequestId()); + } + ByteArrayOutputStream bos = toByteArrayOutputStream(httpResponse.getContent()); + if (bos.size() > 0) { + OBJECT_MAPPER.readerForUpdating(applicationMonitorResponse).readValue(bos.toByteArray()); + } + return true; + } + + return super.handle(httpResponse, response); + } + + /** + * 转换为字节数组流 + */ + private static ByteArrayOutputStream toByteArrayOutputStream(InputStream input) throws IOException { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len; + while ((len = input.read(buffer)) > -1) { + bos.write(buffer, 0, len); + } + bos.flush(); + input.close(); + return bos; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/BaseMetricDataRequest.java b/src/main/java/com/baidubce/services/bcm/model/BaseMetricDataRequest.java new file mode 100644 index 00000000..683e0510 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/BaseMetricDataRequest.java @@ -0,0 +1,94 @@ +package com.baidubce.services.bcm.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Base Metric Data Request + */ +public abstract class BaseMetricDataRequest extends AbstractBceRequest { + + /** + * 主账号id + */ + public String userId; + + /** + * 仅限于使用如下字符集合:"0~9、A~Z、a~z"、 "_" + */ + public String scope; + + /** + * Statistics + */ + public Statistics[] statistics; + + /** + * DateTime,请参考日期与时间,UTC日期表示 + */ + public String startTime; + + /** + * DateTime,请参考日期与时间,UTC日期表示 + */ + public String endTime; + + /** + * Integer,60的倍数,单位:秒(s) + */ + public Integer periodInSecond; + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public Statistics[] getStatistics() { + return statistics; + } + + public void setStatistics(Statistics[] statistics) { + this.statistics = statistics; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public Integer getPeriodInSecond() { + return periodInSecond; + } + + public void setPeriodInSecond(Integer periodInSecond) { + this.periodInSecond = periodInSecond; + } + + @Override + public BaseMetricDataRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/CommonKV.java b/src/main/java/com/baidubce/services/bcm/model/CommonKV.java new file mode 100644 index 00000000..6bb7dca9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/CommonKV.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CommonKV { + private String key; + private String value; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/DataPoint.java b/src/main/java/com/baidubce/services/bcm/model/DataPoint.java new file mode 100644 index 00000000..fee8d055 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/DataPoint.java @@ -0,0 +1,79 @@ +package com.baidubce.services.bcm.model; + +/** + * the metric data + */ +public class DataPoint { + + public Double average; + + public Double sum; + + public Double maximum; + + public Double minimum; + + public Integer sampleCount; + + public Double value; + + /** + * DateTime,请参考日期与时间,UTC日期表示 + */ + public String timestamp; + + public Double getAverage() { + return average; + } + + public void setAverage(Double average) { + this.average = average; + } + + public Double getSum() { + return sum; + } + + public void setSum(Double sum) { + this.sum = sum; + } + + public Double getMaximum() { + return maximum; + } + + public void setMaximum(Double maximum) { + this.maximum = maximum; + } + + public Double getMinimum() { + return minimum; + } + + public void setMinimum(Double minimum) { + this.minimum = minimum; + } + + public Integer getSampleCount() { + return sampleCount; + } + + public void setSampleCount(Integer sampleCount) { + this.sampleCount = sampleCount; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public Double getValue(){ + return value; + } + public void setValue(Double value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/Dimension.java b/src/main/java/com/baidubce/services/bcm/model/Dimension.java new file mode 100644 index 00000000..ea33409d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/Dimension.java @@ -0,0 +1,43 @@ +package com.baidubce.services.bcm.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * the dimension for metric. + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Dimension { + + private String name; + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public Dimension withName(String name) { + this.name = name; + return this; + } + + public Dimension withValue(String value) { + this.value = value; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/EmptyResponse.java b/src/main/java/com/baidubce/services/bcm/model/EmptyResponse.java new file mode 100644 index 00000000..48454ae6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/EmptyResponse.java @@ -0,0 +1,8 @@ +package com.baidubce.services.bcm.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class EmptyResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/ErrorMetricData.java b/src/main/java/com/baidubce/services/bcm/model/ErrorMetricData.java new file mode 100644 index 00000000..83c8bc86 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/ErrorMetricData.java @@ -0,0 +1,39 @@ +package com.baidubce.services.bcm.model; + +import java.util.List; + +/** + * Error Metric Data + */ +public class ErrorMetricData { + + String metricName; + + List dimensions; + + private String message = ""; + + public String getMetricName() { + return metricName; + } + + public void setMetricName(String metricName) { + this.metricName = metricName; + } + + public List getDimensions() { + return dimensions; + } + + public void setDimensions(List dimensions) { + this.dimensions = dimensions; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/ListMetricDataRequest.java b/src/main/java/com/baidubce/services/bcm/model/ListMetricDataRequest.java new file mode 100644 index 00000000..4d1b3749 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/ListMetricDataRequest.java @@ -0,0 +1,83 @@ +package com.baidubce.services.bcm.model; + +import com.baidubce.auth.BceCredentials; + +/** + * The request for query metric data. + */ +public class ListMetricDataRequest extends BaseMetricDataRequest { + + /** + * 仅限于使用如下字符集合:"0~9、A~Z、a~z"、 "_" + */ + private String[] metricNames; + + /** + * 由dimensionName:dimensionValue组成 + * 当监控项具备多个维度时使用分号连接, 如: k1:v1;k2:v2 + * 相同维度只能指定一个维度值 + */ + private String dimensions; + + public String[] getMetricNames() { + return metricNames; + } + + public void setMetricNames(String[] metricNames) { + this.metricNames = metricNames; + } + + public String getDimensions() { + return dimensions; + } + + public void setDimensions(String dimensions) { + this.dimensions = dimensions; + } + + public ListMetricDataRequest withUserId(String userId) { + this.userId = userId; + return this; + } + + public ListMetricDataRequest withScope(String scope) { + this.scope = scope; + return this; + } + + public ListMetricDataRequest withMetricNames(String[] metricNames) { + this.metricNames = metricNames; + return this; + } + + public ListMetricDataRequest withDimensions(String dimensions) { + this.dimensions = dimensions; + return this; + } + + public ListMetricDataRequest withStatistics(Statistics[] statistics) { + this.statistics = statistics; + return this; + } + + public ListMetricDataRequest withPeriodInSecond(Integer periodInSecond) { + this.periodInSecond = periodInSecond; + return this; + } + + public ListMetricDataRequest withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + public ListMetricDataRequest withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + @Override + public ListMetricDataRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/ListMetricDataResponse.java b/src/main/java/com/baidubce/services/bcm/model/ListMetricDataResponse.java new file mode 100644 index 00000000..8f8b95b8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/ListMetricDataResponse.java @@ -0,0 +1,62 @@ +package com.baidubce.services.bcm.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * List of Metric Data + */ +public class ListMetricDataResponse extends AbstractBceResponse { + + private String requestId; + + private String code = ""; + + private String message = ""; + + List errorList; + + List successList; + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public List getErrorList() { + return errorList; + } + + public void setErrorList(List errorList) { + this.errorList = errorList; + } + + public List getSuccessList() { + return successList; + } + + public void setSuccessList(List successList) { + this.successList = successList; + } + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/ListResponse.java b/src/main/java/com/baidubce/services/bcm/model/ListResponse.java new file mode 100644 index 00000000..61e88eba --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/ListResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcm.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class ListResponse extends AbstractBceResponse { + private List result = new ArrayList(); +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/MapListResponse.java b/src/main/java/com/baidubce/services/bcm/model/MapListResponse.java new file mode 100644 index 00000000..00651bb0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/MapListResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Data +public class MapListResponse extends AbstractBceResponse { + Map> result = new HashMap>(); +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/MetricDataRequest.java b/src/main/java/com/baidubce/services/bcm/model/MetricDataRequest.java new file mode 100644 index 00000000..1e6eeff8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/MetricDataRequest.java @@ -0,0 +1,83 @@ +package com.baidubce.services.bcm.model; + +import com.baidubce.auth.BceCredentials; + +/** + * The request for query metric data. + */ +public class MetricDataRequest extends BaseMetricDataRequest { + + /** + * 仅限于使用如下字符集合:"0~9、A~Z、a~z"、 "_" + */ + private String metricName; + + /** + * 由dimensionName:dimensionValue组成 + * 当监控项具备多个维度时使用分号连接, 如: k1:v1;k2:v2 + * 相同维度只能指定一个维度值 + */ + private String dimensions; + + public String getMetricName() { + return metricName; + } + + public void setMetricName(String metricName) { + this.metricName = metricName; + } + + public String getDimensions() { + return dimensions; + } + + public void setDimensions(String dimensions) { + this.dimensions = dimensions; + } + + public MetricDataRequest withUserId(String userId) { + super.userId = userId; + return this; + } + + public MetricDataRequest withScope(String scope) { + this.scope = scope; + return this; + } + + public MetricDataRequest withMetricName(String metricName) { + this.metricName = metricName; + return this; + } + + public MetricDataRequest withDimensions(String dimensions) { + this.dimensions = dimensions; + return this; + } + + public MetricDataRequest withStatistics(Statistics[] statistics) { + this.statistics = statistics; + return this; + } + + public MetricDataRequest withPeriodInSecond(Integer periodInSecond) { + this.periodInSecond = periodInSecond; + return this; + } + + public MetricDataRequest withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + public MetricDataRequest withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + @Override + public MetricDataRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/MetricDataResponse.java b/src/main/java/com/baidubce/services/bcm/model/MetricDataResponse.java new file mode 100644 index 00000000..3fb0b33e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/MetricDataResponse.java @@ -0,0 +1,51 @@ +package com.baidubce.services.bcm.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for query metric data. + */ +public class MetricDataResponse extends AbstractBceResponse { + + private String requestId = ""; + + private String code = ""; + + private String message = ""; + + List dataPoints; + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public List getDataPoints() { + return dataPoints; + } + + public void setDataPoints(List dataPoints) { + this.dataPoints = dataPoints; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/Page.java b/src/main/java/com/baidubce/services/bcm/model/Page.java new file mode 100644 index 00000000..7a82a148 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/Page.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model; + + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class Page extends AbstractBceResponse { + private String orderBy; + + private String order; + + private Integer pageNo; + + private Integer pageSize; + + private Integer totalCount; + + private List result; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/PushCustomMetricDataRequest.java b/src/main/java/com/baidubce/services/bcm/model/PushCustomMetricDataRequest.java new file mode 100644 index 00000000..99f7a7fe --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/PushCustomMetricDataRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.bcm.model; + + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * push custom metric data request + * + * @Author: wanglu51 + * @Date: 2023/6/12 10:24 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PushCustomMetricDataRequest extends AbstractBceRequest { + @JsonIgnore + private String userId; + private String namespace; + private String metricName; + private List dimensions; + private Double value; + private StatisticValue statisticValues; + private String timestamp; + + @Override + public PushCustomMetricDataRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/PushMetricDataResponse.java b/src/main/java/com/baidubce/services/bcm/model/PushMetricDataResponse.java new file mode 100644 index 00000000..7b919572 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/PushMetricDataResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * push metric data response + * + * @Author: wanglu51 + * @Date: 2023/6/12 10:24 + */ +@Data +public class PushMetricDataResponse extends AbstractBceResponse { + private String requestId; + private String message; + private Boolean success; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/StatisticValue.java b/src/main/java/com/baidubce/services/bcm/model/StatisticValue.java new file mode 100644 index 00000000..9894be9c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/StatisticValue.java @@ -0,0 +1,25 @@ +package com.baidubce.services.bcm.model; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * statistic value object + * + * @Author: wanglu51 + * @Date: 2023/6/12 10:24 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class StatisticValue { + private double maximum; + private double minimum; + private double average; + private Integer sampleCount; + private Double sum; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/Statistics.java b/src/main/java/com/baidubce/services/bcm/model/Statistics.java new file mode 100644 index 00000000..41cc74ec --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/Statistics.java @@ -0,0 +1,8 @@ +package com.baidubce.services.bcm.model; + +/** + * the Statistics for metric data. + */ +public enum Statistics { + average, maximum, minimum, sum, sampleCount; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/SuccessMetricData.java b/src/main/java/com/baidubce/services/bcm/model/SuccessMetricData.java new file mode 100644 index 00000000..1ad3f766 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/SuccessMetricData.java @@ -0,0 +1,39 @@ +package com.baidubce.services.bcm.model; + +import java.util.List; + +/** + * Success Metric Data + */ +public class SuccessMetricData { + + String metricName; + + List dimensions; + + List dataPoints; + + public String getMetricName() { + return metricName; + } + + public void setMetricName(String metricName) { + this.metricName = metricName; + } + + public List getDimensions() { + return dimensions; + } + + public void setDimensions(List dimensions) { + this.dimensions = dimensions; + } + + public List getDataPoints() { + return dataPoints; + } + + public void setDataPoints(List dataPoints) { + this.dataPoints = dataPoints; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/action/Action.java b/src/main/java/com/baidubce/services/bcm/model/action/Action.java new file mode 100644 index 00000000..f8bd736a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/Action.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.action; + +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Data +public class Action { + private String productName; + private String name; + private String alias; + private String source = "USER"; + private String type; + private List disableTimes ; + private List notifications; + private List actionCallBacks ; + private List members; + private List userInfos; + private Map> groupInfos; + private Date lastModifiedDate; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/ActionCallBack.java b/src/main/java/com/baidubce/services/bcm/model/action/ActionCallBack.java new file mode 100644 index 00000000..80c4a713 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/ActionCallBack.java @@ -0,0 +1,8 @@ +package com.baidubce.services.bcm.model.action; + +import lombok.Data; + +@Data +public class ActionCallBack { + private String url; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/ActionDisableTime.java b/src/main/java/com/baidubce/services/bcm/model/action/ActionDisableTime.java new file mode 100644 index 00000000..04f0e186 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/ActionDisableTime.java @@ -0,0 +1,11 @@ +package com.baidubce.services.bcm.model.action; + +import lombok.Data; + +import java.sql.Time; + +@Data +public class ActionDisableTime { + private Time from; + private Time to; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/ActionNotification.java b/src/main/java/com/baidubce/services/bcm/model/action/ActionNotification.java new file mode 100644 index 00000000..71e41575 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/ActionNotification.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.action; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ActionNotification { + private String receiver; + private String type; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/ActionUserInfo.java b/src/main/java/com/baidubce/services/bcm/model/action/ActionUserInfo.java new file mode 100644 index 00000000..bc175601 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/ActionUserInfo.java @@ -0,0 +1,11 @@ +package com.baidubce.services.bcm.model.action; + +import lombok.Data; + +@Data +public class ActionUserInfo { + private String name; + private String email; + private String phone; + private String type; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/CreateAndUpdateActionRequest.java b/src/main/java/com/baidubce/services/bcm/model/action/CreateAndUpdateActionRequest.java new file mode 100644 index 00000000..faa534b6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/CreateAndUpdateActionRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.action; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Data +public class CreateAndUpdateActionRequest extends AbstractBceRequest{ + private String userId; + private String productName; + private String alias; + private String source = "USER"; + private String type; + private List disableTimes = new ArrayList(); + private List notifications; + private List actionCallBacks = new ArrayList(); + private List members; + private Date lastModifiedDate; + private String name; + private List userInfos; + private Map> groupInfos; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/DeleteActionRequest.java b/src/main/java/com/baidubce/services/bcm/model/action/DeleteActionRequest.java new file mode 100644 index 00000000..fef2d3bb --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/DeleteActionRequest.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.action; + + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class DeleteActionRequest extends AbstractBceRequest { + private String userId; + private String name; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/ListActionsRequest.java b/src/main/java/com/baidubce/services/bcm/model/action/ListActionsRequest.java new file mode 100644 index 00000000..6c05190c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/ListActionsRequest.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bcm.model.action; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + + +@Data +public class ListActionsRequest extends AbstractBceRequest { + private String userId; + private String name; + private String order; + private String orderBy; + private int pageNo; + private int pageSize; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/ListActionsResponse.java b/src/main/java/com/baidubce/services/bcm/model/action/ListActionsResponse.java new file mode 100644 index 00000000..218246d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/ListActionsResponse.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.action; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.Page; +import lombok.Data; + +@Data +public class ListActionsResponse extends AbstractBceResponse { + private String requestId; + private String message; + private boolean success; + private int code; + private Page result; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/ListNotifyGroupsResponse.java b/src/main/java/com/baidubce/services/bcm/model/action/ListNotifyGroupsResponse.java new file mode 100644 index 00000000..1e98816d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/ListNotifyGroupsResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcm.model.action; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.Page; +import lombok.Data; + +@Data +public class ListNotifyGroupsResponse extends AbstractBceResponse { + private Boolean success; + private Integer status; + private Page page; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/ListNotifyPartiesResponse.java b/src/main/java/com/baidubce/services/bcm/model/action/ListNotifyPartiesResponse.java new file mode 100644 index 00000000..5a1e8403 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/ListNotifyPartiesResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcm.model.action; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.Page; +import lombok.Data; + +@Data +public class ListNotifyPartiesResponse extends AbstractBceResponse { + private Boolean success; + private Integer status; + private Page page; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/Member.java b/src/main/java/com/baidubce/services/bcm/model/action/Member.java new file mode 100644 index 00000000..3104d7cf --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/Member.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.action; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Member { + private String type; + private String id; + private String name = ""; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/NotifyGroup.java b/src/main/java/com/baidubce/services/bcm/model/action/NotifyGroup.java new file mode 100644 index 00000000..bba6d76c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/NotifyGroup.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.action; + +import lombok.Data; + +@Data +public class NotifyGroup { + private String id; + + private String domainId; + + private String name; + + private String description; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/NotifyParty.java b/src/main/java/com/baidubce/services/bcm/model/action/NotifyParty.java new file mode 100644 index 00000000..de9a8c5e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/NotifyParty.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.action; + +import lombok.Data; + +@Data +public class NotifyParty { + private String id; + + private String domainId; + + private String name; + + private String email; + + private String phone; + + private String type; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/action/NotifyRequest.java b/src/main/java/com/baidubce/services/bcm/model/action/NotifyRequest.java new file mode 100644 index 00000000..f0407f6f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/action/NotifyRequest.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.action; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class NotifyRequest extends AbstractBceRequest { + private String name; + private int pageNo; + private int pageSize; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/ACAlarmType.java b/src/main/java/com/baidubce/services/bcm/model/alarm/ACAlarmType.java new file mode 100644 index 00000000..4153a60a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/ACAlarmType.java @@ -0,0 +1,11 @@ +package com.baidubce.services.bcm.model.alarm; + +public enum ACAlarmType { + INSTANCE, + APP, + SERVICE, + SITE, + HOST, + DOMAIN; + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfig.java b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfig.java new file mode 100644 index 00000000..0c9bc621 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfig.java @@ -0,0 +1,36 @@ +package com.baidubce.services.bcm.model.alarm; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Set; + +@Data +@NoArgsConstructor +public class AlarmConfig extends AbstractBceResponse { + private String alarmDescription; + private String alarmName; + private String aliasName; + private String userId; + private String scope; + private String region; + private AlarmLevel level; + private MonitorObject monitorObject; + private Set alarmActions; + private Set okActions; + private Set insufficientActions; + private String srcName; + private String srcType; + private AlarmType type = AlarmType.NORMAL; + private List eventTypeList; + private int insufficientCycle; + private int maxRepeatCount; + private int repeatAlarmCycle; + private String callbackUrl = ""; + private String callbackToken = ""; + private List> rules; +} + + diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigActionV2.java b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigActionV2.java new file mode 100644 index 00000000..e57092e1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigActionV2.java @@ -0,0 +1,11 @@ +package com.baidubce.services.bcm.model.alarm; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class AlarmConfigActionV2 { + private String name; + private String id; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigPolicyRuleV2.java b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigPolicyRuleV2.java new file mode 100644 index 00000000..e086dd6c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigPolicyRuleV2.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.alarm; + +import com.baidubce.services.bcm.model.CommonKV; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +public class AlarmConfigPolicyRuleV2 { + private String metricName; + private List metricDimensions; + private String operator; + private String statistics; + private double threshold; + private int window = 60; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigPolicyV2.java b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigPolicyV2.java new file mode 100644 index 00000000..de34368c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigPolicyV2.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.alarm; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +public class AlarmConfigPolicyV2 { + private List rules; + private int alarmPendingPeriodCount; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigV2.java b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigV2.java new file mode 100644 index 00000000..5aef6e87 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmConfigV2.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bcm.model.alarm; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.CommonKV; +import lombok.Data; + +import java.util.List; + +@Data +public class AlarmConfigV2 extends AbstractBceResponse { + private String userId; + private String aliasName; + private String alarmName; + private String scope; + private String region; + private TargetType targetType; + private String resourceType = "Instance"; + private AlarmLevel alarmLevel = AlarmLevel.CRITICAL; + private List targetInstanceGroups; + private List targetInstanceTags; + private String callbackUrl; + private String callbackToken; + private int insufficientDataPendingPeriod; + private int alarmRepeatInterval; + private int alarmRepeatCount; + + private List policies; + private List targetInstances; + private List actions; + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmLevel.java b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmLevel.java new file mode 100644 index 00000000..730617d6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmLevel.java @@ -0,0 +1,5 @@ +package com.baidubce.services.bcm.model.alarm; + +public enum AlarmLevel { + NOTICE, WARNING, CRITICAL, MAJOR, CUSTOM +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmMetric.java b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmMetric.java new file mode 100644 index 00000000..a499a533 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmMetric.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.alarm; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class AlarmMetric extends AbstractBceResponse { + private String alias; + private String name; + private String unitCategory; + private String unitName; + private Integer cycle; + private List> metricDimensions; + private String scope; + private String typeName; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmRule.java b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmRule.java new file mode 100644 index 00000000..188ced29 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmRule.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.alarm; + +import com.baidubce.services.bcm.model.Dimension; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +public class AlarmRule { + private Long index; + private String metric; + private Long periodInSecond; + private String statistics; + private String threshold; + private String comparisonOperator; + private Integer evaluationPeriodCount; + private List metricDimensions; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmType.java b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmType.java new file mode 100644 index 00000000..6c18595d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/AlarmType.java @@ -0,0 +1,5 @@ +package com.baidubce.services.bcm.model.alarm; + +public enum AlarmType { + NORMAL, EVENT +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/MonitorObject.java b/src/main/java/com/baidubce/services/bcm/model/alarm/MonitorObject.java new file mode 100644 index 00000000..7e4161f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/MonitorObject.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.alarm; + +import com.baidubce.services.bcm.model.application.MonitorObjectType; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MonitorObject { + private MonitorObjectType type; + private List names; + private List resources; + private String typeName; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/PolicyResource.java b/src/main/java/com/baidubce/services/bcm/model/alarm/PolicyResource.java new file mode 100644 index 00000000..f4a0c9bd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/PolicyResource.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcm.model.alarm; + +import com.baidubce.services.bcm.model.Dimension; +import lombok.Data; + +import java.util.List; + +@Data +public class PolicyResource { + private List identifiers; + private List metricDimensions; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/TargetInstance.java b/src/main/java/com/baidubce/services/bcm/model/alarm/TargetInstance.java new file mode 100644 index 00000000..1d296416 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/TargetInstance.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bcm.model.alarm; + +import com.baidubce.services.bcm.model.CommonKV; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +public class TargetInstance { + private String region; + private List identifiers; + private List metricDimensions; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/TargetType.java b/src/main/java/com/baidubce/services/bcm/model/alarm/TargetType.java new file mode 100644 index 00000000..3490c484 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/TargetType.java @@ -0,0 +1,5 @@ +package com.baidubce.services.bcm.model.alarm; + +public enum TargetType { + TARGET_TYPE_ALL_INSTANCES,TARGET_TYPE_INSTANCE_GROUP,TARGET_TYPE_MULTI_INSTANCES,TARGET_TYPE_INSTANCE_TAGS +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/request/CommonAlarmConfigRequest.java b/src/main/java/com/baidubce/services/bcm/model/alarm/request/CommonAlarmConfigRequest.java new file mode 100644 index 00000000..01e9b544 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/request/CommonAlarmConfigRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.alarm.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CommonAlarmConfigRequest extends AbstractBceRequest { + private String alarmName; + private String userId; + private String scope; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/request/CreateOrUpdateAlarmConfigRequest.java b/src/main/java/com/baidubce/services/bcm/model/alarm/request/CreateOrUpdateAlarmConfigRequest.java new file mode 100644 index 00000000..3c9fa011 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/request/CreateOrUpdateAlarmConfigRequest.java @@ -0,0 +1,49 @@ +package com.baidubce.services.bcm.model.alarm.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcm.model.alarm.AlarmLevel; +import com.baidubce.services.bcm.model.alarm.AlarmRule; +import com.baidubce.services.bcm.model.alarm.AlarmType; +import com.baidubce.services.bcm.model.alarm.MonitorObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Set; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateOrUpdateAlarmConfigRequest extends AbstractBceRequest { + private String alarmDescription; + private String alarmName; + private String aliasName; + private String userId; + private String scope; + private String region; + private AlarmLevel level = AlarmLevel.CRITICAL; + private MonitorObject monitorObject; + private Set alarmActions; + private Set okActions; + private Set insufficientActions; + private String srcName; + private String srcType; + private AlarmType type = AlarmType.NORMAL; + private List eventTypeList; + private int insufficientCycle; + private int maxRepeatCount; + private int repeatAlarmCycle; + private String callbackUrl = ""; + private String callbackToken = ""; + private List> rules; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/request/CreateOrUpdateAlarmConfigV2Request.java b/src/main/java/com/baidubce/services/bcm/model/alarm/request/CreateOrUpdateAlarmConfigV2Request.java new file mode 100644 index 00000000..9808fb91 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/request/CreateOrUpdateAlarmConfigV2Request.java @@ -0,0 +1,48 @@ +package com.baidubce.services.bcm.model.alarm.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcm.model.CommonKV; +import com.baidubce.services.bcm.model.alarm.AlarmConfigActionV2; +import com.baidubce.services.bcm.model.alarm.AlarmConfigPolicyV2; +import com.baidubce.services.bcm.model.alarm.AlarmLevel; +import com.baidubce.services.bcm.model.alarm.TargetInstance; +import com.baidubce.services.bcm.model.alarm.TargetType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateOrUpdateAlarmConfigV2Request extends AbstractBceRequest { + private String userId; + private String aliasName; + private String alarmName; + private String scope; + private String region; + private TargetType targetType; + private String resourceType = "Instance"; + private AlarmLevel alarmLevel = AlarmLevel.CRITICAL; + private List targetInstanceGroups; + private List targetInstanceTags; + private String callbackUrl; + private String callbackToken; + private int insufficientDataPendingPeriod; + private int alarmRepeatInterval; + private int alarmRepeatCount; + + private List policies; + private List targetInstances; + private List actions; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/request/ListAlarmMetricsRequest.java b/src/main/java/com/baidubce/services/bcm/model/alarm/request/ListAlarmMetricsRequest.java new file mode 100644 index 00000000..4019c01c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/request/ListAlarmMetricsRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.alarm.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class ListAlarmMetricsRequest extends AbstractBceRequest { + private String userId; + private String scope; + private String region; + private String dimensions; + private String type; + private String locale; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/request/ListSingleInstanceAlarmConfigsRequest.java b/src/main/java/com/baidubce/services/bcm/model/alarm/request/ListSingleInstanceAlarmConfigsRequest.java new file mode 100644 index 00000000..ce58e13e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/request/ListSingleInstanceAlarmConfigsRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.alarm.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ListSingleInstanceAlarmConfigsRequest extends AbstractBceRequest { + private String userId; + private String scope; + private String region; + private String dimensions; + private String order; + private int pageNo; + private int pageSize; + private Boolean actionEnabled; + private String alarmNamePrefix; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/alarm/response/CreateAlarmConfigV2Response.java b/src/main/java/com/baidubce/services/bcm/model/alarm/response/CreateAlarmConfigV2Response.java new file mode 100644 index 00000000..d66d4819 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarm/response/CreateAlarmConfigV2Response.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.alarm.response; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.alarm.AlarmConfigV2; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateAlarmConfigV2Response extends AbstractBceResponse { + private boolean success; + private String msg; + private AlarmConfigV2 result; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Action.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Action.java new file mode 100644 index 00000000..ae3268f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Action.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +@Data +public class Action { + private String type; + private String name; + private Long executedTime; + private String alias; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List notifications; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List callBacks; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List members; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Alarm.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Alarm.java new file mode 100644 index 00000000..5b76de48 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Alarm.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +@Data +public class Alarm { + private String id; + private String seriesId; + private String userId; + private String initState; + private String state; + private String closeReason; + private Long startTime; + private Long endTime; + + private Resource resource; + private Policy policy; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List actions; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List alertMetrics; + + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmDetailRequest.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmDetailRequest.java new file mode 100644 index 00000000..378c3f7d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmDetailRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AlarmDetailRequest extends AbstractBceRequest { + private String alarmId; + private String userId; + + /** + * {@inheritDoc} + * + * 重写父类方法,实现AlarmDetailRequest接口。返回当前对象自身,以支持链式调用。 + * + * @param credentials BceCredentials,包含请求的Access Key ID和Secret Access Key。可为null,表示使用默认的Access Key ID和Secret Access Key。 + * @return AlarmDetailRequest,当前对象自身,以支持链式调用。 + */ + @Override + public AlarmDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmDetailResponse.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmDetailResponse.java new file mode 100644 index 00000000..f0b865b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmDetailResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class AlarmDetailResponse extends AbstractBceResponse { + private Boolean success; + private String msg; + private Alarm result; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmListRequest.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmListRequest.java new file mode 100644 index 00000000..f42eb195 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmListRequest.java @@ -0,0 +1,50 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AlarmListRequest extends AbstractBceRequest { + private String userId; + private String alarmType; + + private Integer pageNo; + private Integer pageSize; + + private Long startTime; + private Long endTime; + + private String scope; + private String resourceType; + private List states; + private String sort = "startTime"; + private Boolean ascending = false; + private String level; + private String region; + private String alarmAliasName; + private ResourceKV resource; + private List resources; + + /** + * {@inheritDoc} + * + * 重写父类的方法,实现对请求凭证的设置。 + * + * @param credentials BCE凭证信息 + * @return 当前对象自身,以便链式调用 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmListResponse.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmListResponse.java new file mode 100644 index 00000000..f8867760 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlarmListResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AlarmListResponse extends AbstractBceResponse { + private Boolean success; + private String msg; + private PageResult result; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlertMetric.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlertMetric.java new file mode 100644 index 00000000..2bfff904 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/AlertMetric.java @@ -0,0 +1,9 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import lombok.Data; + +@Data +public class AlertMetric { + private Metric metric; + private Rule rule; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Metric.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Metric.java new file mode 100644 index 00000000..943ad627 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Metric.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +@Data +public class Metric { + private String name; + private Long value; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map dimensions; + private String aliasName; + private String aliasNameEn; + private String unit; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/PageResult.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/PageResult.java new file mode 100644 index 00000000..74398e51 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/PageResult.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import lombok.Data; + +import java.util.List; + +@Data +public class PageResult { + private List alarms; + private Integer pageNo; + private Integer pageSize; + private Integer totalCount; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Policy.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Policy.java new file mode 100644 index 00000000..697caad0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Policy.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +@Data +public class Policy { + private String name; + private String aliasName; + private String content; + private String contentEn; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map extra; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Resource.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Resource.java new file mode 100644 index 00000000..fee57e3e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Resource.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +@Data +public class Resource { + private String scope; + private String resourceType; + private String region; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map identifiers; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map properties; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/ResourceKV.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/ResourceKV.java new file mode 100644 index 00000000..a4da3d10 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/ResourceKV.java @@ -0,0 +1,9 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import lombok.Data; + +@Data +public class ResourceKV { + private String instanceId; + private String taskId; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Rule.java b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Rule.java new file mode 100644 index 00000000..131accf2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/alarmhouse/Rule.java @@ -0,0 +1,10 @@ +package com.baidubce.services.bcm.model.alarmhouse; + +import lombok.Data; + +@Data +public class Rule { + private Integer seq; + private String operator; + private Long threshold; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ACMonitorObject.java b/src/main/java/com/baidubce/services/bcm/model/application/ACMonitorObject.java new file mode 100644 index 00000000..5fb63ddd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ACMonitorObject.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.application; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ACMonitorObject { + private Long id; + private Set monitorObjectView; + private MonitorObjectType monitorObjectType; + private String typeName; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ACMonitorObjectViewModel.java b/src/main/java/com/baidubce/services/bcm/model/application/ACMonitorObjectViewModel.java new file mode 100644 index 00000000..bcf2d403 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ACMonitorObjectViewModel.java @@ -0,0 +1,10 @@ +package com.baidubce.services.bcm.model.application; + +import lombok.Data; + +@Data +public class ACMonitorObjectViewModel { + private String monitorObjectName; + private String monitorObjectNameView = ""; + private String metricDimensionView = ""; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/AggrTag.java b/src/main/java/com/baidubce/services/bcm/model/application/AggrTag.java new file mode 100644 index 00000000..fedce1e4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/AggrTag.java @@ -0,0 +1,9 @@ +package com.baidubce.services.bcm.model.application; + +import lombok.Data; + +@Data +public class AggrTag { + private String range; + private String tags; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/AppAlarmRule.java b/src/main/java/com/baidubce/services/bcm/model/application/AppAlarmRule.java new file mode 100644 index 00000000..dc059e4b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/AppAlarmRule.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.services.bcm.model.Dimension; +import com.baidubce.services.bcm.model.Statistics; +import lombok.Data; + +import java.util.List; + +@Data +public class AppAlarmRule { + private String metric; + private String metricAlias; + private int cycle; + private Statistics statistics; + private double threshold; + private String comparisonOperator; + private int count; + private String function; + private int sequence; + private List metricDimensions; + private String formulaV2Alias; + private String metricTags; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationAggrTag.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationAggrTag.java new file mode 100644 index 00000000..f021c03f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationAggrTag.java @@ -0,0 +1,9 @@ +package com.baidubce.services.bcm.model.application; + +import lombok.Data; + +@Data +public class ApplicationAggrTag { + private String range; + private String tags; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationAlarmConfig.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationAlarmConfig.java new file mode 100644 index 00000000..66e2fe6f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationAlarmConfig.java @@ -0,0 +1,41 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.alarm.ACAlarmType; +import com.baidubce.services.bcm.model.alarm.AlarmLevel; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +@Data +public class ApplicationAlarmConfig extends AbstractBceResponse{ + private String alarmDescription; + /** + * userId下唯一 + */ + private String alarmName; + private String userId; + private String appName; + private MonitorObjectType monitorObjectType; + private ACMonitorObject monitorObject; + private String srcName; + + private String srcType; + private ACAlarmType type; + private AlarmLevel level; + private Boolean actionEnabled; + private Boolean policyEnabled; + private List> rules; + private Set incidentActions; + private Set resumeActions; + private Set insufficientActions; + /** + * 无数据报警判断周期 + */ + private int insufficientCycle; + + private int repeatAlarmCycle; // 重复提醒周期 + private int maxRepeatCount; // 重复提醒次数 + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDataListRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDataListRequest.java new file mode 100644 index 00000000..6be57f32 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDataListRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +/** + * @author gongjiaming + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationDataListRequest extends AbstractBceRequest { + @NonNull + private Integer pageNo; + @NonNull + private Integer pageSize; + + private String searchName; + @Override + public ApplicationDataListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDataListResponse.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDataListResponse.java new file mode 100644 index 00000000..48003f01 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDataListResponse.java @@ -0,0 +1,38 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author gongjiaming + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ApplicationDataListResponse extends AbstractBceResponse { + private List content; + + private Boolean last; + + private Integer totalElements; + + private Integer totalPages; + + private Boolean first; + + private Integer number; + + private Integer size; + + private Integer numberOfElements; + + private Sort sort; + + private Pageable pageable; + + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableDeleteRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableDeleteRequest.java new file mode 100644 index 00000000..8a06baf6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableDeleteRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ApplicationDimensionTableDeleteRequest extends AbstractBceRequest { + + private String userId; + + private String appName; + + private String tableName; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableInfoRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableInfoRequest.java new file mode 100644 index 00000000..4159f9ca --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableInfoRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +/** + * @author gongjiaming + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ApplicationDimensionTableInfoRequest extends AbstractBceRequest { + @NotNull + private String userId; + @NotNull + private String appName; + @NotNull + private String mapContentJson; + @NotNull + private String tableName; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableInfoResponse.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableInfoResponse.java new file mode 100644 index 00000000..d95e58e0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableInfoResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * @author gongjiaming + */ +@Data +public class ApplicationDimensionTableInfoResponse extends AbstractBceResponse { + private String userId; + private String appName; + private String mapContentJson; + private String tableName; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableListRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableListRequest.java new file mode 100644 index 00000000..0474b453 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableListRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ApplicationDimensionTableListRequest extends AbstractBceRequest { + private String userId; + + private String appName; + + private String searchName; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableListResponse.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableListResponse.java new file mode 100644 index 00000000..9b726226 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationDimensionTableListResponse.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * @author gongjiaming + */ +@Data +public class ApplicationDimensionTableListResponse extends AbstractBceResponse { + private List applicationDimensionTableInfoList; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoDetaleRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoDetaleRequest.java new file mode 100644 index 00000000..051e748f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoDetaleRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationInfoDetaleRequest extends AbstractBceRequest { + @NonNull + private String name; + @Override + public ApplicationInfoDetaleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoRequest.java new file mode 100644 index 00000000..077f4438 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoRequest.java @@ -0,0 +1,36 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationInfoRequest extends AbstractBceRequest { + + private String name; + + private String description; + + private String type; + + private String alias; + + private String userId; + + + + @Override + public ApplicationInfoRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoResponse.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoResponse.java new file mode 100644 index 00000000..043f9078 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoResponse.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationInfoResponse extends AbstractBceResponse { + private Long id; + + private String name; + + private String description; + + private String type; + + private String userId; + + private String alias; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoUpdateRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoUpdateRequest.java new file mode 100644 index 00000000..7d48c773 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoUpdateRequest.java @@ -0,0 +1,37 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ApplicationInfoUpdateRequest extends AbstractBceRequest { + + @NonNull + private Long id; + + @NonNull + private String name; + + private String description; + + @NonNull + private String type; + + private String alias; + + @NonNull + private String userId; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoUpdateResponse.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoUpdateResponse.java new file mode 100644 index 00000000..31f38a56 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInfoUpdateResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationInfoUpdateResponse extends AbstractBceResponse { + + private Long id; + + private String name; + + private String description; + + private String type; + + private String alias; + + private String userId; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceCreateRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceCreateRequest.java new file mode 100644 index 00000000..d93fa877 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceCreateRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +import java.util.List; + +/** + * @author gongjiaming + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ApplicationInstanceCreateRequest extends AbstractBceRequest { + @NonNull + private String userId; + + @NonNull + private String appName; + + private List hostList; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceCreatedListRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceCreatedListRequest.java new file mode 100644 index 00000000..a8157763 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceCreatedListRequest.java @@ -0,0 +1,32 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +/** + * @author gongjiaming + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ApplicationInstanceCreatedListRequest extends AbstractBceRequest { + @NotNull + private String userId; + + @NotNull + private String appName; + + private String region; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceDeleteRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceDeleteRequest.java new file mode 100644 index 00000000..3ed34cf5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceDeleteRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +/** + * @author gongjiaming + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationInstanceDeleteRequest extends AbstractBceRequest { + @NotNull + private String id; + + @NotNull + private String appName; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceInfo.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceInfo.java new file mode 100644 index 00000000..b18342b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceInfo.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationInstanceInfo extends AbstractBceRequest { + private String id; + private String instanceId; + private String instanceUuid; + private String name; + private String internalIp; + private String floatingIp; + private String publicIp; + private Boolean hasBinded; + @Override + public ApplicationInstanceInfo withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceListRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceListRequest.java new file mode 100644 index 00000000..e86dfd7c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceListRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationInstanceListRequest extends AbstractBceRequest { + private Integer pageSize; + private Integer pageNo; + private String searchName; + private String searchValue; + private String region; + private String appName; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceListResponse.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceListResponse.java new file mode 100644 index 00000000..8fd0002c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationInstanceListResponse.java @@ -0,0 +1,36 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationInstanceListResponse extends AbstractBceResponse { + + private List content; + + private Boolean first; + + private Boolean last; + + private Integer pageElements; + + private Integer pageNumber; + + private Integer pageSize; + + private Integer totalElements; + + private Integer totalPages; + + private String[] orderBy; + + private String[] fields; + + private String query; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMetric.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMetric.java new file mode 100644 index 00000000..30b35e9e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMetric.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.application; + +import lombok.Data; + +import java.util.List; + +@Data +public class ApplicationMetric { + private long id; + private long taskId; + private String metricName; + private String metricAlias; + private String metricUnit; + private int valueFieldType; + private String valueFieldName; + private String valueMatchRule; + + private List aggrTags; + + private int saveInstanceData; + + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorResponse.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorResponse.java new file mode 100644 index 00000000..a628c9fb --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationMonitorResponse extends AbstractBceResponse { + private String requestId; + private String code; + private String message; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskDeleteRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskDeleteRequest.java new file mode 100644 index 00000000..deef6f9e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskDeleteRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ApplicationMonitorTaskDeleteRequest extends AbstractBceRequest { + private String userId; + + private String name; + + private String appName; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskDetailRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskDetailRequest.java new file mode 100644 index 00000000..12767d72 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskDetailRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationMonitorTaskDetailRequest extends AbstractBceRequest { + private String userId; + private String appName; + private String taskName; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskInfoRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskInfoRequest.java new file mode 100644 index 00000000..7d11c58d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskInfoRequest.java @@ -0,0 +1,53 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author gongjiaming + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationMonitorTaskInfoRequest extends AbstractBceRequest { + + private long id; + private String name; + private String aliasName; + private String appName; + private String userId; + private int cycle; + private String target; + private int type; + private String description; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private boolean hasAlarmConfig; + + /** + * 以下是日志监控任务字段 + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String logExample; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String matchRule; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer rate; + @JsonInclude(JsonInclude.Include.NON_NULL) + private List extractResult; + @JsonInclude(JsonInclude.Include.NON_NULL) + private List metrics; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskListRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskListRequest.java new file mode 100644 index 00000000..71d3f405 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskListRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationMonitorTaskListRequest extends AbstractBceRequest { + + private String userId; + private String appName; + private String type; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskListResponse.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskListResponse.java new file mode 100644 index 00000000..13e9472d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskListResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author gongjiaming + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationMonitorTaskListResponse extends AbstractBceResponse { + private List applicationMonitorTaskList; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskResponse.java new file mode 100644 index 00000000..d5eb92ff --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ApplicationMonitorTaskResponse.java @@ -0,0 +1,34 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ApplicationMonitorTaskResponse extends AbstractBceResponse { + private long id; + private String name; + private String aliasName; + private String appName; + private String userId; + private int cycle; + private String target; + private int type; + private String description; + + private boolean hasAlarmConfig; + + private String logExample; + private String matchRule; + private Integer rate; + private List extractResult; + private List metrics; + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/CreateOrUpdateAlarmConfigForApplicationRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/CreateOrUpdateAlarmConfigForApplicationRequest.java new file mode 100644 index 00000000..fc16c998 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/CreateOrUpdateAlarmConfigForApplicationRequest.java @@ -0,0 +1,50 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcm.model.alarm.ACAlarmType; +import com.baidubce.services.bcm.model.alarm.AlarmLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Set; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateOrUpdateAlarmConfigForApplicationRequest extends AbstractBceRequest { + + private String alarmDescription; + private String alarmName; + private String userId; + private String appName; + private MonitorObjectType monitorObjectType; + private ACMonitorObject monitorObject; + private String srcName; + + private String srcType; + private ACAlarmType type; + private AlarmLevel level; + private Boolean actionEnabled; + private Boolean policyEnabled; + private List> rules; + private Set incidentActions; + private Set resumeActions; + private Set insufficientActions; + /** + * 无数据报警判断周期 + */ + private int insufficientCycle; + + private int repeatAlarmCycle; // 重复提醒周期 + private int maxRepeatCount; // 重复提醒次数 + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/DeleteAlarmConfigForApplicationRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/DeleteAlarmConfigForApplicationRequest.java new file mode 100644 index 00000000..afd89dda --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/DeleteAlarmConfigForApplicationRequest.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class DeleteAlarmConfigForApplicationRequest extends AbstractBceRequest { + private String userId; + private String appName; + private String alarmName; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/GetAlarmConfigForApplicationRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/GetAlarmConfigForApplicationRequest.java new file mode 100644 index 00000000..4400071c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/GetAlarmConfigForApplicationRequest.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetAlarmConfigForApplicationRequest extends AbstractBceRequest{ + private String userId; + private String appName; + private String alarmName; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/GetMetricDataForApplicationRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/GetMetricDataForApplicationRequest.java new file mode 100644 index 00000000..b64c4590 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/GetMetricDataForApplicationRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcm.model.Statistics; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class GetMetricDataForApplicationRequest extends AbstractBceRequest{ + private String userId; + private String appName; + private String taskName; + private List instances; + private String metricName; + private int cycle; + private String startTime; + private String endTime; + private Map> dimensions; + private Statistics statistics; + private Boolean aggrData = false; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/GetMetricMetaForApplicationRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/GetMetricMetaForApplicationRequest.java new file mode 100644 index 00000000..2e4b6c67 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/GetMetricMetaForApplicationRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class GetMetricMetaForApplicationRequest extends AbstractBceRequest{ + private String userId; + private String appName; + private String taskName; + private List instances; + private String metricName; + private List dimensionKeys; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/HostInstanceInfo.java b/src/main/java/com/baidubce/services/bcm/model/application/HostInstanceInfo.java new file mode 100644 index 00000000..f808f887 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/HostInstanceInfo.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.application; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@NoArgsConstructor +public class HostInstanceInfo { + + private String instanceId; + + private String region; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ListAlarmConfigForApplicationRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ListAlarmConfigForApplicationRequest.java new file mode 100644 index 00000000..7f78235a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ListAlarmConfigForApplicationRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class ListAlarmConfigForApplicationRequest extends AbstractBceRequest { + private String userId; + private String appName; + private String alarmName; + private Boolean actionEnabled; + private String srcType; + private String taskName; + private int pageNo; + private int pageSize = 10; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/ListAlarmMetricsForApplicationRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/ListAlarmMetricsForApplicationRequest.java new file mode 100644 index 00000000..65c0f879 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/ListAlarmMetricsForApplicationRequest.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class ListAlarmMetricsForApplicationRequest extends AbstractBceRequest { + private String userId; + private String appName; + private String taskName; + private String searchName; + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/LogExtractRequest.java b/src/main/java/com/baidubce/services/bcm/model/application/LogExtractRequest.java new file mode 100644 index 00000000..f3920671 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/LogExtractRequest.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class LogExtractRequest extends AbstractBceRequest { + private String userId; + private String extractRule; + private String logExample; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/LogExtractResult.java b/src/main/java/com/baidubce/services/bcm/model/application/LogExtractResult.java new file mode 100644 index 00000000..5105801e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/LogExtractResult.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bcm.model.application; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author gongjiaming + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class LogExtractResult { + private String extractFieldName; + private String extractFieldValue; + private String dimensionMapTable; + private int metricEnable; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/Metric.java b/src/main/java/com/baidubce/services/bcm/model/application/Metric.java new file mode 100644 index 00000000..01d26db2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/Metric.java @@ -0,0 +1,29 @@ +package com.baidubce.services.bcm.model.application; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Metric { + private long id; + private long taskId; + private String metricName; + private String metricAlias; + private String metricUnit; + private int valueFieldType; + private String valueFieldName; + private String valueMatchRule; + + private List aggrTags; + + private int saveInstanceData; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/MetricDataForApplication.java b/src/main/java/com/baidubce/services/bcm/model/application/MetricDataForApplication.java new file mode 100644 index 00000000..a1a648cf --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/MetricDataForApplication.java @@ -0,0 +1,19 @@ +package com.baidubce.services.bcm.model.application; + +import com.baidubce.services.bcm.model.DataPoint; +import lombok.Data; + +import java.util.List; + +@Data +public class MetricDataForApplication { + private String namespace; + private List dimensions; + private List dataPoints; + + @Data + public static class Dimension { + private String key; + private String name; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/application/MonitorObjectType.java b/src/main/java/com/baidubce/services/bcm/model/application/MonitorObjectType.java new file mode 100644 index 00000000..e9277661 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/MonitorObjectType.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.application; + +public enum MonitorObjectType { + APP, + SERVICE, + SITE, + CUSTOM, + INSTANCE, + DOMAIN, + TAG, + ALL, + MULTI_INSTANCE +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/Pageable.java b/src/main/java/com/baidubce/services/bcm/model/application/Pageable.java new file mode 100644 index 00000000..f3b03e65 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/Pageable.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.application; + +import lombok.Data; + +/** + * @author gongjiaming + */ +@Data +public class Pageable { + private Sort sort; + private Integer pageSize; + + private Integer pageNo; + + private Integer offset; + + private Boolean unpaged; + + private Boolean paged; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/application/Sort.java b/src/main/java/com/baidubce/services/bcm/model/application/Sort.java new file mode 100644 index 00000000..a19cc527 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/application/Sort.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcm.model.application; + +import lombok.Data; + +/** + * @author gongjiaming + */ +@Data +public class Sort { + private Boolean sorted; + private Boolean unsorted; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/AlarmLevel.java b/src/main/java/com/baidubce/services/bcm/model/custom/AlarmLevel.java new file mode 100644 index 00000000..38f5b39d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/AlarmLevel.java @@ -0,0 +1,5 @@ +package com.baidubce.services.bcm.model.custom; + +public enum AlarmLevel { + NOTICE, WARNING, CRITICAL, MAJOR, CUSTOM +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/AlarmPolicyBatch.java b/src/main/java/com/baidubce/services/bcm/model/custom/AlarmPolicyBatch.java new file mode 100644 index 00000000..29c024da --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/AlarmPolicyBatch.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.custom; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class AlarmPolicyBatch { + private String userId; + private String scope; + private List alarmName; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/AlarmPolicyBatchListRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/AlarmPolicyBatchListRequest.java new file mode 100644 index 00000000..8b09ab0f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/AlarmPolicyBatchListRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class AlarmPolicyBatchListRequest extends AbstractBceRequest { + List customAlarmList; + @Override + public AlarmPolicyBatchListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/BatchDeleteNamespaceEventsRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/BatchDeleteNamespaceEventsRequest.java new file mode 100644 index 00000000..cf4bec6f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/BatchDeleteNamespaceEventsRequest.java @@ -0,0 +1,32 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 批量删除自定义空间事件请求 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:16 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchDeleteNamespaceEventsRequest extends AbstractBceRequest { + private String userId; + private String namespace; + private List names; + + @Override + public BatchDeleteNamespaceEventsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/BatchDeleteNamespaceMetricsRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/BatchDeleteNamespaceMetricsRequest.java new file mode 100644 index 00000000..41abcf62 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/BatchDeleteNamespaceMetricsRequest.java @@ -0,0 +1,32 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 批量删除自定义空间指标请求 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:16 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchDeleteNamespaceMetricsRequest extends AbstractBceRequest { + private String userId; + private String namespace; + private List ids; + + @Override + public BatchDeleteNamespaceMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/BatchDeleteNamespacesRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/BatchDeleteNamespacesRequest.java new file mode 100644 index 00000000..67b84a01 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/BatchDeleteNamespacesRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 批量删除自定义空间请求 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:16 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchDeleteNamespacesRequest extends AbstractBceRequest { + private String userId; + private List names; + + @Override + public BatchDeleteNamespacesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmConfig.java b/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmConfig.java new file mode 100644 index 00000000..48b33867 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmConfig.java @@ -0,0 +1,37 @@ +package com.baidubce.services.bcm.model.custom; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Set; + +/** + * @author guanyanyan + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CustomAlarmConfig { + + private String comment = ""; // 注释 + private String userId; + private String alarmName; // userId下唯一 + private String namespace; + private AlarmLevel level; + private Boolean actionEnabled; + private Boolean policyEnabled; + private Set alarmActions; + private Set okActions; + private Set insufficientActions; + private int insufficientCycle; // 无数据报警判断周期 + private List rules; + private String region = ""; + private String callbackUrl = ""; // 报警回调地址 + private String callbackToken = ""; // 报警回调token + private String tag = ""; // 用来标识单条规则的老策略 + private int repeatAlarmCycle; // 重复提醒周期 + private int maxRepeatCount; // 重复提醒次数 +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmConfigRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmConfigRequest.java new file mode 100644 index 00000000..25313423 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmConfigRequest.java @@ -0,0 +1,46 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Set; + +/** + * @author guanyanyan + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class CustomAlarmConfigRequest extends AbstractBceRequest { + + private String comment = ""; // 注释 + private String userId; + private String alarmName; // userId下唯一 + private String namespace; + private AlarmLevel level; + private Boolean actionEnabled; + private Boolean policyEnabled; + private Set alarmActions; + private Set okActions; + private Set insufficientActions; + private int insufficientCycle; // 无数据报警判断周期 + private List rules; + private String region = ""; + private String callbackUrl = ""; // 报警回调地址 + private String callbackToken = ""; // 报警回调token + private String tag = ""; // 用来标识单条规则的老策略 + private int repeatAlarmCycle; // 重复提醒周期 + private int maxRepeatCount; // 重复提醒次数 + @Override + public CustomAlarmConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmConfigResponse.java b/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmConfigResponse.java new file mode 100644 index 00000000..0bc0d088 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmConfigResponse.java @@ -0,0 +1,37 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Set; + +/** + * @author guanyanyan + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CustomAlarmConfigResponse extends AbstractBceResponse { + private String comment = ""; // 注释 + private String userId; + private String alarmName; // userId下唯一 + private String namespace; + private String level; + private Boolean actionEnabled; + private Boolean policyEnabled; + private Set alarmActions; + private Set okActions; + private Set insufficientActions; + private int insufficientCycle; // 无数据报警判断周期 + private List rules; + private String region = ""; + private String callbackUrl = ""; // 报警回调地址 + private String callbackToken = ""; // 报警回调token + private String tag = ""; // 用来标识单条规则的老策略 + private int repeatAlarmCycle; // 重复提醒周期 + private int maxRepeatCount; // 重复提醒次数 +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmRule.java b/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmRule.java new file mode 100644 index 00000000..a60eb34f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/CustomAlarmRule.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bcm.model.custom; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author guanyanyan + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class CustomAlarmRule { + @JsonIgnoreProperties + private Long id; + private int index; + private String metricName; + private List dimensions; + private String statistics; + private String threshold; + private String comparisonOperator; + private int cycle; + private int count; + private String function; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/CustomMonitorResponse.java b/src/main/java/com/baidubce/services/bcm/model/custom/CustomMonitorResponse.java new file mode 100644 index 00000000..3dbf7f6c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/CustomMonitorResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * 自定义监控返回结构 + * + * @Author: wanglu51 + * @Date: 2023/12/7 10:12 + */ +@Data +public class CustomMonitorResponse extends AbstractBceResponse { + private String requestId; + private String code; + private String message; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/DetailCustomAlarmConfigRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/DetailCustomAlarmConfigRequest.java new file mode 100644 index 00000000..fdf4e4cd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/DetailCustomAlarmConfigRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DetailCustomAlarmConfigRequest extends AbstractBceRequest { + private String userId; + private String alarmName; + private String namespace; + @Override + public DetailCustomAlarmConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/EventLevelEnum.java b/src/main/java/com/baidubce/services/bcm/model/custom/EventLevelEnum.java new file mode 100644 index 00000000..09358eff --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/EventLevelEnum.java @@ -0,0 +1,34 @@ +package com.baidubce.services.bcm.model.custom; + +import lombok.AllArgsConstructor; + +/** + * 事件级别枚举 + * + * @Author: wanglu51 + * @Date: 2023/12/7 18:45 + */ +@AllArgsConstructor +public enum EventLevelEnum { + /** + * 通知事件级别 + */ + NOTICE, + + /** + * 预警事件级别 + */ + MAJOR, + + /** + * 警告事件级别 + */ + WARNING, + + /** + * 故障事件级别 + */ + CRITICAL, + + ; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomEventRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomEventRequest.java new file mode 100644 index 00000000..4286ef02 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomEventRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 获取某个自定义空间事件请求 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:16 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetCustomEventRequest extends AbstractBceRequest { + private String userId; + private String namespace; + private String eventName; + + @Override + public GetCustomEventRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomEventResponse.java b/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomEventResponse.java new file mode 100644 index 00000000..0ca1c32c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomEventResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * 获取某个自定义空间事件响应 + * + * @Author: wanglu51 + * @Date: 2023/12/7 10:59 + */ +@Data +public class GetCustomEventResponse extends AbstractBceResponse { + private String userId; + private String namespace; + private String eventName; + private String eventNameAlias; + private String eventLevel; + private String comment; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomMetricRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomMetricRequest.java new file mode 100644 index 00000000..99f806d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomMetricRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 获取某个自定义空间指标请求 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:16 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetCustomMetricRequest extends AbstractBceRequest { + private String userId; + private String namespace; + private String metricName; + + @Override + public GetCustomMetricRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomMetricResponse.java b/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomMetricResponse.java new file mode 100644 index 00000000..37a68fcc --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/GetCustomMetricResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * 获取某个自定义空间的指标响应 + * + * @Author: wanglu51 + * @Date: 2023/12/7 10:59 + */ +@Data +public class GetCustomMetricResponse extends AbstractBceResponse { + private Long id; + private String userId; + private String namespace; + private String metricName; + private String metricAlias; + private String unit; + private Integer cycle; + private List dimensions; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/ListCustomAlarmConfigRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/ListCustomAlarmConfigRequest.java new file mode 100644 index 00000000..cb00650f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/ListCustomAlarmConfigRequest.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class ListCustomAlarmConfigRequest extends AbstractBceRequest { + private String userId; + private String alarmName; + private String namespace; + private Boolean actionEnabled; + private int pageNo; + private int pageSize; + @Override + public ListCustomAlarmConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/ListCustomConfigResponse.java b/src/main/java/com/baidubce/services/bcm/model/custom/ListCustomConfigResponse.java new file mode 100644 index 00000000..42ca7a31 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/ListCustomConfigResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class ListCustomConfigResponse extends AbstractBceResponse { + private String orderBy = ""; + private String order = ""; + private int pageNo = 1; + private int pageSize = 0; + private int totalCount = 0; + private List result = new ArrayList(); +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceEventsRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceEventsRequest.java new file mode 100644 index 00000000..9c262647 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceEventsRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 获取自定义空间事件列表请求 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:16 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ListNamespaceEventsRequest extends AbstractBceRequest { + private String userId; + private String namespace; + private String name; + private EventLevelEnum eventLevel; + private Integer pageNo; + private Integer pageSize; + + @Override + public ListNamespaceEventsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceEventsResponse.java b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceEventsResponse.java new file mode 100644 index 00000000..0d41ad51 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceEventsResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * 获取自定义空间事件列表响应对象 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:58 + */ +@Data +public class ListNamespaceEventsResponse extends AbstractBceResponse { + private Integer pageNo; + private Integer pageSize; + private Integer totalCount; + private List result; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceMetricsRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceMetricsRequest.java new file mode 100644 index 00000000..ee2b3ede --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceMetricsRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 获取自定义空间指标列表请求 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:16 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ListNamespaceMetricsRequest extends AbstractBceRequest { + private String userId; + private String namespace; + private String metricName; + private String metricAlias; + private Integer pageNo; + private Integer pageSize; + + @Override + public ListNamespaceMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceMetricsResponse.java b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceMetricsResponse.java new file mode 100644 index 00000000..0fed75e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespaceMetricsResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * 获取自定义空间指标列表响应对象 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:58 + */ +@Data +public class ListNamespaceMetricsResponse extends AbstractBceResponse { + private Integer pageNo; + private Integer pageSize; + private Integer totalCount; + private List result; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespacesRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespacesRequest.java new file mode 100644 index 00000000..82a5c18f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespacesRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 获取自定义空间列表请求 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:16 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ListNamespacesRequest extends AbstractBceRequest { + private String userId; + private String name; + private Integer pageNo; + private Integer pageSize; + + @Override + public ListNamespacesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespacesResponse.java b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespacesResponse.java new file mode 100644 index 00000000..124f2e09 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/ListNamespacesResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * 获取自定义空间列表响应对象 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:58 + */ +@Data +public class ListNamespacesResponse extends AbstractBceResponse { + private Integer pageNo; + private Integer pageSize; + private Integer totalCount; + private List result; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/MetricDimensions.java b/src/main/java/com/baidubce/services/bcm/model/custom/MetricDimensions.java new file mode 100644 index 00000000..24386c05 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/MetricDimensions.java @@ -0,0 +1,25 @@ +package com.baidubce.services.bcm.model.custom; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author guanyanyan + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MetricDimensions { + + private String name; + + @Builder.Default + private Set value = new HashSet(); +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceEvent.java b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceEvent.java new file mode 100644 index 00000000..e7606e65 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceEvent.java @@ -0,0 +1,19 @@ +package com.baidubce.services.bcm.model.custom; + +import lombok.Data; + +/** + * 自定义事件 + * + * @Author: wanglu51 + * @Date: 2023/12/7 10:59 + */ +@Data +public class NamespaceEvent { + private String userId; + private String namespace; + private String eventName; + private String eventNameAlias; + private String eventLevel; + private String comment; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceEventRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceEventRequest.java new file mode 100644 index 00000000..0e1cf664 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceEventRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 自定义事件请求 + * + * @Author: wanglu51 + * @Date: 2023/12/7 10:59 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class NamespaceEventRequest extends AbstractBceRequest { + private String userId; + private String namespace; + private String eventName; + private String eventNameAlias; + private EventLevelEnum eventLevel; + private String comment; + + @Override + public NamespaceEventRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceMetric.java b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceMetric.java new file mode 100644 index 00000000..f529691d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceMetric.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.custom; + +import lombok.Data; + +import java.util.List; + +/** + * 自定义空间中的指标 + * + * @Author: wanglu51 + * @Date: 2023/12/7 10:59 + */ +@Data +public class NamespaceMetric { + private Long id; + private String userId; + private String namespace; + private String metricName; + private String metricAlias; + private String unit; + private Integer cycle; + private List dimensions; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceMetricDimension.java b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceMetricDimension.java new file mode 100644 index 00000000..e44d7036 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceMetricDimension.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.custom; + +import lombok.Data; + +/** + * 自定义指标维度 + * + * @Author: wanglu51 + * @Date: 2023/12/7 11:20 + */ +@Data +public class NamespaceMetricDimension { + private String name; + private String alias; + private Integer order; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceMetricRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceMetricRequest.java new file mode 100644 index 00000000..51e15a5e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceMetricRequest.java @@ -0,0 +1,37 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 自定义空间中的指标 + * + * @Author: wanglu51 + * @Date: 2023/12/7 10:59 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class NamespaceMetricRequest extends AbstractBceRequest { + private Long id; + private String userId; + private String namespace; + private String metricName; + private String metricAlias; + private String unit; + private Integer cycle; + private List dimensions; + + @Override + public NamespaceMetricRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceRequest.java b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceRequest.java new file mode 100644 index 00000000..df7d9784 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bcm.model.custom; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 自定义空间请求 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:16 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class NamespaceRequest extends AbstractBceRequest { + private String userId; + private String name; + private String namespaceAlias; + private String comment; + + @Override + public NamespaceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceWithMetricAndEvent.java b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceWithMetricAndEvent.java new file mode 100644 index 00000000..7232bbbe --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/custom/NamespaceWithMetricAndEvent.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcm.model.custom; + +import lombok.Data; + +import java.util.List; + +/** + * 有指标和事件的自定义空间对象 + * + * @Author: wanglu51 + * @Date: 2023/12/6 19:55 + */ +@Data +public class NamespaceWithMetricAndEvent { + private String name; + private String namespaceAlias; + private String userId; + private String comment; + private List metrics; + private List eventConfigs; + + @Data + public static class NamespaceItemView { + private String name; + private String alias; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBaseRequest.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBaseRequest.java new file mode 100644 index 00000000..21a339b9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBaseRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.dashboard; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DashboardBaseRequest extends AbstractBceRequest { + public String configure; + + public String title; + + public String type; + + public String userId; + + public String dashboardName; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBaseResponse.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBaseResponse.java new file mode 100644 index 00000000..9fbda51a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBaseResponse.java @@ -0,0 +1,19 @@ +package com.baidubce.services.bcm.model.dashboard; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardBaseResponse extends AbstractBceResponse { + public Integer code; + + public String message; + + public String traceInfo; + + public Boolean success; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBillboardData.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBillboardData.java new file mode 100644 index 00000000..32b37d24 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBillboardData.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DashboardBillboardData { + private List> data; + private Object decimals; + private String displayName; + private String instanceName; + private String metricDimension; + private String name; + private String unit; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBillboardDataResponse.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBillboardDataResponse.java new file mode 100644 index 00000000..f176d2cf --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardBillboardDataResponse.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardBillboardDataResponse extends DashboardBaseResponse { + private List data; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardCreateResponse.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardCreateResponse.java new file mode 100644 index 00000000..40005c49 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardCreateResponse.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardCreateResponse extends DashboardBaseResponse { + private Map data; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardData.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardData.java new file mode 100644 index 00000000..830a0530 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardData.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@NoArgsConstructor +@Data +@AllArgsConstructor +public class DashboardData { + private List metric; + private List monitorObject; + private String scope; + private String subService; + private String region; + private ScopeValue scopeValue; + private String resourceType; + private String monitorType; + private List namespace; + private String product; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDataRequest.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDataRequest.java new file mode 100644 index 00000000..5e81ab01 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDataRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.bcm.model.dashboard; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DashboardDataRequest extends AbstractBceRequest { + private List data; + private String time; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimension.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimension.java new file mode 100644 index 00000000..4d2279f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimension.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DashboardDimension { + private String namespace; + private List metrics; + private List tags; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimensionsData.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimensionsData.java new file mode 100644 index 00000000..a88d5a79 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimensionsData.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DashboardDimensionsData { + private String name; + private String product; + private String comment; + private List dimensionValues; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimensionsRequest.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimensionsRequest.java new file mode 100644 index 00000000..205f78e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimensionsRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.bcm.model.dashboard; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DashboardDimensionsRequest extends AbstractBceRequest { + private String userId; + private String service; + private String region; + private String showId; + private String dimensions; + private String metricName; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimensionsResponse.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimensionsResponse.java new file mode 100644 index 00000000..acecb1a0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardDimensionsResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.dashboard; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; +import java.util.Set; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardDimensionsResponse extends AbstractBceResponse { + private Map> data; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardMetric.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardMetric.java new file mode 100644 index 00000000..10e7ffbd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardMetric.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@NoArgsConstructor +@Data +@AllArgsConstructor +public class DashboardMetric { + private String name; + private String unit; + private String alias; + private List contrast; + private List timeContrast; + private String statistics; + private List dimensions; + private List metricDimensions; + private int cycle; + private String displayName; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardMonitorObject.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardMonitorObject.java new file mode 100644 index 00000000..6eb8aefa --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardMonitorObject.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardMonitorObject { + private String instanceName; + private String id; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardNamespace.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardNamespace.java new file mode 100644 index 00000000..78ba7192 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardNamespace.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardNamespace { + private String namespaceType; + private String transfer = ""; + private String filter; + private String name; + private String instanceName; + private String region; + private String bcmService; + private List subService; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardReportData.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardReportData.java new file mode 100644 index 00000000..518472c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardReportData.java @@ -0,0 +1,19 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DashboardReportData { + private String alias; + private List children; + private Map metrics; + private String name; + private String value; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardReportDataResponse.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardReportDataResponse.java new file mode 100644 index 00000000..1746639a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardReportDataResponse.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardReportDataResponse extends DashboardBaseResponse { + private List data; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardResponse.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardResponse.java new file mode 100644 index 00000000..2900655d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardResponse extends DashboardBaseResponse { + private String data; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendData.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendData.java new file mode 100644 index 00000000..df93dd80 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendData.java @@ -0,0 +1,32 @@ +package com.baidubce.services.bcm.model.dashboard; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DashboardTrendData extends AbstractBceResponse { + private List> data; + private int denominator; + private String dimensions; + private Object legend; + private String metric; + private String metricType; + private String metricUnit; + private String metricUnitTransformation; + private String name; + private String namespace; + private int numerator; + private Object product; + private String scope; + private Object statistics; + private Object time; + private String transPolicy; + private Object hostName; + private Object internalIp; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendDataResponse.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendDataResponse.java new file mode 100644 index 00000000..bca6a275 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendDataResponse.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardTrendDataResponse extends DashboardBaseResponse { + private List data; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendSeniorData.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendSeniorData.java new file mode 100644 index 00000000..767e9e8a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendSeniorData.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DashboardTrendSeniorData { + private List items; + private Job job; + private Numeric numeric; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendSeniorDataResponse.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendSeniorDataResponse.java new file mode 100644 index 00000000..aeee052e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardTrendSeniorDataResponse.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DashboardTrendSeniorDataResponse extends DashboardBaseResponse { + private List data; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardWidgetConfigure.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardWidgetConfigure.java new file mode 100644 index 00000000..045b2297 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardWidgetConfigure.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.Data; + +import java.util.List; + +@Data +public class DashboardWidgetConfigure { + private List data; + private Style style; + private String title; + private TimeRange timeRange; + private String time; + private String monitorType; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardWidgetRequest.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardWidgetRequest.java new file mode 100644 index 00000000..a6c29955 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DashboardWidgetRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.dashboard; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DashboardWidgetRequest extends AbstractBceRequest { + + private String widgetName; + + private String title; + + private String type; + + private String userId; + + private String dashboardName; + + private DashboardWidgetConfigure configure; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DimensionFilter.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DimensionFilter.java new file mode 100644 index 00000000..6c880465 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DimensionFilter.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DimensionFilter { + private String name; + private List values; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/DimensionValue.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/DimensionValue.java new file mode 100644 index 00000000..6d27e4b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/DimensionValue.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DimensionValue { + private String name; + private String comment; + private boolean available; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/Item.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/Item.java new file mode 100644 index 00000000..32a020aa --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/Item.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Item { + private Numeric statisticsValue; + private int timestamp; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/Job.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/Job.java new file mode 100644 index 00000000..a5f30c87 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/Job.java @@ -0,0 +1,35 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Job { + private String alias; + private boolean bcmSource; + private String contrast; + private Object decimals; + private String displayName; + private int endTime; + private boolean flatten; + private Object instanceID; + private String instanceName; + private Object intranetIP; + private List items; + private String metricName; + private String namespace; + private int offset; + private int originalPeriod; + private int period; + private String product; + private int startTime; + private String statistics; + private String tags; + private List tagsForTsdb; + private String unit; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/MetricDimensions.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/MetricDimensions.java new file mode 100644 index 00000000..10275222 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/MetricDimensions.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@NoArgsConstructor +@Data +@AllArgsConstructor +public class MetricDimensions { + private String name; + private List values; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/Numeric.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/Numeric.java new file mode 100644 index 00000000..8fc1514b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/Numeric.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Numeric { + private double avg; + private double cnt; + private double max; + private double min; + private double sum; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/ScopeValue.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/ScopeValue.java new file mode 100644 index 00000000..41547bd3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/ScopeValue.java @@ -0,0 +1,14 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@Data +@AllArgsConstructor +public class ScopeValue { + private String name; + private String value; + private boolean hasChildren; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/Style.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/Style.java new file mode 100644 index 00000000..f3ab7c11 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/Style.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Style { + private String displayType; + private String nullPointMode; + private int threshold; + private int decimals; + private boolean isEdit; + private String unit; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/SubService.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/SubService.java new file mode 100644 index 00000000..0fbf422b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/SubService.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@AllArgsConstructor +@NoArgsConstructor +@Data +public class SubService { + private String name; + private String value; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/TagForTsdb.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/TagForTsdb.java new file mode 100644 index 00000000..89a624e6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/TagForTsdb.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TagForTsdb { + private String key; + private String value; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/dashboard/TimeRange.java b/src/main/java/com/baidubce/services/bcm/model/dashboard/TimeRange.java new file mode 100644 index 00000000..81f40a79 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/dashboard/TimeRange.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bcm.model.dashboard; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@Data +@AllArgsConstructor +public class TimeRange { + private String timeType; + private String unit; + private int number; + private String relative; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/BlockStatus.java b/src/main/java/com/baidubce/services/bcm/model/event/BlockStatus.java new file mode 100644 index 00000000..547d4e70 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/BlockStatus.java @@ -0,0 +1,9 @@ +package com.baidubce.services.bcm.model.event; + +/** + * Created by dongjiawei on 2023/12/13. + */ +public enum BlockStatus { + NORMAL, + BLOCKED +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/CloudEventData.java b/src/main/java/com/baidubce/services/bcm/model/event/CloudEventData.java new file mode 100644 index 00000000..de8520fa --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/CloudEventData.java @@ -0,0 +1,66 @@ +package com.baidubce.services.bcm.model.event; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CloudEventData { + + private String accountId; + + /** + * Name of the cloud service to which the event belongs + */ + private String serviceName; + + /** + * Region to which the event belongs, default is "global" + */ + private String region = "global"; + + /** + * Type of the instance to which the event belongs, + * used to distinguish different types of cloud resource objects, default is "instance" + */ + private String resourceType; + + /** + * Instance Id of the event instance + */ + private String resourceId; + + /** + * Event ID + */ + private String eventId; + + /** + * Event type + */ + private String eventType; + + /** + * Event level, [NOTICE/WARNING/MAJOR/CRITICAL] + */ + private EventLevel eventLevel; + + /** + * Event alias + */ + private String eventAlias; + + /** + * Timestamp of the event occurrence, in UTC format + */ + private String timestamp; + + /** + * Event content + */ + private String content; + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/event/CloudEventResponse.java b/src/main/java/com/baidubce/services/bcm/model/event/CloudEventResponse.java new file mode 100644 index 00000000..367bb107 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/CloudEventResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.event; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/13. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CloudEventResponse extends AbstractBceResponse { + private List content = new ArrayList(); + private int pageNumber; + private int pageSize; + private int pageElements; + private boolean last; + private boolean first; + private int totalPages; + private long totalElements; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/event/EventDataRequest.java b/src/main/java/com/baidubce/services/bcm/model/event/EventDataRequest.java new file mode 100644 index 00000000..28994029 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/EventDataRequest.java @@ -0,0 +1,74 @@ +package com.baidubce.services.bcm.model.event; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +public class EventDataRequest extends AbstractBceRequest { + /** + * Page number for pagination + */ + private Integer pageNo = 1; + /** + * Page size for pagination + */ + private Integer pageSize = 10; + /** + * Filter condition for the event occurrence time, represented in UTC date, e.g., 2019-01-01T00:00:00Z + */ + private String startTime; + /** + * Filter condition for the event end time, represented in UTC date, e.g., 2019-01-01T00:00:00Z + */ + private String endTime; + /** + * Account ID + */ + private String accountId; + /** + * Whether to sort in ascending order by event occurrence time, default is descending (false) + */ + private Boolean ascending; + /** + * Name of the cloud service to which the event belongs + */ + private String scope; + /** + * Filter condition for the region to which the event belongs + */ + private String region; + /** + * Filter condition for the event level, including: CRITICAL, MAJOR, WARNING, NOTICE + */ + private EventLevel eventLevel; + /** + * Exact search for event name + */ + private String eventName; + /** + * Fuzzy search for event alias + */ + private String eventAlias; + /** + * Product subtype to which the event-affected instance belongs, e.g., BCC subtype: Instance + */ + private String resourceType; + /** + * Instance Id of the event instance, e.g., BCC instance: i-SyZeMxxx + */ + private String resourceId; + /** + * Unique ID of the event. e.g., 999bbc21-2061-49e6-bb2a-fd3e6c5xxxxx + */ + private String eventId; + + @Override + public EventDataRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/event/EventFilter.java b/src/main/java/com/baidubce/services/bcm/model/event/EventFilter.java new file mode 100644 index 00000000..3a9cd597 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/EventFilter.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.event; + +import lombok.Data; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +import java.util.HashSet; +import java.util.Set; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class EventFilter { + private EventLevel eventLevel; + private Set eventTypeList; + private Set eventAliasNames = new HashSet(); +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/EventLevel.java b/src/main/java/com/baidubce/services/bcm/model/event/EventLevel.java new file mode 100644 index 00000000..69e93c93 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/EventLevel.java @@ -0,0 +1,25 @@ +package com.baidubce.services.bcm.model.event; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Created by dongjiawei on 2023/12/12. + */ +public enum EventLevel { + CRITICAL("CRITICAL"), + MAJOR("MAJOR"), + WARNING("WARNING"), + NOTICE("NOTICE"), + ALL("*"); + + private final String name; + + EventLevel(String name) { + this.name = name; + } + + @JsonValue + public String getName() { + return name; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/EventPolicy.java b/src/main/java/com/baidubce/services/bcm/model/event/EventPolicy.java new file mode 100644 index 00000000..0303f7e3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/EventPolicy.java @@ -0,0 +1,29 @@ +package com.baidubce.services.bcm.model.event; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +public class EventPolicy extends AbstractBceRequest { + + private String accountId; + private String serviceName; + private String name; + private BlockStatus blockStatus; + private EventFilter eventFilter = new EventFilter(); + private EventResourceFilter resource = new EventResourceFilter(); + private Set incidentActions = new HashSet(); + + @Override + public EventPolicy withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/EventPolicyResponse.java b/src/main/java/com/baidubce/services/bcm/model/event/EventPolicyResponse.java new file mode 100644 index 00000000..46987f48 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/EventPolicyResponse.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.event; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +import java.util.HashSet; +import java.util.Set; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class EventPolicyResponse extends AbstractBceResponse { + private String accountId; + private String serviceName; + private String name; + private BlockStatus blockStatus; + private EventFilter eventFilter = new EventFilter(); + private EventResourceFilter resource = new EventResourceFilter(); + private Set incidentActions = new HashSet(); +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/EventResource.java b/src/main/java/com/baidubce/services/bcm/model/event/EventResource.java new file mode 100644 index 00000000..0e428b55 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/EventResource.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.event; + +import com.baidubce.services.bcm.model.Dimension; +import lombok.Data; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class EventResource { + + List identifiers = new ArrayList(); +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/EventResourceFilter.java b/src/main/java/com/baidubce/services/bcm/model/event/EventResourceFilter.java new file mode 100644 index 00000000..68cb6a44 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/EventResourceFilter.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.event; + +import com.baidubce.services.bcm.model.application.MonitorObjectType; +import lombok.Data; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class EventResourceFilter { + private String region; + + private String type; + + private MonitorObjectType monitorObjectType = MonitorObjectType.ALL; + + private List resources = new ArrayList(); + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/EventType.java b/src/main/java/com/baidubce/services/bcm/model/event/EventType.java new file mode 100644 index 00000000..63fd3a59 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/EventType.java @@ -0,0 +1,8 @@ +package com.baidubce.services.bcm.model.event; + +/** + * Created by dongjiawei on 2023/12/12. + */ +public enum EventType { + Cloud, Platform; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/PlatformEventData.java b/src/main/java/com/baidubce/services/bcm/model/event/PlatformEventData.java new file mode 100644 index 00000000..68292b6d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/PlatformEventData.java @@ -0,0 +1,64 @@ +package com.baidubce.services.bcm.model.event; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class PlatformEventData { + + /** + * 用户ID + */ + private String userId; + /** + * 事件来源 + */ + private String eventSource; + /** + * 事件名称 + */ + private String eventName; + /** + * 事件发生的时间戳,UTC格式 + */ + private String timestamp; + /** + * 事件ID,用于标识一个事件,事件ID在租户、应用、区域下唯一。ID由业务方生成。 + */ + private String eventId; + /** + * 事件归属的区域名 + */ + private String region; + /** + * 事件归属的区域名 + */ + private String az; + /** + * 事件级别,[NOTICE/WARNING/MAJOR/CRITICAL],非空会覆盖默认值 + */ + private EventLevel eventLevel; + /** + * 事件别名,非空会覆盖默认值 + */ + private String eventAlias; + /** + * 父类型的事件名称 + */ + private String eventParentAlias; + /** + * 事件内容 + */ + private String content; + + /*事件影响范围*/ + private List resources = new ArrayList(); + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/PlatformEventResponse.java b/src/main/java/com/baidubce/services/bcm/model/event/PlatformEventResponse.java new file mode 100644 index 00000000..ecfbea8a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/PlatformEventResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.event; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class PlatformEventResponse extends AbstractBceResponse { + private List content = new ArrayList(); + private int pageNumber; + private int pageSize; + private int pageElements; + private boolean last; + private boolean first; + private int totalPages; + private long totalElements; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/event/PlatformResource.java b/src/main/java/com/baidubce/services/bcm/model/event/PlatformResource.java new file mode 100644 index 00000000..c1387f37 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/event/PlatformResource.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.event; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class PlatformResource { + private String service; + private String userId; + private String instanceId; + private String shortInstanceId; + private String instanceName; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceItem.java b/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceItem.java new file mode 100644 index 00000000..e998e3b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceItem.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.group; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/12. + */ + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class IGInstanceItem { + private String itemName; + private String itemAlias; + private String itemValue; + private boolean itemIdentitable; + private String itemDimension; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceListResponse.java b/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceListResponse.java new file mode 100644 index 00000000..ac47e3a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceListResponse.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bcm.model.group; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class IGInstanceListResponse extends AbstractBceResponse { + private String orderBy = ""; + private String order = ""; + private int pageNo = 1; + private int pageSize = 0; + private int totalCount = 0; + private List> result = new ArrayList(); +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceQuery.java b/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceQuery.java new file mode 100644 index 00000000..2831a981 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceQuery.java @@ -0,0 +1,29 @@ +package com.baidubce.services.bcm.model.group; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +public class IGInstanceQuery extends AbstractBceRequest { + private String userId; + private Long id; + private String uuid; + private String serviceName; + private String typeName; + private String region; + private ViewType viewType; + private Integer pageNo; + private Integer pageSize; + private String keywordType; + private String keyword; + + @Override + public IGInstanceQuery withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceQueryType.java b/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceQueryType.java new file mode 100644 index 00000000..6c19db69 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/IGInstanceQueryType.java @@ -0,0 +1,19 @@ +package com.baidubce.services.bcm.model.group; + +/** + * Created by dongjiawei on 2023/12/12. + */ +public enum IGInstanceQueryType { + /** + * ALL: return all instance + */ + ALL, + /** + * FILTER: Returns instances that are not included in the instance group + */ + FILTER, + /** + * INCLUDE: Returns instances that are included in the instance group + */ + INCLUDE, +} diff --git a/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroup.java b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroup.java new file mode 100644 index 00000000..5d0abaaa --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroup.java @@ -0,0 +1,43 @@ +package com.baidubce.services.bcm.model.group; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +public class InstanceGroup extends AbstractBceRequest { + + private Long id; + + private String name; + + private String serviceName; + + private String typeName; + + private String region; + + private String userId; + + private String uuid; + + private int count; + + private String serviceNameAlias; + + private String typeNameAlias; + + private String regionAlias; + + private String tagKey = ""; + + @Override + public InstanceGroup withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupBase.java b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupBase.java new file mode 100644 index 00000000..28f92661 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupBase.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.group; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +public class InstanceGroupBase extends AbstractBceRequest { + private String id; + private String userId; + + @Override + public InstanceGroupBase withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupListResponse.java b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupListResponse.java new file mode 100644 index 00000000..8aaeea40 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupListResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.group; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class InstanceGroupListResponse extends AbstractBceResponse { + + private String orderBy = ""; + private String order = ""; + private int pageNo = 1; + private int pageSize = 0; + private int totalCount = 0; + private List result = new ArrayList(); + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupQuery.java b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupQuery.java new file mode 100644 index 00000000..dda3bed9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupQuery.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bcm.model.group; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +public class InstanceGroupQuery extends AbstractBceRequest { + + private String userId; + private String name; + private String serviceName; + private String region; + private String typeName; + private Integer pageNo; + private Integer pageSize; + + @Override + public InstanceGroupQuery withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupResponse.java b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupResponse.java new file mode 100644 index 00000000..fac8b272 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/InstanceGroupResponse.java @@ -0,0 +1,40 @@ +package com.baidubce.services.bcm.model.group; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +import javax.validation.constraints.NotNull; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class InstanceGroupResponse extends AbstractBceResponse { + @NotNull + private Long id; + @NotNull + private String name; + @NotNull + private String serviceName; + @NotNull + private String typeName; + @NotNull + private String region; + + private String userId; + + private String uuid; + + private int count; + + private String serviceNameAlias; + + private String typeNameAlias; + + private String regionAlias; + + private String tagKey = ""; + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/group/MergedGroup.java b/src/main/java/com/baidubce/services/bcm/model/group/MergedGroup.java new file mode 100644 index 00000000..5aeabef0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/MergedGroup.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.group; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +public class MergedGroup extends AbstractBceRequest { + private Long id; + + private String userId; + + private String region; + + private String serviceName; + + private String typeName; + + private String name; + + private List resourceIdList; + + @Override + public MergedGroup withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/group/MonitorObjectType.java b/src/main/java/com/baidubce/services/bcm/model/group/MonitorObjectType.java new file mode 100644 index 00000000..8ae01598 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/MonitorObjectType.java @@ -0,0 +1,7 @@ +package com.baidubce.services.bcm.model.group; + +public enum MonitorObjectType { + ALL, + TAG, + INSTANCE +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/group/MonitorResource.java b/src/main/java/com/baidubce/services/bcm/model/group/MonitorResource.java new file mode 100644 index 00000000..37329b1a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/MonitorResource.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.group; + +import com.baidubce.services.bcm.model.Dimension; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by dongjiawei on 2023/12/12. + */ +@Data +public class MonitorResource { + private String userId; + private String region; + private String serviceName; + private String typeName; + private String resourceId; + private String errUpdateTime; + private List identifiers = new ArrayList(); + private List properties = new ArrayList(); + private List tags = new ArrayList(); +} diff --git a/src/main/java/com/baidubce/services/bcm/model/group/ViewType.java b/src/main/java/com/baidubce/services/bcm/model/group/ViewType.java new file mode 100644 index 00000000..bd7ab849 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/group/ViewType.java @@ -0,0 +1,8 @@ +package com.baidubce.services.bcm.model.group; + +/** + * Created by dongjiawei on 2023/12/13. + */ +public enum ViewType { + LIST_VIEW, DETAIL_VIEW +} diff --git a/src/main/java/com/baidubce/services/bcm/model/metrics/MultiDimensionalMetricsRequest.java b/src/main/java/com/baidubce/services/bcm/model/metrics/MultiDimensionalMetricsRequest.java new file mode 100644 index 00000000..c6918547 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/metrics/MultiDimensionalMetricsRequest.java @@ -0,0 +1,43 @@ +package com.baidubce.services.bcm.model.metrics; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcm.model.Dimension; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MultiDimensionalMetricsRequest extends AbstractBceRequest { + private String userId; + + private String scope; + + private String region; + + private String type = "Instance"; + + private String startTime; + + private String endTime; + + private List metricNames; + + private List statistics; + + private List> dimensions; + + private int cycle = 60; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/metrics/PartialDimensionsMetricsRequest.java b/src/main/java/com/baidubce/services/bcm/model/metrics/PartialDimensionsMetricsRequest.java new file mode 100644 index 00000000..3b339ed1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/metrics/PartialDimensionsMetricsRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.bcm.model.metrics; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcm.model.Dimension; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PartialDimensionsMetricsRequest extends AbstractBceRequest { + private String userId; + private String startTime; + private String endTime; + private List statistics; + private Integer cycle; + private List dimensions; + private String scope; + private String resourceType; + private String metricName; + private String region; + private Integer pageNo; + private Integer pageSize; + @Override + public PartialDimensionsMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbDataQueryResult.java b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbDataQueryResult.java new file mode 100644 index 00000000..232e8d14 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbDataQueryResult.java @@ -0,0 +1,55 @@ +package com.baidubce.services.bcm.model.metrics; + + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TsdbDataQueryResult extends AbstractBceResponse { + private String region; + private String scope; + private String userid; + private String resourceId; + private String namespace; + private String metricName; + /* 带前缀的指标名称,为了兼容旧代码 */ + @JsonIgnore + private String metricNameWithPrefix; + + /** 其他的维度信息 */ + private Map dimensions; + + /** 数据点,按照时间顺序排列的 */ + private List dataPoints; + + @JsonIgnore + private String requestId; + + /** + * 代表一个数据点 + */ + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class DataPoint { + private String timestamp; + private Double average; + private Double sum; + private Double maximum; + private Double minimum; + private Integer sampleCount; + private Object value; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbDimensionTopQuery.java b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbDimensionTopQuery.java new file mode 100644 index 00000000..fab12e82 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbDimensionTopQuery.java @@ -0,0 +1,41 @@ +package com.baidubce.services.bcm.model.metrics; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; +import java.util.Set; + +/** + * create by pangyangyang on 2024/04/27 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TsdbDimensionTopQuery extends AbstractBceRequest { + + private String requestId; + private String userId; + private String scope; + private String region; + private String metricName; + private String statistics; + private String startTime; + private String endTime; + private Map dimensions; + private Set labels; + private int topNum; + private String order; + private int cycle; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbDimensionTopResult.java b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbDimensionTopResult.java new file mode 100644 index 00000000..524fad26 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbDimensionTopResult.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.metrics; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.Dimension; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * create by pangyangyang on 2024/04/27 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TsdbDimensionTopResult extends AbstractBceResponse { + + private String requestId; + + private List topDatas; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class TopData { + private int order; + private List dimensions; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbMetricAllDataResult.java b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbMetricAllDataResult.java new file mode 100644 index 00000000..39e17baf --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbMetricAllDataResult.java @@ -0,0 +1,37 @@ +package com.baidubce.services.bcm.model.metrics; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.Dimension; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TsdbMetricAllDataResult extends AbstractBceResponse { + private String requestId; + private String code; + private String message; + private List metrics; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class AllDataMetric { + private String region; + private String scope; + private String userId; + private String resourceId; + private String metricName; + private List dimensions; + private List dataPoints; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbMetricResult.java b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbMetricResult.java new file mode 100644 index 00000000..714da0bc --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbMetricResult.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.metrics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class TsdbMetricResult extends AbstractBceResponse { + private String requestId; + private String code; + private String message; + private T result; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbQueryMetaData.java b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbQueryMetaData.java new file mode 100644 index 00000000..789ea6aa --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/metrics/TsdbQueryMetaData.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcm.model.metrics; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.Dimension; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TsdbQueryMetaData extends AbstractBceResponse { + + private String requestId; + private String userId; + private String serviceName; + private String metricName; + private String resourceId; + private List dimensions; + private List dataPoints; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/AlarmLevel.java b/src/main/java/com/baidubce/services/bcm/model/site/AlarmLevel.java new file mode 100644 index 00000000..9c53ee65 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/AlarmLevel.java @@ -0,0 +1,5 @@ +package com.baidubce.services.bcm.model.site; + +public enum AlarmLevel { + NOTICE, WARNING, CRITICAL, MAJOR, CUSTOM +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/BaseTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/BaseTaskRequest.java new file mode 100644 index 00000000..1948acd9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/BaseTaskRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class BaseTaskRequest extends AbstractBceRequest { + + private String userId; + private String taskId; + private String scope = "BCM_SITE"; + private String taskName; + private String address; + private String type; + private Integer cycle; + private String idc; + private List idcObjs; + private int timeout; + private String confResource; + private Boolean advanceConfig; + private String ipType = "ipv4"; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/DeleteSiteAlarmConfigRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/DeleteSiteAlarmConfigRequest.java new file mode 100644 index 00000000..6ba86769 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/DeleteSiteAlarmConfigRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/14 + */ +@Data +public class DeleteSiteAlarmConfigRequest extends AbstractBceRequest { + + private String userId; + private List alarmNames; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/DnsTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/DnsTaskRequest.java new file mode 100644 index 00000000..73b980fe --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/DnsTaskRequest.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class DnsTaskRequest extends BaseTaskRequest { + + private String server; + private ResolveTypeEnum resolveType = ResolveTypeEnum.RECURSION; + private String kidnapWhite; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/DnsTaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/DnsTaskResponse.java new file mode 100644 index 00000000..253320e1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/DnsTaskResponse.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class DnsTaskResponse extends AbstractBceResponse { + + private int port; + private int inputType; + private int outputType; + private String input; + private String expectedOutput; + + private String userId; + private String taskId; + private String scope = "BCM_SITE"; + private String taskName; + private String address; + private String type; + private Integer cycle; + private String idc; + private List idcObjs; + private int timeout; + private String confResource; + private Boolean advanceConfig; + private String ipType = "ipv4"; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/FtpTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/FtpTaskRequest.java new file mode 100644 index 00000000..c02d3632 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/FtpTaskRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class FtpTaskRequest extends BaseTaskRequest { + + private int port; + private boolean anonymousLogin; + private String userName; + private String password; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/FtpTaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/FtpTaskResponse.java new file mode 100644 index 00000000..3ca9f377 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/FtpTaskResponse.java @@ -0,0 +1,32 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class FtpTaskResponse extends AbstractBceResponse { + + private int port; + private boolean anonymousLogin; + private String userName; + private String password; + + private String userId; + private String taskId; + private String scope = "BCM_SITE"; + private String taskName; + private String address; + private String type; + private Integer cycle; + private String idc; + private List idcObjs; + private int timeout; + private String confResource; + private Boolean advanceConfig; + private String ipType = "ipv4"; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/HttpTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/HttpTaskRequest.java new file mode 100644 index 00000000..ea45bb5e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/HttpTaskRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class HttpTaskRequest extends BaseTaskRequest { + + private String method; + private String postContent; + private String cookies; + private String host; + private String userAgent; + private String responseCode; + private String responseCheck = ""; + private String responseCheckType = "CONTAIN"; + private String responseCheckRange = "BODY"; + private String userName = ""; + private String password = ""; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/HttpTaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/HttpTaskResponse.java new file mode 100644 index 00000000..0236b72d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/HttpTaskResponse.java @@ -0,0 +1,38 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class HttpTaskResponse extends AbstractBceResponse { + + private String method; + private String postContent; + private String cookies; + private String host; + private String userAgent; + private String responseCode; + private String responseCheck = ""; + private String responseCheckType = "CONTAIN"; + private String responseCheckRange = "BODY"; + private String userName = ""; + private String password = ""; + private String userId; + private String taskId; + private String scope = "BCM_SITE"; + private String taskName; + private String address; + private String type; + private Integer cycle; + private String idc; + private List idcObjs; + private int timeout; + private String confResource; + private Boolean advanceConfig; + private String ipType = "ipv4"; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/HttpsTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/HttpsTaskRequest.java new file mode 100644 index 00000000..69cba884 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/HttpsTaskRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class HttpsTaskRequest extends BaseTaskRequest { + + private String method; + private String postContent; + private String cookies; + private String host; + private String userAgent; + private String responseCode; + private String responseCheck = ""; + private String responseCheckType = "CONTAIN"; + private String responseCheckRange = "BODY"; + private String userName = ""; + private String password = ""; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/HttpsTaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/HttpsTaskResponse.java new file mode 100644 index 00000000..6383dd24 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/HttpsTaskResponse.java @@ -0,0 +1,38 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class HttpsTaskResponse extends AbstractBceResponse { + + private String method; + private String postContent; + private String cookies; + private String host; + private String userAgent; + private String responseCode; + private String responseCheck = ""; + private String responseCheckType = "CONTAIN"; + private String responseCheckRange = "BODY"; + private String userName = ""; + private String password = ""; + private String userId; + private String taskId; + private String scope = "BCM_SITE"; + private String taskName; + private String address; + private String type; + private Integer cycle; + private String idc; + private List idcObjs; + private int timeout; + private String confResource; + private Boolean advanceConfig; + private String ipType = "ipv4"; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/IDC.java b/src/main/java/com/baidubce/services/bcm/model/site/IDC.java new file mode 100644 index 00000000..ebe3ed8a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/IDC.java @@ -0,0 +1,19 @@ +package com.baidubce.services.bcm.model.site; + +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class IDC { + /** + * idc编号:beijing-UNICOM + */ + private String id; + + /** + * idc名称:北京联通 + */ + private String name; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/IdcIspResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/IdcIspResponse.java new file mode 100644 index 00000000..a4a531de --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/IdcIspResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +/** + * create by pangyangyang on 2021/02/22 + */ +@Data +public class IdcIspResponse extends AbstractBceResponse { + + + private List idcs; + private Set isps; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/PageData.java b/src/main/java/com/baidubce/services/bcm/model/site/PageData.java new file mode 100644 index 00000000..fc3ede72 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/PageData.java @@ -0,0 +1,121 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +public class PageData extends AbstractBceResponse { + + private List content; + private String query; + private String[] fields = new String[0]; + private String[] orderBy = new String[0]; + private int pageNumber; + private int pageSize; + private int pageElements; + private boolean last; + private boolean first; + private int totalPages; + private long totalElements; + + public List getContent() { + return content; + } + + public PageData setContent(List content) { + if (content != null) { + this.content = content; + } + return this; + } + + public String getQuery() { + return query; + } + + public PageData setQuery(String query) { + this.query = query; + return this; + } + + public String[] getFields() { + return fields; + } + + public PageData setFields(String[] fields) { + this.fields = fields; + return this; + } + + public String[] getOrderBy() { + return orderBy; + } + + public PageData setOrderBy(String[] orderBy) { + this.orderBy = orderBy; + return this; + } + + public int getPageNumber() { + return pageNumber; + } + + public PageData setPageNumber(int pageNumber) { + this.pageNumber = pageNumber; + return this; + } + + public int getPageSize() { + return pageSize; + } + + public PageData setPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + public int getPageElements() { + return pageElements; + } + + public PageData setPageElements(int pageElements) { + this.pageElements = pageElements; + return this; + } + + public boolean isLast() { + return last; + } + + public PageData setLast(boolean last) { + this.last = last; + return this; + } + + public boolean isFirst() { + return first; + } + + public PageData setFirst(boolean first) { + this.first = first; + return this; + } + + public int getTotalPages() { + return totalPages; + } + + public PageData setTotalPages(int totalPages) { + this.totalPages = totalPages; + return this; + } + + public long getTotalElements() { + return totalElements; + } + + public PageData setTotalElements(long totalElements) { + this.totalElements = totalElements; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/PageResultResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/PageResultResponse.java new file mode 100644 index 00000000..4cdf3292 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/PageResultResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/14 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PageResultResponse extends AbstractBceResponse { + + private String orderBy = ""; + private String order = ""; + private int pageNo = 1; + private int pageSize = 0; + private int totalCount = 0; + private List result; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/PingTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/PingTaskRequest.java new file mode 100644 index 00000000..72b2f531 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/PingTaskRequest.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class PingTaskRequest extends BaseTaskRequest { + + private int packetCount; + private int packetLossRate; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/PingTaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/PingTaskResponse.java new file mode 100644 index 00000000..d4f9eb4c --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/PingTaskResponse.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class PingTaskResponse extends AbstractBceResponse { + + private int packetCount; + private int packetLossRate; + + private String userId; + private String taskId; + private String scope = "BCM_SITE"; + private String taskName; + private String address; + private String type; + private Integer cycle; + private String idc; + private List idcObjs; + private int timeout; + private String confResource; + private Boolean advanceConfig; + private String ipType = "ipv4"; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/ResolveTypeEnum.java b/src/main/java/com/baidubce/services/bcm/model/site/ResolveTypeEnum.java new file mode 100644 index 00000000..8d416ad1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/ResolveTypeEnum.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.site; + +/** + * create by pangyangyang on 2023/03/06 + */ +public enum ResolveTypeEnum { + /** + * 递归解析 + */ + RECURSION, + + /** + * 迭代解析 + */ + ITERATION +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteAgentRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteAgentRequest.java new file mode 100644 index 00000000..d7d2926f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteAgentRequest.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/14 + */ +@Data +public class SiteAgentRequest extends AbstractBceRequest { + + private String userId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteAgentResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteAgentResponse.java new file mode 100644 index 00000000..10e2f3e0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteAgentResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.site; + +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/14 + */ +@Data +public class SiteAgentResponse { + + private String agentId; + private String agentName; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmConfigDetailResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmConfigDetailResponse.java new file mode 100644 index 00000000..bbcd815f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmConfigDetailResponse.java @@ -0,0 +1,40 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class SiteAlarmConfigDetailResponse extends AbstractBceResponse { + + private String taskId; + private String comment = ""; + private String userId; + private String alarmName; + private String aliasName; + private String namespace = "BCM_SITE"; + private AlarmLevel level; + private Boolean actionEnabled; + private Boolean policyEnabled; + private Set incidentActions; + private Set resumeActions; + private Set insufficientActions; + private int insufficientCycle; + private List rules; + private String region = "bj"; + private String callbackUrl = ""; + private String callbackToken = ""; + private String protocolType; + private String cycle; + private String method; + private String siteMonitor; + private String tag = ""; + private String srcType = "SITE"; + private int repeatAlarmCycle; + private int maxRepeatCount; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmConfigListRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmConfigListRequest.java new file mode 100644 index 00000000..0acbbee9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmConfigListRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/14 + */ +@Data +public class SiteAlarmConfigListRequest extends AbstractBceRequest { + + private String userId; + private String taskId; + private String aliasName; + private boolean actionEnabled; + private int pageNo; + private int pageSize; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmConfigRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmConfigRequest.java new file mode 100644 index 00000000..5c427221 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmConfigRequest.java @@ -0,0 +1,47 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class SiteAlarmConfigRequest extends AbstractBceRequest { + + private String taskId; + private String comment = ""; + private String userId; + private String alarmName; + private String aliasName; + private String namespace = "BCM_SITE"; + private AlarmLevel level; + private Boolean actionEnabled; + private Boolean policyEnabled; + private Set incidentActions; + private Set resumeActions; + private Set insufficientActions; + private int insufficientCycle; + private List rules; + private String region = "bj"; + private String callbackUrl = ""; + private String callbackToken = ""; + private String protocolType; + private String cycle; + private String method; + private String siteMonitor; + private String tag = ""; + private String srcType = "SITE"; + private int repeatAlarmCycle; + private int maxRepeatCount; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmRule.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmRule.java new file mode 100644 index 00000000..cfb2193e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmRule.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bcm.model.site; + +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2021/02/22 + */ +@Data +public class SiteAlarmRule { + + private Long id; + private int index; + private String metric; + private String metricAlias; + private String statistics; + private String threshold; + private String comparisonOperator; + private int cycle; + private int count; + private String function; + private int sequence; + // 当前报警规则作用与的探测点,如果是全网均值,需要传 AVERAGE + private List actOnIdcs; + // 当前报警规则作用与的运营商 + private List actOnIsps; + // 标示哪些规则可以合并为一个的报警规则 + private String versionSite; + private String unitName; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmUserIdRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmUserIdRequest.java new file mode 100644 index 00000000..e7a3993f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteAlarmUserIdRequest.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class SiteAlarmUserIdRequest extends AbstractBceRequest { + + private String userId; + private String alarmName; + private String namespace; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteBasicResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteBasicResponse.java new file mode 100644 index 00000000..cba32360 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteBasicResponse.java @@ -0,0 +1,19 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * create by pangyangyang on 2021/02/22 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SiteBasicResponse extends AbstractBceResponse { + + private String requestId; + private String message; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteInfoResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteInfoResponse.java new file mode 100644 index 00000000..4f2b16d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteInfoResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * create by pangyangyang on 2021/06/17 + */ +@Data +public class SiteInfoResponse extends AbstractBceResponse { + + private String name; + private String address; + private String method; + private String siteId; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteMetricDataQueryRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteMetricDataQueryRequest.java new file mode 100644 index 00000000..3bc23706 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteMetricDataQueryRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class SiteMetricDataQueryRequest extends AbstractBceRequest { + + private String userId; + private String taskId; + private String metricName; + private String[] statistics; + private String startTime; + private String endTime; + private int cycle; + private String dimensions; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteMetricDataQueryResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteMetricDataQueryResponse.java new file mode 100644 index 00000000..da829e04 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteMetricDataQueryResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcm.model.Dimension; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2021/02/22 + */ +@Data +public class SiteMetricDataQueryResponse extends AbstractBceResponse { + + private String namespace; + + private List dimensions; + + private List dataPoints; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteTaskIspRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteTaskIspRequest.java new file mode 100644 index 00000000..179bcffd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteTaskIspRequest.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/14 + */ +@Data +public class SiteTaskIspRequest extends AbstractBceRequest { + + private String userId; + private String taskId; + private String isp; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteTaskRequest.java new file mode 100644 index 00000000..777376cd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteTaskRequest.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class SiteTaskRequest extends AbstractBceRequest { + + private String userId; + private String taskId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/SiteViewResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/SiteViewResponse.java new file mode 100644 index 00000000..b87e9734 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/SiteViewResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/14 + */ +@Data +public class SiteViewResponse extends AbstractBceResponse { + + private String id; + private String name; + private String availability; + private Double responseTime; +} + diff --git a/src/main/java/com/baidubce/services/bcm/model/site/TaskDetailRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/TaskDetailRequest.java new file mode 100644 index 00000000..aa720cc8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/TaskDetailRequest.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class TaskDetailRequest extends AbstractBceRequest { + + private String userId; + private String taskId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/TaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/TaskResponse.java new file mode 100644 index 00000000..4045be70 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/TaskResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class TaskResponse extends AbstractBceResponse { + + private String taskId; + private String jobId; + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/TaskSummaryRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/TaskSummaryRequest.java new file mode 100644 index 00000000..f9a59192 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/TaskSummaryRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * create by pangyangyang on 2021/02/22 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TaskSummaryRequest extends AbstractBceRequest { + + private String userId; + private String query; + private String type; + private int pageNo; + private int pageSize; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/TaskSummaryResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/TaskSummaryResponse.java new file mode 100644 index 00000000..27834e6d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/TaskSummaryResponse.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * create by pangyangyang on 2021/02/22 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TaskSummaryResponse extends AbstractBceResponse { + + private String taskId; + private String taskName; + private int cycle; + private String type; + private String address; + private String status; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/TcpTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/TcpTaskRequest.java new file mode 100644 index 00000000..4cbac53d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/TcpTaskRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class TcpTaskRequest extends BaseTaskRequest { + + private int port; + private int inputType; + private int outputType; + private String input; + private String expectedOutput; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/TcpTaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/TcpTaskResponse.java new file mode 100644 index 00000000..a49343fd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/TcpTaskResponse.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class TcpTaskResponse extends AbstractBceResponse { + + private int port; + private int inputType; + private int outputType; + private String input; + private String expectedOutput; + + private String userId; + private String taskId; + private String scope = "BCM_SITE"; + private String taskName; + private String address; + private String type; + private Integer cycle; + private String idc; + private List idcObjs; + private int timeout; + private String confResource; + private Boolean advanceConfig; + private String ipType = "ipv4"; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/TsdbQueryDataPoint.java b/src/main/java/com/baidubce/services/bcm/model/site/TsdbQueryDataPoint.java new file mode 100644 index 00000000..3ea3bbe8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/TsdbQueryDataPoint.java @@ -0,0 +1,25 @@ +package com.baidubce.services.bcm.model.site; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author panzhiwei01@baidu.com + * @Date 2020/2/25 6:42 下午 + * @Description + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TsdbQueryDataPoint { + private String timestamp; + private Double average; + private Double sum; + private Double maximum; + private Double minimum; + private Integer sampleCount; + private Object value; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/UdpTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/site/UdpTaskRequest.java new file mode 100644 index 00000000..77c83bb9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/UdpTaskRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class UdpTaskRequest extends BaseTaskRequest { + + private int port; + private int inputType; + private int outputType; + private String input; + private String expectedOutput; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/site/UdpTaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/site/UdpTaskResponse.java new file mode 100644 index 00000000..f9f12f64 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/site/UdpTaskResponse.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.site; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * create by pangyangyang on 2023/12/13 + */ +@Data +public class UdpTaskResponse extends AbstractBceResponse { + + private int port; + private int inputType; + private int outputType; + private String input; + private String expectedOutput; + + private String userId; + private String taskId; + private String scope = "BCM_SITE"; + private String taskName; + private String address; + private String type; + private Integer cycle; + private String idc; + private List idcObjs; + private int timeout; + private String confResource; + private Boolean advanceConfig; + private String ipType = "ipv4"; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/AbstractResponse.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/AbstractResponse.java new file mode 100644 index 00000000..5b72cf4b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/AbstractResponse.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcm.model.siteonce; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author guanyanyan + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class AbstractResponse extends AbstractBceResponse { + + @JsonInclude(value = JsonInclude.Include.NON_NULL) + private String requestId; + + private String message = ""; + + private Boolean success = true; + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/EmptyRequest.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/EmptyRequest.java new file mode 100644 index 00000000..142455f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/EmptyRequest.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bcm.model.siteonce; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class EmptyRequest extends AbstractBceRequest { + @Override + public EmptyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/HttpResponseWrapper.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/HttpResponseWrapper.java new file mode 100644 index 00000000..d088f4f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/HttpResponseWrapper.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.siteonce; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author panzhiwei01@baidu.com + * @Date 2022/7/11 5:19 下午 + * @Description + */ +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class HttpResponseWrapper extends AbstractResponse { + private T result; + private Integer code; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/ResolveTypeEnum.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/ResolveTypeEnum.java new file mode 100644 index 00000000..3fe39fdb --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/ResolveTypeEnum.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bcm.model.siteonce; + +/** + * create by pangyangyang on 2023/03/06 + */ +public enum ResolveTypeEnum { + /** + * 递归解析 + */ + RECURSION, + + /** + * 迭代解析 + */ + ITERATION +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteAdvancedConfig.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteAdvancedConfig.java new file mode 100644 index 00000000..d507850f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteAdvancedConfig.java @@ -0,0 +1,41 @@ +package com.baidubce.services.bcm.model.siteonce; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SiteAdvancedConfig { + /**HTTP/HTTPS请求头各字段*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String cookies; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String userAgent; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String host; + + /**HTTP/HTTP响应Code*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String responseCode = ""; + /**HTTP/HTTP响应内容匹配*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String responseCheck = ""; + /**HTTP/HTTP验证用户名与密码*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String username = ""; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String password = ""; + + /**TCP请求内容格式*/ + private int inputType; + /**TCP请求内容*/ + private String input; + /**TCP响应内容匹配格式*/ + private int outputType; + /**TCP响应匹配内容*/ + private String expectedOutput; + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteAgent.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteAgent.java new file mode 100644 index 00000000..08fa4ab8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteAgent.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bcm.model.siteonce; + +import lombok.Data; + + +/** + * create by pangyangyang on 2021/02/22 + */ +@Data +public class SiteAgent { + + private String agentId; + private String agentName; + private Integer status; + private Integer ipv6Status; + private SiteAgentRegion region; + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteAgentRegion.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteAgentRegion.java new file mode 100644 index 00000000..f9861b1b --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteAgentRegion.java @@ -0,0 +1,57 @@ +package com.baidubce.services.bcm.model.siteonce; + + + +import java.util.HashMap; +import java.util.Map; + +public enum SiteAgentRegion { + NORTHEAST, + NORTH, + EAST, + SOUTH, + CENTRAL, + NORTHWEST, + SOUTHWEST; + + private static final Map REGION_MAP_MAP = new HashMap(){{ + put("beijing", NORTH); + put("tianjin", NORTH); + put("hebei", NORTH); + put("shanxi", NORTH); + put("neimenggu", NORTH); + put("liaonin", NORTHEAST); + put("jilin", NORTHEAST); + put("heilongjiang", NORTHEAST); + put("liaoning", NORTHEAST); + put("shanghai", EAST); + put("jiangsu", EAST); + put("zhejiang", EAST); + put("anhui", EAST); + put("fujian", EAST); + put("jiangxi", EAST); + put("shandong", EAST); + put("henan", SOUTH); + put("hubei", SOUTH); + put("hunan", SOUTH); + put("guangdong", SOUTH); + put("guangxi", SOUTH); + put("hainan", SOUTH); + put("chongqing", SOUTHWEST); + put("sichuan", SOUTHWEST); + put("guizhou", SOUTHWEST); + put("yunnan", SOUTHWEST); + put("xizang", SOUTHWEST); + put("shaanxi", NORTHWEST); + put("gansu", NORTHWEST); + put("qinghai", NORTHWEST); + put("ningxia", NORTHWEST); + put("xinjiang", NORTHWEST); + + }}; + + public static Map getAgentRegion() { + return REGION_MAP_MAP; + } + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteConstant.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteConstant.java new file mode 100644 index 00000000..4105d2c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteConstant.java @@ -0,0 +1,130 @@ +package com.baidubce.services.bcm.model.siteonce; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * create by pangyangyang on 2021/02/22 + */ +public class SiteConstant { + + public static final long SIXTY_SECONDS = 60L; + + public static final String SITE_SERVICE_NAME = "BCM_SITE"; + public static final List CYCLE_LIST = Arrays.asList( + 10, 30, 60, 120, 300, 600, 900, 1800, 3600, 7200, 10800); + public static final int IDC_LIMIT = 5; + public static final int DEFAULT_HTTP_RESPONSE_CODE_CHECK = 200; + public static final int DEFAULT_PING_PACKET_COUNT = 1; + public static final int DEFAULT_CYCLE = 60; + public static final String PROV_DIMENTION = "prov"; + public static final String ISP_DIMENTION = "isp"; + public static final String TASK_ID = "taskId"; + public static final String FIRST_UPPERCASE_TASK_ID = "TaskId"; + public static final String SITE_CYCLE = "CYCLE"; + public static final String AGGR_SITE_CYCLE = "cycle"; + public static final String SITE_USERID = "UserId"; + public static final String SITE_REGION = "bj"; + public static final String PACKET_LOSS = "packetLoss"; + public static final String A = "A"; + public static final String AAAA = "AAAA"; + public static final String CNAME = "CNAME"; + public static final Integer SITE_IS_DELETE_FLAG = 1; + public static final Integer SITE_NO_DELETE_FLAG = 0; + public static final String REACH_EXPECT = "符合预期"; + public static final String NO_REACH_EXPECT = "解析结果不符合预期"; + public static final String NOT_MATCH = "-"; + public static final String SITE_AUTO_RENEW_REGION = "global"; + public static final String SITE_AUTO_RENEW_SERVICE = "BCM"; + + public static final String SITE_ONCE_CONNECT_TIME = "connectTime"; + public static final String SITE_ONCE_DNS_TIME = "dnsTime"; + public static final String SITE_ONCE_TOTAL_TIME = "totalTime"; + public static final String SITE_ONCE_AVGRTT_TIME = "avgRTT"; + public static final String SITE_ONCE_REDIRECT_TIME = "redirectTime"; + public static final String SITE_ONCE_FIRST_BYTE_TIME = "firstByteTime"; + public static final String SITE_ONCE_PACKET_LOSS = "packetLoss"; + public static final String SITE_ONCE_DNS_KIDNAP = "dnsKidnap"; + + public static final String SITE_IP_RUNNING = "RUNNING"; + public static final String SITE_IP_STOPPED = "STOPPED"; + + public static final String IP_ERR_RATE = "errRate"; + public static final String IP_TOTAL_TIME = "totalTime"; + public static final String IP_PACKET_LOSS = "packetLoss"; + public static final String IP_RTT = "rtt"; + + public static final String SITE_HTTPS_PROTOCOL = "https://"; + public static final String SITE_HTTP_PROTOCOL = "http://"; + + public static final List SITE_AGGR_METRIC_NAME = Arrays.asList( + "connectTime", "dnsTime", "firstByteTime", "packetLoss", "totalTime", "success", + "redirectTime", "tlsTime", "downloadTime"); + + public static final Map METRIC_NAME = new HashMap(); + + public static final Map AREA_MAP = new HashMap(); + public static final Map ISP_MAP = new HashMap(); + public static final Map AVERAGE_MAP = new HashMap(); + public static final Map AGGR_GROUP_BY_MAP = new HashMap(); + public static final Map PROV_ISP_MAP = new HashMap(); + + static { + AREA_MAP.put("anhui", "安徽"); + AREA_MAP.put("beijing", "北京"); + AREA_MAP.put("fujian", "福建"); + AREA_MAP.put("gansu", "甘肃"); + AREA_MAP.put("guangdong", "广东"); + AREA_MAP.put("guangxi", "广西"); + AREA_MAP.put("guizhou", "贵州"); + AREA_MAP.put("hainan", "海南"); + AREA_MAP.put("hebei", "河北"); + AREA_MAP.put("henan", "河南"); + AREA_MAP.put("heilongjiang", "黑龙江"); + AREA_MAP.put("hubei", "湖北"); + AREA_MAP.put("hunan", "湖南"); + AREA_MAP.put("jilin", "吉林"); + AREA_MAP.put("jiangsu", "江苏"); + AREA_MAP.put("jiangxi", "江西"); + AREA_MAP.put("liaoning", "辽宁"); + AREA_MAP.put("neimenggu", "内蒙古"); + AREA_MAP.put("ningxia", "宁夏"); + AREA_MAP.put("qinghai", "青海"); + AREA_MAP.put("shandong", "山东"); + AREA_MAP.put("shanxi", "山西"); + AREA_MAP.put("shaanxi", "陕西"); + AREA_MAP.put("shanghai", "上海"); + AREA_MAP.put("sichuan", "四川"); + AREA_MAP.put("tianjin", "天津"); + AREA_MAP.put("xizang", "西藏"); + AREA_MAP.put("xinjiang", "新疆"); + AREA_MAP.put("zhejiang", "浙江"); + AREA_MAP.put("chongqing", "重庆"); + AREA_MAP.put("hunnan", "云南"); + + ISP_MAP.put("CHINANET", "电信"); + ISP_MAP.put("CMNET", "移动"); + ISP_MAP.put("UNICOM", "联通"); + + AVERAGE_MAP.put("average", "全网均值"); + + AGGR_GROUP_BY_MAP.put("isp", "userId&serviceName&taskId&isp"); + AGGR_GROUP_BY_MAP.put("all", "userId&serviceName&taskId"); + + METRIC_NAME.put("connectTime", "建连时间"); + METRIC_NAME.put("dnsTime", "DNS解析时间"); + METRIC_NAME.put("firstByteTime", "首包时间"); + METRIC_NAME.put("packetLoss", "丢包率"); + METRIC_NAME.put("totalTime", "响应时间"); + METRIC_NAME.put("success", "可用率"); + METRIC_NAME.put("redirectTime", "重定向时间"); + METRIC_NAME.put("tlsTime", "TLS时间"); + METRIC_NAME.put("downloadTime", "下载时间"); + METRIC_NAME.put("dnsKidnap", "DNS劫持率"); + + PROV_ISP_MAP.put("prov", "省份"); + PROV_ISP_MAP.put("isp", "运营商"); + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceAgent.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceAgent.java new file mode 100644 index 00000000..1f6197bd --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceAgent.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bcm.model.siteonce; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SiteOnceAgent { + private boolean whiteUser; + private Set siteAgents; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceConfig.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceConfig.java new file mode 100644 index 00000000..694bc453 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceConfig.java @@ -0,0 +1,59 @@ +package com.baidubce.services.bcm.model.siteonce; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class SiteOnceConfig { + + /**HTTP/HTTPS请求方法*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String method; + /**HTTP/HTTPS请求方法为POST时的提交内容*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String postContent; + + /** + * RECURSION:递归解析 ITERATION:迭代解析(不设置,默认为RECURSION) + */ + private ResolveTypeEnum resolveType = ResolveTypeEnum.RECURSION; + /** + * DNS服务器(可选,如无需求,不需要设置) + */ + private String server; + /** + * 劫持白名单,形如:www.baidu.com:1.2.3.4|a.b.c.d|* + * 每一个ip/cname用 "|" 分割,支持通配符 + * ipv4: 192.168.1.* 或者 192.168.1.1~254 + * ipv6: 2400:A480:aa:400:a1:b2:c3:* 或者 2400:A480:aa:400:a1:b2:C3:0~FFFF + * cname: www.baidu.com 或者 *baidu.com 或者 www.*.com 或者 www.baidu.* 或者 * + */ + private String kidnapWhite; + + /**PING发包数*/ + private int packetCount; + + /**TCP/UDP/FTP端口号*/ + private int port; + /**UDP请求内容格式*/ + private int inputType; + /**UDP请求内容*/ + private String input; + /**UDP响应内容匹配格式*/ + private int outputType; + /**UDP响应匹配内容*/ + private String expectedOutput; + + /**是否匿名登录*/ + private boolean anonymousLogin; + /**FTP登陆用户名*/ + private String username; + /**FTP登陆密码*/ + private String password; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceDetail.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceDetail.java new file mode 100644 index 00000000..bc315b7d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceDetail.java @@ -0,0 +1,32 @@ +package com.baidubce.services.bcm.model.siteonce; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SiteOnceDetail { + private long id; + private SiteAgentRegion region; + private String agentProv; + private String agentIsp; + private String clientIp; + private String clientCity; + private String remoteAddr; + private String remoteArea; + private String remoteCity; + private String remoteCounty; + private List analysisResult; + private String ipProtocol; + private Map metrics; + private BigDecimal success; + private Date monitorTime; + private String status; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceGroupTask.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceGroupTask.java new file mode 100644 index 00000000..d8a31fe4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceGroupTask.java @@ -0,0 +1,32 @@ +package com.baidubce.services.bcm.model.siteonce; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Set; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class SiteOnceGroupTask { + private int totalNum; + private int sumSampleNum; + private int pageNo; + private int pageSize; + private String order; + private String orderBy; + private String filterArea; + private String filterIsp; + private SiteOnceProtocol protocolType; + private String url; + private String taskType; + private String groupId; + private List metricOrder; + private Set allAreas; + private SiteOnceOverview overviewData; + private List detailData; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceOverview.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceOverview.java new file mode 100644 index 00000000..61b88183 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceOverview.java @@ -0,0 +1,19 @@ +package com.baidubce.services.bcm.model.siteonce; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SiteOnceOverview { + private BigDecimal success; + private Map metrics; + private int sumSampleNum; + private int rightSampleNum; + private int errSampleNum; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceProtocol.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceProtocol.java new file mode 100644 index 00000000..814129a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceProtocol.java @@ -0,0 +1,63 @@ +package com.baidubce.services.bcm.model.siteonce; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public enum SiteOnceProtocol { + HTTP, + HTTPS, + PING, + TCP, + UDP, + FTP, + DNS; + + private static final Map> PROTOCOL_METRIC_MAP = + new HashMap>(){{ + put(HTTP, new ArrayList() {{ + add(SiteConstant.SITE_ONCE_TOTAL_TIME); + add(SiteConstant.SITE_ONCE_DNS_TIME); + add(SiteConstant.SITE_ONCE_CONNECT_TIME); + add(SiteConstant.SITE_ONCE_REDIRECT_TIME); + add(SiteConstant.SITE_ONCE_FIRST_BYTE_TIME); + }}); + put(HTTPS, new ArrayList() {{ + add(SiteConstant.SITE_ONCE_TOTAL_TIME); + add(SiteConstant.SITE_ONCE_DNS_TIME); + add(SiteConstant.SITE_ONCE_CONNECT_TIME); + add(SiteConstant.SITE_ONCE_REDIRECT_TIME); + add(SiteConstant.SITE_ONCE_FIRST_BYTE_TIME); + }}); + put(PING, new ArrayList() {{ + add(SiteConstant.SITE_ONCE_AVGRTT_TIME); + add(SiteConstant.SITE_ONCE_PACKET_LOSS); + }}); + put(TCP, new ArrayList() {{ + add(SiteConstant.SITE_ONCE_TOTAL_TIME); + add(SiteConstant.SITE_ONCE_CONNECT_TIME); + add(SiteConstant.SITE_ONCE_DNS_TIME); + }}); + put(UDP, new ArrayList() {{ + add(SiteConstant.SITE_ONCE_TOTAL_TIME); + add(SiteConstant.SITE_ONCE_DNS_TIME); + }}); + put(FTP, new ArrayList() {{ + add(SiteConstant.SITE_ONCE_TOTAL_TIME); + add(SiteConstant.SITE_ONCE_CONNECT_TIME); + add(SiteConstant.SITE_ONCE_DNS_TIME); + }}); + put(DNS, new ArrayList() {{ + add(SiteConstant.SITE_ONCE_TOTAL_TIME); + add(SiteConstant.SITE_ONCE_DNS_TIME); + add(SiteConstant.SITE_ONCE_DNS_KIDNAP); + }}); + }}; + + public static Map> getProtocolMetricMap() { + return PROTOCOL_METRIC_MAP; + } + +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceRecord.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceRecord.java new file mode 100644 index 00000000..a94aa639 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceRecord.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bcm.model.siteonce; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SiteOnceRecord { + private String siteId; + private String groupId; + private String userId; + private String taskType; + private String ipType; + private SiteOnceProtocol protocolType; + private String url; + private int sumSampleNum; + private int agentNum; + private BigDecimal success; + private Date monitorTime; + private Date createTime; + private String status; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceRequest.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceRequest.java new file mode 100644 index 00000000..c4f0c9be --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceRequest.java @@ -0,0 +1,51 @@ +package com.baidubce.services.bcm.model.siteonce; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class SiteOnceRequest extends AbstractBceRequest { + + /**用户id*/ + private String userId; + /**探测地址*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String address; + /**探测点ip类型*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String ipType; + /**重新探测创建的任务属于同一个group*/ + private String groupId; + /**探测点*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String idc; + /**任务协议类型*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private SiteOnceProtocol protocolType; + /**任务类型*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String taskType; + /**超时时间*/ + private int timeout; + + /**探测任务普通配置*/ + private SiteOnceConfig onceConfig; + /**是否开启高级配置*/ + @JsonInclude(JsonInclude.Include.NON_NULL) + private Boolean advancedFlag; + /**高级配置内容*/ + private SiteAdvancedConfig advancedConfig = new SiteAdvancedConfig(); + @Override + public SiteOnceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTask.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTask.java new file mode 100644 index 00000000..c10386ee --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTask.java @@ -0,0 +1,40 @@ +package com.baidubce.services.bcm.model.siteonce; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; +import java.util.Set; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SiteOnceTask { + private int totalNum; + private int pageNo; + private int pageSize; + private String order; + private String orderBy; + private String filterArea; + private String filterIsp; + private String status; + private SiteOnceProtocol protocolType; + private String url; + private String taskType; + private int agentNum; + private Date monitorTime; + private Date createTime; + private String siteId; + private String jobId; + private String groupId; + private String userId; + private Set allAreas; + private List metricOrder; + private SiteOnceOverview overviewData; + private List detailData; + private SiteOnceRequest taskConfig; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTaskList.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTaskList.java new file mode 100644 index 00000000..0a880714 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTaskList.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bcm.model.siteonce; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SiteOnceTaskList { + private int pageNo; + private int pageSize; + private int totalCount; + private List taskList; +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTaskRequest.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTaskRequest.java new file mode 100644 index 00000000..6ba3113f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTaskRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bcm.model.siteonce; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class SiteOnceTaskRequest extends AbstractBceRequest { + private String siteId; + private String userId; + private String groupId; + private int pageNo; + private int pageSize; + private String filterArea; + private String filterIsp; + private String order; + private String orderBy; + private String url; + private List siteIds; + @Override + public SiteOnceTaskRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTaskResponse.java b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTaskResponse.java new file mode 100644 index 00000000..e1e7a0e7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcm/model/siteonce/SiteOnceTaskResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bcm.model.siteonce; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SiteOnceTaskResponse { + private String siteId; + private String groupId; +} diff --git a/src/main/java/com/baidubce/services/bec/BecClient.java b/src/main/java/com/baidubce/services/bec/BecClient.java new file mode 100644 index 00000000..b7ff0432 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/BecClient.java @@ -0,0 +1,3150 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.CreateBecAppBlbIpGroupBackendPolicyRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.CreateBecAppBlbIpGroupBackendPolicyResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.CreateBecAppBlbIpGroupMembersRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.CreateBecAppBlbIpGroupMembersResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.CreateBecAppBlbIpGroupRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.CreateBecAppBlbIpGroupResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.DeleteBecAppBlbIpGroupBackendPoliciesRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.DeleteBecAppBlbIpGroupBackendPoliciesResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.DeleteBecAppBlbIpGroupMembersRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.DeleteBecAppBlbIpGroupMembersResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.DeleteBecAppBlbIpGroupRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.DeleteBecAppBlbIpGroupResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.GetBecAppBlbIpGroupBackendPoliciesRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.GetBecAppBlbIpGroupBackendPoliciesResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.GetBecAppBlbIpGroupMembersRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.GetBecAppBlbIpGroupMembersResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.GetBecAppBlbIpGroupsRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.GetBecAppBlbIpGroupsResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.UpdateBecAppBlbIpGroupBackendPolicyRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.UpdateBecAppBlbIpGroupBackendPolicyResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.UpdateBecAppBlbIpGroupMembersRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.UpdateBecAppBlbIpGroupMembersResponse; +import com.baidubce.services.bec.model.appblbv2.backendbind.UpdateBecAppBlbIpGroupRequest; +import com.baidubce.services.bec.model.appblbv2.backendbind.UpdateBecAppBlbIpGroupResponse; +import com.baidubce.services.bec.model.appblbv2.instance.CreateBecAppBlbRequest; +import com.baidubce.services.bec.model.appblbv2.instance.CreateBecAppBlbResponse; +import com.baidubce.services.bec.model.appblbv2.instance.DeleteBecAppBlbRequest; +import com.baidubce.services.bec.model.appblbv2.instance.DeleteBecAppBlbResponse; +import com.baidubce.services.bec.model.appblbv2.instance.GetBecAppBlbRequest; +import com.baidubce.services.bec.model.appblbv2.instance.GetBecAppBlbResponse; +import com.baidubce.services.bec.model.appblbv2.instance.GetBecAppBlbsRequest; +import com.baidubce.services.bec.model.appblbv2.instance.GetBecAppBlbsResponse; +import com.baidubce.services.bec.model.appblbv2.instance.UpdateBecAppBlbRequest; +import com.baidubce.services.bec.model.appblbv2.instance.UpdateBecAppBlbResponse; +import com.baidubce.services.bec.model.appblbv2.listener.BatchDeleteBecAppBlbListenersRequest; +import com.baidubce.services.bec.model.appblbv2.listener.BatchDeleteBecAppBlbListenersResponse; +import com.baidubce.services.bec.model.appblbv2.listener.CreateBecAppBlbListenerPoliciesRequest; +import com.baidubce.services.bec.model.appblbv2.listener.CreateBecAppBlbListenerPoliciesResponse; +import com.baidubce.services.bec.model.appblbv2.listener.CreateBecAppBlbTCPListenerRequest; +import com.baidubce.services.bec.model.appblbv2.listener.CreateBecAppBlbTCPListenerResponse; +import com.baidubce.services.bec.model.appblbv2.listener.CreateBecAppBlbUDPListenerRequest; +import com.baidubce.services.bec.model.appblbv2.listener.CreateBecAppBlbUDPListenerResponse; +import com.baidubce.services.bec.model.appblbv2.listener.DeleteBecAppBlbListenerPoliciesRequest; +import com.baidubce.services.bec.model.appblbv2.listener.DeleteBecAppBlbListenerPoliciesResponse; +import com.baidubce.services.bec.model.appblbv2.listener.GetBecAppBlbListenerPoliciesRequest; +import com.baidubce.services.bec.model.appblbv2.listener.GetBecAppBlbListenerPoliciesResponse; +import com.baidubce.services.bec.model.appblbv2.listener.GetBecAppBlbTCPListenersRequest; +import com.baidubce.services.bec.model.appblbv2.listener.GetBecAppBlbTCPListenersResponse; +import com.baidubce.services.bec.model.appblbv2.listener.GetBecAppBlbUDPListenersRequest; +import com.baidubce.services.bec.model.appblbv2.listener.GetBecAppBlbUDPListenersResponse; +import com.baidubce.services.bec.model.appblbv2.listener.UpdateBecAppBlbTCPListenerRequest; +import com.baidubce.services.bec.model.appblbv2.listener.UpdateBecAppBlbTCPListenerResponse; +import com.baidubce.services.bec.model.appblbv2.listener.UpdateBecAppBlbUDPListenerRequest; +import com.baidubce.services.bec.model.appblbv2.listener.UpdateBecAppBlbUDPListenerResponse; +import com.baidubce.services.bec.model.blb.CreateBecBlbBindingRequest; +import com.baidubce.services.bec.model.blb.CreateBecBlbBindingResponse; +import com.baidubce.services.bec.model.blb.CreateBecBlbMonitorPortRequest; +import com.baidubce.services.bec.model.blb.CreateBecBlbMonitorPortResponse; +import com.baidubce.services.bec.model.blb.CreateBecBlbRequest; +import com.baidubce.services.bec.model.blb.CreateBecBlbResponse; +import com.baidubce.services.bec.model.blb.DeleteBecBlbRequest; +import com.baidubce.services.bec.model.blb.DeleteBecBlbResponse; +import com.baidubce.services.bec.model.blb.GetBecBlbBackendBindingStsListRequest; +import com.baidubce.services.bec.model.blb.GetBecBlbBackendBindingStsListResponse; +import com.baidubce.services.bec.model.blb.GetBecBlbBackendPodListRequest; +import com.baidubce.services.bec.model.blb.GetBecBlbBackendPodListResponse; +import com.baidubce.services.bec.model.blb.GetBecBlbBindingPodListWithStsRequest; +import com.baidubce.services.bec.model.blb.GetBecBlbBindingPodListWithStsResponse; +import com.baidubce.services.bec.model.blb.GetBecBlbMonitorPortDetailsRequest; +import com.baidubce.services.bec.model.blb.GetBecBlbMonitorPortDetailsResponse; +import com.baidubce.services.bec.model.blb.GetBecBlbMonitorPortListRequest; +import com.baidubce.services.bec.model.blb.GetBecBlbMonitorPortListResponse; +import com.baidubce.services.bec.model.blb.GetBecBlbInstanceRequest; +import com.baidubce.services.bec.model.blb.GetBecBlbResourceMetricsRequest; +import com.baidubce.services.bec.model.blb.GetBecBlbResourceMetricsResponse; +import com.baidubce.services.bec.model.blb.GetBecBlbInstanceResponse; +import com.baidubce.services.bec.model.blb.GetBecBlbsRequest; +import com.baidubce.services.bec.model.blb.GetBecBlbsResponse; +import com.baidubce.services.bec.model.blb.UpdateBecBlbBindPodWeightRequest; +import com.baidubce.services.bec.model.blb.UpdateBecBlbBindPodWeightResponse; +import com.baidubce.services.bec.model.blb.UpdateBecBlbMonitorPortRequest; +import com.baidubce.services.bec.model.blb.UpdateBecBlbMonitorPortResponse; +import com.baidubce.services.bec.model.blb.UpdateBecBlbRequest; +import com.baidubce.services.bec.model.blb.UpdateBecBlbResponse; +import com.baidubce.services.bec.model.handler.BecHttpResponseHandler; +import com.baidubce.services.bec.model.network.acl.BatchCreateBecAclRulesRequest; +import com.baidubce.services.bec.model.network.acl.BatchCreateBecAclRulesResponse; +import com.baidubce.services.bec.model.network.acl.BatchDeleteBecAclRulesRequest; +import com.baidubce.services.bec.model.network.acl.BatchDeleteBecAclRulesResponse; +import com.baidubce.services.bec.model.network.acl.GetBecAclRequest; +import com.baidubce.services.bec.model.network.acl.GetBecAclResponse; +import com.baidubce.services.bec.model.network.acl.GetBecAclsRequest; +import com.baidubce.services.bec.model.network.acl.GetBecAclsResponse; +import com.baidubce.services.bec.model.network.acl.UpdateBecAclRequest; +import com.baidubce.services.bec.model.network.acl.UpdateBecAclResponse; +import com.baidubce.services.bec.model.network.acl.UpdateBecAclRuleRequest; +import com.baidubce.services.bec.model.network.acl.UpdateBecAclRuleResponse; +import com.baidubce.services.bec.model.network.nat.dnatrule.BatchCreateBecDnatRulesRequest; +import com.baidubce.services.bec.model.network.nat.dnatrule.BatchCreateBecDnatRulesResponse; +import com.baidubce.services.bec.model.network.nat.dnatrule.BatchDeleteBecDnatRulesRequest; +import com.baidubce.services.bec.model.network.nat.dnatrule.BatchDeleteBecDnatRulesResponse; +import com.baidubce.services.bec.model.network.nat.dnatrule.CreateBecDnatRuleRequest; +import com.baidubce.services.bec.model.network.nat.dnatrule.CreateBecDnatRuleResponse; +import com.baidubce.services.bec.model.network.nat.dnatrule.GetBecDnatRulesRequest; +import com.baidubce.services.bec.model.network.nat.dnatrule.GetBecDnatRulesResponse; +import com.baidubce.services.bec.model.network.nat.dnatrule.UpdateBecDnatRuleRequest; +import com.baidubce.services.bec.model.network.nat.dnatrule.UpdateBecDnatRuleResponse; +import com.baidubce.services.bec.model.network.nat.instance.BatchCreateBecNatsRequest; +import com.baidubce.services.bec.model.network.nat.instance.BatchCreateBecNatsResponse; +import com.baidubce.services.bec.model.network.nat.instance.BatchDeleteBecNatsRequest; +import com.baidubce.services.bec.model.network.nat.instance.BatchDeleteBecNatsResponse; +import com.baidubce.services.bec.model.network.nat.instance.GetBecNatMetricsRequest; +import com.baidubce.services.bec.model.network.nat.instance.GetBecNatMetricsResponse; +import com.baidubce.services.bec.model.network.nat.instance.GetBecNatRequest; +import com.baidubce.services.bec.model.network.nat.instance.GetBecNatResponse; +import com.baidubce.services.bec.model.network.nat.instance.GetBecNatsRequest; +import com.baidubce.services.bec.model.network.nat.instance.GetBecNatsResponse; +import com.baidubce.services.bec.model.network.nat.instance.UpdateBecNatBandwidthRequest; +import com.baidubce.services.bec.model.network.nat.instance.UpdateBecNatBandwidthResponse; +import com.baidubce.services.bec.model.network.nat.instance.UpdateBecNatRequest; +import com.baidubce.services.bec.model.network.nat.instance.UpdateBecNatResponse; +import com.baidubce.services.bec.model.network.nat.snatrule.BatchCreateBecSnatRulesRequest; +import com.baidubce.services.bec.model.network.nat.snatrule.BatchCreateBecSnatRulesResponse; +import com.baidubce.services.bec.model.network.nat.snatrule.BatchDeleteBecSnatRulesRequest; +import com.baidubce.services.bec.model.network.nat.snatrule.BatchDeleteBecSnatRulesResponse; +import com.baidubce.services.bec.model.network.nat.snatrule.CreateBecSnatRuleRequest; +import com.baidubce.services.bec.model.network.nat.snatrule.CreateBecSnatRuleResponse; +import com.baidubce.services.bec.model.network.nat.snatrule.GetBecSnatRulesRequest; +import com.baidubce.services.bec.model.network.nat.snatrule.GetBecSnatRulesResponse; +import com.baidubce.services.bec.model.network.nat.snatrule.UpdateBecSnatRuleRequest; +import com.baidubce.services.bec.model.network.nat.snatrule.UpdateBecSnatRuleResponse; +import com.baidubce.services.bec.model.network.route.CreateBecRouteRuleRequest; +import com.baidubce.services.bec.model.network.route.CreateBecRouteRuleResponse; +import com.baidubce.services.bec.model.network.route.DeleteBecRouteRuleRequest; +import com.baidubce.services.bec.model.network.route.DeleteBecRouteRuleResponse; +import com.baidubce.services.bec.model.network.route.GetBecRouteRulesRequest; +import com.baidubce.services.bec.model.network.route.GetBecRouteRulesResponse; +import com.baidubce.services.bec.model.network.route.GetBecRouteTableRequest; +import com.baidubce.services.bec.model.network.route.GetBecRouteTableResponse; +import com.baidubce.services.bec.model.network.route.GetBecRouteTablesRequest; +import com.baidubce.services.bec.model.network.route.GetBecRouteTablesResponse; +import com.baidubce.services.bec.model.network.route.UpdateBecRouteTableRequest; +import com.baidubce.services.bec.model.network.route.UpdateBecRouteTableResponse; +import com.baidubce.services.bec.model.network.securitygroup.BatchCreateBecSgRulesRequest; +import com.baidubce.services.bec.model.network.securitygroup.BatchCreateBecSgRulesResponse; +import com.baidubce.services.bec.model.network.securitygroup.BatchDeleteBecSgRulesRequest; +import com.baidubce.services.bec.model.network.securitygroup.BatchDeleteBecSgRulesResponse; +import com.baidubce.services.bec.model.network.securitygroup.CreateBecSecurityGroupRequest; +import com.baidubce.services.bec.model.network.securitygroup.CreateBecSecurityGroupResponse; +import com.baidubce.services.bec.model.network.securitygroup.DeleteBecSecurityGroupRequest; +import com.baidubce.services.bec.model.network.securitygroup.DeleteBecSecurityGroupResponse; +import com.baidubce.services.bec.model.network.securitygroup.GetBecSecurityGroupRequest; +import com.baidubce.services.bec.model.network.securitygroup.GetBecSecurityGroupResponse; +import com.baidubce.services.bec.model.network.securitygroup.GetBecSecurityGroupsRequest; +import com.baidubce.services.bec.model.network.securitygroup.GetBecSecurityGroupsResponse; +import com.baidubce.services.bec.model.network.securitygroup.UpdateBecSecurityGroupRequest; +import com.baidubce.services.bec.model.network.securitygroup.UpdateBecSecurityGroupResponse; +import com.baidubce.services.bec.model.network.securitygroup.UpdateBecSecurityGroupRuleRequest; +import com.baidubce.services.bec.model.network.securitygroup.UpdateBecSecurityGroupRuleResponse; +import com.baidubce.services.bec.model.network.subnet.CreateBecSubnetRequest; +import com.baidubce.services.bec.model.network.subnet.CreateBecSubnetResponse; +import com.baidubce.services.bec.model.network.subnet.DeleteBecSubnetRequest; +import com.baidubce.services.bec.model.network.subnet.DeleteBecSubnetResponse; +import com.baidubce.services.bec.model.network.subnet.GetBecSubnetRequest; +import com.baidubce.services.bec.model.network.subnet.GetBecSubnetResponse; +import com.baidubce.services.bec.model.network.subnet.GetBecSubnetsRequest; +import com.baidubce.services.bec.model.network.subnet.GetBecSubnetsResponse; +import com.baidubce.services.bec.model.network.subnet.UpdateBecSubnetRequest; +import com.baidubce.services.bec.model.network.subnet.UpdateBecSubnetResponse; +import com.baidubce.services.bec.model.network.vpc.CreateBecVpcRequest; +import com.baidubce.services.bec.model.network.vpc.CreateBecVpcResponse; +import com.baidubce.services.bec.model.network.vpc.DeleteBecVpcRequest; +import com.baidubce.services.bec.model.network.vpc.DeleteBecVpcResponse; +import com.baidubce.services.bec.model.network.vpc.GetBecVpcRequest; +import com.baidubce.services.bec.model.network.vpc.GetBecVpcResponse; +import com.baidubce.services.bec.model.network.vpc.GetBecVpcsRequest; +import com.baidubce.services.bec.model.network.vpc.GetBecVpcsResponse; +import com.baidubce.services.bec.model.network.vpc.UpdateBecVpcRequest; +import com.baidubce.services.bec.model.network.vpc.UpdateBecVpcResponse; +import com.baidubce.services.bec.model.overview.GetBecContainerMetricsRequest; +import com.baidubce.services.bec.model.overview.GetBecContainerMetricsResponse; +import com.baidubce.services.bec.model.overview.GetBecContainerSummaryRequest; +import com.baidubce.services.bec.model.overview.GetBecContainerSummaryResponse; +import com.baidubce.services.bec.model.overview.GetBecResourceSummaryRequest; +import com.baidubce.services.bec.model.overview.GetBecResourceSummaryResponse; +import com.baidubce.services.bec.model.overview.GetBecVMSummaryRequest; +import com.baidubce.services.bec.model.overview.GetBecVMSummaryResponse; +import com.baidubce.services.bec.model.overview.GetBecVmMetricsRequest; +import com.baidubce.services.bec.model.overview.GetBecVmMetricsResponse; +import com.baidubce.services.bec.model.overview.GetBecVmNodeLevelMetricsRequest; +import com.baidubce.services.bec.model.overview.GetBecVmNodeLevelMetricsResponse; +import com.baidubce.services.bec.model.resource.ListBecPassThroughDiskPackagesRequest; +import com.baidubce.services.bec.model.resource.ListBecPassThroughDiskPackagesResponse; +import com.baidubce.services.bec.model.resource.ListBecServicePackagesRequest; +import com.baidubce.services.bec.model.resource.ListBecServicePackagesResponse; +import com.baidubce.services.bec.model.vm.deployset.CreateBecDeploySetRequest; +import com.baidubce.services.bec.model.vm.deployset.CreateBecDeploySetResponse; +import com.baidubce.services.bec.model.vm.deployset.DeleteBecDeploySetInstancesRequest; +import com.baidubce.services.bec.model.vm.deployset.DeleteBecDeploySetInstancesResponse; +import com.baidubce.services.bec.model.vm.deployset.DeleteBecDeploySetRequest; +import com.baidubce.services.bec.model.vm.deployset.DeleteBecDeploySetResponse; +import com.baidubce.services.bec.model.vm.deployset.GetBecDeploySetRequest; +import com.baidubce.services.bec.model.vm.deployset.GetBecDeploySetResponse; +import com.baidubce.services.bec.model.vm.deployset.GetBecDeploySetsRequest; +import com.baidubce.services.bec.model.vm.deployset.GetBecDeploySetsResponse; +import com.baidubce.services.bec.model.vm.deployset.UpdateBecDeploySetInstanceRequest; +import com.baidubce.services.bec.model.vm.deployset.UpdateBecDeploySetInstanceResponse; +import com.baidubce.services.bec.model.vm.deployset.UpdateBecDeploySetRequest; +import com.baidubce.services.bec.model.vm.deployset.UpdateBecDeploySetResponse; +import com.baidubce.services.bec.model.vm.image.BatchDeleteBecVmImageRequest; +import com.baidubce.services.bec.model.vm.image.BatchDeleteBecVmImageResponse; +import com.baidubce.services.bec.model.vm.image.CreateBecVmImageRequest; +import com.baidubce.services.bec.model.vm.image.CreateBecVmImageResponse; +import com.baidubce.services.bec.model.vm.image.GetBecVmImagesRequest; +import com.baidubce.services.bec.model.vm.image.GetBecVmImagesResponse; +import com.baidubce.services.bec.model.vm.image.UpdateBecVmImageRequest; +import com.baidubce.services.bec.model.vm.image.UpdateBecVmImageResponse; +import com.baidubce.services.bec.model.vm.instance.DeleteBecVmInstanceRequest; +import com.baidubce.services.bec.model.vm.instance.DeleteBecVmInstanceResponse; +import com.baidubce.services.bec.model.vm.instance.GetBecNodeVmInstanceListRequest; +import com.baidubce.services.bec.model.vm.instance.GetBecNodeVmInstanceListResponse; +import com.baidubce.services.bec.model.vm.instance.GetBecVirtualMachineRequest; +import com.baidubce.services.bec.model.vm.instance.GetBecVirtualMachineResponse; +import com.baidubce.services.bec.model.vm.instance.GetBecVmConfigRequest; +import com.baidubce.services.bec.model.vm.instance.GetBecVmConfigResponse; +import com.baidubce.services.bec.model.vm.instance.GetBecVmInstanceListRequest; +import com.baidubce.services.bec.model.vm.instance.GetBecVmInstanceListResponse; +import com.baidubce.services.bec.model.vm.instance.GetBecVmInstanceMetricsRequest; +import com.baidubce.services.bec.model.vm.instance.GetBecVmInstanceMetricsResponse; +import com.baidubce.services.bec.model.vm.instance.OperateBecVmDeploymentRequest; +import com.baidubce.services.bec.model.vm.instance.OperateBecVmDeploymentResponse; +import com.baidubce.services.bec.model.vm.instance.ReinstallBecVmInstanceRequest; +import com.baidubce.services.bec.model.vm.instance.ReinstallBecVmInstanceResponse; +import com.baidubce.services.bec.model.vm.instance.UpdateBecVmDeploymentRequest; +import com.baidubce.services.bec.model.vm.instance.UpdateBecVmDeploymentResponse; +import com.baidubce.services.bec.model.vm.service.BecVmServiceActionRequest; +import com.baidubce.services.bec.model.vm.service.BecVmServiceActionResponse; +import com.baidubce.services.bec.model.vm.service.CreateBecVmServiceRequest; +import com.baidubce.services.bec.model.vm.service.CreateBecVmServiceResponse; +import com.baidubce.services.bec.model.vm.service.DelBecVmServiceRequest; +import com.baidubce.services.bec.model.vm.service.DelBecVmServiceResponse; +import com.baidubce.services.bec.model.vm.service.GetBecVmServiceMetricsRequest; +import com.baidubce.services.bec.model.vm.service.GetBecVmServiceMetricsResponse; +import com.baidubce.services.bec.model.vm.service.GetBecVmServiceRequest; +import com.baidubce.services.bec.model.vm.service.GetBecVmServiceResponse; +import com.baidubce.services.bec.model.vm.service.GetBecVmServicesRequest; +import com.baidubce.services.bec.model.vm.service.GetBecVmServicesResponse; +import com.baidubce.services.bec.model.vm.service.UpdateBecVmServiceRequest; +import com.baidubce.services.bec.model.vm.service.UpdateBecVmServiceResponse; +import com.baidubce.services.bec.model.vm.template.CreateBecVmTemplateRequest; +import com.baidubce.services.bec.model.vm.template.CreateBecVmTemplateResponse; +import com.baidubce.services.bec.model.vm.template.GetBecVmTemplateListRequest; +import com.baidubce.services.bec.model.vm.template.GetBecVmTemplateListResponse; +import com.baidubce.services.bec.model.vm.template.GetBecVmTemplateRequest; +import com.baidubce.services.bec.model.vm.template.GetBecVmTemplateResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkMultyParamsNotBothEmpty; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Baidu Cloud Edge Compute Service(bec). + */ +public class BecClient extends AbstractBceClient { + + private static final String VERSION = "v1"; + private static final String VERSION_2 = "v2"; + private static final String OVERVIEW = "overview"; + private static final String SUMMARY = "summary"; + private static final String CONTAINER = "container"; + private static final String BLB_PREFIX = "blb"; + private static final String LB_PREFIX = "lb"; + private static final String VM_PREFIX = "vm"; + private static final String NODE_PREFIX = "node"; + private static final String DEPLOY_SET_PREFIX = "deployset"; + private static final String VPC_PREFIX = "vpc"; + private static final String SUBNET_PREFIX = "subnet"; + private static final String SECURITY_GROUP_PREFIX = "securityGroup"; + private static final String ROUTE_PREFIX = "route"; + private static final String APP_BLB_PREFIX = "appblb"; + private static final String NAT_PREFIX = "nat"; + private static final String SERVICE = "service"; + private static final String INSTANCE = "instance"; + private static final String TEMPLATE = "template"; + private static final String IMAGE = "image"; + private static final String METRICS = "metrics"; + private static final String ACL = "acl"; + private static final String RULE = "rule"; + private static final String BATCH = "batch"; + private static final String DELETE = "delete"; + private static final String ADD = "add"; + private static final String UPDATE = "update"; + private static final String DETAIL = "detail"; + private static final String REGIONS = "regions"; + private static final String SERVICE_PROVIDER = "sps"; + private static final String CITIES = "cities"; + private static final String SYSTEM = "system"; + private static final String CONFIG = "config"; + private static final String REINSTALL = "reinstall"; + private static final String MONITOR = "monitor"; + private static final String RESOURCE = "resource"; + private static final String PACKAGE = "package"; + private static final String DISK = "disk"; + private static final String PASS_THROUGH = "passthrough"; + private static final String BINDED = "binded"; + private static final String BINDING = "binding"; + private static final String BINDINGPOD = "bindingpod"; + private static final String PORT = "port"; + private static final String CLIENT_TOKEN = "clientToken"; + private static final String CREATE = "create"; + private static final String LIST = "list"; + private static final String DEL_RELATION = "delRelation"; + private static final String UPDATE_RELATION = "updateRelation"; + private static final String TCP_LISTENER = "TCPlistener"; + private static final String UDP_LISTENER = "UDPlistener"; + private static final String POLICYS = "policys"; + private static final String LISTENER = "listener"; + private static final String IP_GROUP = "ipgroup"; + private static final String UPDATE_BANDWIDTH = "updateBandwidth"; + private static final String BACKEND_POLICY = "backendpolicy"; + private static final String MEMBER = "member"; + private static final String SNAT_RULE = "snatRule"; + private static final String DNAT_RULE = "dnatRule"; + private static final String BATCH_CREATE = "batchCreate"; + private static final String BATCH_DELETE = "batchdelete"; + + /** + * List selection keywords. + */ + private static final String MARKER = "marker"; + private static final String MAX_KEYS = "maxKeys"; + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String OFFSET_IN_SECONDS_NULL_ERROR_MESSAGE = "offsetInSeconds should not be null."; + private static final String BLB_ID_MESSAGE_KEY = "blbId"; + private static final String BLB_TYPE_MESSAGE_KEY = "type"; + private static final String IP_TYPE_MESSAGE_KEY = "ipType"; + private static final String VM_SERVICE_ID_MESSAGE_KEY = "serviceId"; + private static final String VM_ID_MESSAGE_KEY = "vmId"; + private static final String TEMPLATE_ID_MESSAGE_KEY = "templateId"; + private static final String VM_INSTANCE_REGION_MESSAGE_KEY = "region"; + private static final String VM_INSTANCE_SPS_MESSAGE_KEY = "serviceProvider"; + private static final String VM_INSTANCE_CITY_MESSAGE_KEY = "city"; + private static final String VM_ACTION_MESSAGE_KEY = "action"; + private static final String IMAGE_ID_MESSAGE_KEY = "imageId"; + private static final String IMAGE_ID_LIST_MESSAGE_KEY = "imageIdList"; + private static final String METRICS_TYPE_MESSAGE_KEY = "metricsType"; + private static final String START_MESSAGE_KEY = "start"; + private static final String END_MESSAGE_KEY = "end"; + private static final String DEPLOY_SET_ID_MESSAGE_KEY = "deploySetId"; + private static final String VPC_ID_MESSAGE_KEY = "vpcId"; + private static final String SUBNET_ID_MESSAGE_KEY = "subnetId"; + private static final String INSTANCE_ID_MESSAGE_KEY = "instanceId"; + private static final String SECURITY_GROUP_ID_MESSAGE_KEY = "securityGroupId"; + private static final String SECURITY_GROUP_RULE_ID_MESSAGE_KEY = "securityGroupRuleId"; + private static final String ROUTE_TABLE_ID_MESSAGE_KEY = "tableId"; + private static final String ACL_RULE_ID_MESSAGE_KEY = "aclRuleId"; + private static final String ROUTE_RULE_ID_MESSAGE_KEY = "ruleId"; + private static final String ACL_ID_MESSAGE_KEY = "aclId"; + private static final String NAT_ID_MESSAGE_KEY = "natId"; + private static final String RULE_ID_MESSAGE_KEY = "ruleId"; + private static final String IP_GROUP_ID_MESSAGE_KEY = "ipGroupId"; + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling httpResponses from all bec service calls. + */ + private static final HttpResponseHandler[] bec_handlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BecHttpResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on bec. + */ + public BecClient() { + this(new BecClientConfiguration()); + } + + /** + * Constructs a new bec client using the client configuration to access bec. + * + * @param clientConfiguration The bec client configuration options controlling how this client + * connects to bec (e.g. proxy settings, retry counts, etc). + */ + public BecClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, bec_handlers); + } + + /** + * Creates and initializes a new request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + return commonRequestProcess(bceRequest, httpMethod, path); + } + + /** + * Creates and initializes a new v2 request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new v2 request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequestV2(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION_2); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + return commonRequestProcess(bceRequest, httpMethod, path); + } + + /** + * Common Request Process. + * + * @param bceRequest + * @param httpMethod + * @param path + * @return final InternalRequest. + */ + private InternalRequest commonRequestProcess(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + List path) { + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * Caution: only support HttpMethodName.POST or HttpMethodName.PUT. + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + + /** + * Create a new BEC virtual machine api. + * + * @param request: The request containing all options for creating a bec virtual machine service. + * @return: The response with id of service newly created. + */ + public CreateBecVmServiceResponse createBecVmService(CreateBecVmServiceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VM_PREFIX, SERVICE); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecVmServiceResponse.class); + } + + /** + * create BEC virtual machine instances for service api + * + * @param request: The request contains all options to create a bec virtual machine for the service. + * @return: The response with id of service. + */ + public CreateBecVmServiceResponse createBecVmServiceInstances(CreateBecVmServiceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getServiceId() + , checkEmptyExceptionMessageFormat(VM_SERVICE_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VM_PREFIX, SERVICE, + request.getServiceId(), INSTANCE); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecVmServiceResponse.class); + } + + /** + * Get BEC virtual machine service list + * + * @param request: The request contains all options for getting a list of BEC virtual machine services. + * @return: paged api list, for brief info. + */ + public GetBecVmServicesResponse getBecVmServices(GetBecVmServicesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET + , VM_PREFIX, SERVICE); + if (StringUtils.isNotEmpty(request.getKeywordType())) { + internalRequest.addParameter("keywordType", request.getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getKeyword())) { + internalRequest.addParameter("keyword", request.getKeyword()); + } + if (request.getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + return invokeHttpClient(internalRequest, GetBecVmServicesResponse.class); + } + + /** + * Update BEC virtual machine service. + * + * @param request: The request containing all options for updating the virtual machine service. + * @return: The response contains information about whether the service was successfully updated. + */ + public UpdateBecVmServiceResponse updateBecVmService(UpdateBecVmServiceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getServiceId() + , checkEmptyExceptionMessageFormat(VM_SERVICE_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + VM_PREFIX, SERVICE, request.getServiceId()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecVmServiceResponse.class); + } + + /** + * Get BEC virtual machine service details. + * + * @param request: The request containing all options for getting the api details. + * @return: BEC virtual machine service details. + */ + public GetBecVmServiceResponse getBecVmService(GetBecVmServiceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getServiceId() + , checkEmptyExceptionMessageFormat(VM_SERVICE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET + , VM_PREFIX, SERVICE, request.getServiceId()); + return invokeHttpClient(internalRequest, GetBecVmServiceResponse.class); + } + + /** + * start/stop/release the BEC virtual machine service. + * + * @param request: The request contains all options for operating the virtual machine service. + * @return: The response contains the result of operating the virtual machine service. + */ + public BecVmServiceActionResponse becVmServiceAction(BecVmServiceActionRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getServiceId() + , checkEmptyExceptionMessageFormat(VM_SERVICE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAction() + , checkEmptyExceptionMessageFormat(VM_ACTION_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + VM_PREFIX, SERVICE, request.getServiceId(), request.getAction()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + return invokeHttpClient(internalRequest, BecVmServiceActionResponse.class); + } + + /** + * Delete BEC virtual machine service. + * + * @param request: The request contains the api ID that should be deleted. + * @return: The response contains the result of whether the service was successfully deleted. + */ + public DelBecVmServiceResponse deleteBecVmService(DelBecVmServiceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getServiceId() + , checkEmptyExceptionMessageFormat(VM_SERVICE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, + VM_PREFIX, SERVICE, request.getServiceId()); + return invokeHttpClient(internalRequest, DelBecVmServiceResponse.class); + } + + /** + * Get BEC service metrics. + * + * @param request: The request containing all options for getting BEC service metrics. + * @return: The response contains BEC service metrics. + */ + public GetBecVmServiceMetricsResponse getBecVmServiceMetrics(GetBecVmServiceMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getServiceId() + , checkEmptyExceptionMessageFormat(VM_SERVICE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getType() + , checkEmptyExceptionMessageFormat(METRICS_TYPE_MESSAGE_KEY)); + checkNotNull(request.getOffsetInSeconds(), OFFSET_IN_SECONDS_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, + MONITOR, SERVICE, VM_PREFIX, request.getServiceId()); + if (StringUtils.isNotEmpty(request.getServiceId())) { + internalRequest.addParameter("serviceId", request.getServiceId()); + } + if (StringUtils.isNotEmpty(request.getType())) { + internalRequest.addParameter("metricsType", request.getType()); + } + if (request.getOffsetInSeconds() > 0) { + // 获取整分数据 + long end = Calendar.getInstance().getTimeInMillis() / 1000; + + long start = end - request.getOffsetInSeconds(); + internalRequest.addParameter("start", String.valueOf(start)); + internalRequest.addParameter("end", String.valueOf(end)); + } + if (StringUtils.isNotEmpty(request.getServiceProvider())) { + internalRequest.addParameter("serviceProvider", request.getServiceProvider()); + } + if (request.getStepInMin() != null && request.getStepInMin() > 0) { + internalRequest.addParameter("stepInMin", String.valueOf(request.getStepInMin())); + } + return invokeHttpClient(internalRequest, GetBecVmServiceMetricsResponse.class); + + } + + /** + * Get the list of BEC virtual machine instances. + * + * @param request: optional query parameter, the keyword for deployment name. + * @return: paged deployment list. + */ + public GetBecVmInstanceListResponse getBecVmInstanceList(GetBecVmInstanceListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, + VM_PREFIX, INSTANCE); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getKeywordType())) { + internalRequest.addParameter("keywordType", request.getListRequest().getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getKeyword())) { + internalRequest.addParameter("keyword", request.getListRequest().getKeyword()); + } + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + if (StringUtils.isNotEmpty(request.getListRequest().getOrder())) { + internalRequest.addParameter("order", request.getListRequest().getOrder()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getOrderBy())) { + internalRequest.addParameter("orderBy", request.getListRequest().getOrderBy()); + } + } + return invokeHttpClient(internalRequest, GetBecVmInstanceListResponse.class); + } + + /** + * Get the BEC virtual machine list of the node. + * + * @param request: optional query parameter, the keyword for deployment name. + * @return: deployment list. + */ + public GetBecNodeVmInstanceListResponse getBecNodeVmInstanceList(GetBecNodeVmInstanceListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getRegion(), checkEmptyExceptionMessageFormat(VM_INSTANCE_REGION_MESSAGE_KEY)); + checkStringNotEmpty(request.getServiceProvider(), + checkEmptyExceptionMessageFormat(VM_INSTANCE_SPS_MESSAGE_KEY)); + checkStringNotEmpty(request.getCity(), checkEmptyExceptionMessageFormat(VM_INSTANCE_CITY_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VM_PREFIX, INSTANCE, REGIONS, + request.getRegion(), SERVICE_PROVIDER, request.getServiceProvider(), CITIES, request.getCity()); + return invokeHttpClient(internalRequest, GetBecNodeVmInstanceListResponse.class); + } + + /** + * Get the details of the BEC virtual machine. + * + * @param request: The request contains all the options for getting the details of the BEC virtual machine. + * @return: deployment details. + */ + public GetBecVirtualMachineResponse getBecVmInstance(GetBecVirtualMachineRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVmID(), checkEmptyExceptionMessageFormat(VM_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VM_PREFIX, INSTANCE, + request.getVmID()); + return invokeHttpClient(internalRequest, GetBecVirtualMachineResponse.class); + } + + /** + * Delete BEC virtual machine. + * + * @param request: The request contains all options for deleting the BEC virtual machine. + * @return: The response contains the result of whether the Instance was successfully deleted. + */ + public DeleteBecVmInstanceResponse deleteBecVmInstance(DeleteBecVmInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVmID(), checkEmptyExceptionMessageFormat(VM_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, VM_PREFIX, INSTANCE, + request.getVmID()); + return invokeHttpClient(internalRequest, DeleteBecVmInstanceResponse.class); + } + + /** + * Update BEC virtual machine resources. + * + * @param request: The request contains all the options for updating BEC virtual machine resources. + * @return: The response contains information about whether the instance was successfully updated. + */ + public UpdateBecVmDeploymentResponse updateBecVmDeployment(UpdateBecVmDeploymentRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVmID(), checkEmptyExceptionMessageFormat(VM_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, VM_PREFIX, INSTANCE, + request.getVmID()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecVmDeploymentResponse.class); + } + + /** + * Reinstall the BEC virtual machine system. + * + * @param request: The request contains all the options for reinstalling the BEC virtual machine system. + * @return: The response contains information on whether the system reinstallation was successful. + */ + public ReinstallBecVmInstanceResponse reinstallBecVmInstance(ReinstallBecVmInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVmID(), checkEmptyExceptionMessageFormat(VM_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, VM_PREFIX, INSTANCE, + request.getVmID(), SYSTEM, REINSTALL); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ReinstallBecVmInstanceResponse.class); + } + + /** + * start/stop/restart the BEC virtual machine instance. + * + * @param request: The request contains all options for operating the BEC virtual machine instance. + * @return: The response contains the result of operating the virtual machine instance. + */ + public OperateBecVmDeploymentResponse operateBecVmDeployment(OperateBecVmDeploymentRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVmID(), checkEmptyExceptionMessageFormat(VM_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAction(), checkEmptyExceptionMessageFormat(VM_ACTION_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, VM_PREFIX, INSTANCE, + request.getVmID(), request.getAction()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, OperateBecVmDeploymentResponse.class); + } + + /** + * Get the BEC virtual machine instance metrics. + * + * @param request: The request containing all options for getting bec virtual machine instance metrics. + * @return: The response contains BEC virtual machine instance metrics. + */ + public GetBecVmInstanceMetricsResponse getBecVmInstanceMetrics(GetBecVmInstanceMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVmId(), checkEmptyExceptionMessageFormat(VM_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getType(), checkEmptyExceptionMessageFormat(METRICS_TYPE_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, + MONITOR, VM_PREFIX, request.getVmId()); + if (StringUtils.isNotEmpty(request.getVmId())) { + internalRequest.addParameter("vmId", request.getVmId()); + } + if (StringUtils.isNotEmpty(request.getType())) { + internalRequest.addParameter("metricsType", request.getType()); + } + if (request.getOffsetInSeconds() > 0) { + // 获取整分数据 + long end = Calendar.getInstance().getTimeInMillis() / 1000; + + long start = end - request.getOffsetInSeconds(); + internalRequest.addParameter("start", String.valueOf(start)); + internalRequest.addParameter("end", String.valueOf(end)); + } + if (StringUtils.isNotEmpty(request.getServiceProvider())) { + internalRequest.addParameter("serviceProvider", request.getServiceProvider()); + } + if (request.getStepInMin() != null && request.getStepInMin() > 0) { + internalRequest.addParameter("stepInMin", String.valueOf(request.getStepInMin())); + } + return invokeHttpClient(internalRequest, GetBecVmInstanceMetricsResponse.class); + } + + /** + * Get the BEC node level virtual machine instance metrics. + * + * @param request: The request containing all options for getting bec node level virtual machine instance metrics. + * @return: The response contains BEC node level virtual machine instance metrics. + */ + public GetBecVmNodeLevelMetricsResponse getVmNodeMetrics(GetBecVmNodeLevelMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getType(), checkEmptyExceptionMessageFormat(METRICS_TYPE_MESSAGE_KEY)); + checkStringNotEmpty(request.getRegion(), checkEmptyExceptionMessageFormat(VM_INSTANCE_REGION_MESSAGE_KEY)); + checkStringNotEmpty(request.getCity(), checkEmptyExceptionMessageFormat(VM_INSTANCE_CITY_MESSAGE_KEY)); + checkStringNotEmpty(request.getServiceProvider(), + checkEmptyExceptionMessageFormat(VM_INSTANCE_SPS_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, + MONITOR, OVERVIEW, VM_PREFIX, NODE_PREFIX, request.getType()); + + if (request.getStart() > 0 && request.getEnd() > 0) { + internalRequest.addParameter("start", String.valueOf(request.getStart())); + internalRequest.addParameter("end", String.valueOf(request.getEnd())); + } + + if (StringUtils.isNotEmpty(request.getServiceProvider())) { + internalRequest.addParameter("serviceProvider", request.getServiceProvider()); + } + + if (StringUtils.isNotEmpty(request.getServiceProvider())) { + internalRequest.addParameter("city", request.getCity()); + } + + if (StringUtils.isNotEmpty(request.getServiceProvider())) { + internalRequest.addParameter("region", request.getRegion()); + } + + if (StringUtils.isNotEmpty(request.getNetwork())) { + internalRequest.addParameter("network", request.getNetwork()); + } + + if (request.getStepInMin() != null && request.getStepInMin() > 0) { + internalRequest.addParameter("stepInMin", String.valueOf(request.getStepInMin())); + } + + return invokeHttpClient(internalRequest, GetBecVmNodeLevelMetricsResponse.class); + + } + + /** + * Get the BEC virtual machine instance config. + * + * @param request: The request containing all options for getting BEC virtual machine instance config. + * @return: The response contains BEC virtual machine instance config. + */ + public GetBecVmConfigResponse getBecVmConfig(GetBecVmConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVmID(), checkEmptyExceptionMessageFormat(VM_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VM_PREFIX, INSTANCE, + request.getVmID(), CONFIG); + return invokeHttpClient(internalRequest, GetBecVmConfigResponse.class); + } + + /** + * Create a virtual machine template. + * + * @param request: The request containing all options for creating the BEC vm template. + * @return: The response with id of template newly created. + */ + public CreateBecVmTemplateResponse createBecVmTemplate(CreateBecVmTemplateRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VM_PREFIX, TEMPLATE, CREATE); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecVmTemplateResponse.class); + } + + /** + * Get the list of BEC virtual machine templates. + * + * @param request: The request containing all options for getting the BEC vm template list. + * @return: paged template list. + */ + public GetBecVmTemplateListResponse listBecVmTemplate(GetBecVmTemplateListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VM_PREFIX, TEMPLATE, LIST); + + if (StringUtils.isNotEmpty(request.getKeyword())) { + internalRequest.addParameter("keyword", request.getKeyword()); + } + + if (StringUtils.isNotEmpty(request.getKeywordType())) { + internalRequest.addParameter("keywordType", request.getKeywordType()); + } + + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + + if (request.getPageNo() != 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + + if (request.getPageSize() != 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + + return invokeHttpClient(internalRequest, GetBecVmTemplateListResponse.class); + } + + /** + * Get BEC virtual machine template details. + * + * @param request: The request containing all options for getting the teplate details. + * @return: BEC virtual machine template details. + */ + public GetBecVmTemplateResponse getBecVmTemplate(GetBecVmTemplateRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getTemplateId(), checkEmptyExceptionMessageFormat(TEMPLATE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VM_PREFIX, TEMPLATE, + request.getTemplateId()); + return invokeHttpClient(internalRequest, GetBecVmTemplateResponse.class); + } + + /** + * Create a BEC blb with the specified options. + * + * @param request: The request containing all options for creating the BEC blb. + * @return: The response contains whether the BEC blb was successfully created. + */ + public CreateBecBlbResponse createBecBlb(CreateBecBlbRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, BLB_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecBlbResponse.class); + } + + /** + * Get the BEC blb list. + * + * @param request: The request containing all options for getting the BEC blb list. + * @return: The response contains the created BEC blb list. + */ + public GetBecBlbsResponse getBecBlbs(GetBecBlbsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, BLB_PREFIX); + if (StringUtils.isNotEmpty(request.getLbType())) { + internalRequest.addParameter("lbType", request.getLbType()); + } + if (request.getLbType() != null) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getLbType() != null) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + return invokeHttpClient(internalRequest, GetBecBlbsResponse.class); + } + + /** + * Get the specific BEC blb instance. + * + * @param request: The request containing all options for getting the BEC blb instance info. + * @return: The response contains the created BEC blb instance. + */ + public GetBecBlbInstanceResponse getBecBlb(GetBecBlbInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, BLB_PREFIX, + request.getBlbId()); + return invokeHttpClient(internalRequest, GetBecBlbInstanceResponse.class); + } + + /** + * Delete the specific BEC blb instance. + * + * @param request: The request containing all options for deleting the BEC blb instance. + * @return: The response contains information about whether the BEC blb instance was successfully deleted. + */ + public DeleteBecBlbResponse deleteBecBlb(DeleteBecBlbRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE + , BLB_PREFIX, request.getBlbId()); + return invokeHttpClient(internalRequest, DeleteBecBlbResponse.class); + } + + /** + * Update the specific BEC blb instance. + * + * @param request: The request containing all options for updating the BEC blb instance. + * @return: The response contains information about whether the BLB instance was successfully updated. + */ + public UpdateBecBlbResponse updateBecBlb(UpdateBecBlbRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, BLB_PREFIX, request.getBlbId()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecBlbResponse.class); + } + + /** + * Create the BEC blb monitor port for assign blb. + * + * @param request: The request containing all options for creating the BEC blb monitor port. + * @return: The response contains information on whether the BEC blb monitor port was successfully created. + */ + public CreateBecBlbMonitorPortResponse createBecBlbMonitorPort(CreateBecBlbMonitorPortRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, BLB_PREFIX, + request.getBlbId(), MONITOR); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecBlbMonitorPortResponse.class); + } + + /** + * Get the BEC blb port monitor list for assign blb. + * + * @param request: The request containing all options for getting the BEC blb port monitor list. + * @return paged blb listeners port list, for brief info + */ + public GetBecBlbMonitorPortListResponse getBlbMonitorPortList(GetBecBlbMonitorPortListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, BLB_PREFIX, + request.getBlbId(), MONITOR); + return invokeHttpClient(internalRequest, GetBecBlbMonitorPortListResponse.class); + + } + + /** + * Get the BEC blb monitor port details for assign blb and assign port. + * + * @param request: The request containing all options for getting the BEC blb monitor port details. + * @return: The response contains the BEC blb monitor port details. + */ + public GetBecBlbMonitorPortDetailsResponse getBecBlbMonitorPortDetails(GetBecBlbMonitorPortDetailsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, BLB_PREFIX, + request.getBlbId(), MONITOR, PORT); + if (request.getProtocol() != null) { + internalRequest.addParameter("protocol", String.valueOf(request.getProtocol())); + } + if (request.getPort() != 0) { + internalRequest.addParameter("port", String.valueOf(request.getPort())); + } + return invokeHttpClient(internalRequest, GetBecBlbMonitorPortDetailsResponse.class); + } + + /** + * Update the BEC blb monitor port for assign blb. + * + * @param request: The request containing all options for updating the Blb monitor port. + * @return: The response contains information about whether the BEC blb monitor port was successfully updated. + */ + public UpdateBecBlbMonitorPortResponse updateBecBlbMonitorPort(UpdateBecBlbMonitorPortRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, BLB_PREFIX, + request.getBlbId(), MONITOR); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecBlbMonitorPortResponse.class); + } + + /** + * Get the bind BEC blb backend Pod/Vm list for assign blb. + * + * @param request: The request containing all options for getting the bind BEC blb backend Pod/Vm list. + * @return: paged blb backend pod list, for brief info. + */ + public GetBecBlbBackendPodListResponse getBecBlbBackendPodList(GetBecBlbBackendPodListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, BLB_PREFIX, + request.getBlbId(), BINDED); + return invokeHttpClient(internalRequest, GetBecBlbBackendPodListResponse.class); + } + + /** + * Get the binding BEC blb backend StatefulSet/VmReplicas list for assign blb. + * + * @param request: The request containing all options for getting the binding BEC blb backend + * StatefulSet/VmReplicas list. + * @return: paged blb backend StatefulSet/VmReplicas list, for brief info. + */ + public GetBecBlbBackendBindingStsListResponse getBecBlbBackendBindingStsList(GetBecBlbBackendBindingStsListRequest + request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, BLB_PREFIX, + request.getBlbId(), BINDING); + return invokeHttpClient(internalRequest, GetBecBlbBackendBindingStsListResponse.class); + } + + /** + * Get the binding BEC blb backend Pod/Vm list for assign blb. + * + * @param request: The request containing all options for getting the binding BEC blb backend Pod/Vm list. + * @return: paged blb backend Pod/Vm list, for brief info. + */ + public GetBecBlbBindingPodListWithStsResponse getBecBlbBindingPodListWithSts(GetBecBlbBindingPodListWithStsRequest + request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, BLB_PREFIX + , request.getBlbId(), BINDINGPOD); + if (StringUtils.isNotEmpty(request.getStsName())) { + internalRequest.addParameter("stsName", request.getStsName()); + } + return invokeHttpClient(internalRequest, GetBecBlbBindingPodListWithStsResponse.class); + } + + /** + * Bind the backend StatefulSet/VmReplicas to the specified BEC blb. + * + * @param request: The request containing all options for binding the backend StatefulSet/VmReplicas. + * @return: The response contains information about whether the binding was successful. + */ + public CreateBecBlbBindingResponse createBecBlbBinding(CreateBecBlbBindingRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, BLB_PREFIX + , request.getBlbId(), BINDING); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecBlbBindingResponse.class); + } + + /** + * Modify the weight of the Pod/Vm bound to the specified BEC BLB backend. + * + * @param request: The request containing all options for modifying the weight of the Pod/Vm. + * @return: The response contains information about whether the weight modification was successful. + */ + public UpdateBecBlbBindPodWeightResponse updateBecBlbBindPodWeight(UpdateBecBlbBindPodWeightRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, BLB_PREFIX + , request.getBlbId(), BINDED); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecBlbBindPodWeightResponse.class); + } + + /** + * Get the BEC blb monitor metrics. + * + * @param request: The request containing all options for getting the BEC blb monitor metrics. + * @return: The response contains the BEC blb monitor metrics. + */ + public GetBecBlbResourceMetricsResponse getBecBlbResourceMetrics(GetBecBlbResourceMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkNotNull(request.getStart(), START_MESSAGE_KEY); + checkNotNull(request.getEnd(), END_MESSAGE_KEY); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, MONITOR, LB_PREFIX, + request.getBlbId()); + if (StringUtils.isNotEmpty(request.getMetricsType())) { + internalRequest.addParameter("metricsType", request.getMetricsType()); + } + if (StringUtils.isNotEmpty(request.getIpType())) { + internalRequest.addParameter("ipType", request.getIpType()); + } + if (request.getStart() > 0 && request.getEnd() > 0) { + internalRequest.addParameter("start", String.valueOf(request.getStart())); + internalRequest.addParameter("end", String.valueOf(request.getEnd())); + } + if (StringUtils.isNotEmpty(request.getPort())) { + internalRequest.addParameter("port", request.getPort()); + } + if (StringUtils.isNotEmpty(request.getServiceProvider())) { + internalRequest.addParameter("serviceProvider", request.getServiceProvider()); + } + return invokeHttpClient(internalRequest, GetBecBlbResourceMetricsResponse.class); + } + + /** + * Get the BEC user level overview data. + * + * @param request: The request containing all options for getting the BEC user level overview data. + * @return user level data, include service/deployment/pod status + */ + public GetBecResourceSummaryResponse getBecResourceSummary(GetBecResourceSummaryRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, OVERVIEW, SUMMARY); + if (StringUtils.isNotEmpty(request.getRegion())) { + internalRequest.addParameter("region", request.getRegion()); + } + return invokeHttpClient(internalRequest, GetBecResourceSummaryResponse.class); + } + + /** + * Get overview information of container services. + * + * @param request: The request containing all options for getting overview information of container services. + * @return user level data,container service overview information. + */ + public GetBecContainerSummaryResponse getBecContainerSummary(GetBecContainerSummaryRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, OVERVIEW, SUMMARY, CONTAINER); + return invokeHttpClient(internalRequest, GetBecContainerSummaryResponse.class); + } + + /** + * Get overview information of vm services. + * + * @param request: The request containing all options for getting overview information of vm services. + * @return user level data,vm service overview information. + */ + public GetBecVMSummaryResponse getBecVmSummary(GetBecVMSummaryRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, OVERVIEW, SUMMARY, VM_PREFIX); + return invokeHttpClient(internalRequest, GetBecVMSummaryResponse.class); + } + + /** + * Get BEC user level container metrics. + * + * @param request: The request containing all options for getting BEC user level container metrics. + * @return metrics data + */ + public GetBecContainerMetricsResponse getBecContainerMetrics(GetBecContainerMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getOffsetInSeconds(), OFFSET_IN_SECONDS_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getType(), checkEmptyExceptionMessageFormat(METRICS_TYPE_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, MONITOR, OVERVIEW, + CONTAINER, request.getType()); + if (StringUtils.isNotEmpty(request.getType())) { + internalRequest.addParameter("metricsType", request.getType()); + } + if (request.getOffsetInSeconds() != null && request.getOffsetInSeconds() > 0) { + // 获取整分数据 + long end = Calendar.getInstance().getTimeInMillis() / 1000; + + long start = end - request.getOffsetInSeconds(); + internalRequest.addParameter("start", String.valueOf(start)); + internalRequest.addParameter("end", String.valueOf(end)); + } + if (StringUtils.isNotEmpty(request.getServiceProvider())) { + internalRequest.addParameter("serviceProvider", request.getServiceProvider()); + } + if (request.getStepInMin() != null && request.getStepInMin() > 0) { + internalRequest.addParameter("stepInMin", String.valueOf(request.getStepInMin())); + } + return invokeHttpClient(internalRequest, GetBecContainerMetricsResponse.class); + } + + /** + * Get BEC user level vm metrics. + * + * @param request: The request containing all options for getting BEC user level vm metrics. + * @return metrics data + */ + public GetBecVmMetricsResponse getBecVmMetrics(GetBecVmMetricsRequest request) { + checkNotNull(request.getOffsetInSeconds(), OFFSET_IN_SECONDS_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getType(), checkEmptyExceptionMessageFormat(METRICS_TYPE_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, MONITOR, + OVERVIEW, VM_PREFIX, request.getType()); + if (StringUtils.isNotEmpty(request.getType())) { + internalRequest.addParameter("metricsType", request.getType()); + } + if (request.getOffsetInSeconds() != null && request.getOffsetInSeconds() > 0) { + // 获取整分数据 + long end = Calendar.getInstance().getTimeInMillis() / 1000; + + long start = end - request.getOffsetInSeconds(); + internalRequest.addParameter("start", String.valueOf(start)); + internalRequest.addParameter("end", String.valueOf(end)); + } + if (StringUtils.isNotEmpty(request.getServiceProvider())) { + internalRequest.addParameter("serviceProvider", request.getServiceProvider()); + } + if (request.getStepInMin() != null && request.getStepInMin() > 0) { + internalRequest.addParameter("stepInMin", String.valueOf(request.getStepInMin())); + } + return invokeHttpClient(internalRequest, GetBecVmMetricsResponse.class); + } + + /** + * List bec service packages. + * + * @param request: The request containing all options for listing bec service packages. + * @return bec service packages data + */ + public ListBecServicePackagesResponse listBecServicePackages(ListBecServicePackagesRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, RESOURCE, PACKAGE + , request.getType()); + return invokeHttpClient(internalRequest, ListBecServicePackagesResponse.class); + } + + /** + * List bec passThrough disk packages. + * + * @param request: The request containing all options for listing bec passThrough disk packages. + * @return bec passThrough disk packages data + */ + public ListBecPassThroughDiskPackagesResponse listBecPassThroughDiskPackages + (ListBecPassThroughDiskPackagesRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, RESOURCE, DISK + , PASS_THROUGH); + return invokeHttpClient(internalRequest, ListBecPassThroughDiskPackagesResponse.class); + } + + /** + * Create a new BEC vm image. + * + * @param request: The request containing all options for creating a bec vm image request. + * @return: The vm image detail. + */ + public CreateBecVmImageResponse createBecVmImage(CreateBecVmImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VM_PREFIX, IMAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecVmImageResponse.class); + } + + /** + * Get BEC vm images. + * + * @param request: The request contains all options for getting a list of BEC vm image. + * @return: paged api list, contains vm image details. + */ + public GetBecVmImagesResponse getBecVmImages(GetBecVmImagesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VM_PREFIX, IMAGE); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getKeywordType())) { + internalRequest.addParameter("keywordType", request.getListRequest().getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getKeyword())) { + internalRequest.addParameter("keyword", request.getListRequest().getKeyword()); + } + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + if (StringUtils.isNotEmpty(request.getListRequest().getOrder())) { + internalRequest.addParameter("order", request.getListRequest().getOrder()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getOrderBy())) { + internalRequest.addParameter("orderBy", request.getListRequest().getOrderBy()); + } + } + if (StringUtils.isNotEmpty(request.getType())) { + internalRequest.addParameter("type", request.getType()); + } + if (StringUtils.isNotEmpty(request.getImageId())) { + internalRequest.addParameter("imageId", request.getImageId()); + } + if (StringUtils.isNotEmpty(request.getOsName())) { + internalRequest.addParameter("osName", request.getOsName()); + } + if (StringUtils.isNotEmpty(request.getRegionId())) { + internalRequest.addParameter("regionId", request.getRegionId()); + } + return invokeHttpClient(internalRequest, GetBecVmImagesResponse.class); + } + + /** + * Update vm image. + * + * @param request: The request contains all the options for updating BEC vm image. + * @return: The response contains information about whether the vm image was successfully updated. + */ + public UpdateBecVmImageResponse updateBecVmImage(UpdateBecVmImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getImageId(), checkEmptyExceptionMessageFormat(IMAGE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, VM_PREFIX, IMAGE, + request.getImageId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecVmImageResponse.class); + } + + /** + * Batch delete BEC vm image list. + * + * @param request: The request contains the vm image ids that should be deleted. + * @return: The response contains information about whether the vm image list was successfully deleted. + */ + public BatchDeleteBecVmImageResponse batchDeleteBecVmImage(BatchDeleteBecVmImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkMultyParamsNotBothEmpty(request.getImageIdList(), IMAGE_ID_LIST_MESSAGE_KEY); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, VM_PREFIX, IMAGE); + String imageIdList = String.join(",", request.getImageIdList()); + internalRequest.addParameter("imageIdList", imageIdList); + return invokeHttpClient(internalRequest, BatchDeleteBecVmImageResponse.class); + } + + /** + * Create a new BEC deployment set. + * + * @param request: The request containing all options for creating a bec deployment set request. + * @return: The deployment set id. + */ + public CreateBecDeploySetResponse createBecDeploySet(CreateBecDeploySetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DEPLOY_SET_PREFIX, CREATE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecDeploySetResponse.class); + } + + /** + * Get BEC deployment set list + * + * @param request: The request contains all options for getting a list of BEC deployment set. + * @return: paged api list, for brief info. + */ + public GetBecDeploySetsResponse getBecDeploySets(GetBecDeploySetsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DEPLOY_SET_PREFIX, LIST); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getKeywordType())) { + internalRequest.addParameter("keywordType", request.getListRequest().getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getKeyword())) { + internalRequest.addParameter("keyword", request.getListRequest().getKeyword()); + } + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + } + return invokeHttpClient(internalRequest, GetBecDeploySetsResponse.class); + } + + /** + * Get BEC deployment set detail. + * + * @param request: The request containing all options for getting the api detail. + * @return: BEC deployment set detail. + */ + public GetBecDeploySetResponse getBecDeploySet(GetBecDeploySetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDeploySetId(), checkEmptyExceptionMessageFormat(DEPLOY_SET_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DEPLOY_SET_PREFIX, + request.getDeploySetId()); + return invokeHttpClient(internalRequest, GetBecDeploySetResponse.class); + } + + /** + * Update BEC deployment set. + * + * @param request: The request containing all options for updating the deployment set. + * @return: The response is empty. + */ + public UpdateBecDeploySetResponse updateBecDeploySet(UpdateBecDeploySetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDeploySetId(), checkEmptyExceptionMessageFormat(DEPLOY_SET_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DEPLOY_SET_PREFIX, + request.getDeploySetId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + internalRequest.addParameter("modifyAttribute", ""); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecDeploySetResponse.class); + } + + /** + * Delete BEC deployment set. + * + * @param request: The request contains the deployment set id that should be deleted. + * @return: The response is empty. + */ + public DeleteBecDeploySetResponse deleteBecDeploySet(DeleteBecDeploySetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDeploySetId(), checkEmptyExceptionMessageFormat(DEPLOY_SET_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, DEPLOY_SET_PREFIX, + request.getDeploySetId()); + return invokeHttpClient(internalRequest, DeleteBecDeploySetResponse.class); + } + + /** + * Delete BEC deployment set's instances. + * + * @param request: The request containing all options for deleting the deployment set's instances. + * @return: The response is empty. + */ + public DeleteBecDeploySetInstancesResponse deleteBecDeploySetInstances(DeleteBecDeploySetInstancesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDeploysetId(), checkEmptyExceptionMessageFormat(DEPLOY_SET_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DEPLOY_SET_PREFIX, DEL_RELATION); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DeleteBecDeploySetInstancesResponse.class); + } + + /** + * Update BEC instance's deployment set. + * + * @param request: The request containing all options for updating a bec instance's deployment sets. + * @return: The response is empty. + */ + public UpdateBecDeploySetInstanceResponse updateBecDeploySetInstance(UpdateBecDeploySetInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCE_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DEPLOY_SET_PREFIX, UPDATE_RELATION); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecDeploySetInstanceResponse.class); + } + + /** + * Create a new BEC vpc. + * + * @param request: The request containing all options for creating a bec vpc request. + * @return: The vpc id. + */ + public CreateBecVpcResponse createBecVpc(CreateBecVpcRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VPC_PREFIX); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecVpcResponse.class); + } + + /** + * Get a BEC vpc detail. + * + * @param request: The request containing all options for getting the api detail. + * @return: The BEC vpc detail. + */ + public GetBecVpcResponse getBecVpc(GetBecVpcRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVpcId(), checkEmptyExceptionMessageFormat(VPC_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VPC_PREFIX, + request.getVpcId()); + return invokeHttpClient(internalRequest, GetBecVpcResponse.class); + } + + /** + * Get BEC vpcs. + * + * @param request: The request contains all options for getting a list of BEC vpc. + * @return: paged api list, contains vpc details. + */ + public GetBecVpcsResponse getBecVpcs(GetBecVpcsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VPC_PREFIX); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getKeywordType())) { + internalRequest.addParameter("keywordType", request.getListRequest().getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getKeyword())) { + internalRequest.addParameter("keyword", request.getListRequest().getKeyword()); + } + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + } + if (StringUtils.isNotEmpty(request.getRegionId())) { + internalRequest.addParameter("regionId", request.getRegionId()); + } + return invokeHttpClient(internalRequest, GetBecVpcsResponse.class); + } + + /** + * Update BEC vpc. + * + * @param request: The request contains all the options for updating BEC vpc. + * @return: The response contains information about whether the vpc was successfully updated. + */ + public UpdateBecVpcResponse updateBecVpc(UpdateBecVpcRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVpcId(), checkEmptyExceptionMessageFormat(VPC_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, VPC_PREFIX, + request.getVpcId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecVpcResponse.class); + } + + /** + * Delete BEC vpc. + * + * @param request: The request contains the vpc id that should be deleted. + * @return: The response contains information about whether the vpc was successfully deleted. + */ + public DeleteBecVpcResponse deleteBecVpc(DeleteBecVpcRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVpcId(), checkEmptyExceptionMessageFormat(VPC_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, VPC_PREFIX, + request.getVpcId()); + return invokeHttpClient(internalRequest, DeleteBecVpcResponse.class); + } + + /** + * Create a new BEC subnet. + * + * @param request: The request containing all options for creating a bec subnet request. + * @return: The subnet detail. + */ + public CreateBecSubnetResponse createBecSubnet(CreateBecSubnetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VPC_PREFIX, SUBNET_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecSubnetResponse.class); + } + + /** + * Get BEC subnet detail. + * + * @param request: The request containing all options for getting the api detail. + * @return: BEC subnet detail. + */ + public GetBecSubnetResponse getBecSubnet(GetBecSubnetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSubnetId(), checkEmptyExceptionMessageFormat(SUBNET_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VPC_PREFIX, SUBNET_PREFIX, + request.getSubnetId()); + return invokeHttpClient(internalRequest, GetBecSubnetResponse.class); + } + + /** + * Get BEC subnets. + * + * @param request: The request contains all options for getting a list of BEC subnet. + * @return: paged api list, contains subnet details. + */ + public GetBecSubnetsResponse getBecSubnets(GetBecSubnetsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VPC_PREFIX, SUBNET_PREFIX); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getKeywordType())) { + internalRequest.addParameter("keywordType", request.getListRequest().getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getKeyword())) { + internalRequest.addParameter("keyword", request.getListRequest().getKeyword()); + } + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + } + if (StringUtils.isNotEmpty(request.getVpcId())) { + internalRequest.addParameter("vpcId", request.getVpcId()); + } + return invokeHttpClient(internalRequest, GetBecSubnetsResponse.class); + } + + /** + * Update subnet. + * + * @param request: The request contains all the options for updating BEC subnet. + * @return: The response contains information about whether the subnet was successfully updated. + */ + public UpdateBecSubnetResponse updateBecSubnet(UpdateBecSubnetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSubnetId(), checkEmptyExceptionMessageFormat(SUBNET_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, VPC_PREFIX, SUBNET_PREFIX, + request.getSubnetId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecSubnetResponse.class); + } + + /** + * Delete BEC subnet. + * + * @param request: The request contains the subnet id that should be deleted. + * @return: The response contains information about whether the subnet was successfully deleted. + */ + public DeleteBecSubnetResponse deleteBecSubnet(DeleteBecSubnetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSubnetId(), checkEmptyExceptionMessageFormat(SUBNET_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, VPC_PREFIX, SUBNET_PREFIX, + request.getSubnetId()); + return invokeHttpClient(internalRequest, DeleteBecSubnetResponse.class); + } + + /** + * Create a new BEC security group. + * + * @param request: The request containing all options for creating a bec security group request. + * @return: The security group detail. + */ + public CreateBecSecurityGroupResponse createBecSecurityGroup(CreateBecSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, SECURITY_GROUP_PREFIX); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecSecurityGroupResponse.class); + } + + /** + * Batch create a new BEC security group rules. + * + * @param request: The request containing all options for creating a bec security group rules request. + * @return: The security group rules detail. + */ + public BatchCreateBecSgRulesResponse batchCreateBecSecurityGroupRules(BatchCreateBecSgRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId() + , checkEmptyExceptionMessageFormat(SECURITY_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, SECURITY_GROUP_PREFIX, + request.getSecurityGroupId(), RULE, BATCH, ADD); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchCreateBecSgRulesResponse.class); + } + + /** + * Get BEC security group detail. + * Doesn't exist in Baidu cloud website api introduction. + * + * @param request: The request containing all options for getting the api detail. + * @return: BEC security group detail. + */ + public GetBecSecurityGroupResponse getBecSecurityGroup(GetBecSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId() + , checkEmptyExceptionMessageFormat(SECURITY_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, SECURITY_GROUP_PREFIX, + request.getSecurityGroupId()); + return invokeHttpClient(internalRequest, GetBecSecurityGroupResponse.class); + } + + /** + * Get BEC security groups. + * + * @param request: The request contains all options for getting a list of BEC security group. + * @return: paged api list, contains security group detail. + */ + public GetBecSecurityGroupsResponse getBecSecurityGroups(GetBecSecurityGroupsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, SECURITY_GROUP_PREFIX); + + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getKeywordType())) { + internalRequest.addParameter("keywordType", request.getListRequest().getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getKeyword())) { + internalRequest.addParameter("keyword", request.getListRequest().getKeyword()); + } + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + } + return invokeHttpClient(internalRequest, GetBecSecurityGroupsResponse.class); + } + + /** + * Update security group. + * + * @param request: The request contains all the options for updating BEC security group. + * @return: The response contains information about whether the security group was successfully updated. + */ + public UpdateBecSecurityGroupResponse updateBecSecurityGroup(UpdateBecSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITY_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, SECURITY_GROUP_PREFIX, + request.getSecurityGroupId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecSecurityGroupResponse.class); + } + + /** + * Update security group rule. + * + * @param request: The request contains all the options for updating BEC security group. + * @return: The response contains information about whether the security group was successfully updated. + */ + public UpdateBecSecurityGroupRuleResponse updateBecSecurityGroupRule(UpdateBecSecurityGroupRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITY_GROUP_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getSecurityGroupRuleId(), + checkEmptyExceptionMessageFormat(SECURITY_GROUP_RULE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, SECURITY_GROUP_PREFIX, + request.getSecurityGroupId(), RULE, request.getSecurityGroupRuleId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecSecurityGroupRuleResponse.class); + } + + /** + * Delete BEC security group. + * + * @param request: The request contains the security group id that should be deleted. + * @return: The response contains information about whether the security group was successfully deleted. + */ + public DeleteBecSecurityGroupResponse deleteBecSecurityGroup(DeleteBecSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITY_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, SECURITY_GROUP_PREFIX, + request.getSecurityGroupId()); + return invokeHttpClient(internalRequest, DeleteBecSecurityGroupResponse.class); + } + + /** + * Delete BEC batch security group rules. + * + * @param request: The request contains the batch security group id that should be deleted. + * @return: The response contains information about whether the batch security group was successfully deleted. + */ + public BatchDeleteBecSgRulesResponse batchDeleteBecSecurityGroupRules(BatchDeleteBecSgRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getSecurityGroupId(), + checkEmptyExceptionMessageFormat(SECURITY_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, SECURITY_GROUP_PREFIX, + request.getSecurityGroupId(), RULE, BATCH, DELETE); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchDeleteBecSgRulesResponse.class); + } + + /** + * Create a new BEC route rule. + * + * @param request: The request containing all options for creating a bec route rule request. + * @return: The route rule detail. + */ + public CreateBecRouteRuleResponse createBecRouteRule(CreateBecRouteRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, ROUTE_PREFIX, RULE); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecRouteRuleResponse.class); + } + + /** + * Get BEC route table detail. + * + * @param request: The request containing all options for getting the api detail. + * @return: BEC route detail. + */ + public GetBecRouteTableResponse getBecRouteTable(GetBecRouteTableRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getTableId(), checkEmptyExceptionMessageFormat(ROUTE_TABLE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, ROUTE_PREFIX, DETAIL, + request.getTableId()); + return invokeHttpClient(internalRequest, GetBecRouteTableResponse.class); + } + + /** + * Get BEC route tables. + * + * @param request: The request contains all options for getting a list of BEC security group. + * @return: paged api list, contains route table details. + */ + public GetBecRouteTablesResponse getBecRouteTables(GetBecRouteTablesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, ROUTE_PREFIX, LIST); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getKeywordType())) { + internalRequest.addParameter("keywordType", request.getListRequest().getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getKeyword())) { + internalRequest.addParameter("keyword", request.getListRequest().getKeyword()); + } + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + } + if (StringUtils.isNotEmpty(request.getRegionId())) { + internalRequest.addParameter("regionId", request.getRegionId()); + } + if (StringUtils.isNotEmpty(request.getVpcId())) { + internalRequest.addParameter("vpcId", request.getVpcId()); + } + return invokeHttpClient(internalRequest, GetBecRouteTablesResponse.class); + } + + /** + * Get BEC route rules. + * + * @param request: The request contains all options for getting a list of the BEC route rule. + * @return: paged api list, contains the route rule details. + */ + public GetBecRouteRulesResponse getBecRouteRules(GetBecRouteRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getTableId(), checkEmptyExceptionMessageFormat(ROUTE_TABLE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, ROUTE_PREFIX, RULE, LIST, + request.getTableId()); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + } + if (StringUtils.isNotEmpty(request.getTableId())) { + internalRequest.addParameter("tableId", request.getTableId()); + } + return invokeHttpClient(internalRequest, GetBecRouteRulesResponse.class); + } + + /** + * Update route table. + * + * @param request: The request contains all the options for updating BEC route table. + * @return: The response contains information about whether the route table was successfully updated. + */ + public UpdateBecRouteTableResponse updateBecRouteTable(UpdateBecRouteTableRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getTableId(), checkEmptyExceptionMessageFormat(ROUTE_TABLE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, ROUTE_PREFIX, UPDATE, + request.getTableId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecRouteTableResponse.class); + } + + /** + * Delete BEC route rule. + * + * @param request: The request contains the route rule id that should be deleted. + * @return: The response contains information about whether the route rule was successfully deleted. + */ + public DeleteBecRouteRuleResponse deleteBecRouteRule(DeleteBecRouteRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getRuleId(), checkEmptyExceptionMessageFormat(ROUTE_RULE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, ROUTE_PREFIX, RULE, DELETE, + request.getRuleId()); + return invokeHttpClient(internalRequest, DeleteBecRouteRuleResponse.class); + } + + /** + * Batch create BEC acl rules. + * + * @param request: The request containing all options for creating bec acl rules request. + * @return: The acl rules. + */ + public BatchCreateBecAclRulesResponse batchCreateBecAclRules(BatchCreateBecAclRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VPC_PREFIX, ACL, RULE, BATCH, CREATE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchCreateBecAclRulesResponse.class); + } + + /** + * Get BEC acl detail. + * + * @param request: The request containing all options for getting the api detail. + * @return: BEC acl detail. + */ + public GetBecAclResponse getBecAcl(GetBecAclRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVpcId(), checkEmptyExceptionMessageFormat(VPC_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VPC_PREFIX, ACL, DETAIL); + if (StringUtils.isNotEmpty(request.getVpcId())) { + internalRequest.addParameter("vpcId", request.getVpcId()); + } + return invokeHttpClient(internalRequest, GetBecAclResponse.class); + } + + /** + * Get BEC acls. + * + * @param request: The request contains all options for getting a list of BEC acl. + * @return: paged api list, contains acl detail. + */ + public GetBecAclsResponse getBecAcls(GetBecAclsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VPC_PREFIX, ACL, LIST); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getKeywordType())) { + internalRequest.addParameter("keywordType", request.getListRequest().getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getKeyword())) { + internalRequest.addParameter("keyword", request.getListRequest().getKeyword()); + } + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + } + if (StringUtils.isNotEmpty(request.getVpcId())) { + internalRequest.addParameter("vpcId", request.getVpcId()); + } + if (StringUtils.isNotEmpty(request.getRegionId())) { + internalRequest.addParameter("regionId", request.getRegionId()); + } + return invokeHttpClient(internalRequest, GetBecAclsResponse.class); + } + + /** + * Update acl. + * + * @param request: The request contains all the options for updating BEC acl. + * @return: The response contains information about whether the acl was successfully updated. + */ + public UpdateBecAclResponse updateBecAcl(UpdateBecAclRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getAclId(), checkEmptyExceptionMessageFormat(ACL_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, VPC_PREFIX, ACL, + request.getAclId()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecAclResponse.class); + } + + /** + * Update acl rule. + * + * @param request: The request contains all the options for updating BEC acl rule. + * @return: The response contains information about whether the acl rule was successfully updated. + */ + public UpdateBecAclRuleResponse updateBecAclRule(UpdateBecAclRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getAclRuleId(), checkEmptyExceptionMessageFormat(ACL_RULE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, VPC_PREFIX, ACL, RULE, + request.getAclRuleId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecAclRuleResponse.class); + } + + /** + * Batch delete BEC acl rules. + * + * @param request: The request contains the acl rule ids that should be deleted. + * @return: The response contains information about whether the acl rules was successfully deleted. + */ + public BatchDeleteBecAclRulesResponse batchDeleteBecAclRules(BatchDeleteBecAclRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VPC_PREFIX, ACL, RULE, BATCH, DELETE); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchDeleteBecAclRulesResponse.class); + } + + /** + * App blb instance api begin. + */ + /** + * Create a new BEC app blb instance. + * + * @param request: The request containing all options for creating a bec app blb instance request. + * @return: The app blb instance detail. + */ + public CreateBecAppBlbResponse createBecAppBlbV2(CreateBecAppBlbRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.POST, APP_BLB_PREFIX); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecAppBlbResponse.class); + } + + /** + * Get BEC app blb instance detail. + * + * @param request: The request containing all options for getting the api instance detail. + * @return: BEC app blb instance detail. + */ + public GetBecAppBlbResponse getBecAppBlbV2(GetBecAppBlbRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.GET, APP_BLB_PREFIX, + request.getBlbId()); + return invokeHttpClient(internalRequest, GetBecAppBlbResponse.class); + } + + /** + * Get BEC app blb instances. + * + * @param request: The request contains all options for getting a list of BEC app blb instance. + * @return: paged api list, contains app blb instance detail. + */ + public GetBecAppBlbsResponse getBecAppBlbsV2(GetBecAppBlbsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.GET, APP_BLB_PREFIX); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getMarker())) { + internalRequest.addParameter(MARKER, request.getListRequest().getMarker()); + } + if (ObjectUtils.allNotNull((request.getListRequest().getMaxKeys()))) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getListRequest().getMaxKeys())); + } + } + return invokeHttpClient(internalRequest, GetBecAppBlbsResponse.class); + } + + /** + * Update app blb instance. + * + * @param request: The request contains all the options for updating BEC app blb instance. + * @return: The response contains information about whether the app blb instance was successfully updated. + */ + public UpdateBecAppBlbResponse updateBecAppBlbV2(UpdateBecAppBlbRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecAppBlbResponse.class); + } + + /** + * Delete BEC app blb instance. + * + * @param request: The request contains the app blb instance id that should be deleted. + * @return: The response is empty. + */ + public DeleteBecAppBlbResponse deleteBecAppBlbV2(DeleteBecAppBlbRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.DELETE, APP_BLB_PREFIX, + request.getBlbId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + return invokeHttpClient(internalRequest, DeleteBecAppBlbResponse.class); + } + /** + * App blb instance api end. + */ + + /** + * App blb listener api begin. + */ + /** + * Create a new BEC app blb TCP listener. + * + * @param request: The request containing all options for creating a bec app blb TCP listener request. + * @return: The app blb TCP listener detail. + */ + public CreateBecAppBlbTCPListenerResponse createBecAppBlbTCPListenerV2(CreateBecAppBlbTCPListenerRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.POST, APP_BLB_PREFIX, + request.getBlbId(), TCP_LISTENER); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecAppBlbTCPListenerResponse.class); + } + + /** + * Create a new BEC app blb UDP listener. + * + * @param request: The request containing all options for creating a bec app blb UDP listener request. + * @return: The app blb UDP listener detail. + */ + public CreateBecAppBlbUDPListenerResponse createBecAppBlbUDPListenerV2(CreateBecAppBlbUDPListenerRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.POST, APP_BLB_PREFIX, + request.getBlbId(), UDP_LISTENER); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecAppBlbUDPListenerResponse.class); + } + + /** + * Create BEC app blb listener policies. + * + * @param request: The request containing all options for creating a bec app blb listener policies request. + * @return: The app blb listener policies. + */ + public CreateBecAppBlbListenerPoliciesResponse createBecAppBlbListenerPoliciesV2(CreateBecAppBlbListenerPoliciesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.POST, APP_BLB_PREFIX, + request.getBlbId(), POLICYS); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecAppBlbListenerPoliciesResponse.class); + } + + /** + * Get BEC app blb TCP listener detail. + * + * @param request: The request containing all options for getting the api listener detail. + * @return: BEC app blb TCP listener detail. + */ + public GetBecAppBlbTCPListenersResponse getBecAppBlbTCPListenersV2(GetBecAppBlbTCPListenersRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.GET, APP_BLB_PREFIX, + request.getBlbId(), TCP_LISTENER); + if (ObjectUtils.allNotNull((request.getListenerPort()))) { + internalRequest.addParameter("listenerPort", String.valueOf(request.getListenerPort())); + } + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getMarker())) { + internalRequest.addParameter(MARKER, request.getListRequest().getMarker()); + } + if (ObjectUtils.allNotNull((request.getListRequest().getMaxKeys()))) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getListRequest().getMaxKeys())); + } + } + return invokeHttpClient(internalRequest, GetBecAppBlbTCPListenersResponse.class); + } + + + /** + * Get BEC app blb UDP listener detail. + * + * @param request: The request containing all options for getting the api listener detail. + * @return: BEC app blb UDP listener detail. + */ + public GetBecAppBlbUDPListenersResponse getBecAppBlbUDPListenersV2(GetBecAppBlbUDPListenersRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.GET, APP_BLB_PREFIX, + request.getBlbId(), UDP_LISTENER); + if (ObjectUtils.allNotNull((request.getListenerPort()))) { + internalRequest.addParameter("listenerPort", String.valueOf(request.getListenerPort())); + } + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getMarker())) { + internalRequest.addParameter(MARKER, request.getListRequest().getMarker()); + } + if (ObjectUtils.allNotNull((request.getListRequest().getMaxKeys()))) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getListRequest().getMaxKeys())); + } + } + return invokeHttpClient(internalRequest, GetBecAppBlbUDPListenersResponse.class); + } + + /** + * Get BEC app blb listener policies. + * + * @param request: The request contains all options for getting a list of BEC app blb listener policies. + * @return: paged api list, contains app blb listener policy detail. + */ + public GetBecAppBlbListenerPoliciesResponse getBecAppBlbListenerPoliciesV2(GetBecAppBlbListenerPoliciesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.GET, APP_BLB_PREFIX, + request.getBlbId(), POLICYS); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getMarker())) { + internalRequest.addParameter(MARKER, request.getListRequest().getMarker()); + } + if (ObjectUtils.allNotNull((request.getListRequest().getMaxKeys()))) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getListRequest().getMaxKeys())); + } + } + if (ObjectUtils.allNotNull((request.getPort()))) { + internalRequest.addParameter("port", String.valueOf(request.getPort())); + } + if (ObjectUtils.allNotNull((request.getType()))) { + internalRequest.addParameter("type", String.valueOf(request.getType())); + } + return invokeHttpClient(internalRequest, GetBecAppBlbListenerPoliciesResponse.class); + } + + /** + * Update app blb TCP listener. + * + * @param request: The request contains all the options for updating BEC app blb TCP listener. + * @return: The response contains information about whether the app blb TCP listener was successfully updated. + */ + public UpdateBecAppBlbTCPListenerResponse updateBecAppBlbTCPListenerV2(UpdateBecAppBlbTCPListenerRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), TCP_LISTENER); + if (ObjectUtils.allNotNull((request.getListenerPort()))) { + internalRequest.addParameter("listenerPort", String.valueOf(request.getListenerPort())); + } + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecAppBlbTCPListenerResponse.class); + } + + + /** + * Update app blb UDP listener. + * + * @param request: The request contains all the options for updating BEC app blb UDP listener. + * @return: The response contains information about whether the app blb UDP listener was successfully updated. + */ + public UpdateBecAppBlbUDPListenerResponse updateBecAppBlbUDPListenerV2(UpdateBecAppBlbUDPListenerRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), UDP_LISTENER); + if (ObjectUtils.allNotNull((request.getListenerPort()))) { + internalRequest.addParameter("listenerPort", String.valueOf(request.getListenerPort())); + } + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecAppBlbUDPListenerResponse.class); + } + + + /** + * Delete BEC app blb listener policies. + * + * @param request: The request contains the app blb listener policy ids that should be deleted. + * @return: The response is empty. + */ + public DeleteBecAppBlbListenerPoliciesResponse deleteBecAppBlbListenerPoliciesV2(DeleteBecAppBlbListenerPoliciesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), POLICYS); + internalRequest.addParameter(BATCH_DELETE, ""); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DeleteBecAppBlbListenerPoliciesResponse.class); + } + + /** + * Delete BEC app blb listeners. + * + * @param request: The request contains the app blb listener ids that should be deleted. + * @return: The response is empty. + */ + public BatchDeleteBecAppBlbListenersResponse batchDeleteBecAppBlbListenersV2(BatchDeleteBecAppBlbListenersRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), LISTENER); + internalRequest.addParameter(BATCH_DELETE, ""); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchDeleteBecAppBlbListenersResponse.class); + } + /** + * App blb listener api end. + */ + + /** + * App blb backend api begin. + */ + /** + * Create a new BEC app blb ip group. + * + * @param request: The request containing all options for creating a bec app blb ip group request. + * @return: The app blb ip group detail. + */ + public CreateBecAppBlbIpGroupResponse createBecAppBlbIpGroupV2(CreateBecAppBlbIpGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.POST, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecAppBlbIpGroupResponse.class); + } + + /** + * Create a new BEC app blb ip group policy. + * + * @param request: The request containing all options for creating a bec app blb ip group policy request. + * @return: The app blb ip group policy detail. + */ + public CreateBecAppBlbIpGroupBackendPolicyResponse createBecAppBlbIpGroupBackendPoliciesV2(CreateBecAppBlbIpGroupBackendPolicyRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.POST, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP, BACKEND_POLICY); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecAppBlbIpGroupBackendPolicyResponse.class); + } + + /** + * Create a new BEC app blb ip group member. + * + * @param request: The request containing all options for creating a bec app blb ip group member request. + * @return: The app blb ip group member detail. + */ + public CreateBecAppBlbIpGroupMembersResponse createBecAppBlbIpGroupMembersV2(CreateBecAppBlbIpGroupMembersRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.POST, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP, MEMBER); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecAppBlbIpGroupMembersResponse.class); + } + + /** + * Get BEC app blb ip group detail. + * + * @param request: The request containing all options for getting the api ip group detail. + * @return: BEC app blb ip group detail. + */ + public GetBecAppBlbIpGroupsResponse getBecAppBlbIpGroupsV2(GetBecAppBlbIpGroupsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.GET, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getMarker())) { + internalRequest.addParameter(MARKER, request.getListRequest().getMarker()); + } + if (ObjectUtils.allNotNull((request.getListRequest().getMaxKeys()))) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getListRequest().getMaxKeys())); + } + } + if (StringUtils.isNotEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (ObjectUtils.allNotNull(request.getExactlyMatch())) { + internalRequest.addParameter("exactlyMatch", String.valueOf(request.getExactlyMatch())); + } + return invokeHttpClient(internalRequest, GetBecAppBlbIpGroupsResponse.class); + } + + + /** + * Get BEC app blb ip group policies. + * + * @param request: The request containing all options for getting the api ip group policies detail. + * @return: BEC app blb ip group polices. + */ + public GetBecAppBlbIpGroupBackendPoliciesResponse getBecAppBlbIpGroupPoliciesV2(GetBecAppBlbIpGroupBackendPoliciesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.GET, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP, BACKEND_POLICY); + internalRequest.addParameter("ipGroupId", request.getIpGroupId()); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getMarker())) { + internalRequest.addParameter(MARKER, request.getListRequest().getMarker()); + } + if (ObjectUtils.allNotNull((request.getListRequest().getMaxKeys()))) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getListRequest().getMaxKeys())); + } + } + return invokeHttpClient(internalRequest, GetBecAppBlbIpGroupBackendPoliciesResponse.class); + } + + + /** + * Get BEC app blb ip group members. + * + * @param request: The request contains all options for getting a list of BEC app blb ip group members. + * @return: paged api list, contains app blb ip group member details. + */ + public GetBecAppBlbIpGroupMembersResponse getBecAppBlbIpGroupMembersV2(GetBecAppBlbIpGroupMembersRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.GET, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP, MEMBER); + internalRequest.addParameter("ipGroupId", request.getIpGroupId()); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getMarker())) { + internalRequest.addParameter(MARKER, request.getListRequest().getMarker()); + } + if (ObjectUtils.allNotNull((request.getListRequest().getMaxKeys()))) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getListRequest().getMaxKeys())); + } + } + return invokeHttpClient(internalRequest, GetBecAppBlbIpGroupMembersResponse.class); + } + + /** + * Update app blb ip group. + * + * @param request: The request contains all the options for updating BEC app blb ip group. + * @return: The response contains information about whether the app blb ip group was successfully updated. + */ + public UpdateBecAppBlbIpGroupResponse updateBecAppBlbIpGroupV2(UpdateBecAppBlbIpGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecAppBlbIpGroupResponse.class); + } + + /** + * Update app blb ip group policy. + * + * @param request: The request contains all the options for updating BEC app blb ip group policy. + * @return: The response contains information about whether the app blb ip group policy were successfully updated. + */ + public UpdateBecAppBlbIpGroupBackendPolicyResponse updateBecAppBlbIpGroupPolicyV2(UpdateBecAppBlbIpGroupBackendPolicyRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP, BACKEND_POLICY); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecAppBlbIpGroupBackendPolicyResponse.class); + } + + + /** + * Update app blb ip group members. + * + * @param request: The request contains all the options for updating BEC app blb ip group members. + * @return: The response contains information about whether the app blb ip group members were successfully updated. + */ + public UpdateBecAppBlbIpGroupMembersResponse updateBecAppBlbIpGroupMembersV2(UpdateBecAppBlbIpGroupMembersRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP, MEMBER); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecAppBlbIpGroupMembersResponse.class); + } + + /** + * Delete BEC app blb ip group. + * + * @param request: The request contains the app blb ip group id that should be deleted. + * @return: The response is empty. + */ + public DeleteBecAppBlbIpGroupResponse deleteBecAppBlbIpGroupV2(DeleteBecAppBlbIpGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP); + internalRequest.addParameter(DELETE, ""); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DeleteBecAppBlbIpGroupResponse.class); + } + + /** + * Delete BEC app blb ip group policies. + * + * @param request: The request contains the app blb ip group policies id that should be deleted. + * @return: The response is empty. + */ + public DeleteBecAppBlbIpGroupBackendPoliciesResponse deleteBecAppBlbIpGroupBackendPoliciesV2( + DeleteBecAppBlbIpGroupBackendPoliciesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP, BACKEND_POLICY); + internalRequest.addParameter(DELETE, ""); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DeleteBecAppBlbIpGroupBackendPoliciesResponse.class); + } + + /** + * Delete BEC app blb ip group members. + * + * @param request: The request contains the app blb ip group member ids that should be deleted. + * @return: The response is empty. + */ + public DeleteBecAppBlbIpGroupMembersResponse deleteBecAppBlbIpGroupMembersV2(DeleteBecAppBlbIpGroupMembersRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBlbId(), checkEmptyExceptionMessageFormat(BLB_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequestV2(request, HttpMethodName.PUT, APP_BLB_PREFIX, + request.getBlbId(), IP_GROUP, MEMBER); + internalRequest.addParameter(DELETE, ""); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DeleteBecAppBlbIpGroupMembersResponse.class); + } + /** + * App blb backend api end. + */ + + /** + * Bec nat api begin. + */ + /** + * Create a new BEC nat. + * + * @param request: The request containing all options for creating a bec nat request. + * @return: The nat detail. + */ + public BatchCreateBecNatsResponse batchCreateBecNat(BatchCreateBecNatsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, NAT_PREFIX, BATCH, CREATE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchCreateBecNatsResponse.class); + } + + /** + * Get BEC nat detail. + * + * @param request: The request containing all options for getting the nat detail. + * @return: BEC nat detail. + */ + public GetBecNatResponse getBecNat(GetBecNatRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, NAT_PREFIX, + request.getNatId()); + return invokeHttpClient(internalRequest, GetBecNatResponse.class); + } + + /** + * Get BEC nats. + * + * @param request: The request containing all options for getting the nats. + * @return: BEC nats. + */ + public GetBecNatsResponse getBecNats(GetBecNatsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, NAT_PREFIX, LIST); + if (ObjectUtils.allNotNull(request.getListRequest())) { + if (StringUtils.isNotEmpty(request.getListRequest().getKeywordType())) { + internalRequest.addParameter("keywordType", request.getListRequest().getKeywordType()); + } + if (StringUtils.isNotEmpty(request.getListRequest().getKeyword())) { + internalRequest.addParameter("keyword", request.getListRequest().getKeyword()); + } + if (request.getListRequest().getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getListRequest().getPageNo())); + } + if (request.getListRequest().getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getListRequest().getPageSize())); + } + } + if (StringUtils.isNotEmpty(request.getRegionId())) { + internalRequest.addParameter("regionId", request.getRegionId()); + } + if (StringUtils.isNotEmpty(request.getVpcId())) { + internalRequest.addParameter("vpcId", request.getVpcId()); + } + return invokeHttpClient(internalRequest, GetBecNatsResponse.class); + } + + /** + * Update nat. + * + * @param request: The request contains all the options for updating BEC nat. + * @return: The response contains information about whether the nat was successfully updated. + */ + public UpdateBecNatResponse updateBecNat(UpdateBecNatRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, NAT_PREFIX, + request.getNatId(), UPDATE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecNatResponse.class); + } + + /** + * Update nat bandwidth. + * + * @param request: The request contains all the options for updating BEC nat bandwidth. + * @return: The response contains information about whether the nat bandwidth was successfully updated. + */ + public UpdateBecNatBandwidthResponse updateBecNatBandwidth(UpdateBecNatBandwidthRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, NAT_PREFIX, + request.getNatId(), UPDATE_BANDWIDTH); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecNatBandwidthResponse.class); + } + + /** + * Delete BEC nats. + * + * @param request: The request contains the nat ids that should be deleted. + * @return: The response is empty. + */ + public BatchDeleteBecNatsResponse batchDeleteBecNats(BatchDeleteBecNatsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, NAT_PREFIX, BATCH, DELETE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchDeleteBecNatsResponse.class); + } + + /** + * Get the BEC nat instance metrics. + * + * @param request: The request containing all options for getting bec nat instance metrics. + * @return: The response contains BEC nat instance metrics. + */ + public GetBecNatMetricsResponse getBecNatMetrics(GetBecNatMetricsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getMetricsType(), checkEmptyExceptionMessageFormat(METRICS_TYPE_MESSAGE_KEY)); + checkNotNull(request.getStart(), START_MESSAGE_KEY); + checkNotNull(request.getEnd(), END_MESSAGE_KEY); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, MONITOR, NAT_PREFIX, + request.getNatId()); + if (request.getStart() > 0 && request.getEnd() > 0) { + internalRequest.addParameter("start", String.valueOf(request.getStart())); + internalRequest.addParameter("end", String.valueOf(request.getEnd())); + } + if (StringUtils.isNotEmpty(request.getMetricsType())) { + internalRequest.addParameter("metricsType", request.getMetricsType()); + } + return invokeHttpClient(internalRequest, GetBecNatMetricsResponse.class); + } + /** + * Bec nat api end. + */ + + /** + * Bec S-NAT rule begin. + */ + /** + * Create a new BEC rule. + * + * @param request: The request containing all options for creating a bec S-NAT rule request. + * @return: The S-NAT rule detail. + */ + public CreateBecSnatRuleResponse createBecSnatRule(CreateBecSnatRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, NAT_PREFIX, + request.getNatId(), SNAT_RULE, CREATE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecSnatRuleResponse.class); + } + + /** + * Batch create BEC S-NAT rules. + * + * @param request: The request containing all options for creating bec S-NAT rules request. + * @return: The S-NAT rules. + */ + public BatchCreateBecSnatRulesResponse batchCreateBecSnatRules(BatchCreateBecSnatRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, NAT_PREFIX, + request.getNatId(), SNAT_RULE, BATCH_CREATE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchCreateBecSnatRulesResponse.class); + } + + /** + * Get BEC S-NAT rules. + * + * @param request: The request containing all options for getting the S-NAT rules. + * @return: BEC S-NAT rules. + */ + public GetBecSnatRulesResponse getBecSnatRules(GetBecSnatRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, NAT_PREFIX, + request.getNatId(), SNAT_RULE); + if (request.getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + return invokeHttpClient(internalRequest, GetBecSnatRulesResponse.class); + } + + /** + * Update S-NAT rule. + * + * @param request: The request contains all the options for updating BEC S-NAT rule. + * @return: The response contains information about whether the S-NAT rule was successfully updated. + */ + public UpdateBecSnatRuleResponse updateBecSnatRule(UpdateBecSnatRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, NAT_PREFIX, + request.getNatId(), SNAT_RULE, request.getRuleId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecSnatRuleResponse.class); + } + + /** + * Delete BEC S-NAT rules. + * + * @param request: The request contains the S-NAT rule ids that should be deleted. + * @return: The response is empty. + */ + public BatchDeleteBecSnatRulesResponse batchDeleteBecSnatRules(BatchDeleteBecSnatRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, NAT_PREFIX, + request.getNatId(), SNAT_RULE, BATCH, DELETE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchDeleteBecSnatRulesResponse.class); + } + /** + * Bec S-NAT rule end. + */ + + /** + * Bec D-NAT rule begin. + */ + /** + * Create a new BEC D-NAT rule. + * + * @param request: The request containing all options for creating a bec D-NAT rule request. + * @return: The D-NAT rule detail. + */ + public CreateBecDnatRuleResponse createBecDnatRule(CreateBecDnatRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, NAT_PREFIX, + request.getNatId(), DNAT_RULE, CREATE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateBecDnatRuleResponse.class); + } + + /** + * Batch create BEC D-NAT rules. + * + * @param request: The request containing all options for creating batch bec D-NAT rules request. + * @return: The D-NAT rules。 + */ + public BatchCreateBecDnatRulesResponse batchCreateBecDnatRules(BatchCreateBecDnatRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, NAT_PREFIX, + request.getNatId(), DNAT_RULE, BATCH_CREATE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchCreateBecDnatRulesResponse.class); + } + + /** + * Get BEC D-NAT rules. + * + * @param request: The request containing all options for getting the D-NAT rules. + * @return: BEC D-NAT rules. + */ + public GetBecDnatRulesResponse getBecDnatRules(GetBecDnatRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, NAT_PREFIX, + request.getNatId(), DNAT_RULE); + if (request.getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + return invokeHttpClient(internalRequest, GetBecDnatRulesResponse.class); + } + + /** + * Update D-NAT rule. + * + * @param request: The request contains all the options for updating BEC D-NAT rule. + * @return: The response contains information about whether the D-NAT rule was successfully updated. + */ + public UpdateBecDnatRuleResponse updateBecDnatRule(UpdateBecDnatRuleRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getRuleId(), + checkEmptyExceptionMessageFormat(RULE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, NAT_PREFIX, + request.getNatId(), DNAT_RULE, request.getRuleId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBecDnatRuleResponse.class); + } + + /** + * Batch Delete BEC D-NAT rules. + * + * @param request: The request contains the D-NAT rule ids that should be deleted. + * @return: The response is empty. + */ + public BatchDeleteBecDnatRulesResponse batchDeleteBecDnatRules(BatchDeleteBecDnatRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getNatId(), checkEmptyExceptionMessageFormat(NAT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, NAT_PREFIX, + request.getNatId(), DNAT_RULE, BATCH, DELETE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BatchDeleteBecDnatRulesResponse.class); + } + /** + * Bec D-NAT rule end. + */ +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/BecClientConfiguration.java b/src/main/java/com/baidubce/services/bec/BecClientConfiguration.java new file mode 100644 index 00000000..8df59cf2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/BecClientConfiguration.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for bec service. + */ +public class BecClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/bec/model/Backends.java b/src/main/java/com/baidubce/services/bec/model/Backends.java new file mode 100644 index 00000000..4196c58f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/Backends.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model; + +import lombok.Data; + +/** + * Backends. + */ +@Data +public class Backends { + + /** + * The name of the pod/vm. + */ + private String name; + + /** + * The ip of the pod/vm. + */ + private String ip; + + /** + * The weight of the pod/vm. + */ + private Integer weight; +} diff --git a/src/main/java/com/baidubce/services/bec/model/ImageDetail.java b/src/main/java/com/baidubce/services/bec/model/ImageDetail.java new file mode 100644 index 00000000..96b09d91 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/ImageDetail.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model; + +import lombok.Data; + +/** + * Image detail. + */ +@Data +public class ImageDetail { + + /** + * Id. + */ + private String id; + + /** + * The id of image. + */ + private String imageId; + + /** + * The name of image. + */ + private String name; + + /** + * nameFri. + */ + private String nameFri; + + /** + * The type of image. + */ + private String imageType; + + /** + * The id of snapshot. + */ + private String snapshotId; + + /** + * The number of cpu. + */ + private Integer cpu; + + /** + * The number of memory. + */ + private Integer memory; + + /** + * The type of os. + */ + private String osType; + + /** + * The version of os. + */ + private String osVersion; + + /** + * The name of os. + */ + private String osName; + + /** + * Os creation time. + */ + private String osBuild; + + /** + * Os language. + */ + private String osLang; + + /** + * Disk size. + */ + private Integer diskSize; + + /** + * Creation time. + */ + private String createTime; + + /** + * Status. + */ + private String status; + + /** + * The minimum amount of memory. + */ + private Integer minMem; + + /** + * The minimum number of CPUs. + */ + private Integer minCpu; + + /** + * The minimum number of disks. + */ + private Integer minDiskGb; + + /** + * Description. + */ + private String desc; + + /** + * osArch. + */ + private String osArch; + + /** + * ephemeralSize. + */ + private Integer ephemeralSize; + + /** + * Image description. + */ + private String imageDescription; + + /** + * Share limit. + */ + private Integer shareToUserNumLimit; + + /** + * Number of shares. + */ + private Integer sharedToUserNum; + + /** + * fpgaType. + */ + private String fpgaType; +} diff --git a/src/main/java/com/baidubce/services/bec/model/ListRequest.java b/src/main/java/com/baidubce/services/bec/model/ListRequest.java new file mode 100644 index 00000000..07536e5d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/ListRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The core keywords which were used in list selection scene. + * It is not recommended to amend the class unless if it is necessary. + */ +@Data +public class ListRequest extends AbstractBceRequest { + + /** + * The keyword type of the query instance. + */ + public String keywordType; + + /** + * The keyword of the query instance. + */ + public String keyword; + + /** + * Page number of display page. + */ + public int pageNo; + + /** + * The number of services on the display page. + */ + public int pageSize; + + /** + * Sort, ascending/descending. + */ + public String order; + + /** + * Sort field. + */ + public String orderBy; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListRequest with credentials. + */ + public ListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/Listeners.java b/src/main/java/com/baidubce/services/bec/model/Listeners.java new file mode 100644 index 00000000..7d645a8a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/Listeners.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model; + +import com.baidubce.services.bec.model.enums.LbModeEnum; +import com.baidubce.services.bec.model.enums.ProtocolEnum; +import lombok.Data; + +/** + * Listeners. + */ +@Data +public class Listeners { + + /** + * Load balance protocol. + */ + private ProtocolEnum protocol; + + /** + * Load balance port. + */ + private Integer port; + + /** + * Backend port. + */ + private Integer backendPort; + + /** + * Forwarding rules. + */ + private LbModeEnum scheduler; + + /** + * Health check interval. + */ + private Integer healthCheckInterval; + + /** + * Health check threshold. + */ + private Integer healthCheckRetry; + + /** + * Health check timeout period. + */ + private Integer healthCheckTimeout; + + /** + * UDP Health Check String. + */ + private String udpHealthCheckString; + + /** + * Health Check type, like tcp, http, udp. + */ + private String healthCheckType; + + /** + * The health check url path, default /. + */ + private String healthCheckURI; +} diff --git a/src/main/java/com/baidubce/services/bec/model/Stats.java b/src/main/java/com/baidubce/services/bec/model/Stats.java new file mode 100644 index 00000000..6424cfd8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/Stats.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model; + +import com.baidubce.services.bec.model.enums.ProtocolEnum; +import lombok.Data; + +/** + * Stats. + */ +@Data +public class Stats { + + /** + * health status. + */ + private Boolean health; + + /** + * port. + */ + private Integer port; + + /** + * protocol type. + */ + private ProtocolEnum protocol; +} diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupBackendPolicyRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupBackendPolicyRequest.java new file mode 100644 index 00000000..1c2a1f30 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupBackendPolicyRequest.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for creating app blb ip group policy. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateBecAppBlbIpGroupBackendPolicyRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The health check type, TCP/HTTP/UDP/ICMP. + */ + private String healthCheck; + + /** + * The unhealthy check threshold, making it unavailable after consecutive unsuccessful health checks. + * Default is 3, it should be an integer between 2-5. + */ + private Integer healthCheckDownRetry; + + /** + * The health check host, like "localhost", default empty, valid under HTTP protocol. + */ + private String healthCheckHost; + + /** + * The health check interval time, the unit is second. + * Default is 3, it should be an integer between 1-10. + */ + private Integer healthCheckIntervalInSecond; + + /** + * The health check http status code under healthy condition, like http_1xx|http_2xx; valid under HTTP protocol. + */ + private String healthCheckNormalStatus; + + /** + * The health check port, must assign under HTTP protocol. + */ + private Integer healthCheckPort; + + /** + * The health check timeout time, the unit is second. + * Default is 3, it should be an integer between 1-60. + */ + private Integer healthCheckTimeoutInSecond; + + /** + * The healthy check threshold, making it available after consecutive successful health checks. + * Default is 3, it should be an integer between 2-5. + */ + private Integer healthCheckUpRetry; + + /** + * The health check url path, default /, valid under HTTP protocol. + */ + private String healthCheckUrlPath; + + /** + * The ip group id. + */ + private String ipGroupId; + + /** + * The ip group protocol, TCP/HTTP/UDP. + */ + private String type; + + /** + * The UDP health check string, must assign under UDP protocol. + */ + private String udpHealthCheckString; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public CreateBecAppBlbIpGroupBackendPolicyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupBackendPolicyResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupBackendPolicyResponse.java new file mode 100644 index 00000000..1affea84 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupBackendPolicyResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for creating app blb ip group policies. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecAppBlbIpGroupBackendPolicyResponse extends AbstractBceResponse { + + /** + * The ip group policy id. + */ + private String id; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupMembersRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupMembersRequest.java new file mode 100644 index 00000000..823b1d7f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupMembersRequest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for creating app blb ip group members. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateBecAppBlbIpGroupMembersRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The ip group id. + */ + private String ipGroupId; + + /** + * The members. + */ + private List memberList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public CreateBecAppBlbIpGroupMembersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupMembersResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupMembersResponse.java new file mode 100644 index 00000000..13cac272 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupMembersResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.blb.model.AppIpGroupMember; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for creating app blb ip group members. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecAppBlbIpGroupMembersResponse extends AbstractBceResponse { + + /** + * The members. + */ + private List memberList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupRequest.java new file mode 100644 index 00000000..1bd33b66 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupRequest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for creating app blb ip group. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateBecAppBlbIpGroupRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The name. + */ + private String name; + + /** + * The description. + */ + private String desc; + + /** + * The ip group members. + */ + private List memberList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public CreateBecAppBlbIpGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupResponse.java new file mode 100644 index 00000000..4bc88f0b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/CreateBecAppBlbIpGroupResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for creating app blb ip group. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecAppBlbIpGroupResponse extends AbstractBceResponse { + + /** + * Theip group id. + */ + private String id; + + /** + * The ip group name. + */ + private String name; + + /** + * The ip group description. + */ + private String desc; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupBackendPoliciesRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupBackendPoliciesRequest.java new file mode 100644 index 00000000..17fe5e08 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupBackendPoliciesRequest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for deleting app blb ip group policies. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeleteBecAppBlbIpGroupBackendPoliciesRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The ip group id. + */ + private String ipGroupId; + + /** + * The backend policy ids. + */ + private List backendPolicyIdList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public DeleteBecAppBlbIpGroupBackendPoliciesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupBackendPoliciesResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupBackendPoliciesResponse.java new file mode 100644 index 00000000..d93fc3be --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupBackendPoliciesResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for deleting app blb ip group policies. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecAppBlbIpGroupBackendPoliciesResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupMembersRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupMembersRequest.java new file mode 100644 index 00000000..02850136 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupMembersRequest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for deleting app blb ip group members. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeleteBecAppBlbIpGroupMembersRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The ip group id. + */ + private String ipGroupId; + + /** + * The member ids. + */ + private List memberIdList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public DeleteBecAppBlbIpGroupMembersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupMembersResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupMembersResponse.java new file mode 100644 index 00000000..6109e6bb --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupMembersResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for deleting app blb ip group members. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecAppBlbIpGroupMembersResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupRequest.java new file mode 100644 index 00000000..fcf63f39 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for deleting app blb ip group. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeleteBecAppBlbIpGroupRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The ip group id. + */ + private String ipGroupId; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public DeleteBecAppBlbIpGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupResponse.java new file mode 100644 index 00000000..2e3dd1e3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/DeleteBecAppBlbIpGroupResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for deleting app blb ip group. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecAppBlbIpGroupResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupBackendPoliciesRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupBackendPoliciesRequest.java new file mode 100644 index 00000000..a10ab598 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupBackendPoliciesRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vo.v2.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting app blb ip group policies. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecAppBlbIpGroupBackendPoliciesRequest extends AbstractBceRequest { + + /** + * ListRequest. + */ + private ListRequest listRequest; + + /** + * The app blb id. + */ + private String blbId; + + /** + * The app blb ip group id. + */ + private String ipGroupId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecAppBlbIpGroupBackendPoliciesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupBackendPoliciesResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupBackendPoliciesResponse.java new file mode 100644 index 00000000..f602069c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupBackendPoliciesResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.services.bec.model.vo.v2.AppIpGroupBackendPolicyVo; +import com.baidubce.services.bec.model.vo.v2.ListResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting app blb ip group policies. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAppBlbIpGroupBackendPoliciesResponse extends ListResponse { + + /** + * The ip group backend policies. + */ + private List backendPolicyList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupMembersRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupMembersRequest.java new file mode 100644 index 00000000..53527c24 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupMembersRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vo.v2.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting app blb ip group members. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecAppBlbIpGroupMembersRequest extends AbstractBceRequest { + + /** + * ListRequest. + */ + private ListRequest listRequest; + + /** + * The app blb id. + */ + private String blbId; + + /** + * The ip group id. + */ + private String ipGroupId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecAppBlbIpGroupMembersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupMembersResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupMembersResponse.java new file mode 100644 index 00000000..fcae2b45 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupMembersResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.blb.model.AppIpGroupMember; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting app blb ip group members. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAppBlbIpGroupMembersResponse extends AbstractBceResponse { + + /** + * The members. + */ + private List memberList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupsRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupsRequest.java new file mode 100644 index 00000000..cc6aa003 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupsRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vo.v2.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting app blb ip group. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecAppBlbIpGroupsRequest extends AbstractBceRequest { + + /** + * ListRequest. + */ + private ListRequest listRequest; + + /** + * The app blb id. + */ + private String blbId; + + /** + * The name. + */ + private String name; + + /** + * Whether exactly match. + */ + private Boolean exactlyMatch; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecAppBlbIpGroupsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupsResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupsResponse.java new file mode 100644 index 00000000..17b53aa0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/GetBecAppBlbIpGroupsResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.services.bec.model.vo.v2.AppIpGroupVo; +import com.baidubce.services.bec.model.vo.v2.ListResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting app blb ip group. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAppBlbIpGroupsResponse extends ListResponse { + + /** + * The ip groups. + */ + private List appIpGroupList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/IpGroupMemberForm.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/IpGroupMemberForm.java new file mode 100644 index 00000000..d99eb730 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/IpGroupMemberForm.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 20:27 + * @Version v1.0 + *

+ * Ip group member form. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class IpGroupMemberForm { + + /** + * The member ip. + */ + private String ip; + + /** + * The member port. + */ + private Integer port; + + /** + * The member weight, 0 - 100. + */ + private Integer weight; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupBackendPolicyRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupBackendPolicyRequest.java new file mode 100644 index 00000000..e1fd7a0b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupBackendPolicyRequest.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating app blb ip group policy. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecAppBlbIpGroupBackendPolicyRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The unhealthy check threshold, making it unavailable after consecutive unsuccessful health checks. + * Default is 3, it should be an integer between 2-5. + */ + private Integer healthCheckDownRetry; + + /** + * The health check host, like "localhost", default empty, valid under HTTP protocol. + */ + private String healthCheckHost; + + /** + * The health check interval time, the unit is second. + * Default is 3, it should be an integer between 1-10. + */ + private Integer healthCheckIntervalInSecond; + + /** + * The health check http status code under healthy condition, like http_1xx|http_2xx; valid under HTTP protocol. + */ + private String healthCheckNormalStatus; + + /** + * The health check port, must assign under HTTP protocol. + */ + private Integer healthCheckPort; + + /** + * The health check timeout time, the unit is second. + * Default is 3, it should be an integer between 1-60. + */ + private Integer healthCheckTimeoutInSecond; + + /** + * The healthy check threshold, making it available after consecutive successful health checks. + * Default is 3, it should be an integer between 2-5. + */ + private Integer healthCheckUpRetry; + + /** + * The health check url path, default /, valid under HTTP protocol. + */ + private String healthCheckUrlPath; + + /** + * The ip group policy id. + */ + private String id; + + /** + * The ip group id. + */ + private String ipGroupId; + + /** + * The ip group protocol, TCP/HTTP/UDP. + */ + private String type; + + /** + * The UDP health check string, must assign under UDP protocol. + */ + private String udpHealthCheckString; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecAppBlbIpGroupBackendPolicyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupBackendPolicyResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupBackendPolicyResponse.java new file mode 100644 index 00000000..764d1a43 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupBackendPolicyResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating app blb ip group policy. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecAppBlbIpGroupBackendPolicyResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupMembersRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupMembersRequest.java new file mode 100644 index 00000000..cf3935f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupMembersRequest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating app blb ip group members. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecAppBlbIpGroupMembersRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The ip group id. + */ + private String ipGroupId; + + /** + * The members. + */ + private List memberList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecAppBlbIpGroupMembersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupMembersResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupMembersResponse.java new file mode 100644 index 00000000..b2c113a6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupMembersResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating app blb ip group members. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecAppBlbIpGroupMembersResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupRequest.java new file mode 100644 index 00000000..fecf6313 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating app blb ip group. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecAppBlbIpGroupRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The app blb ip group id. + */ + private String ipGroupId; + + /** + * The ip group name. + */ + private String name; + + /** + * The ip group description. + */ + private String desc; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecAppBlbIpGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupResponse.java new file mode 100644 index 00000000..e12f67d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateBecAppBlbIpGroupResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating app blb ip group. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecAppBlbIpGroupResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateIpGroupMemberForm.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateIpGroupMemberForm.java new file mode 100644 index 00000000..f880c4fd --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/backendbind/UpdateIpGroupMemberForm.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.backendbind; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 20:48 + * @Version v1.0 + *

+ * Ip group member form when under updating condition. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateIpGroupMemberForm { + + /** + * The member id. + */ + private String memberId; + + /** + * The port. + */ + private Integer port; + + /** + * The weight. + */ + private Integer weight; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/CreateBecAppBlbRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/CreateBecAppBlbRequest.java new file mode 100644 index 00000000..4271a8fd --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/CreateBecAppBlbRequest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for creating app blb. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateBecAppBlbRequest extends AbstractBceRequest { + + /** + * The app blb description. + */ + private String desc; + + /** + * The app blb name. + */ + private String name; + + /** + * Whether the app blb need public ip, default true. + */ + private Boolean needPublicIp; + + /** + * The node region id which the app blb belong to. + */ + private String regionId; + + /** + * The subnet id. + */ + private String subnetId; + + /** + * The isp, the value must be ct/un/cm, only can assign one. + */ + private List subServiceProviders; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public CreateBecAppBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/CreateBecAppBlbResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/CreateBecAppBlbResponse.java new file mode 100644 index 00000000..95179b1c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/CreateBecAppBlbResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for creating app blb. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecAppBlbResponse extends AbstractBceResponse { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The app blb name. + */ + private String name; + + /** + * The app blb description. + */ + private String desc; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/DeleteBecAppBlbRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/DeleteBecAppBlbRequest.java new file mode 100644 index 00000000..ae71a29f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/DeleteBecAppBlbRequest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for deleting app blb. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeleteBecAppBlbRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public DeleteBecAppBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/DeleteBecAppBlbResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/DeleteBecAppBlbResponse.java new file mode 100644 index 00000000..476bbcb6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/DeleteBecAppBlbResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for deleting app blb. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecAppBlbResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbRequest.java new file mode 100644 index 00000000..8994a67a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting app blb. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecAppBlbRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecAppBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbResponse.java new file mode 100644 index 00000000..a2427720 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.services.bec.model.vo.v2.BlbDetailVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting app blb. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAppBlbResponse extends BlbDetailVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbsRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbsRequest.java new file mode 100644 index 00000000..0b6b9f39 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbsRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vo.v2.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting app blbs. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecAppBlbsRequest extends AbstractBceRequest { + + /** + * ListRequest. + */ + private ListRequest listRequest; + + /** + * The app blb id. + */ + private String blbId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecAppBlbsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbsResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbsResponse.java new file mode 100644 index 00000000..8ab156b6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/GetBecAppBlbsResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.services.bec.model.vo.v2.BlbModel; +import com.baidubce.services.bec.model.vo.v2.ListResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting app blbs. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAppBlbsResponse extends ListResponse { + + /** + * The blbs. + */ + private List blbList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/UpdateBecAppBlbRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/UpdateBecAppBlbRequest.java new file mode 100644 index 00000000..ab8a3d58 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/UpdateBecAppBlbRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating app blb. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecAppBlbRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The app blb name. + */ + private String name; + + /** + * The description. + */ + private String desc; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecAppBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/UpdateBecAppBlbResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/UpdateBecAppBlbResponse.java new file mode 100644 index 00000000..1b67b23d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/instance/UpdateBecAppBlbResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating app blb. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecAppBlbResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/AppRule.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/AppRule.java new file mode 100644 index 00000000..456a9be8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/AppRule.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 20:18 + * @Version v1.0 + *

+ * AppRule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AppRule { + + /** + * Key. + */ + private String key; + + /** + * Value. + */ + private String value; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/BatchDeleteBecAppBlbListenersRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/BatchDeleteBecAppBlbListenersRequest.java new file mode 100644 index 00000000..75c4eecc --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/BatchDeleteBecAppBlbListenersRequest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vo.v2.ListenerModel; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for deleting batch app blb listeners. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchDeleteBecAppBlbListenersRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The port type List. + */ + List portTypeList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public BatchDeleteBecAppBlbListenersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/BatchDeleteBecAppBlbListenersResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/BatchDeleteBecAppBlbListenersResponse.java new file mode 100644 index 00000000..2d3f6b84 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/BatchDeleteBecAppBlbListenersResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for deleting batch app blb listeners. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteBecAppBlbListenersResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateAppPolicy.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateAppPolicy.java new file mode 100644 index 00000000..02af4335 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateAppPolicy.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 20:09 + * @Version v1.0 + *

+ * CreateAppPolicy. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateAppPolicy { + + /** + * The ip group id. + */ + private String appIpGroupId; + + /** + * The priority, 1-32768. + */ + private Integer priority; + + /** + * The description, default empty. + */ + private String desc; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbListenerPoliciesRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbListenerPoliciesRequest.java new file mode 100644 index 00000000..ef29423c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbListenerPoliciesRequest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for creating batch app blb listener policies. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateBecAppBlbListenerPoliciesRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The listener port. + */ + private Integer listenerPort; + + /** + * Type. + */ + private String type; + + /** + *The app policies. + */ + private List appPolicyVos; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public CreateBecAppBlbListenerPoliciesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbListenerPoliciesResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbListenerPoliciesResponse.java new file mode 100644 index 00000000..63941478 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbListenerPoliciesResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for creating batch app blb listener policies. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecAppBlbListenerPoliciesResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbTCPListenerRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbTCPListenerRequest.java new file mode 100644 index 00000000..de116611 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbTCPListenerRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for creating app blb tcp listener. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateBecAppBlbTCPListenerRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The listener port. + */ + private Integer listenerPort; + + /** + * The scheduler, scheduler must be [RoundRobin|LeastConnection|Hash]. + */ + private String scheduler; + + /** + * The tcp session timeout. + */ + private Integer tcpSessionTimeout; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public CreateBecAppBlbTCPListenerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbTCPListenerResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbTCPListenerResponse.java new file mode 100644 index 00000000..a71de4b6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbTCPListenerResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for creating app blb tcp listener. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecAppBlbTCPListenerResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbUDPListenerRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbUDPListenerRequest.java new file mode 100644 index 00000000..cf42f0e3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbUDPListenerRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for creating app blb upd listener. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateBecAppBlbUDPListenerRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The listener port. + */ + private Integer listenerPort; + + /** + * The scheduler, scheduler must be [RoundRobin|LeastConnection|Hash]. + */ + private String scheduler; + + /** + * The udp session timeout. + */ + private Integer udpSessionTimeout; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public CreateBecAppBlbUDPListenerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbUDPListenerResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbUDPListenerResponse.java new file mode 100644 index 00000000..da1e2633 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/CreateBecAppBlbUDPListenerResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for creating app blb upd listener. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecAppBlbUDPListenerResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/DeleteBecAppBlbListenerPoliciesRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/DeleteBecAppBlbListenerPoliciesRequest.java new file mode 100644 index 00000000..7b7753ec --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/DeleteBecAppBlbListenerPoliciesRequest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for deleting batch app blb listener policies. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DeleteBecAppBlbListenerPoliciesRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * Port. + */ + private Integer port; + + /** + * Type. + */ + private String type; + + /** + * policyIdList. + */ + private List policyIdList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public DeleteBecAppBlbListenerPoliciesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/DeleteBecAppBlbListenerPoliciesResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/DeleteBecAppBlbListenerPoliciesResponse.java new file mode 100644 index 00000000..e641f45e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/DeleteBecAppBlbListenerPoliciesResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for deleting batch app blb listener policies. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecAppBlbListenerPoliciesResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbListenerPoliciesRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbListenerPoliciesRequest.java new file mode 100644 index 00000000..6c163db2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbListenerPoliciesRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vo.v2.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting batch app blb listener policies. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecAppBlbListenerPoliciesRequest extends AbstractBceRequest { + + /** + * ListRequest. + */ + private ListRequest listRequest; + + /** + * The app blb id. + */ + private String blbId; + + /** + * The listener port. + */ + private Integer port; + + /** + * The type. + */ + private String type; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecAppBlbListenerPoliciesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbListenerPoliciesResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbListenerPoliciesResponse.java new file mode 100644 index 00000000..8d2007d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbListenerPoliciesResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.services.bec.model.vo.v2.AppPolicyVo; +import com.baidubce.services.bec.model.vo.v2.ListResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting batch app blb listener policies. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAppBlbListenerPoliciesResponse extends ListResponse { + /** + * The listener policies. + */ + private List policyList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbTCPListenersRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbTCPListenersRequest.java new file mode 100644 index 00000000..2ac32680 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbTCPListenersRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vo.v2.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting batch app blb listeners. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecAppBlbTCPListenersRequest extends AbstractBceRequest { + + /** + * ListRequest. + */ + private ListRequest listRequest; + + /** + * The app blb id. + */ + private String blbId; + + /** + * The listener port. + */ + private Integer listenerPort; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecAppBlbTCPListenersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbTCPListenersResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbTCPListenersResponse.java new file mode 100644 index 00000000..2c1923cc --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbTCPListenersResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting batch app blb listeners. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAppBlbTCPListenersResponse extends AbstractBceResponse { + + /** + * The listeners. + */ + List listenerList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbUDPListenersRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbUDPListenersRequest.java new file mode 100644 index 00000000..89dd830d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbUDPListenersRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vo.v2.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting batch app blb upd listeners. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecAppBlbUDPListenersRequest extends AbstractBceRequest { + + /** + * ListRequest. + */ + private ListRequest listRequest; + + /** + * The app blb id. + */ + private String blbId; + + /** + * The listener port. + */ + private Integer listenerPort; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecAppBlbUDPListenersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbUDPListenersResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbUDPListenersResponse.java new file mode 100644 index 00000000..be6cf760 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/GetBecAppBlbUDPListenersResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting batch app blb udp listeners. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAppBlbUDPListenersResponse extends AbstractBceResponse { + List listenerList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/TCPListenerModel.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/TCPListenerModel.java new file mode 100644 index 00000000..690d51b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/TCPListenerModel.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 19:57 + * @Version v1.0 + *

+ * TCPListenerModel. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TCPListenerModel { + /** + * The listener port. + */ + private Integer listenerPort; + + /** + * The scheduler, scheduler must be [RoundRobin|LeastConnection|Hash]. + */ + private String scheduler; + + /** + * The tcp session timeout. + */ + private Integer tcpSessionTimeout; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UDPListenerModel.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UDPListenerModel.java new file mode 100644 index 00000000..ed4d8334 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UDPListenerModel.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 19:57 + * @Version v1.0 + *

+ * UDPListenerModel. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UDPListenerModel { + + /** + * The listener port. + */ + private Integer listenerPort; + + /** + * The scheduler, scheduler must be [RoundRobin|LeastConnection|Hash]. + */ + private String scheduler; + + /** + * The tcp session timeout. + */ + private Integer tcpSessionTimeout; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbTCPListenerRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbTCPListenerRequest.java new file mode 100644 index 00000000..cba57165 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbTCPListenerRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating app blb tcp listener. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecAppBlbTCPListenerRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The listener port. + */ + private Integer listenerPort; + + /** + * The scheduler, scheduler must be [RoundRobin|LeastConnection|Hash]. + */ + private String scheduler; + + /** + * The tcp session timeout. + */ + private Integer tcpSessionTimeout; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecAppBlbTCPListenerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbTCPListenerResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbTCPListenerResponse.java new file mode 100644 index 00000000..b0b28552 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbTCPListenerResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating app blb tcp listener. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecAppBlbTCPListenerResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbUDPListenerRequest.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbUDPListenerRequest.java new file mode 100644 index 00000000..1c2727c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbUDPListenerRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating app blb udp listener. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecAppBlbUDPListenerRequest extends AbstractBceRequest { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The listener port. + */ + private Integer listenerPort; + + /** + * The scheduler, scheduler must be [RoundRobin|LeastConnection|Hash]. + */ + private String scheduler; + + /** + * The udp session timeout. + */ + private Integer udpSessionTimeout; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecAppBlbUDPListenerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbUDPListenerResponse.java b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbUDPListenerResponse.java new file mode 100644 index 00000000..013294bd --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/appblbv2/listener/UpdateBecAppBlbUDPListenerResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.appblbv2.listener; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating app blb tcp listener. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecAppBlbUDPListenerResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/blb/BlbBindingForm.java b/src/main/java/com/baidubce/services/bec/model/blb/BlbBindingForm.java new file mode 100644 index 00000000..de7f1fa0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/BlbBindingForm.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.Backends; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-19 14:22 + * @Version v1.0 + *

+ * BlbBindingForm. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BlbBindingForm { + + /** + * The deployment id. + */ + private String deploymentId; + + /** + * The backend weight allocation. + */ + private List podWeight; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/blb/BlbListenerRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/BlbListenerRequest.java new file mode 100644 index 00000000..c8e14bb3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/BlbListenerRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.enums.LbModeEnum; +import lombok.Data; + +/** + * The request for creating a load balancing listener setting. + */ +@Data +public class BlbListenerRequest extends AbstractBceRequest { + + /** + * Load balancing port. + */ + private Port frontendPort; + + /** + * Backend port. + */ + private Integer backendPort; + + /** + * Whether enable to get the true ip. + */ + private Boolean enableCipTTM; + + /** + * Forwarding rules. + */ + private LbModeEnum lbMode; + + /** + * Health check settings. + */ + private HealthCheck healthCheck; + + /** + * The keepalive timeout, 10 - 4000 seconds. + */ + private Integer keepaliveTimeout; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BlbListenerRequest with credentials. + */ + public BlbListenerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbBindingRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbBindingRequest.java new file mode 100644 index 00000000..099890eb --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbBindingRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * The request for binding the backend StatefulSet/VmReplicas. + */ +@Data +@Deprecated +public class CreateBecBlbBindingRequest extends AbstractBceRequest { + + /** + * The id of the blb. + */ + private String blbId; + + /** + * The binding forms. + */ + private List bindingForms; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecBlbBindingRequest with credentials. + */ + public CreateBecBlbBindingRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbBindingResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbBindingResponse.java new file mode 100644 index 00000000..bd257e90 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbBindingResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * The response for binding the backend StatefulSet/VmReplicas. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@Deprecated +public class CreateBecBlbBindingResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbMonitorPortRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbMonitorPortRequest.java new file mode 100644 index 00000000..08aa5db1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbMonitorPortRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * The request for creating the BEC blb monitor port. + */ +@Data +@Deprecated +public class CreateBecBlbMonitorPortRequest extends BlbListenerRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public CreateBecBlbMonitorPortRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbMonitorPortResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbMonitorPortResponse.java new file mode 100644 index 00000000..f3a4af95 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbMonitorPortResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * The response for creating the BEC blb monitor port. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@Deprecated +public class CreateBecBlbMonitorPortResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbRequest.java new file mode 100644 index 00000000..4c8367c9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbRequest.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.enums.ServiceProviderEnum; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +/** + * The request for creating BEC blb. + * Shared with blb and app blb creation. + */ +@Data +@Builder +public class CreateBecBlbRequest extends AbstractBceRequest { + + /** + * Load balance type. + */ + private String lbType; + + /** + * The payment method of the blb. + */ + private String paymentMethod; + + /** + * The name of the blb. + */ + private String blbName; + + /** + * Region selection. + */ + private String regionSelection; + + /** + * The region of the blb. + */ + private String region; + + /** + * The city of the blb. + */ + private String city; + + /** + * The serviceProvider of the blb. + */ + private ServiceProviderEnum serviceProvider; + + /** + * The region id of the blb. + */ + private String regionId; + + /** + * The need for public IP. + */ + private Boolean needPublicIp; + + /** + * Load balancing maximum bandwidth limit, 1 - 20000 Mbps. + */ + private Integer bandwidthInMbpsLimit; + + /** + * tags. + */ + private List tags; + + /** + * The network type, bec network type must be [classic|vpc], default classic. + */ + private String networkType; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * The subnet id. + */ + private String subnetId; + + /** + * The subServiceProvider of the blb, intra represent inner net, [ct,un,cm,intra]. + */ + protected List subServiceProviders; + + /** + * Whether the blb need public ipv6. + */ + private Boolean needIpv6PublicIp; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecBlbRequest with credentials. + */ + public CreateBecBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbResponse.java new file mode 100644 index 00000000..691d6a03 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/CreateBecBlbResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.baidubce.services.bec.model.vo.BlbInstanceVo; +import lombok.Data; + +/** + * The response for creating BEC blb. + */ +@Data +public class CreateBecBlbResponse extends ActionInfoVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbBindPodRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbBindPodRequest.java new file mode 100644 index 00000000..d497e58a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbBindPodRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.Backends; +import lombok.Data; + +import java.util.List; + +/** + * The request for deleting the Pod/Vm bound to the specified BLB backend. + */ +@Data +public class DeleteBecBlbBindPodRequest extends AbstractBceRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * Backend server information + */ + private List podWeightList; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public DeleteBecBlbBindPodRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbBindPodResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbBindPodResponse.java new file mode 100644 index 00000000..060b79b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbBindPodResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * The response for deleting the Pod/Vm bound to the specified BLB backend. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecBlbBindPodResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbMonitorPortRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbMonitorPortRequest.java new file mode 100644 index 00000000..502f5ae5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbMonitorPortRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +/** + * The request for deleting the BEC blb monitor port. + */ +@Data +public class DeleteBecBlbMonitorPortRequest extends AbstractBceRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * List of blb listening ports + */ + private List monitorPorts; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteBecBlbMonitorPortRequest with credentials. + */ + public DeleteBecBlbMonitorPortRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbMonitorPortResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbMonitorPortResponse.java new file mode 100644 index 00000000..75421a0c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbMonitorPortResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * The response for deleting the BEC blb monitor port. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecBlbMonitorPortResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbRequest.java new file mode 100644 index 00000000..f6852ba3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for deleting the BEC blb instance. + */ +@Data +public class DeleteBecBlbRequest extends AbstractBceRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteBecBlbRequest with credentials. + */ + public DeleteBecBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbResponse.java new file mode 100644 index 00000000..b4c7fa53 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/DeleteBecBlbResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; + +import java.util.Map; + +/** + * The response for deleting the BEC blb instance. + */ +public class DeleteBecBlbResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendBindingStsListRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendBindingStsListRequest.java new file mode 100644 index 00000000..b6681386 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendBindingStsListRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the StatefulSet/VmReplicas list that can be bound by the designated BEC blb. + */ +@Data +public class GetBecBlbBackendBindingStsListRequest extends AbstractBceRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * page number. + */ + private int pageNo; + + /** + * page size. + */ + private int pageSize; + + /** + * Key word type,default serviceId. + */ + private String keywordType; + + /** + * Key word. + */ + private String keyword; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public GetBecBlbBackendBindingStsListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendBindingStsListResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendBindingStsListResponse.java new file mode 100644 index 00000000..c22c3b86 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendBindingStsListResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for getting the StatefulSet/VmReplicas list that can be bound by the designated BEC blb. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecBlbBackendBindingStsListResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendPodListRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendPodListRequest.java new file mode 100644 index 00000000..d5b3730f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendPodListRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the bind BEC blb backend Pod/Vm list. + */ +@Data +public class GetBecBlbBackendPodListRequest extends AbstractBceRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * page number + */ + private int pageNo; + + /** + * page size + */ + private int pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecBlbPodBoundListRequest with credentials. + */ + public GetBecBlbBackendPodListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendPodListResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendPodListResponse.java new file mode 100644 index 00000000..972eb7a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBackendPodListResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.BlbBackendPodBriefVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for getting the bind BEC blb backend Pod/Vm list. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecBlbBackendPodListResponse extends LogicPageResultResponse { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBindingPodListWithStsRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBindingPodListWithStsRequest.java new file mode 100644 index 00000000..767c90a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBindingPodListWithStsRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the binding BEC blb backend Pod/Vm list. + * Getting the pod or vm list that can be bound under the deployment status condition. + */ +@Data +public class GetBecBlbBindingPodListWithStsRequest extends AbstractBceRequest { + + /** + * the id of the blb + */ + private String blbId; + + /** + * Deployment name + */ + private String stsName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecBlbBindingPodListWithStsRequest with credentials. + */ + public GetBecBlbBindingPodListWithStsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBindingPodListWithStsResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBindingPodListWithStsResponse.java new file mode 100644 index 00000000..ffc81575 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbBindingPodListWithStsResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.Backends; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * The response for getting the binding BEC blb backend pod or vm list under the deployment status condition. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecBlbBindingPodListWithStsResponse extends AbstractBceResponse { + + /** + * Backend server information + */ + private List result; +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbInstanceRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbInstanceRequest.java new file mode 100644 index 00000000..a9c61f98 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbInstanceRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the BEC blb instance info. + */ +@Data +public class GetBecBlbInstanceRequest extends AbstractBceRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecBlbRequest with credentials. + */ + public GetBecBlbInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbInstanceResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbInstanceResponse.java new file mode 100644 index 00000000..ccb7e417 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbInstanceResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.BlbInstanceVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for getting the BEC blb instance info. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecBlbInstanceResponse extends BlbInstanceVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortDetailsRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortDetailsRequest.java new file mode 100644 index 00000000..615f2d52 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortDetailsRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.enums.ProtocolEnum; +import lombok.Data; + +/** + * The request for getting the BEC blb monitor port details. + */ +@Data +public class GetBecBlbMonitorPortDetailsRequest extends AbstractBceRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * the protocol of the blb. + */ + private ProtocolEnum protocol; + + /** + * the port of the blb. + */ + private Integer port; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public GetBecBlbMonitorPortDetailsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortDetailsResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortDetailsResponse.java new file mode 100644 index 00000000..9579c504 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortDetailsResponse.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.enums.LbModeEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for getting the BEC blb monitor port details. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecBlbMonitorPortDetailsResponse extends AbstractBceResponse { + + /** + * Load balancing port. + */ + private Port frontendPort; + + /** + * Backend port. + */ + private Integer backendPort; + + /** + * Forwarding rules. + */ + private LbModeEnum lbMode; + + /** + * Health check settings. + */ + private HealthCheck healthCheck; + + /** + * The keepalive timeout. + */ + private Integer keepaliveTimeout; +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortListRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortListRequest.java new file mode 100644 index 00000000..bbc6f24e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortListRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the BEC blb port monitor list. + */ +@Data +public class GetBecBlbMonitorPortListRequest extends AbstractBceRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * page number. + */ + private int pageNo; + + /** + * page size. + */ + private int pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecBlbMonitorPortsRequest with credentials. + */ + public GetBecBlbMonitorPortListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortListResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortListResponse.java new file mode 100644 index 00000000..aeb3186d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbMonitorPortListResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.Listeners; +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for getting the BEC blb port monitor list. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecBlbMonitorPortListResponse extends LogicPageResultResponse { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbResourceMetricsRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbResourceMetricsRequest.java new file mode 100644 index 00000000..eccb4bf1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbResourceMetricsRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the BEC blb monitor metrics. + */ +@Data +public class GetBecBlbResourceMetricsRequest extends AbstractBceRequest { + + /** + * The id of the blb. + */ + private String blbId; + + /** + * The metrics type. + */ + private String metricsType; + + /** + * The type of the network. + */ + private String ipType; + + /** + * Query port. + */ + private String port; + + /** + * The start time, unix timestamp, the unit is second. + */ + private Long start; + + /** + * The start time, unix timestamp, the unit is second. + */ + private Long end; + + /** + * ServiceProvider. + */ + private String serviceProvider; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public GetBecBlbResourceMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbResourceMetricsResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbResourceMetricsResponse.java new file mode 100644 index 00000000..362b768b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbResourceMetricsResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.MetricsVo; +import lombok.Data; + +/** + * The response for getting the BEC blb monitor metrics. + */ +@Data +public class GetBecBlbResourceMetricsResponse extends MetricsVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbsRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbsRequest.java new file mode 100644 index 00000000..d0617350 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbsRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting BEC blb list. + */ +@Data +public class GetBecBlbsRequest extends AbstractBceRequest { + + /** + * Load balance type. + */ + private String lbType; + + /** + * page number + */ + private int pageNo; + + /** + * page size + */ + private int pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecBlbsRequest with credentials. + */ + public GetBecBlbsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbsResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbsResponse.java new file mode 100644 index 00000000..4c72f172 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/GetBecBlbsResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.BlbInstanceVo; + +/** + * The response for getting the BEC blb list. + */ +public class GetBecBlbsResponse extends LogicPageResultResponse { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/HealthCheck.java b/src/main/java/com/baidubce/services/bec/model/blb/HealthCheck.java new file mode 100644 index 00000000..d83e5fe3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/HealthCheck.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import lombok.Data; + +/** + * Health check settings. + */ +@Data +public class HealthCheck { + + /** + * Response timeout period. + */ + private Integer timeoutInSeconds; + + /** + * Health check interval time. + */ + private Integer intervalInSeconds; + + /** + * Unhealthy threshold. + */ + private Integer unhealthyThreshold; + + /** + * Healthy threshold. + */ + private Integer healthyThreshold; + + /** + * Healthy check string, udp check string. + */ + private String healthCheckString; + + /** + * The health check type, like tcp, http, udp. + */ + private String healthCheckType; + + /** + * The health check url path, default /. + */ + private String healthCheckURI; +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/LbDeployPo.java b/src/main/java/com/baidubce/services/bec/model/blb/LbDeployPo.java new file mode 100644 index 00000000..321391ac --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/LbDeployPo.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.Backends; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; + +/** + * Blb deployment + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class LbDeployPo { + + /** + * The service name which the lb belong to. + */ + private String serviceName; + + /** + * The backends which can be bound to lb. + */ + List backends; + + /** + * The name of the deployment. + */ + private String deploymentName; + + /** + * User-defined name. + */ + private String customOrigName; + + /** + * The id of the service. + */ + private String serviceId; + + /** + * The type of the deployment. + */ + private String deploymentType; + + /** + * The region of the deployment + */ + private String region; + + /** + * The service provider of the deployment + */ + private String serviceProvider; + + /** + * The city of the deployment + */ + private String city; + + /** + * Number of Pod\Vm instances under deployment. + */ + private Integer replicas; + + /** + * Pod\vm instance cpu usage. + */ + private Integer podCpu; + + /** + * Pod\Vm instance memory usage. + */ + private Integer podMemory; + + /** + * Pod\vm instance gpu usage. + */ + private Integer podGpu; + + /** + * Pod\vm instance disk usage. + */ + private String podDataStorage; + + /** + * The need for public IP. + */ + private Boolean podIpRequired; + + /** + * Last billing time + */ + private long lastBillTime; + + /** + * Whether th lb need public IPv6. + */ + private Boolean podIpv6Required; + + /** + * Deployment creation time. + */ + private Timestamp createTime; + + /** + * Deployment update time + */ + private Timestamp updateTime; + + /** + * The network type, classic/vpc. + */ + private String networkType; + + /** + * The gpu type. + */ + private String gpuType; +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/Port.java b/src/main/java/com/baidubce/services/bec/model/blb/Port.java new file mode 100644 index 00000000..e5c832be --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/Port.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.enums.ProtocolEnum; +import lombok.Data; + +@Data +public class Port { + + /** + * Listen protocol. + */ + private ProtocolEnum protocol; + + /** + * Listen port, 1 - 65535. + */ + private Integer port; +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbBindPodWeightRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbBindPodWeightRequest.java new file mode 100644 index 00000000..55bb6a12 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbBindPodWeightRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.Backends; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * The request for modifying the weight of the Pod/Vm. + */ +@Data +public class UpdateBecBlbBindPodWeightRequest extends AbstractBceRequest { + + /** + * The id of the blb. + */ + private String blbId; + + /** + * Backend server information. + */ + private List podWeightList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public UpdateBecBlbBindPodWeightRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbBindPodWeightResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbBindPodWeightResponse.java new file mode 100644 index 00000000..60bc1a75 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbBindPodWeightResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * The response for modifying the weight of the Pod/Vm. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecBlbBindPodWeightResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbMonitorPortRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbMonitorPortRequest.java new file mode 100644 index 00000000..26ebd618 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbMonitorPortRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.blb.BlbListenerRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * The request for updating the Blb monitor port. + */ +@Data +public class UpdateBecBlbMonitorPortRequest extends BlbListenerRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbMonitorPortResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbMonitorPortResponse.java new file mode 100644 index 00000000..732aaa1f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbMonitorPortResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * The response for updating the Blb monitor port. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecBlbMonitorPortResponse extends ActionInfoVo> { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbRequest.java b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbRequest.java new file mode 100644 index 00000000..39b372cc --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * The request for updating the BEC blb instance. + */ +@Data +public class UpdateBecBlbRequest extends AbstractBceRequest { + + /** + * the id of the blb. + */ + private String blbId; + + /** + * The name of the blb. + */ + private String blbName; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public UpdateBecBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbResponse.java b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbResponse.java new file mode 100644 index 00000000..911d835e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/blb/UpdateBecBlbResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.blb; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.baidubce.services.bec.model.vo.BlbInstanceVo; + +import java.util.Map; + +/** + * The response for updating the BEC blb instance. + */ +public class UpdateBecBlbResponse extends ActionInfoVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/enums/ActionTypeEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/ActionTypeEnum.java new file mode 100644 index 00000000..3d5b9e05 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/ActionTypeEnum.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-06 21:37 + * @Version v1.0 + * + * Action type enum + */ +public enum ActionTypeEnum { + NEW, + + UPGRADE, + + UPDATE, + + RENEW, +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/enums/DiskTypeEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/DiskTypeEnum.java new file mode 100644 index 00000000..6fb8c4f4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/DiskTypeEnum.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 11:57 + * @Version v1.0 + *

+ * The enum of disk type. + */ +public enum DiskTypeEnum { + + NVME("csi-lvm-ssd", "ssd", "1GB"), + + SATA("csi-lvm-hdd", "hdd", "1GB"), + + CDS_HDD("csi-cds-hdd", "cds_hdd", "1GB"), + + CDS_SSD("csi-cds-ssd", "cds_ssd", "1GB"), + + HDD_PASSTHROUGH("local-storage-hdd", "hdd", "1GB"), + + SSD_PASSTHROUGH("local-storage-ssd", "ssd", "1GB"), + + VK_CDS_SSD("vk-csi-cds-ssd", "cds_ssd", "1GB"), + + VK_CDS_HDD("vk-csi-cds-hdd", "cds_hdd", "1GB"); + + private String storageClassName; + + private String flavorName; + + private String flavorValue; + + DiskTypeEnum(String storageClassName, String flavorName, String flavorValue) { + this.storageClassName = storageClassName; + this.flavorName = flavorName; + this.flavorValue = flavorValue; + } + + public String getStorageClassName() { + return storageClassName; + } + + public String getFlavorName() { + return this.flavorName; + } + + public String getFlavorValue() { + return this.flavorValue; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/enums/DnsTypeEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/DnsTypeEnum.java new file mode 100644 index 00000000..5cc4a279 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/DnsTypeEnum.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-14 11:45 + * @Version v1.0 + * The enum of dns type. + */ +public enum DnsTypeEnum { + /** + * none. + */ + NONE(""), + + /** + * default. + */ + DEFAULT("default"), + + /** + * local. + */ + LOCAL("local"), + + /** + * customize. + */ + CUSTOMIZE("customize"); + + private final String value; + + DnsTypeEnum(String val) { + this.value = val; + } + + public String getValue() { + return this.value; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/enums/LbModeEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/LbModeEnum.java new file mode 100644 index 00000000..4b824ea1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/LbModeEnum.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-19 11:39 + * @Version v1.0 + *

+ * The enum of load balance mode/strategy. + */ +public enum LbModeEnum { + + wrr("RoundRobin"), + + minconn("LeastConnection"), + + srch("Hash"); + + /** + * The rule of dispatch. + */ + private String value; + + public String getValue() { + return value; + } + + LbModeEnum(String value) { + this.value = value; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/enums/NetTypeEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/NetTypeEnum.java new file mode 100644 index 00000000..71b04ea1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/NetTypeEnum.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 13:55 + * @Version v1.0 + *

+ * The enum of network type. + */ +public enum NetTypeEnum { + + /** + * Internal ip + */ + INTERNAL_IP("internalIp"), + + /** + * Public ip + */ + PUBLIC_IP("publicIp"), + + /** + * Three-way. + */ + TRIPLE("triple"), + + /** + * China Telecom. + */ + TRIPLE_CT("ct"), + + /** + * China Unicom. + */ + TRIPLE_UN("un"), + + /** + * China Mobile. + */ + TRIPLE_CM("cm"), + + /** + * Unknown. + */ + UNKNOWN("unknown"); + + private String value; + + NetTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/enums/NodeTypeEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/NodeTypeEnum.java new file mode 100644 index 00000000..6eed93ce --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/NodeTypeEnum.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 12:17 + * @Version v1.0 + * + * The enum of node type. + */ +public enum NodeTypeEnum { + SINGLE("single"), + + TRIPLE("triple"), + + UNKNOWN("unknown"); + + private String value; + + NodeTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/enums/ProtocolEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/ProtocolEnum.java new file mode 100644 index 00000000..ff8e48d6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/ProtocolEnum.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-19 11:37 + * @Version v1.0 + *

+ * The enum of protocol. + */ +public enum ProtocolEnum { + + TCP("tcp"), + + UDP("udp"), + + HTTP("http"), + + HTTPS("https"), + + SSL("ssl"), + + ICMP("icmp"); + + private String value; + + public String getValue() { + return value; + } + + ProtocolEnum(String value) { + this.value = value; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/enums/ResourceStatusEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/ResourceStatusEnum.java new file mode 100644 index 00000000..88dfa869 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/ResourceStatusEnum.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-10 22:06 + * @Version v1.0 + *

+ * The enum of resource status. + */ +public enum ResourceStatusEnum { + + STARTING("启动中"), + + RUNNING("运行中"), + + PENDING("调度中"), + + EXCEPTION("异常"), + + FAILED("错误"), + + UNKNOWN("未知"), + + TERMINATED("中止"), + + WAITING("等待"), + + STOP("停止"), + + BINDING("绑定中"), + + STOPPING("关机中"), + + TERMINATING("终止中"), + + DELETING("删除中"), + + NORMAL("正常"); + + private String value; + + ResourceStatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/enums/RouteTypeEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/RouteTypeEnum.java new file mode 100644 index 00000000..e40a29eb --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/RouteTypeEnum.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 13:55 + * @Version v1.0 + *

+ * The enum of route type. + */ +public enum RouteTypeEnum { + + BLACK_HOLE("blackhole", "黑洞路由", "blackhole", "blackhole"), + + CUSTOM("custom", "实例路由", "custom", "custom"), + + SYSTEM("system", "系统", "system", "sys"), + + TGW("vpc2tgw", "TGW路由", "vpc2tgw", "tgw"), + + HAVIP("havip", "高可用虚拟IP", "custom", "custom"), + + NAT("nat", "NAT网关", "nat", "nat"); + + private final String value; + + private final String name; + + private final String bvsValue; + + private final String csnValue; + + RouteTypeEnum(String value, String name, String bvsValue, String csnValue) { + this.name = name; + this.value = value; + this.bvsValue = bvsValue; + this.csnValue = csnValue; + } + + public String getValue() { + return value; + } + + public String getName() { + return name; + } + + public String getBvsValue() { + return bvsValue; + } + + public String getCsnValue() { + return csnValue; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/enums/ServiceProviderEnum.java b/src/main/java/com/baidubce/services/bec/model/enums/ServiceProviderEnum.java new file mode 100644 index 00000000..863de94b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/enums/ServiceProviderEnum.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.enums; + +/** + * The enum of service provider. + */ +public enum ServiceProviderEnum { + BGP("b", "BGP", "bgp"), + + CHINA_MOBILE("m", "移动", "cm"), + + CHINA_UNICOM("u", "联通", "un"), + + CHINA_TELECOM("t", "电信", "ct"), + + TRIPLE_LINE("l", "三线", "tl"), + + INTRA("", "内网", "intra"); + + private final String value; + + private final String name; + + private final String abbr; + + public static final String ABBR_IX = "ix"; + + ServiceProviderEnum(String value, String name, String abbr) { + this.value = value; + this.name = name; + this.abbr = abbr; + } + + public String getValue() { + return value; + } + + public String getName() { + return name; + } + + public String getAbbr() { + return abbr; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/handler/BecHttpResponseHandler.java b/src/main/java/com/baidubce/services/bec/model/handler/BecHttpResponseHandler.java new file mode 100644 index 00000000..fdb61625 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/handler/BecHttpResponseHandler.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.handler; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.Backends; +import com.baidubce.services.bec.model.blb.GetBecBlbBindingPodListWithStsResponse; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.util.EntityUtils; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * The bec http response handler. + */ +public class BecHttpResponseHandler implements HttpResponseHandler { + + public static final ObjectMapper mapper = new ObjectMapper(); + + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + if (!response.getClass().equals(GetBecBlbBindingPodListWithStsResponse.class)) { + return false; + } + InputStream content = httpResponse.getContent(); + if (content == null) { + return false; + } + if (response.getMetadata().getContentLength() > 0 + || "chunked".equalsIgnoreCase(response.getMetadata().getTransferEncoding())) { + String value = EntityUtils.toString(httpResponse.getHttpResponse().getEntity()); + JavaType javaType = getCollectionType(ArrayList.class, Backends.class); + List list = (List) mapper.readValue(value, javaType); + GetBecBlbBindingPodListWithStsResponse response1 = (GetBecBlbBindingPodListWithStsResponse) response; + response1.setResult(list); + return true; + } + content.close(); + return false; + } + + + public static JavaType getCollectionType(Class collectionClass, Class... elementClasses) { + return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses); + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/network/SecurityGroupRuleVo.java b/src/main/java/com/baidubce/services/bec/model/network/SecurityGroupRuleVo.java new file mode 100644 index 00000000..d07faf10 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/SecurityGroupRuleVo.java @@ -0,0 +1,84 @@ +package com.baidubce.services.bec.model.network; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * SecurityGroupRule + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SecurityGroupRuleVo { + + /** + * The id of the securityGroup. + */ + private String securityGroupId; + + /** + * The id of the securityGroup rule. + */ + private String securityGroupRuleId; + + /** + * Direction, eg:ingress + */ + private String direction; + + /** + * Protocol + */ + private String protocol; + + /** + * PortRange + */ + private String portRange; + + /** + * Remark + */ + private String remark; + + /** + * EtherType + */ + private String etherType; + + /** + * SourceGroupId + */ + private String sourceGroupId; + + /** + * SourceIp + */ + private String sourceIp; + + /** + * DestGroupId + */ + private String destGroupId; + + /** + * DestIp + */ + private String destIp; + + /** + * CreatedTime + */ + private String createdTime; + + /** + * UpdatedTime + */ + private String updatedTime; + + /** + * IsValid + */ + private Boolean isValid; +} diff --git a/src/main/java/com/baidubce/services/bec/model/network/SecurityGroupVo.java b/src/main/java/com/baidubce/services/bec/model/network/SecurityGroupVo.java new file mode 100644 index 00000000..f4ab681c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/SecurityGroupVo.java @@ -0,0 +1,45 @@ +package com.baidubce.services.bec.model.network; + +import com.baidubce.BceConstants; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * SecurityGroup + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SecurityGroupVo { + + /** + * The id of the SecurityGroup. + */ + private String id; + + /** + * The name of the SecurityGroup. + */ + private String name; + + /** + * The desc of the SecurityGroup. + */ + private String desc; + + /** + * SecurityGroupRuleVo list + */ + private List rules; + + /** + * Creation time + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + private Date createdTime; +} diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/AclRule.java b/src/main/java/com/baidubce/services/bec/model/network/acl/AclRule.java new file mode 100644 index 00000000..82e57383 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/AclRule.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 19:25 + * @Version v1.0 + * The acl rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AclRule { + + /** + * The subnet id. + */ + private String subnetId; + + /** + * The description. + */ + private String description; + + /** + * Protocol, the value must be all|tcp|udp|icmp. + */ + private String protocol; + + /** + * Source ip address. + * ACL egress source ip address must be in subnet. + * Can take the value "all", represent all ip. + */ + private String sourceIpAddress; + + /** + * Destination ip address. + * ACL ingress destination ip address must be in subnet. + * Can take the value "all", represent all ip. + */ + private String destinationIpAddress; + + /** + * Source port, the value range is 0-65535. + */ + private String sourcePort; + + /** + * Destination port, the value range is 0-65535. + */ + private String destinationPort; + + /** + * The priority, the value range is 1-32768. + * The smaller the value, the higer the priority. + */ + private Integer position; + + /** + * The restrictive direction, the value must be ingress/egress. + */ + private String direction; + + /** + * The ether type, the value must be IPv4/IPv6. + */ + private String etherType; + + /** + * The action policy, the value must be "allow/deny". + */ + private String action; + + /** + * Whether is default. + */ + @JsonProperty("isDefault") + private Boolean isDefault; + + /** + * Whether is valid. + */ + private Boolean isValid; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/BatchCreateBecAclRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/acl/BatchCreateBecAclRulesRequest.java new file mode 100644 index 00000000..1e83e54e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/BatchCreateBecAclRulesRequest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The request for creating the batch acl rules. + */ +@Data +public class BatchCreateBecAclRulesRequest extends AbstractBceRequest { + + /** + * The subnet id. + */ + private String subnetId; + + /** + * The acl rules. + */ + private List aclRules; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BatchCreateBecAclRulesRequest with credentials. + */ + public BatchCreateBecAclRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/BatchCreateBecAclRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/acl/BatchCreateBecAclRulesResponse.java new file mode 100644 index 00000000..b32624c2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/BatchCreateBecAclRulesResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The response for creating the batch acl rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchCreateBecAclRulesResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/BatchDeleteBecAclRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/acl/BatchDeleteBecAclRulesRequest.java new file mode 100644 index 00000000..40ade1f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/BatchDeleteBecAclRulesRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The request for deleting the acl rules. + */ +@Data +public class BatchDeleteBecAclRulesRequest extends AbstractBceRequest { + + /** + * The acl rule ids. + */ + private List aclRuleIds; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BatchDeleteBecAclRulesRequest with credentials. + */ + public BatchDeleteBecAclRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/BatchDeleteBecAclRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/acl/BatchDeleteBecAclRulesResponse.java new file mode 100644 index 00000000..fc996bc7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/BatchDeleteBecAclRulesResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The response for deleting the acl rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteBecAclRulesResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclRequest.java b/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclRequest.java new file mode 100644 index 00000000..66a21a7d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The request for getting the acl. + */ +@Data +public class GetBecAclRequest extends AbstractBceRequest { + + /** + * The vpc id. + */ + private String vpcId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecAclRequest with credentials. + */ + public GetBecAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclResponse.java b/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclResponse.java new file mode 100644 index 00000000..d28f0b96 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.vo.AclVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The response for getting the acl detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAclResponse extends AbstractBceResponse { + + /** + * The acl. + */ + private AclVo acl; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclsRequest.java b/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclsRequest.java new file mode 100644 index 00000000..111fb9d8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclsRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The request for getting the acls. + */ +@Data +public class GetBecAclsRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * The region id. + */ + private String regionId; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecAclsRequest + * with credentials. + */ + public GetBecAclsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclsResponse.java b/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclsResponse.java new file mode 100644 index 00000000..86e52026 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/GetBecAclsResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.AclVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:46 + * @Version v1.0 + *

+ * The response for getting the acls. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecAclsResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclRequest.java b/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclRequest.java new file mode 100644 index 00000000..5ed5bf52 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The request for updating the acl. + */ +@Data +public class UpdateBecAclRequest extends AbstractBceRequest { + + /** + * The acl id. + */ + private String aclId; + + /** + * The acl name. + */ + private String name; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecAclRequest with credentials. + */ + public UpdateBecAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclResponse.java b/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclResponse.java new file mode 100644 index 00000000..57947c10 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The response for updating the acl. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecAclResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclRuleRequest.java b/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclRuleRequest.java new file mode 100644 index 00000000..1892948a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclRuleRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The request for updating the acl rule. + */ +@Data +public class UpdateBecAclRuleRequest extends AbstractBceRequest { + + /** + * The acl rule id. + */ + private String aclRuleId; + + /** + * The acl rule. + */ + private AclRule aclRule; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecAclRuleRequest with credentials. + */ + public UpdateBecAclRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclRuleResponse.java b/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclRuleResponse.java new file mode 100644 index 00000000..b0e7a8ce --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/acl/UpdateBecAclRuleResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.acl; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The response for updating the acl rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecAclRuleResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/NatDeploymentInstance.java b/src/main/java/com/baidubce/services/bec/model/network/nat/NatDeploymentInstance.java new file mode 100644 index 00000000..c880d484 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/NatDeploymentInstance.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-22 10:00 + * @Version v1.0 + *

+ * The abstract of nat deployment instance. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NatDeploymentInstance { + + /** + * The nat id. + */ + private String natId; + + /** + * The region id. + */ + private String regionId; + + /** + * The sub isp service providers, optional ct,un,cm under S-NAT, optional ct,un,cm,ix,nil under S-NAT. + * Ix represents triple-line, nil represents that do not need D-NAT ip. + */ + protected List subServiceProviders; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * The specification, the value must be [small|mid|large]. + */ + private String spec; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchCreateBecDnatRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchCreateBecDnatRulesRequest.java new file mode 100644 index 00000000..68b97e07 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchCreateBecDnatRulesRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:58 + * @Version v1.0 + *

+ * The request for creating batch D-NAT rules. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchCreateBecDnatRulesRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * D-NAT rules. + */ + private List rules; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public BatchCreateBecDnatRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchCreateBecDnatRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchCreateBecDnatRulesResponse.java new file mode 100644 index 00000000..d260b01e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchCreateBecDnatRulesResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:59 + * @Version v1.0 + *

+ * The response for creating batch D-NAT rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchCreateBecDnatRulesResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchDeleteBecDnatRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchDeleteBecDnatRulesRequest.java new file mode 100644 index 00000000..87fc87a9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchDeleteBecDnatRulesRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for deleting batch D-NAT rules. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchDeleteBecDnatRulesRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * The D-NAT rule ids. + */ + private List ruleIdList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public BatchDeleteBecDnatRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchDeleteBecDnatRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchDeleteBecDnatRulesResponse.java new file mode 100644 index 00000000..c810d9d5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/BatchDeleteBecDnatRulesResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for deleting batch D-NAT rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteBecDnatRulesResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/CreateBecDnatRuleRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/CreateBecDnatRuleRequest.java new file mode 100644 index 00000000..72de4861 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/CreateBecDnatRuleRequest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:58 + * @Version v1.0 + *

+ * The request for creating D-NAT rule. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateBecDnatRuleRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * The intranet ip address. + */ + private String privateIpAddress; + + /** + * The intranet port, 1-65535; must assign under TCP/UDP protocol. + */ + private String privatePort; + + /** + * Protocol, must be [TCP|UDP|all]. + */ + private String protocol; + + /** + * The public ip address of the D-NAT. + */ + private String publicIpAddress; + + /** + * The public port of the D-NAT, 1-65535; must assign under TCP/UDP protocol. + */ + private String publicPort; + + /** + * The rule name. + */ + private String ruleName; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public CreateBecDnatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/CreateBecDnatRuleResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/CreateBecDnatRuleResponse.java new file mode 100644 index 00000000..fe3202f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/CreateBecDnatRuleResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:59 + * @Version v1.0 + *

+ * The response for creating D-NAT rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecDnatRuleResponse extends AbstractBceResponse { + + /** + * The D-NAT rule id. + */ + private String ruleId; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/GetBecDnatRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/GetBecDnatRulesRequest.java new file mode 100644 index 00000000..bb620e99 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/GetBecDnatRulesRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting D-NAT rules. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecDnatRulesRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * Page number of display page. + */ + public int pageNo; + + /** + * The number of services on the display page. + */ + public int pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecDnatRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/GetBecDnatRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/GetBecDnatRulesResponse.java new file mode 100644 index 00000000..cef48a29 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/GetBecDnatRulesResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.DnatRuleVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The responsefor getting D-NAT rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecDnatRulesResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/UpdateBecDnatRuleRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/UpdateBecDnatRuleRequest.java new file mode 100644 index 00000000..48ff036a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/UpdateBecDnatRuleRequest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating D-NAT rule. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecDnatRuleRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * The rule id. + */ + private String ruleId; + + /** + * The intranet ip address. + */ + private String privateIpAddress; + + /** + * The intranet port. + */ + private String privatePort; + + /** + * Protocol, must be [TCP|UDP|all]. + */ + private String protocol; + + /** + * The public ip address of the D-NAT. + */ + private String publicIpAddress; + + /** + * The public port of the D-NAT, 1-65535; must assign under TCP/UDP protocol. + */ + private String publicPort; + + /** + * The rule name. + */ + private String ruleName; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecDnatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/UpdateBecDnatRuleResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/UpdateBecDnatRuleResponse.java new file mode 100644 index 00000000..f023a920 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/dnatrule/UpdateBecDnatRuleResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.dnatrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating D-NAT rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecDnatRuleResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchCreateBecNatsRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchCreateBecNatsRequest.java new file mode 100644 index 00000000..cd28c7b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchCreateBecNatsRequest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.network.nat.NatDeploymentInstance; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:58 + * @Version v1.0 + *

+ * The request for creating batch nats. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchCreateBecNatsRequest extends AbstractBceRequest { + + /** + * The nat bandwidth, >1. + */ + private Integer bandwidth; + + /** + * The nat deployment instances. + */ + private List deployInstances; + + /** + * The description. + */ + private String desc; + + /** + * The nat name. + */ + private String name; + + /** + * The tags. + */ + private List tags; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public BatchCreateBecNatsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchCreateBecNatsResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchCreateBecNatsResponse.java new file mode 100644 index 00000000..a786f5ff --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchCreateBecNatsResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.network.nat.NatDeploymentInstance; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:59 + * @Version v1.0 + *

+ * The response for creating batch nats. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchCreateBecNatsResponse extends AbstractBceResponse { + private List deployInstances; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchDeleteBecNatsRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchDeleteBecNatsRequest.java new file mode 100644 index 00000000..693bc0b8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchDeleteBecNatsRequest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for deleting batch nats. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchDeleteBecNatsRequest extends AbstractBceRequest { + + /** + * The nat ids. + */ + private List natIdList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public BatchDeleteBecNatsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchDeleteBecNatsResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchDeleteBecNatsResponse.java new file mode 100644 index 00000000..e48dd10d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/BatchDeleteBecNatsResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for deleting batch nats. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteBecNatsResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatMetricsRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatMetricsRequest.java new file mode 100644 index 00000000..fd896fd7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatMetricsRequest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting nat metrics. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecNatMetricsRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * The nat metric type. + */ + private String metricsType; + + /** + * The start time, unix timestamp, the unit is second. + */ + private Long start; + + /** + * The end time, unix timestamp, the unit is second. + */ + private Long end; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecNatMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatMetricsResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatMetricsResponse.java new file mode 100644 index 00000000..ccfdde5e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatMetricsResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.services.bec.model.vo.MetricsVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting nat metrics. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecNatMetricsResponse extends MetricsVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatRequest.java new file mode 100644 index 00000000..0b76cecd --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting nat. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecNatRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecNatRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatResponse.java new file mode 100644 index 00000000..8b1bd455 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.services.bec.model.vo.NatVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting nat. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecNatResponse extends NatVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatsRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatsRequest.java new file mode 100644 index 00000000..655d1bea --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatsRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting nats. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecNatsRequest extends AbstractBceRequest { + + /** + * ListRequest. + */ + private ListRequest listRequest; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * The region id. + */ + private String regionId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecNatsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatsResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatsResponse.java new file mode 100644 index 00000000..80fbef11 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/GetBecNatsResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.NatVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for getting nats. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecNatsResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatBandwidthRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatBandwidthRequest.java new file mode 100644 index 00000000..28162e89 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatBandwidthRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating nat bandwidth. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecNatBandwidthRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * The nat bandwidth. + */ + private Integer bandwidth; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecNatBandwidthRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatBandwidthResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatBandwidthResponse.java new file mode 100644 index 00000000..9b6fd088 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatBandwidthResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating nat bandwidth. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecNatBandwidthResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatRequest.java new file mode 100644 index 00000000..ef953441 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating nat. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecNatRequest extends AbstractBceRequest { + + /** + * The nat description. + */ + private String desc; + + /** + * The nat name. + */ + private String name; + + /** + * The nat id. + */ + private String natId; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecNatRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatResponse.java new file mode 100644 index 00000000..693fcf28 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/instance/UpdateBecNatResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating nat. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecNatResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchCreateBecSnatRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchCreateBecSnatRulesRequest.java new file mode 100644 index 00000000..1fb088bb --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchCreateBecSnatRulesRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:58 + * @Version v1.0 + *

+ * The request for creating batch S-NAT rules. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchCreateBecSnatRulesRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * The S-NAT rules. + */ + private List snatRules; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public BatchCreateBecSnatRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchCreateBecSnatRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchCreateBecSnatRulesResponse.java new file mode 100644 index 00000000..c8fc38c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchCreateBecSnatRulesResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:59 + * @Version v1.0 + *

+ * The response for creating batch S-NAT rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchCreateBecSnatRulesResponse extends AbstractBceResponse { + + /** + * The S-NAT rule ids. + */ + private List snatRuleIds; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchDeleteBecSnatRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchDeleteBecSnatRulesRequest.java new file mode 100644 index 00000000..67aa77b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchDeleteBecSnatRulesRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for deleting batch S-NAT rules. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BatchDeleteBecSnatRulesRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * The S-NAT rule ids. + */ + private List ruleIdList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public BatchDeleteBecSnatRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchDeleteBecSnatRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchDeleteBecSnatRulesResponse.java new file mode 100644 index 00000000..226ac991 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/BatchDeleteBecSnatRulesResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for deleting batch S-NAT rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteBecSnatRulesResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/CreateBecSnatRuleRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/CreateBecSnatRuleRequest.java new file mode 100644 index 00000000..3373e454 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/CreateBecSnatRuleRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:58 + * @Version v1.0 + *

+ * The request for creating S-NAT rule. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateBecSnatRuleRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * The rule name. + */ + private String ruleName; + + /** + * The source cidr. + */ + private String sourceCIDR; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public CreateBecSnatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/CreateBecSnatRuleResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/CreateBecSnatRuleResponse.java new file mode 100644 index 00000000..ef093860 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/CreateBecSnatRuleResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 16:59 + * @Version v1.0 + *

+ * The response for creating S-NAT rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecSnatRuleResponse extends AbstractBceResponse { + + /** + * The rule id. + */ + private String ruleId; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/GetBecSnatRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/GetBecSnatRulesRequest.java new file mode 100644 index 00000000..abe4ddbf --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/GetBecSnatRulesRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for getting S-NAT rules. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GetBecSnatRulesRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * Page number of display page. + */ + public int pageNo; + + /** + * The number of services on the display page. + */ + public int pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public GetBecSnatRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/GetBecSnatRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/GetBecSnatRulesResponse.java new file mode 100644 index 00000000..ff0e85f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/GetBecSnatRulesResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.SnatRuleVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The request for getting S-NAT rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecSnatRulesResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/UpdateBecSnatRuleRequest.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/UpdateBecSnatRuleRequest.java new file mode 100644 index 00000000..bc798006 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/UpdateBecSnatRuleRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:18 + * @Version v1.0 + *

+ * The request for updating S-NAT rule. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UpdateBecSnatRuleRequest extends AbstractBceRequest { + + /** + * The nat id. + */ + private String natId; + + /** + * The rule id. + */ + private String ruleId; + + /** + * The rule name. + */ + private String ruleName; + + /** + * The source cidr. + */ + private String sourceCIDR; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return Request entity with credentials. + */ + public UpdateBecSnatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/UpdateBecSnatRuleResponse.java b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/UpdateBecSnatRuleResponse.java new file mode 100644 index 00000000..a387b088 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/nat/snatrule/UpdateBecSnatRuleResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.nat.snatrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 11:22 + * @Version v1.0 + *

+ * The response for updating S-NAT rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecSnatRuleResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/CreateBecRouteRuleRequest.java b/src/main/java/com/baidubce/services/bec/model/network/route/CreateBecRouteRuleRequest.java new file mode 100644 index 00000000..5a1e0e9d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/CreateBecRouteRuleRequest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.enums.RouteTypeEnum; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The request for creating the route rule. + */ +@Data +public class CreateBecRouteRuleRequest extends AbstractBceRequest { + + /** + * The route table id. + */ + private String tableId; + + /** + * The ip version, like 4. + */ + private Integer ipVersion; + + /** + * The route rule source address. + */ + private String sourceAddress; + + /** + * The route rule destination address. + */ + private String destinationAddress; + + /** + * The route type. + */ + private RouteTypeEnum routeType; + + /** + * The next hop. + */ + private String nexthop; + + /** + * The description. + */ + private String description; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecRouteRuleRequest with credentials. + */ + public CreateBecRouteRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/CreateBecRouteRuleResponse.java b/src/main/java/com/baidubce/services/bec/model/network/route/CreateBecRouteRuleResponse.java new file mode 100644 index 00000000..2a7751dd --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/CreateBecRouteRuleResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.baidubce.services.bec.model.vo.RouteRuleVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The response for creating the route rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecRouteRuleResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/DeleteBecRouteRuleRequest.java b/src/main/java/com/baidubce/services/bec/model/network/route/DeleteBecRouteRuleRequest.java new file mode 100644 index 00000000..a7aba0be --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/DeleteBecRouteRuleRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The request for deleting the route rule. + */ +@Data +public class DeleteBecRouteRuleRequest extends AbstractBceRequest { + + /** + * The route rule id + */ + String ruleId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteBecRouteRuleRequest with credentials. + */ + public DeleteBecRouteRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/DeleteBecRouteRuleResponse.java b/src/main/java/com/baidubce/services/bec/model/network/route/DeleteBecRouteRuleResponse.java new file mode 100644 index 00000000..f1df24ec --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/DeleteBecRouteRuleResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The response for deleting the route rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecRouteRuleResponse extends ActionInfoVo> { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteRulesRequest.java new file mode 100644 index 00000000..a583e369 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteRulesRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The request for getting the route rules. + */ +@Data +public class GetBecRouteRulesRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * The route table id. + */ + private String tableId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecRouteRulesRequest + * with credentials. + */ + public GetBecRouteRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteRulesResponse.java new file mode 100644 index 00000000..a3e2f7f4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteRulesResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.RouteRuleVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:46 + * @Version v1.0 + *

+ * The response for getting the route rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecRouteRulesResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTableRequest.java b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTableRequest.java new file mode 100644 index 00000000..06f0e751 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTableRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The request for getting the route table detail. + */ +@Data +public class GetBecRouteTableRequest extends AbstractBceRequest { + + /** + * The route table id. + */ + private String tableId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecRouteTableRequest with credentials. + */ + public GetBecRouteTableRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTableResponse.java b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTableResponse.java new file mode 100644 index 00000000..dba96974 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTableResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The response for getting the route table detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecRouteTableResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTablesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTablesRequest.java new file mode 100644 index 00000000..e4f1f26d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTablesRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The request for getting the route tables. + */ +@Data +public class GetBecRouteTablesRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * The region id. + */ + private String regionId; + + /** + * List vpc id. + */ + private String vpcId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecRouteTablesRequest with credentials. + */ + public GetBecRouteTablesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTablesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTablesResponse.java new file mode 100644 index 00000000..dd21a42c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/GetBecRouteTablesResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.RouteTableVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:46 + * @Version v1.0 + *

+ * The response for getting the route tables. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecRouteTablesResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/GetRouteTableBackResponse.java b/src/main/java/com/baidubce/services/bec/model/network/route/GetRouteTableBackResponse.java new file mode 100644 index 00000000..e530904a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/GetRouteTableBackResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.services.bec.model.vo.RouteTableVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-15 11:14 + * @Version v1.0 + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetRouteTableBackResponse { + private RouteTableVo routeTableVo; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/UpdateBecRouteTableRequest.java b/src/main/java/com/baidubce/services/bec/model/network/route/UpdateBecRouteTableRequest.java new file mode 100644 index 00000000..e1c654e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/UpdateBecRouteTableRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The request for updating the route table. + */ +@Data +public class UpdateBecRouteTableRequest extends AbstractBceRequest { + + /** + * The route table id. + */ + private String tableId; + + /** + * The route table name. + */ + private String tableName; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecRouteTableRequest with credentials. + */ + public UpdateBecRouteTableRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/route/UpdateBecRouteTableResponse.java b/src/main/java/com/baidubce/services/bec/model/network/route/UpdateBecRouteTableResponse.java new file mode 100644 index 00000000..c6ce48a9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/route/UpdateBecRouteTableResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.route; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The response for updating the route table. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecRouteTableResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchCreateBecSgRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchCreateBecSgRulesRequest.java new file mode 100644 index 00000000..7ebff4aa --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchCreateBecSgRulesRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The request for creating the security group rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchCreateBecSgRulesRequest extends AbstractBceRequest { + + /** + * The security group id. + */ + private String securityGroupId; + + /** + * The security group rules. + */ + private List rules; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BatchCreateBecSgRulesRequest with credentials. + */ + public BatchCreateBecSgRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchCreateBecSgRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchCreateBecSgRulesResponse.java new file mode 100644 index 00000000..68bacf61 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchCreateBecSgRulesResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.services.bec.model.network.SecurityGroupVo; +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The response for creating the batch security group rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchCreateBecSgRulesResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchDeleteBecSgRulesRequest.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchDeleteBecSgRulesRequest.java new file mode 100644 index 00000000..b656132d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchDeleteBecSgRulesRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The request for deleting the security group rules. + */ +@Data +public class BatchDeleteBecSgRulesRequest extends AbstractBceRequest { + + /** + * The security group id. + */ + private String securityGroupId; + + /** + * The security group rule ids. + */ + private List securityGroupRuleIds; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BatchDeleteBecSgRulesRequest with credentials. + */ + public BatchDeleteBecSgRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchDeleteBecSgRulesResponse.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchDeleteBecSgRulesResponse.java new file mode 100644 index 00000000..708652ff --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/BatchDeleteBecSgRulesResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.services.bec.model.network.SecurityGroupVo; +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The response for deleting the batch security group rules. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteBecSgRulesResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/CreateBecSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/CreateBecSecurityGroupRequest.java new file mode 100644 index 00000000..ecd15fc3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/CreateBecSecurityGroupRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The request for creating the security group. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecSecurityGroupRequest extends AbstractBceRequest { + + /** + * The name of the security group. + */ + private String name; + + /** + * The description. + */ + private String desc; + + /** + * The rules. + */ + private List rules; + + /** + * Whether with default rules. + */ + private Boolean withDefaultRules; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecSecurityGroupRequest with credentials. + */ + public CreateBecSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/CreateBecSecurityGroupResponse.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/CreateBecSecurityGroupResponse.java new file mode 100644 index 00000000..7494590e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/CreateBecSecurityGroupResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The response for creating the security group. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecSecurityGroupResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/DeleteBecSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/DeleteBecSecurityGroupRequest.java new file mode 100644 index 00000000..9a2252d8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/DeleteBecSecurityGroupRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The request for deleting the security group. + */ +@Data +public class DeleteBecSecurityGroupRequest extends AbstractBceRequest { + + /** + * The security group id. + */ + String securityGroupId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteBecSecurityGroupRequest with credentials. + */ + public DeleteBecSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/DeleteBecSecurityGroupResponse.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/DeleteBecSecurityGroupResponse.java new file mode 100644 index 00000000..5f2751cd --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/DeleteBecSecurityGroupResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The response for deleting the security group. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecSecurityGroupResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupRequest.java new file mode 100644 index 00000000..fea9b8a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The request for getting the security group detail. + */ +@Data +public class GetBecSecurityGroupRequest extends AbstractBceRequest { + + /** + * The security group id. + */ + private String securityGroupId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecSecurityGroupRequest with credentials. + */ + public GetBecSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupResponse.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupResponse.java new file mode 100644 index 00000000..7eaefdc2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.services.bec.model.network.SecurityGroupVo; +import com.baidubce.services.bec.model.vo.BecResultVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The response for getting the security group detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecSecurityGroupResponse extends BecResultVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupsRequest.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupsRequest.java new file mode 100644 index 00000000..ebcde220 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupsRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The request for getting the security groups. + */ +@Data +public class GetBecSecurityGroupsRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecSecurityGroupsRequest + * with credentials. + */ + public GetBecSecurityGroupsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupsResponse.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupsResponse.java new file mode 100644 index 00000000..9e2650f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/GetBecSecurityGroupsResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.services.bec.model.network.SecurityGroupVo; +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:46 + * @Version v1.0 + *

+ * The response for getting the security groups. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecSecurityGroupsResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/SecurityGroupRule.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/SecurityGroupRule.java new file mode 100644 index 00000000..69dbd418 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/SecurityGroupRule.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-15 11:46 + * @Version v1.0 + *

+ * The security group rule. + */ +@Data +public class SecurityGroupRule { + + /** + * The ether type, the value must be IPv4/IPv6. + */ + private String etherType; + + /** + * The restrictive direction, the value must be ingress/egress. + */ + private String direction; + + /** + * Protocol, the value must be all|tcp|udp|icmp. + */ + private String protocol; + + /** + * Port range, default 1-65535. + */ + private String portRange; + + /** + * Source ip address. + * Only used in the scene direction is ingress. + */ + private String sourceIp; + + /** + * Destination ip address. + * Only used in the scene direction is egress. + */ + private String destIp; + + /** + * The remark. + */ + private String remark; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupRequest.java new file mode 100644 index 00000000..549fc62d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-13 12:00 + * @Version v1.0 + *

+ * The request for updating the security group. + */ +@Data +public class UpdateBecSecurityGroupRequest extends AbstractBceRequest { + + /** + * The security group id. + */ + private String securityGroupId; + + /** + * The name. + */ + private String name; + + /** + * The description. + */ + private String desc; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecSecurityGroupRequest with credentials. + */ + public UpdateBecSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupResponse.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupResponse.java new file mode 100644 index 00000000..41401ff3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.services.bec.model.network.SecurityGroupVo; +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-13 12:01 + * @Version v1.0 + *

+ * The response for updating the security group. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecSecurityGroupResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupRuleRequest.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupRuleRequest.java new file mode 100644 index 00000000..34f50ad8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupRuleRequest.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The request for updating the security group rule. + */ +@Data +public class UpdateBecSecurityGroupRuleRequest extends AbstractBceRequest { + + /** + * The security group id. + */ + private String securityGroupId; + + /** + * The security group rule id. + */ + private String securityGroupRuleId; + + /** + * The security group rule direction, ingress/egress. + */ + private String direction; + + /** + * The protocol. + */ + private String protocol; + + /** + * The port range. + */ + private String portRange; + + /** + * The remark. + */ + private String remark; + + /** + * The source ip. + */ + private String sourceIp; + + /** + * The destination ip. + */ + private String destIp; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecSecurityGroupRuleRequest with credentials. + */ + public UpdateBecSecurityGroupRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupRuleResponse.java b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupRuleResponse.java new file mode 100644 index 00000000..7c45972f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/securitygroup/UpdateBecSecurityGroupRuleResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.securitygroup; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The response for updating the security group rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecSecurityGroupRuleResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/CreateBecSubnetRequest.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/CreateBecSubnetRequest.java new file mode 100644 index 00000000..4d1f60a5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/CreateBecSubnetRequest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The request for creating the subnet. + */ +@Data +public class CreateBecSubnetRequest extends AbstractBceRequest { + + /** + * The name of the subnet. + */ + private String name; + + /** + * The vpc id of the subnet. + */ + private String vpcId; + + /** + * The cidr of the subnet. + */ + private String cidr; + + /** + * The description of the subnet. + */ + private String description; + + /** + * The tags. + */ + private List tags; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecSubnetRequest with credentials. + */ + public CreateBecSubnetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/CreateBecSubnetResponse.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/CreateBecSubnetResponse.java new file mode 100644 index 00000000..329c1ea3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/CreateBecSubnetResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.baidubce.services.bec.model.vo.SubnetVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:52 + * @Version v1.0 + *

+ * The response for creating the subnet. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecSubnetResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/DeleteBecSubnetRequest.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/DeleteBecSubnetRequest.java new file mode 100644 index 00000000..af682b8c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/DeleteBecSubnetRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for deleting the subnet. + */ +@Data +public class DeleteBecSubnetRequest extends AbstractBceRequest { + + /** + * The subnet id. + */ + String subnetId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteBecSubnetRequest with credentials. + */ + public DeleteBecSubnetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/DeleteBecSubnetResponse.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/DeleteBecSubnetResponse.java new file mode 100644 index 00000000..6d6a4c32 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/DeleteBecSubnetResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for deleting the subnet. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecSubnetResponse extends ActionInfoVo> { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetRequest.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetRequest.java new file mode 100644 index 00000000..3d9e6f89 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for getting the subnet. + */ +@Data +public class GetBecSubnetRequest extends AbstractBceRequest { + + /** + * The subnet id. + */ + String subnetId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecSubnetRequest with credentials. + */ + public GetBecSubnetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetResponse.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetResponse.java new file mode 100644 index 00000000..e84cdf58 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.vo.SubnetVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for getting the subnet. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecSubnetResponse extends AbstractBceResponse { + /** + * The subnet detail. + */ + private SubnetVo subnet; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetsRequest.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetsRequest.java new file mode 100644 index 00000000..59fc5294 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetsRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for getting the subnets. + */ +@Data +public class GetBecSubnetsRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * vpc id. + */ + private String vpcId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecSubnetsRequest + * }with credentials. + */ + public GetBecSubnetsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetsResponse.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetsResponse.java new file mode 100644 index 00000000..8ce29f0b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/GetBecSubnetsResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.SubnetVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for getting the subnets. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecSubnetsResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/SubnetModel.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/SubnetModel.java new file mode 100644 index 00000000..de1567ab --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/SubnetModel.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 13:58 + * @Version v1.0 + * + * The abstract of the subnet. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_DEFAULT) +public class SubnetModel { + /** + * The purpose of the subnet. + */ + private String purpose; + + /** + * The internet service provider. + */ + private String isp; + + /** + * The range start of the subnet. + */ + private String rangeStart; + + /** + * The range end of the subnet. + */ + private String rangeEnd; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/UpdateBecSubnetRequest.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/UpdateBecSubnetRequest.java new file mode 100644 index 00000000..ae6f4b25 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/UpdateBecSubnetRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for updating the subnet. + */ +@Data +public class UpdateBecSubnetRequest extends AbstractBceRequest { + + /** + * The id of the subnet. + */ + private String subnetId; + + /** + * The name of the subnet. + */ + private String name; + + /** + * The description of the subnet. + */ + private String description; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecSubnetRequest with credentials. + */ + public UpdateBecSubnetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/subnet/UpdateBecSubnetResponse.java b/src/main/java/com/baidubce/services/bec/model/network/subnet/UpdateBecSubnetResponse.java new file mode 100644 index 00000000..46904d61 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/subnet/UpdateBecSubnetResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.subnet; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for updating the subnet. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecSubnetResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/CreateBecVpcRequest.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/CreateBecVpcRequest.java new file mode 100644 index 00000000..2d65a238 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/CreateBecVpcRequest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The request for creating the vpc. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecVpcRequest extends AbstractBceRequest { + + /** + * The name of the vpc. + */ + private String name; + + /** + * The cidr of the vpc. + */ + private String cidr; + + /** + * The description of the vpc. + */ + private String description; + + /** + * The region id. + */ + private String regionId; + + /** + * The tags. + */ + private List tags; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecVpcRequest with credentials. + */ + public CreateBecVpcRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/CreateBecVpcResponse.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/CreateBecVpcResponse.java new file mode 100644 index 00000000..85b48920 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/CreateBecVpcResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:44 + * @Version v1.0 + *

+ * The response for creating the vpc. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecVpcResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/DeleteBecVpcRequest.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/DeleteBecVpcRequest.java new file mode 100644 index 00000000..49323c69 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/DeleteBecVpcRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The request for deleting the vpc. + */ +@Data +public class DeleteBecVpcRequest extends AbstractBceRequest { + + /** + * The vpc id + */ + String vpcId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteBecVpcRequest with credentials. + */ + public DeleteBecVpcRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/DeleteBecVpcResponse.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/DeleteBecVpcResponse.java new file mode 100644 index 00000000..2a0b4669 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/DeleteBecVpcResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:51 + * @Version v1.0 + *

+ * The response for deleting the vpc. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecVpcResponse extends ActionInfoVo> { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcRequest.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcRequest.java new file mode 100644 index 00000000..31cefa1f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The request for getting the vpc detail. + */ +@Data +public class GetBecVpcRequest extends AbstractBceRequest { + + /** + * The vpc id. + */ + String vpcId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVpcRequest with credentials. + */ + public GetBecVpcRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcResponse.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcResponse.java new file mode 100644 index 00000000..64403e61 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.vo.VpcVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The response for getting the vpc detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecVpcResponse extends AbstractBceResponse { + /** + * The vpc. + */ + private VpcVo vpc; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcsRequest.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcsRequest.java new file mode 100644 index 00000000..a0db2c43 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcsRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:45 + * @Version v1.0 + *

+ * The request for getting the vpcs. + */ +@Data +public class GetBecVpcsRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * Region id. + */ + private String regionId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVpcsRequest with credentials. + */ + public GetBecVpcsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcsResponse.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcsResponse.java new file mode 100644 index 00000000..544546fe --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/GetBecVpcsResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.VpcVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:46 + * @Version v1.0 + *

+ * The response for getting the vpcs. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecVpcsResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/UpdateBecVpcRequest.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/UpdateBecVpcRequest.java new file mode 100644 index 00000000..f47c54f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/UpdateBecVpcRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The request for updating the vpc. + */ +@Data +public class UpdateBecVpcRequest extends AbstractBceRequest { + + /** + * The id of the vpc. + */ + private String vpcId; + + /** + * The name of the vpc. + */ + private String name; + + /** + * The description of the vpc. + */ + private String description; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecVpcRequest with credentials. + */ + public UpdateBecVpcRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/network/vpc/UpdateBecVpcResponse.java b/src/main/java/com/baidubce/services/bec/model/network/vpc/UpdateBecVpcResponse.java new file mode 100644 index 00000000..ca9e961f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/network/vpc/UpdateBecVpcResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.network.vpc; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 10:49 + * @Version v1.0 + *

+ * The response for updating the vpc. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecVpcResponse extends ActionInfoVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerMetricsRequest.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerMetricsRequest.java new file mode 100644 index 00000000..8f48380e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerMetricsRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting BEC user level container metrics. + */ +@Data +public class GetBecContainerMetricsRequest extends AbstractBceRequest { + + /** + * Metrics Type. + */ + private String type; + + /** + * Offset In Seconds. + */ + private Integer offsetInSeconds; + + /** + * ServiceProvider. + */ + private String serviceProvider; + + /** + * stepInMin + */ + private Integer stepInMin; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public GetBecContainerMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerMetricsResponse.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerMetricsResponse.java new file mode 100644 index 00000000..1fd876a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerMetricsResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.services.bec.model.vo.MetricsVo; + +/** + * The response for getting BEC user level container metrics. + */ +public class GetBecContainerMetricsResponse extends MetricsVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerSummaryRequest.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerSummaryRequest.java new file mode 100644 index 00000000..8d35d83b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerSummaryRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting overview information of container services. + */ +public class GetBecContainerSummaryRequest extends AbstractBceRequest { + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public GetBecContainerSummaryRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerSummaryResponse.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerSummaryResponse.java new file mode 100644 index 00000000..d758dd2a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecContainerSummaryResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.services.bec.model.vo.ResourceUsageVo; + +/** + * The response for getting overview information of container services. + */ +public class GetBecContainerSummaryResponse extends ResourceUsageVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecResourceSummaryRequest.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecResourceSummaryRequest.java new file mode 100644 index 00000000..5b45df28 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecResourceSummaryRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the BEC user level overview data. + */ +@Data +public class GetBecResourceSummaryRequest extends AbstractBceRequest { + + /** + * region. + */ + private String region; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public GetBecResourceSummaryRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecResourceSummaryResponse.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecResourceSummaryResponse.java new file mode 100644 index 00000000..5784587c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecResourceSummaryResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.services.bec.model.vo.ResourceOverviewVo; + +/** + * The response for getting the BEC user level overview data. + */ +public class GetBecResourceSummaryResponse extends ResourceOverviewVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecVMSummaryRequest.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVMSummaryRequest.java new file mode 100644 index 00000000..3ba4755a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVMSummaryRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting overview information of vm services. + */ +public class GetBecVMSummaryRequest extends AbstractBceRequest { + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public GetBecVMSummaryRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecVMSummaryResponse.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVMSummaryResponse.java new file mode 100644 index 00000000..68a1f09a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVMSummaryResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.services.bec.model.vo.ResourceUsageVo; + +/** + * The response for getting overview information of vm services. + */ +public class GetBecVMSummaryResponse extends ResourceUsageVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmMetricsRequest.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmMetricsRequest.java new file mode 100644 index 00000000..a1ababf3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmMetricsRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting BEC user level vm metrics. + */ +@Data +public class GetBecVmMetricsRequest extends AbstractBceRequest { + + /** + * Metrics Type. + */ + private String type; + + /** + * Offset In Seconds. + */ + private Integer offsetInSeconds; + + /** + * ServiceProvider. + */ + private String serviceProvider; + + /** + * stepInMin + */ + private Integer stepInMin; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public GetBecVmMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmMetricsResponse.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmMetricsResponse.java new file mode 100644 index 00000000..4c4c5197 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmMetricsResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.services.bec.model.vo.MetricsVo; + +/** + * The response for getting BEC user level container metrics. + */ +public class GetBecVmMetricsResponse extends MetricsVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmNodeLevelMetricsRequest.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmNodeLevelMetricsRequest.java new file mode 100644 index 00000000..57f8fe08 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmNodeLevelMetricsRequest.java @@ -0,0 +1,64 @@ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting vm node level overview information. + */ +@Data +public class GetBecVmNodeLevelMetricsRequest extends AbstractBceRequest { + + /** + * The type of the metrics. + */ + private String type; + + /** + * Start time, Unix timestamp. + */ + private long start; + + /** + * Termination time, Unix timestamp. + */ + private long end; + + /** + * Region. + */ + private String region; + + /** + * City. + */ + private String city; + + /** + * ServiceProvider. + */ + private String serviceProvider; + + /** + * Network. + */ + private String network; + + /** + * StepInMin + */ + private Integer stepInMin; + + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVmNodeLevelMetricsRequest with credentials. + */ + public GetBecVmNodeLevelMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmNodeLevelMetricsResponse.java b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmNodeLevelMetricsResponse.java new file mode 100644 index 00000000..bf9c70ae --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/overview/GetBecVmNodeLevelMetricsResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.bec.model.overview; + +import com.baidubce.services.bec.model.vo.MetricsVo; + + +/** + * The response for getting vm node level overview information. + */ +public class GetBecVmNodeLevelMetricsResponse extends MetricsVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/purchase/AutoRenew.java b/src/main/java/com/baidubce/services/bec/model/purchase/AutoRenew.java new file mode 100644 index 00000000..ceba8904 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/purchase/AutoRenew.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.purchase; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 18:15 + * @Version v1.0 + *

+ * AutoRenew configuration. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AutoRenew { + + /** + * The renewal time length of the prepayment purchase. + */ + private Integer length; + + /** + * The renewal time unit of the prepayment purchase. + */ + private String timeUnit; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/purchase/DeploymentInstance.java b/src/main/java/com/baidubce/services/bec/model/purchase/DeploymentInstance.java new file mode 100644 index 00000000..9563c615 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/purchase/DeploymentInstance.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.purchase; + +import lombok.Data; + +import java.util.List; + +/** + * Deployment instance. + */ +@Data +public class DeploymentInstance { + + /** + * The region id of the deployment. + */ + private String regionId; + + /** + * Number of Pod\Vm instances under deployment. + */ + private Integer replicas; + + /** + * The subServiceProvider of the deployment, [ct,un,cm,intra]. + */ + private List subServiceProviders; + + /** + * The network type of the deployment. + */ + private String networkType; + + /** + * The vpc id of the deployment. + */ + private String vpcId; + + /** + * The subnet id of the deployment. + */ + private String subnetId; +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/Disk.java b/src/main/java/com/baidubce/services/bec/model/resource/Disk.java new file mode 100644 index 00000000..e0561090 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/Disk.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bec.model.resource; + +import lombok.Data; + +/** + * Disk. + */ +@Data +public class Disk { + + /** + * Volume type. + */ + private String volumeType; + + /** + * Size. + */ + private Integer sizeInGb; +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/DiskPackage.java b/src/main/java/com/baidubce/services/bec/model/resource/DiskPackage.java new file mode 100644 index 00000000..d9cb7031 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/DiskPackage.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bec.model.resource; + +import lombok.Data; + +/** + * Bec passThrough disk packages. + */ +@Data +public class DiskPackage { + + /** + * Disk type. + */ + private String type; + + /** + * Disk name. + */ + private String name; + + /** + * Disk code. + */ + private String code; + + /** + * Disk size. + */ + private Integer sizeInGb; +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/ListBecPassThroughDiskPackagesRequest.java b/src/main/java/com/baidubce/services/bec/model/resource/ListBecPassThroughDiskPackagesRequest.java new file mode 100644 index 00000000..2d03d93f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/ListBecPassThroughDiskPackagesRequest.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bec.model.resource; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for listing bec passThrough disk packages. + */ +public class ListBecPassThroughDiskPackagesRequest extends AbstractBceRequest { + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public ListBecPassThroughDiskPackagesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/ListBecPassThroughDiskPackagesResponse.java b/src/main/java/com/baidubce/services/bec/model/resource/ListBecPassThroughDiskPackagesResponse.java new file mode 100644 index 00000000..62011dfb --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/ListBecPassThroughDiskPackagesResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.bec.model.resource; + +import com.baidubce.services.bec.model.vo.BecResultVo; + +import java.util.List; + +/** + * The response for listing bec passThrough disk packages. + */ +public class ListBecPassThroughDiskPackagesResponse extends BecResultVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/ListBecServicePackagesRequest.java b/src/main/java/com/baidubce/services/bec/model/resource/ListBecServicePackagesRequest.java new file mode 100644 index 00000000..06558c36 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/ListBecServicePackagesRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.bec.model.resource; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for listing Bec Service Packages. + */ +@Data +public class ListBecServicePackagesRequest extends AbstractBceRequest { + + /** + * Resource Package Type(vm,container,bm). + */ + private String type; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + public ListBecServicePackagesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/ListBecServicePackagesResponse.java b/src/main/java/com/baidubce/services/bec/model/resource/ListBecServicePackagesResponse.java new file mode 100644 index 00000000..e3e25e16 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/ListBecServicePackagesResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.bec.model.resource; + +import com.baidubce.services.bec.model.vo.BecResultVo; + +import java.util.List; + +/** + * The response for listing bec service packages. + */ +public class ListBecServicePackagesResponse extends BecResultVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/ResourceCount.java b/src/main/java/com/baidubce/services/bec/model/resource/ResourceCount.java new file mode 100644 index 00000000..6e361604 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/ResourceCount.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.resource; + +import lombok.Data; + +/** + * Resource Count. + */ +@Data +public class ResourceCount { + + /** + * total Count. + */ + private Integer total; + + /** + * running Count. + */ + private Integer runningCount; + + /** + * failed Count. + */ + private Integer failedCount; + + /** + * closed Count. + */ + private Integer closedCount; +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/ResourcePackage.java b/src/main/java/com/baidubce/services/bec/model/resource/ResourcePackage.java new file mode 100644 index 00000000..cd6cd6c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/ResourcePackage.java @@ -0,0 +1,72 @@ +package com.baidubce.services.bec.model.resource; + +import lombok.Data; + +import java.util.List; + +/** + * Resource Package. + */ +@Data +public class ResourcePackage { + + /** + * Resource package name. + */ + private String name; + + /** + * Resource cpu. + */ + private Integer cpu; + + /** + * Resource memory. + */ + private Integer memory; + + /** + * Resource gpu. + */ + private Integer gpu; + + /** + * Resource code. + */ + private String code; + + /** + * Inter bandwidth. + */ + private Integer interBandwidth; + + /** + * Inner bandwidth. + */ + private Float innerBandwidth; + + /** + * Cpu model. + */ + private String cpuModel; + + /** + * Data disk list. + */ + private List dataDiskList; + + /** + * System disk. + */ + private Disk systemDisk; + + /** + * Storage partition. + */ + private StoragePartition storagePartition; + + /** + * Network packet data. + */ + private Integer networkPacketData; +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/ResourceUsageInISP.java b/src/main/java/com/baidubce/services/bec/model/resource/ResourceUsageInISP.java new file mode 100644 index 00000000..e083084c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/ResourceUsageInISP.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.resource; + +import lombok.Data; + +import java.util.Map; + +/** + * Summary of user resource usage. + */ +@Data +public class ResourceUsageInISP { + + /** + * Summary of user resource usage. + */ + private Map usageMap; + + @Data + public static class Usage { + /** + * cpu usage. + */ + private Integer cpu; + + /** + * memory usage. + */ + private Integer memory; + + /** + * storage usage. + */ + private Long storage; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/resource/StoragePartition.java b/src/main/java/com/baidubce/services/bec/model/resource/StoragePartition.java new file mode 100644 index 00000000..b825f5e7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/resource/StoragePartition.java @@ -0,0 +1,16 @@ +package com.baidubce.services.bec.model.resource; + +import lombok.Data; + +/** + * Storage partition. + */ +@Data +public class StoragePartition { + + private Integer swapInGb; + + private Integer rootInGb; + + private Integer homeInGb; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/DnsConfig.java b/src/main/java/com/baidubce/services/bec/model/vm/DnsConfig.java new file mode 100644 index 00000000..482d9180 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/DnsConfig.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bec.model.vm; + +import com.baidubce.services.bec.model.enums.DnsTypeEnum; +import lombok.Data; + +@Data +public class DnsConfig { + + private DnsTypeEnum dnsType; + + private String dnsAddress; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/KeyConfig.java b/src/main/java/com/baidubce/services/bec/model/vm/KeyConfig.java new file mode 100644 index 00000000..db836c14 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/KeyConfig.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bec.model.vm; + +import lombok.Data; + +import java.util.List; + +@Data +public class KeyConfig { + + private String type; + + private String adminPass; + + private List bccKeyPairIdList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/KeyPair.java b/src/main/java/com/baidubce/services/bec/model/vm/KeyPair.java new file mode 100644 index 00000000..00f9de24 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/KeyPair.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-10 19:51 + * @Version v1.0 + * + * The abstract of key pair. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class KeyPair { + + /** + * The id of key pair. + */ + + private String keyPairId; + + /** + * The name of key pair. + */ + private String name; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/LogicPageResultResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/LogicPageResultResponse.java new file mode 100644 index 00000000..d55ce425 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/LogicPageResultResponse.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * paged api list, for brief info + */ +@Data +public class LogicPageResultResponse extends AbstractBceResponse { + + /** + * Paged api list, for brief info. + */ + private List result; + + /** + * The order list. + */ + private List orders; + + /** + * The order by info. + */ + private String orderBy; + + /** + * The order info, eg asc, desc. + */ + private String order; + + /** + * page number + */ + private int pageNo; + + /** + * Page size. + */ + private int pageSize; + + /** + * Total number of results. + */ + private Integer totalCount; + + /** + * The order information. + */ + @Data + public class OrderModel { + + /** + * The order info. + */ + private String order; + + /** + * The order by info. + */ + private String orderBy; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/NetworkConfig.java b/src/main/java/com/baidubce/services/bec/model/vm/NetworkConfig.java new file mode 100644 index 00000000..f17fd46b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/NetworkConfig.java @@ -0,0 +1,82 @@ +package com.baidubce.services.bec.model.vm; + +import com.baidubce.services.bec.model.enums.NetTypeEnum; +import com.baidubce.services.bec.model.enums.NodeTypeEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NetworkConfig { + + /** + * The node type. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private NodeTypeEnum nodeType; + + /** + * The network list. + */ + private List networksList; + + @Data + public static class Networks { + + /** + * The network type. + */ + private NetTypeEnum netType; + + /** + * The network name. + */ + private String netName; + + /** + * The network interface card index. + */ + private Integer nicIndex; + + /** + * The id of elastic network interface. + */ + private String eniId; + + /** + * The mac address. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String mac; + + /** + * The IPv4 info. + */ + private IpAddress ipv4; + + /** + * The IPv6 info. + */ + private IpAddress ipv6; + + /** + * The auxiliary ips. + */ + @Deprecated + private List reserveIps; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class IpAddress { + private String ip; + private String gw; + private String cidr; + private String mask; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/SystemVolumeConfig.java b/src/main/java/com/baidubce/services/bec/model/vm/SystemVolumeConfig.java new file mode 100644 index 00000000..ba3fef4a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/SystemVolumeConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm; + +import com.baidubce.services.bec.model.enums.DiskTypeEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * System volume config information. + * Shared with return vo. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SystemVolumeConfig { + + /** + * The type of the Volume. + */ + private DiskTypeEnum volumeType; + + /** + * The size of the Volume. + */ + private Integer sizeInGB; + + /** + * The name of the Volume. + */ + private String name; + + /** + * The pvc name. + */ + private String pvcName; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/VolumeConfig.java b/src/main/java/com/baidubce/services/bec/model/vm/VolumeConfig.java new file mode 100644 index 00000000..de88c6c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/VolumeConfig.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm; + +import com.baidubce.services.bec.model.enums.DiskTypeEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * Volume config information. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VolumeConfig { + + /** + * The name of the volume. + */ + private String name; + + /** + * The type of the volume. + */ + private DiskTypeEnum volumeType; + + /** + * The size of the volume. + */ + private Integer sizeInGB; + + /** + * The pass through code of the volume. + * Monopolized disk needs. + */ + private String passthroughCode; + + /** + * The pvc name. + */ + private String pvcName; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/CreateBecDeploySetRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/CreateBecDeploySetRequest.java new file mode 100644 index 00000000..bdeeca7a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/CreateBecDeploySetRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for creating the deployment set. + */ +@Data +public class CreateBecDeploySetRequest extends AbstractBceRequest { + + /** + * The deployment set name. + */ + private String name; + + /** + * The deployment set strategy. + */ + private String strategy; + + /** + * The maximum of concurrency. + */ + private Integer concurrency; + + /** + * The deployment set description. + */ + private String desc; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecDeploySetRequest with credentials. + */ + public CreateBecDeploySetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/CreateBecDeploySetResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/CreateBecDeploySetResponse.java new file mode 100644 index 00000000..fe1ec3f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/CreateBecDeploySetResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:52 + * @Version v1.0 + *

+ * The response for creating the deployment set. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecDeploySetResponse extends AbstractBceResponse { + + /** + * The deployment set ids + */ + private List deploysetIdList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetInstancesRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetInstancesRequest.java new file mode 100644 index 00000000..aecdca14 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetInstancesRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for deleting the deployment set's virtual machine. + */ +@Data +public class DeleteBecDeploySetInstancesRequest extends AbstractBceRequest { + + /** + * The virtual machine instance ids of the deployment set. + */ + List instanceIdList; + + /** + * The id of the deployment set. + */ + String deploysetId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteBecDeploySetInstancesRequest with credentials. + */ + public DeleteBecDeploySetInstancesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetInstancesResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetInstancesResponse.java new file mode 100644 index 00000000..4625dd99 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetInstancesResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for deleting the deployment set's virtual machine. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecDeploySetInstancesResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetRequest.java new file mode 100644 index 00000000..1086fc2f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for deleting the deployment set. + */ +@Data +public class DeleteBecDeploySetRequest extends AbstractBceRequest { + + /** + * The deployment id. + */ + String deploySetId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteBecDeploySetRequest with credentials. + */ + public DeleteBecDeploySetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetResponse.java new file mode 100644 index 00000000..a3c65605 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/DeleteBecDeploySetResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for deleting the deployment set. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeleteBecDeploySetResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetRequest.java new file mode 100644 index 00000000..d3526749 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for getting the deployment set detail. + */ +@Data +public class GetBecDeploySetRequest extends AbstractBceRequest { + + /** + * The deployment id. + */ + String deploySetId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecDeploySetRequest with credentials. + */ + public GetBecDeploySetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetResponse.java new file mode 100644 index 00000000..b02a6298 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.services.bec.model.vo.DeploySetVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for getting the deployment set detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecDeploySetResponse extends DeploySetVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetsRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetsRequest.java new file mode 100644 index 00000000..b549ebb4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetsRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for getting the deployment sets. + */ +@Data +public class GetBecDeploySetsRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecDeploySetsRequest + * with credentials. + */ + public GetBecDeploySetsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetsResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetsResponse.java new file mode 100644 index 00000000..daaa180d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/GetBecDeploySetsResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.DeploySetVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for getting the deployment sets. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecDeploySetsResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/NodeInstanceStatis.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/NodeInstanceStatis.java new file mode 100644 index 00000000..54a375d0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/NodeInstanceStatis.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 12:09 + * @Version v1.0 + * The statistics of node instance. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NodeInstanceStatis { + + /** + * The region id of the deployment set. + */ + private String regionId; + + /** + * The instance count of the deployment set. + */ + private Integer instanceCount; + + /** + * The maximum instance of the deployment set. + */ + private Integer instanceTotal; + + /** + * The instance ids of the deployment set. + */ + private List instanceIds; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetInstanceRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetInstanceRequest.java new file mode 100644 index 00000000..2b0ba202 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetInstanceRequest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for updating the virtual machine instance's deployment sets. + */ +@Data +public class UpdateBecDeploySetInstanceRequest extends AbstractBceRequest { + /** + * The deployment set ids. + */ + List deploysetIdList; + + /** + * The virtual machine id under the deployment set ids. + */ + String instanceId; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecDeploySetInstanceRequest with credentials. + */ + public UpdateBecDeploySetInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetInstanceResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetInstanceResponse.java new file mode 100644 index 00000000..71844154 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetInstanceResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for updating the virtual machine instance's deployment sets. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecDeploySetInstanceResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetRequest.java new file mode 100644 index 00000000..629aafa8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The request for updating the deployment set. + */ +@Data +public class UpdateBecDeploySetRequest extends AbstractBceRequest { + + /** + * The id of deployment set. + */ + private String deploySetId; + + /** + * The name of deployment set. + */ + private String name; + + /** + * The description of deployment set. + */ + private String desc; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecDeploySetRequest with credentials. + */ + public UpdateBecDeploySetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetResponse.java new file mode 100644 index 00000000..e60efa6c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/deployset/UpdateBecDeploySetResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.deployset; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-07 09:41 + * @Version v1.0 + *

+ * The response for updating the deployment set. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecDeploySetResponse extends AbstractBceResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/BatchDeleteBecVmImageRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/image/BatchDeleteBecVmImageRequest.java new file mode 100644 index 00000000..1fc039a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/BatchDeleteBecVmImageRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-14 09:47 + * @Version v1.0 + *

+ * The request for deleting the batch virtual machine images. + */ +@Data +public class BatchDeleteBecVmImageRequest extends AbstractBceRequest { + + /** + * The vm image ids. + */ + private List imageIdList; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BatchDeleteBecVmImageRequest with credentials. + */ + public BatchDeleteBecVmImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/BatchDeleteBecVmImageResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/image/BatchDeleteBecVmImageResponse.java new file mode 100644 index 00000000..b5a5ed58 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/BatchDeleteBecVmImageResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import com.baidubce.services.bec.model.vo.BecResultVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-14 09:47 + * @Version v1.0 + *

+ * The response for deleting the batch virtual machine images. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteBecVmImageResponse extends BecResultVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/CreateBecVmImageRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/image/CreateBecVmImageRequest.java new file mode 100644 index 00000000..15d7da33 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/CreateBecVmImageRequest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-14 09:47 + * @Version v1.0 + *

+ * The request for creating the virtual machine image. + */ +@Data +public class CreateBecVmImageRequest extends AbstractBceRequest { + + /** + * The virtual machine id. + */ + private String vmId; + + /** + * The list for creating vm image. + */ + private List images; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecVmImageRequest with credentials. + */ + public CreateBecVmImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/CreateBecVmImageResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/image/CreateBecVmImageResponse.java new file mode 100644 index 00000000..2b78d82a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/CreateBecVmImageResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import com.baidubce.services.bec.model.vo.BecResultVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-14 09:52 + * @Version v1.0 + *

+ * The response for creating the virtual machine image. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecVmImageResponse extends BecResultVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/GetBecVmImagesRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/image/GetBecVmImagesRequest.java new file mode 100644 index 00000000..a2ec6262 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/GetBecVmImagesRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-14 09:47 + * @Version v1.0 + *

+ * The request for getting the virtual machine images. + */ +@Data +public class GetBecVmImagesRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * The image type, becCommon/becCustom, default becCustom. + */ + private String type; + + /** + * The image id. + */ + private String imageId; + + /** + * Os type, CentOS、Ubuntu、Debian、opensuse. + */ + private String osName; + + /** + * The region id. + */ + private String regionId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVmImagesRequest + * with credentials. + */ + public GetBecVmImagesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/GetBecVmImagesResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/image/GetBecVmImagesResponse.java new file mode 100644 index 00000000..32fa8ab1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/GetBecVmImagesResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.VmImageVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-14 09:47 + * @Version v1.0 + *

+ * The response for getting the virtual machine images. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecVmImagesResponse extends LogicPageResultResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/Image.java b/src/main/java/com/baidubce/services/bec/model/vm/image/Image.java new file mode 100644 index 00000000..7b772725 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/Image.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import lombok.Data; + +/** + * The image for the BEC virtual machine. + */ +@Data +public class Image { + + /** + * The name of the BEC virtual machine image. + */ + private String imageName; + + /** + * The id of the pvc. + */ + private String pvcId; + + /** + * The id of the BEC virtual machine image. + */ + private String imageId; + + /** + * The type of the BEC virtual machine image. + */ + private String imageType; + + /** + * The type of the BEC virtual machine image process. + */ + private String imageProcessType; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/UpdateBecVmImageRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/image/UpdateBecVmImageRequest.java new file mode 100644 index 00000000..0fc9b225 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/UpdateBecVmImageRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-14 09:47 + * @Version v1.0 + *

+ * The request for updating the virtual machine image. + */ +@Data +public class UpdateBecVmImageRequest extends AbstractBceRequest { + + /** + * The id of vm image. + */ + private String imageId; + + /** + * The name of vm image. + */ + private String name; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecVmImageRequest with credentials. + */ + public UpdateBecVmImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/UpdateBecVmImageResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/image/UpdateBecVmImageResponse.java new file mode 100644 index 00000000..0d5321a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/UpdateBecVmImageResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import com.baidubce.services.bec.model.vo.BecResultVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-14 09:47 + * @Version v1.0 + *

+ * The response for updating the virtual machine image. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecVmImageResponse extends BecResultVo { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/image/VmImage.java b/src/main/java/com/baidubce/services/bec/model/vm/image/VmImage.java new file mode 100644 index 00000000..51375981 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/image/VmImage.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.image; + +import lombok.Data; + +/** + * The image for the BEC virtual machine. + */ +@Data +public class VmImage { + + /** + * The name of the BEC virtual machine image. + */ + private String imageName; + + /** + * The id of the pvc. + */ + private String pvcId; + + /** + * The type of the BEC virtual machine image process, like local. + */ + private String imageProcessType; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/DeleteBecVmInstanceRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/DeleteBecVmInstanceRequest.java new file mode 100644 index 00000000..ab104bb7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/DeleteBecVmInstanceRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for deleting the BEC virtual machine. + */ +@Data +public class DeleteBecVmInstanceRequest extends AbstractBceRequest { + + /** + * The id of the BEC virtual machine. + */ + String vmID; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteBecVmInstanceRequest with credentials. + */ + public DeleteBecVmInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/DeleteBecVmInstanceResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/DeleteBecVmInstanceResponse.java new file mode 100644 index 00000000..97d4452e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/DeleteBecVmInstanceResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import lombok.Data; + +import java.util.Map; + +/** + * The response for deleting the BEC virtual machine. + */ +@Data +public class DeleteBecVmInstanceResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecNodeVmInstanceListRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecNodeVmInstanceListRequest.java new file mode 100644 index 00000000..765f666b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecNodeVmInstanceListRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * The request for getting the BEC virtual machine list of the node. + */ +@Data +public class GetBecNodeVmInstanceListRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * the region of the node. + */ + private String region; + + /** + * the serviceProvider of the node. + */ + private String serviceProvider; + + /** + * the city of the node. + */ + private String city; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecNodeVmInstanceListRequest with credentials. + */ + public GetBecNodeVmInstanceListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecNodeVmInstanceListResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecNodeVmInstanceListResponse.java new file mode 100644 index 00000000..c73a534d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecNodeVmInstanceListResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.services.bec.model.vo.BecResultVo; +import com.baidubce.services.bec.model.vo.VmInstanceBriefVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * The response for getting the BEC virtual machine list of the node. + * Return the instance detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecNodeVmInstanceListResponse extends BecResultVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVirtualMachineRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVirtualMachineRequest.java new file mode 100644 index 00000000..3ebff967 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVirtualMachineRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The request for getting the details of the BEC virtual machine. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecVirtualMachineRequest extends AbstractBceRequest { + + /** + * The id of the BEC virtual machine. + */ + String vmID; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVirtualMachineRequest with credentials. + */ + public GetBecVirtualMachineRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVirtualMachineResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVirtualMachineResponse.java new file mode 100644 index 00000000..b3203940 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVirtualMachineResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.services.bec.model.vo.VmInstanceDetailsVo; +import lombok.Data; + +/** + * The response for getting the details of the BEC virtual machine. + */ +@Data +public class GetBecVirtualMachineResponse extends VmInstanceDetailsVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmConfigRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmConfigRequest.java new file mode 100644 index 00000000..e9aa2af0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmConfigRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting BEC virtual machine instance config. + */ +@Data +public class GetBecVmConfigRequest extends AbstractBceRequest { + + /** + * The id of the BEC virtual machine instance config. + */ + String vmID; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVmConfigRequest with credentials. + */ + public GetBecVmConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmConfigResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmConfigResponse.java new file mode 100644 index 00000000..b4dc7fa4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmConfigResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.services.bec.model.vo.VmConfigVo; +import lombok.Data; + +/** + * The response for getting BEC virtual machine instance config. + */ +@Data +public class GetBecVmConfigResponse extends VmConfigVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceListRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceListRequest.java new file mode 100644 index 00000000..974ed538 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceListRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.ListRequest; +import lombok.Data; + +/** + * The request for getting the list of BEC virtual machine instances. + */ +@Data +public class GetBecVmInstanceListRequest extends AbstractBceRequest { + + /** + * List request information. + */ + private ListRequest listRequest; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVmInstanceListRequest with credentials. + */ + public GetBecVmInstanceListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceListResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceListResponse.java new file mode 100644 index 00000000..9dfc54a3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceListResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.VmInstanceBriefVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * The response for getting the list of BEC virtual machine instances. + * Return the instance detail. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecVmInstanceListResponse extends LogicPageResultResponse { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceMetricsRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceMetricsRequest.java new file mode 100644 index 00000000..5110afc3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceMetricsRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting bec virtual machine instance metrics. + */ +@Data +public class GetBecVmInstanceMetricsRequest extends AbstractBceRequest { + + /** + * The id of the bec virtual machine instance. + */ + private String vmId; + + /** + * The type of the metrics. + */ + private String type; + + /** + * Offset in seconds. + */ + private int offsetInSeconds; + + /** + * ServiceProvider. + */ + private String serviceProvider; + + /** + * stepInMin + */ + private Integer stepInMin; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVmInstanceMetricsRequest with credentials. + */ + public GetBecVmInstanceMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceMetricsResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceMetricsResponse.java new file mode 100644 index 00000000..93c6dd4a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/GetBecVmInstanceMetricsResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.services.bec.model.vo.MetricsVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for getting bec virtual machine instance metrics. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecVmInstanceMetricsResponse extends MetricsVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/OperateBecVmDeploymentRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/OperateBecVmDeploymentRequest.java new file mode 100644 index 00000000..d366bcfb --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/OperateBecVmDeploymentRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * The request for operating the bec virtual machine instance. + */ +@Data +public class OperateBecVmDeploymentRequest extends AbstractBceRequest { + + /** + * The id of the BEC virtual machine instance. + */ + String vmID; + + /** + * Operation type of the virtual machine instance. + */ + String action; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return OperateBecVmDeploymentRequest with credentials. + */ + public OperateBecVmDeploymentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/OperateBecVmDeploymentResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/OperateBecVmDeploymentResponse.java new file mode 100644 index 00000000..74949788 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/OperateBecVmDeploymentResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import lombok.Data; + +import java.util.Map; + +/** + * The response for operating the bec virtual machine instance. + */ +@Data +public class OperateBecVmDeploymentResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/ReinstallBecVmInstanceRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/ReinstallBecVmInstanceRequest.java new file mode 100644 index 00000000..584c6d77 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/ReinstallBecVmInstanceRequest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vm.KeyConfig; +import com.baidubce.services.bec.model.vm.image.Image; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * The request for reinstalling the BEC virtual machine system. + */ +@Data +public class ReinstallBecVmInstanceRequest extends AbstractBceRequest { + + /** + * The id of the BEC virtual machine system. + */ + private String vmID; + + /** + * Password. + */ + @Deprecated + private String adminPass; + + /** + * The new way to configure password and key. + */ + private KeyConfig keyConfig; + + /** + * Image id. + * worked with imageType, be marked on 24.11. + */ + private String imageId; + + /** + * Image type, image type must be [bec|bcc|rds] + * worked with imageId. + */ + private String imageType; + + /** + * Data volume image info. + */ + private List images; + + /** + * Reset data disk. + */ + private Boolean resetDataDisk; + + /** + * The host name of the virtual machine. + */ + private String hostname; + + /** + * The userData of the virtual machine. + *

+ * The custom injected data, user need to encode the original text using base64. The encoding formula : + * base64(user_injected_data: base64(original text)) + */ + private String userData; + + /** + * The cuda version of the virtual machine. + */ + private String cudaVersion; + + /** + * The driver version of the virtual machine. + */ + private String driverVersion; + + /** + * The cuDNN version of the virtual machine. + */ + private String cudnnVersion; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ReinstallBecVmInstanceRequest with credentials. + */ + public ReinstallBecVmInstanceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/ReinstallBecVmInstanceResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/ReinstallBecVmInstanceResponse.java new file mode 100644 index 00000000..50673c6d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/ReinstallBecVmInstanceResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for reinstalling the BEC virtual machine system. + * Return the instance detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ReinstallBecVmInstanceResponse extends ActionInfoVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/UpdateBecVmDeploymentRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/UpdateBecVmDeploymentRequest.java new file mode 100644 index 00000000..df81a4a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/UpdateBecVmDeploymentRequest.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vm.DnsConfig; +import com.baidubce.services.bec.model.vm.KeyConfig; +import com.baidubce.services.bec.model.vm.NetworkConfig; +import com.baidubce.services.bec.model.vm.SystemVolumeConfig; +import com.baidubce.services.bec.model.vm.VolumeConfig; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * The request for updating BEC virtual machine resources. + */ +@Data +public class UpdateBecVmDeploymentRequest extends AbstractBceRequest { + + /** + * The id of the BEC virtual machine. + */ + private String vmID; + + /** + * The hostname of the BEC virtual machine. + */ + private String hostname; + + /** + * Update type. + */ + private String type; + + /** + * The number of CPUs of the virtual machine instance. + */ + private Integer cpu; + + /** + * The memory of the virtual machine instance. + */ + private Integer memory; + + /** + * The specification of the virtual machine instance. + */ + private String spec; + + /** + * Password. + */ + @Deprecated + private String adminPass; + + /** + * The new way to configure password and key + */ + private KeyConfig keyConfig; + + /** + * Image id. + */ + private String imageId; + + /** + * The bandwidth of the BEC virtual machine. + */ + private float bandwidth; + + /** + * The name of the BEC virtual machine. + */ + private String vmName; + + /** + * The security groupIds of the BEC virtual machine. + */ + private List securityGroupIds; + + /** + * Virtual machine network information configuration + */ + private NetworkConfig networkConfig; + + /** + * Whether IPV6 is required + */ + private Boolean needIpv6PublicIp; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The data volumes of the BEC virtual machine. + */ + private List dataVolumeList; + + /** + * The security groupIds of the BEC virtual machine. + */ + private SystemVolumeConfig systemVolume; + + /** + * The dns config of the BEC virtual machine. + */ + private DnsConfig dnsConfig; + + /** + * Whether Reboot is required + */ + private Boolean reboot; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecVmDeploymentRequest with credentials. + */ + public UpdateBecVmDeploymentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/instance/UpdateBecVmDeploymentResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/instance/UpdateBecVmDeploymentResponse.java new file mode 100644 index 00000000..00b62850 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/instance/UpdateBecVmDeploymentResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.instance; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.baidubce.services.bec.model.vo.VmInstanceDetailsVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for updating BEC virtual machine resources. + * Return the instance detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecVmDeploymentResponse extends ActionInfoVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/network/VmNetworkConfig.java b/src/main/java/com/baidubce/services/bec/model/vm/network/VmNetworkConfig.java new file mode 100644 index 00000000..38bb10a9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/network/VmNetworkConfig.java @@ -0,0 +1,45 @@ +package com.baidubce.services.bec.model.vm.network; + +import com.baidubce.services.bec.model.vm.NetworkConfig; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VmNetworkConfig extends NetworkConfig { + + /** + * Whether the user need intranet network. + */ + private Boolean needPrivateNetwork; + + /** + * Whether the user need public network. + */ + private Boolean needPublicNetwork; + + /** + * The private network name. + */ + private String privateNetworkName; + + /** + * The public network name. + */ + private String publicNetworkName; + + /** + * The public network China Mobile name. + */ + private String publicNetworkChinaMobileName; + + /** + * The public network China Unicom name. + */ + private String publicNetworkChinaUnicomName; + + /** + * The private network China Telecom name. + */ + private String publicNetworkChinaTelecomName; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/BecVmServiceActionRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/service/BecVmServiceActionRequest.java new file mode 100644 index 00000000..694dcb6b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/BecVmServiceActionRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +/** + * The request for operating the virtual machine service. + */ +@Data +public class BecVmServiceActionRequest extends AbstractBceRequest { + + /** + * The id of the virtual machine service. + */ + String serviceId; + + /** + * Operation of the virtual machine service. + */ + String action; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BecVmServiceActionRequest with credentials. + */ + public BecVmServiceActionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/BecVmServiceActionResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/service/BecVmServiceActionResponse.java new file mode 100644 index 00000000..25891a7a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/BecVmServiceActionResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; + +import java.util.Map; + +/** + * The response for operating the virtual machine service. + */ +public class BecVmServiceActionResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/CreateBecVmServiceRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/service/CreateBecVmServiceRequest.java new file mode 100644 index 00000000..c95ff017 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/CreateBecVmServiceRequest.java @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.purchase.AutoRenew; +import com.baidubce.services.bec.model.purchase.DeploymentInstance; +import com.baidubce.services.bec.model.vm.DnsConfig; +import com.baidubce.services.bec.model.vm.KeyConfig; +import com.baidubce.services.bec.model.vm.NetworkConfig; +import com.baidubce.services.bec.model.vm.SystemVolumeConfig; +import com.baidubce.services.bec.model.vm.VolumeConfig; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +/** + * The request for creating a newly vm service. + * Shared with creating vm instances. + */ +@Data +@Builder +public class CreateBecVmServiceRequest extends AbstractBceRequest { + + /** + * The id of the service. + */ + private String serviceId; + + /** + * The name of the service. + */ + private String serviceName; + + /** + * The name of the vm. + */ + private String vmName; + + /** + * TemplateId. + */ + private String templateId; + + /** + * Password. + */ + @Deprecated + private String adminPass; + + /** + * The payment method of the service. + */ + private String paymentMethod; + + /** + * The prepayment reservation configuration of the virtual machine service + */ + private Reservation reservation; + + /** + * The autoRenew configuration. + */ + private AutoRenew autoRenew; + + /** + * Whether the vm service need public ip. + */ + private Boolean needPublicIp; + + /** + * Whether the vm service need public ipv6. + */ + private Boolean needIpv6PublicIp; + + /** + * Disable Intra net. + */ + private Boolean disableIntranet; + + /** + * Disable Cloud Init. + */ + private Boolean disableCloudInit; + + /** + * The bandwidth of the service. + */ + private Integer bandwidth; + + /** + * List of deployment instances. + */ + private List deployInstances; + + /** + * The cpu of the service. + */ + private Integer cpu; + + /** + * The memory of the service. + */ + private Integer memory; + + /** + * The imageId of the service. + */ + private String imageId; + + /** + * The imageType of the service. + */ + private String imageType; + + /** + * Data disk configuration list. + */ + private List dataVolumeList; + + /** + * System disk configuration information. + */ + private SystemVolumeConfig systemVolume; + + /** + * The keyConfig of the vm service. + */ + private KeyConfig keyConfig; + + /** + * The specification of the vm service. + */ + private String spec; + + /** + * The hostname of the vm service. + */ + private String hostname; + + /** + * The network config list of the virtual machine service. + */ + private List networkConfigList; + + /** + * The dns configuration of the virtual machine service. + */ + private DnsConfig dnsConfig; + + /** + * The security group ids of the vm. + */ + private List securityGroupIds; + + /** + * The user script of the vm. + *

+ * The custom injected data, user need to encode the original text using base64. The encoding formula : + * base64(user_injected_data: base64(original text)) + */ + private String userData; + + /** + * The cuda version of the virtual machine. + */ + private String cudaVersion; + + /** + * The driver version of the virtual machine. + */ + private String driverVersion; + + /** + * The cuDNN version of the virtual machine. + */ + private String cudnnVersion; + + /** + * The deployment set ids of the vm service. + */ + private List deploysetIdList; + + /** + * The tags of the virtual machine. + */ + private List tags; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public CreateBecVmServiceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/CreateBecVmServiceResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/service/CreateBecVmServiceResponse.java new file mode 100644 index 00000000..24e15c1a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/CreateBecVmServiceResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.baidubce.services.bec.model.vo.VmServiceBriefVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for creating the BEC service. + * Shared with creating the BEC service instance, return the brief content. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateBecVmServiceResponse extends ActionInfoVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/DelBecVmServiceRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/service/DelBecVmServiceRequest.java new file mode 100644 index 00000000..83eda4ef --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/DelBecVmServiceRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for deleting the virtual machine service. + */ +@Data +public class DelBecVmServiceRequest extends AbstractBceRequest { + + /** + * The id of the virtual machine service. + */ + String serviceId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DelBecVmServiceRequest with credentials. + */ + public DelBecVmServiceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/DelBecVmServiceResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/service/DelBecVmServiceResponse.java new file mode 100644 index 00000000..eed85205 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/DelBecVmServiceResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; + +import java.util.Map; + +/** + * The response for deleting the virtual machine service. + */ +public class DelBecVmServiceResponse extends ActionInfoVo> { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceMetricsRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceMetricsRequest.java new file mode 100644 index 00000000..5f210917 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceMetricsRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting BEC service metrics. + */ +@Data +public class GetBecVmServiceMetricsRequest extends AbstractBceRequest { + + /** + * The id of the virtual machine service. + */ + private String serviceId; + + /** + * The type of the metrics. + */ + private String type; + + /** + * Offset in seconds. + */ + private int offsetInSeconds; + + /** + * ServiceProvider. + */ + private String serviceProvider; + + /** + * stepInMin + */ + private Integer stepInMin; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVmServiceMetricsRequest with credentials. + */ + public GetBecVmServiceMetricsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceMetricsResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceMetricsResponse.java new file mode 100644 index 00000000..e53acd38 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceMetricsResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.services.bec.model.vo.MetricsVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for getting BEC service metrics. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBecVmServiceMetricsResponse extends MetricsVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceRequest.java new file mode 100644 index 00000000..411a62a0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting BEC virtual machine service. + */ +@Data +public class GetBecVmServiceRequest extends AbstractBceRequest { + + /** + * The id of the BEC virtual machine service. + */ + private String serviceId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVmServiceRequest with credentials. + */ + @Override + public GetBecVmServiceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceResponse.java new file mode 100644 index 00000000..95b948c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServiceResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.services.bec.model.vo.VmServiceDetailsVo; +import lombok.Data; + +/** + * The response for getting BEC virtual machine service. + */ +@Data +public class GetBecVmServiceResponse extends VmServiceDetailsVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServicesRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServicesRequest.java new file mode 100644 index 00000000..a3fc5908 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServicesRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the list of BEC virtual machine services. + */ +@Data +public class GetBecVmServicesRequest extends AbstractBceRequest { + + /** + * Query the keyword type of the virtual machine service. + */ + public String keywordType; + + /** + * Query the keyword of the virtual machine service. + */ + public String keyword; + + /** + * Page number of display page. + */ + public int pageNo; + + /** + * The number of services on the display page. + */ + public int pageSize; + + /** + * Sort, ascending/descending. + */ + public String order; + + /** + * Sort field. + */ + public String orderBy; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public GetBecVmServicesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServicesResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServicesResponse.java new file mode 100644 index 00000000..bee0e166 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/GetBecVmServicesResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.VmServiceBriefVo; +import lombok.Data; + +/** + * The response for getting the list of BEC virtual machine services. + */ +@Data +public class GetBecVmServicesResponse extends LogicPageResultResponse { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/Reservation.java b/src/main/java/com/baidubce/services/bec/model/vm/service/Reservation.java new file mode 100644 index 00000000..8faa72f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/Reservation.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-06 20:43 + * @Version v1.0 + * The reservation of the virtual machine service. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Reservation { + + /** + * The time length of reservation. + */ + private Integer length; + /** + * The time unit of reservation. + */ + private String timeUnit; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/UpdateBecVmServiceRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/service/UpdateBecVmServiceRequest.java new file mode 100644 index 00000000..9a2fe701 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/UpdateBecVmServiceRequest.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.purchase.DeploymentInstance; +import com.baidubce.services.bec.model.vm.KeyConfig; +import com.baidubce.services.bec.model.vm.VolumeConfig; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +/** + * The request for updating BEC virtual machine service. + * Consistent with cloud API. + */ +@Data +@Builder +public class UpdateBecVmServiceRequest extends AbstractBceRequest { + + /** + * The id of the vm service. + */ + private String serviceId; + + /** + * List of deployment instances. + */ + private List deployInstances; + + /** + * The name of the vm service. + */ + private String serviceName; + + /** + * The type of the vm service. + */ + private String type; + + /** + * The cpu of the vm service. + */ + private Integer cpu; + + /** + * The memory of the vm service. + */ + private Integer memory; + + /** + * Data disk configuration information. + */ + private VolumeConfig dataStorage; + + /** + * The password of the vm service. + */ + private String adminPass; + + /** + * The imageId of the service. + */ + private String imageId; + + /** + * The imageType of the service. + */ + private String imageType; + + /** + * The bandwidth of the service. + */ + private float bandwidth; + + /** + * The vm name of the service. + */ + private String vmName; + + /** + * The specification of the vm service. + */ + private String spec; + + /** + * The hostname of the vm service. + */ + private String hostname; + + /** + * The new way to configure password and key. + */ + private KeyConfig keyConfig; + + /** + * The security group ids. + */ + private List securityGroupIds; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateBecVmServiceRequest with credentials. + */ + public UpdateBecVmServiceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/service/UpdateBecVmServiceResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/service/UpdateBecVmServiceResponse.java new file mode 100644 index 00000000..e78b7754 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/service/UpdateBecVmServiceResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vm.service; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; +import com.baidubce.services.bec.model.vo.VmServiceDetailsVo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The response for updating the virtual machine service. + * Backend return the vm service detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateBecVmServiceResponse extends ActionInfoVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/template/CreateBecVmTemplateRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/template/CreateBecVmTemplateRequest.java new file mode 100644 index 00000000..6ac5e2c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/template/CreateBecVmTemplateRequest.java @@ -0,0 +1,123 @@ +package com.baidubce.services.bec.model.vm.template; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bec.model.vm.DnsConfig; +import com.baidubce.services.bec.model.vm.NetworkConfig.Networks; +import com.baidubce.services.bec.model.vm.SystemVolumeConfig; +import com.baidubce.services.bec.model.vm.VolumeConfig; +import lombok.Data; + +import java.util.List; + +/** + * The request for creating a newly vm template. + */ +@Data +public class CreateBecVmTemplateRequest extends AbstractBceRequest { + + /** + * The name of the virtual machine template. + */ + private String templateName; + + /** + * Policy + */ + private String policy; + + /** + * Specifications. + */ + private String spec; + + /** + * The number of CPUs of the virtual machine instance. + */ + private Integer cpu; + + /** + * The memory of the virtual machine instance. + */ + private Integer memory; + + /** + * Image id. + */ + private String imageId; + + /** + * Image type(bcc,bec) + * The subtypes becCommon, becCustom, and becGpu are unified as the request value bec, + * and the background will distinguish them according to imageId. + */ + private String imageType; + + /** + * Whether to disable the intranet,default false. + */ + private Boolean disableIntranet; + + /** + * Whether public network is required. + */ + private Boolean needPublicIp; + + /** + * Whether public IPv6 is required, needPublicIp needs to be true. + */ + private Boolean needIpv6PublicIp; + + /** + * The bandwidth of the BEC virtual template. + */ + private Integer bandwidth; + + /** + * GPU configuration information of virtual machine. + */ + private GpuRequest gpu; + + @Data + public static class GpuRequest { + private String type; + + private Integer num; + } + + /** + * Network information list. + */ + private List networksList; + + /** + * DNS configuration. + */ + private DnsConfig dnsConfig; + + /** + * Data disk configuration list. + */ + private List dataVolumeList; + + /** + * System disk configuration information. + */ + private SystemVolumeConfig systemVolume; + + /** + * Security group list. + */ + private List securityGroupIds; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateBecVmTemplateRequest with credentials. + */ + public CreateBecVmTemplateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/template/CreateBecVmTemplateResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/template/CreateBecVmTemplateResponse.java new file mode 100644 index 00000000..432cd57e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/template/CreateBecVmTemplateResponse.java @@ -0,0 +1,9 @@ +package com.baidubce.services.bec.model.vm.template; + +import com.baidubce.services.bec.model.vo.ActionInfoVo; + +/** + * The response for creating the BEC vm template. + */ +public class CreateBecVmTemplateResponse extends ActionInfoVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateListRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateListRequest.java new file mode 100644 index 00000000..f541b87f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateListRequest.java @@ -0,0 +1,9 @@ +package com.baidubce.services.bec.model.vm.template; + +import com.baidubce.services.bec.model.ListRequest; + +/** + * The request for getting the list of BEC virtual machine templates. + */ +public class GetBecVmTemplateListRequest extends ListRequest { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateListResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateListResponse.java new file mode 100644 index 00000000..57f67f69 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateListResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.bec.model.vm.template; + +import com.baidubce.services.bec.model.vm.LogicPageResultResponse; +import com.baidubce.services.bec.model.vo.VmTemplateVo; + +/** + * The response for getting the list of BEC virtual machine templates. + */ +public class GetBecVmTemplateListResponse extends LogicPageResultResponse { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateRequest.java b/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateRequest.java new file mode 100644 index 00000000..3329d708 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.bec.model.vm.template; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for getting the details of the BEC virtual machine template. + */ +@Data +public class GetBecVmTemplateRequest extends AbstractBceRequest { + + /** + * The id of the virtual machine template. + */ + private String templateId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetBecVmTemplateRequest with credentials. + */ + public GetBecVmTemplateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateResponse.java b/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateResponse.java new file mode 100644 index 00000000..1380721c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vm/template/GetBecVmTemplateResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bec.model.vm.template; + +import com.baidubce.services.bec.model.vo.BecResultVo; +import com.baidubce.services.bec.model.vo.VmTemplateVo; +import lombok.Data; + +/** + * The response for getting the details of the BEC virtual machine template. + */ +@Data +public class GetBecVmTemplateResponse extends BecResultVo { +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/AclEntryVo.java b/src/main/java/com/baidubce/services/bec/model/vo/AclEntryVo.java new file mode 100644 index 00000000..42985e27 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/AclEntryVo.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 19:29 + * @Version v1.0 + * The acl entry. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AclEntryVo { + + /** + * The subnet id. + */ + private String subnetId; + + /** + * The subnet name. + */ + private String subnetName; + + /** + * The subnet cidr. + */ + private String subnetCidr; + + /** + * The subnet description. + */ + private String subnetDescription; + + /** + * The acl rules. + */ + private List aclRules; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/AclRuleVo.java b/src/main/java/com/baidubce/services/bec/model/vo/AclRuleVo.java new file mode 100644 index 00000000..5ff8a1ab --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/AclRuleVo.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 19:25 + * @Version v1.0 + * The acl rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AclRuleVo { + + /** + * The acl id. + */ + private String aclId; + + /** + * The acl name. + */ + private String aclName; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * The vpc name. + */ + private String vpcName; + + /** + * The vpc cidr. + */ + private String vpcCidr; + + /** + * The acl rule id. + */ + private String aclRuleId; + + /** + * The acl rule long resource id. + */ + private String aclRuleUuid; + + /** + * The vpc id. + */ + private String subnetId; + + /** + * The description. + */ + private String description; + + /** + * Protocol, the value must be all|tcp|udp|icmp. + */ + private String protocol; + + /** + * Source ip address. + * ACL egress source ip address must be in subnet. + * Can take the value "all", represent all ip. + */ + private String sourceIpAddress; + + /** + * Destination ip address. + * ACL ingress destination ip address must be in subnet. + * Can take the value "all", represent all ip. + */ + private String destinationIpAddress; + + /** + * Source port, the value range is 0-65535. + */ + private String sourcePort; + + /** + * Destination port, the value range is 0-65535. + */ + private String destinationPort; + + /** + * The priority, the value range is 1-32768. + * The smaller the value, the higer the priority. + */ + private Integer position; + + /** + * The restrictive direction, the value must be ingress/egress. + */ + private String direction; + + /** + * The ether type, the value must be IPv4/IPv6. + */ + private String etherType; + + /** + * The action policy, the value must be "allow/deny". + */ + private String action; + + /** + * Whether is default. + */ + @JsonProperty("isDefault") + private Boolean isDefault; + + /** + * Whether is valid. + */ + private Boolean isValid; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/AclVo.java b/src/main/java/com/baidubce/services/bec/model/vo/AclVo.java new file mode 100644 index 00000000..5d4067d0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/AclVo.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 19:28 + * @Version v1.0 + * The acl. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AclVo extends AbstractBceResponse { + + /** + * The acl id. + */ + private String aclId; + + /** + * The acl name. + */ + private String aclName; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * The vpc name. + */ + private String vpcName; + + /** + * The vpc cidr. + */ + private String vpcCidr; + + /** + * The rgion id. + */ + private String regionId; + + /** + * The acl entry list. + */ + private List aclEntrys; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/ActionInfoVo.java b/src/main/java/com/baidubce/services/bec/model/vo/ActionInfoVo.java new file mode 100644 index 00000000..937e329c --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/ActionInfoVo.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The base response contains the basic information about the operation. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ActionInfoVo extends AbstractBceResponse { + + /** + * Operation result. + */ + private Boolean result; + + /** + * Operation type. + */ + private String action; + + /** + * Specific operation information. + */ + private T details; + +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/BecResultVo.java b/src/main/java/com/baidubce/services/bec/model/vo/BecResultVo.java new file mode 100644 index 00000000..5cded633 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/BecResultVo.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * BEC return result. + */ +@Data +public class BecResultVo extends AbstractBceResponse { + + /** + * Return result. + */ + public T result; + + /** + * Whether the operation was successful. + */ + public Boolean success; + + public BecResultVo() { + } + + public BecResultVo(T result) { + this.result = result; + success = true; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/BlbBackendPodBriefVo.java b/src/main/java/com/baidubce/services/bec/model/vo/BlbBackendPodBriefVo.java new file mode 100644 index 00000000..e5f5a442 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/BlbBackendPodBriefVo.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.services.bec.model.Stats; +import lombok.Data; + +import java.util.List; + +/** + * Blb Backend Pod Brief. + */ +@Data +public class BlbBackendPodBriefVo { + + /** + * The name of the Pod/Vm. + */ + private String podName; + + /** + * The status of the Pod/Vm. + */ + private String podStatus; + + /** + * The ip of the Pod/Vm. + */ + private String podIp; + + /** + * The port of the Pod/Vm. + */ + private List backendPort; + + /** + * The weight of the Pod/Vm. + */ + private Integer weight; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/BlbInstanceVo.java b/src/main/java/com/baidubce/services/bec/model/vo/BlbInstanceVo.java new file mode 100644 index 00000000..76173b73 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/BlbInstanceVo.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.Listeners; +import com.baidubce.services.bec.model.enums.ResourceStatusEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * BEC blb instance. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BlbInstanceVo extends AbstractBceResponse { + + /** + * The id of the blb. + */ + private String blbId; + + /** + * The name of the blb. + */ + private String blbName; + + /** + * The status of the blb. + */ + private ResourceStatusEnum status; + + /** + * Load balance type. + */ + private String lbType; + + /** + * The region id. + */ + private String regionId; + + /** + * Public ip. + */ + private String publicIp; + + /** + * China mobile public ip. + */ + private String cmPublicIP; + + /** + * China telecom public ip. + */ + private String ctPublicIP; + + /** + * China unicom public ip. + */ + private String unPublicIP; + + /** + * Internal ip. + */ + private String internalIp; + + /** + * Load balance port. + */ + private List ports; + + /** + * The number of backend servers bound to load balancing. + */ + private Integer podCount; + + /** + * Load balance maximum bandwidth limit. + */ + private Integer bandwidthInMbpsLimit; + + /** + * Creation time. + */ + private String createTime; + + /** + * Description. + */ + private String desc; + + /** + * The public ipv6 address. + */ + private String ipv6PublicIp; + + /** + * The China Mobile public ipv6 address. + */ + private String cmIpv6PublicIP; + + /** + * The China Telcom ipv6 address. + */ + private String ctIpv6PublicIP; + + /** + * The China Unicom public ipv6 address. + */ + private String unIpv6PublicIP; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/DeploySetVo.java b/src/main/java/com/baidubce/services/bec/model/vo/DeploySetVo.java new file mode 100644 index 00000000..796691ab --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/DeploySetVo.java @@ -0,0 +1,56 @@ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Date; + +import static com.baidubce.BceConstants.DEFAULT_DATETIME_FORMAT; + +/** + * DeploySet + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeploySetVo extends AbstractBceResponse { + + /** + * The deployment set id of the deployment set. + */ + private String deploysetId; + + /** + * The name of the deployment set. + */ + private String name; + + /** + * The description of the deployment set. + */ + private String desc; + + /** + * The maximum of concurrency of the deployment set. + */ + private Integer concurrency; + + /** + * The instance count of the deployment set. + */ + private Integer instanceCount; + + /** + * The total instances of the deployment set. + */ + private Integer instanceTotal; + + /** + * Creation time. + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DEFAULT_DATETIME_FORMAT, timezone = "GMT-8") + private Date createTime; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/DnatRuleVo.java b/src/main/java/com/baidubce/services/bec/model/vo/DnatRuleVo.java new file mode 100644 index 00000000..1fe82d6b --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/DnatRuleVo.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-22 11:07 + * @Version v1.0 + *

+ * The D-NAT rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DnatRuleVo { + + /** + * The nat id. + */ + private String natId; + + /** + * The intranet ip address. + */ + private String privateIpAddress; + + /** + * The intranet port. + */ + private String privatePort; + + /** + * Protocol. + */ + private String protocol; + + /** + * The public ip address. + */ + private NatEipVo publicIpAddress; + + /** + * The public port. + */ + private String publicPort; + + /** + * The rule id. + */ + private String ruleId; + + /** + * The rule name. + */ + private String ruleName; + + /** + * The rule status, like active/down. + */ + private String status; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/EipVo.java b/src/main/java/com/baidubce/services/bec/model/vo/EipVo.java new file mode 100644 index 00000000..ca63cfdd --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/EipVo.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.BceConstants; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 12:27 + * @Version v1.0 + * + * The abstract of the elastic public ip. + */ +@Data +@JsonInclude(JsonInclude.Include.NON_DEFAULT) +@JsonIgnoreProperties(ignoreUnknown = true) +public class EipVo { + + /** + * The id of the elastic public ip. + */ + private String eipId; + + /** + * The name of the elastic public ip. + */ + private String name; + + /** + * The shared bandwidth group id + */ + private String shareGroupId; + + /** + * The elastic public ip instance type, the value must be normal/shared. + */ + private String eipInstanceType; + + /** + * The elastic public ip + */ + private String eip; + + /** + * The id of instance which the elastic public ip is bound to. + */ + private String instanceId; + + /** + * The type of instance which the elastic public ip is bound to. + */ + private String instanceType; + + /** + * The binding status. + */ + private String status; + + /** + * The bandwidth. + */ + private Integer bandwidthInMbps; + + /** + * The route type. + */ + private String routeType; + + /** + * Creation time. + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "GMT-8") + private Date createTime; + + /** + * The expired time. + */ + private String expireTime; + + /** + * The payment time, Prepaid,Postpaid. + */ + private String paymentTiming; + + /** + * The resource tags. + */ + private List tags; + + /** + * The region id of the elastic public ip. + */ + private String regionId; + + /** + * The ip type version. + */ + private Integer ipVersion; + + /** + * The mode of network. + */ + private String mode; + + /** + * The purpose. + */ + private String purpose; + + /** + * The name of instance which the elastic public ip is bound to. + */ + private String instanceName; + + /** + * The ip of instance which the elastic public ip is bound to. + */ + private String instanceIp; + + /** + * The internet service provider. + */ + private String isp; + + /** + * The lb type. + */ + private String lbType; + + /** + * The status of instance which the elastic public ip is bound to. + */ + private String instanceStatus; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/EniVo.java b/src/main/java/com/baidubce/services/bec/model/vo/EniVo.java new file mode 100644 index 00000000..69ba2a2f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/EniVo.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.BceConstants; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 12:19 + * @Version v1.0 + * + * The abstract of the elastic network interface. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class EniVo { + + /** + * The id of the elastic network interface. + */ + private String eniId; + + /** + * The name of the elastic network interface. + */ + private String name; + + /** + * The description of the elastic network interface. + */ + private String description; + + /** + * The vpc id of the elastic network interface. + */ + private String vpcId; + + /** + * The subnet id of the elastic network interface. + */ + private String subnetId; + + /** + * The security group ids of the elastic network interface. + */ + private List securityGroupIds; + + /** + * The intranet ip set v1. + */ + private List ipSet; + + /** + * The status of the elastic network interface, like available/inuse/attaching/detaching. + */ + private String status; + + /** + * The mac address of the elastic network interface. + */ + private String macAddress; + + /** + * The instance id which the elastic network interface belong to. + */ + private String instanceId; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "UTC") + /** + * Creation time. + */ + private Date createTime; + + /** + * The region id of the elastic network interface. + */ + private String regionId; + + /** + * The subnet cidr which the elastic network interface belong to. + */ + private String subnetCidr; + + /** + * The instance name which the elastic network interface belong to. + */ + private String instanceName; + + /** + * The elastic public ips of the elastic network interface. + */ + private List eips; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/IpPackageVo.java b/src/main/java/com/baidubce/services/bec/model/vo/IpPackageVo.java new file mode 100644 index 00000000..03f48ef2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/IpPackageVo.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.enums.ServiceProviderEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 10:34 + * @Version v1.0 + *

+ * The abstract of ip. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class IpPackageVo extends AbstractBceResponse { + + /** + * Single-line public ip. + */ + private String publicIp; + + /** + * The single-line public ipv6 address. + */ + private String ipv6PublicIp; + + /** + * The single-line internal ipv6 address. + */ + private String ipv6InternalIp; + + /** + * The internal ip. + */ + private String internalIp; + + /** + * Triple-line public ip. + */ + private List multiplePublicIp; + + /** + * The internet service provider. + */ + private ServiceProviderEnum serviceProvider; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class IpInfo { + private ServiceProviderEnum serviceProvider; + private String ip; + private String ipv6; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/MetricsVo.java b/src/main/java/com/baidubce/services/bec/model/vo/MetricsVo.java new file mode 100644 index 00000000..9c929db4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/MetricsVo.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * BEC metrics. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class MetricsVo extends AbstractBceResponse { + + /** + * The list of the BEC metrics. + */ + private List metrics; + + /** + * Max value. + */ + private BigDecimal maxValue; + + /** + * Average value. + */ + private BigDecimal avgValue; + + /** + * Total value. + */ + private BigDecimal totalValue; + + /** + * The metric name. + */ + private String name; + + @Data + public static class Metric { + + /** + * Timestamp. + */ + private Integer timeInSecond; + + /** + * Metric value. + */ + private BigDecimal value; + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/NatEipVo.java b/src/main/java/com/baidubce/services/bec/model/vo/NatEipVo.java new file mode 100644 index 00000000..8b293b10 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/NatEipVo.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-22 10:20 + * @Version v1.0 + *

+ * NatEipVo. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NatEipVo { + + /** + * The nat eip. + */ + private String ip; + + /** + * The isp service provider. + */ + private String serviceProvider; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/NatVo.java b/src/main/java/com/baidubce/services/bec/model/vo/NatVo.java new file mode 100644 index 00000000..4de9abec --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/NatVo.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-22 10:14 + * @Version v1.0 + *

+ * The nat view object. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NatVo extends AbstractBceResponse { + + /** + * The bandwidth of nat. + */ + private Integer bandwidth; + + /** + * Creation time. + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'") + private Date createTime; + + /** + * The description. + */ + private String desc; + + /** + * The dnat eips. + */ + private List dnatEips; + + /** + * The eips. + */ + private List eips; + + /** + * The nat name. + */ + private String name; + + /** + * The nat id. + */ + private String natId; + + /** + * The region id. + */ + private String regionId; + + /** + * The specification. + */ + private String spec; + + /** + * The nat status, like starting/down/active/deleting + */ + private String status; + + /** + * The tags. + */ + private List tags; + + /** + * The vpc id. + */ + private String vpcId; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/NodeInfoVo.java b/src/main/java/com/baidubce/services/bec/model/vo/NodeInfoVo.java new file mode 100644 index 00000000..57b35100 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/NodeInfoVo.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Node information. + */ +@Data +public class NodeInfoVo { + + + /** + * Node information. + */ + private List regionList = new ArrayList(); + + /** + * Get node sum. + */ + public int getNodeSum() { + int result = 0; + for (RegionInfo regionInfo : regionList) { + for (CityInfo cityInfo : regionInfo.getCityList()) { + result += cityInfo.getServiceProviderList().size(); + } + } + return result; + } + + /** + * Region information. + */ + @Data + public static class RegionInfo { + + /** + * The English name of the region to which the node belongs. + */ + private String region; + + /** + * The Chinese name of the region to which the node belongs. + */ + private String name; + + /** + * Information about the city where the node is located. + */ + private List cityList = new ArrayList(); + + } + + /** + * City information. + */ + @Data + public static class CityInfo { + + /** + * The English name of the city to which the node belongs. + */ + private String city; + + /** + * The Chinese name of the city to which the node belongs. + */ + private String name; + + /** + * Information of the operator where the node is located. + */ + private List serviceProviderList = new ArrayList(); + + } + + /** + * Service provider information. + */ + @Data + public static class ServiceProviderInfo { + + /** + * The English name of the service provider to which the node belongs. + */ + private String serviceProvider; + + /** + * The Chinese name of the service provider to which the node belongs. + */ + private String name; + + } +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/PrivateIpSetVo.java b/src/main/java/com/baidubce/services/bec/model/vo/PrivateIpSetVo.java new file mode 100644 index 00000000..44a0ca1e --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/PrivateIpSetVo.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-08 14:17 + * @Version v1.0 + * The abstract of privateIp set + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PrivateIpSetVo { + /** + * Whether the primary ip. + */ + Boolean primary; + + /** + * Whether is ipv6. + */ + Boolean ipv6; + + /** + * The intranet ip which assigned automatically. + */ + String privateIpAddress; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/ResourceOverviewVo.java b/src/main/java/com/baidubce/services/bec/model/vo/ResourceOverviewVo.java new file mode 100644 index 00000000..6aa14a43 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/ResourceOverviewVo.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.resource.ResourceUsageInISP; +import lombok.Data; + +/** + * Resource overview information. + */ +@Data +public class ResourceOverviewVo extends AbstractBceResponse { + + /** + * The number of online nodes. + */ + private Integer ready; + + /** + * The number of nodes that are not online. + */ + private Integer notReady; + + /** + * The number of nodes purchased. + */ + private Integer used; + + /** + * Summary of user resource usage. + */ + private ResourceUsageInISP resourceUsage; + + /** + * The user has purchased the node summary. + */ + private NodeInfoVo usedNodes; + + /** + * Summary of online node information. + */ + private NodeInfoVo readyNodes; + + /** + * Summary of node information that is not online. + */ + private NodeInfoVo notReadyNodes; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/ResourceUsageVo.java b/src/main/java/com/baidubce/services/bec/model/vo/ResourceUsageVo.java new file mode 100644 index 00000000..b33de93d --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/ResourceUsageVo.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.resource.ResourceCount; +import lombok.Data; + +/** + * Summary of user container usage. + */ +@Data +public class ResourceUsageVo extends AbstractBceResponse { + + /** + * Service overview quantity summary. + */ + private ResourceCount serviceCount; + + /** + * Summary of deployment overview quantity. + */ + private ResourceCount deploymentCount; + + /** + * Summary of the number of pod overviews. + */ + private ResourceCount instanceCount; + + /** + * Summary of current cpu usage. + */ + private Integer cpu; + + /** + * Summary of current memory usage. + */ + private Integer memory; + + /** + * Summary of current gpu usage. + */ + private Integer gpu; + + /** + * Summary of current bandwidth usage. + */ + private Long bandwidth; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/RouteRuleVo.java b/src/main/java/com/baidubce/services/bec/model/vo/RouteRuleVo.java new file mode 100644 index 00000000..a23ee502 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/RouteRuleVo.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.services.bec.model.enums.RouteTypeEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * RouteRuleVo + * + * @Author zhangyongchao01 + * @Since 2024-11-12 19:08 + * @Version v1.0 + *

+ * The route rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class RouteRuleVo { + + /** + * The route table id. + */ + private String tableId; + + /** + * The route rule id. + */ + private String ruleId; + + /** + * The status of the route table. + */ + private String status; + + /** + * The ip versions. + */ + private Integer ipVersion; + + /** + * The source address. + */ + private String sourceAddress; + + /** + * The destination address. + */ + private String destinationAddress; + + /** + * The route type. + */ + private RouteTypeEnum routeType; + + /** + * The next hop. + */ + private String nexthop; + + /** + * The description. + */ + private String description; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/RouteTableVo.java b/src/main/java/com/baidubce/services/bec/model/vo/RouteTableVo.java new file mode 100644 index 00000000..7e90150f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/RouteTableVo.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-12 19:35 + * @Version v1.0 + * The route table. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class RouteTableVo { + + /** + * The route table id. + */ + private String tableId; + + /** + * The route table name. + */ + private String name; + + /** + * The route table status, ready、deleting、timeout. + */ + private String status; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * The vpc name. + */ + private String vpcName; + + /** + * The vpc cidr. + */ + private String vpcCidr; + + /** + * The region id. + */ + private String regionId; + + /** + * The route rule count. + */ + private Integer ruleCount; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/SnatRuleVo.java b/src/main/java/com/baidubce/services/bec/model/vo/SnatRuleVo.java new file mode 100644 index 00000000..54e4ba23 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/SnatRuleVo.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-22 19:38 + * @Version v1.0 + * The S-Nat rule. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SnatRuleVo { + + /** + * The nat id. + */ + private String natId; + + /** + * The rule id. + */ + private String ruleId; + + /** + * The rule name. + */ + private String ruleName; + + /** + * The rule status, like active/down. + */ + private String status; + + /** + * The source cidr. + */ + private String sourceCIDR; + + /** + * The public ip addresses. + */ + private List publicIpsAddress; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/SubnetVo.java b/src/main/java/com/baidubce/services/bec/model/vo/SubnetVo.java new file mode 100644 index 00000000..d03b5f7a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/SubnetVo.java @@ -0,0 +1,119 @@ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.BceConstants; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * Subnet instance + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SubnetVo extends AbstractBceResponse { + + /** + * The subnetId of the subnet instance. + */ + private String subnetId; + + /** + * The name of the subnet instance. + */ + private String name; + + /** + * The cidr of the subnet instance. + */ + private String cidr; + + /** + * The description of the subnet instance. + */ + private String description; + + /** + * The region id of the subnet instance. + */ + private String regionId; + + /** + * The long resource uuid of the subnet instance. + */ + private String uuid; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * The vpc name. + */ + private String vpcName; + + /** + * The ipv6 cidr. + */ + private String ipv6Cidr; + + /** + * Whether enable ipv6. + */ + private Boolean enableIpv6; + + /** + * The ipv6 subnet id of the subnet instance. + */ + private String ipv6SubnetId; + + /** + * The available ip count. + */ + private Integer availableIp; + + /** + * The used ip count. + */ + private Integer usedIp; + + /** + * The ip type version. + */ + private Integer ipVersion; + + /** + * Creation time. + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "GMT-8") + private Date createdTime; + + /** + * Whether default + */ + @JsonProperty("isDefault") + private Boolean isDefault; + + /** + * The status of the subnet instance. + */ + private String status; + + /** + * The tags. + */ + private List tags; + + /** + * The type of the subnet instance, like bm/common. + */ + private String subnetType; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/VmConfigVo.java b/src/main/java/com/baidubce/services/bec/model/vo/VmConfigVo.java new file mode 100644 index 00000000..9d731fa6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/VmConfigVo.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.ImageDetail; +import com.baidubce.services.bec.model.vm.SystemVolumeConfig; +import com.baidubce.services.bec.model.vm.VolumeConfig; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * VM config. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VmConfigVo extends AbstractBceResponse { + + /** + * The number of CPUs of the virtual machine instance. + */ + private Integer cpu; + + /** + * The memory of the virtual machine instance. + */ + private Integer mem; + + /** + * The need for public IP. + */ + private Boolean needPublicIp; + + /** + * The bandwidth of the virtual machine instance. + */ + private String bandwidth; + + /** + * System image details. + */ + private ImageDetail osImage; + + /** + * Data disk configuration list. + */ + private List dataVolumeList; + + /** + * System disk configuration information. + */ + private SystemVolumeConfig systemVolume; + + /** + * The region id of the virtual machine instance. + */ + private String regionId; + + /** + * The specification of the virtual machine instance. + */ + private String spec; + + /** + * The gpu card count of the virtual machine instance. + */ + private Integer gpu; + + /** + * The gpu type of the virtual machine instance, like nvidia.com/GA102_GeForce_RTX_3080. + */ + private String gpuType; + + /** + * The gpu model of the virtual machine instance, like NVIDIA GeForce RTX 3080. + */ + private String gpuModel; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/VmImageVo.java b/src/main/java/com/baidubce/services/bec/model/vo/VmImageVo.java new file mode 100644 index 00000000..777d1b57 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/VmImageVo.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-15 17:00 + * @Version v1.0 + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VmImageVo { + + /** + * The image id. + */ + private String imageId; + + /** + * Whether the image is used. + */ + private Boolean beingUsed; + + /** + * The image status, like IMAGING,SUCCEEDED. + */ + private String status; + + /** + * The bcc Base-line image id. + */ + private String bccImageId; + + /** + * The image name. + */ + private String name; + + /** + * The image type. + */ + private String imageType; + + /** + * The os type. + */ + private String osType; + + /** + * The os version. + */ + private String osVersion; + + /** + * The os name. + */ + private String osName; + + /** + * The os build version. + */ + private String osBuild; + + /** + * The os language. + */ + private String osLang; + + /** + * The os arch. + */ + private String osArch; + + /** + * The image size in byte. + */ + private Long sizeInByte; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/VmInstanceBriefVo.java b/src/main/java/com/baidubce/services/bec/model/vo/VmInstanceBriefVo.java new file mode 100644 index 00000000..ea888371 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/VmInstanceBriefVo.java @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.services.bec.model.ImageDetail; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Vm Instance Brief. + * Limited brief content return. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VmInstanceBriefVo extends IpPackageVo { + + /** + * The id of the virtual machine instance. + */ + private String vmId; + + /** + * The long resource uuid. + */ + private String uuid; + + /** + * The name of the virtual machine instance. + */ + private String vmName; + + /** + * The hostname of the virtual machine instance. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String hostname; + + /** + * The status of the virtual machine instance. + */ + private String status; + + /** + * The number of CPUs of the virtual machine instance. + */ + private Integer cpu; + + /** + * The memory of the virtual machine instance. + */ + private Integer mem; + + /** + * The number of GPUs the virtual machine instance. + */ + private Integer gpu; + + /** + * The same as GpuFlavor front end. + */ + private String gpuModel; + + /** + * The region id of the virtual machine instance. + */ + private String regionId; + + /** + * Whether the virtual machine need public ip. + */ + private Boolean needPublicIp; + + /** + * Whether the virtual machine need public ipv6. + */ + private Boolean needIpv6PublicIp; + + /** + * The bandwidth of the virtual machine instance. + */ + private String bandwidth; + + /** + * System image details. + */ + private ImageDetail osImage; + + /** + * The id of the virtual machine service. + */ + private String serviceId; + + /** + * The payment method of the virtual machine. + */ + private String paymentMethod; + + /** + * The reservation time length of the prepayment purchase. + */ + private Integer reserveLength; + + /** + * The renewal cycle of the prepayment purchase. + */ + private Integer renewCycle; + + /** + * The order ids of the virtual machine instance. + */ + private List orderIdList; + + /** + * The gpu flavor. + */ + private String gpuFlavor; + + /** + * Creation time. + */ + private String createTime; + + /** + * The deployment id of the virtual machine instance. + */ + private String deploymentId; + + /** + * The userData of the virtual machine instance. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String userData; + + /** + * The dns of the virtual machine instance. + */ + private String dns; + + /** + * The vpc of the virtual machine instance. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private VpcVo vpc; + + /** + * The subnet id of the virtual machine instance. + */ + private String subnetId; + + /** + * The security group ids of the virtual machine instance. + */ + private String sgIds; + + /** + * The deployment set id of the virtual machine instance. + */ + private String deploysetId; + + /** + * The tags of the virtual machine instance. + */ + private List tags; + + /** + * The cuda version of the virtual machine instance. + */ + private String cudaVersion; + + /** + * The driver version of the virtual machine instance. + */ + private String driverVersion; + + /** + * The cuDNN version of the virtual machine instance. + */ + private String cudnnVersion; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/VmInstanceDetailsVo.java b/src/main/java/com/baidubce/services/bec/model/vo/VmInstanceDetailsVo.java new file mode 100644 index 00000000..1c7db818 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/VmInstanceDetailsVo.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.services.bec.model.network.SecurityGroupVo; +import com.baidubce.services.bec.model.vm.KeyPair; +import com.baidubce.services.bec.model.vm.NetworkConfig; +import com.baidubce.services.bec.model.vm.SystemVolumeConfig; +import com.baidubce.services.bec.model.vm.VolumeConfig; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * Vm Instance Details. + * Limited detail return, used in getting vm instance detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VmInstanceDetailsVo extends VmInstanceBriefVo { + + /** + * The count of system disks. + */ + private Integer rootDiskSize; + + /** + * The count of data disks. + */ + private Integer dataStorage; + + /** + * The data volumes of the virtual machine instance. + */ + private List dataVolumeList; + + /** + * The system volume of the virtual machine instance. + */ + private SystemVolumeConfig systemVolume; + + /** + * The bcc key pairs of the virtual machine instance. + */ + private List bccKeyPairList; + + /** + * The intranet private ips of the virtual machine instance. + */ + private List privateIps; + + /** + * The virtual network configuration of the virtual machine instance. + */ + private NetworkConfig networkConfig; + + /** + * The security groups of the virtual machine instance. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private List securityGroups; + + /** + * The service name of the virtual machine instance. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String serviceName; + + /** + * The specification of the virtual machine instance. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private String spec; + + /** + * The deployment set list of the virtual machine instance. + */ + @JsonInclude(JsonInclude.Include.NON_NULL) + private List deploysetList; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/VmInstanceIdVo.java b/src/main/java/com/baidubce/services/bec/model/vo/VmInstanceIdVo.java new file mode 100644 index 00000000..c2bee98f --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/VmInstanceIdVo.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * Simple true vm instance id, region id info and so on. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VmInstanceIdVo { + + /** + * The id of the virtual machine instance. + */ + private String vmId; + + /** + * The name of the virtual machine instance. + */ + private String vmName; + + /** + * The region id of the virtual machine instance. + */ + private String regionId; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/VmServiceBriefVo.java b/src/main/java/com/baidubce/services/bec/model/vo/VmServiceBriefVo.java new file mode 100644 index 00000000..b678a1f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/VmServiceBriefVo.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.ImageDetail; +import com.baidubce.services.bec.model.enums.ResourceStatusEnum; +import com.baidubce.services.bec.model.purchase.DeploymentInstance; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * Vm Service Brief. + * Limited brief content return. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VmServiceBriefVo extends AbstractBceResponse { + + /** + * The id of the BEC virtual machine service. + */ + private String serviceId; + + /** + * The name of the BEC virtual machine service. + */ + private String serviceName; + + /** + * The status of the BEC virtual machine service. + */ + private ResourceStatusEnum status; + + /** + * The payment method of the BEC virtual machine service. + */ + private String paymentMethod; + + /** + * Total number of cpu. + */ + private Integer totalCpu; + + /** + * Total number of memory. + */ + private Integer totalMem; + + /** + * The total number of data disks. + */ + private Integer totalDisk; + + /** + * The total number of system disks. + */ + private Integer totalRootDisk; + + /** + * Number of regions. + */ + private Integer regions; + + /** + * List of deployment instances. + */ + private List deployInstances; + + /** + * The total number of instances. + */ + private Integer totalInstances; + + /** + * Number of running instances. + */ + private Integer runningInstances; + + /** + * System image details. + */ + private ImageDetail osImage; + + /** + * The simple instances info of the BEC virtual machine service. + */ + private List instances; + + /** + * Creation time. + */ + private String createTime; + + /** + * The order ids of the BEC virtual machine service. + */ + private List orderIdList; + + /** + * The tags of the BEC virtual machine service. + */ + private List tags; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/VmServiceDetailsVo.java b/src/main/java/com/baidubce/services/bec/model/vo/VmServiceDetailsVo.java new file mode 100644 index 00000000..a1305467 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/VmServiceDetailsVo.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * Vm Service Details. + * Limited detail return. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VmServiceDetailsVo extends VmServiceBriefVo { + + /** + * The bandwidth of the BEC virtual machine service. + */ + private String bandwidth; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/VmTemplateVo.java b/src/main/java/com/baidubce/services/bec/model/vo/VmTemplateVo.java new file mode 100644 index 00000000..df835796 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/VmTemplateVo.java @@ -0,0 +1,189 @@ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.services.bec.model.network.SecurityGroupVo; +import com.baidubce.services.bec.model.vm.DnsConfig; +import com.baidubce.services.bec.model.vm.NetworkConfig; +import com.baidubce.services.bec.model.vm.SystemVolumeConfig; +import com.baidubce.services.bec.model.vm.VolumeConfig; +import com.baidubce.services.bec.model.vm.template.CreateBecVmTemplateRequest.GpuRequest; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; + +/** + * Vm template + */ +@Data +public class VmTemplateVo { + + /** + * The name of the virtual machine template. + */ + private String templateName; + + /** + * The id of the virtual machine template. + */ + private String templateId; + + /** + * Policy + */ + private String policy; + + /** + * The number of CPUs of the virtual machine instance. + */ + private Integer cpu; + + /** + * The memory of the virtual machine instance. + */ + private Integer memory; + + /** + * Specifications. + */ + private String spec; + + /** + * Specifications. + */ + private String specType; + + /** + * Cpu model. + */ + private String cpuModel; + + /** + * Cpu frequency. + */ + private String cpuGHz; + + /** + * GPU configuration information of virtual machine. + */ + private GpuRequest gpu; + + /** + * Name of os, eg:CentOS + */ + private String osName; + + /** + * Version of os, eg:7.1 + */ + private String osVersion; + + /** + * Image type of os, eg:becCommon + */ + private String osImageType; + + /** + * Image name of os, eg:centos7.1 + */ + private String osImageName; + + /** + * System disk configuration information. + */ + private SystemVolumeConfig systemVolume; + + /** + * Data disk configuration list. + */ + private List dataVolumeList; + + /** + * Intra ip type, eg:ipv4 + */ + private String intraIpType; + + /** + * Extra ip type, eg:ipv4 + */ + private String extraIpType; + + /** + * Network configuration information list. + */ + private List networkConfigList; + + /** + * DNS configuration. + */ + private DnsConfig dnsConfig; + + /** + * The bandwidth of the BEC virtual template. + */ + private Integer bandwidth; + + /** + * The id of image. + */ + private String imageId; + + /** + * The type of image, eg:bec + */ + private String imageType; + + /** + * Whether to disable the intranet. + */ + private Boolean disableIntranet; + + /** + * Is the template available. + */ + private Boolean templateAvailable; + + /** + * Whether public network is required. + */ + private Boolean needPublicIp; + + /** + * Whether IPV6 is required + */ + private Boolean needIpv6PublicIp; + + /** + * SecurityGroup id list. + */ + private List securityGroupIds; + + /** + * SecurityGroups. + */ + private List securityGroups; + + /** + * FlavorTypePrepay + */ + private String flavorTypePrepay; + + /** + * FlavorTypePostpay + */ + private String flavorTypePostpay; + + /** + * FlavorTypePostpayCpt1 + */ + private String flavorTypePostpayCpt1; + + /** + * CreateTime + */ + private Timestamp createTime; + + /** + * UpdateTime + */ + private Timestamp updateTime; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/VpcVo.java b/src/main/java/com/baidubce/services/bec/model/vo/VpcVo.java new file mode 100644 index 00000000..752645fb --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/VpcVo.java @@ -0,0 +1,86 @@ +package com.baidubce.services.bec.model.vo; + +import com.baidubce.BceConstants; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * Vpc instance + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VpcVo extends AbstractBceResponse { + + /** + * The vpcId of the vpc instance. + */ + private String vpcId; + + /** + * The name of the vpc instance. + */ + private String name; + + /** + * The cidr of the vpc instance. + */ + private String cidr; + + /** + * The ipv6 cidr of the vpc. + */ + private String ipv6Cidr; + + /** + * The description of the vpc instance. + */ + private String description; + + /** + * Whether default. + */ + @JsonProperty("isDefault") + private Boolean isDefault; + + /** + * The subnets of the vpc. + */ + private List subnets; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BceConstants.DEFAULT_DATETIME_FORMAT, timezone = "GMT-8") + private Date createdTime; + + /** + * The region id of the vpc. + */ + private String regionId; + + /** + * The status of the vpc. + */ + private String status; + + /** + * The id of csn which the vpc is bound to. + */ + private String csnId; + + /** + * The name of csn which the vpc is bound to. + */ + private String csnName; + + /** + * The tags of the vpc. + */ + private List tags; +} diff --git a/src/main/java/com/baidubce/services/bec/model/vo/v2/AppIpGroupBackendPolicyVo.java b/src/main/java/com/baidubce/services/bec/model/vo/v2/AppIpGroupBackendPolicyVo.java new file mode 100644 index 00000000..7336c1ef --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/v2/AppIpGroupBackendPolicyVo.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo.v2; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 20:33 + * @Version v1.0 + *

+ * AppIpGroupBackendPolicyVo. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AppIpGroupBackendPolicyVo { + + /** + * The app blb id. + */ + private String blbId; + + /** + * The health check type, TCP/HTTP/UDP/ICMP. + */ + private String healthCheck; + + /** + * The unhealthy check threshold, making it unavailable after consecutive unsuccessful health checks. + * Default is 3, it should be an integer between 2-5. + */ + private Integer healthCheckDownRetry; + + /** + * The health check host, like "localhost", default empty, valid under HTTP protocol. + */ + private String healthCheckHost; + + /** + * The health check interval time, the unit is second. + * Default is 3, it should be an integer between 1-10. + */ + private Integer healthCheckIntervalInSecond; + + /** + * The health check http status code under healthy condition, like http_1xx|http_2xx; valid under HTTP protocol. + */ + private String healthCheckNormalStatus; + + /** + * The health check port, must assign under HTTP protocol. + */ + private Integer healthCheckPort; + + /** + * The health check timeout time, the unit is second. + * Default is 3, it should be an integer between 1-60. + */ + private Integer healthCheckTimeoutInSecond; + + /** + * The healthy check threshold, making it available after consecutive successful health checks. + * Default is 3, it should be an integer between 2-5. + */ + private Integer healthCheckUpRetry; + + /** + * The health check url path, default /, valid under HTTP protocol. + */ + private String healthCheckUrlPath; + + /** + * The policy id. + */ + private String id; + + /** + * The ip group id. + */ + private String ipGroupId; + + /** + * The ip group protocol, TCP/HTTP/UDP. + */ + private String type; + + /** + * The UDP health check string, must assign under UDP protocol. + */ + private String udpHealthCheckString; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/v2/AppIpGroupVo.java b/src/main/java/com/baidubce/services/bec/model/vo/v2/AppIpGroupVo.java new file mode 100644 index 00000000..f6ea1c07 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/v2/AppIpGroupVo.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo.v2; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 20:32 + * @Version v1.0 + *

+ * App ip group. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AppIpGroupVo { + + /** + * The ip group id. + */ + private String id; + + /** + * The ip group name. + */ + private String name; + + /** + * The ip group description. + */ + private String desc; + + /** + * The ip group backend policies. + */ + private List backendPolicyList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/v2/AppPolicyVo.java b/src/main/java/com/baidubce/services/bec/model/vo/v2/AppPolicyVo.java new file mode 100644 index 00000000..dc1892e0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/v2/AppPolicyVo.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo.v2; + +import com.baidubce.services.bec.model.appblbv2.listener.AppRule; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 20:14 + * @Version v1.0 + *

+ * App policy. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AppPolicyVo { + + /** + * The policy id. + */ + private String id; + + /** + * The ip group id. + */ + private String appIpGroupId; + + /** + * The ip group name. + */ + private String appIpGroupName; + + /** + * The description. + */ + private String desc; + + /** + * The frontend port. + */ + private Integer frontendPort; + + /** + * The priority. + */ + private Integer priority; + + /** + * The rule List. + */ + private List ruleList; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/v2/BlbDetailVo.java b/src/main/java/com/baidubce/services/bec/model/vo/v2/BlbDetailVo.java new file mode 100644 index 00000000..63da5629 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/v2/BlbDetailVo.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo.v2; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bec.model.enums.ResourceStatusEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 14:10 + * @Version v1.0 + *

+ * Bec blb detail. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BlbDetailVo extends AbstractBceResponse { + + /** + * The intra net ip. + */ + private String address; + + /** + * The blb id. + */ + private String blbId; + + /** + * The blb vpc cidr. + */ + private String cidr; + + /** + * Creation time. + */ + private String createTime; + + /** + * The blb descripton. + */ + private String desc; + + /** + * The listeners mounted on the blb. + */ + private List listener; + + /** + * The blb public ipv6 address. + */ + private String ipv6; + + /** + * The blb name. + */ + private String name; + + /** + * The blb public ip. + */ + private String publicIp; + + /** + * The region id. + */ + private String regionId; + + /** + * The blb status. + */ + private ResourceStatusEnum status; + + /** + * The blb id. + */ + private String subnetCidr; + + /** + * The blb subnet id. + */ + private String subnetId; + + /** + * The blb subnet name. + */ + private String subnetName; + + /** + * The vpc id. + */ + private String vpcId; + + /** + * The vpc name. + */ + private String vpcName; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/v2/BlbModel.java b/src/main/java/com/baidubce/services/bec/model/vo/v2/BlbModel.java new file mode 100644 index 00000000..c03ca948 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/v2/BlbModel.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo.v2; + +import com.baidubce.services.bec.model.enums.ResourceStatusEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 19:32 + * @Version v1.0 + *

+ * Blb model. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BlbModel { + + /** + * The intra net ip. + */ + private String address; + + /** + * The blb id. + */ + private String blbId; + + /** + * The blb description. + */ + private String desc; + + /** + * The blb public ipv6 address. + */ + private String ipv6; + + /** + * The blb name. + */ + private String name; + + /** + * The blb public ip. + */ + private String publicIp; + + /** + * The region id. + */ + private String regionId; + + /** + * The blb status. + */ + private ResourceStatusEnum status; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/v2/ListRequest.java b/src/main/java/com/baidubce/services/bec/model/vo/v2/ListRequest.java new file mode 100644 index 00000000..dbf43eb0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/v2/ListRequest.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo.v2; + +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-20 14:22 + * @Version v1.0 + *

+ * ListRequest. + */ +@Data +public class ListRequest { + + /** + * The selection start position. + */ + private String marker; + + /** + * A page can contain the maximum value, 1-1000, default 1000. + */ + private Integer maxKeys; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/v2/ListResponse.java b/src/main/java/com/baidubce/services/bec/model/vo/v2/ListResponse.java new file mode 100644 index 00000000..4d1e1d0a --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/v2/ListResponse.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo.v2; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 19:21 + * @Version v1.0 + *

+ * ListResponse + */ +@Data +public class ListResponse extends AbstractBceResponse { + + /** + * The selection start position. + */ + private String marker; + + /** + * The next selection start position. true represent that there are other more data, false represent + * that there are no data already. + */ + private Boolean isTruncated; + + /** + * The next selection start position. + */ + private String nextMarker; + + /** + * A page can contain the maximum value, 1-1000, default 1000. + */ + private Integer maxKeys; + + /** + * Selection result. + */ + @JsonIgnore + private List result; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bec/model/vo/v2/ListenerModel.java b/src/main/java/com/baidubce/services/bec/model/vo/v2/ListenerModel.java new file mode 100644 index 00000000..bf8305bd --- /dev/null +++ b/src/main/java/com/baidubce/services/bec/model/vo/v2/ListenerModel.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bec.model.vo.v2; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @Author zhangyongchao01 + * @Since 2024-11-21 19:11 + * @Version v1.0 + *

+ * The listener Model. + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListenerModel { + + /** + * The listen port. + */ + private String port; + + /** + * The listen protocol. + */ + private String type; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/BesClient.java b/src/main/java/com/baidubce/services/bes/BesClient.java new file mode 100644 index 00000000..dc4f0597 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/BesClient.java @@ -0,0 +1,642 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bes.model.BesCreateAutoRenewRuleRequest; +import com.baidubce.services.bes.model.BesCreateAutoRenewRuleResponse; +import com.baidubce.services.bes.model.BesCreateClusterRequest; +import com.baidubce.services.bes.model.BesCreateClusterResponse; +import com.baidubce.services.bes.model.BesDeleteAutoRenewRuleRequest; +import com.baidubce.services.bes.model.BesDeleteAutoRenewRuleResponse; +import com.baidubce.services.bes.model.BesDeleteClusterRequest; +import com.baidubce.services.bes.model.BesDeleteClusterResponse; +import com.baidubce.services.bes.model.BesGetAutoRenewRuleListRequest; +import com.baidubce.services.bes.model.BesGetAutoRenewRuleListResponse; +import com.baidubce.services.bes.model.BesGetClusterDetailRequest; +import com.baidubce.services.bes.model.BesGetClusterDetailResponse; +import com.baidubce.services.bes.model.BesGetClusterListRequest; +import com.baidubce.services.bes.model.BesGetClusterListResponse; +import com.baidubce.services.bes.model.BesGetRenewListRequest; +import com.baidubce.services.bes.model.BesGetRenewListResponse; +import com.baidubce.services.bes.model.BesRenewClusterRequest; +import com.baidubce.services.bes.model.BesRenewClusterResponse; +import com.baidubce.services.bes.model.BesResizeClusterRequest; +import com.baidubce.services.bes.model.BesStartClusterRequest; +import com.baidubce.services.bes.model.BesStartClusterResponse; +import com.baidubce.services.bes.model.BesStartInstanceRequest; +import com.baidubce.services.bes.model.BesStartInstanceResponse; +import com.baidubce.services.bes.model.BesStopClusterRequest; +import com.baidubce.services.bes.model.BesStopClusterResponse; +import com.baidubce.services.bes.model.BesStopInstanceRequest; +import com.baidubce.services.bes.model.BesStopInstanceResponse; +import com.baidubce.services.bes.model.BesUpdateAutoRenewRuleRequest; +import com.baidubce.services.bes.model.BesUpdateAutoRenewRuleResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonGenerator; +import org.apache.commons.codec.binary.Hex; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.io.IOException; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Baidu Elasticsearch service + */ +public class BesClient extends AbstractBceClient { + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + private static final String BASE_PATH = "/api/bes/cluster"; + private static final String STOP = "/stop"; + private static final String START = "/start"; + private static final String DELETE = "/delete"; + private static final String LIST = "/list"; + private static final String DETAIL = "/detail"; + private static final String CREATE = "/create"; + private static final String RESIZE = "/resize"; + private static final String UPDATE = "/update"; + private static final String INSTANCE = "/instance"; + private static final String RENEW = "/renew"; + private static final String AUTO_RENEW_RULE = "/auto_renew_rule"; + private static final String X_REGION = "X-Region"; + private static final String BES_SERVICE_TYPE = "BES"; + private String region; + /** + * Responsible for handling HttpResponse from all BES service calls. + */ + private static final HttpResponseHandler[] BES_HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public BesClient() { + this(new BceClientConfiguration()); + } + + /** + * @param clientConfiguration The BCE client configuration options. + */ + public BesClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, BES_HANDLERS); + } + + /** + * @param clientConfiguration The BCE client configuration options. + * @param region client configuration options Defaults to bj + */ + public BesClient(BceClientConfiguration clientConfiguration, String region) { + super(clientConfiguration, BES_HANDLERS); + this.region = region; + } + + /** + * Stop cluster owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param besStopClusterRequest + * @return Returns a request response code or error message + */ + public BesStopClusterResponse stopCluster(BesStopClusterRequest besStopClusterRequest) { + checkNotNull(besStopClusterRequest, "request should not be null."); + checkStringNotEmpty(besStopClusterRequest.getClusterId(), + "The parameter clusterId should not be null or empty string."); + + String json = null; + try { + json = besStopClusterRequest.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + besStopClusterRequest, HttpMethodName.POST, BASE_PATH, STOP); + + addCommonHeader(internalRequest, json); + + BesStopClusterResponse besStopClusterResponse = + this.invokeHttpClient(internalRequest, BesStopClusterResponse.class); + return besStopClusterResponse; + } + + /** + * Start cluster owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param besStartClusterRequest + * @return Returns a request response code or error message + */ + public BesStartClusterResponse startCluster(BesStartClusterRequest besStartClusterRequest) { + checkNotNull(besStartClusterRequest, "request should not be null."); + checkStringNotEmpty(besStartClusterRequest.getClusterId(), + "The parameter clusterId should not be null or empty string."); + + String json = null; + try { + json = besStartClusterRequest.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + besStartClusterRequest, HttpMethodName.POST, BASE_PATH, START); + + addCommonHeader(internalRequest, json); + + BesStartClusterResponse besStartClusterResponse = + this.invokeHttpClient(internalRequest, BesStartClusterResponse.class); + return besStartClusterResponse; + } + + /** + * Delete cluster owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param besDeleteClusterRequest + * @return Returns a request response code or error message + */ + public BesDeleteClusterResponse deleteCluster(BesDeleteClusterRequest besDeleteClusterRequest) { + checkNotNull(besDeleteClusterRequest, "request should not be null."); + checkStringNotEmpty(besDeleteClusterRequest.getClusterId(), "" + + "The parameter clusterId should not be null or empty string."); + + String json = null; + try { + json = besDeleteClusterRequest.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + besDeleteClusterRequest, HttpMethodName.POST, BASE_PATH, DELETE); + + addCommonHeader(internalRequest, json); + + BesDeleteClusterResponse besDeleteClusterResponse = + this.invokeHttpClient(internalRequest, BesDeleteClusterResponse.class); + return besDeleteClusterResponse; + } + + /** + * List BES clusters owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param besGetClusterListRequest + * @return The response containing a list of the BES clusters owned by the authenticated sender of the request. + */ + public BesGetClusterListResponse getClusterList(BesGetClusterListRequest besGetClusterListRequest) { + checkNotNull(besGetClusterListRequest, "request should not be null."); + + String json = null; + try { + json = besGetClusterListRequest.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + besGetClusterListRequest, HttpMethodName.POST, BASE_PATH, LIST); + + addCommonHeader(internalRequest, json); + + BesGetClusterListResponse besGetClusterListResponse = + this.invokeHttpClient(internalRequest, BesGetClusterListResponse.class); + return besGetClusterListResponse; + } + + /** + * Get cluster detail owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param besGetClusterDetailRequest + * @return Get cluster information or error code + */ + public BesGetClusterDetailResponse getClusterDetail(BesGetClusterDetailRequest besGetClusterDetailRequest) { + checkNotNull(besGetClusterDetailRequest, "request should not be null."); + checkStringNotEmpty(besGetClusterDetailRequest.getClusterId(), + "The parameter clusterId should not be null or empty string."); + + String json = null; + try { + json = besGetClusterDetailRequest.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + besGetClusterDetailRequest, HttpMethodName.POST, BASE_PATH, DETAIL); + + addCommonHeader(internalRequest, json); + + BesGetClusterDetailResponse besGetClusterDetailResponse = + this.invokeHttpClient(internalRequest, BesGetClusterDetailResponse.class); + return besGetClusterDetailResponse; + } + + /** + * Create a cluster + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param request + * @return Create the order ID for the cluster + */ + public BesCreateClusterResponse createCluster(BesCreateClusterRequest request) { + checkNotNull(request, "request should not be null."); + + String json = null; + try { + json = request.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, BASE_PATH, CREATE); + + addCommonHeader(internalRequest, json); + + BesCreateClusterResponse deployResponse = + this.invokeHttpClient(internalRequest, BesCreateClusterResponse.class); + return deployResponse; + } + + /** + * Resize cluster detail owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param request + * @return Create the order ID for the cluster + */ + public BesCreateClusterResponse resizeCluster(BesResizeClusterRequest request) { + checkNotNull(request, "request should not be null."); + + String json = null; + try { + json = request.toJson(region); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, BASE_PATH, RESIZE); + + internalRequest.addParameter("orderType", "RESIZE"); + addCommonHeader(internalRequest, json); + + BesCreateClusterResponse deployResponse = + this.invokeHttpClient(internalRequest, BesCreateClusterResponse.class); + return deployResponse; + } + + /** + * Start cluster instance owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param request + * @return Returns a request response code or error message + */ + public BesStartInstanceResponse startClusterInstance(BesStartInstanceRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getClusterId(), + "The parameter clusterId should not be null or empty string."); + String json = null; + try { + json = request.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, BASE_PATH, INSTANCE, START); + + addCommonHeader(internalRequest, json); + + BesStartInstanceResponse besStartInstanceResponse = + this.invokeHttpClient(internalRequest, BesStartInstanceResponse.class); + return besStartInstanceResponse; + } + + /** + * Stop cluster instance owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param request + * @return Returns a request response code or error message + */ + public BesStopInstanceResponse stopClusterInstance(BesStopInstanceRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getClusterId(), + "The parameter clusterId should not be null or empty string."); + String json = null; + try { + json = request.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, BASE_PATH, INSTANCE, STOP); + + addCommonHeader(internalRequest, json); + + BesStopInstanceResponse besStopInstanceResponse = + this.invokeHttpClient(internalRequest, BesStopInstanceResponse.class); + return besStopInstanceResponse; + } + + /** + * Get BES renew list owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param request + * @return Returns a request response code or error message + */ + public BesGetRenewListResponse getRenewList(BesGetRenewListRequest request) { + checkNotNull(request, "request should not be null."); + + String json = null; + try { + json = request.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, BASE_PATH, RENEW, LIST); + + addCommonHeader(internalRequest, json); + + BesGetRenewListResponse besGetRenewListResponse = + this.invokeHttpClient(internalRequest, BesGetRenewListResponse.class); + return besGetRenewListResponse; + } + + /** + * Renew cluster owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param request + * @return Returns a request response code or error message + */ + public BesRenewClusterResponse renewCluster(BesRenewClusterRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getClusterId(), + "The parameter clusterId should not be null or empty string."); + String json = null; + try { + json = request.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, BASE_PATH, RENEW); + + internalRequest.addParameter("orderType", "RENEW"); + addCommonHeader(internalRequest, json); + + BesRenewClusterResponse besRenewClusterResponse = + this.invokeHttpClient(internalRequest, BesRenewClusterResponse.class); + return besRenewClusterResponse; + } + + /** + * Get BES auto renew list owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @return Returns a request response code or error message + */ + public BesGetAutoRenewRuleListResponse getAutoRenewRuleList() { + BesGetAutoRenewRuleListRequest besGetAutoRenewRuleListRequest = new BesGetAutoRenewRuleListRequest(); + besGetAutoRenewRuleListRequest.setServiceType(BES_SERVICE_TYPE); + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("serviceType", BES_SERVICE_TYPE); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + besGetAutoRenewRuleListRequest, HttpMethodName.POST, BASE_PATH, AUTO_RENEW_RULE, LIST); + + addCommonHeader(internalRequest, writer.toString()); + + BesGetAutoRenewRuleListResponse besGetAutoRenewRuleResponse = + this.invokeHttpClient(internalRequest, BesGetAutoRenewRuleListResponse.class); + return besGetAutoRenewRuleResponse; + } + + /** + * Create auto renew rule by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param request + * @return Returns a request response code or error message + */ + public BesCreateAutoRenewRuleResponse createAutoRenewRule(BesCreateAutoRenewRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getClusterIds(), + "The parameter clusterIds should not be null or empty string."); + String json = null; + try { + json = request.toJson(region); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, BASE_PATH, AUTO_RENEW_RULE, CREATE); + + addCommonHeader(internalRequest, json); + + BesCreateAutoRenewRuleResponse besCreateAutoRenewRuleResponse = + this.invokeHttpClient(internalRequest, BesCreateAutoRenewRuleResponse.class); + return besCreateAutoRenewRuleResponse; + } + + /** + * Update auto renew rule owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param request + * @return Returns a request response code or error message + */ + public BesUpdateAutoRenewRuleResponse updateAutoRenewRule(BesUpdateAutoRenewRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getClusterId(), + "The parameter clusterIds should not be null or empty string."); + + String json = null; + try { + json = request.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, BASE_PATH, AUTO_RENEW_RULE, UPDATE); + + addCommonHeader(internalRequest, json); + + BesUpdateAutoRenewRuleResponse besUpdateAutoRenewRuleResponse = + this.invokeHttpClient(internalRequest, BesUpdateAutoRenewRuleResponse.class); + return besUpdateAutoRenewRuleResponse; + } + + /** + * Delete auto renew rule owned by the authenticated user. + * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the BES clusters owned by the user. + * + * @param request + * @return Returns a request response code or error message + */ + public BesDeleteAutoRenewRuleResponse deleteAutoRenewRule(BesDeleteAutoRenewRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getClusterId(), + "The parameter clusterIds should not be null or empty string."); + + String json = null; + try { + json = request.toJson(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, BASE_PATH, AUTO_RENEW_RULE, DELETE); + + addCommonHeader(internalRequest, json); + + BesDeleteAutoRenewRuleResponse besDeleteAutoRenewRuleResponse = + this.invokeHttpClient(internalRequest, BesDeleteAutoRenewRuleResponse.class); + return besDeleteAutoRenewRuleResponse; + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest( + AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { + List path = new ArrayList(); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + + return request; + } + + /** + * The encryption implement for AES-128 algorithm for BCE password encryption. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + * + * @param content The content String to encrypt. + * @param privateKey The security key to encrypt. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + * + * @return The encrypted string of the original content with AES-128 algorithm. + * + * @throws GeneralSecurityException + */ + private String aes128EncryptWithFirst16Char(String content, String privateKey) throws GeneralSecurityException { + if (privateKey == null || privateKey.length() < 16) { + throw new GeneralSecurityException("account secretKey is wrong"); + } + byte[] crypted = null; + SecretKeySpec skey = new SecretKeySpec(privateKey.substring(0, 16).getBytes(), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, skey); + crypted = cipher.doFinal(content.getBytes()); + return new String(Hex.encodeHex(crypted)); + } + + /** + * Add the common request header to the request object + * + * @param internalRequest A new request object populated with endpoint, resource path and specific + * parameters to send. + * @param json Json transmission of the request body + */ + private void addCommonHeader(InternalRequest internalRequest, String json) { + byte[] bytes = null; + try { + bytes = json.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(bytes.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json"); + internalRequest.addHeader(X_REGION, region); + internalRequest.setContent(RestartableInputStream.wrap(bytes)); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/AbstractBesRequest.java b/src/main/java/com/baidubce/services/bes/model/AbstractBesRequest.java new file mode 100644 index 00000000..9127b223 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/AbstractBesRequest.java @@ -0,0 +1,29 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.io.Serializable; + +/** + * @Description: Base class for all BES web service request objects. + */ +public class AbstractBesRequest extends AbstractBceRequest implements Serializable { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesClusterBillingResponse.java b/src/main/java/com/baidubce/services/bes/model/BesClusterBillingResponse.java new file mode 100644 index 00000000..25ef85d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesClusterBillingResponse.java @@ -0,0 +1,31 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @Description: Query the response for the payment method + */ +public class BesClusterBillingResponse { + @JsonProperty + private String paymentType; + + public String getPaymentType() { + return paymentType; + } + + public void setPaymentType(String paymentType) { + this.paymentType = paymentType; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesConfigTuple.java b/src/main/java/com/baidubce/services/bes/model/BesConfigTuple.java new file mode 100644 index 00000000..84c0b3ff --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesConfigTuple.java @@ -0,0 +1,44 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @Description: Cluster resize configuration + */ +public class BesConfigTuple { + + @JsonProperty + private String id; + + @JsonProperty + private String value; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesCreateAutoRenewRuleRequest.java b/src/main/java/com/baidubce/services/bes/model/BesCreateAutoRenewRuleRequest.java new file mode 100644 index 00000000..7110c269 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesCreateAutoRenewRuleRequest.java @@ -0,0 +1,87 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.List; + +public class BesCreateAutoRenewRuleRequest extends AbstractBesRequest { + @JsonProperty + private List clusterIds; + @JsonProperty + private String userId; + @JsonProperty + private String renewTimeUnit; + @JsonProperty + private int renewTime; + + public List getClusterIds() { + return clusterIds; + } + + public void setClusterIds(List clusterIds) { + this.clusterIds = clusterIds; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getRenewTimeUnit() { + return renewTimeUnit; + } + + public void setRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + } + + public int getRenewTime() { + return renewTime; + } + + public void setRenewTime(int renewTime) { + this.renewTime = renewTime; + } + + public String toJson(String region) throws IOException { + + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("clusterIds"); + for (String clusterId : clusterIds) { + jsonGenerator.writeString(clusterId); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeStringField("serviceType", "BES"); + jsonGenerator.writeStringField("userId", userId); + jsonGenerator.writeStringField("region", region); + jsonGenerator.writeStringField("renewTimeUnit", renewTimeUnit); + jsonGenerator.writeNumberField("renewTime", renewTime); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesCreateAutoRenewRuleResponse.java b/src/main/java/com/baidubce/services/bes/model/BesCreateAutoRenewRuleResponse.java new file mode 100644 index 00000000..20383c3d --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesCreateAutoRenewRuleResponse.java @@ -0,0 +1,52 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +public class BesCreateAutoRenewRuleResponse extends AbstractBceResponse implements Serializable { + @JsonProperty + private Boolean success; + @JsonProperty + private int status; + @JsonProperty + private String result = " "; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesCreateClusterRequest.java b/src/main/java/com/baidubce/services/bes/model/BesCreateClusterRequest.java new file mode 100644 index 00000000..72eccf06 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesCreateClusterRequest.java @@ -0,0 +1,264 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.List; + +/** + * @Description: Request to create a cluster + */ +public class BesCreateClusterRequest extends AbstractBesRequest { + @JsonProperty + private String name; + + @JsonProperty + private String password; + + @JsonProperty + private List modules; + + @JsonProperty + private String version; + + @JsonProperty + private String availableZone; + + @JsonProperty + private String securityGroupId; + + @JsonProperty + private String subnetUuid; + + @JsonProperty + private String vpcId; + @JsonProperty + private ClusterBilling billing; + @JsonProperty + private boolean isOldPackage; + + public boolean isOldPackage() { + return isOldPackage; + } + + public void setOldPackage(boolean oldPackage) { + isOldPackage = oldPackage; + } + + public ClusterBilling getBilling() { + return billing; + } + + public void setBilling(ClusterBilling billing) { + this.billing = billing; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public List getModules() { + return modules; + } + + public void setModules(List modules) { + this.modules = modules; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getAvailableZone() { + return availableZone; + } + + public void setAvailableZone(String availableZone) { + this.availableZone = availableZone; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + public String getSubnetUuid() { + return subnetUuid; + } + + public void setSubnetUuid(String subnetUuid) { + this.subnetUuid = subnetUuid; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + /** + * Configuration information for the cluster + */ + @JsonIgnoreProperties(ignoreUnknown = true) + public static class ModuleInfo { + @JsonProperty + private String type; + @JsonProperty + private int instanceNum; + + @JsonProperty + private String slotType; + + @JsonProperty + private DiskSlotInfo diskSlotInfo; + + public String getSlotType() { + return slotType; + } + + public void setSlotType(SlotType slotType) { + setSlotType(slotType.getSlotType()); + } + + public void setSlotType(String slotType) { + this.slotType = slotType; + } + + public DiskSlotInfo getDiskSlotInfo() { + return diskSlotInfo; + } + + public void setDiskSlotInfo(DiskSlotInfo diskSlotInfo) { + this.diskSlotInfo = diskSlotInfo; + } + + public int getInstanceNum() { + return instanceNum; + } + + public void setInstanceNum(int instanceNum) { + this.instanceNum = instanceNum; + } + + public String getType() { + return type; + } + + public void setType(ModuleType type) { + setType(type.getModuleType()); + } + + public void setType(String type) { + this.type = type; + } + } + + /** + * Cluster payment method + */ + @JsonIgnoreProperties(ignoreUnknown = true) + public static class ClusterBilling { + @JsonProperty + private String paymentType; + @JsonProperty + private int time; + + public String getPaymentType() { + return paymentType; + } + + public void setPaymentType(PaymentType paymentType) { + setPaymentType(paymentType.getPaymentType()); + } + + public void setPaymentType(String paymentType) { + this.paymentType = paymentType; + } + + public int getTime() { + return time; + } + + public void setTime(int time) { + this.time = time; + } + } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("name", name); + jsonGenerator.writeStringField("password", password); + jsonGenerator.writeArrayFieldStart("modules"); + for (BesCreateClusterRequest.ModuleInfo module : modules) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("type", module.getType()); + jsonGenerator.writeNumberField("instanceNum", module.getInstanceNum()); + jsonGenerator.writeStringField("slotType", module.getSlotType()); + if (module.getDiskSlotInfo() != null) { + jsonGenerator.writeObjectFieldStart("diskSlotInfo"); + jsonGenerator.writeStringField("type", module.getDiskSlotInfo().getType()); + jsonGenerator.writeNumberField("size", module.getDiskSlotInfo().getSize()); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeObjectFieldStart("billing"); + jsonGenerator.writeStringField("paymentType", billing.getPaymentType()); + jsonGenerator.writeNumberField("time", billing.getTime()); + jsonGenerator.writeEndObject(); + jsonGenerator.writeStringField("version", version); + jsonGenerator.writeBooleanField("isOpenService", false); + jsonGenerator.writeBooleanField("isOldPackage", isOldPackage); + jsonGenerator.writeStringField("availableZone", availableZone); + jsonGenerator.writeStringField("securityGroupId", securityGroupId); + jsonGenerator.writeStringField("subnetUuid", subnetUuid); + jsonGenerator.writeStringField("vpcId", vpcId); + jsonGenerator.writeStringField("serviceType", "BES"); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesCreateClusterResponse.java b/src/main/java/com/baidubce/services/bes/model/BesCreateClusterResponse.java new file mode 100644 index 00000000..a3015b42 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesCreateClusterResponse.java @@ -0,0 +1,67 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.io.Serializable; + +/** + * @Description: Create the cluster response + */ +public class BesCreateClusterResponse extends AbstractBceResponse implements Serializable { + private Boolean success; + + private int status; + + private CreateResponse result; + + public CreateResponse getResult() { + return result; + } + + public void setResult(CreateResponse result) { + this.result = result; + } + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public static class CreateResponse { + /** + * The order ID for the newly created cluster + */ + private String orderId; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesDeleteAutoRenewRuleRequest.java b/src/main/java/com/baidubce/services/bes/model/BesDeleteAutoRenewRuleRequest.java new file mode 100644 index 00000000..35339cb0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesDeleteAutoRenewRuleRequest.java @@ -0,0 +1,45 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +public class BesDeleteAutoRenewRuleRequest extends AbstractBesRequest { + @JsonProperty + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesDeleteAutoRenewRuleResponse.java b/src/main/java/com/baidubce/services/bes/model/BesDeleteAutoRenewRuleResponse.java new file mode 100644 index 00000000..0788d1fc --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesDeleteAutoRenewRuleResponse.java @@ -0,0 +1,51 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +public class BesDeleteAutoRenewRuleResponse extends AbstractBceResponse implements Serializable { + @JsonProperty + private Boolean success; + @JsonProperty + private int status; + @JsonProperty + private String result = " "; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesDeleteClusterRequest.java b/src/main/java/com/baidubce/services/bes/model/BesDeleteClusterRequest.java new file mode 100644 index 00000000..448be3c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesDeleteClusterRequest.java @@ -0,0 +1,49 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +/** + * @Description: The request for delete cluster + */ +public class BesDeleteClusterRequest extends AbstractBesRequest { + + @JsonProperty + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesDeleteClusterResponse.java b/src/main/java/com/baidubce/services/bes/model/BesDeleteClusterResponse.java new file mode 100644 index 00000000..ebb0687c --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesDeleteClusterResponse.java @@ -0,0 +1,56 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * @Description: The response for delete cluster + */ +public class BesDeleteClusterResponse extends AbstractBceResponse implements Serializable { + @JsonProperty + private Boolean success; + + @JsonProperty + private int status; + + @JsonProperty + private String result = " "; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesGetAutoRenewRuleListRequest.java b/src/main/java/com/baidubce/services/bes/model/BesGetAutoRenewRuleListRequest.java new file mode 100644 index 00000000..d04a681b --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesGetAutoRenewRuleListRequest.java @@ -0,0 +1,28 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class BesGetAutoRenewRuleListRequest extends AbstractBesRequest { + @JsonProperty + private String serviceType; + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesGetAutoRenewRuleListResponse.java b/src/main/java/com/baidubce/services/bes/model/BesGetAutoRenewRuleListResponse.java new file mode 100644 index 00000000..91419a57 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesGetAutoRenewRuleListResponse.java @@ -0,0 +1,135 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.util.List; + +public class BesGetAutoRenewRuleListResponse extends AbstractBceResponse implements Serializable { + private Boolean success; + private int status; + private List result; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public static class AutoRenewRulesList { + private String uuid; + private String userId; + private String clusterId; + private String region; + private String renewTimeUnit; + private Integer renewTime; + @JsonFormat( + shape = JsonFormat.Shape.STRING, + pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", + timezone = "UTC" + ) + private Timestamp createTime; + @JsonFormat( + shape = JsonFormat.Shape.STRING, + pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", + timezone = "UTC" + ) + private Timestamp updateTime; + + public String getUuid() { + return this.uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getClusterId() { + return this.clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getRegion() { + return this.region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getRenewTimeUnit() { + return this.renewTimeUnit; + } + + public void setRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + } + + public Integer getRenewTime() { + return this.renewTime; + } + + public void setRenewTime(Integer renewTime) { + this.renewTime = renewTime; + } + + public Timestamp getCreateTime() { + return this.createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public Timestamp getUpdateTime() { + return this.updateTime; + } + + public void setUpdateTime(Timestamp updateTime) { + this.updateTime = updateTime; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesGetClusterDetailRequest.java b/src/main/java/com/baidubce/services/bes/model/BesGetClusterDetailRequest.java new file mode 100644 index 00000000..e032c98f --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesGetClusterDetailRequest.java @@ -0,0 +1,49 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +/** + * @Description: Request for cluster details + */ +public class BesGetClusterDetailRequest extends AbstractBesRequest { + + @JsonProperty + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesGetClusterDetailResponse.java b/src/main/java/com/baidubce/services/bes/model/BesGetClusterDetailResponse.java new file mode 100644 index 00000000..e9076b55 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesGetClusterDetailResponse.java @@ -0,0 +1,354 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @Description: Response to query for cluster details + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BesGetClusterDetailResponse extends AbstractBceResponse implements Serializable { + @JsonProperty + private Boolean success; + @JsonProperty + private int status; + @JsonProperty + ClusterDetail result; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public ClusterDetail getResult() { + return result; + } + + public void setResult(ClusterDetail result) { + this.result = result; + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class ClusterDetail { + @JsonProperty + private String clusterId; + @JsonProperty + private String clusterName; + @JsonProperty + private String adminUsername; + @JsonProperty + private String actualStatus; + @JsonProperty + private String desireStatus; + @JsonProperty + private String esUrl; + @JsonProperty + private String kibanaUrl; + @JsonProperty + private String esEip; + @JsonProperty + private String kibanaEip; + @JsonProperty + private List modules; + @JsonProperty + private List instances; + @JsonFormat( + shape = JsonFormat.Shape.STRING, + pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", + timezone = "UTC" + ) + @JsonProperty + private Date expireTime; + @JsonProperty + private String region; + @JsonProperty + private String vpc; + @JsonProperty + private String subnet; + @JsonProperty + private String availableZone; + @JsonProperty + private String securityGroup; + @JsonProperty + private BesClusterBillingResponse billing; + + public BesClusterBillingResponse getBilling() { + return billing; + } + + public void setBilling(BesClusterBillingResponse billing) { + this.billing = billing; + } + + public Date getExpireTime() { + return expireTime; + } + + public void setExpireTime(Date expireTime) { + this.expireTime = expireTime; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public String getAdminUsername() { + return adminUsername; + } + + public void setAdminUsername(String adminUsername) { + this.adminUsername = adminUsername; + } + + public String getActualStatus() { + return actualStatus; + } + + public void setActualStatus(String actualStatus) { + this.actualStatus = actualStatus; + } + + public String getDesireStatus() { + return desireStatus; + } + + public void setDesireStatus(String desireStatus) { + this.desireStatus = desireStatus; + } + + public String getEsUrl() { + return esUrl; + } + + public void setEsUrl(String esUrl) { + this.esUrl = esUrl; + } + + public String getKibanaUrl() { + return kibanaUrl; + } + + public void setKibanaUrl(String kibanaUrl) { + this.kibanaUrl = kibanaUrl; + } + + public String getEsEip() { + return esEip; + } + + public void setEsEip(String esEip) { + this.esEip = esEip; + } + + public String getKibanaEip() { + return kibanaEip; + } + + public void setKibanaEip(String kibanaEip) { + this.kibanaEip = kibanaEip; + } + + public List getModules() { + return modules; + } + + public void setModules(List modules) { + this.modules = modules; + } + + public List getInstances() { + return instances; + } + + public void setInstances(List instances) { + this.instances = instances; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getVpc() { + return vpc; + } + + public void setVpc(String vpc) { + this.vpc = vpc; + } + + public String getSubnet() { + return subnet; + } + + public void setSubnet(String subnet) { + this.subnet = subnet; + } + + public String getAvailableZone() { + return availableZone; + } + + public void setAvailableZone(String availableZone) { + this.availableZone = availableZone; + } + + public String getSecurityGroup() { + return securityGroup; + } + + public void setSecurityGroup(String securityGroup) { + this.securityGroup = securityGroup; + } + + public static class InstanceInfoResponse { + @JsonProperty + private String instanceId; + @JsonProperty + private String status; + @JsonProperty + private String moduleType; + @JsonProperty + private String moduleVersion; + @JsonProperty + private String hostIp; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getModuleType() { + return moduleType; + } + + public void setModuleType(String moduleType) { + this.moduleType = moduleType; + } + + public String getModuleVersion() { + return moduleVersion; + } + + public void setModuleVersion(String moduleVersion) { + this.moduleVersion = moduleVersion; + } + + public String getHostIp() { + return hostIp; + } + + public void setHostIp(String hostIp) { + this.hostIp = hostIp; + } + } + + public static class ModuleInfoResponse { + @JsonProperty + private String type; + @JsonProperty + private String version; + @JsonProperty + private String slotType; + @JsonProperty + private String slotDescription; + @JsonProperty + private int actualInstanceNum; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getSlotType() { + return slotType; + } + + public void setSlotType(String slotType) { + this.slotType = slotType; + } + + public String getSlotDescription() { + return slotDescription; + } + + public void setSlotDescription(String slotDescription) { + this.slotDescription = slotDescription; + } + + public int getActualInstanceNum() { + return actualInstanceNum; + } + + public void setActualInstanceNum(int actualInstanceNum) { + this.actualInstanceNum = actualInstanceNum; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesGetClusterListRequest.java b/src/main/java/com/baidubce/services/bes/model/BesGetClusterListRequest.java new file mode 100644 index 00000000..4d55e86f --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesGetClusterListRequest.java @@ -0,0 +1,61 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +/** + * @Description: Request to view a list of clusters + */ +public class BesGetClusterListRequest extends AbstractBesRequest { + + @JsonProperty + private int pageSize; + + @JsonProperty + private int pageNo; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeNumberField("pageNo", pageNo); + jsonGenerator.writeNumberField("pageSize", pageSize); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesGetClusterListResponse.java b/src/main/java/com/baidubce/services/bes/model/BesGetClusterListResponse.java new file mode 100644 index 00000000..260d5fdb --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesGetClusterListResponse.java @@ -0,0 +1,147 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description: View the response for the cluster list + */ +public class BesGetClusterListResponse extends AbstractBceResponse implements Serializable { + private Boolean success; + private int status; + private ListPageResponse page; + + public ListPageResponse getPage() { + return page; + } + + public void setPage(ListPageResponse page) { + this.page = page; + } + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public static class ListPageResponse { + private int pageNo; + private int pageSize; + private int totalCount; + private List result; + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public static class ClusterSummaryInfo { + private String clusterId; + private String clusterName; + private String createTime; + private String actualStatus; + private String runningTime; + private BesClusterBillingResponse billing; + + public BesClusterBillingResponse getBilling() { + return billing; + } + + public void setBilling(BesClusterBillingResponse billing) { + this.billing = billing; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getActualStatus() { + return actualStatus; + } + + public void setActualStatus(String actualStatus) { + this.actualStatus = actualStatus; + } + + public String getRunningTime() { + return runningTime; + } + + public void setRunningTime(String runningTime) { + this.runningTime = runningTime; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesGetRenewListRequest.java b/src/main/java/com/baidubce/services/bes/model/BesGetRenewListRequest.java new file mode 100644 index 00000000..6d93ec78 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesGetRenewListRequest.java @@ -0,0 +1,89 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +public class BesGetRenewListRequest extends AbstractBesRequest { + @JsonProperty + private String order; + @JsonProperty + private String orderBy; + @JsonProperty + private int pageNo; + @JsonProperty + private int pageSize; + @JsonProperty + private int daysToExpiration = -1; // 最近多少天过期,<0为不限制 + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getDaysToExpiration() { + return daysToExpiration; + } + + public void setDaysToExpiration(int daysToExpiration) { + this.daysToExpiration = daysToExpiration; + } + + public String toJson() throws IOException { + StringWriter writer = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("order", order); + jsonGenerator.writeStringField("orderBy", orderBy); + jsonGenerator.writeNumberField("pageNo", pageNo); + jsonGenerator.writeNumberField("pageSize", pageSize); + jsonGenerator.writeNumberField("daysToExpiration", daysToExpiration); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return writer.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesGetRenewListResponse.java b/src/main/java/com/baidubce/services/bes/model/BesGetRenewListResponse.java new file mode 100644 index 00000000..2637baa5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesGetRenewListResponse.java @@ -0,0 +1,160 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +public class BesGetRenewListResponse extends AbstractBceResponse implements Serializable { + private Boolean success; + private int status; + private Page page; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public Page getPage() { + return page; + } + + public void setPage(Page page) { + this.page = page; + } + + public static class Page { + private String orderBy = ""; + private String order = ""; + private int pageNo; + private int pageSize; + private int totalCount; + private List result; + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public static class BesRenewListResponse { + private String clusterId; + private String clusterName; + private String region; + @JsonFormat( + shape = JsonFormat.Shape.STRING, + pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", + timezone = "UTC" + ) + private Date expiredTime; + private String clusterStatus; + + public String getClusterId() { + return this.clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterName() { + return this.clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public String getRegion() { + return this.region; + } + + public void setRegion(String region) { + this.region = region; + } + + public Date getExpiredTime() { + return this.expiredTime; + } + + public void setExpiredTime(Date expiredTime) { + this.expiredTime = expiredTime; + } + + public String getClusterStatus() { + return this.clusterStatus; + } + + public void setClusterStatus(String clusterStatus) { + this.clusterStatus = clusterStatus; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesRenewClusterRequest.java b/src/main/java/com/baidubce/services/bes/model/BesRenewClusterRequest.java new file mode 100644 index 00000000..9e44f8b6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesRenewClusterRequest.java @@ -0,0 +1,57 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +public class BesRenewClusterRequest extends AbstractBesRequest { + @JsonProperty + private int time = 0; + @JsonProperty + private String clusterId; + + public int getTime() { + return time; + } + + public void setTime(int time) { + this.time = time; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String toJson() throws IOException { + + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("serviceType", "BES"); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeNumberField("time", time); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + return stringWriter.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesRenewClusterResponse.java b/src/main/java/com/baidubce/services/bes/model/BesRenewClusterResponse.java new file mode 100644 index 00000000..85a1608b --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesRenewClusterResponse.java @@ -0,0 +1,62 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.io.Serializable; + +public class BesRenewClusterResponse extends AbstractBceResponse implements Serializable { + private Boolean success; + private int status; + private RenewClusterResponse result; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public RenewClusterResponse getResult() { + return result; + } + + public void setResult(RenewClusterResponse result) { + this.result = result; + } + + public static class RenewClusterResponse { + /** + * The order ID for the renew cluster + */ + private String orderId; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesResizeClusterRequest.java b/src/main/java/com/baidubce/services/bes/model/BesResizeClusterRequest.java new file mode 100644 index 00000000..3a327201 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesResizeClusterRequest.java @@ -0,0 +1,199 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import javax.validation.constraints.NotNull; +import java.io.IOException; +import java.io.StringWriter; +import java.util.List; + +/** + * @Description: Request to resize a cluster + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BesResizeClusterRequest extends AbstractBesRequest { + + @JsonProperty + private String name; + + @JsonProperty + private List modules; + + @NotNull + @JsonProperty + private List configs; + + @JsonProperty + private String paymentType; + + @JsonProperty + private String clusterId; + + @JsonProperty + private String region; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public List getModules() { + return modules; + } + + public void setModules(List modules) { + this.modules = modules; + } + + public List getConfigs() { + return configs; + } + + public void setConfigs(List configs) { + this.configs = configs; + } + + public String getPaymentType() { + return paymentType; + } + + public void setPaymentType(PaymentType paymentType) { + setPaymentType(paymentType.getPaymentType()); + } + + public void setPaymentType(String paymentType) { + this.paymentType = paymentType; + } + + public static class ModuleDesc { + + @JsonProperty + private String type; + + @JsonProperty + private String version; + + @JsonProperty("slot_type") + private String slotType; + + @JsonProperty + private int desireInstanceNum; + + @JsonProperty + private DiskSlotInfo diskSlotInfo; + + public DiskSlotInfo getDiskSlotInfo() { + return diskSlotInfo; + } + + public void setDiskSlotInfo(DiskSlotInfo diskSlotInfo) { + this.diskSlotInfo = diskSlotInfo; + } + + public String getType() { + return type; + } + + public void setType(ModuleType type) { + setType(type.getModuleType()); + } + + public void setType(String type) { + this.type = type; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getSlotType() { + return slotType; + } + + public void setSlotType(SlotType slotType) { + setSlotType(slotType.getSlotType()); + } + + public void setSlotType(String slotType) { + this.slotType = slotType; + } + + public int getDesireInstanceNum() { + return desireInstanceNum; + } + + public void setDesireInstanceNum(int desireInstanceNum) { + this.desireInstanceNum = desireInstanceNum; + } + } + + public String toJson(String region) throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeStringField("name", name); + jsonGenerator.writeStringField("region", region); + jsonGenerator.writeStringField("paymentType", paymentType); + jsonGenerator.writeArrayFieldStart("modules"); + for (BesResizeClusterRequest.ModuleDesc module : modules) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("slotType", module.getSlotType()); + jsonGenerator.writeNumberField("desireInstanceNum", module.getDesireInstanceNum()); + jsonGenerator.writeStringField("version", module.getVersion()); + jsonGenerator.writeStringField("type", module.getType()); + if (module.getDiskSlotInfo() != null) { + jsonGenerator.writeObjectFieldStart("diskSlotInfo"); + jsonGenerator.writeStringField("type", module.getDiskSlotInfo().getType()); + jsonGenerator.writeNumberField("size", module.getDiskSlotInfo().getSize()); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesStartClusterRequest.java b/src/main/java/com/baidubce/services/bes/model/BesStartClusterRequest.java new file mode 100644 index 00000000..db082faf --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesStartClusterRequest.java @@ -0,0 +1,49 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +/** + * @Description: Request to start a cluster + */ +public class BesStartClusterRequest extends AbstractBesRequest { + + @JsonProperty + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesStartClusterResponse.java b/src/main/java/com/baidubce/services/bes/model/BesStartClusterResponse.java new file mode 100644 index 00000000..d90b4142 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesStartClusterResponse.java @@ -0,0 +1,56 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * @Description: Start the cluster response + */ +public class BesStartClusterResponse extends AbstractBceResponse implements Serializable { + @JsonProperty + private Boolean success; + + @JsonProperty + private int status; + + @JsonProperty + private String result = " "; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesStartInstanceRequest.java b/src/main/java/com/baidubce/services/bes/model/BesStartInstanceRequest.java new file mode 100644 index 00000000..ae462fca --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesStartInstanceRequest.java @@ -0,0 +1,57 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +/** + * @Description: Request to start a node in a cluster + */ +public class BesStartInstanceRequest extends AbstractBesRequest { + + @JsonProperty + private String instanceId; + + @JsonProperty + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getInstanceId() { return instanceId; } + + public void setInstanceId(String instanceId) { this.instanceId = instanceId; } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("instanceId", instanceId); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesStartInstanceResponse.java b/src/main/java/com/baidubce/services/bes/model/BesStartInstanceResponse.java new file mode 100644 index 00000000..f5a2b0c4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesStartInstanceResponse.java @@ -0,0 +1,57 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * @Description: Start the response of nodes in a cluster + */ +public class BesStartInstanceResponse extends AbstractBceResponse implements Serializable { + + @JsonProperty + private Boolean success; + + @JsonProperty + private int status; + + @JsonProperty + private String result = " "; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesStopClusterRequest.java b/src/main/java/com/baidubce/services/bes/model/BesStopClusterRequest.java new file mode 100644 index 00000000..01d740b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesStopClusterRequest.java @@ -0,0 +1,49 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +/** + * @Description: Request to stop a cluster + */ +public class BesStopClusterRequest extends AbstractBesRequest { + + @JsonProperty + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesStopClusterResponse.java b/src/main/java/com/baidubce/services/bes/model/BesStopClusterResponse.java new file mode 100644 index 00000000..b333c816 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesStopClusterResponse.java @@ -0,0 +1,56 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * @Description: Stop the cluster response + */ +public class BesStopClusterResponse extends AbstractBceResponse implements Serializable { + @JsonProperty + private Boolean success; + + @JsonProperty + private int status; + + @JsonProperty + private String result = " "; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesStopInstanceRequest.java b/src/main/java/com/baidubce/services/bes/model/BesStopInstanceRequest.java new file mode 100644 index 00000000..37dced7a --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesStopInstanceRequest.java @@ -0,0 +1,57 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +/** + * @Description: Request to stop a node in a cluster + */ +public class BesStopInstanceRequest extends AbstractBesRequest { + + @JsonProperty + private String instanceId; + + @JsonProperty + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getInstanceId() { return instanceId; } + + public void setInstanceId(String instanceId) { this.instanceId = instanceId; } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("instanceId", instanceId); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesStopInstanceResponse.java b/src/main/java/com/baidubce/services/bes/model/BesStopInstanceResponse.java new file mode 100644 index 00000000..55a0a6d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesStopInstanceResponse.java @@ -0,0 +1,57 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * @Description: Stops the response of nodes in a cluster + */ +public class BesStopInstanceResponse extends AbstractBceResponse implements Serializable { + + @JsonProperty + private Boolean success; + + @JsonProperty + private int status; + + @JsonProperty + private String result = " "; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/BesUpdateAutoRenewRuleRequest.java b/src/main/java/com/baidubce/services/bes/model/BesUpdateAutoRenewRuleRequest.java new file mode 100644 index 00000000..a6886c0e --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesUpdateAutoRenewRuleRequest.java @@ -0,0 +1,68 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; + +public class BesUpdateAutoRenewRuleRequest extends AbstractBesRequest { + @JsonProperty + private String clusterId; + @JsonProperty + private String renewTimeUnit; + @JsonProperty + private int renewTime; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getRenewTimeUnit() { + return renewTimeUnit; + } + + public void setRenewTimeUnit(String renewTimeUnit) { + this.renewTimeUnit = renewTimeUnit; + } + + public int getRenewTime() { + return renewTime; + } + + public void setRenewTime(int renewTime) { + this.renewTime = renewTime; + } + + public String toJson() throws IOException { + StringWriter stringWriter = new StringWriter(); + + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(stringWriter); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("clusterId", clusterId); + jsonGenerator.writeStringField("renewTimeUnit", renewTimeUnit); + jsonGenerator.writeNumberField("renewTime", renewTime); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + + return stringWriter.toString(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/BesUpdateAutoRenewRuleResponse.java b/src/main/java/com/baidubce/services/bes/model/BesUpdateAutoRenewRuleResponse.java new file mode 100644 index 00000000..ed1f320a --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/BesUpdateAutoRenewRuleResponse.java @@ -0,0 +1,51 @@ +/** + * Copyright 2020 Baidu, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +public class BesUpdateAutoRenewRuleResponse extends AbstractBceResponse implements Serializable { + @JsonProperty + private Boolean success; + @JsonProperty + private int status; + @JsonProperty + private String result = " "; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bes/model/DiskSlotInfo.java b/src/main/java/com/baidubce/services/bes/model/DiskSlotInfo.java new file mode 100644 index 00000000..272020d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/DiskSlotInfo.java @@ -0,0 +1,43 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class DiskSlotInfo { + @JsonProperty + private String type; + @JsonProperty + private int size; + + public String getType() { + return type; + } + + public void setType(DiskType type) { + setType(type.getDiskType()); + } + + public void setType(String type) { + this.type = type; + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + +} diff --git a/src/main/java/com/baidubce/services/bes/model/DiskType.java b/src/main/java/com/baidubce/services/bes/model/DiskType.java new file mode 100644 index 00000000..26d84860 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/DiskType.java @@ -0,0 +1,27 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +public enum DiskType { + SSD("ssd"), PREMIUM_SSD("premium_ssd"); + + private String diskType; + + DiskType(String diskType) { + this.diskType = diskType; + } + + public String getDiskType() { + return diskType; + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/ModuleType.java b/src/main/java/com/baidubce/services/bes/model/ModuleType.java new file mode 100644 index 00000000..958e14e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/ModuleType.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bes.model; + +public enum ModuleType { + ES_NODE("es_node"), + KIBANA("kibana"), + ES_DEDICATED_MASTER("es_dedicated_master"); + + private String moduleType; + + ModuleType(String moduleType) { + this.moduleType = moduleType; + } + + public String getModuleType() { + return moduleType; + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/PaymentType.java b/src/main/java/com/baidubce/services/bes/model/PaymentType.java new file mode 100644 index 00000000..fe77a69f --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/PaymentType.java @@ -0,0 +1,27 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +public enum PaymentType { + POSTPAY("postpay"), PREPAY("prepay"); + + private String paymentType; + + PaymentType(String paymentType) { + this.paymentType = paymentType; + } + + public String getPaymentType() { + return paymentType; + } +} diff --git a/src/main/java/com/baidubce/services/bes/model/SlotType.java b/src/main/java/com/baidubce/services/bes/model/SlotType.java new file mode 100644 index 00000000..c4fa6f16 --- /dev/null +++ b/src/main/java/com/baidubce/services/bes/model/SlotType.java @@ -0,0 +1,71 @@ +/** + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bes.model; + +public enum SlotType { + // 老套餐 + CALCULATE_V1("calculate_v1"), // CPU 4核, 内存 32G, SSD 云磁盘100G + CALCULATE_V2("calculate_v2"), // CPU 16核, 内存 64G, SSD 云磁盘200G + CALCULATE_V3("calculate_v3"), // CPU 32核, 内存 128G, SSD 云磁盘500G + STORAGE_V1("storage_v1"), // CPU 4核, 内存 16G, SSD 云磁盘500G + STORAGE_V2("storage_v2"), // CPU 8核, 内存 32G, SSD 云磁盘1024G + STORAGE_V3("storage_v3"), // CPU 16核, 内存 64G, SSD 云磁盘2048G + + // 新套餐(es_node) + // 通用型 + BES_G3_CPU_2_MEM_8("bes.g3.c2m8"), // CPU 2核, 内存 8G + BES_G3_CPU_4_MEM_16("bes.g3.c4m16"), // CPU 4核, 内存 16G + BES_G3_CPU_8_MEM_32("bes.g3.c8m32"), // CPU 8核, 内存 32G + BES_G3_CPU_16_MEM_64("bes.g3.c16m64"), // CPU 16核, 内存 64G + BES_G3_CPU_32_MEM_128("bes.g3.c32m128"), // CPU 32核, 内存 128G + + // 计算型 + BES_C3_CPU_2_MEM_4("bes.c3.c2m4"), // CPU 2核, 内存 4G + BES_C3_CPU_4_MEM_8("bes.c3.c4m8"), // CPU 4核, 内存 8G + BES_C3_CPU_8_MEM_16("bes.c3.c8m16"), // CPU 8核, 内存 16G + BES_C3_CPU_16_MEM_32("bes.c3.c16m32"), // CPU 16核, 内存 32G + BES_C3_CPU_32_MEM_64("bes.c3.c32m64"), // CPU 32核, 内存 64G + + // 密集计算型 + BES_IC3_CPU_4_MEM_4("bes.ic3.c4m4"), // CPU 4核, 内存 4G + BES_IC3_CPU_8_MEM_8("bes.ic3.c8m8"), // CPU 8核, 内存 8G + BES_IC3_CPU_12_MEM_12("bes.ic3.c12m12"), // CPU 12核, 内存 12G + BES_IC3_CPU_16_MEM_16("bes.ic3.c16m16"), // CPU 16核, 内存 16G + + // 内存型 + BES_M3_CPU_2_MEM_16("bes.m3.c2m16"), // CPU 2核, 内存 16G + BES_M3_CPU_4_MEM_32("bes.m3.c4m32"), // CPU 4核, 内存 32G + BES_M3_CPU_8_MEM_64("bes.m3.c8m64"), // CPU 8核, 内存 64G + + // 新套餐(kibana) + // 通用型 + KIBANA_G3_CPU_2_MEM_8("bes.g3.c2m8"), // CPU 2核, 内存 8G + KIBANA_G3_CPU_4_MEM_16("bes.g3.c4m16"), // CPU 4核, 内存 16G + KIBANA_G3_CPU_8_MEM_32("bes.g3.c8m32"), // CPU 8核, 内存 32G + + // 计算型 + KIBANA_C3_CPU_1_MEM_2("bes.c3.c1m2"), // CPU 1核, 内存 2G (免费套餐) + KIBANA_C3_CPU_2_MEM_4("bes.c3.c2m4"), // CPU 2核, 内存 4G + KIBANA_C3_CPU_4_MEM_8("bes.c3.c4m8"), // CPU 4核, 内存 8G + KIBANA_C3_CPU_8_MEM_16("bes.c3.c8m16"); // CPU 8核, 内存 16G + + private String slotType; + + SlotType(String slotType) { + this.slotType = slotType; + } + + public String getSlotType() { + return slotType; + } +} diff --git a/src/main/java/com/baidubce/services/billing/BillingClient.java b/src/main/java/com/baidubce/services/billing/BillingClient.java new file mode 100644 index 00000000..71812bfc --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/BillingClient.java @@ -0,0 +1,665 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing; + +import static com.baidubce.util.Validate.checkIsTrue; +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.billing.model.ResourceMonthBillRequest; +import com.baidubce.services.billing.model.ResourceMonthBillResponse; +import com.baidubce.services.billing.model.bill.CostSplitBillRequest; +import com.baidubce.services.billing.model.bill.CostSplitBillResponse; +import com.baidubce.services.billing.model.bill.PrepayShareBillRequest; +import com.baidubce.services.billing.model.bill.PrepayShareBillResponse; +import com.baidubce.services.billing.model.bill.ProductMonthBillSummaryRequest; +import com.baidubce.services.billing.model.bill.ProductMonthBillSummaryResponse; +import com.baidubce.services.billing.model.bill.ResourceBillListQueryRequest; +import com.baidubce.services.billing.model.bill.ResourceBillListQueryResponse; +import com.baidubce.services.billing.model.bill.ShareBillRequest; +import com.baidubce.services.billing.model.bill.ShareBillResponse; +import com.baidubce.services.billing.model.finance.SupervisorBalanceQueryRequest; +import com.baidubce.services.billing.model.finance.SupervisorBalanceResponse; +import com.baidubce.services.billing.model.finance.SupervisorBalanceTransferRequest; +import com.baidubce.services.billing.model.finance.SupervisorTransactionPageRequest; +import com.baidubce.services.billing.model.finance.SupervisorTransactionResponse; +import com.baidubce.services.billing.model.finance.TransferResultResponse; +import com.baidubce.services.billing.model.finance.UserBalanceQueryRequest; +import com.baidubce.services.billing.model.finance.UserBalanceQueryResponse; +import com.baidubce.services.billing.model.order.OrderCancelRequest; +import com.baidubce.services.billing.model.order.OrderCancelResponse; +import com.baidubce.services.billing.model.order.OrderListRequest; +import com.baidubce.services.billing.model.order.OrderListResponse; +import com.baidubce.services.billing.model.order.OrderPaymentRequest; +import com.baidubce.services.billing.model.order.OrderPaymentResponse; +import com.baidubce.services.billing.model.order.OrderUuidQueryRequest; +import com.baidubce.services.billing.model.price.CpcPricingRequest; +import com.baidubce.services.billing.model.price.CptPricingRequest; +import com.baidubce.services.billing.model.price.PricingQueryResponse; +import com.baidubce.services.billing.model.renew.RenewResourceDetailRequest; +import com.baidubce.services.billing.model.renew.RenewResourceDetailResponse; +import com.baidubce.services.billing.model.renew.RenewResourceListRequest; +import com.baidubce.services.billing.model.renew.RenewResourceResponse; +import com.baidubce.services.billing.model.renew.ResourceAutoRenewRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +/** + * Provides the client for accessing the Baidu Billing Service(billing). + */ +public class BillingClient extends AbstractBceClient { + private static final Logger LOGGER = LoggerFactory.getLogger(BillingClient.class); + + private static final String VERSION_V1 = "v1"; + private static final String BILL = "bill"; + private static final String RESOURCE = "resource"; + private static final String RENEW = "renew"; + private static final String MONTH = "month"; + private static final String SHARE_PREPAY = "share/prepay"; + private static final String SHARE_BILL = "share/bill"; + private static final String MONTH_SUMMARY = "month/summary"; + private static final String COST_SPLIT_BILL = "/cost/split/bill/list"; + private static final String QUERY_RENEW = "query/renew"; + private static final String PRICE = "price"; + private static final String CPC = "cpc"; + private static final String CPT = "cpt"; + private static final String ORDER = "order"; + private static final String CANCEL = "cancel"; + private static final String PAY = "pay"; + private static final String LIST = "list"; + private static final String GET_BY_UUID = "getByUuid"; + + private static final String FINANCE = "finance"; + private static final String SUPERVISOR = "supervisor"; + private static final String BALANCE = "balance"; + private static final String TRANSFER = "transfer"; + private static final String GATHER = "gather"; + private static final String CASH = "cash"; + private static final String TRANSACTION = "transaction"; + + /** + * Responsible for handling httpResponses from all billing service calls. + */ + private static HttpResponseHandler[] billingHandlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on billing with default configuration. + */ + public BillingClient() { + this(new BillingClientConfiguration()); + } + + /** + * Constructs a new client to invoke service methods on billing default configuration. + */ + public BillingClient(BceClientConfiguration config) { + super(config, billingHandlers); + } + + /** + * Query the detail resource month bills. + * Set the parameter queryAccountId if want to query the sub account's bills whole is in finance circle. + * + * @param request The request containing all options for getting the bills info. + * @return detailed resource month bill list. + */ + public ResourceMonthBillResponse getResourceMonthBill(ResourceMonthBillRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkIsTrue(!StringUtils.isEmpty(request.getBeginTime()) || !StringUtils.isEmpty(request.getEndTime()) + || !StringUtils.isEmpty(request.getMonth()), + "Parameters month , beginTime and endTime cannot all be empty!"); + checkIsTrue(!(StringUtils.isEmpty(request.getBeginTime()) && !StringUtils.isEmpty(request.getEndTime())), + "If parameter endTime is not empty, parameter beginTime cannot be empty!"); + checkIsTrue(!(!StringUtils.isEmpty(request.getBeginTime()) && StringUtils.isEmpty(request.getEndTime())), + "If parameter beginTime is not empty, parameter endTime cannot be empty!"); + checkStringNotEmpty(request.getProductType(), "The parameter productType should NOT be null"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VERSION_V1, BILL, RESOURCE, + MONTH); + if (request.getMonth() != null) { + internalRequest.addParameter(MONTH, request.getMonth()); + } + if (request.getBeginTime() != null) { + internalRequest.addParameter("beginTime", request.getBeginTime()); + } + if (request.getEndTime() != null) { + internalRequest.addParameter("endTime", request.getEndTime()); + } + internalRequest.addParameter("productType", request.getProductType()); + + if (request.getServiceType() != null) { + internalRequest.addParameter("serviceType", request.getServiceType()); + } + if (request.getQueryAccountId() != null) { + internalRequest.addParameter("queryAccountId", request.getQueryAccountId()); + } + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + + return invokeHttpClient(internalRequest, ResourceMonthBillResponse.class); + } + + /** + * Query the detail prepay share bills. + * Set the parameter queryAccountId if want to query the sub account's bills whole is in finance circle. + * + * @param request The request containing all options for getting the bills info. + * @return detailed prepay share bill list. + */ + public PrepayShareBillResponse queryPrepayShareBill(PrepayShareBillRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkIsTrue(!StringUtils.isEmpty(request.getMonth()), "The parameter month cannot be empty!"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VERSION_V1, BILL, SHARE_PREPAY); + if (request.getMonth() != null) { + internalRequest.addParameter(MONTH, request.getMonth()); + } + if (request.getServiceType() != null) { + internalRequest.addParameter("serviceType", request.getServiceType()); + } + if (request.getQueryAccountId() != null) { + internalRequest.addParameter("queryAccountId", request.getQueryAccountId()); + } + if (request.getShowDeductPrice() != null) { + internalRequest.addParameter("showDeductPrice", String.valueOf(request.getShowDeductPrice())); + } + if (request.getShowControversial() != null) { + internalRequest.addParameter("showControversial", String.valueOf(request.getShowControversial())); + } + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + + return invokeHttpClient(internalRequest, PrepayShareBillResponse.class); + } + + /** + * Query the detail share bills. containing prepay/postpay. + * Set the parameter queryAccountId if want to query the sub account's bills whole is in finance circle. + * + * @param request The request containing all options for getting the bills info. + * @return detailed share bill list. + */ + public ShareBillResponse queryShareBill(ShareBillRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkIsTrue(!StringUtils.isEmpty(request.getStartDay()) || !StringUtils.isEmpty(request.getEndDay()) + || !StringUtils.isEmpty(request.getMonth()), + "Parameters month, startDay and endDay cannot all be empty!"); + checkIsTrue(!(StringUtils.isEmpty(request.getStartDay()) && !StringUtils.isEmpty(request.getEndDay())), + "If parameter endDay is not empty, parameter startDay cannot be empty!"); + checkIsTrue(!(!StringUtils.isEmpty(request.getStartDay()) && StringUtils.isEmpty(request.getEndDay())), + "If parameter startDay is not empty, parameter endDay cannot be empty!"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VERSION_V1, BILL, SHARE_BILL); + if (request.getMonth() != null) { + internalRequest.addParameter(MONTH, request.getMonth()); + } + if (request.getStartDay() != null) { + internalRequest.addParameter("startDay", request.getStartDay()); + } + if (request.getEndDay() != null) { + internalRequest.addParameter("endDay", request.getEndDay()); + } + if (request.getProductType() != null) { + internalRequest.addParameter("productType", request.getProductType()); + } + if (request.getServiceType() != null) { + internalRequest.addParameter("serviceType", request.getServiceType()); + } + if (request.getQueryAccountId() != null) { + internalRequest.addParameter("queryAccountId", request.getQueryAccountId()); + } + if (request.getShowDeductPrice() != null) { + internalRequest.addParameter("showDeductPrice", String.valueOf(request.getShowDeductPrice())); + } + if (request.getShowControversial() != null) { + internalRequest.addParameter("showControversial", String.valueOf(request.getShowControversial())); + } + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + return invokeHttpClient(internalRequest, ShareBillResponse.class); + } + + /** + * Query the product month bill summary. + * + * @param request The request containing all options for getting the bills info. + * @return detailed product month bill list. + */ + public ProductMonthBillSummaryResponse queryProductMonthBillSummary(ProductMonthBillSummaryRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkIsTrue(!StringUtils.isEmpty(request.getBillMonth()), "The parameter billMonth cannot be empty!"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, VERSION_V1, BILL, MONTH_SUMMARY); + + internalRequest.addParameter("billMonth", request.getBillMonth()); + + if (request.getProductType() != null) { + internalRequest.addParameter("productType", request.getProductType()); + } + if (request.getServiceType() != null) { + internalRequest.addParameter("serviceType", request.getServiceType()); + } + if (request.getQueryAccountId() != null) { + internalRequest.addParameter("queryAccountId", request.getQueryAccountId()); + } + return invokeHttpClient(internalRequest, ProductMonthBillSummaryResponse.class); + } + + /** + * 成本拆分账单查询 + * + * @param request 成本拆分账单查询参数 + * @return 成本拆分账单详情 + */ + public CostSplitBillResponse queryCostSplitBill(CostSplitBillRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + InternalRequest internalRequest = + createRequest(request, HttpMethodName.GET, VERSION_V1, BILL, COST_SPLIT_BILL); + + if (request.getMonth() != null) { + internalRequest.addParameter("month", request.getMonth()); + } + if (request.getStartDay() != null) { + internalRequest.addParameter("startDay", request.getStartDay()); + } + if (request.getEndDay() != null) { + internalRequest.addParameter("endDay", request.getEndDay()); + } + if (request.getServiceType() != null) { + internalRequest.addParameter("serviceType", request.getServiceType()); + } + if (request.getQueryAccountId() != null) { + internalRequest.addParameter("queryAccountId", request.getQueryAccountId()); + } + if (request.getInstanceId() != null) { + internalRequest.addParameter("instanceId", request.getInstanceId()); + } + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + return invokeHttpClient(internalRequest, CostSplitBillResponse.class); + } + + /** + * Query the resource bill list + * + * @param request The request containing all options for getting the resource info. + * @return detailed resource bill list. + */ + public ResourceBillListQueryResponse getResourceBillList(ResourceBillListQueryRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkIsTrue(!StringUtils.isEmpty(request.getBeginTime()) || !StringUtils.isEmpty(request.getEndTime()) + || !StringUtils.isEmpty(request.getBillMonth()), + "Parameters billMonth , beginTime and endTime cannot all be empty!"); + checkIsTrue(!(StringUtils.isEmpty(request.getBeginTime()) && !StringUtils.isEmpty(request.getEndTime())), + "If parameter endTime is not empty, parameter beginTime cannot be empty!"); + checkIsTrue(!(!StringUtils.isEmpty(request.getBeginTime()) && StringUtils.isEmpty(request.getEndTime())), + "If parameter beginTime is not empty, parameter endTime cannot be empty!"); + checkStringNotEmpty(request.getProductType(), "The parameter productType should NOT be null"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, BILL, RESOURCE, LIST); + + return invokeHttpClient(internalRequest, ResourceBillListQueryResponse.class); + + } + + /** + * Query the order list + * + * @param request The request containing all options for getting the order info. + * @return detailed order information list. + */ + public OrderListResponse getOrderList(OrderListRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, ORDER, LIST); + + return invokeHttpClient(internalRequest, OrderListResponse.class); + } + + /** + * Get order list with uuid + * @param request request of order query with uuid list + * @return detailed order information list. + */ + public OrderListResponse getOrdersByUuid(OrderUuidQueryRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, ORDER, GET_BY_UUID); + + return invokeHttpClient(internalRequest, OrderListResponse.class); + } + + /** + * Cancel the order list. + * + * @param request The request containing all options for cancel orders. + * @return whether the order is cancelled successfully. + */ + public OrderCancelResponse cancelOrders(OrderCancelRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkNotNull(request.getOrderIds(), "The parameter orderIds should NOT be null."); + checkIsTrue(request.getOrderIds().size() > 0, "The parameter orderIds should NOT be empty."); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, ORDER, CANCEL); + + return invokeHttpClient(internalRequest, OrderCancelResponse.class); + } + + /** + * Pay the order. + * + * @param request The request containing all options for the order payment. + * @return whether the order is payment successfully. + */ + public OrderPaymentResponse payOrder(OrderPaymentRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getOrderId(), "The parameter orderId should NOT be empty."); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, ORDER, PAY); + + return invokeHttpClient(internalRequest, OrderPaymentResponse.class); + } + + /** + * Query the detail price of charge items + * + * @param request The request containing all options for getting the price info. + * @return detail price. + */ + public PricingQueryResponse getSpecificCpcPrice(CpcPricingRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getServiceType(), "The parameter serviceType should NOT be null"); + checkStringNotEmpty(request.getProductType(), "The parameter productType should NOT be null"); + checkStringNotEmpty(request.getRegion(), "The parameter region should NOT be null"); + checkNotNull(request.getFlavor(), "The parameter flavor should NOT be null"); + checkNotNull(request.getFlavor().getChargeItems(), "The parameter chargeItems should NOT be null"); + checkIsTrue(request.getFlavor().getChargeItems().size() > 0, "The parameter chargeItems should NOT be empty!"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, PRICE, CPC); + + return invokeHttpClient(internalRequest, PricingQueryResponse.class); + } + + /** + * Query the detail price of charge items + * + * @param request The request containing all options for getting the price info. + * @return detail price. + */ + public PricingQueryResponse getSpecificCptPrice(CptPricingRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getServiceType(), "The parameter serviceType should NOT be null"); + checkStringNotEmpty(request.getProductType(), "The parameter productType should NOT be null"); + checkStringNotEmpty(request.getRegion(), "The parameter region should NOT be null"); + checkNotNull(request.getFlavor(), "The parameter flavor should NOT be null"); + checkNotNull(request.getFlavor().getChargeItems(), "The parameter chargeItems should NOT be null"); + checkIsTrue(request.getFlavor().getChargeItems().size() > 0, "The parameter chargeItems should NOT be empty!"); + checkNotNull(request.getPeriod(), "The parameter period should NOT be null."); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, PRICE, CPT); + + return invokeHttpClient(internalRequest, PricingQueryResponse.class); + } + + /** + * Query auto renew resource list + * Set the parameter queryAccountId if want to query the sub account's bills whole is in finance circle. + * + * @param request The request containing all options for getting the resource list info. + * @return detailed prepay resource list + */ + public RenewResourceResponse queryRenewResourceList(RenewResourceListRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkIsTrue(!StringUtils.isEmpty(request.getServiceType()), "The parameter serviceType cannot be empty!"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, RENEW, + "/resource/list"); + + return invokeHttpClient(internalRequest, RenewResourceResponse.class); + } + + /** + * Query renew resource list by expire time + * Set the parameter queryAccountId if want to query the sub account's bills whole is in finance circle. + * + * @param request The request containing all options for getting the resource list info. + * @return detailed renew resource list + */ + public RenewResourceDetailResponse queryRenewResourceListV2(RenewResourceDetailRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getServiceType(), "The parameter serviceType should NOT be null"); + checkStringNotEmpty(request.getRegion(), "The parameter region should NOT be null"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, RESOURCE, + QUERY_RENEW); + + return invokeHttpClient(internalRequest, RenewResourceDetailResponse.class); + } + + /** + * SET auto renew resource rule + * Set the parameter accountId if want to manage the sub account's resource who is in finance circle. + * + * @param request The request containing all options for set the resource list renew rule. + */ + public void setRenewResourceRule(ResourceAutoRenewRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getServiceType(), "The parameter serviceType should NOT be null"); + checkStringNotEmpty(request.getRegion(), "The parameter region should NOT be null"); + checkStringNotEmpty(request.getInstanceId(), "The parameter instanceId should NOT be null"); + checkNotNull(request.getRenewTime(), "The parameter renewTime should NOT be null."); + checkNotNull(request.getRenewTimeUnit(), "The parameter renewTimeUnit should NOT be null."); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, RENEW, + "/resource/rule/create"); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * do balance transfer form supervisor to supervised account + * + * @param request request contain supervisedId and amount + * @return transfer result + */ + public TransferResultResponse balanceTransfer(SupervisorBalanceTransferRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getSupervisedId(), "The parameter supervisedId should NOT be null"); + checkNotNull(request.getAmount(), "The parameter amount should NOT be null"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, FINANCE, SUPERVISOR, + BALANCE, TRANSFER); + return invokeHttpClient(internalRequest, TransferResultResponse.class); + } + + /** + * do balance gather form supervised account to supervisor + * + * @param request request contain supervisedId and amount + * @return gather result + */ + public TransferResultResponse balanceGather(SupervisorBalanceTransferRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getSupervisedId(), "The parameter supervisedId should NOT be null"); + checkNotNull(request.getAmount(), "The parameter amount should NOT be null"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, FINANCE, SUPERVISOR, + BALANCE, GATHER); + return invokeHttpClient(internalRequest, TransferResultResponse.class); + } + + /** + * get the transfer record + * + * @param request request contain time and page param + * @return page result + */ + public SupervisorTransactionResponse transactionList(SupervisorTransactionPageRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getBeginTime(), "The parameter beginTime should NOT be null"); + checkStringNotEmpty(request.getEndTime(), "The parameter endTime should NOT be null"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, FINANCE, SUPERVISOR, + CASH, TRANSACTION); + return invokeHttpClient(internalRequest, SupervisorTransactionResponse.class); + } + + /** + * get balance info + * + * @param request request contain accountIds param + * @return balance result + */ + public SupervisorBalanceResponse balanceQuery(SupervisorBalanceQueryRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkNotNull(request.getAccountIds(), "The parameter accountIds should NOT be null"); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, VERSION_V1, FINANCE, SUPERVISOR, + CASH, BALANCE); + return invokeHttpClient(internalRequest, SupervisorBalanceResponse.class); + } + + /** + * get user balance info + * + * @return user balance result + */ + public UserBalanceQueryResponse userBalanceQuery() { + InternalRequest internalRequest = createRequest(new UserBalanceQueryRequest(), HttpMethodName.POST, VERSION_V1, + FINANCE, CASH, BALANCE); + return invokeHttpClient(internalRequest, UserBalanceQueryResponse.class); + } + + /** + * Creates and initializes a new request object for the specified billing resource. This method is responsible + * for determining HTTP method, URI path,credentials and request body for POST method. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); // build URL paths + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + + // get a InternalRequest instance and set headers + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillRequestPayload(request, bceRequest); + } + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillRequestPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/billing/BillingClientConfiguration.java b/src/main/java/com/baidubce/services/billing/BillingClientConfiguration.java new file mode 100644 index 00000000..5f173bac --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/BillingClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for billing service. + */ +public class BillingClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/billing/example/BillingExample.java b/src/main/java/com/baidubce/services/billing/example/BillingExample.java new file mode 100644 index 00000000..898398c2 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/example/BillingExample.java @@ -0,0 +1,483 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.example; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.billing.BillingClient; +import com.baidubce.services.billing.BillingClientConfiguration; +import com.baidubce.services.billing.model.ResourceMonthBillRequest; +import com.baidubce.services.billing.model.ResourceMonthBillResponse; +import com.baidubce.services.billing.model.bill.CostSplitBillRequest; +import com.baidubce.services.billing.model.bill.CostSplitBillResponse; +import com.baidubce.services.billing.model.bill.PrepayShareBillRequest; +import com.baidubce.services.billing.model.bill.PrepayShareBillResponse; +import com.baidubce.services.billing.model.bill.ProductMonthBillSummaryRequest; +import com.baidubce.services.billing.model.bill.ProductMonthBillSummaryResponse; +import com.baidubce.services.billing.model.bill.ResourceBillListQueryRequest; +import com.baidubce.services.billing.model.bill.ResourceBillListQueryResponse; +import com.baidubce.services.billing.model.bill.ShareBillRequest; +import com.baidubce.services.billing.model.bill.ShareBillResponse; +import com.baidubce.services.billing.model.finance.SupervisorBalanceQueryRequest; +import com.baidubce.services.billing.model.finance.SupervisorBalanceResponse; +import com.baidubce.services.billing.model.finance.SupervisorBalanceTransferRequest; +import com.baidubce.services.billing.model.finance.SupervisorTransactionPageRequest; +import com.baidubce.services.billing.model.finance.SupervisorTransactionResponse; +import com.baidubce.services.billing.model.finance.TransferResultResponse; +import com.baidubce.services.billing.model.finance.UserBalanceQueryResponse; +import com.baidubce.services.billing.model.order.OrderCancelRequest; +import com.baidubce.services.billing.model.order.OrderCancelResponse; +import com.baidubce.services.billing.model.order.OrderListRequest; +import com.baidubce.services.billing.model.order.OrderListResponse; +import com.baidubce.services.billing.model.order.OrderPaymentRequest; +import com.baidubce.services.billing.model.order.OrderPaymentResponse; +import com.baidubce.services.billing.model.order.OrderUuidQueryRequest; +import com.baidubce.services.billing.model.price.ChargeItem; +import com.baidubce.services.billing.model.price.CpcPricingRequest; +import com.baidubce.services.billing.model.price.CptPricingRequest; +import com.baidubce.services.billing.model.price.Flavor; +import com.baidubce.services.billing.model.price.PricingQueryResponse; +import com.baidubce.services.billing.model.renew.RenewResourceListRequest; +import com.baidubce.services.billing.model.renew.RenewResourceResponse; +import com.baidubce.services.billing.model.renew.ResourceAutoRenewRequest; +import com.baidubce.util.JsonUtils; +import com.google.common.collect.Lists; + +/** + * examples for billing open api + */ +public class BillingExample { + + private static final String ACCESS_KEY_ID = "ak "; + private static final String SECRET_ACCESS_KEY = "sk "; + private static final String ENDPOINT = "https://billing endpoint"; + private static final String TEST_ACCOUNT_ID = "test id"; + + public static void main(String[] args) { + sampleForQueryResourceBillList(); + sampleForQueryRenewResourceList(); + // sampleForSetRenewResourceRule(); + sampleForQueryPrepayShareBill(); + sampleForQueryShareBill(); + sampleForQueryCostSplitBill(); + sampleForQueryProductMonthBillSummary(); + sampleForGetResourceMonthBills(); + sampleForQueryOrderList(); + sampleForGetOrderWithUuid(); + sampleForCancelOrders(); + sampleForPayOrder(); + sampleForgetSpecificCptPrice(); + sampleForgetSpecificCpcPrice(); + sampleForCashBalanceQuery(); + sampleForUserBalanceQuery(); + } + + private static void sampleForQueryRenewResourceList() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + RenewResourceListRequest request = new RenewResourceListRequest(); + request.setServiceType("CDS"); + request.setPageNo(1); + request.setPageSize(50); + + RenewResourceResponse response = client.queryRenewResourceList(request); + + System.out.println("=================================="); + System.out.println("sampleForQueryRenewResourceList RenewResourceResponse result:"); + System.out.println(" accountId: " + response.getAccountId()); + System.out.println(" loginName: " + response.getLoginName()); + System.out.println(" size: " + response.getTotalCount()); + System.out.println(" resources: " + response.getResources()); + System.out.println("=================================="); + } + + private static void sampleForSetRenewResourceRule() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + ResourceAutoRenewRequest request = new ResourceAutoRenewRequest(); + request.setServiceType("CDS"); + request.setInstanceId("id "); + request.setRegion("bj"); + request.setRenewTime(1); + request.setRenewTimeUnit("year"); + + client.setRenewResourceRule(request); + + System.out.println("=================================="); + System.out.println("sampleForSetRenewResourceRule ResourceAutoRenewRequest :"); + System.out.println(" serviceType: " + request.getServiceType()); + System.out.println(" instanceId: " + request.getInstanceId()); + System.out.println(" region: " + request.getRegion()); + System.out.println(" renewTime: " + request.getRenewTime()); + System.out.println(" renewTimeUnit: " + request.getRenewTimeUnit()); + System.out.println("=================================="); + } + + private static void sampleForQueryResourceBillList() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + ResourceBillListQueryRequest request = new ResourceBillListQueryRequest(); + request.setBillMonth("2020-08"); + request.setProductType("prepay"); + request.setPageNo(1); + request.setPageSize(10); + + ResourceBillListQueryResponse response = client.getResourceBillList(request); + + System.out.println("=================================="); + System.out.println("sampleForQueryResourceBillList ResourceBillListQueryResponse result:"); + System.out.println(" accountId: " + response.getAccountId()); + System.out.println(" month: " + response.getBillMonth()); + System.out.println(" size: " + response.getTotalCount()); + System.out.println(" bills: " + response.getBills()); + System.out.println("=================================="); + } + + private static void sampleForQueryPrepayShareBill() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + PrepayShareBillRequest request = new PrepayShareBillRequest(); + request.setMonth("2020-04"); + request.setPageNo(1); + request.setPageSize(50); + + PrepayShareBillResponse response = client.queryPrepayShareBill(request); + + System.out.println("=================================="); + System.out.println("sampleForQueryPrepayShareBill PrepayShareBillResponse result:"); + System.out.println(" accountId: " + response.getAccountId()); + System.out.println(" month: " + response.getBillMonth()); + System.out.println(" size: " + response.getTotalCount()); + System.out.println(" bills: " + response.getBills()); + System.out.println("=================================="); + } + + private static void sampleForQueryShareBill() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + ShareBillRequest request = new ShareBillRequest(); + request.setMonth("2022-09"); + request.setPageNo(1); + request.setPageSize(50); + + ShareBillResponse response = client.queryShareBill(request); + + System.out.println("=================================="); + System.out.println("sampleForQueryShareBill ShareBillResponse result:"); + System.out.println(" accountId: " + response.getAccountId()); + System.out.println(" month: " + response.getBillMonth()); + System.out.println(" size: " + response.getTotalCount()); + System.out.println(" bills: " + response.getBills()); + System.out.println("=================================="); + } + + private static void sampleForQueryCostSplitBill() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + CostSplitBillRequest request = new CostSplitBillRequest(); + request.setMonth("2022-09"); + request.setPageNo(1); + request.setPageSize(50); + + CostSplitBillResponse response = client.queryCostSplitBill(request); + + System.out.println("=================================="); + System.out.println("sampleForQueryCostSplitBill CostSplitBillResponse result:"); + System.out.println(" accountId: " + response.getAccountId()); + System.out.println(" month: " + response.getBillMonth()); + System.out.println(" size: " + response.getTotalCount()); + System.out.println(" bills: " + response.getBills()); + System.out.println("=================================="); + } + + private static void sampleForQueryProductMonthBillSummary() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + ProductMonthBillSummaryRequest request = new ProductMonthBillSummaryRequest(); + request.setBillMonth("2022-09"); + + ProductMonthBillSummaryResponse response = client.queryProductMonthBillSummary(request); + + System.out.println("=================================="); + System.out.println("sampleForQueryShareBill ShareBillResponse result:"); + System.out.println(" accountId: " + response.getAccountId()); + System.out.println(" data: " + response.getData()); + System.out.println("=================================="); + } + + private static void sampleForGetResourceMonthBills() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + ResourceMonthBillRequest request = new ResourceMonthBillRequest(); + request.setMonth("2019-04"); + request.setProductType("postpay"); + request.setPageNo(1); + request.setPageSize(50); + + ResourceMonthBillResponse response = client.getResourceMonthBill(request); + + System.out.println("=================================="); + System.out.println("sampleForGetResourceMonthBills ResourceMonthBillResponse result:"); + System.out.println(" accountId: " + response.getAccountId()); + System.out.println(" month: " + response.getBillMonth()); + System.out.println(" size: " + response.getTotalCount()); + System.out.println(" bills: " + response.getBills()); + System.out.println("=================================="); + } + + private static void sampleForQueryOrderList() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + OrderListRequest request = new OrderListRequest(); + request.setProductType("postpay"); + request.setPageNo(1); + request.setPageSize(50); + + OrderListResponse response = client.getOrderList(request); + + System.out.println("=================================="); + System.out.println("sampleForQueryOrderList OrderListResponse result:"); + System.out.println(" pageNo: " + response.getPageNo()); + System.out.println(" pageSize: " + response.getPageSize()); + System.out.println(" size: " + response.getTotalCount()); + System.out.println(" orders: " + response.getOrders()); + System.out.println("=================================="); + } + + private static void sampleForGetOrderWithUuid() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + OrderUuidQueryRequest request = new OrderUuidQueryRequest(); + request.setQueryAccountId("query accountId"); + List uuidList = new ArrayList(); + uuidList.add("order id A"); + uuidList.add("order id B"); + request.setUuids(uuidList); + + + OrderListResponse response = client.getOrdersByUuid(request); + + System.out.println("=================================="); + System.out.println("sampleForGetOrderWithUuid OrderListResponse result:"); + System.out.println(" pageNo: " + response.getPageNo()); + System.out.println(" pageSize: " + response.getPageSize()); + System.out.println(" size: " + response.getTotalCount()); + System.out.println(" orders: " + response.getOrders()); + System.out.println("=================================="); + } + + private static void sampleForCancelOrders() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + OrderCancelRequest request = new OrderCancelRequest(); + List orderIds = new ArrayList(); + orderIds.add("test order uuid 1"); + orderIds.add("test order uuid 2"); + request.setOrderIds(orderIds); + + OrderCancelResponse response = client.cancelOrders(request); + + System.out.println("=================================="); + System.out.println("sampleForCancelOrders OrderCancelResponse result:"); + System.out.println(" success: " + response.getSuccess()); + System.out.println("=================================="); + } + + private static void sampleForPayOrder() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + OrderPaymentRequest request = new OrderPaymentRequest(); + request.setOrderId("test order uuid"); + + OrderPaymentResponse response = client.payOrder(request); + + System.out.println("=================================="); + System.out.println("sampleForPayOrder OrderPaymentResponse result:"); + System.out.println(" success: " + response.getSuccess()); + System.out.println("=================================="); + } + + private static void sampleForgetSpecificCptPrice() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + Flavor flavor = new Flavor(); + List items = new ArrayList(); + items.add(new ChargeItem("memory", "1g", BigDecimal.valueOf(8))); + items.add(new ChargeItem("physicalZone", "zone id", BigDecimal.valueOf(8))); + items.add(new ChargeItem("cpu", "1", BigDecimal.valueOf(2))); + items.add(new ChargeItem("subServiceType", "defaultBcc3", null)); + flavor.setChargeItems(items); + + CptPricingRequest request = new CptPricingRequest(); + request.setServiceType("BCC"); + request.setProductType("RESERVED"); + request.setRegion("bj"); + request.setFlavor(flavor); + request.setCount(1); + request.setPeriod("P1M"); + + PricingQueryResponse response = client.getSpecificCptPrice(request); + + System.out.println("=================================="); + System.out.println("sampleForgetSpecificCptPrice PricingQueryResponse result:"); + System.out.println(" price: " + response.getPrice()); + System.out.println(" catalogPrice: " + response.getCatalogPrice()); + System.out.println("=================================="); + } + + private static void sampleForgetSpecificCpcPrice() { + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + Flavor flavor = new Flavor(); + List items = new ArrayList(); + items.add(new ChargeItem("OutBytes", "10G", null)); + flavor.setChargeItems(items); + + CpcPricingRequest request = new CpcPricingRequest(); + request.setServiceType("LSS"); + request.setProductType("ON_DEMAND"); + request.setRegion("global"); + request.setFlavor(flavor); + request.setCount(1); + + PricingQueryResponse response = client.getSpecificCpcPrice(request); + + System.out.println("=================================="); + System.out.println("sampleForgetSpecificCpcPrice PricingQueryResponse result:"); + System.out.println(" price: " + response.getPrice()); + System.out.println(" catalogPrice: " + response.getCatalogPrice()); + System.out.println("=================================="); + } + + private static void sampleForBalanceTransfer() { + + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + SupervisorBalanceTransferRequest request = new SupervisorBalanceTransferRequest(); + request.setSupervisedId("subUserId"); + request.setAmount(new BigDecimal("20")); + + TransferResultResponse response = client.balanceTransfer(request); + + System.out.println("=================================="); + System.out.println("sampleForBalanceTransfer response result:"); + System.out.println(" result: " + response.isSuccess()); + System.out.println("=================================="); + } + + private static void sampleForTransactionList() { + + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + SupervisorTransactionPageRequest request = new SupervisorTransactionPageRequest(); + request.setBeginTime("2019-12-31T16:00:00"); + request.setEndTime("2020-01-31T15:59:59"); + request.setPageNo(1); + request.setPageSize(100); + + SupervisorTransactionResponse response = client.transactionList(request); + + System.out.println("=================================="); + System.out.println("sampleForBalanceTransfer response result:"); + System.out.println(" pageno: " + response.getPageNo()); + System.out.println(" pagesize: " + response.getPageSize()); + System.out.println(" size: " + response.getTotalCount()); + System.out.println(" result: " + response.getResult()); + System.out.println("=================================="); + } + + private static void sampleForCashBalanceQuery() { + + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + SupervisorBalanceQueryRequest request = new SupervisorBalanceQueryRequest(); + request.setAccountIds(Lists.newArrayList(TEST_ACCOUNT_ID)); + + SupervisorBalanceResponse response = client.balanceQuery(request); + + System.out.println("=================================="); + System.out.println("SupervisorBalance response result:"); + System.out.println(" result: " + JsonUtils.toJsonString(response.getResult())); + System.out.println("=================================="); + } + + private static void sampleForUserBalanceQuery() { + + BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY); + BillingClient client = new BillingClient( + new BillingClientConfiguration().withEndpoint(ENDPOINT).withCredentials(credentials) + ); + + UserBalanceQueryResponse response = client.userBalanceQuery(); + + System.out.println("============================"); + System.out.println("UserBalance response result:"); + System.out.println(" result: " + JsonUtils.toJsonString(response.getCashBalance())); + System.out.println("============================"); + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/ResourceMonthBillRequest.java b/src/main/java/com/baidubce/services/billing/model/ResourceMonthBillRequest.java new file mode 100644 index 00000000..f869b1b6 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/ResourceMonthBillRequest.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * request model for query resource month bill + */ +public class ResourceMonthBillRequest extends AbstractBceRequest { + + /** + * the month of bill, query by month + */ + private String month; + + /** + * the begin time of bill, query by day + */ + private String beginTime; + + /** + * the end time of bill, query by day + */ + private String endTime; + + /** + * pay type : prepay/postpay + */ + private String productType; + + /** + * the type of service + */ + private String serviceType; + + /** + * the account id you want to query + * tips: only the master account of organization group can set the parameter to query the sub account's bill + */ + private String queryAccountId; + + /** + * page number + */ + Integer pageNo; + + /** + * page size + */ + Integer pageSize; + + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } + + public String getBeginTime() { + return beginTime; + } + + public void setBeginTime(String beginTime) { + this.beginTime = beginTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + this.productType = productType; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getQueryAccountId() { + return queryAccountId; + } + + public void setQueryAccountId(String queryAccountId) { + this.queryAccountId = queryAccountId; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public ResourceMonthBillRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/billing/model/ResourceMonthBillResponse.java b/src/main/java/com/baidubce/services/billing/model/ResourceMonthBillResponse.java new file mode 100644 index 00000000..ba60bb49 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/ResourceMonthBillResponse.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * the detail info of resource month bills + */ +public class ResourceMonthBillResponse extends AbstractBceResponse { + + /** + * the month of bill + */ + String billMonth; + + /** + * the begin time of bill, query by day + */ + private String beginTime; + + /** + * the end time of bill, query by day + */ + private String endTime; + + /** + * the account id + */ + String accountId; + + /** + * the login name of the account id + */ + String loginName; + + /** + * the sub account id + */ + String subAccountId; + + /** + * the login name of sub account id + */ + String subLoginName; + + /** + * the unit name of the sub account + */ + String ouName; + + /** + * page number + */ + Integer pageNo; + + /** + * page size + */ + Integer pageSize; + + /** + * the total count of the bills + */ + Integer totalCount; + + /** + * resource month instance bill + */ + List bills = new ArrayList(); + + public String getBillMonth() { + return billMonth; + } + + public void setBillMonth(String billMonth) { + this.billMonth = billMonth; + } + + public String getBeginTime() { + return beginTime; + } + + public void setBeginTime(String beginTime) { + this.beginTime = beginTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getLoginName() { + return loginName; + } + + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + public String getSubAccountId() { + return subAccountId; + } + + public void setSubAccountId(String subAccountId) { + this.subAccountId = subAccountId; + } + + public String getSubLoginName() { + return subLoginName; + } + + public void setSubLoginName(String subLoginName) { + this.subLoginName = subLoginName; + } + + public String getOuName() { + return ouName; + } + + public void setOuName(String ouName) { + this.ouName = ouName; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public List getBills() { + return bills; + } + + public void setBills(List bills) { + this.bills = bills; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/ResourceMonthInstanceBill.java b/src/main/java/com/baidubce/services/billing/model/ResourceMonthInstanceBill.java new file mode 100644 index 00000000..288c7433 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/ResourceMonthInstanceBill.java @@ -0,0 +1,637 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model; + +import java.math.BigDecimal; + +import lombok.ToString; + +/** + * the detail info of resource month bill + */ +@ToString +public class ResourceMonthInstanceBill { + + /** + * service provider + */ + private String vendor; + + /** + * 账单ID + */ + private String billId; + + /** + * user id + */ + private String accountId; + + /** + * the name of service + */ + private String serviceType; + + /** + * chinese name of service + */ + private String serviceTypeName; + + /** + * the pay type + */ + private String productType; + + /** + * the region of the resource + */ + private String region; + + /** + * the id of the resource + */ + private String instanceId; + + /** + * the id of the order which is related to the resource + */ + private String orderId; + + /** + * the type of order + */ + private String orderType; + + /** + * the chinese name of the order type + */ + private String orderTypeDesc; + + /** + * the time of purchase the order + */ + private String orderPurchaseTime; + + /** + * the start time of the bill + */ + private String startTime; + + /** + * the end time of the bill + */ + private String endTime; + + /** + * resource start time + */ + private String serviceStartTime; + + /** + * resource end time + */ + private String serviceEndTime; + + /** + * the configuration of the resource + */ + private String configurationCH; + + /** + * the tag info of the resource + */ + private String tag; + + /** + * the prepay service time + */ + private String duration = ""; + + /** + * the charge item of the resource + */ + private String chargeItem = ""; + + /** + * the charge item of the resource in chinese + */ + private String chargeItemDesc = ""; + + /** + * the usage amount of the charge item + */ + private String amount; + + /** + * the unit of the usage amout + */ + private String amountUnit = ""; + + /** + * the usage amount of discount + */ + private String discountAmount; + + /** + * the unit price of the charge item + */ + private String unitPrice = ""; + + /** + * the price unit of the charge item + */ + private String pricingUnit = ""; + + /** + * the discounts of the bill + */ + private String discountUnit = ""; + + /** + * the tex of the resource + */ + private BigDecimal tex; + + /** + * amount of bill + */ + private BigDecimal originPrice; + + /** + * amount need to pay + */ + private BigDecimal financePrice; + + /** + * amount of cash + */ + private BigDecimal cash; + + /** + * amount of rebase + */ + private BigDecimal rebate; + + /** + * amount of credit cost + */ + private BigDecimal creditCost; + + /** + * amount of redit refund + */ + private BigDecimal creditRefund; + + /** + * amount of redit refund + */ + private BigDecimal creditRefundDeduct; + + /** + * amount of debt + */ + private BigDecimal debt; + + /** + * amount not need to pay + */ + private BigDecimal noPaidPrice; + + /** + * amount of coupon + */ + private BigDecimal couponPrice; + + /** + * amount of discount conpon + */ + private BigDecimal discountCouponPrice; + + /** + * amount of discount + */ + private BigDecimal discountPrice; + + /** + * amount of sales + */ + private BigDecimal sysGold; + + private BigDecimal deductPrice; + + private BigDecimal deductCash; + + private BigDecimal deductRebate; + + private BigDecimal deductCreditCost; + + private BigDecimal deductCouponPrice; + + private BigDecimal deductDiscountCouponPrice; + + private BigDecimal deductDiscountPrice; + + private BigDecimal deductCashEquivalentCouponPrice; + + public String getVendor() { + return vendor; + } + + public void setVendor(String vendor) { + this.vendor = vendor; + } + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceTypeName() { + return serviceTypeName; + } + + public void setServiceTypeName(String serviceTypeName) { + this.serviceTypeName = serviceTypeName; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + this.productType = productType; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getOrderType() { + return orderType; + } + + public void setOrderType(String orderType) { + this.orderType = orderType; + } + + public String getOrderTypeDesc() { + return orderTypeDesc; + } + + public void setOrderTypeDesc(String orderTypeDesc) { + this.orderTypeDesc = orderTypeDesc; + } + + public String getOrderPurchaseTime() { + return orderPurchaseTime; + } + + public void setOrderPurchaseTime(String orderPurchaseTime) { + this.orderPurchaseTime = orderPurchaseTime; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getServiceStartTime() { + return serviceStartTime; + } + + public void setServiceStartTime(String serviceStartTime) { + this.serviceStartTime = serviceStartTime; + } + + public String getServiceEndTime() { + return serviceEndTime; + } + + public void setServiceEndTime(String serviceEndTime) { + this.serviceEndTime = serviceEndTime; + } + + public String getConfigurationCH() { + return configurationCH; + } + + public void setConfigurationCH(String configurationCH) { + this.configurationCH = configurationCH; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getChargeItem() { + return chargeItem; + } + + public void setChargeItem(String chargeItem) { + this.chargeItem = chargeItem; + } + + public String getChargeItemDesc() { + return chargeItemDesc; + } + + public void setChargeItemDesc(String chargeItemDesc) { + this.chargeItemDesc = chargeItemDesc; + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public String getAmountUnit() { + return amountUnit; + } + + public void setAmountUnit(String amountUnit) { + this.amountUnit = amountUnit; + } + + public String getDiscountAmount() { + return discountAmount; + } + + public void setDiscountAmount(String discountAmount) { + this.discountAmount = discountAmount; + } + + public String getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(String unitPrice) { + this.unitPrice = unitPrice; + } + + public String getPricingUnit() { + return pricingUnit; + } + + public void setPricingUnit(String pricingUnit) { + this.pricingUnit = pricingUnit; + } + + public String getDiscountUnit() { + return discountUnit; + } + + public void setDiscountUnit(String discountUnit) { + this.discountUnit = discountUnit; + } + + public BigDecimal getTex() { + return tex; + } + + public void setTex(BigDecimal tex) { + this.tex = tex; + } + + public BigDecimal getOriginPrice() { + return originPrice; + } + + public void setOriginPrice(BigDecimal originPrice) { + this.originPrice = originPrice; + } + + public BigDecimal getFinancePrice() { + return financePrice; + } + + public void setFinancePrice(BigDecimal financePrice) { + this.financePrice = financePrice; + } + + public BigDecimal getCash() { + return cash; + } + + public void setCash(BigDecimal cash) { + this.cash = cash; + } + + public BigDecimal getRebate() { + return rebate; + } + + public void setRebate(BigDecimal rebate) { + this.rebate = rebate; + } + + public BigDecimal getCreditCost() { + return creditCost; + } + + public void setCreditCost(BigDecimal creditCost) { + this.creditCost = creditCost; + } + + public BigDecimal getCreditRefund() { + return creditRefund; + } + + public void setCreditRefund(BigDecimal creditRefund) { + this.creditRefund = creditRefund; + } + + public BigDecimal getDebt() { + return debt; + } + + public void setDebt(BigDecimal debt) { + this.debt = debt; + } + + public BigDecimal getNoPaidPrice() { + return noPaidPrice; + } + + public void setNoPaidPrice(BigDecimal noPaidPrice) { + this.noPaidPrice = noPaidPrice; + } + + public BigDecimal getCouponPrice() { + return couponPrice; + } + + public void setCouponPrice(BigDecimal couponPrice) { + this.couponPrice = couponPrice; + } + + public BigDecimal getDiscountCouponPrice() { + return discountCouponPrice; + } + + public void setDiscountCouponPrice(BigDecimal discountCouponPrice) { + this.discountCouponPrice = discountCouponPrice; + } + + public BigDecimal getDiscountPrice() { + return discountPrice; + } + + public void setDiscountPrice(BigDecimal discountPrice) { + this.discountPrice = discountPrice; + } + + public BigDecimal getSysGold() { + return sysGold; + } + + public void setSysGold(BigDecimal sysGold) { + this.sysGold = sysGold; + } + + public String getBillId() { + return billId; + } + + public void setBillId(String billId) { + this.billId = billId; + } + + public BigDecimal getCreditRefundDeduct() { + return creditRefundDeduct; + } + + public void setCreditRefundDeduct(BigDecimal creditRefundDeduct) { + this.creditRefundDeduct = creditRefundDeduct; + } + + public BigDecimal getDeductPrice() { + return deductPrice; + } + + public void setDeductPrice(BigDecimal deductPrice) { + this.deductPrice = deductPrice; + } + + public BigDecimal getDeductCash() { + return deductCash; + } + + public void setDeductCash(BigDecimal deductCash) { + this.deductCash = deductCash; + } + + public BigDecimal getDeductRebate() { + return deductRebate; + } + + public void setDeductRebate(BigDecimal deductRebate) { + this.deductRebate = deductRebate; + } + + public BigDecimal getDeductCreditCost() { + return deductCreditCost; + } + + public void setDeductCreditCost(BigDecimal deductCreditCost) { + this.deductCreditCost = deductCreditCost; + } + + public BigDecimal getDeductCouponPrice() { + return deductCouponPrice; + } + + public void setDeductCouponPrice(BigDecimal deductCouponPrice) { + this.deductCouponPrice = deductCouponPrice; + } + + public BigDecimal getDeductDiscountCouponPrice() { + return deductDiscountCouponPrice; + } + + public void setDeductDiscountCouponPrice(BigDecimal deductDiscountCouponPrice) { + this.deductDiscountCouponPrice = deductDiscountCouponPrice; + } + + public BigDecimal getDeductDiscountPrice() { + return deductDiscountPrice; + } + + public void setDeductDiscountPrice(BigDecimal deductDiscountPrice) { + this.deductDiscountPrice = deductDiscountPrice; + } + + public BigDecimal getDeductCashEquivalentCouponPrice() { + return deductCashEquivalentCouponPrice; + } + + public void setDeductCashEquivalentCouponPrice(BigDecimal deductCashEquivalentCouponPrice) { + this.deductCashEquivalentCouponPrice = deductCashEquivalentCouponPrice; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/AmountDetail.java b/src/main/java/com/baidubce/services/billing/model/bill/AmountDetail.java new file mode 100644 index 00000000..9345f4f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/AmountDetail.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.bill; + +import java.math.BigDecimal; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.Data; + +/** + * 币种明细 + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AmountDetail { + + /** + * 账单金额 + */ + private BigDecimal originPrice = BigDecimal.ZERO; + + /** + * 目录价 + */ + private BigDecimal catalogPrice = BigDecimal.ZERO; + + /** + * 应付金额 + */ + private BigDecimal financePrice = BigDecimal.ZERO; + + /** + * 现金支付 + */ + private BigDecimal cash = BigDecimal.ZERO; + + /** + * 返点支付 + */ + private BigDecimal rebate = BigDecimal.ZERO; + + /** + * 帐期支付 + */ + private BigDecimal creditCost = BigDecimal.ZERO; + + /** + * 账期退款 + */ + private BigDecimal creditRefund = BigDecimal.ZERO; + + /** + * 账期退款抵扣 + */ + private BigDecimal creditRefundDeduct = BigDecimal.ZERO; + + /** + * 欠费 + */ + private BigDecimal debt = BigDecimal.ZERO; + + /** + * 代金劵 + */ + private BigDecimal couponPrice = BigDecimal.ZERO; + + /** + * 折扣券 + */ + private BigDecimal discountCouponPrice = BigDecimal.ZERO; + + /** + * 现金券 + */ + private BigDecimal cashEquivalentCouponPrice = BigDecimal.ZERO; + + /** + * 折扣金额 + */ + private BigDecimal discountPrice = BigDecimal.ZERO; + + /** + * 销账金额 + */ + private BigDecimal sysGold = BigDecimal.ZERO; + + private BigDecimal deductPrice = BigDecimal.ZERO; + + private BigDecimal deductCash = BigDecimal.ZERO; + + private BigDecimal deductRebate = BigDecimal.ZERO; + + private BigDecimal deductCreditCost = BigDecimal.ZERO; + + private BigDecimal deductCouponPrice = BigDecimal.ZERO; + + private BigDecimal deductDiscountCouponPrice = BigDecimal.ZERO; + + private BigDecimal deductDiscountPrice = BigDecimal.ZERO; + + private BigDecimal deductCashEquivalentCouponPrice = BigDecimal.ZERO; +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ChargeItemBill.java b/src/main/java/com/baidubce/services/billing/model/bill/ChargeItemBill.java new file mode 100644 index 00000000..9980559a --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ChargeItemBill.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import lombok.Data; + +/** + * the bill of the charge item + */ +@Data +public class ChargeItemBill extends AmountDetail { + + /** + * the charge item ,like RunningTimeMinutes + */ + private String chargeItem; + + /** + * the charge item ,like 运行时间 + */ + private String chargeItemDesc; + + /** + * the usage amount of the charge item + */ + private String amount; + + /** + * the amount unit of the charge item + */ + private String amountUnit; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/CostSplitBillRequest.java b/src/main/java/com/baidubce/services/billing/model/bill/CostSplitBillRequest.java new file mode 100644 index 00000000..6076b28e --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/CostSplitBillRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +/** + * Created by shizhan@baidu.com + */ +@Data +public class CostSplitBillRequest extends AbstractBceRequest { + /** + * 选传,账单月份,yyyy-MM + * 最早为2020-04 + * month 和 【startDay,endTime】组合二选一,优先使用 month + */ + private String month; + + /** + * 选传,账单起始日,yyyy-MM-dd + * 【startDay,endTime】需要同时选传 + */ + private String startDay; + + /** + * 选传,账单截止日,yyyy-MM-dd + * 【startDay,endTime】需要同时选传 + */ + private String endDay; + + /** + * 计费类型:all/prepay/postpay,分别表示全量/预付费/后付费 + * 缺省时为 all + */ + private String productType; + + /** + * 产品名称 + * 缺省为所有产品 + */ + private String serviceType; + + /** + * 非必传,查询账户ID,默认为登录账户 + * 若非登录账户,则必须是主账户的子账户,且该子账户加入了财务圈 + */ + private String queryAccountId; + + private String instanceId; + + /** + * 分页查询的页数,从1开始计数 + * 缺省值为1 + */ + private Integer pageNo = 1; + + /** + * 每页包含的最大数量,最大数量通常不超过1000 + * 缺省值为100 + */ + private Integer pageSize = 100; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + return null; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/CostSplitBillResponse.java b/src/main/java/com/baidubce/services/billing/model/bill/CostSplitBillResponse.java new file mode 100644 index 00000000..8549cbf0 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/CostSplitBillResponse.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; +import lombok.ToString; + +/** + * Created by shizhan@baidu.com + */ +@Data +@ToString +public class CostSplitBillResponse extends AbstractBceResponse { + /** + * 账户ID,若查询子账户,则为主账户ID + */ + protected String accountId; + + /** + * 账户登录名,若查询子账户,则为主账户登录名 + */ + protected String loginName; + + /** + * 子账户ID + */ + protected String subAccountId; + + /** + * 子账户登录名 + */ + protected String subLoginName; + + /** + * 子账户所在组织单元名 + */ + protected String ouName; + + /** + * 账单时间,YYYY-MM + * 按月查询 + */ + private String billMonth; + + /** + * 页码,默认值为1 + */ + private Integer pageNo; + + /** + * 每页数量,默认值:20,最大值:100 + */ + private Integer pageSize; + + /** + * 当前查询条件总数 + */ + private Integer totalCount; + + /** + * 预付费分摊账单详情,包含用量包 + */ + private List bills = new ArrayList<>(); +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/PrepayShareBill.java b/src/main/java/com/baidubce/services/billing/model/bill/PrepayShareBill.java new file mode 100644 index 00000000..a4033e96 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/PrepayShareBill.java @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import java.math.BigDecimal; + +import lombok.Data; + +/** + * the detail info of prepay share bill + */ +@Data +public class PrepayShareBill { + + /** + * the month of bill + */ + private String billMonth; + + /** + * the type of service + */ + private String serviceType; + + /** + * chinese name of service + */ + private String serviceTypeName; + + /** + * the id of the resource + */ + private String instanceId; + + /** + * the short id of the resource + */ + private String shortId; + + /** + * the configuration of the resource + */ + private String configurationCH; + + /** + * the tag info of the resource + */ + private String tag; + + /** + * the region of the resource + */ + private String region; + + /** + * the chinese name of the region + */ + private String regionName; + + /** + * the id of the order which is related to the resource + */ + private String orderId; + + /** + * the type of order + */ + private String orderType; + + /** + * the chinese name of the order type + */ + private String orderTypeDesc; + + /** + * the create time of the order + */ + private String createTime; + + /** + * the start time of the order + */ + private String serviceStartTime; + + /** + * the end time of the order + */ + private String serviceEndTime; + + /** + * the time span of the order + */ + private String serviceTimeSpan; + + /** + * the capacity of the order(for usage package) + */ + private String capacity; + + /** + * the price of the order + */ + private BigDecimal price; + + /** + * the finance price + */ + private BigDecimal financePrice; + + /** + * the coupon price + */ + private BigDecimal couponPrice; + + /** + * the discount coupon price + */ + private BigDecimal discountCouponPrice; + + /** + * the cash coupon price + */ + private BigDecimal cashEquivalentCouponPrice; + + /** + * the discount price + */ + private BigDecimal discountPrice; + + /** + * the price shared in this month + */ + private BigDecimal sharePrice; + + /** + * the finance price shared in this month + */ + private BigDecimal shareFinancePrice; + + /** + * the coupon price shared in this month + */ + private BigDecimal shareCouponPrice; + + /** + * the discount coupon price shared in this month + */ + private BigDecimal shareDiscountCouponPrice; + + /** + * the cash coupon price shared in this month + */ + private BigDecimal shareCashEquivalentCouponPrice; + + /** + * the discount price shared in this month + */ + private BigDecimal shareDiscountPrice; + + /** + * the deduct finance price shared in this month + */ + private BigDecimal deductShareFinancePrice; + + /** + * the deduct coupon price shared in this month + */ + private BigDecimal deductShareCouponPrice; + + /** + * the deduct discount coupon price shared in this month + */ + private BigDecimal deductShareDiscountCouponPrice; + + /** + * the deduct cash coupon price shared in this month + */ + private BigDecimal deductShareCashEquivalentCouponPrice; + + /** + * the deduct discount price shared in this month + */ + private BigDecimal deductShareDiscountPrice; + + /** + * the controversial flag + */ + private int controversialItem; + + /** + * the op time + */ + private String opTime; + + /** + * the time of this bill is confirmed + */ + private String confirmTime; + + /** + * the amount shared in this month + */ + private BigDecimal shareAmount; + + /** + * the time span shared in this month + */ + private Integer shareDays; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/PrepayShareBillRequest.java b/src/main/java/com/baidubce/services/billing/model/bill/PrepayShareBillRequest.java new file mode 100644 index 00000000..d1dcff2c --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/PrepayShareBillRequest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.bill; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +/** + * request model for query prepay share bill + */ +@Data +public class PrepayShareBillRequest extends AbstractBceRequest { + + /** + * the month of bill + */ + private String month; + + /** + * the type of service + */ + private String serviceType; + + /** + * the account id you want to query + * tips: only the master account of organization group can set the parameter to query the sub account's bill + */ + private String queryAccountId; + + /** + * is show deduct price + */ + private Boolean showDeductPrice; + + /** + * is show controversial + */ + private Boolean showControversial; + + /** + * page number + */ + private Integer pageNo; + + /** + * page size + */ + private Integer pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public PrepayShareBillRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/PrepayShareBillResponse.java b/src/main/java/com/baidubce/services/billing/model/bill/PrepayShareBillResponse.java new file mode 100644 index 00000000..5597832e --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/PrepayShareBillResponse.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +/** + * the detail info of prepay share bills + */ +@Data +public class PrepayShareBillResponse extends AbstractBceResponse { + + /** + * the month of bill + */ + String billMonth; + + /** + * the account id + */ + String accountId; + + /** + * the login name of the account id + */ + String loginName; + + /** + * the sub account id + */ + String subAccountId; + + /** + * the login name of sub account id + */ + String subLoginName; + + /** + * the unit name of the sub account + */ + String ouName; + + /** + * page number + */ + Integer pageNo; + + /** + * page size + */ + Integer pageSize; + + /** + * the total count of the bills + */ + Integer totalCount; + + /** + * resource month instance bill + */ + List bills = new ArrayList(); + +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ProductMonthBillItem.java b/src/main/java/com/baidubce/services/billing/model/bill/ProductMonthBillItem.java new file mode 100644 index 00000000..90ed6875 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ProductMonthBillItem.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.bill; + +import java.math.BigDecimal; +import java.util.List; + +import lombok.Data; + +/** + * 产品月账单详情 + */ +@Data +public class ProductMonthBillItem { + /** + * 产品名 + */ + private String serviceType; + /** + * 产品中文名 + */ + private String serviceTypeName; + /** + * 付费类型 + */ + private String productType; + /** + * 账单金额 + */ + private BigDecimal originPrice = BigDecimal.ZERO; + /** + * 应付金额(现金等价物部分金额)应付金额=现金+返点+账期待还+账期退款+欠费 + */ + private BigDecimal financePrice = BigDecimal.ZERO; + /** + * 现金支付 + */ + private BigDecimal cash = BigDecimal.ZERO; + /** + * 返点支付 + */ + private BigDecimal rebate = BigDecimal.ZERO; + /** + * 账期未还 + */ + private BigDecimal creditCost = BigDecimal.ZERO; + /** + * 账期退款 + */ + private BigDecimal creditRefund = BigDecimal.ZERO; + /** + * 欠费金额 + */ + private BigDecimal debt = BigDecimal.ZERO; + /** + * 优惠金额 优惠金额=代金券+折扣券+折扣金额+销账 + */ + private BigDecimal noPaidPrice = BigDecimal.ZERO; + /** + * 代金券支付 + */ + private BigDecimal couponPrice = BigDecimal.ZERO; + /** + * 折扣券支付 + */ + private BigDecimal discountCouponPrice = BigDecimal.ZERO; + /** + * 现金等额券支付 + */ + private BigDecimal cashEquivalentCouponPrice = BigDecimal.ZERO; + /** + * 折扣金额 + */ + private BigDecimal discountPrice = BigDecimal.ZERO; + /** + * 销账金额 + */ + private BigDecimal sysGold = BigDecimal.ZERO; + + /** + * 待确认金额 + */ + private BigDecimal unconfirmPrice = BigDecimal.ZERO; + + private BigDecimal creditRefundDeduct = BigDecimal.ZERO; + + private BigDecimal deductPrice = BigDecimal.ZERO; + + private BigDecimal deductCash = BigDecimal.ZERO; + + private BigDecimal deductRebate = BigDecimal.ZERO; + + private BigDecimal deductCreditCost = BigDecimal.ZERO; + + private BigDecimal deductCouponPrice = BigDecimal.ZERO; + + private BigDecimal deductDiscountCouponPrice = BigDecimal.ZERO; + + private BigDecimal deductDiscountPrice = BigDecimal.ZERO; + + private BigDecimal deductCashEquivalentCouponPrice = BigDecimal.ZERO; + + private List items; +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ProductMonthBillSummaryRequest.java b/src/main/java/com/baidubce/services/billing/model/bill/ProductMonthBillSummaryRequest.java new file mode 100644 index 00000000..99a83ce9 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ProductMonthBillSummaryRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.bill; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +/** + * request model for query product month bill + */ +@Data +public class ProductMonthBillSummaryRequest extends AbstractBceRequest { + + /** + * the month of bill + * yyyy-MM + */ + private String billMonth; + + /** + * the type of charging + * enum: prepay/postpay + */ + private String productType; + + /** + * the type of service + */ + private String serviceType; + + /** + * the account id you want to query + * tips: only the master account of organization group can set the parameter to query the sub account's bill + */ + private String queryAccountId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ProductMonthBillSummaryResponse.java b/src/main/java/com/baidubce/services/billing/model/bill/ProductMonthBillSummaryResponse.java new file mode 100644 index 00000000..3d010539 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ProductMonthBillSummaryResponse.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.bill; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; +import lombok.ToString; + +/** + * product month bill summary response + */ +@Data +@ToString +public class ProductMonthBillSummaryResponse extends AbstractBceResponse { + + /** + * 账单查询起止时间 + * 按月查询 + */ + private String billBeginTime; + + /** + * 账单查询起止时间 + */ + private String billEndTime; + + /** + * 当前账户不是财务圈子账户时,返回当前账户accountId + * 是财务圈子账户时,返回当前账户主账户的accountId + */ + private String accountId; + + /** + * 账户登录名,若查询子账户,则为主账户登录名 + */ + private String loginName; + + /** + * 当前账户不是财务圈子账户时,返回"/" + * 是财务圈子账户时,返回当前账户的accountId + */ + private String subAccountId; + + /** + * 当前账户不是财务圈子账户时,返回"/" + * 是财务圈子账户时,返回当前账户的登录名 + */ + private String subLoginName; + + /** + * 当前账户不是财务圈子账户时,返回"/" + * 是财务圈子账户时,返回当前账户所在组织单元的单元名 + */ + private String ouName; + + /** + * 产品项详情 + */ + private ProductMonthBillItem data; +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ResourceBill.java b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBill.java new file mode 100644 index 00000000..b136a340 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBill.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import java.util.List; + +import lombok.Data; + +/** + * the bill of resource + */ +@Data +public class ResourceBill extends AmountDetail { + + /** + * the name of service + */ + private String serviceType; + + /** + * chinese name of service + */ + private String serviceTypeName; + + /** + * the pay type + */ + private String productType; + + /** + * the id of the resource + */ + private String instanceId; + + /** + * the short id of the resource + */ + private String shortId; + + /** + * the region of the resource + */ + private String region; + + /** + * the tag info of the resource + */ + private String tag; + + /** + * the detail info if the resource is a postpay resource + */ + private List postpayDetails; + + /** + * the detail info if the resource is a pretpay resource + */ + private List prepayDetails; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillListQueryRequest.java b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillListQueryRequest.java new file mode 100644 index 00000000..a24f86b9 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillListQueryRequest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +/** + * request model for query resource bill list + */ +@Data +public class ResourceBillListQueryRequest extends AbstractBceRequest { + + /** + * the month of bill, query by month + */ + private String billMonth; + + /** + * the begin time of bill, query by day + */ + private String beginTime; + + /** + * the end time of bill, query by day + */ + private String endTime; + + /** + * pay type : prepay/postpay + */ + private String productType; + + /** + * the type of service + */ + private String serviceType; + + /** + * the resource instance id or resource short id + */ + private String shortOrInstanceId; + + /** + * the account id you want to query + * tips: only the master account of organization group can set the parameter to query the sub account's bill + */ + private String queryAccountId; + + /** + * page number + */ + Integer pageNo; + + /** + * page size + */ + Integer pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public ResourceBillListQueryRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillListQueryResponse.java b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillListQueryResponse.java new file mode 100644 index 00000000..eb0057d8 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillListQueryResponse.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +/** + * the detail list info of resource bills + */ +@Data +public class ResourceBillListQueryResponse extends AbstractBceResponse { + + /** + * the month of bill + */ + String billMonth; + + /** + * the begin time of bill, query by day + */ + private String beginTime; + + /** + * the end time of bill, query by day + */ + private String endTime; + + /** + * the account id + */ + String accountId; + + /** + * the login name of the account id + */ + String loginName; + + /** + * the sub account id + */ + String subAccountId; + + /** + * the login name of sub account id + */ + String subLoginName; + + /** + * the unit name of the sub account + */ + String ouName; + + /** + * page number + */ + Integer pageNo; + + /** + * page size + */ + Integer pageSize; + + /** + * the total count of the bills + */ + Integer totalCount; + + /** + * resource month instance bill + */ + List bills = new ArrayList(); + +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillPostpayDetail.java b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillPostpayDetail.java new file mode 100644 index 00000000..aa54a756 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillPostpayDetail.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import java.math.BigDecimal; +import java.util.List; + +import lombok.Data; + +/** + * the detail info if the resource is a postpay resource + */ +@Data +public class ResourceBillPostpayDetail { + + /** + * the start time of the detail bill + */ + private String detailBillStartTime; + + /** + * the end time of the detail bill + */ + private String detailBillEndTime; + + /** + * the sum price of all the charge item + */ + private BigDecimal totalPrice; + + /** + * charge granularity of the resource,like month day + */ + private String granularity; + + /** + * the charget item bill list + */ + private List chargeItems; + + /** + * 现金支付 + */ + private BigDecimal cash = BigDecimal.ZERO; + + /** + * 返点支付 + */ + private BigDecimal rebate = BigDecimal.ZERO; + + /** + * 帐期支付 + */ + private BigDecimal creditCost = BigDecimal.ZERO; + + /** + * 账期退款 + */ + private BigDecimal creditRefund = BigDecimal.ZERO; + + /** + * 欠费 + */ + private BigDecimal debt = BigDecimal.ZERO; + + /** + * 代金劵 + */ + private BigDecimal couponPrice = BigDecimal.ZERO; + + /** + * 折扣券 + */ + private BigDecimal discountCouponPrice = BigDecimal.ZERO; + + /** + * 现金券 + */ + private BigDecimal cashEquivalentCouponPrice = BigDecimal.ZERO; + + /** + * 折扣金额 + */ + private BigDecimal discountPrice = BigDecimal.ZERO; + + /** + * 销账金额 + */ + private BigDecimal sysGold = BigDecimal.ZERO; + + private BigDecimal creditRefundDeduct = BigDecimal.ZERO; + + private BigDecimal deductPrice = BigDecimal.ZERO; + + private BigDecimal deductCash = BigDecimal.ZERO; + + private BigDecimal deductRebate = BigDecimal.ZERO; + + private BigDecimal deductCreditCost = BigDecimal.ZERO; + + private BigDecimal deductCouponPrice = BigDecimal.ZERO; + + private BigDecimal deductDiscountCouponPrice = BigDecimal.ZERO; + + private BigDecimal deductDiscountPrice = BigDecimal.ZERO; + + private BigDecimal deductCashEquivalentCouponPrice = BigDecimal.ZERO; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillPrepayDetail.java b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillPrepayDetail.java new file mode 100644 index 00000000..ed365869 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ResourceBillPrepayDetail.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.bill; + +import java.math.BigDecimal; + +import lombok.Data; + +/** + * the detail info if the resource is a prepay resource + */ +@Data +public class ResourceBillPrepayDetail { + + /** + * the type of order + */ + private String orderType; + + /** + * the chinese name of the order type + */ + private String orderTypeDesc; + + /** + * the origin price of the order + */ + private BigDecimal orderOriginPrice; + + /** + * the time length of the order resource + */ + private BigDecimal time; + + /** + * the time unit of the order resource + */ + private String timeUnit; + + /** + * the time of the order create + */ + private String orderCreateTime; + + /** + * 现金支付 + */ + private BigDecimal cash = BigDecimal.ZERO; + + /** + * 返点支付 + */ + private BigDecimal rebate = BigDecimal.ZERO; + + /** + * 帐期支付 + */ + private BigDecimal creditCost = BigDecimal.ZERO; + + /** + * 账期退款 + */ + private BigDecimal creditRefund = BigDecimal.ZERO; + + /** + * 欠费 + */ + private BigDecimal debt = BigDecimal.ZERO; + + /** + * 代金劵 + */ + private BigDecimal couponPrice = BigDecimal.ZERO; + + /** + * 折扣券 + */ + private BigDecimal discountCouponPrice = BigDecimal.ZERO; + + /** + * 现金券 + */ + private BigDecimal cashEquivalentCouponPrice = BigDecimal.ZERO; + + /** + * 折扣金额 + */ + private BigDecimal discountPrice = BigDecimal.ZERO; + + /** + * 销账金额 + */ + private BigDecimal sysGold = BigDecimal.ZERO; + + private BigDecimal creditRefundDeduct = BigDecimal.ZERO; + + private BigDecimal deductPrice = BigDecimal.ZERO; + + private BigDecimal deductCash = BigDecimal.ZERO; + + private BigDecimal deductRebate = BigDecimal.ZERO; + + private BigDecimal deductCreditCost = BigDecimal.ZERO; + + private BigDecimal deductCouponPrice = BigDecimal.ZERO; + + private BigDecimal deductDiscountCouponPrice = BigDecimal.ZERO; + + private BigDecimal deductDiscountPrice = BigDecimal.ZERO; + + private BigDecimal deductCashEquivalentCouponPrice = BigDecimal.ZERO; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ShareBill.java b/src/main/java/com/baidubce/services/billing/model/bill/ShareBill.java new file mode 100644 index 00000000..fd0b4087 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ShareBill.java @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.bill; + +import java.math.BigDecimal; + +import lombok.Data; + +/** + * share bill object + */ +@Data +public class ShareBill { + + /** + * 账单时间,yyyy-MM + * 按月查询 + */ + private String billMonth; + + /** + * 账单时间,yyyy-MM-dd + * 按天查询 + */ + private String billDay; + + /** + * 产品付费类型 + */ + private String productType; + + /** + * 产品付费类型中文 + */ + private String productTypeName; + + /** + * 产品名称 + */ + private String serviceType; + + /** + * 产品展示名称,产品中心后续都用展示名 + */ + private String serviceTypeName; + + /** + * 实例信息 + */ + private String instanceId; + + /** + * shortId + */ + private String shortId; + + /** + * 产品中文配置,部分后付费有 + * e.m. ["类型:快照","size:1G"] + * /n分隔符拼接成字符串 + */ + private String configurationCH; + + /** + * 计费项英文名,仅后付费才有 + */ + private String chargeItem; + + /** + * 计费项中文名字,后付费才有 + */ + private String chargeItemDesc; + + /** + * 资源tag信息,根据instanceId查询资源绑定的tag + */ + private String tag; + + /** + * 区域,bj + */ + private String region; + + /** + * 区域中文名称,华北-北京等 + */ + private String regionName; + + /** + * 订单ID (后付费为空) + */ + private String orderId; + + /** + * 订单类型 (后付费为空) + */ + private String orderType; + + /** + * 订单类型,中文表示 (后付费为空) + */ + private String orderTypeDesc; + + /** + * 订单创建时间,utc时间 (后付费为空) + */ + private String createTime; + + /** + * 订单服务开始时间,utc时间 (后付费取资源账单开始时间) + */ + private String serviceStartTime; + + /** + * 订单服务结束时间,utc时间(后付费取资源账单结束时间) + */ + private String serviceEndTime; + + /** + * 订单资源服务时长 (只有CPT2有) + */ + private String serviceTimeSpan; + + /** + * 用量包总量(只有存储包、用量包有) + */ + private String capacity; + + // 总量费用信息,8个金额 + /** + * 账单原始金额 (后付费与分摊一致) + */ + private BigDecimal price; + + /** + * 原始应付金额(后付费与分摊一致) + */ + private BigDecimal financePrice; + + /** + * 原始目录金额(后付费与分摊一致) + */ + private BigDecimal catalogPrice; + + /** + * 代金券金额(后付费与分摊一致) + */ + private BigDecimal couponPrice; + + /** + * 折扣券金额(后付费与分摊一致) + */ + private BigDecimal discountCouponPrice; + + /** + * 现金券金额(后付费与分摊一致) + */ + private BigDecimal cashEquivalentCouponPrice; + + /** + * 折扣金额(后付费与分摊一致) + */ + private BigDecimal discountPrice; + + /** + * 销账金额(后付费与分摊一致) + */ + private BigDecimal sysGoldPrice; + + // 本月分摊信息,8个金额加用量加时长 + /** + * 本月(天)分摊价格 + */ + private BigDecimal sharePrice; + + /** + * 本月(天)分摊应付价格 + */ + private BigDecimal shareFinancePrice; + + /** + * 本月(天)分摊目录价格 + */ + private BigDecimal shareCatalogPrice; + + /** + * 本月(天)分摊代金券 + */ + private BigDecimal shareCouponPrice; + + /** + * 本月(天)分摊折扣券 + */ + private BigDecimal shareDiscountCouponPrice; + + /** + * 本月(天)分摊现金券 + */ + private BigDecimal shareCashEquivalentCouponPrice; + + /** + * 本月(天)分摊折扣金额 + */ + private BigDecimal shareDiscountPrice; + + /** + * 本月(天)分摊销账金额 + */ + private BigDecimal shareSysGoldPrice; + + /** + * 本月分摊应付价格(调减) + */ + private BigDecimal deductShareFinancePrice; + + /** + * 本月分摊代金券(调减) + */ + private BigDecimal deductShareCouponPrice; + + /** + * 本月分摊折扣券(调减) + */ + private BigDecimal deductShareDiscountCouponPrice; + + /** + * 本月分摊现金等额券金额(调减) + */ + private BigDecimal deductShareCashEquivalentCouponPrice; + + /** + * 本月分摊折扣金额(调减) + */ + private BigDecimal deductShareDiscountPrice; + + /** + * 账单争议标记 + */ + private int controversialItem; + + /** + * 操作时间 + */ + private String opTime; + + /** + * 确认时间 + */ + private String confirmTime; + + /** + * 本月(天)分摊用量(包括量包和所有后付费计费项) + */ + private BigDecimal shareAmount; + + /** + * 量包抵扣对应的应收金额 + */ + private BigDecimal deductPackageFinancePrice = BigDecimal.ZERO; + + /** + * 用量单位 + */ + private String amountUnit; + + /** + * 本月(天)分摊时长(天) (只用于CPT2、Project计费项) + */ + private Integer shareDays; +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ShareBillRequest.java b/src/main/java/com/baidubce/services/billing/model/bill/ShareBillRequest.java new file mode 100644 index 00000000..9e2dcfe0 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ShareBillRequest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.bill; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +/** + * request model for query share bill + */ +@Data +public class ShareBillRequest extends AbstractBceRequest { + /** + * the month of bill + * yyyy-MM + */ + private String month; + + /** + * the start day of bill + * tips: bill request time either month or startDay/endDay + */ + private String startDay; + + /** + * the end day of bill + * tips: bill request time either month or startDay/endDay + */ + private String endDay; + + /** + * the type of charging + * enum: prepay/postpay + */ + private String productType; + + /** + * the type of service + */ + private String serviceType; + + /** + * the account id you want to query + * tips: only the master account of organization group can set the parameter to query the sub account's bill + */ + private String queryAccountId; + + /** + * is show deduct price + */ + private Boolean showDeductPrice; + + /** + * is show controversial + */ + private Boolean showControversial; + + /** + * page number + */ + private Integer pageNo; + + /** + * page size + */ + private Integer pageSize; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/bill/ShareBillResponse.java b/src/main/java/com/baidubce/services/billing/model/bill/ShareBillResponse.java new file mode 100644 index 00000000..44c24cc3 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/bill/ShareBillResponse.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.bill; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; +import lombok.ToString; + +/** + * share bill response + */ +@Data +@ToString +public class ShareBillResponse extends AbstractBceResponse { + + /** + * 账户ID,若查询子账户,则为主账户ID + */ + private String accountId; + + /** + * 账户登录名,若查询子账户,则为主账户登录名 + */ + private String loginName; + + /** + * 子账户ID + */ + private String subAccountId; + + /** + * 子账户登录名 + */ + private String subLoginName; + + /** + * 子账户所在组织单元名 + */ + private String ouName; + + /** + * 账单时间,YYYY-MM + * 按月查询 + */ + private String billMonth; + + /** + * 页码,默认值为1 + */ + private Integer pageNo; + + /** + * 每页数量,默认值:20,最大值:100 + */ + private Integer pageSize; + + /** + * 当前查询条件总数 + */ + private Integer totalCount; + + /** + * 分摊账单 + */ + private List bills; +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalance.java b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalance.java new file mode 100644 index 00000000..9cb3a6a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalance.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import java.math.BigDecimal; + +/** + * response item for balance query + **/ +public class SupervisorBalance { + + /** + * accountId + */ + private String accountId; + /** + * the account type : MASTER_ACCOUNT or SUB_ACCOUNT + */ + private String accountType; + /** + * login name of the account + */ + private String loginName; + /** + * organization unit + */ + private String ouName; + /** + * comment + */ + private String comment; + /** + * cash balance + */ + private BigDecimal cashBalance; + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getAccountType() { + return accountType; + } + + public void setAccountType(String accountType) { + this.accountType = accountType; + } + + public String getLoginName() { + return loginName; + } + + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + public String getOuName() { + return ouName; + } + + public void setOuName(String ouName) { + this.ouName = ouName; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public BigDecimal getCashBalance() { + return cashBalance; + } + + public void setCashBalance(BigDecimal cashBalance) { + this.cashBalance = cashBalance; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalanceQueryRequest.java b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalanceQueryRequest.java new file mode 100644 index 00000000..1b6bfd77 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalanceQueryRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * request for balance query + **/ +public class SupervisorBalanceQueryRequest extends AbstractBceRequest { + + /** + * the accountId list to query cash balance + */ + private List accountIds; + + public List getAccountIds() { + return accountIds; + } + + public void setAccountIds(List accountIds) { + this.accountIds = accountIds; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalanceResponse.java b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalanceResponse.java new file mode 100644 index 00000000..3e2e1122 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalanceResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * response model for balance query + **/ +public class SupervisorBalanceResponse extends AbstractBceResponse { + + private List result; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalanceTransferRequest.java b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalanceTransferRequest.java new file mode 100644 index 00000000..a2dac1da --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorBalanceTransferRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import java.math.BigDecimal; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * request for balance transfer and gather + **/ +public class SupervisorBalanceTransferRequest extends AbstractBceRequest { + + /** + * the accountId of supervised + */ + private String supervisedId; + + /** + * want transfer amount + */ + private BigDecimal amount; + + public String getSupervisedId() { + return supervisedId; + } + + public void setSupervisedId(String supervisedId) { + this.supervisedId = supervisedId; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/SupervisorTransaction.java b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorTransaction.java new file mode 100644 index 00000000..772fcb97 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorTransaction.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import java.math.BigDecimal; + +/** + * balance transaction between supervised and supervisor + * + */ +public class SupervisorTransaction { + + /** + * inAccountId + */ + private String inAccountId; + + /** + * outAccountId + */ + private String outAccountId; + + /** + * trade amount + */ + private BigDecimal amount; + + /** + * opt time + */ + private String createTime; + + /** + * trade type :放款/收款 + */ + private String transTypeDesc; + + public String getInAccountId() { + return inAccountId; + } + + public void setInAccountId(String inAccountId) { + this.inAccountId = inAccountId; + } + + public String getOutAccountId() { + return outAccountId; + } + + public void setOutAccountId(String outAccountId) { + this.outAccountId = outAccountId; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getTransTypeDesc() { + return transTypeDesc; + } + + public void setTransTypeDesc(String transTypeDesc) { + this.transTypeDesc = transTypeDesc; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/SupervisorTransactionPageRequest.java b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorTransactionPageRequest.java new file mode 100644 index 00000000..75cb62a9 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorTransactionPageRequest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * page request + */ +public class SupervisorTransactionPageRequest extends AbstractBceRequest { + + /** + * transaction begin time + */ + private String beginTime; + + /** + * transaction end time + */ + private String endTime; + + private int pageNo = 1; + + private int pageSize = 10; + + public String getBeginTime() { + return beginTime; + } + + public void setBeginTime(String beginTime) { + this.beginTime = beginTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/SupervisorTransactionResponse.java b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorTransactionResponse.java new file mode 100644 index 00000000..1bb36eba --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/SupervisorTransactionResponse.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * supervisor transaction response model + **/ +public class SupervisorTransactionResponse extends AbstractBceResponse { + private Integer pageNo; + private Integer pageSize; + private Integer totalCount; + private String orderBy; + private String order; + private List result = new ArrayList(); + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/TransferResultResponse.java b/src/main/java/com/baidubce/services/billing/model/finance/TransferResultResponse.java new file mode 100644 index 00000000..97c17b5b --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/TransferResultResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import com.baidubce.model.AbstractBceResponse; + +/** + * response for balance transfer + **/ +public class TransferResultResponse extends AbstractBceResponse { + private boolean success; + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/UserBalanceQueryRequest.java b/src/main/java/com/baidubce/services/billing/model/finance/UserBalanceQueryRequest.java new file mode 100644 index 00000000..4d3a72b9 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/UserBalanceQueryRequest.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * request for user balance query + */ +public class UserBalanceQueryRequest extends AbstractBceRequest { + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/finance/UserBalanceQueryResponse.java b/src/main/java/com/baidubce/services/billing/model/finance/UserBalanceQueryResponse.java new file mode 100644 index 00000000..485792e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/finance/UserBalanceQueryResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.finance; + +import java.math.BigDecimal; + +import com.baidubce.model.AbstractBceResponse; + +/** + * response model for user balance query + */ +public class UserBalanceQueryResponse extends AbstractBceResponse { + + private BigDecimal cashBalance; + + public BigDecimal getCashBalance() { + return cashBalance; + } + + public void setCashBalance(BigDecimal cashBalance) { + this.cashBalance = cashBalance; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/AlterPrice.java b/src/main/java/com/baidubce/services/billing/model/order/AlterPrice.java new file mode 100644 index 00000000..f23fd476 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/AlterPrice.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.math.BigDecimal; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of alter price + */ +@Data +@ToString +public class AlterPrice { + + /** + * number + */ + private int num; + + /** + * the actual price + */ + private BigDecimal price; + + /** + * thr origin price + */ + private BigDecimal originPrice; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/AlterPriceList.java b/src/main/java/com/baidubce/services/billing/model/order/AlterPriceList.java new file mode 100644 index 00000000..fb154f77 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/AlterPriceList.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.util.List; + +import com.google.common.collect.Lists; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of the price list + */ +@Data +@ToString +public class AlterPriceList { + + /** + * the price change List + */ + List alterPrices = Lists.newArrayList(); + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/BidPrice.java b/src/main/java/com/baidubce/services/billing/model/order/BidPrice.java new file mode 100644 index 00000000..6a35b8d9 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/BidPrice.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.math.BigDecimal; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of bid price + */ +@Data +@ToString +public class BidPrice { + + /** + * the bidding model + */ + private String bidModel; + + /** + * the bid price + */ + private BigDecimal bidPrice; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/Cpt2Price.java b/src/main/java/com/baidubce/services/billing/model/order/Cpt2Price.java new file mode 100644 index 00000000..7c8daa25 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/Cpt2Price.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.math.BigDecimal; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of annual and monthly billing + */ +@Data +@ToString +public class Cpt2Price { + + /** + * the actual price + */ + private BigDecimal price = BigDecimal.ZERO; + + /** + * the catalog price + */ + private BigDecimal catalogPrice = BigDecimal.ZERO; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/Fee.java b/src/main/java/com/baidubce/services/billing/model/order/Fee.java new file mode 100644 index 00000000..a19714ed --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/Fee.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.math.BigDecimal; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of finance amount + */ +@Data +@ToString +public class Fee { + + /** + * the total price + **/ + private BigDecimal price; + + /** + * the amount of cash + **/ + private BigDecimal cash; + + /** + * the amount of coupon + **/ + private BigDecimal coupon; + + /** + * the amount of discount vouchers + **/ + private BigDecimal discountCoupon; + + /** + * the amount of discount + **/ + private BigDecimal discountAmount; + + /** + * the amount of cash paid by agent + **/ + private BigDecimal agentCash; + + /** + * the amount of rebate paid by agent + **/ + private BigDecimal agentRebateIn; + + /** + * the amount of cash equivalents + */ + private BigDecimal cashEquivalents; + + /** + * the amount of cash to refund + */ + private BigDecimal refundCash; + + /** + * the amount of coupon to refund + */ + private BigDecimal refundCoupon; + + /** + * the catalog price + */ + private BigDecimal catalogPrice; + + /** + * the alter price + */ + private BigDecimal alterPrice; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/Order.java b/src/main/java/com/baidubce/services/billing/model/order/Order.java new file mode 100644 index 00000000..30487ae0 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/Order.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.math.BigDecimal; +import java.util.List; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of order + */ +@Data +@ToString +public class Order { + /** + * the unique id of order + */ + private String uuid; + + /** + * the type of order + */ + private String type; + + /** + * user id + */ + private String accountId; + + /** + * the type of service. BCC, CDS, EIP, BCC__CDS, etc. + */ + private String serviceType; + + /** + * the type of billing. prepay/postpay/postpay__prepay + */ + private String productType; + + /** + * the type of sub product + * project(*), bandwidth, network,etc. + * generally for postpay, but project is for prepay + */ + private String subProductType; + + /** + * the order item list + */ + private List orderItems; + + /** + * the fee of the order + */ + private Fee orderFee; + + /** + * the price of the order + */ + private BigDecimal price; + + /** + * the status of the order + */ + private String status; + + /** + * the create time of order + */ + private String createTime; + + /** + * the time of paying the order + */ + private String purchaseTime; + + /** + * the last time of updating the order + */ + private String updateTime; + + /** + * the active time of the order for SHIFT_CHARGE order + */ + private String activeTime; + + /** + * the list of resource id + */ + private List resourceIds; + + /** + * the list of resource short id + */ + private List shortIds; + + /** + * the channel of paying the order + */ + private String payChannel; + + /** + * whether the order is payed automatically + */ + private Boolean isAutoPayed; + + /** + * whether the order is created by auto-renew service + */ + private Boolean autoRenewOrder; + + /** + * the finance price of the order + */ + private BigDecimal financePrice; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/OrderCancelRequest.java b/src/main/java/com/baidubce/services/billing/model/order/OrderCancelRequest.java new file mode 100644 index 00000000..3f2b7708 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/OrderCancelRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; +import lombok.ToString; + +/** + * The request of cancel orders. + * @author Liu Mengbo(liumengbo@baidu.com). + */ +@Data +@ToString +public class OrderCancelRequest extends AbstractBceRequest { + + /** + * The account id you want to cancel orders. + * tips: only the master account of organization group can set the parameter to cancel the sub account's order + */ + private String queryAccountId; + + /** + * the unique id of orders. + */ + private List orderIds; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public OrderCancelRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/OrderCancelResponse.java b/src/main/java/com/baidubce/services/billing/model/order/OrderCancelResponse.java new file mode 100644 index 00000000..8d602e90 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/OrderCancelResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; +import lombok.ToString; + +/** + * The response of cancel orders. + * @author Liu Mengbo(liumengbo@baidu.com). + */ +@Data +@ToString +public class OrderCancelResponse extends AbstractBceResponse { + + /** + * Whether the order is cancelled successfully. + */ + private Boolean success; +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/OrderItem.java b/src/main/java/com/baidubce/services/billing/model/order/OrderItem.java new file mode 100644 index 00000000..c01d8771 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/OrderItem.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.math.BigDecimal; +import java.util.List; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of order item + */ +@Data +@ToString +public class OrderItem { + + /** + * the type of service. BCC, CDS, EIP, BCC__CDS, etc. + */ + private String serviceType; + + /** + * the type of billing. prepay/postpay/postpay__prepay + */ + private String productType; + + /** + * the type of sub product + * project(*), bandwidth, network,etc. + * generally for postpay, but project is for prepay + */ + private String subProductType = ""; + + /** + * the region of the order item + */ + private String region; + + /** + * Identification used to distinguish different order items + */ + private String key; + + /** + * the configurations of the order item + */ + private List configurations; + + /** + * the resource number of the order item + */ + private int count; + + /** + * the time length of resources purchased + */ + private BigDecimal time = BigDecimal.ZERO; + + /** + * the unit of time + */ + private String timeUnit; + + /** + * the model of pricing detail + */ + private PricingDetail pricingDetail; + + /** + * the model of payment method + */ + private PaymentMethod paymentMethod; + + /** + * the release time of the resource + */ + private String releaseTime; + + /** + * the active time of the resource + */ + private String resourceActiveTime; + + /** + * the service type of merger purchase order + */ + private String combinedServiceType; + + /** + * the fee of the order item + */ + private Fee itemFee; + + /** + * the resource ids + */ + private List resourceIds; + + /** + * the list of resource short id + */ + private List shortIds; + + /** + * the resources' id and fee + */ + private List resourceIdAndFees; + + /** + * the start time of the resource + */ + private String resourceStartTime; + + /** + * the end time of the resource + */ + private String resourceEndTime; + + /** + * the catalog price + */ + private BigDecimal catalogPrice; + + /** + * the status of the order item + */ + private String status; + + /** + * the information of the related resources + */ + private List resourceMappings; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/OrderListRequest.java b/src/main/java/com/baidubce/services/billing/model/order/OrderListRequest.java new file mode 100644 index 00000000..71058e98 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/OrderListRequest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; +import lombok.ToString; + +/** + * the request of query order list + */ +@Data +@ToString +public class OrderListRequest extends AbstractBceRequest { + + /** + * the unique id of order + */ + private String uuid; + + /** + * the account id you want to query + * tips: only the master account of organization group can set the parameter to query the sub account's order + */ + private String queryAccountId; + + /** + * the type of order + */ + private String orderType; + + /** + * the status of order + */ + private String status; + + /** + * the type of service. BCC, CDS, EIP, BCC__CDS, etc. + */ + private String serviceType; + + /** + * the type of billing. prepay/postpay/postpay__prepay + */ + private String productType; + + /** + * the start time of the create time of order + */ + private String startTime; + + /** + * the end time of the create time of order + */ + private String endTime; + + /** + * whether the order is payed automatically + */ + private Boolean autoPayed; + + /** + * whether the order is created by auto-renew service + */ + private Boolean autoRenewOrder; + + /** + * page number, begin with 1 + */ + private Integer pageNo; + + /** + * page size , max(100) + */ + private Integer pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public OrderListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/OrderListResponse.java b/src/main/java/com/baidubce/services/billing/model/order/OrderListResponse.java new file mode 100644 index 00000000..e54afd3e --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/OrderListResponse.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; +import lombok.ToString; + +/** + * the response of query order list + */ +@Data +@ToString +public class OrderListResponse extends AbstractBceResponse { + + /** + * page number, min(1) + */ + Integer pageNo; + + /** + * page number, begin with 1 + */ + Integer pageSize; + + /** + * the total count of the query + */ + Integer totalCount; + + /** + * the order list + */ + private List orders = new ArrayList(); + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/OrderPaymentRequest.java b/src/main/java/com/baidubce/services/billing/model/order/OrderPaymentRequest.java new file mode 100644 index 00000000..eff55699 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/OrderPaymentRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; +import lombok.ToString; + +/** + * The request of order pay. + * @author Liu Mengbo(liumengbo@baidu.com). + */ +@Data +@ToString +public class OrderPaymentRequest extends AbstractBceRequest { + + /** + * The account id you want to pay order. + * tips: only the master account of organization group can set the parameter to pay the sub account's order + */ + private String queryAccountId; + + /** + * the unique id of order. + */ + private String orderId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public OrderPaymentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/OrderPaymentResponse.java b/src/main/java/com/baidubce/services/billing/model/order/OrderPaymentResponse.java new file mode 100644 index 00000000..38cb8c8a --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/OrderPaymentResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; +import lombok.ToString; + +/** + * The response of pay order. + * @author Liu Mengbo(liumengbo@baidu.com). + */ +@Data +@ToString +public class OrderPaymentResponse extends AbstractBceResponse { + + /** + * Whether the order is payment successfully. + */ + private Boolean success; +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/OrderUuidQueryRequest.java b/src/main/java/com/baidubce/services/billing/model/order/OrderUuidQueryRequest.java new file mode 100644 index 00000000..87da6cda --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/OrderUuidQueryRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; +import lombok.ToString; + +/** + * request of order query with uuid list + * @author fangyinyuan on 2023/2/14 + */ +@Data +@ToString +public class OrderUuidQueryRequest extends AbstractBceRequest { + + /** + * account id of the orders + */ + private String queryAccountId; + + /** + * uuid list of orders to query + */ + private List uuids; + + /** + * Configure request credential for the request. + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/PaymentMethod.java b/src/main/java/com/baidubce/services/billing/model/order/PaymentMethod.java new file mode 100644 index 00000000..b3e2b878 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/PaymentMethod.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of payment method + */ +@Data +@ToString +public class PaymentMethod { + + /** + * the rate of discount + */ + private Integer discountRate = 100; + + /** + * the coupon list + */ + private List coupons = new ArrayList(); + + /** + * the discount coupon list + */ + private List discountCoupons = new ArrayList(); + + @Data + public static class CouponInfo { + /** + * the id of the coupon + */ + private String couponId; + + /** + * the amount of the amount + */ + private BigDecimal amount; + } + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/PricingDetail.java b/src/main/java/com/baidubce/services/billing/model/order/PricingDetail.java new file mode 100644 index 00000000..a89a7440 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/PricingDetail.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import java.math.BigDecimal; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of pricing detail + */ +@Data +@ToString +public class PricingDetail { + + /** + * the model of annual and monthly billing + */ + private Cpt2Price cpt2Price; + + /** + * billing by minute for fixed configuration resource + */ + private BigDecimal cpt1Price; + + /** + * pricing strategy + */ + private String policy; + + /** + * Independent pricing + */ + private boolean customPrice = false; + + /** + * the alter price list + */ + private AlterPriceList alterPriceList; + + /** + * the model of bidding price + */ + private BidPrice bidPrice; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/ResourceIdAndFee.java b/src/main/java/com/baidubce/services/billing/model/order/ResourceIdAndFee.java new file mode 100644 index 00000000..02ced5e1 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/ResourceIdAndFee.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of resource id an fee + */ +@Data +@ToString +public class ResourceIdAndFee { + + /** + * the id of resource + */ + private String resourceId; + + /** + * the fee of resource + */ + private Fee resourceFee; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/order/ResourceMapping.java b/src/main/java/com/baidubce/services/billing/model/order/ResourceMapping.java new file mode 100644 index 00000000..bdff9a05 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/order/ResourceMapping.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.order; + +import lombok.Data; +import lombok.ToString; + +/** + * the model of resource information related to the order item + */ +@Data +@ToString +public class ResourceMapping { + + /** + * the unique key of the resource + */ + private String key; + + /** + * the id of resource instance + */ + private String id; + + /** + * the short id of the resource instance + */ + private String shortId; + + /** + * the status of resource instance + */ + private String status; + + /** + * the expire time of resource instance + */ + private String expiredTime; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/price/ChargeItem.java b/src/main/java/com/baidubce/services/billing/model/price/ChargeItem.java new file mode 100644 index 00000000..7769420b --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/price/ChargeItem.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.price; + +import java.math.BigDecimal; + +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * the model of charge item + */ +@Data +@AllArgsConstructor +public class ChargeItem { + + /** + * the name of charge item + */ + private String name; + + /** + * the value of charge item + */ + private String value; + + /** + * the number of charge item + */ + private BigDecimal scale; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/price/CpcPricingRequest.java b/src/main/java/com/baidubce/services/billing/model/price/CpcPricingRequest.java new file mode 100644 index 00000000..6c4f38e1 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/price/CpcPricingRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.price; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +/** + * request model for query price + */ +@Data +public class CpcPricingRequest extends AbstractBceRequest { + + /** + * the type of service + */ + private String serviceType; + + /** + * the sale type + */ + private String productType; + + /** + * the region of the price object + */ + private String region; + + /** + * the configurations of price object + */ + private Flavor flavor; + + /** + * the count of price object + */ + private int count; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public CpcPricingRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/price/CptPricingRequest.java b/src/main/java/com/baidubce/services/billing/model/price/CptPricingRequest.java new file mode 100644 index 00000000..62efecca --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/price/CptPricingRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.price; + +import lombok.Data; + +/** + * request model for query price + */ +@Data +public class CptPricingRequest extends CpcPricingRequest { + + /** + * the time length of purchase + */ + private String period; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/price/Flavor.java b/src/main/java/com/baidubce/services/billing/model/price/Flavor.java new file mode 100644 index 00000000..adc232eb --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/price/Flavor.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.price; + +import java.util.List; + +import lombok.Data; + +/** + * the model of configurations of price object + */ +@Data +public class Flavor { + + /** + * the list of charge items + */ + private List chargeItems; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/price/PricingQueryResponse.java b/src/main/java/com/baidubce/services/billing/model/price/PricingQueryResponse.java new file mode 100644 index 00000000..18555162 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/price/PricingQueryResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.price; + +import java.math.BigDecimal; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +/** + * the detail price information + */ +@Data +public class PricingQueryResponse extends AbstractBceResponse { + + /** + * the actual price + */ + private BigDecimal price; + + /** + * the catalog price + */ + private BigDecimal catalogPrice; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/renew/RenewResource.java b/src/main/java/com/baidubce/services/billing/model/renew/RenewResource.java new file mode 100644 index 00000000..8b23151e --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/renew/RenewResource.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.renew; + +import lombok.Data; +import lombok.ToString; + +/** + * auto renew resource + */ +@Data +@ToString +public class RenewResource { + + /** + * the service type + */ + private String serviceType; + + /** + * region + */ + private String region; + + /** + * the short id of the resource + */ + private String shortId; + + /** + * the id of the resource + */ + private String instanceId; + + /** + * the time that the resource expire + * yyyy-MM-ddTHH:mm:ssZ + */ + private String expireTime; + + /** + * whether the resource can set auto renew + */ + private Boolean aloneRenewEnable = Boolean.TRUE; + + /** + * whether the resource already set auto renew + */ + private Boolean alreadyRenewSet = Boolean.FALSE; + + /** + * the time unit of the auto renew rule + */ + private String renewTimeUnit; + + /** + * the time of the auto renew rule + */ + private Integer renewTime; + + /** + * the next time that renew the prepay resource + * yyyy-MM-dd CST + */ + private String nextRenewTime; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceDetail.java b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceDetail.java new file mode 100644 index 00000000..78bf2e78 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceDetail.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.renew; + +import lombok.Data; + +/** + * renew resource detail model + */ +@Data +public class RenewResourceDetail { + /** + * 区域 + */ + private String region; + + /** + * 产品名称 + */ + private String serviceType; + + /** + * 资源 name + */ + private String resourceName; + + /** + * 资源短 id + */ + private String shortId; + + /** + * 资源过期时间 + */ + private String expiredTime; + + /** + * 实例名称,即客户自定义名称 + */ + private String instanceName; + + /** + * 下次自动续费时长 + */ + private Integer renewTime; + + /** + * 下次自动续费时长单位:MONTH、YEAR、DAY + */ + private String renewTimeUnit; + + /** + * 是否允许续费 + */ + private Boolean enableRenew; + + /** + * 自动续费id + */ + private String autoRenewUuid; + + /** + * 禁止续费的原因 + * 如,已存在未完成订单,禁止续费、该资源已封禁、禁止续费 + */ + private String disableRenewReason; +} diff --git a/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceDetailRequest.java b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceDetailRequest.java new file mode 100644 index 00000000..3729d1f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceDetailRequest.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.renew; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; +import lombok.ToString; + +/** + * request model for renew resource detail list + */ +@Data +@ToString +public class RenewResourceDetailRequest extends AbstractBceRequest { + /** + * 最近多少天过期,<0 为不限制 + */ + @Min(-1) + @Max(90) + private int daysToExpiration; + + /** + * 区域 + */ + @NotNull + private String region; + + /** + * 产品名称 + */ + @NotNull + private String serviceType; + + /** + * 待查询实例的 ID(可能是长 id,也可能是短 id) + */ + private String instanceId; + + /** + * 实例名称 + */ + private String instanceName; + + /** + * 账户id + */ + private String accountId; + + /** + * 过滤已开通自动续费的规则 + */ + private String autoRenewStatus; + + /** + * 页码 + */ + @Min(1) + private Integer pageNo = 1; + + /** + * 页大小 + */ + @Min(1) + @Max(100) + private Integer pageSize = 100; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public RenewResourceDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceDetailResponse.java b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceDetailResponse.java new file mode 100644 index 00000000..6796ac3d --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceDetailResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.billing.model.renew; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; +import lombok.ToString; + +@Data +@ToString +public class RenewResourceDetailResponse extends AbstractBceResponse { + + private int totalCount; + + private int pageNo; + + private int pageSize; + + private List result; + + private String orderBy; + + private String order; + +} diff --git a/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceListRequest.java b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceListRequest.java new file mode 100644 index 00000000..32eb5d63 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceListRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.renew; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; +import lombok.ToString; + +/** + * the request to query auto renew resource list + */ +@Data +@ToString +public class RenewResourceListRequest extends AbstractBceRequest { + + /** + * the service type + */ + private String serviceType; + + /** + * region + */ + private String region; + + /** + * the days that the resource will expired + */ + private Integer expiredDays; + + /** + * the list of instance id or short id + */ + private List shortOrInstanceIds; + + /** + * the account id you want to query + * tips: only the master account of organization group can set the parameter to query the sub account's bill + */ + private String queryAccountId; + + /** + * page number + */ + private Integer pageNo; + + /** + * page size + */ + private Integer pageSize; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public RenewResourceListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceResponse.java b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceResponse.java new file mode 100644 index 00000000..d53dc0ea --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/renew/RenewResourceResponse.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.renew; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; +import lombok.ToString; + +/** + * the response to query auto renew resource list + */ +@Data +@ToString +public class RenewResourceResponse extends AbstractBceResponse { + + /** + * the account id + */ + private String accountId; + + /** + * the login name of the account id + */ + private String loginName; + + /** + * the sub account id + */ + private String subAccountId; + + /** + * the login name of sub account id + */ + private String subLoginName; + + /** + * the unit name of the sub account + */ + private String ouName; + + /** + * page number + */ + private Integer pageNo; + + /** + * page size + */ + private Integer pageSize; + + /** + * the total count of the bills + */ + private Integer totalCount; + + /** + * auto renew resource list + */ + private List resources = new ArrayList(); + +} diff --git a/src/main/java/com/baidubce/services/billing/model/renew/ResourceAutoRenewRequest.java b/src/main/java/com/baidubce/services/billing/model/renew/ResourceAutoRenewRequest.java new file mode 100644 index 00000000..e298c894 --- /dev/null +++ b/src/main/java/com/baidubce/services/billing/model/renew/ResourceAutoRenewRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.billing.model.renew; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; +import lombok.ToString; + +/** + * the request set auto renew rule + */ +@Data +@ToString +public class ResourceAutoRenewRequest extends AbstractBceRequest { + + /** + * the account id you want to set + * tips: only the master account of organization group can set the parameter to manage the sub account's resource + */ + private String accountId; + + /** + * the service type + */ + private String serviceType; + + /** + * region + */ + private String region; + + /** + * instance id of the resource + */ + private String instanceId; + + /** + * the time of the renew rule + * year :1-3 + * month : 1-9 + */ + private Integer renewTime; + + /** + * the time unit of the renew rule: month or year + */ + private String renewTimeUnit; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindTagsRequest with credentials. + */ + @Override + public ResourceAutoRenewRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/binaryparser/BinaryParserClient.java b/src/main/java/com/baidubce/services/binaryparser/BinaryParserClient.java new file mode 100644 index 00000000..a9c2eb59 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/BinaryParserClient.java @@ -0,0 +1,144 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law * or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.binaryparser; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.binaryparser.model.BinaryParser; +import com.baidubce.services.binaryparser.model.CreateBinaryParserRequest; +import com.baidubce.services.binaryparser.model.ListBinaryParserRequest; +import com.baidubce.services.binaryparser.model.ListBinaryParserResponse; +import com.baidubce.services.binaryparser.model.UpdateBinaryParserRequest; +import com.baidubce.services.binaryparser.model.NormalResponse; +import com.baidubce.services.iotalarm.model.CommonResponse; +import com.baidubce.services.iotalarm.model.UuidResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Client for binary parser service + * Created by yuanyoujun on 2017/9/2. + */ +public class BinaryParserClient extends AbstractBceClient { + private static final String ENDPOINT = "parser.iot.gz.baidubce.com"; + private static final String VERSION = "v1"; + private static final String BINPARSER = "binparser"; + private static final String CLEAR_ERROR = "clearerror"; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + private static final String DELETE = "delete"; + + private static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; + + public BinaryParserClient(BceClientConfiguration config) { + + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, HANDLERS); + } + + public BinaryParserClient(String accessKey, String secretKey) { + this(new BceClientConfiguration() + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)) + .withEndpoint(ENDPOINT)); + } + + public ListBinaryParserResponse list(ListBinaryParserRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.GET, BINPARSER); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + + return this.invokeHttpClient(internalRequest, ListBinaryParserResponse.class); + } + + public UuidResponse create(CreateBinaryParserRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.POST, BINPARSER); + return this.invokeHttpClient(internalRequest, UuidResponse.class); + } + + public BinaryParser get(String uuid) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.GET, BINPARSER, uuid); + return this.invokeHttpClient(internalRequest, BinaryParser.class); + } + + public CommonResponse update(UpdateBinaryParserRequest req, String uuid) { + InternalRequest internalRequest = + createRequest(req, HttpMethodName.PUT, BINPARSER, uuid); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse delete(String uuid) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, BINPARSER, uuid); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public NormalResponse clearError(String uuid) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.PUT, BINPARSER, uuid, CLEAR_ERROR); + return this.invokeHttpClient(internalRequest, NormalResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, request); + } + + return request; + } + + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/binaryparser/model/BinaryParser.java b/src/main/java/com/baidubce/services/binaryparser/model/BinaryParser.java new file mode 100644 index 00000000..346d5034 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/BinaryParser.java @@ -0,0 +1,108 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law * or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Response model for binary parser service + * Created by yuanyoujun on 2017/9/2. + */ +public class BinaryParser extends AbstractBceResponse { + private String uuid; + private String name; + private String endpoint; + private String inputTopic; + private String script; + private String outputTopic; + private String outputRuleid; + private Format format; + private String errorEvent; + private String errorTime; + + public String getOutputRuleid() { + return outputRuleid; + } + + public void setOutputRuleid(String outputRuleid) { + this.outputRuleid = outputRuleid; + } + + public Format getFormat() { + return format; + } + + public void setFormat(Format format) { + this.format = format; + } + + public String getErrorEvent() { + return errorEvent; + } + + public void setErrorEvent(String errorEvent) { + this.errorEvent = errorEvent; + } + + public String getErrorTime() { + return errorTime; + } + + public void setErrorTime(String errorTime) { + this.errorTime = errorTime; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getInputTopic() { + return inputTopic; + } + + public void setInputTopic(String inputTopic) { + this.inputTopic = inputTopic; + } + + public String getScript() { + return script; + } + + public void setScript(String script) { + this.script = script; + } + + public String getOutputTopic() { + return outputTopic; + } + + public void setOutputTopic(String outputTopic) { + this.outputTopic = outputTopic; + } +} diff --git a/src/main/java/com/baidubce/services/binaryparser/model/CreateBinaryParserRequest.java b/src/main/java/com/baidubce/services/binaryparser/model/CreateBinaryParserRequest.java new file mode 100644 index 00000000..179f6d7e --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/CreateBinaryParserRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law * or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * Request model for creating binary parser + * Created by yuanyoujun on 2017/9/2. + */ +public class CreateBinaryParserRequest extends GenericAccountRequest { + private String name; + private String endpoint; + private String inputTopic; + private String script; + private String outputTopic; + private String outputRuleid; + private Format format; + + public String getOutputRuleid() { + return outputRuleid; + } + + public void setOutputRuleid(String outputRuleid) { + this.outputRuleid = outputRuleid; + } + + public Format getFormat() { + return format; + } + + public void setFormat(Format format) { + this.format = format; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getInputTopic() { + return inputTopic; + } + + public void setInputTopic(String inputTopic) { + this.inputTopic = inputTopic; + } + + public String getScript() { + return script; + } + + public void setScript(String script) { + this.script = script; + } + + public String getOutputTopic() { + return outputTopic; + } + + public void setOutputTopic(String outputTopic) { + this.outputTopic = outputTopic; + } +} diff --git a/src/main/java/com/baidubce/services/binaryparser/model/Format.java b/src/main/java/com/baidubce/services/binaryparser/model/Format.java new file mode 100644 index 00000000..9648d916 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/Format.java @@ -0,0 +1,19 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law * or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.binaryparser.model; + +/** + * For BinaryParserClient + * Specify format can be sent in request + * Type: enumeration, with value BINARY, HEXSTRING + */ +public enum Format { + BINARY, + HEXSTRING +} diff --git a/src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserRequest.java b/src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserRequest.java new file mode 100644 index 00000000..4a2fe4ee --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law * or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * Request Model for querying binary parser list + * Created by yuanyoujun on 2017/9/2. + */ +public class ListBinaryParserRequest extends GenericAccountRequest { + private int pageNo = 1; + private int pageSize = 50; + + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserResponse.java b/src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserResponse.java new file mode 100644 index 00000000..345e2874 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserResponse.java @@ -0,0 +1,57 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law * or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response model for requesting binary parser list + * Created by yuanyoujun on 2017/9/2. + */ +public class ListBinaryParserResponse extends AbstractBceResponse { + private List result; + private int totalCount; + private int pageNo; + private int pageSize; + + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/binaryparser/model/NormalResponse.java b/src/main/java/com/baidubce/services/binaryparser/model/NormalResponse.java new file mode 100644 index 00000000..c1742204 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/NormalResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law * or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent normal response containing message field + * received from binary parser service + */ +public class NormalResponse extends AbstractBceResponse { + + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/com/baidubce/services/binaryparser/model/UpdateBinaryParserRequest.java b/src/main/java/com/baidubce/services/binaryparser/model/UpdateBinaryParserRequest.java new file mode 100644 index 00000000..1b5110f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/UpdateBinaryParserRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law * or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * Request model for updating binary parser + * Created by yuanyoujun on 2017/9/2. + */ +public class UpdateBinaryParserRequest extends GenericAccountRequest { + private String name; + private String inputTopic; + private String script; + private String outputTopic; + private Format format; + private String outputRuleid; + + public Format getFormat() { + return format; + } + + public void setFormat(Format format) { + this.format = format; + } + + public String getOutputRuleid() { + return outputRuleid; + } + + public void setOutputRuleid(String outputRuleid) { + this.outputRuleid = outputRuleid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getInputTopic() { + return inputTopic; + } + + public void setInputTopic(String inputTopic) { + this.inputTopic = inputTopic; + } + + public String getScript() { + return script; + } + + public void setScript(String script) { + this.script = script; + } + + public String getOutputTopic() { + return outputTopic; + } + + public void setOutputTopic(String outputTopic) { + this.outputTopic = outputTopic; + } +} diff --git a/src/main/java/com/baidubce/services/blb/AppBlbClient.java b/src/main/java/com/baidubce/services/blb/AppBlbClient.java new file mode 100644 index 00000000..bfdf086a --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/AppBlbClient.java @@ -0,0 +1,1586 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb; + +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import com.baidubce.services.blb.model.ListAppRsMountResponse; +import com.baidubce.services.blb.model.ListAppRsUnMountResponse; +import org.apache.commons.lang3.StringUtils; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.blb.model.AllListener; +import com.baidubce.services.blb.model.AppBackendPolicyRequest; +import com.baidubce.services.blb.model.AppBackendServer; +import com.baidubce.services.blb.model.AppIgRequest; +import com.baidubce.services.blb.model.AppIgResponse; +import com.baidubce.services.blb.model.AppIpGroupMember; +import com.baidubce.services.blb.model.AppIpGroupMemberRequest; +import com.baidubce.services.blb.model.AppPolicy; +import com.baidubce.services.blb.model.AppPolicyRequest; +import com.baidubce.services.blb.model.AppRsRequest; +import com.baidubce.services.blb.model.AppSgPortRequest; +import com.baidubce.services.blb.model.AppSgPortResponse; +import com.baidubce.services.blb.model.AppSgRequest; +import com.baidubce.services.blb.model.AppSgResponse; +import com.baidubce.services.blb.model.BlbDetailRequest; +import com.baidubce.services.blb.model.BlbInstance; +import com.baidubce.services.blb.model.BlbListenerAction; +import com.baidubce.services.blb.model.BlbListenerRequest; +import com.baidubce.services.blb.model.CreateAppPolicyResponse; +import com.baidubce.services.blb.model.CreateBlbRequest; +import com.baidubce.services.blb.model.CreateBlbResponse; +import com.baidubce.services.blb.model.DeleteAppPolicyRequest; +import com.baidubce.services.blb.model.DeleteBlbRequest; +import com.baidubce.services.blb.model.DeleteListenerRequest; +import com.baidubce.services.blb.model.EsgOperateRequest; +import com.baidubce.services.blb.model.HttpListener; +import com.baidubce.services.blb.model.HttpsListener; +import com.baidubce.services.blb.model.ListAllListenerRequest; +import com.baidubce.services.blb.model.ListAppIgRequest; +import com.baidubce.services.blb.model.ListAppIgResponse; +import com.baidubce.services.blb.model.ListAppIpGroupMemberRequest; +import com.baidubce.services.blb.model.ListAppIpGroupMemberResponse; +import com.baidubce.services.blb.model.ListAppPolicyRequest; +import com.baidubce.services.blb.model.ListAppPolicyResponse; +import com.baidubce.services.blb.model.ListAppRsRequest; +import com.baidubce.services.blb.model.ListAppRsResponse; +import com.baidubce.services.blb.model.ListAppSgRequest; +import com.baidubce.services.blb.model.ListAppSgResponse; +import com.baidubce.services.blb.model.ListBackendServerStatusRequest; +import com.baidubce.services.blb.model.ListBackendServerStatusResponse; +import com.baidubce.services.blb.model.ListBlbEsgResponse; +import com.baidubce.services.blb.model.ListBlbRequest; +import com.baidubce.services.blb.model.ListBlbResponse; +import com.baidubce.services.blb.model.ListBlbSgRequest; +import com.baidubce.services.blb.model.ListBlbSgResponse; +import com.baidubce.services.blb.model.ListListenerRequest; +import com.baidubce.services.blb.model.ListListenerResponse; +import com.baidubce.services.blb.model.ListenerConstant; +import com.baidubce.services.blb.model.ModifyBlbAttributesRequest; +import com.baidubce.services.blb.model.SgOperateRequest; +import com.baidubce.services.blb.model.SslListener; +import com.baidubce.services.blb.model.TcpListener; +import com.baidubce.services.blb.model.UdpListener; +import com.baidubce.services.tag.model.Tag; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Strings; + +/** + * Provides the client for accessing the Baidu Cloud network Service Baidu Application Load Balance (APPBLB). + */ +public class AppBlbClient extends AbstractBceClient { + + /** + * BLB API pathVersion + */ + private static final String VERSION = "v1"; + + private static final String PREFIX = "appblb"; + + private static final String CLIENT_TOKEN_IDENTIFY = "clientToken"; + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static final HttpResponseHandler[] blbHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on blb. + */ + public AppBlbClient() { + this(new BlbClientConfiguration()); + } + + /** + * Constructs a new blb client using the client configuration to access network. + * + * @param clientConfiguration The blb client configuration options controlling how this client + * connects to network (e.g. proxy settings, retry counts, etc). + */ + public AppBlbClient(BlbClientConfiguration clientConfiguration) { + super(clientConfiguration, blbHandlers); + } + + /** + * Creates and initializes a new request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * Create a blb with the specified options. + * + * @param name The name of blb + * @param desc The description of blb + * @param vpcId The vpcId of blb + * + * @return The response contains detail of the blb. + */ + public CreateBlbResponse createBlb(String name, String desc, String vpcId, String subnetId, List tags) { + return createBlb(new CreateBlbRequest().withName(name).withDesc(desc).withVpcId(vpcId) + .withSubnetId(subnetId).withTags(tags)); + } + + /** + * Create a blb with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param createBlbRequest The request containing all options for creating a blb. + * + * @return The response contains detail of the blb. + */ + public CreateBlbResponse createBlb(CreateBlbRequest createBlbRequest) { + checkNotNull(createBlbRequest, "request should not be null."); + if (Strings.isNullOrEmpty(createBlbRequest.getClientToken())) { + createBlbRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(createBlbRequest, HttpMethodName.POST, PREFIX); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, createBlbRequest.getClientToken()); + fillPayload(internalRequest, createBlbRequest); + return invokeHttpClient(internalRequest, CreateBlbResponse.class); + } + + /** + * Return a list of blbs with the specified options. + * + * @param address The address of the blb + * @param name The name of the blb. + * @param blbId The id of the blb. + * @param bccId The bcc id of the blb. + * + * @return The response containing a list of blbs owned by the specified options. + */ + public ListBlbResponse listBlbs(String address, String name, String blbId, String bccId) { + return listBlbs(new ListBlbRequest().withAddress(address).withName(name).withBlbId(blbId).withBccId(bccId)); + } + + /** + * Return a list of blbs with the specified options. + * + * @param listBlbRequest The request containing all options for listing blbs. + * + * @return The response containing a list of blbs with the specified options. + */ + public ListBlbResponse listBlbs(ListBlbRequest listBlbRequest) { + checkNotNull(listBlbRequest, "request should not be null."); + InternalRequest internalRequest = this.createRequest(listBlbRequest, HttpMethodName.GET, PREFIX); + if (StringUtils.isNotEmpty(listBlbRequest.getAddress())) { + internalRequest.addParameter("address", listBlbRequest.getAddress()); + } + if (StringUtils.isNotEmpty(listBlbRequest.getName())) { + internalRequest.addParameter("name", listBlbRequest.getName()); + } + if (StringUtils.isNotEmpty(listBlbRequest.getBlbId())) { + internalRequest.addParameter("blbId", listBlbRequest.getBlbId()); + } + if (StringUtils.isNotEmpty(listBlbRequest.getBccId())) { + internalRequest.addParameter("bccId", listBlbRequest.getBccId()); + } + if (listBlbRequest.getMarker() != null) { + internalRequest.addParameter("marker", listBlbRequest.getMarker()); + } + if (listBlbRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listBlbRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListBlbResponse.class); + } + + + /** + * Return the blb detail with the specified id. + * + * @param request The request containing all options for getting blb detail. + * + * @return The response containing the blb detail + */ + public BlbInstance blbDetail(BlbDetailRequest request) { + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, PREFIX, request.getBlbId()); + return invokeHttpClient(internalRequest, BlbInstance.class); + } + + /** + * Modifying the special attribute to new blb. + * + * @param blbId The id of the blb. + * @param name The name after modifying. + * @param desc The description after modifying. + */ + public void modifyBlbAttributes(String blbId, String name, String desc) { + modifyBlbAttributes(new ModifyBlbAttributesRequest(blbId, name, desc)); + } + + /** + * Modifying the special attribute to new blb. + * + * @param modifyBlbAttributesRequest The request containing all options for modifying a blb. + */ + public void modifyBlbAttributes(ModifyBlbAttributesRequest modifyBlbAttributesRequest) { + checkNotNull(modifyBlbAttributesRequest, "request should not be null."); + checkStringNotEmpty(modifyBlbAttributesRequest.getBlbId(), "request blbId should not be null."); + if (Strings.isNullOrEmpty(modifyBlbAttributesRequest.getClientToken())) { + modifyBlbAttributesRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(modifyBlbAttributesRequest, HttpMethodName.PUT, PREFIX, + modifyBlbAttributesRequest.getBlbId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, modifyBlbAttributesRequest.getClientToken()); + fillPayload(internalRequest, modifyBlbAttributesRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified blb. + * + * @param blbId The id of the blb to delete. + */ + public void deleteBlb(String blbId) { + deleteBlb(new DeleteBlbRequest(blbId)); + } + + /** + * Delete the specified blb. + * + * @param deleteBlbRequest The request containing all options for deleting blb. + */ + public void deleteBlb(DeleteBlbRequest deleteBlbRequest) { + checkNotNull(deleteBlbRequest, "request should not be null."); + if (Strings.isNullOrEmpty(deleteBlbRequest.getClientToken())) { + deleteBlbRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(deleteBlbRequest, HttpMethodName.DELETE, PREFIX, + deleteBlbRequest.getBlbId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, deleteBlbRequest.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create a listener with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param blbListenerRequest The request containing all options for creating a listener. + */ + public void createListener(BlbListenerRequest blbListenerRequest) { + checkNotNull(blbListenerRequest, "request should not be null."); + if (Strings.isNullOrEmpty(blbListenerRequest.getClientToken())) { + blbListenerRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(blbListenerRequest.getType(), "listener type should not be null."); + if (!ListenerConstant.LISTENER_SET.contains(blbListenerRequest.getType())) { + throw new IllegalArgumentException("listener type is illegal."); + } + InternalRequest internalRequest = this.createRequest(blbListenerRequest, HttpMethodName.POST, PREFIX, + blbListenerRequest.getBlbId(), blbListenerRequest.getType() + "listener"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, blbListenerRequest.getClientToken()); + fillPayload(internalRequest, blbListenerRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of tcp listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listTcpListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.TCP_LISTENER)); + response.setListenerList( + OBJECT_MAPPER.convertValue(response.getListenerList(), new TypeReference>() { + })); + return response; + } + + /** + * Return a list of udp listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listUdpListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.UDP_LISTENER)); + response.setListenerList(OBJECT_MAPPER.convertValue(response.getListenerList(), + new TypeReference>() { + })); + return response; + } + + /** + * Return a list of http listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listHttpListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.HTTP_LISTENER)); + response.setListenerList( + OBJECT_MAPPER.convertValue(response.getListenerList(), new TypeReference>() { + })); + return response; + } + + /** + * Return a list of https listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listHttpsListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.HTTPS_LISTENER)); + response.setListenerList( + OBJECT_MAPPER.convertValue(response.getListenerList(), new TypeReference>() { + })); + return response; + } + + /** + * Return a list of ssl listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listSslListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.SSL_LISTENER)); + response.setListenerList( + OBJECT_MAPPER.convertValue(response.getListenerList(), new TypeReference>() { + })); + return response; + } + + /** + * Return a list of all listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener. + */ + public ListListenerResponse listAllListener(String blbId) { + return listAllListener(new ListAllListenerRequest().withBlbId(blbId)); + } + + /** + * Return a list of listener with the specified options of blb. + * + * @param request The request containing all options for listing listeners of blb. + * + * @return The response containing a list of listener with the specified options. + */ + public ListListenerResponse listAllListener(ListAllListenerRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, PREFIX, + request.getBlbId(), "listener"); + if (request.getListenerPort() != 0) { + internalRequest.addParameter("listenerPort", String.valueOf(request.getListenerPort())); + } + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + ListListenerResponse response = invokeHttpClient(internalRequest, ListListenerResponse.class); + response.setListenerList(OBJECT_MAPPER.convertValue(response.getListenerList(), + new TypeReference>() { + })); + return response; + } + + /** + * Return a list of listener with the specified options. + * + * @param listListenerRequest The request containing all options for listing listeners. + * + * @return The response containing a list of listener with the specified options. + */ + public ListListenerResponse listListener(ListListenerRequest listListenerRequest) { + checkNotNull(listListenerRequest, "request should not be null."); + checkNotNull(listListenerRequest.getType(), "listener type should not be null."); + if (!ListenerConstant.LISTENER_SET.contains(listListenerRequest.getType())) { + throw new IllegalArgumentException("listener type is illegal."); + } + InternalRequest internalRequest = this.createRequest(listListenerRequest, HttpMethodName.GET, PREFIX, + listListenerRequest.getBlbId(), listListenerRequest.getType() + "listener"); + if (listListenerRequest.getListenerPort() != 0) { + internalRequest.addParameter("listenerPort", String.valueOf(listListenerRequest.getListenerPort())); + } + if (listListenerRequest.getMarker() != null) { + internalRequest.addParameter("marker", listListenerRequest.getMarker()); + } + if (listListenerRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listListenerRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListListenerResponse.class); + } + + /** + * Modifying the special attribute to new listener. + * + * @param modifyListenerAttributesRequest The request containing all options for modifying listener. + */ + public void modifyListenerAttributes(BlbListenerRequest modifyListenerAttributesRequest) { + checkNotNull(modifyListenerAttributesRequest, "request should not be null."); + if (Strings.isNullOrEmpty(modifyListenerAttributesRequest.getClientToken())) { + modifyListenerAttributesRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(modifyListenerAttributesRequest.getType(), "listener type should not be null."); + if (!ListenerConstant.LISTENER_SET.contains(modifyListenerAttributesRequest.getType())) { + throw new IllegalArgumentException("listener type is illegal."); + } + InternalRequest internalRequest = + this.createRequest(modifyListenerAttributesRequest, HttpMethodName.PUT, PREFIX, + modifyListenerAttributesRequest.getBlbId(), + modifyListenerAttributesRequest.getType() + "listener"); + internalRequest.addParameter("listenerPort", String.valueOf(modifyListenerAttributesRequest.getListenerPort())); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, modifyListenerAttributesRequest.getClientToken()); + fillPayload(internalRequest, modifyListenerAttributesRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified listener. + * + * @param blbId The blb id of the listener to delete. + * @param portList The ports of the listener to delete. + */ + public void deleteListener(String blbId, List portList) { + deleteListener(new DeleteListenerRequest(blbId, portList)); + } + + /** + * Delete the specified listener. + * + * @param deleteListenerRequest The request containing all options for deleting listener. + */ + public void deleteListener(DeleteListenerRequest deleteListenerRequest) { + checkNotNull(deleteListenerRequest, "request should not be null."); + if (Strings.isNullOrEmpty(deleteListenerRequest.getClientToken())) { + deleteListenerRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(deleteListenerRequest, HttpMethodName.PUT, PREFIX, + deleteListenerRequest.getBlbId(), "listener"); + internalRequest.addParameter(BlbListenerAction.batchdelete.name(), null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, deleteListenerRequest.getClientToken()); + fillPayload(internalRequest, deleteListenerRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Add backend servers to the specified blb appServerGroup. + * + * @param blbId The id of blb to add backend server. + * @param sgId The id of blb appServerGroup to add backend server. + * @param backendServerList The backend servers to add. + */ + public void createBlbRs(String blbId, String sgId, List backendServerList) { + createBlbRs(new AppSgRequest().withBlbId(blbId).withSgId(sgId).withBackendServerList(backendServerList)); + } + + /** + * Add backend servers to the specified blb appServerGroup. + * + * @param appSgRequest The request containing all backend servers for adding to the specified blb appServerGroup. + */ + public void createBlbRs(AppSgRequest appSgRequest) { + checkNotNull(appSgRequest, "request should not be null."); + checkNotNull(appSgRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(appSgRequest.getSgId(), "request sgId should not be null."); + checkNotNull(appSgRequest.getBackendServerList(), "request backendServerList should not be null."); + if (Strings.isNullOrEmpty(appSgRequest.getClientToken())) { + appSgRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appSgRequest, HttpMethodName.POST, PREFIX, + appSgRequest.getBlbId(), "blbrs"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appSgRequest.getClientToken()); + fillPayload(internalRequest, appSgRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Add member to the specified blb appIpGroup. + * + * @param blbId The id of blb to add ipGroup member. + * @param ipGroupId The id of blb appIpGroup to add member. + * @param memberList The ipGroup members to add. + */ + public void createIpGroupMember(String blbId, String ipGroupId, List memberList) { + createIpGroupMember(new AppIgRequest().withBlbId(blbId).withIpGroupId(ipGroupId).withMemberList(memberList)); + } + + /** + * Add member to the specified blb appIpGroup. + * + * @param appIgRequest The request containing all members for adding to the specified blb appIpGroup. + */ + public void createIpGroupMember(AppIgRequest appIgRequest) { + checkNotNull(appIgRequest, "request should not be null."); + checkNotNull(appIgRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(appIgRequest.getIpGroupId(), "request ipGroupId should not be null."); + checkNotNull(appIgRequest.getMemberList(), "request memberList should not be null."); + if (Strings.isNullOrEmpty(appIgRequest.getClientToken())) { + appIgRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appIgRequest, HttpMethodName.POST, PREFIX, + appIgRequest.getBlbId(), "ipgroup", "member"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appIgRequest.getClientToken()); + fillPayload(internalRequest, appIgRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of healthStatus of backend servers with the specified blb and listener port. + * + * @param blbId The id of the specified blb. + * @param listenerPort The specified listener port. + * + * @return The response containing a list healthStatus of backend servers. + */ + public ListBackendServerStatusResponse listBackendServerStatus(String blbId, int listenerPort) { + return listBackendServerStatus(new ListBackendServerStatusRequest(blbId, listenerPort)); + } + + /** + * Return a list of healthStatus of backend server with the specified blb and listener port. + * + * @param listBackendServerStatusRequest The request containing all options for listing backend server healtStatus. + * + * @return The response containing a list healthStatus of backend servers. + */ + public ListBackendServerStatusResponse listBackendServerStatus( + ListBackendServerStatusRequest listBackendServerStatusRequest) { + checkNotNull(listBackendServerStatusRequest, "request should not be null."); + InternalRequest internalRequest = + this.createRequest(listBackendServerStatusRequest, HttpMethodName.GET, PREFIX, + listBackendServerStatusRequest.getBlbId(), "backendserver"); + internalRequest.addParameter("listenerPort", String.valueOf(listBackendServerStatusRequest.getListenerPort())); + if (listBackendServerStatusRequest.getMarker() != null) { + internalRequest.addParameter("marker", listBackendServerStatusRequest.getMarker()); + } + if (listBackendServerStatusRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listBackendServerStatusRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListBackendServerStatusResponse.class); + } + + + /** + * Return a list of appServerGroup of the specified blb. + * + * @param blbId The id of the blb. + * @param name The name of the appServerGroup. + * + * @return The response containing a list of backend servers of the specified blb. + */ + public ListAppSgResponse listAppServerGroup(String blbId, String name) { + return listAppServerGroup(new ListAppSgRequest(blbId).withName(name)); + } + + /** + * Return a list of appServerGroup of the specified blb + * + * @param listAppSgRequest The request containing all options for listing appServerGroup. + * + * @return The response containing a list of appServerGroup of the specified blb. + */ + public ListAppSgResponse listAppServerGroup(ListAppSgRequest listAppSgRequest) { + checkNotNull(listAppSgRequest, "request should not be null."); + InternalRequest internalRequest = this.createRequest(listAppSgRequest, HttpMethodName.GET, PREFIX, + listAppSgRequest.getBlbId(), "appservergroup"); + if (StringUtils.isNotEmpty(listAppSgRequest.getName())) { + internalRequest.addParameter("name", listAppSgRequest.getName()); + } + if (listAppSgRequest.getMarker() != null) { + internalRequest.addParameter("marker", listAppSgRequest.getMarker()); + } + if (listAppSgRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listAppSgRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListAppSgResponse.class); + } + + /** + * Return a list of appIpGroup of the specified blb. + * + * @param blbId The id of the blb. + * @param name The name of the appIpGroup. + * + * @return The response containing a list of backend servers of the specified blb. + */ + public ListAppIgResponse listAppIpGroup(String blbId, String name) { + return listAppIpGroup(new ListAppIgRequest(blbId).withName(name)); + } + + /** + * Return a list of appIpGroup of the specified blb + * + * @param listAppIgRequest The request containing all options for listing appIpGroup. + * + * @return The response containing a list of appIpGroup of the specified blb. + */ + public ListAppIgResponse listAppIpGroup(ListAppIgRequest listAppIgRequest) { + checkNotNull(listAppIgRequest, "request should not be null."); + InternalRequest internalRequest = this.createRequest(listAppIgRequest, HttpMethodName.GET, PREFIX, + listAppIgRequest.getBlbId(), "ipgroup"); + if (StringUtils.isNotEmpty(listAppIgRequest.getName())) { + internalRequest.addParameter("name", listAppIgRequest.getName()); + } + if (listAppIgRequest.getMarker() != null) { + internalRequest.addParameter("marker", listAppIgRequest.getMarker()); + } + if (listAppIgRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listAppIgRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListAppIgResponse.class); + } + + /** + * Return a list of backend server of the specified blb appServerGroup. + * + * @param blbId The id of the blb. + * @param sgId The id of the appServerGroup. + * + * @return The response containing a list of backend servers of the specified blb appServerGroup. + */ + public ListAppRsMountResponse listBlbRsMount(String blbId, String sgId) { + return listBlbRsMount(new ListAppRsRequest(blbId).withSgId(sgId)); + } + + /** + * Return a list of backend server of the specified blb appServerGroup + * + * @param listAppRsRequest The request containing all options for listing backend server. + * + * @return The response containing a list of backend servers of the specified blb appServerGroup. + */ + public ListAppRsMountResponse listBlbRsMount(ListAppRsRequest listAppRsRequest) { + checkNotNull(listAppRsRequest, "request should not be null."); + checkNotNull(listAppRsRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(listAppRsRequest.getSgId(), "request sgId should not be null."); + InternalRequest internalRequest = this.createRequest(listAppRsRequest, HttpMethodName.GET, PREFIX, + listAppRsRequest.getBlbId(), "blbrsmount"); + internalRequest.addParameter("sgId", listAppRsRequest.getSgId()); + return invokeHttpClient(internalRequest, ListAppRsMountResponse.class); + + } + + /** + * Return a list of backend server of the specified blb appServerGroup. + * + * @param blbId The id of the blb. + * @param sgId The id of the appServerGroup. + * + * @return The response containing a list of backend servers of the specified blb appServerGroup. + */ + public ListAppRsUnMountResponse listBlbRsUnMount(String blbId, String sgId) { + return listBlbRsUnMount(new ListAppRsRequest(blbId).withSgId(sgId)); + } + + /** + * Return a list of backend server of the specified blb appServerGroup + * + * @param listAppRsRequest The request containing all options for listing backend server. + * + * @return The response containing a list of backend servers of the specified blb appServerGroup. + */ + public ListAppRsUnMountResponse listBlbRsUnMount(ListAppRsRequest listAppRsRequest) { + checkNotNull(listAppRsRequest, "request should not be null."); + checkNotNull(listAppRsRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(listAppRsRequest.getSgId(), "request sgId should not be null."); + InternalRequest internalRequest = this.createRequest(listAppRsRequest, HttpMethodName.GET, PREFIX, + listAppRsRequest.getBlbId(), "blbrsunmount"); + internalRequest.addParameter("sgId", listAppRsRequest.getSgId()); + return invokeHttpClient(internalRequest, ListAppRsUnMountResponse.class); + + } + + /** + * Return a list of backend server of the specified blb appServerGroup. + * + * @param blbId The id of the blb. + * @param sgId The id of the appServerGroup. + * + * @return The response containing a list of backend servers of the specified blb appServerGroup. + */ + public ListAppRsResponse listBlbRs(String blbId, String sgId) { + return listBlbRs(new ListAppRsRequest(blbId).withSgId(sgId)); + } + + /** + * Return a list of backend server of the specified blb appServerGroup + * + * @param listAppRsRequest The request containing all options for listing backend server. + * + * @return The response containing a list of backend servers of the specified blb appServerGroup. + */ + public ListAppRsResponse listBlbRs(ListAppRsRequest listAppRsRequest) { + checkNotNull(listAppRsRequest, "request should not be null."); + checkNotNull(listAppRsRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(listAppRsRequest.getSgId(), "request sgId should not be null."); + InternalRequest internalRequest = this.createRequest(listAppRsRequest, HttpMethodName.GET, PREFIX, + listAppRsRequest.getBlbId(), "blbrs"); + internalRequest.addParameter("sgId", listAppRsRequest.getSgId()); + if (listAppRsRequest.getMarker() != null) { + internalRequest.addParameter("marker", listAppRsRequest.getMarker()); + } + if (listAppRsRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listAppRsRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListAppRsResponse.class); + + } + + /** + * Return a list of member of the specified blb appIpGroup. + * + * @param blbId The id of the blb. + * @param ipGroupId The id of the appIpGroup. + * + * @return The response containing a list of member of the specified blb appIpGroup. + */ + public ListAppIpGroupMemberResponse listIpGroupMember(String blbId, String ipGroupId) { + return listIpGroupMember(new ListAppIpGroupMemberRequest(blbId).withIpGroupId(ipGroupId)); + } + + /** + * Return a list of member of the specified blb appIpGroup + * + * @param listAppIpGroupMemberRequest The request containing all options for listing member. + * + * @return The response containing a list of member of the specified blb appIpGroup. + */ + public ListAppIpGroupMemberResponse listIpGroupMember(ListAppIpGroupMemberRequest listAppIpGroupMemberRequest) { + checkNotNull(listAppIpGroupMemberRequest, "request should not be null."); + checkNotNull(listAppIpGroupMemberRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(listAppIpGroupMemberRequest.getIpGroupId(), "request ipGroupId should not be null."); + InternalRequest internalRequest = this.createRequest(listAppIpGroupMemberRequest, HttpMethodName.GET, PREFIX, + listAppIpGroupMemberRequest.getBlbId(), "ipgroup", "member"); + internalRequest.addParameter("ipGroupId", listAppIpGroupMemberRequest.getIpGroupId()); + if (listAppIpGroupMemberRequest.getMarker() != null) { + internalRequest.addParameter("marker", listAppIpGroupMemberRequest.getMarker()); + } + if (listAppIpGroupMemberRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listAppIpGroupMemberRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListAppIpGroupMemberResponse.class); + + } + + + + + /** + * Modifying the special backend servers of the specified blb appServerGroup. + * + * @param blbId The id of the specified blb. + * @param sgId The id of blb appServerGroup. + * @param backendServerList The backend servers to modifying. + */ + public void modifyBlbRs(String blbId, String sgId, List backendServerList) { + modifyBlbRs(new AppSgRequest().withBlbId(blbId).withSgId(sgId).withBackendServerList(backendServerList)); + } + + /** + * Modifying the special backend servers of the specified blb appServerGroup. + * + * @param appSgRequest The request containing all options for modifying backend servers. + */ + public void modifyBlbRs(AppSgRequest appSgRequest) { + checkNotNull(appSgRequest, "request should not be null."); + checkNotNull(appSgRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(appSgRequest.getSgId(), "request sgId should not be null."); + checkNotNull(appSgRequest.getBackendServerList(), "request backendServerList should not be null."); + if (Strings.isNullOrEmpty(appSgRequest.getClientToken())) { + appSgRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appSgRequest, HttpMethodName.PUT, PREFIX, + appSgRequest.getBlbId(), "blbrs"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appSgRequest.getClientToken()); + fillPayload(internalRequest, appSgRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Modifying the special members of the specified blb appIpGroup. + * + * @param blbId The id of the specified blb. + * @param ipGroupId The id of blb appIpGroup. + * @param memberList The ipGroup members to modifying. + */ + public void modifyIpGroupMember(String blbId, String ipGroupId, List memberList) { + modifyIpGroupMember(new AppIgRequest().withBlbId(blbId).withIpGroupId(ipGroupId).withMemberList(memberList)); + } + + /** + * Modifying the special members of the specified blb appIpGroup. + * + * @param appIgRequest The request containing all options for modifying members. + */ + public void modifyIpGroupMember(AppIgRequest appIgRequest) { + checkNotNull(appIgRequest, "request should not be null."); + checkNotNull(appIgRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(appIgRequest.getIpGroupId(), "request ipGroupId should not be null."); + checkNotNull(appIgRequest.getMemberList(), "request memberList should not be null."); + if (Strings.isNullOrEmpty(appIgRequest.getClientToken())) { + appIgRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appIgRequest, HttpMethodName.PUT, PREFIX, + appIgRequest.getBlbId(), "ipgroup", "member"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appIgRequest.getClientToken()); + fillPayload(internalRequest, appIgRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Delete the specified backend server from the specified blb appServerGroup. + * + * @param blbId The id of the blb. + * @param sgId The id of the appServerGroup. + * @param backendServerIdList The id list of the backend server id to deleting. + */ + public void deleteBlbRs(String blbId, String sgId, List backendServerIdList) { + deleteBlbRs(new AppRsRequest().withBlbId(blbId).withSgId(sgId) + .withBackendServerIdList(backendServerIdList)); + } + + /** + * Delete the specified backend server from the specified blb appServerGroup. + * + * @param appRsRequest The request containing all options for deleting backend server from the specified blb appServerGroup. + */ + public void deleteBlbRs(AppRsRequest appRsRequest) { + checkNotNull(appRsRequest, "request should not be null."); + checkNotNull(appRsRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(appRsRequest.getSgId(), "request sgId should not be null."); + checkNotNull(appRsRequest.getBackendServerIdList(), "request backendServerIdList should not be null."); + if (Strings.isNullOrEmpty(appRsRequest.getClientToken())) { + appRsRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appRsRequest, HttpMethodName.PUT, PREFIX, + appRsRequest.getBlbId(), "blbrs"); + internalRequest.addParameter("batchdelete", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appRsRequest.getClientToken()); + fillPayload(internalRequest, appRsRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified member from the specified blb appIpGroup. + * + * @param blbId The id of the blb. + * @param ipGroupId The id of the appIpGroup. + * @param memberIdList The id list of the member id to deleting. + */ + public void deleteIpGroupMember(String blbId, String ipGroupId, List memberIdList) { + deleteIpGroupMember(new AppIpGroupMemberRequest().withBlbId(blbId).withIpGroupId(ipGroupId) + .withMemberIdList(memberIdList)); + } + + /** + * Delete the specified member from the specified blb appIpGroup. + * + * @param appIpGroupMemberRequest The request containing all options for deleting member + * from the specified blb appIpGroup. + */ + public void deleteIpGroupMember(AppIpGroupMemberRequest appIpGroupMemberRequest) { + checkNotNull(appIpGroupMemberRequest, "request should not be null."); + checkNotNull(appIpGroupMemberRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(appIpGroupMemberRequest.getIpGroupId(), "request ipGroupId should not be null."); + checkNotNull(appIpGroupMemberRequest.getMemberIdList(), "request memberIdList should not be null."); + if (Strings.isNullOrEmpty(appIpGroupMemberRequest.getClientToken())) { + appIpGroupMemberRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appIpGroupMemberRequest, HttpMethodName.PUT, PREFIX, + appIpGroupMemberRequest.getBlbId(), "ipgroup", "member"); + internalRequest.addParameter("delete", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appIpGroupMemberRequest.getClientToken()); + fillPayload(internalRequest, appIpGroupMemberRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Create an appServerGroup with the specified options. + * + * @param blbId The id of blb + * @param name The name of appServerGroup + * @param desc The description of appServerGroup + * @param backendServerList The backendServers of appServerGroup + * + * @return The response contains detail of the appServerGroup. + */ + public AppSgResponse createAppServerGroup(String blbId, String name, String desc + , List backendServerList) { + return createAppServerGroup(new AppSgRequest().withBlbId(blbId).withName(name).withDesc(desc) + .withBackendServerList(backendServerList)); + } + + /** + * Create an appServerGroup with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param appSgRequest The request containing all options for creating a appSg. + */ + public AppSgResponse createAppServerGroup(AppSgRequest appSgRequest) { + checkNotNull(appSgRequest, "request should not be null."); + checkNotNull(appSgRequest.getBlbId(), "request blbId should not be null."); + if (Strings.isNullOrEmpty(appSgRequest.getClientToken())) { + appSgRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appSgRequest, HttpMethodName.POST, PREFIX, + appSgRequest.getBlbId(), "appservergroup"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appSgRequest.getClientToken()); + fillPayload(internalRequest, appSgRequest); + return invokeHttpClient(internalRequest, AppSgResponse.class); + } + + + /** + * Create an appIpGroup with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param appIgRequest The request containing all options for creating an appIg. + */ + public AppIgResponse createAppIpGroup(AppIgRequest appIgRequest) { + checkNotNull(appIgRequest, "request should not be null."); + checkNotNull(appIgRequest.getBlbId(), "request blbId should not be null."); + if (Strings.isNullOrEmpty(appIgRequest.getClientToken())) { + appIgRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appIgRequest, HttpMethodName.POST, PREFIX, + appIgRequest.getBlbId(), "ipgroup"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appIgRequest.getClientToken()); + fillPayload(internalRequest, appIgRequest); + return invokeHttpClient(internalRequest, AppIgResponse.class); + } + + + /** + * Create an appIpGroup with the specified options. + * + * @param blbId The id of blb + * @param name The name of appIpGroup + * @param desc The description of appIpGroup + * @param memberList The backen of appIpGroup + * + * @return The response contains detail of the appIpGroup. + */ + public AppIgResponse createAppIpGroup(String blbId, String name, String desc + , List memberList) { + return createAppIpGroup(new AppIgRequest().withBlbId(blbId).withName(name).withDesc(desc) + .withMemberList(memberList)); + } + + /** + * Update a appServerGroup with the specified options. + * + * @param blbId The id of blb + * @param sgId The id of appServerGroup + * @param name The name of appServerGroup + * @param desc The description of appServerGroup + * + */ + public void modifyAppServerGroupAttributes(String blbId, String sgId, String name, String desc) { + modifyAppServerGroupAttributes(new AppSgRequest().withBlbId(blbId).withSgId(sgId) + .withName(name).withDesc(desc)); + } + + + /** + * Modifying the special attribute to new appServerGroup. + * + * @param appSgRequest The request containing all options for modifying appSgRequest. + */ + public void modifyAppServerGroupAttributes(AppSgRequest appSgRequest) { + checkNotNull(appSgRequest, "request should not be null."); + if (Strings.isNullOrEmpty(appSgRequest.getClientToken())) { + appSgRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(appSgRequest.getBlbId(), "blbId should not be null."); + checkNotNull(appSgRequest.getSgId(), "sgId should not be null."); + InternalRequest internalRequest = + this.createRequest(appSgRequest, HttpMethodName.PUT, PREFIX, + appSgRequest.getBlbId(), "appservergroup"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appSgRequest.getClientToken()); + fillPayload(internalRequest, appSgRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update an appIpGroup with the specified options. + * + * @param blbId The id of blb + * @param ipGroupId The id of appIpGroup + * @param name The name of appIpGroup + * @param desc The description of appIpGroup + * + */ + public void modifyAppIpGroupAttributes(String blbId, String ipGroupId, String name, String desc) { + modifyAppIpGroupAttributes(new AppIgRequest().withBlbId(blbId).withIpGroupId(ipGroupId) + .withName(name).withDesc(desc)); + } + + + /** + * Modifying the special attribute to new appIpGroup. + * + * @param appIgRequest The request containing all options for modifying appIgRequest. + */ + public void modifyAppIpGroupAttributes(AppIgRequest appIgRequest) { + checkNotNull(appIgRequest, "request should not be null."); + if (Strings.isNullOrEmpty(appIgRequest.getClientToken())) { + appIgRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(appIgRequest.getBlbId(), "blbId should not be null."); + checkNotNull(appIgRequest.getIpGroupId(), "ipGroupId should not be null."); + InternalRequest internalRequest = + this.createRequest(appIgRequest, HttpMethodName.PUT, PREFIX, + appIgRequest.getBlbId(), "ipgroup"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appIgRequest.getClientToken()); + fillPayload(internalRequest, appIgRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + + + /** + * Delete a appServerGroup with the specified options. + * + * @param blbId The id of blb + * @param sgId The id of appServerGroup + * + */ + public void deleteAppServerGroup(String blbId, String sgId) { + deleteAppServerGroup(new AppSgRequest().withBlbId(blbId).withSgId(sgId)); + } + + + /** + * Delete the special appServerGroup. + * + * @param appSgRequest The request containing all options for deleting appSgRequest. + */ + public void deleteAppServerGroup(AppSgRequest appSgRequest) { + checkNotNull(appSgRequest, "request should not be null."); + if (Strings.isNullOrEmpty(appSgRequest.getClientToken())) { + appSgRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(appSgRequest.getBlbId(), "blbId should not be null."); + checkNotNull(appSgRequest.getSgId(), "sgId should not be null."); + InternalRequest internalRequest = this.createRequest(appSgRequest, HttpMethodName.PUT + , PREFIX, appSgRequest.getBlbId(), "appservergroup"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appSgRequest.getClientToken()); + internalRequest.addParameter("delete", null); + fillPayload(internalRequest, appSgRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete an appIpGroup with the specified options. + * + * @param blbId The id of blb + * @param ipGroupId The id of appIpGroup + * + */ + public void deleteAppIpGroup(String blbId, String ipGroupId) { + deleteAppIpGroup(new AppIgRequest().withBlbId(blbId).withIpGroupId(ipGroupId)); + } + + + /** + * Delete the special appIpGroup. + * + * @param appIgRequest The request containing all options for deleting appIpGroup. + */ + public void deleteAppIpGroup(AppIgRequest appIgRequest) { + checkNotNull(appIgRequest, "request should not be null."); + if (Strings.isNullOrEmpty(appIgRequest.getClientToken())) { + appIgRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(appIgRequest.getBlbId(), "blbId should not be null."); + checkNotNull(appIgRequest.getIpGroupId(), "ipGroupId should not be null."); + InternalRequest internalRequest = this.createRequest(appIgRequest, HttpMethodName.PUT + , PREFIX, appIgRequest.getBlbId(), "ipgroup"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appIgRequest.getClientToken()); + internalRequest.addParameter("delete", null); + fillPayload(internalRequest, appIgRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create an appIpGroupBackendPolicy with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param appBackendPolicyRequest The request containing all options for creating an appIpGroupBackendPolicy. + */ + public void createAppIpGroupBackendPolicy(AppBackendPolicyRequest appBackendPolicyRequest) { + checkNotNull(appBackendPolicyRequest, "request should not be null."); + checkNotNull(appBackendPolicyRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(appBackendPolicyRequest.getIpGroupId(), "request ipGroupId should not be null."); + checkNotNull(appBackendPolicyRequest.getType(), "request type should not be null."); + if (Strings.isNullOrEmpty(appBackendPolicyRequest.getClientToken())) { + appBackendPolicyRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appBackendPolicyRequest, HttpMethodName.POST, PREFIX, + appBackendPolicyRequest.getBlbId(), "ipgroup", "backendpolicy"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appBackendPolicyRequest.getClientToken()); + fillPayload(internalRequest, appBackendPolicyRequest); + invokeHttpClient(internalRequest, AppSgPortResponse.class); + } + + /** + * Modifying the special attribute to new appIpGroupBackendPolicy. + * + * @param appBackendPolicyRequest The request containing all options for modifying appIpGroupBackendPolicy. + */ + public void modifyAppIpGroupBackendPolicyAttributes(AppBackendPolicyRequest appBackendPolicyRequest) { + checkNotNull(appBackendPolicyRequest, "request should not be null."); + if (Strings.isNullOrEmpty(appBackendPolicyRequest.getClientToken())) { + appBackendPolicyRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(appBackendPolicyRequest.getBlbId(), "blbId should not be null."); + checkNotNull(appBackendPolicyRequest.getIpGroupId(), "ipGroupId should not be null."); + checkNotNull(appBackendPolicyRequest.getId(), "id should not be null."); + InternalRequest internalRequest = + this.createRequest(appBackendPolicyRequest, HttpMethodName.PUT, PREFIX, + appBackendPolicyRequest.getBlbId(), "ipgroup", "backendpolicy"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appBackendPolicyRequest.getClientToken()); + fillPayload(internalRequest, appBackendPolicyRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete an appIpGroupBackendPolicy with the specified options. + * + * @param blbId The id of blb + * @param ipGroupId The id of appServerGroup + * @param backendPolicyIdList The id of appIpGroupBackendPolicy list + * + */ + public void deleteAppIpGroupBackendPolicy(String blbId, String ipGroupId, List backendPolicyIdList) { + deleteAppIpGroupBackendPolicy(new AppBackendPolicyRequest().withBlbId(blbId) + .withIpGroupId(ipGroupId).withBackendPolicyIdList(backendPolicyIdList)); + } + + + /** + * Delete the special AppBackendPolicy. + * + * @param appBackendPolicyRequest The request containing all options for deleting appBackendPolicy. + */ + public void deleteAppIpGroupBackendPolicy(AppBackendPolicyRequest appBackendPolicyRequest) { + checkNotNull(appBackendPolicyRequest, "request should not be null."); + if (Strings.isNullOrEmpty(appBackendPolicyRequest.getClientToken())) { + appBackendPolicyRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(appBackendPolicyRequest.getBlbId(), "blbId should not be null."); + checkNotNull(appBackendPolicyRequest.getIpGroupId(), "ipGroupId should not be null."); + checkNotNull(appBackendPolicyRequest.getBackendPolicyIdList(), "backendPolicyIdList should not be null."); + InternalRequest internalRequest = this.createRequest(appBackendPolicyRequest, HttpMethodName.PUT + , PREFIX, appBackendPolicyRequest.getBlbId(), "ipgroup", "backendpolicy"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appBackendPolicyRequest.getClientToken()); + internalRequest.addParameter("delete", null); + fillPayload(internalRequest, appBackendPolicyRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Create a appServerGroupPort with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param appSgPortRequest The request containing all options for creating a appSgPort. + */ + public AppSgPortResponse createAppServerGroupPort(AppSgPortRequest appSgPortRequest) { + checkNotNull(appSgPortRequest, "request should not be null."); + checkNotNull(appSgPortRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(appSgPortRequest.getSgId(), "request sgId should not be null."); + checkNotNull(appSgPortRequest.getPort(), "request port should not be null."); + checkNotNull(appSgPortRequest.getType(), "request type should not be null."); + if (Strings.isNullOrEmpty(appSgPortRequest.getClientToken())) { + appSgPortRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appSgPortRequest, HttpMethodName.POST, PREFIX, + appSgPortRequest.getBlbId(), "appservergroupport"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appSgPortRequest.getClientToken()); + fillPayload(internalRequest, appSgPortRequest); + return invokeHttpClient(internalRequest, AppSgPortResponse.class); + } + + + /** + * Modifying the special attribute to new appServerGroupPort. + * + * @param appSgPortRequest The request containing all options for modifying appSgPortRequest. + */ + public void modifyAppServerGroupPortAttributes(AppSgPortRequest appSgPortRequest) { + checkNotNull(appSgPortRequest, "request should not be null."); + if (Strings.isNullOrEmpty(appSgPortRequest.getClientToken())) { + appSgPortRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(appSgPortRequest.getBlbId(), "blbId should not be null."); + checkNotNull(appSgPortRequest.getSgId(), "sgId should not be null."); + checkNotNull(appSgPortRequest.getPortId(), "portId should not be null."); + InternalRequest internalRequest = + this.createRequest(appSgPortRequest, HttpMethodName.PUT, PREFIX, + appSgPortRequest.getBlbId(), "appservergroupport"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appSgPortRequest.getClientToken()); + fillPayload(internalRequest, appSgPortRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete a appServerGroup with the specified options. + * + * @param blbId The id of blb + * @param sgId The id of appServerGroup + * @param portIdList The id of appServerGroupPort list + * + */ + public void deleteAppServerGroupPort(String blbId, String sgId, List portIdList) { + deleteAppServerGroupPort(new AppSgPortRequest().withBlbId(blbId).withSgId(sgId).withPortIdList(portIdList)); + } + + + /** + * Delete the special appServerGroupPort. + * + * @param appSgPortRequest The request containing all options for deleting AppSgPortRequest. + */ + public void deleteAppServerGroupPort(AppSgPortRequest appSgPortRequest) { + checkNotNull(appSgPortRequest, "request should not be null."); + if (Strings.isNullOrEmpty(appSgPortRequest.getClientToken())) { + appSgPortRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(appSgPortRequest.getBlbId(), "blbId should not be null."); + checkNotNull(appSgPortRequest.getSgId(), "sgId should not be null."); + checkNotNull(appSgPortRequest.getPortIdList(), "portIdList should not be null."); + InternalRequest internalRequest = this.createRequest(appSgPortRequest, HttpMethodName.PUT + , PREFIX, appSgPortRequest.getBlbId(), "appservergroupport"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appSgPortRequest.getClientToken()); + internalRequest.addParameter("batchdelete", null); + fillPayload(internalRequest, appSgPortRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Create a policy with the specified options. + * + * @param blbId The id of blb + * @param listenerPort The listenerPort of policy + * @param type The listenerType of Policy + * @param appPolicyVos The appPolicyVos of policy + * + */ + public CreateAppPolicyResponse createPolicys(String blbId, Integer listenerPort, String type, + List appPolicyVos) { + return createPolicys(new AppPolicyRequest().withBlbId(blbId).withListenerPort(listenerPort).withType(type) + .withAppPolicyVos(appPolicyVos)); + } + + /** + * Create a policy with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param appPolicyRequest The request containing all options for creating a policy. + */ + public CreateAppPolicyResponse createPolicys(AppPolicyRequest appPolicyRequest) { + checkNotNull(appPolicyRequest, "request should not be null."); + checkNotNull(appPolicyRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(appPolicyRequest.getListenerPort(), "request listenerPort should not be null."); + checkNotNull(appPolicyRequest.getAppPolicyVos(), "request appPolicyVos should not be null."); + if (Strings.isNullOrEmpty(appPolicyRequest.getClientToken())) { + appPolicyRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(appPolicyRequest, HttpMethodName.POST, PREFIX, + appPolicyRequest.getBlbId(), "policys"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, appPolicyRequest.getClientToken()); + fillPayload(internalRequest, appPolicyRequest); + return invokeHttpClient(internalRequest, CreateAppPolicyResponse.class); + } + + + /** + * Return a list of backend server of the specified blb appServerGroup. + * + * @param blbId The id of the blb. + * @param port The port of the policy. + * + * @return The response containing a list of policy of the specified blb. + */ + public ListAppPolicyResponse listPolicys(String blbId, Integer port) { + return listPolicys(new ListAppPolicyRequest().withBlbId(blbId).withPort(port)); + } + + /** + * Return a list of policy of the specified blb + * + * @param listAppPolicyRequest The request containing all options for listing policy. + * + * @return The response containing a list of policy of the specified blb. + */ + public ListAppPolicyResponse listPolicys(ListAppPolicyRequest listAppPolicyRequest) { + checkNotNull(listAppPolicyRequest, "request should not be null."); + checkNotNull(listAppPolicyRequest.getBlbId(), "request blbId should not be null."); + checkNotNull(listAppPolicyRequest.getPort(), "request port should not be null."); + InternalRequest internalRequest = this.createRequest(listAppPolicyRequest, HttpMethodName.GET, PREFIX, + listAppPolicyRequest.getBlbId(), "policys"); + internalRequest.addParameter("port", String.valueOf(listAppPolicyRequest.getPort())); + if (listAppPolicyRequest.getMarker() != null) { + internalRequest.addParameter("marker", listAppPolicyRequest.getMarker()); + } + if (listAppPolicyRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listAppPolicyRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListAppPolicyResponse.class); + + } + + + /** + * Delete a appServerGroup with the specified options. + * + * @param blbId The id of blb + * @param port The port of policy + * @param policyIdList The id of policy list + * + */ + public void deletePolicys(String blbId, Integer port, List policyIdList) { + deletePolicys(new DeleteAppPolicyRequest().withBlbId(blbId) + .withPort(port).withPolicyIdList(policyIdList)); + } + + + /** + * Delete the special policy. + * + * @param deleteAppPolicyRequest The request containing all options for deleting policy. + */ + public void deletePolicys(DeleteAppPolicyRequest deleteAppPolicyRequest) { + checkNotNull(deleteAppPolicyRequest, "request should not be null."); + if (Strings.isNullOrEmpty(deleteAppPolicyRequest.getClientToken())) { + deleteAppPolicyRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(deleteAppPolicyRequest.getBlbId(), "blbId should not be null."); + checkNotNull(deleteAppPolicyRequest.getPort(), "port should not be null."); + checkNotNull(deleteAppPolicyRequest.getPolicyIdList(), "policyIdList should not be null."); + InternalRequest internalRequest = this.createRequest(deleteAppPolicyRequest, HttpMethodName.PUT + , PREFIX, deleteAppPolicyRequest.getBlbId(), "policys"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, deleteAppPolicyRequest.getClientToken()); + internalRequest.addParameter("batchdelete", null); + fillPayload(internalRequest, deleteAppPolicyRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * bind the securityGroups on the specified blb. + * + * @param request The request containing all options for binding sg. + */ + public void bindSg(SgOperateRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, "blb", + request.getBlbId(), "securitygroup"); + internalRequest.addParameter("bind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * unbind the securityGroups from the specified blb. + * + * @param request The request containing all options for unbinding sg. + */ + public void unBindSg(SgOperateRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, "blb", + request.getBlbId(), "securitygroup"); + internalRequest.addParameter("unbind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of sg info of the specified blb + * + * @param request The request containing all options for listing blb's sg. + * + * @return The response containing a listing blb's sg. + */ + public ListBlbSgResponse listBlbSg(ListBlbSgRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, "blb", + request.getBlbId(), "securitygroup"); + return invokeHttpClient(internalRequest, ListBlbSgResponse.class); + } + + /** + * bind the enterpriseSecurityGroups on the specified blb. + * + * @param request The request containing all options for binding esg. + */ + public void bindEsg(EsgOperateRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, "blb", + request.getBlbId(), "enterprise", "securitygroup"); + internalRequest.addParameter("bind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * unbind the enterpriseSecurityGroups from the specified blb. + * + * @param request The request containing all options for unbinding esg. + */ + public void unBindEsg(EsgOperateRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, "blb", + request.getBlbId(), "enterprise", "securitygroup"); + internalRequest.addParameter("unbind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of esg info of the specified blb + * + * @param request The request containing all options for listing blb's esg. + * + * @return The response containing a listing blb's esg. + */ + public ListBlbEsgResponse listBlbEsg(ListBlbSgRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, "blb", + request.getBlbId(), "enterprise", "securitygroup"); + return invokeHttpClient(internalRequest, ListBlbEsgResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/blb/BlbClient.java b/src/main/java/com/baidubce/services/blb/BlbClient.java new file mode 100644 index 00000000..d96c9050 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/BlbClient.java @@ -0,0 +1,854 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.blb.model.AddBackendServersRequest; +import com.baidubce.services.blb.model.AllListener; +import com.baidubce.services.blb.model.BSAction; +import com.baidubce.services.blb.model.BackendServer; +import com.baidubce.services.blb.model.BlbDetailRequest; +import com.baidubce.services.blb.model.BlbInstance; +import com.baidubce.services.blb.model.BlbListenerAction; +import com.baidubce.services.blb.model.BlbListenerRequest; +import com.baidubce.services.blb.model.CreateBlbRequest; +import com.baidubce.services.blb.model.CreateBlbResponse; +import com.baidubce.services.blb.model.DeleteBSRequest; +import com.baidubce.services.blb.model.DeleteBlbRequest; +import com.baidubce.services.blb.model.DeleteListenerRequest; +import com.baidubce.services.blb.model.EsgOperateRequest; +import com.baidubce.services.blb.model.HttpListener; +import com.baidubce.services.blb.model.HttpsListener; +import com.baidubce.services.blb.model.ListAllListenerRequest; +import com.baidubce.services.blb.model.ListBackendServerRequest; +import com.baidubce.services.blb.model.ListBackendServerResponse; +import com.baidubce.services.blb.model.ListBackendServerStatusRequest; +import com.baidubce.services.blb.model.ListBackendServerStatusResponse; +import com.baidubce.services.blb.model.ListBlbEsgResponse; +import com.baidubce.services.blb.model.ListBlbRequest; +import com.baidubce.services.blb.model.ListBlbResponse; +import com.baidubce.services.blb.model.ListBlbSgRequest; +import com.baidubce.services.blb.model.ListBlbSgResponse; +import com.baidubce.services.blb.model.ListListenerRequest; +import com.baidubce.services.blb.model.ListListenerResponse; +import com.baidubce.services.blb.model.ListenerConstant; +import com.baidubce.services.blb.model.ModifyBSAttributesRequest; +import com.baidubce.services.blb.model.ModifyBlbAttributesRequest; +import com.baidubce.services.blb.model.SgOperateRequest; +import com.baidubce.services.blb.model.SslListener; +import com.baidubce.services.blb.model.TcpListener; +import com.baidubce.services.blb.model.UdpListener; +import com.baidubce.services.blb.model.UpdateLoadBalancerAclRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Strings; +import org.apache.commons.lang3.StringUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Baidu Cloud network Service Baidu Load Balance (BLB). + */ +public class BlbClient extends AbstractBceClient { + + /** + * BLB API pathVersion + */ + private static final String VERSION = "v1"; + + private static final String PREFIX = "blb"; + + private static final String CLIENT_TOKEN_IDENTIFY = "clientToken"; + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static final HttpResponseHandler[] blbHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on blb. + */ + public BlbClient() { + this(new BlbClientConfiguration()); + } + + /** + * Constructs a new blb client using the client configuration to access network. + * + * @param clientConfiguration The blb client configuration options controlling how this client + * connects to network (e.g. proxy settings, retry counts, etc). + */ + public BlbClient(BlbClientConfiguration clientConfiguration) { + super(clientConfiguration, blbHandlers); + } + + /** + * Creates and initializes a new request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * Create a blb with the specified options. + * + * @param name The name of blb + * @param desc The description of blb + * @param vpcId The vpcId of blb + * + * @return The response contains detail of the blb. + */ + public CreateBlbResponse createBlb(String name, String desc, String vpcId, String subnetId) { + return createBlb(new CreateBlbRequest().withName(name).withDesc(desc).withVpcId(vpcId).withSubnetId(subnetId)); + } + + /** + * Create an ipv6 blb with the specified options. + * + * @param name The name of blb + * @param desc The description of blb + * @param vpcId The vpcId of blb + * + * @return The response contains detail of the blb. + */ + public CreateBlbResponse createIpv6Blb(String name, String desc, String vpcId, String subnetId) { + return createBlb(new CreateBlbRequest().withName(name).withDesc(desc).withVpcId(vpcId) + .withSubnetId(subnetId).withType("ipv6")); + } + + /** + * Create a blb with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param createBlbRequest The request containing all options for creating a blb. + * + * @return The response contains detail of the blb. + */ + public CreateBlbResponse createBlb(CreateBlbRequest createBlbRequest) { + checkNotNull(createBlbRequest, "request should not be null."); + if (Strings.isNullOrEmpty(createBlbRequest.getClientToken())) { + createBlbRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(createBlbRequest, HttpMethodName.POST, PREFIX); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, createBlbRequest.getClientToken()); + fillPayload(internalRequest, createBlbRequest); + return invokeHttpClient(internalRequest, CreateBlbResponse.class); + } + + /** + * Return a list of blbs with the specified options. + * + * @param address The address of the blb + * @param name The name of the blb. + * @param blbId The id of the blb. + * @param bccId The bcc id of the blb. + * + * @return The response containing a list of blbs owned by the specified options. + */ + public ListBlbResponse listBlbs(String address, String name, String blbId, String bccId) { + return listBlbs(new ListBlbRequest().withAddress(address).withName(name).withBlbId(blbId).withBccId(bccId)); + } + + /** + * Return a list of blbs with the specified options. + * + * @param address The address of the blb + * @param name The name of the blb. + * @param blbId The id of the blb. + * @param bccId The bcc id of the blb. + * + * @return The response containing a list of blbs owned by the specified options. + */ + public ListBlbResponse listIpv6Blbs(String address, String name, String blbId, String bccId) { + return listBlbs(new ListBlbRequest().withAddress(address).withName(name).withBlbId(blbId).withBccId(bccId) + .withType("ipv6")); + } + + /** + * Return a list of blbs with the specified options. + * + * @param listBlbRequest The request containing all options for listing blbs. + * + * @return The response containing a list of blbs with the specified options. + */ + public ListBlbResponse listBlbs(ListBlbRequest listBlbRequest) { + checkNotNull(listBlbRequest, "request should not be null."); + InternalRequest internalRequest = this.createRequest(listBlbRequest, HttpMethodName.GET, PREFIX); + if (StringUtils.isNotEmpty(listBlbRequest.getAddress())) { + internalRequest.addParameter("address", listBlbRequest.getAddress()); + } + if (StringUtils.isNotEmpty(listBlbRequest.getName())) { + internalRequest.addParameter("name", listBlbRequest.getName()); + } + if (StringUtils.isNotEmpty(listBlbRequest.getBlbId())) { + internalRequest.addParameter("blbId", listBlbRequest.getBlbId()); + } + if (StringUtils.isNotEmpty(listBlbRequest.getBccId())) { + internalRequest.addParameter("bccId", listBlbRequest.getBccId()); + } + if (StringUtils.isNotEmpty(listBlbRequest.getType())) { + internalRequest.addParameter("type", listBlbRequest.getType()); + } + if (listBlbRequest.getMarker() != null) { + internalRequest.addParameter("marker", listBlbRequest.getMarker()); + } + if (listBlbRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listBlbRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListBlbResponse.class); + } + + /** + * Return the blb detail with the specified id. + * + * @param request The request containing all options for getting blb detail. + * + * @return The response containing the blb detail + */ + public BlbInstance blbDetail(BlbDetailRequest request) { + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, PREFIX, request.getBlbId()); + return invokeHttpClient(internalRequest, BlbInstance.class); + } + + /** + * Modifying the special attribute to new blb. + * + * @param blbId The id of the blb. + * @param name The name after modifying. + * @param desc The description after modifying. + */ + public void modifyBlbAttributes(String blbId, String name, String desc) { + modifyBlbAttributes(new ModifyBlbAttributesRequest(blbId, name, desc)); + } + + /** + * Modifying the special attribute to new blb. + * + * @param modifyBlbAttributesRequest The request containing all options for modifying a blb. + */ + public void modifyBlbAttributes(ModifyBlbAttributesRequest modifyBlbAttributesRequest) { + checkNotNull(modifyBlbAttributesRequest, "request should not be null."); + checkStringNotEmpty(modifyBlbAttributesRequest.getBlbId(), "request blbId should not be null."); + if (Strings.isNullOrEmpty(modifyBlbAttributesRequest.getClientToken())) { + modifyBlbAttributesRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(modifyBlbAttributesRequest, HttpMethodName.PUT, PREFIX, + modifyBlbAttributesRequest.getBlbId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, modifyBlbAttributesRequest.getClientToken()); + fillPayload(internalRequest, modifyBlbAttributesRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified blb. + * + * @param blbId The id of the blb to delete. + */ + public void deleteBlb(String blbId) { + deleteBlb(new DeleteBlbRequest(blbId)); + } + + /** + * Delete the specified blb. + * + * @param deleteBlbRequest The request containing all options for deleting blb. + */ + public void deleteBlb(DeleteBlbRequest deleteBlbRequest) { + checkNotNull(deleteBlbRequest, "request should not be null."); + if (Strings.isNullOrEmpty(deleteBlbRequest.getClientToken())) { + deleteBlbRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(deleteBlbRequest, HttpMethodName.DELETE, PREFIX, + deleteBlbRequest.getBlbId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, deleteBlbRequest.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * update blb acl with the specified options. + * + * @param request The request containing all options for updating blb acl . + */ + public void updateLoadBalancerAcl(UpdateLoadBalancerAclRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, PREFIX, "acl", + request.getBlbId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create a listener with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param blbListenerRequest The request containing all options for creating a listener. + */ + public void createListener(BlbListenerRequest blbListenerRequest) { + checkNotNull(blbListenerRequest, "request should not be null."); + if (Strings.isNullOrEmpty(blbListenerRequest.getClientToken())) { + blbListenerRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(blbListenerRequest.getType(), "listener type should not be null."); + if (!ListenerConstant.LISTENER_SET.contains(blbListenerRequest.getType())) { + throw new IllegalArgumentException("listener type is illegal."); + } + InternalRequest internalRequest = this.createRequest(blbListenerRequest, HttpMethodName.POST, PREFIX, + blbListenerRequest.getBlbId(), blbListenerRequest.getType() + "listener"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, blbListenerRequest.getClientToken()); + fillPayload(internalRequest, blbListenerRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of tcp listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listTcpListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.TCP_LISTENER)); + response.setListenerList(OBJECT_MAPPER.convertValue(response.getListenerList(), + new TypeReference>() { + })); + return response; + } + + /** + * Return a list of udp listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listUdpListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.UDP_LISTENER)); + response.setListenerList(OBJECT_MAPPER.convertValue(response.getListenerList(), + new TypeReference>() { + })); + return response; + } + + /** + * Return a list of http listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listHttpListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.HTTP_LISTENER)); + response.setListenerList(OBJECT_MAPPER.convertValue(response.getListenerList(), + new TypeReference>() { + })); + return response; + } + + /** + * Return a list of https listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listHttpsListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.HTTPS_LISTENER)); + response.setListenerList(OBJECT_MAPPER.convertValue(response.getListenerList(), + new TypeReference>() { + })); + return response; + } + + /** + * Return a list of ssl listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener owned by the specified options. + */ + public ListListenerResponse listSslListener(String blbId) { + ListListenerResponse response = + listListener(new ListListenerRequest().withBlbId(blbId).withType(ListenerConstant.SSL_LISTENER)); + response.setListenerList( + OBJECT_MAPPER.convertValue(response.getListenerList(), new TypeReference>() { + })); + return response; + } + + /** + * Return a list of all listener with the specified options. + * + * @param blbId The blb id of the listener. + * + * @return The response containing a list of listener. + */ + public ListListenerResponse listAllListener(String blbId) { + return listAllListener(new ListAllListenerRequest().withBlbId(blbId)); + } + + /** + * Return a list of listener with the specified options of blb. + * + * @param request The request containing all options for listing listeners of blb. + * + * @return The response containing a list of listener with the specified options. + */ + public ListListenerResponse listAllListener(ListAllListenerRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, PREFIX, + request.getBlbId(), "listener"); + if (request.getListenerPort() != 0) { + internalRequest.addParameter("listenerPort", String.valueOf(request.getListenerPort())); + } + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + ListListenerResponse response = invokeHttpClient(internalRequest, ListListenerResponse.class); + // 泛型丢失,需要手动转换 + response.setListenerList( + OBJECT_MAPPER.convertValue(response.getListenerList(), new TypeReference>() { + })); + return response; + } + + /** + * Return a list of listener with the specified options. + * + * @param listListenerRequest The request containing all options for listing listeners. + * + * @return The response containing a list of listener with the specified options. + */ + public ListListenerResponse listListener(ListListenerRequest listListenerRequest) { + checkNotNull(listListenerRequest, "request should not be null."); + checkNotNull(listListenerRequest.getType(), "listener type should not be null."); + if (!ListenerConstant.LISTENER_SET.contains(listListenerRequest.getType())) { + throw new IllegalArgumentException("listener type is illegal."); + } + InternalRequest internalRequest = this.createRequest(listListenerRequest, HttpMethodName.GET, PREFIX, + listListenerRequest.getBlbId(), listListenerRequest.getType() + "listener"); + if (listListenerRequest.getListenerPort() != 0) { + internalRequest.addParameter("listenerPort", String.valueOf(listListenerRequest.getListenerPort())); + } + if (listListenerRequest.getMarker() != null) { + internalRequest.addParameter("marker", listListenerRequest.getMarker()); + } + if (listListenerRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listListenerRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListListenerResponse.class); + } + + + /** + * Modifying the special attribute to new listener. + * + * @param modifyListenerAttributesRequest The request containing all options for modifying listener. + */ + public void modifyListenerAttributes(BlbListenerRequest modifyListenerAttributesRequest) { + checkNotNull(modifyListenerAttributesRequest, "request should not be null."); + if (Strings.isNullOrEmpty(modifyListenerAttributesRequest.getClientToken())) { + modifyListenerAttributesRequest.setClientToken(this.generateClientToken()); + } + checkNotNull(modifyListenerAttributesRequest.getType(), "listener type should not be null."); + if (!ListenerConstant.LISTENER_SET.contains(modifyListenerAttributesRequest.getType())) { + throw new IllegalArgumentException("listener type is illegal."); + } + InternalRequest internalRequest = + this.createRequest(modifyListenerAttributesRequest, HttpMethodName.PUT, PREFIX, + modifyListenerAttributesRequest.getBlbId(), + modifyListenerAttributesRequest.getType() + "listener"); + internalRequest.addParameter("listenerPort", String.valueOf(modifyListenerAttributesRequest.getListenerPort())); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, modifyListenerAttributesRequest.getClientToken()); + fillPayload(internalRequest, modifyListenerAttributesRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified listener. + * + * @param blbId The blb id of the listener to delete. + * @param portList The ports of the listener to delete. + */ + public void deleteListener(String blbId, List portList) { + deleteListener(new DeleteListenerRequest(blbId, portList)); + } + + /** + * Delete the specified listener. + * + * @param deleteListenerRequest The request containing all options for deleting listener. + */ + public void deleteListener(DeleteListenerRequest deleteListenerRequest) { + checkNotNull(deleteListenerRequest, "request should not be null."); + if (Strings.isNullOrEmpty(deleteListenerRequest.getClientToken())) { + deleteListenerRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(deleteListenerRequest, HttpMethodName.PUT, PREFIX, + deleteListenerRequest.getBlbId(), "listener"); + internalRequest.addParameter(BlbListenerAction.batchdelete.name(), null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, deleteListenerRequest.getClientToken()); + fillPayload(internalRequest, deleteListenerRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Add backend servers to the specified blb. + * + * @param blbId The id of blb to add backend server. + * @param backendServerList The backend servers to add. + */ + public void addBackendServers(String blbId, List backendServerList) { + addBackendServers(new AddBackendServersRequest(blbId, backendServerList)); + } + + /** + * Add backend servers to the specified blb. + * + * @param addBackendServersRequest The request containing all backend servers for adding to the specified blb. + */ + public void addBackendServers(AddBackendServersRequest addBackendServersRequest) { + checkNotNull(addBackendServersRequest, "request should not be null."); + if (Strings.isNullOrEmpty(addBackendServersRequest.getClientToken())) { + addBackendServersRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(addBackendServersRequest, HttpMethodName.POST, PREFIX, + addBackendServersRequest.getBlbId(), "backendserver"); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, addBackendServersRequest.getClientToken()); + fillPayload(internalRequest, addBackendServersRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of healthStatus of backend servers with the specified blb and listener port. + * + * @param blbId The id of the specified blb. + * @param listenerPort The specified listener port. + * + * @return The response containing a list healthStatus of backend servers. + */ + public ListBackendServerStatusResponse listBackendServerStatus(String blbId, int listenerPort) { + return listBackendServerStatus(new ListBackendServerStatusRequest(blbId, listenerPort)); + } + + /** + * Return a list of healthStatus of backend server with the specified blb and listener port. + * + * @param listBackendServerStatusRequest The request containing all options for listing backend server healtStatus. + * + * @return The response containing a list healthStatus of backend servers. + */ + public ListBackendServerStatusResponse listBackendServerStatus( + ListBackendServerStatusRequest listBackendServerStatusRequest) { + checkNotNull(listBackendServerStatusRequest, "request should not be null."); + InternalRequest internalRequest = + this.createRequest(listBackendServerStatusRequest, HttpMethodName.GET, PREFIX, + listBackendServerStatusRequest.getBlbId(), "backendserver"); + internalRequest.addParameter("listenerPort", String.valueOf(listBackendServerStatusRequest.getListenerPort())); + if (listBackendServerStatusRequest.getMarker() != null) { + internalRequest.addParameter("marker", listBackendServerStatusRequest.getMarker()); + } + if (listBackendServerStatusRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listBackendServerStatusRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListBackendServerStatusResponse.class); + } + + /** + * Return a list of backend server of the specified blb. + * + * @param blbId The id of the blb. + * + * @return The response containing a list of backend servers of the specified blb. + */ + public ListBackendServerResponse listBackendServers(String blbId) { + return listBackendServers(new ListBackendServerRequest(blbId)); + } + + /** + * Return a list of backend server of the specified blb + * + * @param listBackendServerRequest The request containing all options for listing backend server. + * + * @return The response containing a list of backend servers of the specified blb. + */ + public ListBackendServerResponse listBackendServers(ListBackendServerRequest listBackendServerRequest) { + checkNotNull(listBackendServerRequest, "request should not be null."); + InternalRequest internalRequest = this.createRequest(listBackendServerRequest, HttpMethodName.GET, PREFIX, + listBackendServerRequest.getBlbId(), "backendserver"); + if (listBackendServerRequest.getMarker() != null) { + internalRequest.addParameter("marker", listBackendServerRequest.getMarker()); + } + if (listBackendServerRequest.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(listBackendServerRequest.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListBackendServerResponse.class); + + } + + /** + * Modifying the special backend servers of the specified blb. + * + * @param blbId The id of the specified blb. + * @param backendServerList The backend servers to modifying. + */ + public void modifyBackendServerAttributes(String blbId, List backendServerList) { + modifyBackendServerAttributes(new ModifyBSAttributesRequest(blbId, backendServerList)); + } + + /** + * Modifying the special backend servers of the specified blb. + * + * @param modifyBSAttributesRequest The request containing all options for modifying backend servers. + */ + public void modifyBackendServerAttributes(ModifyBSAttributesRequest modifyBSAttributesRequest) { + checkNotNull(modifyBSAttributesRequest, "request should not be null."); + if (Strings.isNullOrEmpty(modifyBSAttributesRequest.getClientToken())) { + modifyBSAttributesRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(modifyBSAttributesRequest, HttpMethodName.PUT, PREFIX, + modifyBSAttributesRequest.getBlbId(), "backendserver"); + internalRequest.addParameter(BSAction.update.name(), null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, modifyBSAttributesRequest.getClientToken()); + fillPayload(internalRequest, modifyBSAttributesRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified backend server from the specified blb. + * + * @param blbId The id of the blb. + * @param backendServerList The id list of the backend server to deleting. + */ + public void deleteBackendServers(String blbId, List backendServerList) { + deleteBackendServers(new DeleteBSRequest(blbId, backendServerList)); + } + + /** + * Delete the specified backend server from the specified blb. + * + * @param deleteBSRequest The request containing all options for deleting backend server from the specified blb. + */ + public void deleteBackendServers(DeleteBSRequest deleteBSRequest) { + checkNotNull(deleteBSRequest, "request should not be null."); + if (Strings.isNullOrEmpty(deleteBSRequest.getClientToken())) { + deleteBSRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(deleteBSRequest, HttpMethodName.PUT, PREFIX, + deleteBSRequest.getBlbId(), "backendserver"); + fillPayload(internalRequest, deleteBSRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * bind the securityGroups on the specified blb. + * + * @param request The request containing all options for binding sg. + */ + public void bindSg(SgOperateRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, PREFIX, + request.getBlbId(), "securitygroup"); + internalRequest.addParameter("bind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * unbind the securityGroups from the specified blb. + * + * @param request The request containing all options for unbinding sg. + */ + public void unBindSg(SgOperateRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, PREFIX, + request.getBlbId(), "securitygroup"); + internalRequest.addParameter("unbind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of sg info of the specified blb + * + * @param request The request containing all options for listing blb's sg. + * + * @return The response containing a listing blb's sg. + */ + public ListBlbSgResponse listBlbSg(ListBlbSgRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, PREFIX, + request.getBlbId(), "securitygroup"); + return invokeHttpClient(internalRequest, ListBlbSgResponse.class); + } + + /** + * bind the enterpriseSecurityGroups on the specified blb. + * + * @param request The request containing all options for binding esg. + */ + public void bindEsg(EsgOperateRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, PREFIX, + request.getBlbId(), "enterprise", "securitygroup"); + internalRequest.addParameter("bind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * unbind the enterpriseSecurityGroups from the specified blb. + * + * @param request The request containing all options for unbinding esg. + */ + public void unBindEsg(EsgOperateRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, PREFIX, + request.getBlbId(), "enterprise", "securitygroup"); + internalRequest.addParameter("unbind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of esg info of the specified blb + * + * @param request The request containing all options for listing blb's esg. + * + * @return The response containing a listing blb's esg. + */ + public ListBlbEsgResponse listBlbEsg(ListBlbSgRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getBlbId(), "blbId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, PREFIX, + request.getBlbId(), "enterprise", "securitygroup"); + return invokeHttpClient(internalRequest, ListBlbEsgResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/blb/BlbClientConfiguration.java b/src/main/java/com/baidubce/services/blb/BlbClientConfiguration.java new file mode 100644 index 00000000..5dd715ac --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/BlbClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for bcc service. + */ +public class BlbClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/blb/model/AddBackendServersRequest.java b/src/main/java/com/baidubce/services/blb/model/AddBackendServersRequest.java new file mode 100644 index 00000000..ec637887 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AddBackendServersRequest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for create acl. + */ +public class AddBackendServersRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the id of the blb. + */ + @JsonIgnore + private String blbId; + + /** + * the backendServer list to add. + */ + private List backendServerList; + + public AddBackendServersRequest(String blbId, + List backendServerList) { + this.blbId = blbId; + this.backendServerList = backendServerList; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public List getBackendServerList() { + return backendServerList; + } + + public void setBackendServerList(List backendServerList) { + this.backendServerList = backendServerList; + } + + public AddBackendServersRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public AddBackendServersRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public AddBackendServersRequest withBackendServerList(List backendServerList) { + this.setBackendServerList(backendServerList); + return this; + } + + @Override + public AddBackendServersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AdditionalCertDomain.java b/src/main/java/com/baidubce/services/blb/model/AdditionalCertDomain.java new file mode 100644 index 00000000..ed50e526 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AdditionalCertDomain.java @@ -0,0 +1,49 @@ +package com.baidubce.services.blb.model; + +/** + * Https listener additional certificate and domain + */ +public class AdditionalCertDomain { + + /** + * The short id of certificate + */ + private String certId; + + /** + * The domain name of the certificate corresponding to the above certId + */ + private String host; + + public AdditionalCertDomain() { + } + + public AdditionalCertDomain(String certId, String host) { + this.certId = certId; + this.host = host; + } + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + @Override + public String toString() { + return "AdditionalCertDomain{" + + "certId='" + certId + '\'' + + ", host='" + host + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AllListener.java b/src/main/java/com/baidubce/services/blb/model/AllListener.java new file mode 100644 index 00000000..5781687e --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AllListener.java @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * All listener info modal. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class AllListener extends ListenerBase { + + /** + * the type of listener. + */ + private String listenerType; + /** + * if get blb ip or not. + */ + private Boolean getBlbIp; + /** + * the timeout of the tcp session. + */ + private Integer tcpSessionTimeout; + /** + * the timeout of the udp session. + */ + private Integer udpSessionTimeout; + /** + * the string to health check. + */ + private String healthCheckString; + /** + * if keep session or not. + */ + private Boolean keepSession; + /** + * the type of keep session. + */ + private String keepSessionType; + /** + * the duration of the keep session. + */ + private Integer keepSessionDuration; + /** + * the cookie name of the keep session. + */ + private String keepSessionCookieName; + /** + * if fetch the real ip or not. + */ + private Boolean xForwardFor; + /** + * the type of the health check. + */ + private String healthCheckType; + /** + * the port of the health check. + */ + private Integer healthCheckPort; + /** + * the uri of the health check. + */ + private String healthCheckURI; + /** + * the status of health check when it is normal. + */ + private String healthCheckNormalStatus; + /** + * the host of health check when it is http listener. + */ + private String healthCheckHost; + /** + * the max timeout of server. + */ + private Integer serverTimeout; + /** + * the port of redirect. + */ + private int redirectPort; + /** + * the certificate ids of listener. + */ + private List certIds; + /** + * The additional certificates and domains of listener + * + * @see AdditionalCertDomain + */ + private List additionalCertDomains; + /** + * open dualAuth or not. + */ + private boolean dualAuth; + /** + * the clientCert ids of listener. + */ + private List clientCertIds; + /** + * the encryptionType of listener. + */ + private String encryptionType; + /** + * the encryptionProtocols of listener. + */ + private List encryptionProtocols; + /** + * the appliedCiphers of listener. + */ + private String appliedCiphers; + + + public String getListenerType() { + return listenerType; + } + + public void setListenerType(String listenerType) { + this.listenerType = listenerType; + } + + public Boolean getGetBlbIp() { + return getBlbIp; + } + + public void setGetBlbIp(Boolean getBlbIp) { + this.getBlbIp = getBlbIp; + } + + public Integer getTcpSessionTimeout() { + return tcpSessionTimeout; + } + + public void setTcpSessionTimeout(Integer tcpSessionTimeout) { + this.tcpSessionTimeout = tcpSessionTimeout; + } + + public Integer getUdpSessionTimeout() { + return udpSessionTimeout; + } + + public void setUdpSessionTimeout(Integer udpSessionTimeout) { + this.udpSessionTimeout = udpSessionTimeout; + } + + public String getHealthCheckString() { + return healthCheckString; + } + + public void setHealthCheckString(String healthCheckString) { + this.healthCheckString = healthCheckString; + } + + public String getHealthCheckHost() { + return healthCheckHost; + } + + public void setHealthCheckHost(String healthCheckHost) { + this.healthCheckHost = healthCheckHost; + } + + public List getCertIds() { + return certIds; + } + + public void setCertIds(List certIds) { + this.certIds = certIds; + } + + public List getAdditionalCertDomains() { + return additionalCertDomains; + } + + public void setAdditionalCertDomains( + List additionalCertDomains) { + this.additionalCertDomains = additionalCertDomains; + } + + public boolean isDualAuth() { + return dualAuth; + } + + public void setDualAuth(boolean dualAuth) { + this.dualAuth = dualAuth; + } + + public List getClientCertIds() { + return clientCertIds; + } + + public void setClientCertIds(List clientCertIds) { + this.clientCertIds = clientCertIds; + } + + public String getEncryptionType() { + return encryptionType; + } + + public void setEncryptionType(String encryptionType) { + this.encryptionType = encryptionType; + } + + public List getEncryptionProtocols() { + return encryptionProtocols; + } + + public void setEncryptionProtocols(List encryptionProtocols) { + this.encryptionProtocols = encryptionProtocols; + } + + public String getAppliedCiphers() { + return appliedCiphers; + } + + public void setAppliedCiphers(String appliedCiphers) { + this.appliedCiphers = appliedCiphers; + } + + public Boolean getKeepSession() { + return keepSession; + } + + public void setKeepSession(Boolean keepSession) { + this.keepSession = keepSession; + } + + public String getKeepSessionType() { + return keepSessionType; + } + + public void setKeepSessionType(String keepSessionType) { + this.keepSessionType = keepSessionType; + } + + public Integer getKeepSessionDuration() { + return keepSessionDuration; + } + + public void setKeepSessionDuration(Integer keepSessionDuration) { + this.keepSessionDuration = keepSessionDuration; + } + + public String getKeepSessionCookieName() { + return keepSessionCookieName; + } + + public void setKeepSessionCookieName(String keepSessionCookieName) { + this.keepSessionCookieName = keepSessionCookieName; + } + + public Boolean getxForwardFor() { + return xForwardFor; + } + + public void setxForwardFor(Boolean xForwardFor) { + this.xForwardFor = xForwardFor; + } + + public String getHealthCheckType() { + return healthCheckType; + } + + public void setHealthCheckType(String healthCheckType) { + this.healthCheckType = healthCheckType; + } + + public Integer getHealthCheckPort() { + return healthCheckPort; + } + + public void setHealthCheckPort(Integer healthCheckPort) { + this.healthCheckPort = healthCheckPort; + } + + public String getHealthCheckURI() { + return healthCheckURI; + } + + public void setHealthCheckURI(String healthCheckURI) { + this.healthCheckURI = healthCheckURI; + } + + public String getHealthCheckNormalStatus() { + return healthCheckNormalStatus; + } + + public void setHealthCheckNormalStatus(String healthCheckNormalStatus) { + this.healthCheckNormalStatus = healthCheckNormalStatus; + } + + public Integer getServerTimeout() { + return serverTimeout; + } + + public void setServerTimeout(Integer serverTimeout) { + this.serverTimeout = serverTimeout; + } + + public int getRedirectPort() { + return redirectPort; + } + + public void setRedirectPort(int redirectPort) { + this.redirectPort = redirectPort; + } + + @Override + public String toString() { + return "AllListener{" + + "listenerType='" + listenerType + '\'' + + ", getBlbIp=" + getBlbIp + + ", tcpSessionTimeout=" + tcpSessionTimeout + + ", udpSessionTimeout=" + udpSessionTimeout + + ", healthCheckString='" + healthCheckString + '\'' + + ", keepSession=" + keepSession + + ", keepSessionType='" + keepSessionType + '\'' + + ", keepSessionDuration=" + keepSessionDuration + + ", keepSessionCookieName='" + keepSessionCookieName + '\'' + + ", xForwardFor=" + xForwardFor + + ", healthCheckType='" + healthCheckType + '\'' + + ", healthCheckPort=" + healthCheckPort + + ", healthCheckURI='" + healthCheckURI + '\'' + + ", healthCheckNormalStatus='" + healthCheckNormalStatus + '\'' + + ", healthCheckHost='" + healthCheckHost + '\'' + + ", serverTimeout=" + serverTimeout + + ", redirectPort=" + redirectPort + + ", certIds=" + certIds + + ", additionalCertDomains=" + additionalCertDomains + + ", dualAuth=" + dualAuth + + ", clientCertIds=" + clientCertIds + + ", encryptionType='" + encryptionType + '\'' + + ", encryptionProtocols=" + encryptionProtocols + + ", appliedCiphers='" + appliedCiphers + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppBackendPolicyRequest.java b/src/main/java/com/baidubce/services/blb/model/AppBackendPolicyRequest.java new file mode 100644 index 00000000..854cbad3 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppBackendPolicyRequest.java @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for appBlb ipGroup backendPolicy. + */ +public class AppBackendPolicyRequest extends AbstractBceRequest { + + /** + * the short id of the blb. + */ + @JsonIgnore + private String blbId; + /** + * the short id of the AppIpGroup. + */ + private String ipGroupId; + /** + * the short id of AppIpGroupBackendPolicy. + */ + private String id; + /** + * the type of AppIpGroupBackendPolicy. + */ + private String type; + /** + * the protocol of health check. + */ + private String healthCheck; + /** + * the port of health check. + */ + private Integer healthCheckPort; + /** + * the uri of health check. + */ + private String healthCheckUrlPath; + /** + * the timeout (in second) of health check. + */ + private Integer healthCheckTimeoutInSecond; + /** + * the interval (in second) of health check. + */ + private Integer healthCheckIntervalInSecond; + /** + * down retry times of health check. + */ + private Integer healthCheckDownRetry; + /** + * up retry times of health check. + */ + private Integer healthCheckUpRetry; + /** + * the normal status of health check. + */ + private String healthCheckNormalStatus; + /** + * the string of udp health check. + */ + private String udpHealthCheckString; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * the short id of appIpGroupBackendPolicy list. + */ + private List backendPolicyIdList; + + + + + public AppBackendPolicyRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + public AppBackendPolicyRequest withIpGroupId(String ipGroupId) { + this.ipGroupId = ipGroupId; + return this; + } + + public AppBackendPolicyRequest withBackendPolicyIdList(List backendPolicyIdList) { + this.backendPolicyIdList = backendPolicyIdList; + return this; + } + + + + public AppBackendPolicyRequest withType(String type) { + this.type = type; + return this; + } + + + + + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getHealthCheck() { + return healthCheck; + } + + public void setHealthCheck(String healthCheck) { + this.healthCheck = healthCheck; + } + + public Integer getHealthCheckPort() { + return healthCheckPort; + } + + public void setHealthCheckPort(Integer healthCheckPort) { + this.healthCheckPort = healthCheckPort; + } + + public String getHealthCheckUrlPath() { + return healthCheckUrlPath; + } + + public void setHealthCheckUrlPath(String healthCheckUrlPath) { + this.healthCheckUrlPath = healthCheckUrlPath; + } + + public Integer getHealthCheckTimeoutInSecond() { + return healthCheckTimeoutInSecond; + } + + public void setHealthCheckTimeoutInSecond(Integer healthCheckTimeoutInSecond) { + this.healthCheckTimeoutInSecond = healthCheckTimeoutInSecond; + } + + public Integer getHealthCheckIntervalInSecond() { + return healthCheckIntervalInSecond; + } + + public void setHealthCheckIntervalInSecond(Integer healthCheckIntervalInSecond) { + this.healthCheckIntervalInSecond = healthCheckIntervalInSecond; + } + + public Integer getHealthCheckDownRetry() { + return healthCheckDownRetry; + } + + public void setHealthCheckDownRetry(Integer healthCheckDownRetry) { + this.healthCheckDownRetry = healthCheckDownRetry; + } + + public Integer getHealthCheckUpRetry() { + return healthCheckUpRetry; + } + + public void setHealthCheckUpRetry(Integer healthCheckUpRetry) { + this.healthCheckUpRetry = healthCheckUpRetry; + } + + public String getHealthCheckNormalStatus() { + return healthCheckNormalStatus; + } + + public void setHealthCheckNormalStatus(String healthCheckNormalStatus) { + this.healthCheckNormalStatus = healthCheckNormalStatus; + } + + public String getUdpHealthCheckString() { + return udpHealthCheckString; + } + + public void setUdpHealthCheckString(String udpHealthCheckString) { + this.udpHealthCheckString = udpHealthCheckString; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getIpGroupId() { + return ipGroupId; + } + + public void setIpGroupId(String ipGroupId) { + this.ipGroupId = ipGroupId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public List getBackendPolicyIdList() { + return backendPolicyIdList; + } + + public void setBackendPolicyIdList(List backendPolicyIdList) { + this.backendPolicyIdList = backendPolicyIdList; + } + + @Override + public AppBackendPolicyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppBackendPolicyResponse.java b/src/main/java/com/baidubce/services/blb/model/AppBackendPolicyResponse.java new file mode 100644 index 00000000..b11b0b32 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppBackendPolicyResponse.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for appBlb ipGroup backendPolicy. + */ +public class AppBackendPolicyResponse extends AbstractBceResponse { + + /** + * the short id of the AppIpGroupBackendPolicy. + */ + private String id; + /** + * the type of AppIpGroupBackendPolicy. + */ + private String type; + /** + * the protocol of health check. + */ + private String healthCheck; + /** + * the port of health check. + */ + private Integer healthCheckPort; + /** + * the uri of health check. + */ + private String healthCheckUrlPath; + /** + * the timeout (in second) of health check. + */ + private Integer healthCheckTimeoutInSecond; + /** + * the interval (in second) of health check. + */ + private Integer healthCheckIntervalInSecond; + /** + * down retry times of health check. + */ + private Integer healthCheckDownRetry; + /** + * up retry times of health check. + */ + private Integer healthCheckUpRetry; + /** + * the normal status of health check. + */ + private String healthCheckNormalStatus; + /** + * the string of udp health check. + */ + private String udpHealthCheckString; + + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getHealthCheck() { + return healthCheck; + } + + public void setHealthCheck(String healthCheck) { + this.healthCheck = healthCheck; + } + + public Integer getHealthCheckPort() { + return healthCheckPort; + } + + public void setHealthCheckPort(Integer healthCheckPort) { + this.healthCheckPort = healthCheckPort; + } + + public String getHealthCheckUrlPath() { + return healthCheckUrlPath; + } + + public void setHealthCheckUrlPath(String healthCheckUrlPath) { + this.healthCheckUrlPath = healthCheckUrlPath; + } + + public Integer getHealthCheckTimeoutInSecond() { + return healthCheckTimeoutInSecond; + } + + public void setHealthCheckTimeoutInSecond(Integer healthCheckTimeoutInSecond) { + this.healthCheckTimeoutInSecond = healthCheckTimeoutInSecond; + } + + public Integer getHealthCheckIntervalInSecond() { + return healthCheckIntervalInSecond; + } + + public void setHealthCheckIntervalInSecond(Integer healthCheckIntervalInSecond) { + this.healthCheckIntervalInSecond = healthCheckIntervalInSecond; + } + + public Integer getHealthCheckDownRetry() { + return healthCheckDownRetry; + } + + public void setHealthCheckDownRetry(Integer healthCheckDownRetry) { + this.healthCheckDownRetry = healthCheckDownRetry; + } + + public Integer getHealthCheckUpRetry() { + return healthCheckUpRetry; + } + + public void setHealthCheckUpRetry(Integer healthCheckUpRetry) { + this.healthCheckUpRetry = healthCheckUpRetry; + } + + public String getHealthCheckNormalStatus() { + return healthCheckNormalStatus; + } + + public void setHealthCheckNormalStatus(String healthCheckNormalStatus) { + this.healthCheckNormalStatus = healthCheckNormalStatus; + } + + public String getUdpHealthCheckString() { + return udpHealthCheckString; + } + + public void setUdpHealthCheckString(String udpHealthCheckString) { + this.udpHealthCheckString = udpHealthCheckString; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppBackendServer.java b/src/main/java/com/baidubce/services/blb/model/AppBackendServer.java new file mode 100644 index 00000000..fe4c939e --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppBackendServer.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +/** + * The request for add appBlb backendServer. + */ +public class AppBackendServer { + + /** + * the instanceId of the backendServer. + */ + private String instanceId; + /** + * the weight of the backendServer. + */ + private Integer weight; + /** + * the privateIp of the backendServer. + */ + private String privateIp; + /** + * the portList of the appBackendServer. + */ + private List portList; + + public List getPortList() { + return portList; + } + + public void setPortList(List portList) { + this.portList = portList; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public Integer getWeight() { + return weight; + } + + public void setWeight(Integer weight) { + this.weight = weight; + } + + public String getPrivateIp() { + return privateIp; + } + + public void setPrivateIp(String privateIp) { + this.privateIp = privateIp; + } + + @Override + public String toString() { + return "AppBackendServer{" + + "instanceId='" + instanceId + '\'' + + ", weight=" + weight + + ", privateIp='" + privateIp + '\'' + + ", portList=" + portList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppIgRequest.java b/src/main/java/com/baidubce/services/blb/model/AppIgRequest.java new file mode 100644 index 00000000..d509810a --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppIgRequest.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for appBlb ipGroup. + */ +public class AppIgRequest extends AbstractBceRequest { + + /** + * the short id of the blb. + */ + @JsonIgnore + private String blbId; + /** + * the short id of the AppIpGroup. + */ + private String ipGroupId; + /** + * the name of AppIpGroup. + */ + private String name; + /** + * the description of AppIpGroup. + */ + private String desc; + /** + * the memberList of AppIpGroup. + */ + private List memberList; + + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + + public AppIgRequest withName(String name) { + this.name = name; + return this; + } + + public AppIgRequest withDesc(String desc) { + this.desc = desc; + return this; + } + + public AppIgRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + public AppIgRequest withIpGroupId(String ipGroupId) { + this.ipGroupId = ipGroupId; + return this; + } + + public String getIpGroupId() { + return ipGroupId; + } + + public void setIpGroupId(String ipGroupId) { + this.ipGroupId = ipGroupId; + } + + public AppIgRequest withMemberList(List memberList) { + this.setMemberList(memberList); + return this; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public List getMemberList() { + return memberList; + } + + public void setMemberList(List memberList) { + this.memberList = memberList; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public AppIgRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppIgResponse.java b/src/main/java/com/baidubce/services/blb/model/AppIgResponse.java new file mode 100644 index 00000000..383fc9c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppIgResponse.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for appBlb ipGroup. + */ +public class AppIgResponse extends AbstractBceResponse { + + /** + * the short id of the AppIpGroup. + */ + private String id; + /** + * the name of AppIpGroup. + */ + private String name; + /** + * the description of AppIpGroup. + */ + private String desc; + /** + * the backendPolicyList of AppIpGroup. + */ + private List backendPolicyList; + + public List getBackendPolicyList() { + return backendPolicyList; + } + + public void setBackendPolicyList(List backendPolicyList) { + this.backendPolicyList = backendPolicyList; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppIpGroupMember.java b/src/main/java/com/baidubce/services/blb/model/AppIpGroupMember.java new file mode 100644 index 00000000..0e4de220 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppIpGroupMember.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +/** + * The request for add appBlb ipGroup member. + */ +public class AppIpGroupMember { + + /** + * the id of the member. + */ + private String memberId; + /** + * the weight of the ipGroupMember. + */ + private Integer weight; + /** + * the port of the ipGroupMember. + */ + private Integer port; + /** + * the ip of the ipGroupMember. + */ + private String ip; + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public Integer getWeight() { + return weight; + } + + public void setWeight(Integer weight) { + this.weight = weight; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppIpGroupMemberRequest.java b/src/main/java/com/baidubce/services/blb/model/AppIpGroupMemberRequest.java new file mode 100644 index 00000000..5cc8648e --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppIpGroupMemberRequest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for appBlb member. + */ +public class AppIpGroupMemberRequest extends AbstractBceRequest { + + /** + * the short id of the blb. + */ + @JsonIgnore + private String blbId; + /** + * the short id of the ipGroup. + */ + private String ipGroupId; + /** + * the memberIdList of AppIpGroup. + */ + private List memberIdList; + + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + + + + public AppIpGroupMemberRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + public AppIpGroupMemberRequest withIpGroupId(String ipGroupId) { + this.ipGroupId = ipGroupId; + return this; + } + + public AppIpGroupMemberRequest withMemberIdList(List memberIdList) { + this.memberIdList = memberIdList; + return this; + } + + public String getIpGroupId() { + return ipGroupId; + } + + public void setIpGroupId(String ipGroupId) { + this.ipGroupId = ipGroupId; + } + + public List getMemberIdList() { + return memberIdList; + } + + public void setMemberIdList(List memberIdList) { + this.memberIdList = memberIdList; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public AppIpGroupMemberRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppPolicy.java b/src/main/java/com/baidubce/services/blb/model/AppPolicy.java new file mode 100644 index 00000000..6bfe2d75 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppPolicy.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +/** + * The model of appBlb policy. + */ +public class AppPolicy { + + /** + * the id of the policy. + */ + private String id; + /** + * the description of the policy. + */ + private String desc; + /** + * the appServerGroupId of the policy. + */ + private String appServerGroupId; + /** + * the appServerGroupName of the policy. + */ + private String appServerGroupName; + /** + * the appIpGroupId of the policy. + */ + private String appIpGroupId; + /** + * the appIpGroupName of the policy. + */ + private String appIpGroupName; + /** + * the groupType of the policy. + */ + private String groupType; + /** + * the frontendPort of the policy. + */ + private Integer frontendPort; + /** + * the backendPort of the policy. + */ + private Integer backendPort; + /** + * the portType of the policy. + */ + private String portType; + /** + * the priority of the policy. + */ + private Integer priority; + /** + * the ruleList of the policy. + */ + private List ruleList; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getAppServerGroupId() { + return appServerGroupId; + } + + public void setAppServerGroupId(String appServerGroupId) { + this.appServerGroupId = appServerGroupId; + } + + public String getAppServerGroupName() { + return appServerGroupName; + } + + public void setAppServerGroupName(String appServerGroupName) { + this.appServerGroupName = appServerGroupName; + } + + public Integer getFrontendPort() { + return frontendPort; + } + + public void setFrontendPort(Integer frontendPort) { + this.frontendPort = frontendPort; + } + + public Integer getBackendPort() { + return backendPort; + } + + public void setBackendPort(Integer backendPort) { + this.backendPort = backendPort; + } + + public String getPortType() { + return portType; + } + + public void setPortType(String portType) { + this.portType = portType; + } + + public Integer getPriority() { + return priority; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public List getRuleList() { + return ruleList; + } + + public void setRuleList(List ruleList) { + this.ruleList = ruleList; + } + + public String getAppIpGroupId() { + return appIpGroupId; + } + + public void setAppIpGroupId(String appIpGroupId) { + this.appIpGroupId = appIpGroupId; + } + + public String getAppIpGroupName() { + return appIpGroupName; + } + + public void setAppIpGroupName(String appIpGroupName) { + this.appIpGroupName = appIpGroupName; + } + + public String getGroupType() { + return groupType; + } + + public void setGroupType(String groupType) { + this.groupType = groupType; + } + + @Override + public String toString() { + return "AppPolicy{" + + "id='" + id + '\'' + + ", desc='" + desc + '\'' + + ", appServerGroupId='" + appServerGroupId + '\'' + + ", appServerGroupName='" + appServerGroupName + '\'' + + ", appIpGroupId='" + appIpGroupId + '\'' + + ", appIpGroupName='" + appIpGroupName + '\'' + + ", groupType='" + groupType + '\'' + + ", frontendPort=" + frontendPort + + ", backendPort=" + backendPort + + ", portType='" + portType + '\'' + + ", priority=" + priority + + ", ruleList=" + ruleList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppPolicyRequest.java b/src/main/java/com/baidubce/services/blb/model/AppPolicyRequest.java new file mode 100644 index 00000000..6e595a6b --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppPolicyRequest.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for appBlb policy. + */ +public class AppPolicyRequest extends AbstractBceRequest { + + /** + * the short id of the blb. + */ + @JsonIgnore + private String blbId; + /** + * the listenerPort of the policy. + */ + private Integer listenerPort; + /** + * the listenerType of the policy. + */ + private String type; + /** + * the appPolicyVos of the policy. + */ + private List appPolicyVos; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public Integer getListenerPort() { + return listenerPort; + } + + public void setListenerPort(Integer listenerPort) { + this.listenerPort = listenerPort; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List getAppPolicyVos() { + return appPolicyVos; + } + + public void setAppPolicyVos(List appPolicyVos) { + this.appPolicyVos = appPolicyVos; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public AppPolicyRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + public AppPolicyRequest withListenerPort(Integer listenerPort) { + this.listenerPort = listenerPort; + return this; + } + + public AppPolicyRequest withType(String type) { + this.type = type; + return this; + } + + public AppPolicyRequest withAppPolicyVos(List appPolicyVos) { + this.appPolicyVos = appPolicyVos; + return this; + } + + + @Override + public AppPolicyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppRsPort.java b/src/main/java/com/baidubce/services/blb/model/AppRsPort.java new file mode 100644 index 00000000..fab76e97 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppRsPort.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +/** + * The model of appBlb backendServer port. + */ +public class AppRsPort { + + /** + * the listener port of rs. + */ + private Integer listenerPort; + /** + * the port of rs. + */ + private String backendPort; + /** + * the type of port. + */ + private String portType; + /** + * the protocol of health check. + */ + private String healthCheckPortType; + /** + * the status of port. + */ + private String status; + /** + * the id of port. + */ + private String portId; + /** + * the id of policy. + */ + private String policyId; + + public Integer getListenerPort() { + return listenerPort; + } + + public void setListenerPort(Integer listenerPort) { + this.listenerPort = listenerPort; + } + + public String getBackendPort() { + return backendPort; + } + + public void setBackendPort(String backendPort) { + this.backendPort = backendPort; + } + + public String getPortType() { + return portType; + } + + public void setPortType(String portType) { + this.portType = portType; + } + + public String getHealthCheckPortType() { + return healthCheckPortType; + } + + public void setHealthCheckPortType(String healthCheckPortType) { + this.healthCheckPortType = healthCheckPortType; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPortId() { + return portId; + } + + public void setPortId(String portId) { + this.portId = portId; + } + + public String getPolicyId() { + return policyId; + } + + public void setPolicyId(String policyId) { + this.policyId = policyId; + } + + @Override + public String toString() { + return "AppRsPort{" + + "listenerPort=" + listenerPort + + ", backendPort='" + backendPort + '\'' + + ", portType='" + portType + '\'' + + ", healthCheckPortType='" + healthCheckPortType + '\'' + + ", status='" + status + '\'' + + ", portId='" + portId + '\'' + + ", policyId='" + policyId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppRsRequest.java b/src/main/java/com/baidubce/services/blb/model/AppRsRequest.java new file mode 100644 index 00000000..e5c5566a --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppRsRequest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for appBlb backendServer. + */ +public class AppRsRequest extends AbstractBceRequest { + + /** + * the short id of the blb. + */ + private String blbId; + /** + * the short id of the AppServerGroup. + */ + private String sgId; + /** + * the backendServerIdList of AppServerGroup. + */ + private List backendServerIdList; + + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + + + + public AppRsRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + public AppRsRequest withSgId(String sgId) { + this.sgId = sgId; + return this; + } + + public AppRsRequest withBackendServerIdList(List backendServerIdList) { + this.backendServerIdList = backendServerIdList; + return this; + } + + public String getSgId() { + return sgId; + } + + public void setSgId(String sgId) { + this.sgId = sgId; + } + + public List getBackendServerIdList() { + return backendServerIdList; + } + + public void setBackendServerIdList(List backendServerIdList) { + this.backendServerIdList = backendServerIdList; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public AppRsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppRule.java b/src/main/java/com/baidubce/services/blb/model/AppRule.java new file mode 100644 index 00000000..c127113f --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppRule.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +/** + * The model of appBlb policy rule. + */ +public class AppRule { + + /** + * the key of the rule. + */ + private String key; + /** + * the value of the rule. + */ + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppSgPortRequest.java b/src/main/java/com/baidubce/services/blb/model/AppSgPortRequest.java new file mode 100644 index 00000000..5ae8ac5d --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppSgPortRequest.java @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for appBlb serverGroup port. + */ +public class AppSgPortRequest extends AbstractBceRequest { + + /** + * the short id of the blb. + */ + private String blbId; + /** + * the short id of the AppServerGroup. + */ + private String sgId; + /** + * the short id of AppServerGroupPort. + */ + private String portId; + /** + * the port of AppServerGroup. + */ + private Integer port; + /** + * the type of port. + */ + private String type; + /** + * the protocol of health check. + */ + private String healthCheck; + /** + * the port of health check. + */ + private Integer healthCheckPort; + /** + * the uri of health check. + */ + private String healthCheckUrlPath; + /** + * the timeout (in second) of health check. + */ + private Integer healthCheckTimeoutInSecond; + /** + * the interval (in second) of health check. + */ + private Integer healthCheckIntervalInSecond; + /** + * down retry times of health check. + */ + private Integer healthCheckDownRetry; + /** + * up retry times of health check. + */ + private Integer healthCheckUpRetry; + /** + * the normal status of health check. + */ + private String healthCheckNormalStatus; + /** + * the string of udp health check. + */ + private String udpHealthCheckString; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * the short id of appServerGroupPort list. + */ + private List portIdList; + + + public List getPortIdList() { + return portIdList; + } + + public void setPortIdList(List portIdList) { + this.portIdList = portIdList; + } + + public AppSgPortRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + public AppSgPortRequest withSgId(String sgId) { + this.sgId = sgId; + return this; + } + + public AppSgPortRequest withPort(Integer port) { + this.port = port; + return this; + } + public AppSgPortRequest withPortIdList(List portIdList) { + this.portIdList = portIdList; + return this; + } + + public AppSgPortRequest withType(String type) { + this.type = type; + return this; + } + + public String getSgId() { + return sgId; + } + + public void setSgId(String sgId) { + this.sgId = sgId; + } + + + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getHealthCheck() { + return healthCheck; + } + + public void setHealthCheck(String healthCheck) { + this.healthCheck = healthCheck; + } + + public Integer getHealthCheckPort() { + return healthCheckPort; + } + + public void setHealthCheckPort(Integer healthCheckPort) { + this.healthCheckPort = healthCheckPort; + } + + public String getHealthCheckUrlPath() { + return healthCheckUrlPath; + } + + public void setHealthCheckUrlPath(String healthCheckUrlPath) { + this.healthCheckUrlPath = healthCheckUrlPath; + } + + public Integer getHealthCheckTimeoutInSecond() { + return healthCheckTimeoutInSecond; + } + + public void setHealthCheckTimeoutInSecond(Integer healthCheckTimeoutInSecond) { + this.healthCheckTimeoutInSecond = healthCheckTimeoutInSecond; + } + + public Integer getHealthCheckIntervalInSecond() { + return healthCheckIntervalInSecond; + } + + public void setHealthCheckIntervalInSecond(Integer healthCheckIntervalInSecond) { + this.healthCheckIntervalInSecond = healthCheckIntervalInSecond; + } + + public Integer getHealthCheckDownRetry() { + return healthCheckDownRetry; + } + + public void setHealthCheckDownRetry(Integer healthCheckDownRetry) { + this.healthCheckDownRetry = healthCheckDownRetry; + } + + public Integer getHealthCheckUpRetry() { + return healthCheckUpRetry; + } + + public void setHealthCheckUpRetry(Integer healthCheckUpRetry) { + this.healthCheckUpRetry = healthCheckUpRetry; + } + + public String getHealthCheckNormalStatus() { + return healthCheckNormalStatus; + } + + public void setHealthCheckNormalStatus(String healthCheckNormalStatus) { + this.healthCheckNormalStatus = healthCheckNormalStatus; + } + + public String getUdpHealthCheckString() { + return udpHealthCheckString; + } + + public void setUdpHealthCheckString(String udpHealthCheckString) { + this.udpHealthCheckString = udpHealthCheckString; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getPortId() { + return portId; + } + + public void setPortId(String portId) { + this.portId = portId; + } + + @Override + public AppSgPortRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppSgPortResponse.java b/src/main/java/com/baidubce/services/blb/model/AppSgPortResponse.java new file mode 100644 index 00000000..073af472 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppSgPortResponse.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for appBlb serverGroup port. + */ +public class AppSgPortResponse extends AbstractBceResponse { + + /** + * the short id of the AppServerGroup. + */ + private String id; + /** + * the status of AppServerGroup. + */ + private String status; + /** + * the port of AppServerGroup. + */ + private Integer port; + /** + * the type of port. + */ + private String type; + /** + * the protocol of health check. + */ + private String healthCheck; + /** + * the port of health check. + */ + private Integer healthCheckPort; + /** + * the uri of health check. + */ + private String healthCheckUrlPath; + /** + * the timeout (in second) of health check. + */ + private Integer healthCheckTimeoutInSecond; + /** + * the interval (in second) of health check. + */ + private Integer healthCheckIntervalInSecond; + /** + * down retry times of health check. + */ + private Integer healthCheckDownRetry; + /** + * up retry times of health check. + */ + private Integer healthCheckUpRetry; + /** + * the normal status of health check. + */ + private String healthCheckNormalStatus; + /** + * the string of udp health check. + */ + private String udpHealthCheckString; + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getHealthCheck() { + return healthCheck; + } + + public void setHealthCheck(String healthCheck) { + this.healthCheck = healthCheck; + } + + public Integer getHealthCheckPort() { + return healthCheckPort; + } + + public void setHealthCheckPort(Integer healthCheckPort) { + this.healthCheckPort = healthCheckPort; + } + + public String getHealthCheckUrlPath() { + return healthCheckUrlPath; + } + + public void setHealthCheckUrlPath(String healthCheckUrlPath) { + this.healthCheckUrlPath = healthCheckUrlPath; + } + + public Integer getHealthCheckTimeoutInSecond() { + return healthCheckTimeoutInSecond; + } + + public void setHealthCheckTimeoutInSecond(Integer healthCheckTimeoutInSecond) { + this.healthCheckTimeoutInSecond = healthCheckTimeoutInSecond; + } + + public Integer getHealthCheckIntervalInSecond() { + return healthCheckIntervalInSecond; + } + + public void setHealthCheckIntervalInSecond(Integer healthCheckIntervalInSecond) { + this.healthCheckIntervalInSecond = healthCheckIntervalInSecond; + } + + public Integer getHealthCheckDownRetry() { + return healthCheckDownRetry; + } + + public void setHealthCheckDownRetry(Integer healthCheckDownRetry) { + this.healthCheckDownRetry = healthCheckDownRetry; + } + + public Integer getHealthCheckUpRetry() { + return healthCheckUpRetry; + } + + public void setHealthCheckUpRetry(Integer healthCheckUpRetry) { + this.healthCheckUpRetry = healthCheckUpRetry; + } + + public String getHealthCheckNormalStatus() { + return healthCheckNormalStatus; + } + + public void setHealthCheckNormalStatus(String healthCheckNormalStatus) { + this.healthCheckNormalStatus = healthCheckNormalStatus; + } + + public String getUdpHealthCheckString() { + return udpHealthCheckString; + } + + public void setUdpHealthCheckString(String udpHealthCheckString) { + this.udpHealthCheckString = udpHealthCheckString; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppSgRequest.java b/src/main/java/com/baidubce/services/blb/model/AppSgRequest.java new file mode 100644 index 00000000..50a7c81e --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppSgRequest.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for appBlb serverGroup. + */ +public class AppSgRequest extends AbstractBceRequest { + + /** + * the short id of the blb. + */ + private String blbId; + /** + * the short id of the AppServerGroup. + */ + private String sgId; + /** + * the name of AppServerGroup. + */ + private String name; + /** + * the description of AppServerGroup. + */ + private String desc; + /** + * the backendServerList of AppServerGroup. + */ + private List backendServerList; + + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + + public AppSgRequest withName(String name) { + this.name = name; + return this; + } + + public AppSgRequest withDesc(String desc) { + this.desc = desc; + return this; + } + + public AppSgRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + public AppSgRequest withSgId(String sgId) { + this.sgId = sgId; + return this; + } + + public String getSgId() { + return sgId; + } + + public void setSgId(String sgId) { + this.sgId = sgId; + } + + public AppSgRequest withBackendServerList(List backendServerList) { + this.setBackendServerList(backendServerList); + return this; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public List getBackendServerList() { + return backendServerList; + } + + public void setBackendServerList(List backendServerList) { + this.backendServerList = backendServerList; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public AppSgRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppSgResponse.java b/src/main/java/com/baidubce/services/blb/model/AppSgResponse.java new file mode 100644 index 00000000..3ab78ac9 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppSgResponse.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for appBlb serverGroup. + */ +public class AppSgResponse extends AbstractBceResponse { + + /** + * the short id of the AppServerGroup. + */ + private String id; + /** + * the name of AppServerGroup. + */ + private String name; + /** + * the description of AppServerGroup. + */ + private String desc; + /** + * the status of AppServerGroup. + */ + private String status; + /** + * the portList of AppServerGroup. + */ + private List portList; + + public List getPortList() { + return portList; + } + + public void setPortList(List portList) { + this.portList = portList; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public String toString() { + return "AppSgResponse{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", desc='" + desc + '\'' + + ", status='" + status + '\'' + + ", portList=" + portList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/AppUnMountBackendServer.java b/src/main/java/com/baidubce/services/blb/model/AppUnMountBackendServer.java new file mode 100644 index 00000000..1dc54422 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/AppUnMountBackendServer.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + + + +/** + * The request for list appBlb unMount backendServer. + */ +public class AppUnMountBackendServer { + + /** + * the instanceId of the backendServer. + */ + private String instanceId; + /** + * the privateIp of the backendServer. + */ + private String privateIp; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getPrivateIp() { + return privateIp; + } + + public void setPrivateIp(String privateIp) { + this.privateIp = privateIp; + } + + @Override + public String toString() { + return "AppUnMountBackendServer{" + + "instanceId='" + instanceId + '\'' + + ", privateIp='" + privateIp + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/BSAction.java b/src/main/java/com/baidubce/services/blb/model/BSAction.java new file mode 100644 index 00000000..4be65328 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/BSAction.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +/** + * The action for operating. + */ +public enum BSAction { + + /** + * The action to modify the attribute. + */ + update +} diff --git a/src/main/java/com/baidubce/services/blb/model/BackendServer.java b/src/main/java/com/baidubce/services/blb/model/BackendServer.java new file mode 100644 index 00000000..9cd18b63 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/BackendServer.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +/** + * The backendServer info modal. + */ +public class BackendServer { + + /** + * the instanceId of the backendServer. + */ + private String instanceId; + /** + * the weight of the backendServer. + */ + private Integer weight; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public Integer getWeight() { + return weight; + } + + public void setWeight(Integer weight) { + this.weight = weight; + } + + @Override + public String toString() { + return "BackendServer{" + + "instanceId='" + instanceId + '\'' + + ", weight=" + weight + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/BackendServerStatus.java b/src/main/java/com/baidubce/services/blb/model/BackendServerStatus.java new file mode 100644 index 00000000..14bc4275 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/BackendServerStatus.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +/** + * The backendServer status modal. + */ +public class BackendServerStatus { + + /** + * the instanceId of the backendServer. + */ + private String instanceId; + /** + * the weight of the backendServer. + */ + private int weight; + /** + * the status of the backendServer. + *

+ * value contains Alive|Dead|Unknown. + */ + private String status; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public int getWeight() { + return weight; + } + + public void setWeight(int weight) { + this.weight = weight; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public String toString() { + return "BackendServerStatus{" + + "instanceId='" + instanceId + '\'' + + ", weight=" + weight + + ", status='" + status + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/BlbDetailRequest.java b/src/main/java/com/baidubce/services/blb/model/BlbDetailRequest.java new file mode 100644 index 00000000..617a1fea --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/BlbDetailRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for get blb detail. + */ +@Getter +@Setter +public class BlbDetailRequest extends AbstractBceRequest { + + /** + * the short id of the blb. + */ + private String blbId; + + + public BlbDetailRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + @Override + public BlbDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/BlbEsgResponse.java b/src/main/java/com/baidubce/services/blb/model/BlbEsgResponse.java new file mode 100644 index 00000000..5af94e0c --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/BlbEsgResponse.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * The response for blb's enterpriseSecurityGroup. + */ +@Getter +@Setter +@ToString +public class BlbEsgResponse extends AbstractBceResponse { + + /** + * the short id of the enterpriseSecurityGroup. + */ + private String enterpriseSecurityGroupId; + /** + * the name of enterpriseSecurityGroup. + */ + private String enterpriseSecurityGroupName; + /** + * the description of enterpriseSecurityGroup. + */ + private String enterpriseSecurityGroupDesc; + /** + * the enterpriseSecurityGroupRules of blb esg. + */ + private List enterpriseSecurityGroupRules; + + @Getter + @Setter + @ToString + public static class BlbEsgRule { + + /** + * The esg rule remark. + */ + private String remark; + + /** + * The parameter to define the rule direction,available value are "ingress/egress" + */ + private String direction; + + /** + * The ethernet protocol + */ + private String ethertype; + + /** + * The port range to specify the port which the rule will work on. + * Available range is rang [0, 65535],"" for all port. + */ + private String portRange; + + /** + * The parameter specify which protocol will the rule work on, the fault value is "" for all protocol. + * Available protocol are tcp,udp and icmp. + */ + private String protocol = ""; + + /** + * The source ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "ingress" + */ + private String sourceIp; + + /** + * The destination ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "egress" + */ + private String destIp; + + /** + * Allow or deny strategy, Available value are allow,deny + */ + private String action; + + /** + * Priority of enterprise security group,the smaller value is,the higher priority is + * if allow strategy and deny strategy have the same priority,deny strategy takes precedence + * Available range is rang [1, 1000] + */ + private Integer priority; + + /** + * The id of enterprise security group rule. + */ + private String enterpriseSecurityGroupRuleId; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/BlbInstance.java b/src/main/java/com/baidubce/services/blb/model/BlbInstance.java new file mode 100644 index 00000000..1dfd91df --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/BlbInstance.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The blb info modal. + */ +public class BlbInstance extends AbstractBceResponse { + + /** + * the short id of the blb. + */ + private String blbId; + /** + * the status of the blb. + */ + private String status; + /** + * the name of the blb. + */ + private String name; + /** + * the description of the blb. + */ + private String desc; + /** + * the address of the blb. + */ + private String address; + /** + * the short vpc id of the blb. + */ + private String vpcId; + /** + * the short subnet id of the blb. + */ + private String subnetId; + /** + * the public ip of the blb. + */ + private String publicIp; + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPublicIp() { + return publicIp; + } + + public void setPublicIp(String publicIp) { + this.publicIp = publicIp; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + @Override + public String toString() { + return "BlbInstance{" + + "blbId='" + blbId + '\'' + + ", status='" + status + '\'' + + ", name='" + name + '\'' + + ", desc='" + desc + '\'' + + ", address='" + address + '\'' + + ", vpcId='" + vpcId + '\'' + + ", subnetId='" + subnetId + '\'' + + ", publicIp='" + publicIp + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/BlbListenerAction.java b/src/main/java/com/baidubce/services/blb/model/BlbListenerAction.java new file mode 100644 index 00000000..984e334d --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/BlbListenerAction.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +/** + * The action for operating. + */ +public enum BlbListenerAction { + + /** + * The action to modify the attribute. + */ + batchdelete +} diff --git a/src/main/java/com/baidubce/services/blb/model/BlbListenerRequest.java b/src/main/java/com/baidubce/services/blb/model/BlbListenerRequest.java new file mode 100644 index 00000000..830010d6 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/BlbListenerRequest.java @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for blb listener operations. + */ +public class BlbListenerRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the blb id of the listener. + */ + private String blbId; + /** + * the backend port of the listener. + */ + private Integer backendPort; + /** + * the port of the listener. + */ + private Integer listenerPort; + /** + * the type of the listener. + *

+ * value contains TCP|UDP|HTTP|HTTPS + */ + @JsonIgnore + private String type; + /** + * the scheduler of the listener. + *

+ * the attribute exist when type is TCP|HTTP + */ + private String scheduler; + /** + * if the listener keep session or not. + *

+ * the attribute exist when type is TCP|HTTP + */ + private boolean keepSession; + /** + * the type of keep session. + */ + private String keepSessionType; + /** + * the duration of keep session. + */ + private Integer keepSessionDuration; + /** + * the cookie name of keep session. + */ + private String keepSessionCookieName; + /** + * if the listener fetch the real ip or not. + *

+ * the attribute exist when type is HTTP. + */ + private boolean xForwardFor; + /** + * the type of health check. + *

+ * the attribute exist when type is HTTP. + */ + private String healthCheckType; + /** + * the port of the health check. + */ + private Integer healthCheckPort; + /** + * the timeout of the health check. + */ + private Integer healthCheckTimeoutInSecond; + /** + * the threshold of unhealthy. + */ + private Integer unhealthyThreshold; + /** + * the threshold of healthy. + */ + private Integer healthyThreshold; + /** + * the interval of the health check. + */ + private Integer healthCheckInterval; + /** + * the uri of health check. + */ + private String healthCheckURI; + /** + * the status of health check when it is normal. + */ + private String healthCheckNormalStatus; + /** + * the max timeout of server. + */ + private Integer serverTimeout; + /** + * the certificate ids of listener. + */ + private List certIds; + /** + * The additional certificates and domains of listener + * @see AdditionalCertDomain + */ + private List additionalCertDomains; + /** + * if the request is ie6 compatible or not. + */ + private Boolean ie6Compatible; + /** + * the port of redirect. + */ + private Integer redirectPort; + /** + * the string to health check when type is UDP + */ + private String healthCheckString; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public Integer getBackendPort() { + return backendPort; + } + + public void setBackendPort(Integer backendPort) { + this.backendPort = backendPort; + } + + public Integer getListenerPort() { + return listenerPort; + } + + public void setListenerPort(Integer listenerPort) { + this.listenerPort = listenerPort; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getScheduler() { + return scheduler; + } + + public void setScheduler(String scheduler) { + this.scheduler = scheduler; + } + + public boolean isKeepSession() { + return keepSession; + } + + public void setKeepSession(boolean keepSession) { + this.keepSession = keepSession; + } + + public String getKeepSessionType() { + return keepSessionType; + } + + public void setKeepSessionType(String keepSessionType) { + this.keepSessionType = keepSessionType; + } + + public Integer getKeepSessionDuration() { + return keepSessionDuration; + } + + public void setKeepSessionDuration(Integer keepSessionDuration) { + this.keepSessionDuration = keepSessionDuration; + } + + public String getKeepSessionCookieName() { + return keepSessionCookieName; + } + + public void setKeepSessionCookieName(String keepSessionCookieName) { + this.keepSessionCookieName = keepSessionCookieName; + } + + public boolean isxForwardFor() { + return xForwardFor; + } + + public void setxForwardFor(boolean xForwardFor) { + this.xForwardFor = xForwardFor; + } + + public String getHealthCheckType() { + return healthCheckType; + } + + public void setHealthCheckType(String healthCheckType) { + this.healthCheckType = healthCheckType; + } + + public Integer getHealthCheckPort() { + return healthCheckPort; + } + + public void setHealthCheckPort(Integer healthCheckPort) { + this.healthCheckPort = healthCheckPort; + } + + public Integer getHealthCheckTimeoutInSecond() { + return healthCheckTimeoutInSecond; + } + + public void setHealthCheckTimeoutInSecond(Integer healthCheckTimeoutInSecond) { + this.healthCheckTimeoutInSecond = healthCheckTimeoutInSecond; + } + + public Integer getUnhealthyThreshold() { + return unhealthyThreshold; + } + + public void setUnhealthyThreshold(Integer unhealthyThreshold) { + this.unhealthyThreshold = unhealthyThreshold; + } + + public Integer getHealthyThreshold() { + return healthyThreshold; + } + + public void setHealthyThreshold(Integer healthyThreshold) { + this.healthyThreshold = healthyThreshold; + } + + public Integer getHealthCheckInterval() { + return healthCheckInterval; + } + + public void setHealthCheckInterval(Integer healthCheckInterval) { + this.healthCheckInterval = healthCheckInterval; + } + + public String getHealthCheckURI() { + return healthCheckURI; + } + + public void setHealthCheckURI(String healthCheckURI) { + this.healthCheckURI = healthCheckURI; + } + + public String getHealthCheckNormalStatus() { + return healthCheckNormalStatus; + } + + public void setHealthCheckNormalStatus(String healthCheckNormalStatus) { + this.healthCheckNormalStatus = healthCheckNormalStatus; + } + + public Integer getServerTimeout() { + return serverTimeout; + } + + public void setServerTimeout(Integer serverTimeout) { + this.serverTimeout = serverTimeout; + } + + public List getCertIds() { + return certIds; + } + + public void setCertIds(List certIds) { + this.certIds = certIds; + } + + public List getAdditionalCertDomains() { + return additionalCertDomains; + } + + public void setAdditionalCertDomains( + List additionalCertDomains) { + this.additionalCertDomains = additionalCertDomains; + } + + public Boolean getIe6Compatible() { + return ie6Compatible; + } + + public void setIe6Compatible(Boolean ie6Compatible) { + this.ie6Compatible = ie6Compatible; + } + + public Integer getRedirectPort() { + return redirectPort; + } + + public void setRedirectPort(Integer redirectPort) { + this.redirectPort = redirectPort; + } + + public String getHealthCheckString() { + return healthCheckString; + } + + public void setHealthCheckString(String healthCheckString) { + this.healthCheckString = healthCheckString; + } + + @Override + public BlbListenerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/BlbSgResponse.java b/src/main/java/com/baidubce/services/blb/model/BlbSgResponse.java new file mode 100644 index 00000000..a152e261 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/BlbSgResponse.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * The response for blb's securityGroup. + */ +@Getter +@Setter +@ToString +public class BlbSgResponse extends AbstractBceResponse { + + /** + * the short id of the securityGroup. + */ + private String securityGroupId; + /** + * the name of securityGroup. + */ + private String securityGroupName; + /** + * the description of securityGroup. + */ + private String securityGroupDesc; + /** + * the name of blb's vpc. + */ + private String vpcName; + /** + * the securityGroupRules of blb sg. + */ + private List securityGroupRules; + + @Getter + @Setter + @ToString + public static class BlbSgRule { + /** + * The sg rule id. + */ + private String securityGroupRuleId; + + /** + * The parameter to define the rule direction,available value are "ingress/egress" + */ + private String direction; + + /** + * The ethernet protocol + */ + private String ethertype; + + /** + * The port range to specify the port which the rule will work on. + * Available range is rang [0, 65535],"" for all port. + */ + private String portRange; + + /** + * The parameter specify which protocol will the rule work on, the fault value is "" for all protocol. + * Available protocol are tcp,udp and icmp. + */ + private String protocol = ""; + + /** + * The id of source securitygroup. + * Only works for direction = "ingress" + */ + private String sourceGroupId; + + /** + * The source ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "ingress" + */ + private String sourceIp; + + /** + * The id of destination securitygroup. + * Only works for direction = "egress" + */ + private String destGroupId; + + /** + * The destination ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "egress" + */ + private String destIp; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/CreateAppPolicyResponse.java b/src/main/java/com/baidubce/services/blb/model/CreateAppPolicyResponse.java new file mode 100644 index 00000000..26e339c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/CreateAppPolicyResponse.java @@ -0,0 +1,31 @@ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for create appBlb policy + */ +public class CreateAppPolicyResponse extends AbstractBceResponse { + + /** + * the ids of the policy. + */ + private List idList; + + public List getIdList() { + return idList; + } + + public void setIdList(List idList) { + this.idList = idList; + } + + @Override + public String toString() { + return "CreateAppPolicyResponse{" + + "idList=" + idList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/CreateBlbRequest.java b/src/main/java/com/baidubce/services/blb/model/CreateBlbRequest.java new file mode 100644 index 00000000..d1838cd7 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/CreateBlbRequest.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for create blb. + */ +public class CreateBlbRequest extends AbstractBceRequest { + + /** + * the name of blb. + */ + private String name; + /** + * the description of blb. + */ + private String desc; + /** + * the vpc id of blb. + */ + private String vpcId; + /** + * the subnet id of blb. + */ + private String subnetId; + /** + * the tags of blb. + */ + private List tags; + /** + * the type of blb, it can be 'normal' or 'ipv6'. + */ + private String type; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public CreateBlbRequest withName(String name) { + this.name = name; + return this; + } + + public CreateBlbRequest withDesc(String desc) { + this.desc = desc; + return this; + } + + public CreateBlbRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + public CreateBlbRequest withSubnetId(String subnetId) { + this.setSubnetId(subnetId); + return this; + } + + public CreateBlbRequest withTags(List tags) { + this.setTags(tags); + return this; + } + + public CreateBlbRequest withType(String type) { + this.setType(type); + return this; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public CreateBlbRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + @Override + public CreateBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/CreateBlbResponse.java b/src/main/java/com/baidubce/services/blb/model/CreateBlbResponse.java new file mode 100644 index 00000000..534b1574 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/CreateBlbResponse.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.ListResponse; + +/** + * The response for create blb. + */ +public class CreateBlbResponse extends ListResponse { + + /** + * the id of the blb. + */ + private String blbId; + /** + * the name of the blb. + */ + private String name; + /** + * the description of the blb. + */ + private String desc; + /** + * the address of the blb. + */ + private String address; + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + @Override + public String toString() { + return "CreateBlbResponse{" + + "blbId='" + + blbId + + '\'' + + ", name='" + + name + + '\'' + + ", desc='" + + desc + + '\'' + + ", address='" + + address + + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/DeleteAppPolicyRequest.java b/src/main/java/com/baidubce/services/blb/model/DeleteAppPolicyRequest.java new file mode 100644 index 00000000..c047d6c4 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/DeleteAppPolicyRequest.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request for delete appBlb policy. + */ +public class DeleteAppPolicyRequest extends AbstractBceRequest { + + /** + * the blb id of the policy + */ + private String blbId; + /** + * the port of the policy + */ + private Integer port; + /** + * the id of the policy list + */ + private List policyIdList; + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + public DeleteAppPolicyRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + public DeleteAppPolicyRequest withPort(Integer port) { + this.port = port; + return this; + } + + public DeleteAppPolicyRequest withPolicyIdList(List policyIdList) { + this.policyIdList = policyIdList; + return this; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public List getPolicyIdList() { + return policyIdList; + } + + public void setPolicyIdList(List policyIdList) { + this.policyIdList = policyIdList; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public DeleteAppPolicyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/DeleteBSRequest.java b/src/main/java/com/baidubce/services/blb/model/DeleteBSRequest.java new file mode 100644 index 00000000..dd4b4246 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/DeleteBSRequest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for delete backendServer. + */ +public class DeleteBSRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the blb id of the backendServer. + */ + @JsonIgnore + private String blbId; + /** + * the id list of the backendServer to deleting. + */ + private List backendServerList; + + public DeleteBSRequest(String blbId, List backendServerList) { + this.blbId = blbId; + this.backendServerList = backendServerList; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public List getBackendServerList() { + return backendServerList; + } + + public void setBackendServerList(List backendServerList) { + this.backendServerList = backendServerList; + } + + public DeleteBSRequest withClientTokent(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public DeleteBSRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public DeleteBSRequest withBackendServerList(List backendServerList) { + this.setBackendServerList(backendServerList); + return this; + } + + @Override + public DeleteBSRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/DeleteBlbRequest.java b/src/main/java/com/baidubce/services/blb/model/DeleteBlbRequest.java new file mode 100644 index 00000000..8fa2e7d5 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/DeleteBlbRequest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for delete blb. + */ +public class DeleteBlbRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the id of blb to delete. + */ + private String blbId; + + public DeleteBlbRequest() { + } + + public DeleteBlbRequest(String blbId) { + this.blbId = blbId; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public DeleteBlbRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public DeleteBlbRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + @Override + public DeleteBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/DeleteListenerRequest.java b/src/main/java/com/baidubce/services/blb/model/DeleteListenerRequest.java new file mode 100644 index 00000000..bc3a1a81 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/DeleteListenerRequest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for delete listener. + */ +public class DeleteListenerRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the blb id of listener. + */ + @JsonIgnore + private String blbId; + /** + * the ports of the listener to delete. + */ + private List portList; + + public DeleteListenerRequest() { + } + + public DeleteListenerRequest(String blbId, List portList) { + this.blbId = blbId; + this.portList = portList; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public List getPortList() { + return portList; + } + + public void setPortList(List portList) { + this.portList = portList; + } + + public DeleteListenerRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public DeleteListenerRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public DeleteListenerRequest withPortList(List portList) { + this.setPortList(portList); + return this; + } + + @Override + public DeleteListenerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/EsgOperateRequest.java b/src/main/java/com/baidubce/services/blb/model/EsgOperateRequest.java new file mode 100644 index 00000000..108c024c --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/EsgOperateRequest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for operating blb's esg. + */ +@Getter +@Setter +public class EsgOperateRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * the blb id. + */ + private String blbId; + /** + * the list of enterprise security group ids. + */ + private List enterpriseSecurityGroupIds; + + public EsgOperateRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public EsgOperateRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public EsgOperateRequest withEnterpriseSecurityGroupIds(List enterpriseSecurityGroupIds) { + this.enterpriseSecurityGroupIds = enterpriseSecurityGroupIds; + return this; + } + + @Override + public EsgOperateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/HttpListener.java b/src/main/java/com/baidubce/services/blb/model/HttpListener.java new file mode 100644 index 00000000..c130007d --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/HttpListener.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Http listener info modal. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class HttpListener extends ListenerBase { + + /** + * if keep session or not. + */ + private Boolean keepSession; + /** + * the type of keep session. + */ + private String keepSessionType; + /** + * the duration of the keep session. + */ + private Integer keepSessionDuration; + /** + * the cookie name of the keep session. + */ + private String keepSessionCookieName; + /** + * if fetch the real ip or not. + */ + private Boolean xForwardFor; + /** + * the type of the health check. + */ + private String healthCheckType; + /** + * the port of the health check. + */ + private Integer healthCheckPort; + /** + * the uri of the health check. + */ + private String healthCheckURI; + /** + * the status of health check when it is normal. + */ + private String healthCheckNormalStatus; + /** + * the max timeout of server. + */ + private Integer serverTimeout; + /** + * the port of redirect. + */ + private int redirectPort; + + public Boolean getKeepSession() { + return keepSession; + } + + public void setKeepSession(Boolean keepSession) { + this.keepSession = keepSession; + } + + public String getKeepSessionType() { + return keepSessionType; + } + + public void setKeepSessionType(String keepSessionType) { + this.keepSessionType = keepSessionType; + } + + public Integer getKeepSessionDuration() { + return keepSessionDuration; + } + + public void setKeepSessionDuration(Integer keepSessionDuration) { + this.keepSessionDuration = keepSessionDuration; + } + + public String getKeepSessionCookieName() { + return keepSessionCookieName; + } + + public void setKeepSessionCookieName(String keepSessionCookieName) { + this.keepSessionCookieName = keepSessionCookieName; + } + + public Boolean getxForwardFor() { + return xForwardFor; + } + + public void setxForwardFor(Boolean xForwardFor) { + this.xForwardFor = xForwardFor; + } + + public String getHealthCheckType() { + return healthCheckType; + } + + public void setHealthCheckType(String healthCheckType) { + this.healthCheckType = healthCheckType; + } + + public Integer getHealthCheckPort() { + return healthCheckPort; + } + + public void setHealthCheckPort(Integer healthCheckPort) { + this.healthCheckPort = healthCheckPort; + } + + public String getHealthCheckURI() { + return healthCheckURI; + } + + public void setHealthCheckURI(String healthCheckURI) { + this.healthCheckURI = healthCheckURI; + } + + public String getHealthCheckNormalStatus() { + return healthCheckNormalStatus; + } + + public void setHealthCheckNormalStatus(String healthCheckNormalStatus) { + this.healthCheckNormalStatus = healthCheckNormalStatus; + } + + public Integer getServerTimeout() { + return serverTimeout; + } + + public void setServerTimeout(Integer serverTimeout) { + this.serverTimeout = serverTimeout; + } + + public int getRedirectPort() { + return redirectPort; + } + + public void setRedirectPort(int redirectPort) { + this.redirectPort = redirectPort; + } + + @Override + public String toString() { + return "HttpListener{" + + "keepSession=" + keepSession + + ", keepSessionType='" + keepSessionType + '\'' + + ", keepSessionDuration=" + keepSessionDuration + + ", keepSessionCookieName='" + keepSessionCookieName + '\'' + + ", xForwardFor=" + xForwardFor + + ", healthCheckType='" + healthCheckType + '\'' + + ", healthCheckPort=" + healthCheckPort + + ", healthCheckURI='" + healthCheckURI + '\'' + + ", healthCheckNormalStatus='" + healthCheckNormalStatus + '\'' + + ", serverTimeout=" + serverTimeout + + ", redirectPort=" + redirectPort + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/HttpsListener.java b/src/main/java/com/baidubce/services/blb/model/HttpsListener.java new file mode 100644 index 00000000..8023dfa6 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/HttpsListener.java @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Https listener info modal. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class HttpsListener extends ListenerBase { + + /** + * if keep session or not. + */ + private Boolean keepSession; + /** + * the type of keep session. + */ + private String keepSessionType; + /** + * the duration of the keep session. + */ + private Integer keepSessionDuration; + /** + * the cookie name of the keep session. + */ + private String keepSessionCookieName; + /** + * if fetch the real ip or not. + */ + private Boolean xForwardFor; + /** + * the type of the health check. + */ + private String healthCheckType; + /** + * the port of the health check. + */ + private Integer healthCheckPort; + /** + * the uri of the health check. + */ + private String healthCheckURI; + /** + * the status of health check when it is normal. + */ + private String healthCheckNormalStatus; + /** + * the max timeout of server. + */ + private Integer serverTimeout; + /** + * the certificate ids of listener. + */ + private List certIds; + /** + * The additional certificates and domains of listener + * + * @see AdditionalCertDomain + */ + private List additionalCertDomains; + /** + * if the request is ie6 compatible or not. + */ + private boolean ie6Compatible; + + public Boolean getKeepSession() { + return keepSession; + } + + public void setKeepSession(Boolean keepSession) { + this.keepSession = keepSession; + } + + public String getKeepSessionType() { + return keepSessionType; + } + + public void setKeepSessionType(String keepSessionType) { + this.keepSessionType = keepSessionType; + } + + public Integer getKeepSessionDuration() { + return keepSessionDuration; + } + + public void setKeepSessionDuration(Integer keepSessionDuration) { + this.keepSessionDuration = keepSessionDuration; + } + + public String getKeepSessionCookieName() { + return keepSessionCookieName; + } + + public void setKeepSessionCookieName(String keepSessionCookieName) { + this.keepSessionCookieName = keepSessionCookieName; + } + + public Boolean getxForwardFor() { + return xForwardFor; + } + + public void setxForwardFor(Boolean xForwardFor) { + this.xForwardFor = xForwardFor; + } + + public String getHealthCheckType() { + return healthCheckType; + } + + public void setHealthCheckType(String healthCheckType) { + this.healthCheckType = healthCheckType; + } + + public Integer getHealthCheckPort() { + return healthCheckPort; + } + + public void setHealthCheckPort(Integer healthCheckPort) { + this.healthCheckPort = healthCheckPort; + } + + public String getHealthCheckURI() { + return healthCheckURI; + } + + public void setHealthCheckURI(String healthCheckURI) { + this.healthCheckURI = healthCheckURI; + } + + public String getHealthCheckNormalStatus() { + return healthCheckNormalStatus; + } + + public void setHealthCheckNormalStatus(String healthCheckNormalStatus) { + this.healthCheckNormalStatus = healthCheckNormalStatus; + } + + public Integer getServerTimeout() { + return serverTimeout; + } + + public void setServerTimeout(Integer serverTimeout) { + this.serverTimeout = serverTimeout; + } + + public List getCertIds() { + return certIds; + } + + public void setCertIds(List certIds) { + this.certIds = certIds; + } + + public List getAdditionalCertDomains() { + return additionalCertDomains; + } + + public void setAdditionalCertDomains( + List additionalCertDomains) { + this.additionalCertDomains = additionalCertDomains; + } + + public boolean isIe6Compatible() { + return ie6Compatible; + } + + public void setIe6Compatible(boolean ie6Compatible) { + this.ie6Compatible = ie6Compatible; + } + + @Override + public String toString() { + return "HttpsListener{" + + "keepSession=" + keepSession + + ", keepSessionType='" + keepSessionType + '\'' + + ", keepSessionDuration=" + keepSessionDuration + + ", keepSessionCookieName='" + keepSessionCookieName + '\'' + + ", xForwardFor=" + xForwardFor + + ", healthCheckType='" + healthCheckType + '\'' + + ", healthCheckPort=" + healthCheckPort + + ", healthCheckURI='" + healthCheckURI + '\'' + + ", healthCheckNormalStatus='" + healthCheckNormalStatus + '\'' + + ", serverTimeout=" + serverTimeout + + ", certIds=" + certIds + + ", additionalCertDomains=" + additionalCertDomains + + ", ie6Compatible=" + ie6Compatible + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAllListenerRequest.java b/src/main/java/com/baidubce/services/blb/model/ListAllListenerRequest.java new file mode 100644 index 00000000..36057764 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAllListenerRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list blb's all listeners. + */ +public class ListAllListenerRequest extends ListRequest { + + /** + * the blb id of listener. + */ + private String blbId; + /** + * the port of the listener. + */ + private int listenerPort; + + public ListAllListenerRequest() { + } + + public ListAllListenerRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ListAllListenerRequest withListenerPort(int listenerPort) { + this.setListenerPort(listenerPort); + return this; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public int getListenerPort() { + return listenerPort; + } + + public void setListenerPort(int listenerPort) { + this.listenerPort = listenerPort; + } + + @Override + public ListAllListenerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppIgRequest.java b/src/main/java/com/baidubce/services/blb/model/ListAppIgRequest.java new file mode 100644 index 00000000..04f292de --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppIgRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list appBlb ipGroup. + */ +public class ListAppIgRequest extends ListRequest { + + /** + * the blb id of the appIpGroup + */ + private String blbId; + /** + * the name of the appIpGroup + */ + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ListAppIgRequest(String blbId) { + this.blbId = blbId; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public ListAppIgRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ListAppIgRequest withName(String name) { + this.setName(name); + return this; + } + + @Override + public ListAppIgRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppIgResponse.java b/src/main/java/com/baidubce/services/blb/model/ListAppIgResponse.java new file mode 100644 index 00000000..22cc0d65 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppIgResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response for list appBlb ipGroup + */ +public class ListAppIgResponse extends ListResponse { + + /** + * the appIpGroup info list. + */ + private List appIpGroupList; + + public List getAppIpGroupList() { + return appIpGroupList; + } + + public void setAppIpGroupList(List appIpGroupList) { + this.appIpGroupList = appIpGroupList; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppIpGroupMemberRequest.java b/src/main/java/com/baidubce/services/blb/model/ListAppIpGroupMemberRequest.java new file mode 100644 index 00000000..b27e9422 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppIpGroupMemberRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list appBlb ipGroup member. + */ +public class ListAppIpGroupMemberRequest extends ListRequest { + + /** + * the blb id of the ipGroup member + */ + private String blbId; + /** + * the id of the ipGroup + */ + private String ipGroupId; + + public String getIpGroupId() { + return ipGroupId; + } + + public void setIpGroupId(String ipGroupId) { + this.ipGroupId = ipGroupId; + } + + public ListAppIpGroupMemberRequest(String blbId) { + this.blbId = blbId; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public ListAppIpGroupMemberRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ListAppIpGroupMemberRequest withIpGroupId(String ipGroupId) { + this.setIpGroupId(ipGroupId); + return this; + } + + @Override + public ListAppIpGroupMemberRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppIpGroupMemberResponse.java b/src/main/java/com/baidubce/services/blb/model/ListAppIpGroupMemberResponse.java new file mode 100644 index 00000000..5c39260b --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppIpGroupMemberResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response for list appBlb ipGroup member + */ +public class ListAppIpGroupMemberResponse extends ListResponse { + + /** + * the member info list. + */ + private List memberList; + + public List getMemberList() { + return memberList; + } + + public void setMemberList(List memberList) { + this.memberList = memberList; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppPolicyRequest.java b/src/main/java/com/baidubce/services/blb/model/ListAppPolicyRequest.java new file mode 100644 index 00000000..89efdf3e --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppPolicyRequest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list appBlb policy. + */ +public class ListAppPolicyRequest extends ListRequest { + + /** + * the blb id of the policy + */ + private String blbId; + /** + * the port of the policy + */ + private Integer port; + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public ListAppPolicyRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ListAppPolicyRequest withPort(Integer port) { + this.setPort(port); + return this; + } + + @Override + public ListAppPolicyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppPolicyResponse.java b/src/main/java/com/baidubce/services/blb/model/ListAppPolicyResponse.java new file mode 100644 index 00000000..b898e354 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppPolicyResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response for list appBlb policy + */ +public class ListAppPolicyResponse extends ListResponse { + + /** + * the policy info list. + */ + private List policyList; + + public List getPolicyList() { + return policyList; + } + + public void setPolicyList(List policyList) { + this.policyList = policyList; + } + + @Override + public String toString() { + return "ListAppPolicyResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "policyList=" + policyList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppRsMountResponse.java b/src/main/java/com/baidubce/services/blb/model/ListAppRsMountResponse.java new file mode 100644 index 00000000..350cfb6e --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppRsMountResponse.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for list appBlb backendServer + */ +public class ListAppRsMountResponse extends AbstractBceResponse { + + /** + * the backendServer info list. + */ + private List backendServerList; + + public List getBackendServerList() { + return backendServerList; + } + + public void setBackendServerList(List backendServerList) { + this.backendServerList = backendServerList; + } + + @Override + public String toString() { + return "ListAppRsMountResponse{" + + "backendServerList=" + backendServerList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppRsRequest.java b/src/main/java/com/baidubce/services/blb/model/ListAppRsRequest.java new file mode 100644 index 00000000..9a0888f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppRsRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list appBlb backendServer. + */ +public class ListAppRsRequest extends ListRequest { + + /** + * the blb id of the backendServer + */ + private String blbId; + /** + * the appServerGroup id of the backendServer + */ + private String sgId; + + public String getSgId() { + return sgId; + } + + public void setSgId(String sgId) { + this.sgId = sgId; + } + + public ListAppRsRequest(String blbId) { + this.blbId = blbId; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public ListAppRsRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ListAppRsRequest withSgId(String sgId) { + this.setSgId(sgId); + return this; + } + + @Override + public ListAppRsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppRsResponse.java b/src/main/java/com/baidubce/services/blb/model/ListAppRsResponse.java new file mode 100644 index 00000000..bf48d34c --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppRsResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response for list appBlb backendServer + */ +public class ListAppRsResponse extends ListResponse { + + /** + * the backendServer info list. + */ + private List backendServerList; + + public List getBackendServerList() { + return backendServerList; + } + + public void setBackendServerList(List backendServerList) { + this.backendServerList = backendServerList; + } + + @Override + public String toString() { + return "ListAppRsResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "backendServerList=" + backendServerList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppRsUnMountResponse.java b/src/main/java/com/baidubce/services/blb/model/ListAppRsUnMountResponse.java new file mode 100644 index 00000000..22729c7a --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppRsUnMountResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for list appBlb backendServer + */ +public class ListAppRsUnMountResponse extends AbstractBceResponse { + /** + * the backendServer info list. + */ + private List backendServerList; + + public List getBackendServerList() { + return backendServerList; + } + + public void setBackendServerList(List backendServerList) { + this.backendServerList = backendServerList; + } + + @Override + public String toString() { + return "ListAppRsUnMountResponse{" + + "backendServerList=" + backendServerList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppSgRequest.java b/src/main/java/com/baidubce/services/blb/model/ListAppSgRequest.java new file mode 100644 index 00000000..a0c5ced7 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppSgRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list appBlb serverGroup. + */ +public class ListAppSgRequest extends ListRequest { + + /** + * the blb id of the appServerGroup + */ + private String blbId; + /** + * the name of the appServerGroup + */ + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ListAppSgRequest(String blbId) { + this.blbId = blbId; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public ListAppSgRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ListAppSgRequest withName(String name) { + this.setName(name); + return this; + } + + @Override + public ListAppSgRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListAppSgResponse.java b/src/main/java/com/baidubce/services/blb/model/ListAppSgResponse.java new file mode 100644 index 00000000..1313854a --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListAppSgResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response for list appBlb serverGroup + */ +public class ListAppSgResponse extends ListResponse { + + /** + * the appServerGroup info list. + */ + private List appServerGroupList; + + public List getAppServerGroupList() { + return appServerGroupList; + } + + public void setAppServerGroupList(List appServerGroupList) { + this.appServerGroupList = appServerGroupList; + } + + @Override + public String toString() { + return "ListAppSgResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "appServerGroupList=" + appServerGroupList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListBackendServerRequest.java b/src/main/java/com/baidubce/services/blb/model/ListBackendServerRequest.java new file mode 100644 index 00000000..6cb7ebb5 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListBackendServerRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list backendServer. + */ +public class ListBackendServerRequest extends ListRequest { + + /** + * the blb id of the backendServer + */ + private String blbId; + + public ListBackendServerRequest(String blbId) { + this.blbId = blbId; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public ListBackendServerRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + @Override + public ListBackendServerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListBackendServerResponse.java b/src/main/java/com/baidubce/services/blb/model/ListBackendServerResponse.java new file mode 100644 index 00000000..0b490d69 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListBackendServerResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +/** + * The response for list backendServer + */ +public class ListBackendServerResponse extends ListResponse { + + /** + * the backendServer info list. + */ + private List backendServerList; + + public List getBackendServerList() { + return backendServerList; + } + + public void setBackendServerList(List backendServerList) { + this.backendServerList = backendServerList; + } + + @Override + public String toString() { + return "ListBackendServerResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "backendServerList=" + backendServerList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListBackendServerStatusRequest.java b/src/main/java/com/baidubce/services/blb/model/ListBackendServerStatusRequest.java new file mode 100644 index 00000000..d85089f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListBackendServerStatusRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list backendServer status. + */ +public class ListBackendServerStatusRequest extends ListRequest { + + /** + * the blb id of the backendServer. + */ + private String blbId; + /** + * the port of the listener. + */ + private int listenerPort; + + public ListBackendServerStatusRequest(String blbId, int listenerPort) { + this.blbId = blbId; + this.listenerPort = listenerPort; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public int getListenerPort() { + return listenerPort; + } + + public void setListenerPort(int listenerPort) { + this.listenerPort = listenerPort; + } + + public ListBackendServerStatusRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ListBackendServerStatusRequest withListenerPort(int listenerPort) { + this.setListenerPort(listenerPort); + return this; + } + + @Override + public ListBackendServerStatusRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListBackendServerStatusResponse.java b/src/main/java/com/baidubce/services/blb/model/ListBackendServerStatusResponse.java new file mode 100644 index 00000000..9fe13284 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListBackendServerStatusResponse.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +/** + * The response for list backendServer status. + */ +public class ListBackendServerStatusResponse extends ListResponse { + + /** + * the backendServer info list. + */ + private List backendServerList; + /** + * the type of the backendServer. + */ + private String type; + /** + * the port of the listener. + */ + private int listenerPort; + /** + * the port of the backend. + */ + private int backendPort; + + public List getBackendServerList() { + return backendServerList; + } + + public void setBackendServerList(List backendServerList) { + this.backendServerList = backendServerList; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int getListenerPort() { + return listenerPort; + } + + public void setListenerPort(int listenerPort) { + this.listenerPort = listenerPort; + } + + public int getBackendPort() { + return backendPort; + } + + public void setBackendPort(int backendPort) { + this.backendPort = backendPort; + } + + @Override + public String toString() { + return "ListBackendServerStatusResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "backendServerList=" + backendServerList + + ", type='" + type + '\'' + + ", listenerPort=" + listenerPort + + ", backendPort=" + backendPort + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListBlbEsgResponse.java b/src/main/java/com/baidubce/services/blb/model/ListBlbEsgResponse.java new file mode 100644 index 00000000..0e382337 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListBlbEsgResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * The response for list blb's esg. + */ +@Getter +@Setter +@ToString +public class ListBlbEsgResponse extends AbstractBceResponse { + /** + * the esg info list of blb. + */ + private List enterpriseSecurityGroups; +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListBlbRequest.java b/src/main/java/com/baidubce/services/blb/model/ListBlbRequest.java new file mode 100644 index 00000000..cdff248c --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListBlbRequest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list blb. + */ +public class ListBlbRequest extends ListRequest { + + /** + * the address of the blb. + */ + private String address; + /** + * the name of the blb. + */ + private String name; + /** + * the shor id of the blb. + */ + private String blbId; + /** + * the id of the bcc. + */ + private String bccId; + /** + * the type of the blb. + */ + private String type; + + public ListBlbRequest withAddress(String address) { + this.address = address; + return this; + } + + public ListBlbRequest withName(String name) { + this.name = name; + return this; + } + + public ListBlbRequest withBlbId(String blbId) { + this.blbId = blbId; + return this; + } + + public ListBlbRequest withBccId(String bccId) { + this.bccId = bccId; + return this; + } + + public ListBlbRequest withType(String type) { + this.type = type; + return this; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public String getBccId() { + return bccId; + } + + public void setBccId(String bccId) { + this.bccId = bccId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public ListBlbRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListBlbResponse.java b/src/main/java/com/baidubce/services/blb/model/ListBlbResponse.java new file mode 100644 index 00000000..ae183aaa --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListBlbResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +/** + * The response for list blb. + */ +public class ListBlbResponse extends ListResponse { + + /** + * the blb info list. + */ + private List blbList; + + public List getBlbList() { + return blbList; + } + + public void setBlbList(List blbList) { + this.blbList = blbList; + } + + @Override + public String toString() { + return "ListBlbResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "blbList=" + blbList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListBlbSgRequest.java b/src/main/java/com/baidubce/services/blb/model/ListBlbSgRequest.java new file mode 100644 index 00000000..8bf721b8 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListBlbSgRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for list blb's sg. + */ +@Getter +@Setter +public class ListBlbSgRequest extends AbstractBceRequest { + /** + * the blb id. + */ + private String blbId; + + public ListBlbSgRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + @Override + public ListBlbSgRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListBlbSgResponse.java b/src/main/java/com/baidubce/services/blb/model/ListBlbSgResponse.java new file mode 100644 index 00000000..c7af2205 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListBlbSgResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * The response for list blb's sg. + */ +@Getter +@Setter +@ToString +public class ListBlbSgResponse extends AbstractBceResponse { + /** + * the sg info list of blb. + */ + private List blbSecurityGroups; +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListListenerRequest.java b/src/main/java/com/baidubce/services/blb/model/ListListenerRequest.java new file mode 100644 index 00000000..c55e7474 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListListenerRequest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request for list listener. + */ +public class ListListenerRequest extends ListRequest { + + /** + * the blb id of listener. + */ + private String blbId; + /** + * the port of the listener. + */ + private int listenerPort; + /** + * the type of the listener. + */ + private String type; + + public ListListenerRequest() { + } + + public ListListenerRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ListListenerRequest withListenerPort(int listenerPort) { + this.setListenerPort(listenerPort); + return this; + } + + public ListListenerRequest withType(String type) { + this.setType(type); + return this; + } + + public ListListenerRequest(String blbId, int listenerPort, String type) { + this.blbId = blbId; + this.listenerPort = listenerPort; + this.type = type; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public int getListenerPort() { + return listenerPort; + } + + public void setListenerPort(int listenerPort) { + this.listenerPort = listenerPort; + } + + @Override + public ListListenerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListListenerResponse.java b/src/main/java/com/baidubce/services/blb/model/ListListenerResponse.java new file mode 100644 index 00000000..d249db55 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListListenerResponse.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +/** + * The response for list listener. + */ +public class ListListenerResponse extends ListResponse { + + /** + * the listener info list. + */ + private List listenerList; + + public List getListenerList() { + return listenerList; + } + + public void setListenerList(List listenerList) { + this.listenerList = listenerList; + } + + @Override + public String toString() { + return "ListListenerResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "listenerList=" + listenerList + + '}'; + } +} + + diff --git a/src/main/java/com/baidubce/services/blb/model/ListenerBase.java b/src/main/java/com/baidubce/services/blb/model/ListenerBase.java new file mode 100644 index 00000000..2037ab7a --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListenerBase.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +/** + * The base listener info modal. + */ +public class ListenerBase { + + /** + * the port of the listener. + */ + private Integer listenerPort; + /** + * the backend port of the listener. + */ + private Integer backendPort; + /** + * the scheduler of blb. + */ + private String scheduler; + /** + * the timeout (in second) of health check. + */ + private Integer healthCheckTimeoutInSecond; + /** + * the interval of health check. + */ + private Integer healthCheckInterval; + /** + * the threshold of unhealthy. + */ + private Integer unhealthyThreshold; + /** + * the threshold of healthy. + */ + private Integer healthyThreshold; + + public Integer getListenerPort() { + return listenerPort; + } + + public void setListenerPort(Integer listenerPort) { + this.listenerPort = listenerPort; + } + + public Integer getBackendPort() { + return backendPort; + } + + public void setBackendPort(Integer backendPort) { + this.backendPort = backendPort; + } + + public String getScheduler() { + return scheduler; + } + + public void setScheduler(String scheduler) { + this.scheduler = scheduler; + } + + public Integer getHealthCheckTimeoutInSecond() { + return healthCheckTimeoutInSecond; + } + + public void setHealthCheckTimeoutInSecond(Integer healthCheckTimeoutInSecond) { + this.healthCheckTimeoutInSecond = healthCheckTimeoutInSecond; + } + + public Integer getHealthCheckInterval() { + return healthCheckInterval; + } + + public void setHealthCheckInterval(Integer healthCheckInterval) { + this.healthCheckInterval = healthCheckInterval; + } + + public Integer getUnhealthyThreshold() { + return unhealthyThreshold; + } + + public void setUnhealthyThreshold(Integer unhealthyThreshold) { + this.unhealthyThreshold = unhealthyThreshold; + } + + public Integer getHealthyThreshold() { + return healthyThreshold; + } + + public void setHealthyThreshold(Integer healthyThreshold) { + this.healthyThreshold = healthyThreshold; + } + + @Override + public String toString() { + return "ListenerBase{" + + "listenerPort=" + listenerPort + + ", backendPort=" + backendPort + + ", scheduler='" + scheduler + '\'' + + ", healthCheckTimeoutInSecond=" + healthCheckTimeoutInSecond + + ", healthCheckInterval=" + healthCheckInterval + + ", unhealthyThreshold=" + unhealthyThreshold + + ", healthyThreshold=" + healthyThreshold + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ListenerConstant.java b/src/main/java/com/baidubce/services/blb/model/ListenerConstant.java new file mode 100644 index 00000000..3ac0ab2a --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ListenerConstant.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** + * The constants of listener + */ +public class ListenerConstant { + + public static final String HTTPS_LISTENER = "HTTPS"; + public static final String HTTP_LISTENER = "HTTP"; + public static final String TCP_LISTENER = "TCP"; + public static final String UDP_LISTENER = "UDP"; + public static final String SSL_LISTENER = "SSL"; + + public static final Set LISTENER_SET = new HashSet(Arrays.asList(HTTPS_LISTENER, HTTP_LISTENER, + TCP_LISTENER, UDP_LISTENER, SSL_LISTENER)); + +} diff --git a/src/main/java/com/baidubce/services/blb/model/ModifyBSAttributesRequest.java b/src/main/java/com/baidubce/services/blb/model/ModifyBSAttributesRequest.java new file mode 100644 index 00000000..1ca79f3a --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ModifyBSAttributesRequest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for modify backendServer attributes. + */ +public class ModifyBSAttributesRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the id of the blb. + */ + @JsonIgnore + private String blbId; + + /** + * the backendServers after modifying. + */ + private List backendServerList; + + public ModifyBSAttributesRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public ModifyBSAttributesRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ModifyBSAttributesRequest withBackendServerList(List backendServerList) { + this.setBackendServerList(backendServerList); + return this; + } + + public ModifyBSAttributesRequest(String blbId, List backendServerList) { + this.blbId = blbId; + this.backendServerList = backendServerList; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public List getBackendServerList() { + return backendServerList; + } + + public void setBackendServerList(List backendServerList) { + this.backendServerList = backendServerList; + } + + @Override + public ModifyBSAttributesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/ModifyBlbAttributesRequest.java b/src/main/java/com/baidubce/services/blb/model/ModifyBlbAttributesRequest.java new file mode 100644 index 00000000..0f8a5617 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/ModifyBlbAttributesRequest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for modify blb attributes. + */ +public class ModifyBlbAttributesRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the id of the specified blb. + */ + @JsonIgnore + private String blbId; + + /** + * the name after modifying. + */ + private String name; + + /** + * the description after modifying. + */ + private String desc; + + public ModifyBlbAttributesRequest() { + } + + public ModifyBlbAttributesRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public ModifyBlbAttributesRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public ModifyBlbAttributesRequest withName(String name) { + this.setName(name); + return this; + } + + public ModifyBlbAttributesRequest withDesc(String desc) { + this.setDesc(desc); + return this; + } + + public ModifyBlbAttributesRequest(String blbId, String name, String desc) { + this.blbId = blbId; + this.name = name; + this.desc = desc; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getBlbId() { + return blbId; + } + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + @Override + public ModifyBlbAttributesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/SgOperateRequest.java b/src/main/java/com/baidubce/services/blb/model/SgOperateRequest.java new file mode 100644 index 00000000..af8ed8e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/SgOperateRequest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for operating blb's sg. + */ +@Getter +@Setter +public class SgOperateRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * the blb id. + */ + private String blbId; + /** + * the list of security group ids. + */ + private List securityGroupIds; + + public SgOperateRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public SgOperateRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public SgOperateRequest withSecurityGroupIds(List securityGroupIds) { + this.securityGroupIds = securityGroupIds; + return this; + } + + @Override + public SgOperateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/SslListener.java b/src/main/java/com/baidubce/services/blb/model/SslListener.java new file mode 100644 index 00000000..1bbd93ab --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/SslListener.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * SSL listener info modal. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class SslListener extends ListenerBase { + + /** + * the certificate ids of listener. + */ + private List certIds; + /** + * the encryptionType of listener. + */ + private String encryptionType; + /** + * the encryptionProtocols of listener. + */ + private List encryptionProtocols; + /** + * open dualAuth or not. + */ + private boolean dualAuth; + /** + * the clientCert ids of listener. + */ + private List clientCertIds; + + public List getCertIds() { + return certIds; + } + + public void setCertIds(List certIds) { + this.certIds = certIds; + } + + public String getEncryptionType() { + return encryptionType; + } + + public void setEncryptionType(String encryptionType) { + this.encryptionType = encryptionType; + } + + public List getEncryptionProtocols() { + return encryptionProtocols; + } + + public void setEncryptionProtocols(List encryptionProtocols) { + this.encryptionProtocols = encryptionProtocols; + } + + public boolean isDualAuth() { + return dualAuth; + } + + public void setDualAuth(boolean dualAuth) { + this.dualAuth = dualAuth; + } + + public List getClientCertIds() { + return clientCertIds; + } + + public void setClientCertIds(List clientCertIds) { + this.clientCertIds = clientCertIds; + } + + @Override + public String toString() { + return "SslListener{" + + "certIds=" + certIds + + ", encryptionType='" + encryptionType + '\'' + + ", encryptionProtocols=" + encryptionProtocols + + ", dualAuth=" + dualAuth + + ", clientCertIds=" + clientCertIds + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/TcpListener.java b/src/main/java/com/baidubce/services/blb/model/TcpListener.java new file mode 100644 index 00000000..0252f5d9 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/TcpListener.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Tcp listener info modal. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class TcpListener extends ListenerBase { +} diff --git a/src/main/java/com/baidubce/services/blb/model/UdpListener.java b/src/main/java/com/baidubce/services/blb/model/UdpListener.java new file mode 100644 index 00000000..e26e4ce4 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/UdpListener.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Ddp listener info modal. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class UdpListener extends ListenerBase { + + /** + * the string to health check. + */ + private String healthCheckString; + + public String getHealthCheckString() { + return healthCheckString; + } + + public void setHealthCheckString(String healthCheckString) { + this.healthCheckString = healthCheckString; + } + + @Override + public String toString() { + return "UdpListener{" + + "healthCheckString='" + healthCheckString + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/blb/model/UpdateLoadBalancerAclRequest.java b/src/main/java/com/baidubce/services/blb/model/UpdateLoadBalancerAclRequest.java new file mode 100644 index 00000000..51a0d161 --- /dev/null +++ b/src/main/java/com/baidubce/services/blb/model/UpdateLoadBalancerAclRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.blb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for updating blb acl. + */ +@Getter +@Setter +public class UpdateLoadBalancerAclRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * the id of blb. + */ + private String blbId; + + /** + * is support acl. + */ + private boolean supportAcl; + + public UpdateLoadBalancerAclRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public UpdateLoadBalancerAclRequest withBlbId(String blbId) { + this.setBlbId(blbId); + return this; + } + + public UpdateLoadBalancerAclRequest withSupportAcl(boolean supportAcl) { + this.supportAcl = supportAcl; + return this; + } + + @Override + public UpdateLoadBalancerAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/BmrClient.java b/src/main/java/com/baidubce/services/bmr/BmrClient.java index a9a537fd..2198d774 100644 --- a/src/main/java/com/baidubce/services/bmr/BmrClient.java +++ b/src/main/java/com/baidubce/services/bmr/BmrClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Baidu, Inc. + * Copyright 2014-2019 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -12,25 +12,36 @@ */ package com.baidubce.services.bmr; -import com.baidubce.AbstractBceClient; -import com.baidubce.BceClientConfiguration; -import com.baidubce.BceClientException; -import com.baidubce.auth.SignOptions; -import com.baidubce.http.Headers; -import com.baidubce.http.HttpMethodName; -import com.baidubce.http.handler.BceErrorResponseHandler; -import com.baidubce.http.handler.BceJsonResponseHandler; -import com.baidubce.http.handler.BceMetadataResponseHandler; -import com.baidubce.http.handler.HttpResponseHandler; -import com.baidubce.internal.InternalRequest; -import com.baidubce.internal.RestartableInputStream; -import com.baidubce.model.AbstractBceRequest; -import com.baidubce.model.AbstractBceResponse; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.security.GeneralSecurityException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + import com.baidubce.services.bmr.model.AddStepsRequest; import com.baidubce.services.bmr.model.AddStepsResponse; +import com.baidubce.services.bmr.model.AdditionalFile; import com.baidubce.services.bmr.model.ApplicationConfig; +import com.baidubce.services.bmr.model.CdsItem; import com.baidubce.services.bmr.model.CreateClusterRequest; import com.baidubce.services.bmr.model.CreateClusterResponse; +import com.baidubce.services.bmr.model.CreateSchedulePlanRequest; +import com.baidubce.services.bmr.model.EipBindRequest; +import com.baidubce.services.bmr.model.EipRequest; +import com.baidubce.services.bmr.model.EipUnBindRequest; import com.baidubce.services.bmr.model.GetClusterRequest; import com.baidubce.services.bmr.model.GetClusterResponse; import com.baidubce.services.bmr.model.GetStepRequest; @@ -38,50 +49,88 @@ import com.baidubce.services.bmr.model.InstanceGroupConfig; import com.baidubce.services.bmr.model.ListClustersRequest; import com.baidubce.services.bmr.model.ListClustersResponse; +import com.baidubce.services.bmr.model.ListHistorySchedulePlanResponse; import com.baidubce.services.bmr.model.ListInstanceGroupsRequest; import com.baidubce.services.bmr.model.ListInstanceGroupsResponse; import com.baidubce.services.bmr.model.ListInstancesRequest; import com.baidubce.services.bmr.model.ListInstancesResponse; +import com.baidubce.services.bmr.model.ListScheduleDetailRequest; import com.baidubce.services.bmr.model.ListStepsRequest; import com.baidubce.services.bmr.model.ListStepsResponse; +import com.baidubce.services.bmr.model.ModifyInstanceGroupConfig; +import com.baidubce.services.bmr.model.ModifyInstanceGroupsRequest; +import com.baidubce.services.bmr.model.NormalResponse; +import com.baidubce.services.bmr.model.RenameCluseterRequest; +import com.baidubce.services.bmr.model.ScheduleCreateResponse; +import com.baidubce.services.bmr.model.SchedulePlanDetailListResponse; +import com.baidubce.services.bmr.model.SchedulePlanDetailResponse; +import com.baidubce.services.bmr.model.SchedulePlanRequest; +import com.baidubce.services.bmr.model.ScheduleResultResponse; import com.baidubce.services.bmr.model.StepConfig; +import com.baidubce.services.bmr.model.TemplateIdRequest; +import com.baidubce.services.bmr.model.TemplateInfoResponse; +import com.baidubce.services.bmr.model.TemplateListRequest; +import com.baidubce.services.bmr.model.TemplateListResponse; import com.baidubce.services.bmr.model.TerminateClusterRequest; +import com.baidubce.services.bmr.model.UpdateSchedulePlanRequest; +import com.baidubce.services.bmr.model.AmbariRequest; +import com.baidubce.services.bmr.model.AmbariResponse; +import com.baidubce.services.bmr.model.ListClusterHostsRequest; +import com.baidubce.services.bmr.model.ListClusterHostsResponse; +import org.apache.commons.codec.binary.Hex; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; import com.baidubce.util.HttpUtils; import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonGenerator; -import java.io.StringWriter; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import static com.baidubce.util.Validate.checkStringNotEmpty; -import static com.google.common.base.Preconditions.checkNotNull; - /** * Provides the client for accessing the Baidu MapReduce service. */ public class BmrClient extends AbstractBceClient { private static final String VERSION = "v1"; private static final String CLUSTER = "cluster"; + private static final String TEMPLATE = "template"; + private static final String GET = "get"; + private static final String LIST = "list"; + private static final String EIP = "eip"; + private static final String DETAIL = "detail"; + private static final String HISTORY = "history"; + private static final String DELETE = "delete"; + private static final String RENAME = "rename"; + private static final String UPDATE = "update"; + private static final String STOP = "stop"; + private static final String START = "start"; + private static final String ADD = "add"; private static final String INSTANCE_GROUP = "instanceGroup"; private static final String INSTANCE = "instance"; private static final String STEP = "step"; - private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + private static final String CREATE = "create"; + private static final String SAVE_TEMPLATE = "save_template"; + private static final String[] HEADERS_TO_SIGN = { "host", "x-bce-date" }; + private static final String EXECUTE_PLAN = "execute_plan"; + private static final String BIND = "bind"; + private static final String UNBIND = "unbind"; /** * Responsible for handling HttpResponse from all BMR service calls. */ - private static final HttpResponseHandler[] BMR_HANDLERS = new HttpResponseHandler[] { - new BceMetadataResponseHandler(), - new BceErrorResponseHandler(), - new BceJsonResponseHandler() - }; + private static final HttpResponseHandler[] BMR_HANDLERS = + new HttpResponseHandler[] { new BceMetadataResponseHandler(), new BceErrorResponseHandler(), + new BceJsonResponseHandler() }; /** * Constructs a new client to invoke service methods on BMR. @@ -101,12 +150,11 @@ public BmrClient(BceClientConfiguration clientConfiguration) { /** * List BMR clusters owned by the authenticated user. - * - *

* Users must authenticate with a valid BCE Access Key ID, and the response * contains all the BMR clusters owned by the user. * * @param request The request containing valid query parameters. + * * @return The response containing a list of the BMR clusters owned by the authenticated sender of the request. */ public ListClustersResponse listClusters(ListClustersRequest request) { @@ -136,8 +184,9 @@ public ListClustersResponse listClusters() { * List BMR clusters owned by the authenticated user. * * @param maxKeys The maximum number of clusters returned. + * * @return The response containing a list of the BMR clusters owned by the authenticated sender of the request. - * And the size of list is limited below maxKeys. + * And the size of list is limited below maxKeys. */ public ListClustersResponse listClusters(int maxKeys) { return listClusters(new ListClustersRequest().withMaxKeys(maxKeys)); @@ -146,10 +195,11 @@ public ListClustersResponse listClusters(int maxKeys) { /** * List BMR clusters owned by the authenticated user. * - * @param marker The start record of clusters. + * @param marker The start record of clusters. * @param maxKeys The maximum number of clusters returned. + * * @return The response containing a list of the BMR clusters owned by the authenticated sender of the request. - * The clusters' records start from the marker and the size of list is limited below maxKeys. + * The clusters' records start from the marker and the size of list is limited below maxKeys. */ public ListClustersResponse listClusters(String marker, int maxKeys) { return listClusters(new ListClustersRequest().withMaxKeys(maxKeys).withMarker(marker)); @@ -159,22 +209,39 @@ public ListClustersResponse listClusters(String marker, int maxKeys) { * Describe the detail information of the target cluster. * * @param request The request object containing the ID of the target cluster. + * * @return response containing the detail information of the target cluster. */ public GetClusterResponse getCluster(GetClusterRequest request) { checkNotNull(request, "request should not be null."); checkStringNotEmpty(request.getClusterId(), "The parameter clusterId should not be null or empty string."); - InternalRequest internalRequest = this.createRequest( - request, HttpMethodName.GET, CLUSTER, request.getClusterId()); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, CLUSTER, request.getClusterId()); return this.invokeHttpClient(internalRequest, GetClusterResponse.class); } + /** + * Describe the Ambari Password information of the target cluster. + * + * @param clusterId ID of the target cluster. + * + * @return response containing the Ambari Password information of the target cluster. + */ + public AmbariResponse getClusterAmbariPassword(String clusterId) { + checkNotNull(clusterId, "cluster id should not be null."); + AmbariRequest request = new AmbariRequest().withClusterId(clusterId); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, CLUSTER, request.getClusterId(), "ambaripassword"); + + return this.invokeHttpClient(internalRequest, AmbariResponse.class); + } /** * Describe the detail information of the target cluster. * * @param clusterId The ID of the target cluster. + * * @return The response containing the detail information of the target cluster. */ public GetClusterResponse getCluster(String clusterId) { @@ -185,6 +252,7 @@ public GetClusterResponse getCluster(String clusterId) { * Create a cluster with the specified options. * * @param request The request containing all options for creating a BMR cluster. + * * @return The response containing the ID of the newly created cluster. */ public CreateClusterResponse createCluster(CreateClusterRequest request) { @@ -208,6 +276,18 @@ public CreateClusterResponse createCluster(CreateClusterRequest request) { jsonGenerator.writeStringField("type", instanceGroup.getType()); jsonGenerator.writeStringField("instanceType", instanceGroup.getInstanceType()); jsonGenerator.writeNumberField("instanceCount", instanceGroup.getInstanceCount()); + jsonGenerator.writeNumberField("rootDiskSizeInGB", instanceGroup.getRootDiskSizeInGB()); + jsonGenerator.writeStringField("rootDiskMediumType", instanceGroup.getRootDiskMediumType()); + jsonGenerator.writeArrayFieldStart("cds"); + if (instanceGroup.getCds() != null) { + for (CdsItem cdsItem : instanceGroup.getCds()) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeNumberField("sizeInGB", cdsItem.getSizeInGB()); + jsonGenerator.writeStringField("mediumType", cdsItem.getMediumType()); + jsonGenerator.writeEndObject(); + } + } + jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); @@ -218,6 +298,8 @@ public CreateClusterResponse createCluster(CreateClusterRequest request) { jsonGenerator.writeStringField("logUri", request.getLogUri()); } jsonGenerator.writeBooleanField("autoTerminate", request.getAutoTerminate()); + jsonGenerator.writeBooleanField("serviceHaEnabled", request.getServiceHaEnabled()); + jsonGenerator.writeBooleanField("safeModeEnabled", request.getSafeModeEnabled()); if (request.getApplications() != null) { jsonGenerator.writeArrayFieldStart("applications"); @@ -256,6 +338,36 @@ public CreateClusterResponse createCluster(CreateClusterRequest request) { jsonGenerator.writeEndArray(); } + String requestAdminPwd = request.getAdminPassword(); + if (requestAdminPwd != null) { + if (requestAdminPwd.length() == 0) { + throw new BceClientException("AdminPassword is invalid!"); + } + if (config.getCredentials() == null) { + throw new BceClientException("BceClientConfiguration BceCredentials is null!"); + } + try { + String encryptAdminPassword = + aes128EncryptWithFirst16Char(requestAdminPwd, config.getCredentials().getSecretKey()); + jsonGenerator.writeStringField("adminPassword", encryptAdminPassword); + } catch (GeneralSecurityException ex) { + throw new BceClientException("Fail to encrypt adminPassword", ex); + } + } + + if (request.getVpcId() != null) { + jsonGenerator.writeStringField("vpcId", request.getVpcId()); + } + if (request.getSubnetId() != null) { + jsonGenerator.writeStringField("subnetId", request.getSubnetId()); + } + if (request.getSecurityGroup() != null) { + jsonGenerator.writeStringField("securityGroup", request.getSecurityGroup()); + } + if (request.getAvailabilityZone() != null) { + jsonGenerator.writeStringField("availabilityZone", request.getAvailabilityZone()); + } + jsonGenerator.writeEndObject(); jsonGenerator.close(); } catch (IOException e) { @@ -281,6 +393,53 @@ public CreateClusterResponse createCluster(CreateClusterRequest request) { return this.invokeHttpClient(internalRequest, CreateClusterResponse.class); } + + /** + * Modify the instance groups of the target cluster. + * + * @param request The request containing the ID of BMR cluster and the instance groups to be modified. + */ + public void modifyInstanceGroups(ModifyInstanceGroupsRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getClusterId(), "The clusterId should not be null or empty string."); + checkNotNull(request.getInstanceGroups(), "The instanceGroups should not be null."); + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("instanceGroups"); + for (ModifyInstanceGroupConfig instanceGroup : request.getInstanceGroups()) { + checkStringNotEmpty(instanceGroup.getId(), "The instanceGroupId should not be null or empty string."); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("id", instanceGroup.getId()); + jsonGenerator.writeNumberField("instanceCount", instanceGroup.getInstanceCount()); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + byte[] json = null; + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, CLUSTER, request.getClusterId(), INSTANCE_GROUP); + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json"); + internalRequest.setContent(RestartableInputStream.wrap(json)); + + if (request.getClientToken() != null) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + /** * Terminate a BMR cluster and release all the virtual machine instances. * @@ -290,8 +449,8 @@ public void terminateCluster(TerminateClusterRequest request) { checkNotNull(request, "request should not be null."); checkStringNotEmpty(request.getClusterId(), "The parameter clusterId should not be null or empty string."); - InternalRequest internalRequest = this.createRequest( - request, HttpMethodName.DELETE, CLUSTER, request.getClusterId()); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, CLUSTER, request.getClusterId()); this.invokeHttpClient(internalRequest, AbstractBceResponse.class); } @@ -309,14 +468,15 @@ public void terminateCluster(String clusterId) { * List the instance groups of the target BMR cluster. * * @param request containing the ID of target BMR cluster. + * * @return The response containing a list of InstanceGroup objects. */ public ListInstanceGroupsResponse listInstanceGroups(ListInstanceGroupsRequest request) { checkNotNull(request, "request should not be null."); checkStringNotEmpty(request.getClusterId(), "The parameter clusterId should not be null or empty string."); - InternalRequest internalRequest = this.createRequest( - request, HttpMethodName.GET, CLUSTER, request.getClusterId(), INSTANCE_GROUP); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, CLUSTER, request.getClusterId(), INSTANCE_GROUP); return this.invokeHttpClient(internalRequest, ListInstanceGroupsResponse.class); } @@ -325,6 +485,7 @@ public ListInstanceGroupsResponse listInstanceGroups(ListInstanceGroupsRequest r * List the instance groups of the target BMR cluster. * * @param clusterId the ID of target BMR cluster. + * * @return The response containing a list of InstanceGroup objects. */ public ListInstanceGroupsResponse listInstanceGroups(String clusterId) { @@ -335,6 +496,7 @@ public ListInstanceGroupsResponse listInstanceGroups(String clusterId) { * List the instances belonging to the target instance group in the BMR cluster. * * @param request containing the ID of target BMR cluster and the ID of the instance group. + * * @return The response containing a list of Instance objects. */ public ListInstancesResponse listInstances(ListInstancesRequest request) { @@ -343,9 +505,9 @@ public ListInstancesResponse listInstances(ListInstancesRequest request) { checkStringNotEmpty(request.getInstanceGroupId(), "The parameter instanceGroupId should not be null or empty string."); - InternalRequest internalRequest = this.createRequest( - request, HttpMethodName.GET, CLUSTER, request.getClusterId(), INSTANCE_GROUP, - request.getInstanceGroupId(), INSTANCE); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, CLUSTER, request.getClusterId(), INSTANCE_GROUP, + request.getInstanceGroupId(), INSTANCE); return this.invokeHttpClient(internalRequest, ListInstancesResponse.class); } @@ -353,17 +515,20 @@ public ListInstancesResponse listInstances(ListInstancesRequest request) { /** * List the instances belonging to the target instance in the BMR cluster. * - * @param clusterId the ID of target BMR cluster. + * @param clusterId the ID of target BMR cluster. * @param instanceGroupId the ID of target instance group. + * * @return The response containing a list of Instance objects. */ public ListInstancesResponse listInstances(String clusterId, String instanceGroupId) { return listInstances(new ListInstancesRequest().withClusterId(clusterId).withInstanceGroupId(instanceGroupId)); } + /** * Add steps to a BMR cluster. * * @param request containing the ID of target BMR cluster and several steps to be added. + * * @return The response containing a list of IDs of newly added steps. */ public AddStepsResponse addSteps(AddStepsRequest request) { @@ -389,6 +554,16 @@ public AddStepsResponse addSteps(AddStepsRequest request) { jsonGenerator.writeObjectField(propertyKey, step.getProperties().get(propertyKey)); } jsonGenerator.writeEndObject(); + if (null != step.getAdditionalFiles()) { + jsonGenerator.writeArrayFieldStart("additionalFiles"); + for (AdditionalFile additionalFile : step.getAdditionalFiles()) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("remote", additionalFile.getRemote()); + jsonGenerator.writeStringField("local", additionalFile.getLocal()); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + } jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); @@ -405,8 +580,8 @@ public AddStepsResponse addSteps(AddStepsRequest request) { throw new BceClientException("Fail to get UTF-8 bytes", e); } - InternalRequest internalRequest = this.createRequest( - request, HttpMethodName.POST, CLUSTER, request.getClusterId(), STEP); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, CLUSTER, request.getClusterId(), STEP); internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json"); @@ -419,72 +594,44 @@ public AddStepsResponse addSteps(AddStepsRequest request) { return this.invokeHttpClient(internalRequest, AddStepsResponse.class); } + public void cancelSteps(GetStepRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getClusterId(), "The parameter clusterId should not be null or empty string."); + checkStringNotEmpty(request.getStepId(), "The parameter stepId should not be null or empty string."); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, CLUSTER, request.getClusterId(), STEP, + request.getStepId()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + /** * List all the steps of the target BMR cluster. * * @param request The request containing the ID of target BMR cluster. + * * @return The response containing the list of steps owned by the cluster. */ public ListStepsResponse listSteps(ListStepsRequest request) { checkNotNull(request, "request should not be null."); checkStringNotEmpty(request.getClusterId(), "The parameter clusterId should not be null or empty string."); - InternalRequest internalRequest = this.createRequest( - request, HttpMethodName.GET, CLUSTER, request.getClusterId(), STEP); - if (request.getMarker() != null) { - internalRequest.addParameter("marker", request.getMarker()); - } - if (request.getMaxKeys() >= 0) { - internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); - } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, CLUSTER, request.getClusterId(), STEP); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); return this.invokeHttpClient(internalRequest, ListStepsResponse.class); } - /** - * List all the steps of the target BMR cluster. - * - * @param clusterId The ID of the target BMR cluster. - * @return The response containing the list of steps owned by the cluster. - */ - public ListStepsResponse listSteps(String clusterId) { - return listSteps(new ListStepsRequest().withClusterId(clusterId)); - } - - /** - * List all the steps of the target BMR cluster. - * - * @param clusterId The ID of the target BMR cluster. - * @param maxKeys The maximum number of steps returned. - * @return The response containing the list of steps owned by the cluster. - * And the size of list is limited below maxKeys. - */ - public ListStepsResponse listSteps(String clusterId, int maxKeys) { - return listSteps(new ListStepsRequest().withClusterId(clusterId).withMaxKeys(maxKeys)); - } - - /** - * List all the steps of the target BMR cluster. - * - * @param clusterId The ID of the target BMR cluster. - * @param marker The start record of steps. - * @param maxKeys The maximum number of steps returned. - * @return The response containing a list of the BMR steps owned by the cluster. - * The steps' records start from the marker and the size of list is limited below maxKeys. - */ - public ListStepsResponse listSteps(String clusterId, String marker, int maxKeys) { - return listSteps(new ListStepsRequest().withClusterId(clusterId) - .withMaxKeys(maxKeys) - .withMarker(marker)); - } /** * Describe the detail information of the target step. - * + *

*

* The request is valid just if the step exists and the step is owned by the cluster * * @param request The request containing the ID of BMR cluster and the ID of step. + * * @return The response containing the detail information of target step. */ public GetStepResponse getStep(GetStepRequest request) { @@ -492,8 +639,9 @@ public GetStepResponse getStep(GetStepRequest request) { checkStringNotEmpty(request.getClusterId(), "The parameter clusterId should not be null or empty string."); checkStringNotEmpty(request.getStepId(), "The parameter stepId should not be null or empty string."); - InternalRequest internalRequest = this.createRequest( - request, HttpMethodName.GET, CLUSTER, request.getClusterId(), STEP, request.getStepId()); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, CLUSTER, request.getClusterId(), STEP, + request.getStepId()); return this.invokeHttpClient(internalRequest, GetStepResponse.class); } @@ -502,24 +650,62 @@ public GetStepResponse getStep(GetStepRequest request) { * Describe the detail information of the target step. * * @param clusterId The ID of the cluster which owns the step. - * @param stepId The ID of the target step. + * @param stepId The ID of the target step. + * * @return The response containing the detail information of the target step. */ public GetStepResponse getStep(String clusterId, String stepId) { return getStep(new GetStepRequest().withClusterId(clusterId).withStepId(stepId)); } + /** + * rename a cluster's name + * + * @param request contains cluster's ID and cluster's new name + * + * @return the success info + */ + public NormalResponse renameCluster(RenameCluseterRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getClusterId(), "The parameter clusterId should not be null or empty string."); + checkStringNotEmpty(request.getNewName(), "The parameter newNameId should not be null or empty string."); + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("clusterId", request.getClusterId()); + jsonGenerator.writeStringField("newName", request.getNewName()); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + byte[] json = null; + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CLUSTER, RENAME); + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json"); + internalRequest.setContent(RestartableInputStream.wrap(json)); + return this.invokeHttpClient(internalRequest, NormalResponse.class); + + } + /** * Creates and initializes a new request object for the specified resource. * - * @param bceRequest The original BCE request created by the user. - * @param httpMethod The HTTP method to use when sending the request. + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. * @param pathVariables The optional variables used in the URI path. + * * @return A new request object populated with endpoint, resource path and specific - * parameters to send. + * parameters to send. */ - private InternalRequest createRequest( - AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { List path = new ArrayList(); path.add(VERSION); @@ -538,4 +724,44 @@ private InternalRequest createRequest( return request; } -} \ No newline at end of file + + /** + * The encryption implement for AES-128 algorithm for BCE password encryption. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + *

+ * See more detail on + * + * BCE API doc + * + * @param content The content String to encrypt. + * @param privateKey The security key to encrypt. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + * + * @return The encrypted string of the original content with AES-128 algorithm. + * + * @throws GeneralSecurityException + */ + private String aes128EncryptWithFirst16Char(String content, String privateKey) throws GeneralSecurityException { + if (privateKey == null || privateKey.length() < 16) { + throw new GeneralSecurityException("account secretKey is wrong"); + } + byte[] crypted = null; + SecretKeySpec skey = new SecretKeySpec(privateKey.substring(0, 16).getBytes(), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, skey); + crypted = cipher.doFinal(content.getBytes()); + return new String(Hex.encodeHex(crypted)); + } + /** + * List host info for a cluster + * + * @param clusterId cluster uuid + */ + public ListClusterHostsResponse listClusterHosts(String clusterId) { + checkNotNull(clusterId, "cluster id should not be null."); + ListClusterHostsRequest request = new ListClusterHostsRequest().withClusterId(clusterId); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, CLUSTER, request.getClusterId(), "hosts"); + return this.invokeHttpClient(internalRequest, ListClusterHostsResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/AddStepsRequest.java b/src/main/java/com/baidubce/services/bmr/model/AddStepsRequest.java index 60905f94..3627ce56 100644 --- a/src/main/java/com/baidubce/services/bmr/model/AddStepsRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/AddStepsRequest.java @@ -12,15 +12,15 @@ */ package com.baidubce.services.bmr.model; -import com.baidubce.auth.BceCredentials; -import com.baidubce.model.AbstractBceRequest; - import java.util.ArrayList; import java.util.List; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + /** * Provide options for adding steps to the target cluster. - * + *

* The essential option is the ID of cluster, and the List of steps can be constructed by * calling the methods of StepConfig. */ @@ -57,6 +57,7 @@ public void setSteps(List steps) { * Configure the ID of the cluster. * * @param clusterId The ID of the cluster. + * * @return AddStepsRequest */ public AddStepsRequest withClusterId(String clusterId) { @@ -68,6 +69,7 @@ public AddStepsRequest withClusterId(String clusterId) { * Configure the step to be added. * * @param step a StepConfig object to be added. + * * @return AddStepsRequest */ public AddStepsRequest withStep(StepConfig step) { @@ -84,6 +86,7 @@ public AddStepsRequest withStep(StepConfig step) { * if both of them are used for the same AddStepsRequest instance. * * @param steps a List of StepConfig instances to be added. + * * @return AddStepsRequest */ public AddStepsRequest withSteps(List steps) { @@ -95,6 +98,7 @@ public AddStepsRequest withSteps(List steps) { * Configure optional client token for the request. The request will be idempotent if client token is provided. * * @param clientToken An ASCII string whose length is less than 64. + * * @return AddStepsRequest */ public AddStepsRequest withClientToken(String clientToken) { @@ -106,6 +110,7 @@ public AddStepsRequest withClientToken(String clientToken) { * Configure request credential for the request. * * @param credentials a valid instance of BceCredentials. + * * @return AddStepsRequest */ public AddStepsRequest withRequestCredentials(BceCredentials credentials) { diff --git a/src/main/java/com/baidubce/services/bmr/model/AddStepsResponse.java b/src/main/java/com/baidubce/services/bmr/model/AddStepsResponse.java index 3f86a469..020847ee 100644 --- a/src/main/java/com/baidubce/services/bmr/model/AddStepsResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/AddStepsResponse.java @@ -12,13 +12,13 @@ */ package com.baidubce.services.bmr.model; -import com.baidubce.model.AbstractBceResponse; - import java.util.List; +import com.baidubce.model.AbstractBceResponse; + /** * Represent the response of AddStepsRequest. - * + *

* The response contains a Array of IDs which are newly added steps. */ public class AddStepsResponse extends AbstractBceResponse { diff --git a/src/main/java/com/baidubce/services/bmr/model/AdditionalFile.java b/src/main/java/com/baidubce/services/bmr/model/AdditionalFile.java new file mode 100644 index 00000000..2acb5b5a --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/AdditionalFile.java @@ -0,0 +1,55 @@ +package com.baidubce.services.bmr.model; + +/** + * Represent configuration for a BMR step additional file. + *

+ * An additional file is a mapping of remote file and local file. + * Remote file represents a file which we can not access by Instance local path, like a BOS file. + * Local file represents a file which we can use in the arguments of a BMR step, + * like the arguments of streaming step. + */ +public class AdditionalFile { + private String remote; + + private String local; + + public String getRemote() { + return remote; + } + + public void setRemote(String remote) { + this.remote = remote; + } + + public String getLocal() { + return local; + } + + public void setLocal(String local) { + this.local = local; + } + + /** + * Configure the remote file of the additional file. + * + * @param remote The remote file of the additional file. + * + * @return AdditionalFile + */ + public AdditionalFile withRemote(String remote) { + this.setRemote(remote); + return this; + } + + /** + * Configure the local file of the additional file. + * + * @param local The local file of the additional file. + * + * @return AdditionalFile + */ + public AdditionalFile withLocal(String local) { + this.setLocal(local); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/AmbariRequest.java b/src/main/java/com/baidubce/services/bmr/model/AmbariRequest.java new file mode 100644 index 00000000..cc2520f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/AmbariRequest.java @@ -0,0 +1,43 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Provides option for desribing a BMR cluster Ambari request. The essential option is cluster ID. + */ +public class AmbariRequest extends AbstractBceRequest { + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + /** + * Configure the cluster ID for the request. + * + * @param clusterId The ID of BMR cluster. + * + * @return AmbariRequest + */ + public AmbariRequest withClusterId(String clusterId) { + this.setClusterId(clusterId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * + * @return AmbariRequest + */ + public AmbariRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/AmbariResponse.java b/src/main/java/com/baidubce/services/bmr/model/AmbariResponse.java new file mode 100644 index 00000000..a440e209 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/AmbariResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the response of AmbariPassWordRequest. + *

+ * The response contains a Ambari Password + */ +public class AmbariResponse extends AbstractBceResponse { + + private String password; + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/AzkabanApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/AzkabanApplicationConfig.java new file mode 100644 index 00000000..ba1fd033 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/AzkabanApplicationConfig.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bmr.model; + +public class AzkabanApplicationConfig extends ApplicationConfig { + private static final String Azkaban_APPLICATION = "azkaban"; + + + public AzkabanApplicationConfig() { + this.setName(Azkaban_APPLICATION); + } + + + /** + * Configure the version of azkaban. + * The reference version is as follows: + *

+ * image type | image version | azkaban version supported + * hadoop | 2.0.0 | 3.58.0 + * @param version The version of azkaban. + * + * @return AzkabanApplicationConfig + */ + public AzkabanApplicationConfig withVersion(String version){ + this .setVersion(version); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/BmrSecurityGroupVo.java b/src/main/java/com/baidubce/services/bmr/model/BmrSecurityGroupVo.java new file mode 100644 index 00000000..f40cdc11 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/BmrSecurityGroupVo.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bmr.model; + +public class BmrSecurityGroupVo { + private String name; + private String id; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/CdsItem.java b/src/main/java/com/baidubce/services/bmr/model/CdsItem.java new file mode 100644 index 00000000..b452f69d --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/CdsItem.java @@ -0,0 +1,58 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bmr.model; + +/* + * description of Cloud Disk + */ +public class CdsItem { + private int sizeInGB; + private String mediumType; + + public int getSizeInGB() { + return sizeInGB; + } + + public void setSizeInGB(int sizeInGB) { + this.sizeInGB = sizeInGB; + } + + /** + * @param sizeInGB disk size + * + * @return CdsItem + */ + + public CdsItem withSizeInGB(int sizeInGB) { + this.sizeInGB = sizeInGB; + return this; + } + + public String getMediumType() { + return mediumType; + } + + public void setMediumType(String mediumType) { + this.mediumType = mediumType; + } + + /** + * @param mediumType for example ssd + * + * @return CdsItem + */ + public CdsItem withMediumType(String mediumType) { + this.mediumType = mediumType; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/CluseterDetailInfoResponse.java b/src/main/java/com/baidubce/services/bmr/model/CluseterDetailInfoResponse.java new file mode 100644 index 00000000..07d396fb --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/CluseterDetailInfoResponse.java @@ -0,0 +1,296 @@ +package com.baidubce.services.bmr.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +public class CluseterDetailInfoResponse extends AbstractBceResponse { + private String logUri; + private String imageType; + private String imageVersion; + private Boolean autoTerminate; + private Boolean terminationProtected; + private List applications; + private Reminder reminder; + private ScaleStatus scaleStatus; + private String jupyterUrl; + private String yarnUrl; + private String hueUrl; + private boolean sendMessage; + private String availabilityZone; + private VpcInfo vpc; + private SubnetInfo subnet; + private BmrSecurityGroupVo systemSecurityGroup; + private Boolean serviceHaEnabled; + private Boolean safeModeEnabled; + private List instanceGroups; + private String imageDescription; + private boolean copyable; + private String id; + private String name; + private String payType; + private ClusterStatus status; + private String orderId; + private Boolean alarmEnabled = Boolean.FALSE; + private String executionPlanId; + private boolean vpnEnabled; + private String source; + private String hmsUrl; + private boolean expired; + + public String getLogUri() { + return logUri; + } + + public void setLogUri(String logUri) { + this.logUri = logUri; + } + + public String getImageType() { + return imageType; + } + + public void setImageType(String imageType) { + this.imageType = imageType; + } + + public String getImageVersion() { + return imageVersion; + } + + public void setImageVersion(String imageVersion) { + this.imageVersion = imageVersion; + } + + public Boolean getAutoTerminate() { + return autoTerminate; + } + + public void setAutoTerminate(Boolean autoTerminate) { + this.autoTerminate = autoTerminate; + } + + public Boolean getTerminationProtected() { + return terminationProtected; + } + + public void setTerminationProtected(Boolean terminationProtected) { + this.terminationProtected = terminationProtected; + } + + public List getApplications() { + return applications; + } + + public void setApplications(List applications) { + this.applications = applications; + } + + public Reminder getReminder() { + return reminder; + } + + public void setReminder(Reminder reminder) { + this.reminder = reminder; + } + + public ScaleStatus getScaleStatus() { + return scaleStatus; + } + + public void setScaleStatus(ScaleStatus scaleStatus) { + this.scaleStatus = scaleStatus; + } + + public String getJupyterUrl() { + return jupyterUrl; + } + + public void setJupyterUrl(String jupyterUrl) { + this.jupyterUrl = jupyterUrl; + } + + public String getYarnUrl() { + return yarnUrl; + } + + public void setYarnUrl(String yarnUrl) { + this.yarnUrl = yarnUrl; + } + + public String getHueUrl() { + return hueUrl; + } + + public void setHueUrl(String hueUrl) { + this.hueUrl = hueUrl; + } + + public boolean isSendMessage() { + return sendMessage; + } + + public void setSendMessage(boolean sendMessage) { + this.sendMessage = sendMessage; + } + + public String getAvailabilityZone() { + return availabilityZone; + } + + public void setAvailabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + } + + public VpcInfo getVpc() { + return vpc; + } + + public void setVpc(VpcInfo vpc) { + this.vpc = vpc; + } + + public SubnetInfo getSubnet() { + return subnet; + } + + public void setSubnet(SubnetInfo subnet) { + this.subnet = subnet; + } + + public BmrSecurityGroupVo getSystemSecurityGroup() { + return systemSecurityGroup; + } + + public void setSystemSecurityGroup(BmrSecurityGroupVo systemSecurityGroup) { + this.systemSecurityGroup = systemSecurityGroup; + } + + public Boolean getServiceHaEnabled() { + return serviceHaEnabled; + } + + public void setServiceHaEnabled(Boolean serviceHaEnabled) { + this.serviceHaEnabled = serviceHaEnabled; + } + + public Boolean getSafeModeEnabled() { + return safeModeEnabled; + } + + public void setSafeModeEnabled(Boolean safeModeEnabled) { + this.safeModeEnabled = safeModeEnabled; + } + + public List getInstanceGroups() { + return instanceGroups; + } + + public void setInstanceGroups(List instanceGroups) { + this.instanceGroups = instanceGroups; + } + + public String getImageDescription() { + return imageDescription; + } + + public void setImageDescription(String imageDescription) { + this.imageDescription = imageDescription; + } + + public boolean isCopyable() { + return copyable; + } + + public void setCopyable(boolean copyable) { + this.copyable = copyable; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPayType() { + return payType; + } + + public void setPayType(String payType) { + this.payType = payType; + } + + public ClusterStatus getStatus() { + return status; + } + + public void setStatus(ClusterStatus status) { + this.status = status; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public Boolean getAlarmEnabled() { + return alarmEnabled; + } + + public void setAlarmEnabled(Boolean alarmEnabled) { + this.alarmEnabled = alarmEnabled; + } + + public String getExecutionPlanId() { + return executionPlanId; + } + + public void setExecutionPlanId(String executionPlanId) { + this.executionPlanId = executionPlanId; + } + + public boolean isVpnEnabled() { + return vpnEnabled; + } + + public void setVpnEnabled(boolean vpnEnabled) { + this.vpnEnabled = vpnEnabled; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getHmsUrl() { + return hmsUrl; + } + + public void setHmsUrl(String hmsUrl) { + this.hmsUrl = hmsUrl; + } + + public boolean isExpired() { + return expired; + } + + public void setExpired(boolean expired) { + this.expired = expired; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/Cluster.java b/src/main/java/com/baidubce/services/bmr/model/Cluster.java index c09bb445..04c47d94 100644 --- a/src/main/java/com/baidubce/services/bmr/model/Cluster.java +++ b/src/main/java/com/baidubce/services/bmr/model/Cluster.java @@ -12,20 +12,25 @@ */ package com.baidubce.services.bmr.model; +import java.util.Date; import java.util.List; - /** * Represent a BMR cluster. */ public class Cluster { private String id; private String name; + private String payType; private String imageType; private String imageVersion; private String logUri; - private boolean autoTerminate; + private boolean enableAutoScale; + private Date createTime; + private List tags; private List applications; private ClusterStatus status; + private boolean serviceHaEnabled; + private boolean safeModeEnabled; public String getId() { return id; @@ -59,14 +64,6 @@ public void setImageVersion(String imageVersion) { this.imageVersion = imageVersion; } - public boolean getAutoTerminate() { - return autoTerminate; - } - - public void setAutoTerminate(boolean autoTerminate) { - this.autoTerminate = autoTerminate; - } - public String getLogUri() { return logUri; } @@ -90,4 +87,53 @@ public List getApplications() { public void setApplications(List applications) { this.applications = applications; } + + public Boolean getServiceHaEnabled() { + return serviceHaEnabled; + } + + public void setServiceHaEnabled(Boolean serviceHaEnabled) { + this.serviceHaEnabled = serviceHaEnabled; + } + + public Boolean getSafeModeEnabled() { + return safeModeEnabled; + } + + public void setSafeModeEnabled(Boolean safeModeEnabled) { + this.safeModeEnabled = safeModeEnabled; + } + + public String getPayType() { + return payType; + } + + public void setPayType(String payType) { + this.payType = payType; + } + + public boolean isEnableAutoScale() { + return enableAutoScale; + } + + public void setEnableAutoScale(boolean enableAutoScale) { + this.enableAutoScale = enableAutoScale; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + } diff --git a/src/main/java/com/baidubce/services/bmr/model/ClusterStatus.java b/src/main/java/com/baidubce/services/bmr/model/ClusterStatus.java index 812117fd..092002e2 100644 --- a/src/main/java/com/baidubce/services/bmr/model/ClusterStatus.java +++ b/src/main/java/com/baidubce/services/bmr/model/ClusterStatus.java @@ -19,9 +19,14 @@ */ public class ClusterStatus { private String state; + private String code; + private String message; + private String orderStatus; private Date creationDateTime; private Date endDateTime; private Date readyDateTime; + private Date expireDateTime; + private int expireDates; public String getState() { return state; @@ -54,4 +59,45 @@ public Date getReadyDateTime() { public void setReadyDateTime(Date readyDateTime) { this.readyDateTime = readyDateTime; } + + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getOrderStatus() { + return orderStatus; + } + + public void setOrderStatus(String orderStatus) { + this.orderStatus = orderStatus; + } + + public Date getExpireDateTime() { + return expireDateTime; + } + + public void setExpireDateTime(Date expireDateTime) { + this.expireDateTime = expireDateTime; + } + + public int getExpireDates() { + return expireDates; + } + + public void setExpireDates(int expireDates) { + this.expireDates = expireDates; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/ClusterTemplateInfoVo.java b/src/main/java/com/baidubce/services/bmr/model/ClusterTemplateInfoVo.java new file mode 100644 index 00000000..5b268627 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ClusterTemplateInfoVo.java @@ -0,0 +1,132 @@ +package com.baidubce.services.bmr.model; + +import java.util.List; + +public class ClusterTemplateInfoVo extends ClusterTemplateSummaryVo { + List steps; + private Boolean alarmEnabled; + private Boolean autoTerminate; + private String logUri; + private String payType; + private Reminder reminder; + private Boolean sendMessage; + private Boolean terminationProtected; + private String availabilityZone; + private VpcInfo vpc; + private SubnetInfo subnet; + private BmrSecurityGroupVo systemSecurityGroup; + private Boolean serviceHaEnabled; + private Boolean safeModeEnabled; + + public List getSteps() { + return steps; + } + + public void setSteps(List steps) { + this.steps = steps; + } + + public Boolean getAlarmEnabled() { + return alarmEnabled; + } + + public void setAlarmEnabled(Boolean alarmEnabled) { + this.alarmEnabled = alarmEnabled; + } + + public Boolean getAutoTerminate() { + return autoTerminate; + } + + public void setAutoTerminate(Boolean autoTerminate) { + this.autoTerminate = autoTerminate; + } + + public String getLogUri() { + return logUri; + } + + public void setLogUri(String logUri) { + this.logUri = logUri; + } + + public String getPayType() { + return payType; + } + + public void setPayType(String payType) { + this.payType = payType; + } + + public Reminder getReminder() { + return reminder; + } + + public void setReminder(Reminder reminder) { + this.reminder = reminder; + } + + public Boolean getSendMessage() { + return sendMessage; + } + + public void setSendMessage(Boolean sendMessage) { + this.sendMessage = sendMessage; + } + + public Boolean getTerminationProtected() { + return terminationProtected; + } + + public void setTerminationProtected(Boolean terminationProtected) { + this.terminationProtected = terminationProtected; + } + + public String getAvailabilityZone() { + return availabilityZone; + } + + public void setAvailabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + } + + public VpcInfo getVpc() { + return vpc; + } + + public void setVpc(VpcInfo vpc) { + this.vpc = vpc; + } + + public SubnetInfo getSubnet() { + return subnet; + } + + public void setSubnet(SubnetInfo subnet) { + this.subnet = subnet; + } + + public BmrSecurityGroupVo getSystemSecurityGroup() { + return systemSecurityGroup; + } + + public void setSystemSecurityGroup(BmrSecurityGroupVo systemSecurityGroup) { + this.systemSecurityGroup = systemSecurityGroup; + } + + public Boolean getServiceHaEnabled() { + return serviceHaEnabled; + } + + public void setServiceHaEnabled(Boolean serviceHaEnabled) { + this.serviceHaEnabled = serviceHaEnabled; + } + + public Boolean getSafeModeEnabled() { + return safeModeEnabled; + } + + public void setSafeModeEnabled(Boolean safeModeEnabled) { + this.safeModeEnabled = safeModeEnabled; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ClusterTemplateSummary.java b/src/main/java/com/baidubce/services/bmr/model/ClusterTemplateSummary.java new file mode 100644 index 00000000..970b0e5c --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ClusterTemplateSummary.java @@ -0,0 +1,111 @@ +package com.baidubce.services.bmr.model; + +import java.util.Date; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; + +public class ClusterTemplateSummary { + private List applications; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + creationDateTime; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + updateDateTime; + + private String id; + + private String name; + + private boolean shared; + + private String imageType; + + private String imageVersion; + + private List instanceGroups; + + private String templateType; + + public String getTemplateType() { + return templateType; + } + + public void setTemplateType(String templateType) { + this.templateType = templateType; + } + + + public List getApplications() { + return applications; + } + + public void setApplications(List applications) { + this.applications = applications; + } + + public Date getCreationDateTime() { + return creationDateTime; + } + + public void setCreationDateTime(Date creationDateTime) { + this.creationDateTime = creationDateTime; + } + + public Date getUpdateDateTime() { + return updateDateTime; + } + + public void setUpdateDateTime(Date updateDateTime) { + this.updateDateTime = updateDateTime; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isShared() { + return shared; + } + + public void setShared(boolean shared) { + this.shared = shared; + } + + public String getImageType() { + return imageType; + } + + public void setImageType(String imageType) { + this.imageType = imageType; + } + + public String getImageVersion() { + return imageVersion; + } + + public void setImageVersion(String imageVersion) { + this.imageVersion = imageVersion; + } + + public List getInstanceGroups() { + return instanceGroups; + } + + public void setInstanceGroups(List instanceGroups) { + this.instanceGroups = instanceGroups; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ClusterTemplateSummaryVo.java b/src/main/java/com/baidubce/services/bmr/model/ClusterTemplateSummaryVo.java new file mode 100644 index 00000000..d0c3c6f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ClusterTemplateSummaryVo.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bmr.model; + +public class ClusterTemplateSummaryVo extends ClusterTemplateSummary { + private String imageDescription; + private boolean isCopyable; + private boolean abandoned; + + public String getImageDescription() { + return imageDescription; + } + + public void setImageDescription(String imageDescription) { + this.imageDescription = imageDescription; + } + + public boolean isCopyable() { + return isCopyable; + } + + public void setCopyable(boolean copyable) { + isCopyable = copyable; + } + + public boolean isAbandoned() { + return abandoned; + } + + public void setAbandoned(boolean abandoned) { + this.abandoned = abandoned; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/CreateClusterByTemplateRequest.java b/src/main/java/com/baidubce/services/bmr/model/CreateClusterByTemplateRequest.java new file mode 100644 index 00000000..520743da --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/CreateClusterByTemplateRequest.java @@ -0,0 +1,104 @@ +package com.baidubce.services.bmr.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class CreateClusterByTemplateRequest extends AbstractBceRequest { + + private String clientToken; + + private String templateId; + + private String adminPassword; + + private String logUri; + + private String securityGroup; + + private List steps; + + public CreateClusterByTemplateRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public CreateClusterByTemplateRequest withTemplateId(String templateId) { + this.setTemplateId(templateId); + return this; + } + + public CreateClusterByTemplateRequest withAdminPassword(String adminPassword) { + this.setAdminPassword(adminPassword); + return this; + } + + public CreateClusterByTemplateRequest withLogUri(String logUri) { + this.setLogUri(logUri); + return this; + } + + public CreateClusterByTemplateRequest withSecurityGroup(String securityGroup) { + this.setSecurityGroup(securityGroup); + return this; + } + + public CreateClusterByTemplateRequest withSteps(List steps) { + this.setSteps(steps); + return this; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public String getAdminPassword() { + return adminPassword; + } + + public void setAdminPassword(String adminPassword) { + this.adminPassword = adminPassword; + } + + public String getLogUri() { + return logUri; + } + + public void setLogUri(String logUri) { + this.logUri = logUri; + } + + public String getSecurityGroup() { + return securityGroup; + } + + public void setSecurityGroup(String securityGroup) { + this.securityGroup = securityGroup; + } + + public List getSteps() { + return steps; + } + + public void setSteps(List steps) { + this.steps = steps; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java b/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java old mode 100644 new mode 100755 index 71b042fa..e55bc5a7 --- a/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Baidu, Inc. + * Copyright 2014-2018 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -12,15 +12,15 @@ */ package com.baidubce.services.bmr.model; -import com.baidubce.auth.BceCredentials; -import com.baidubce.model.AbstractBceRequest; - import java.util.ArrayList; import java.util.List; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + /** * Provides options for creating a BMR cluster. - * + *

* The essential options are imageType, imageVersion, instanceGroups, and the optional ones are * clientToken, name, autoTerminate, logUri, applications and steps. */ @@ -31,9 +31,16 @@ public class CreateClusterRequest extends AbstractBceRequest { private boolean autoTerminate = true; private String logUri; private String name; + private boolean serviceHaEnabled; + private boolean safeModeEnabled; private List instanceGroups; private List applications; private List steps; + private String adminPassword; + private String securityGroup; + private String vpcId; + private String subnetId; + private String availabilityZone; public String getImageType() { return imageType; @@ -83,6 +90,22 @@ public void setName(String name) { this.name = name; } + public boolean getServiceHaEnabled() { + return serviceHaEnabled; + } + + public void setServiceHaEnabled(boolean serviceHaEnabled) { + this.serviceHaEnabled = serviceHaEnabled; + } + + public boolean getSafeModeEnabled() { + return safeModeEnabled; + } + + public void setSafeModeEnabled(boolean safeModeEnabled) { + this.safeModeEnabled = safeModeEnabled; + } + public List getInstanceGroups() { return instanceGroups; } @@ -107,10 +130,51 @@ public void setSteps(List steps) { this.steps = steps; } + public String getAdminPassword() { + return adminPassword; + } + + public void setAdminPassword(String adminPassword) { + this.adminPassword = adminPassword; + } + + public String getSecurityGroup() { + return securityGroup; + } + + public void setSecurityGroup(String securityGroup) { + this.securityGroup = securityGroup; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getAvailabilityZone() { + return availabilityZone; + } + + public void setAvailabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + } + /** * Configure the image type for the cluster. * * @param imageType The image type for cluster's instances. + * * @return CreateClusterRequest */ public CreateClusterRequest withImageType(String imageType) { @@ -122,6 +186,7 @@ public CreateClusterRequest withImageType(String imageType) { * Configure image version for the cluster. * * @param imageVersion The image version for the cluster's instance. + * * @return CreateClusterRequest */ public CreateClusterRequest withImageVersion(String imageVersion) { @@ -133,7 +198,8 @@ public CreateClusterRequest withImageVersion(String imageVersion) { * Configure auto-terminate property for the cluster. If set the autoTerminate as true, then * the cluster will be terminated when all the steps are done. And the autoTerminate is true by default. * - * @param autoTerminate + * @param autoTerminate true if the cluster should be auto terminated. + * * @return CreateClusterRequest */ public CreateClusterRequest withAutoTerminate(boolean autoTerminate) { @@ -146,6 +212,7 @@ public CreateClusterRequest withAutoTerminate(boolean autoTerminate) { * steps are not saved in the BOS. * * @param logUri The valid BOS uri for the logs. + * * @return CreateClusterRequest */ public CreateClusterRequest withLogUri(String logUri) { @@ -158,6 +225,7 @@ public CreateClusterRequest withLogUri(String logUri) { * "my-cluster" by default. * * @param name The name for the cluster. + * * @return CreateClusterRequest */ public CreateClusterRequest withName(String name) { @@ -165,10 +233,36 @@ public CreateClusterRequest withName(String name) { return this; } + /** + * Configure optional service HA enable of the cluster. If true will create a ha cluster, default is false. + * + * @param serviceHaEnabled true if the serivce ha enable, default is false. + * + * @return CreateClusterRequest + */ + public CreateClusterRequest withServiceHaEnabled(boolean serviceHaEnabled) { + this.setServiceHaEnabled(serviceHaEnabled); + return this; + } + + /** + * Configure optional safe mode enable of the cluster. If true will create a cluster running as safe mode, + * default is false. + * + * @param safeModeEnabled true if the safe mode enable, default is false. + * + * @return CreateClusterRequest + */ + public CreateClusterRequest withSafeModeEnabled(boolean safeModeEnabled) { + this.setSafeModeEnabled(safeModeEnabled); + return this; + } + /** * Configure the instance group for the cluster. * * @param instanceGroup An InstanceGroupConfig instance. + * * @return CreateClusterRequest */ public CreateClusterRequest withInstanceGroup(InstanceGroupConfig instanceGroup) { @@ -183,6 +277,7 @@ public CreateClusterRequest withInstanceGroup(InstanceGroupConfig instanceGroup) * Configure optional application for the cluster. BMR provides applications such as Hive、Pig、HBase for the cluster. * * @param application An ApplicationConfig instance. + * * @return CreateClusterRequest */ public CreateClusterRequest withApplication(ApplicationConfig application) { @@ -198,6 +293,7 @@ public CreateClusterRequest withApplication(ApplicationConfig application) { * And the step also can be added to the cluster by sending AddStepsRequest. * * @param step a StepConfig instance to be added. + * * @return CreateClusterRequest */ public CreateClusterRequest withStep(StepConfig step) { @@ -214,6 +310,7 @@ public CreateClusterRequest withStep(StepConfig step) { * of them are used for the same CreateClusterRequest instance. * * @param steps a List of StepConfig instances to be added. + * * @return CreateClusterRequest */ public CreateClusterRequest withSteps(List steps) { @@ -225,6 +322,7 @@ public CreateClusterRequest withSteps(List steps) { * Configure optional client token for the request. The request will be idempotent if client token is provided. * * @param clientToken An ASCII string whose length is less than 64. + * * @return CreateClusterRequest */ public CreateClusterRequest withClientToken(String clientToken) { @@ -236,10 +334,71 @@ public CreateClusterRequest withClientToken(String clientToken) { * Configure request credential for the request. * * @param credentials a valid instance of BceCredentials. + * * @return CreateClusterRequest */ public CreateClusterRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } + + /** + * Configure request adminPassword for the request. + * + * @param adminPassword an password for cluster for example bmrtest@123 + * + * @return CreateClusterRequest + */ + public CreateClusterRequest withAdminPassword(String adminPassword) { + this.setAdminPassword(adminPassword); + return this; + } + + /** + * Configure request vpc network name for the request. + * + * @param vpcId vpcId for create cluster + * + * @return CreateClusterRequest + */ + public CreateClusterRequest withVpcId(String vpcId) { + this.setVpcId(vpcId); + return this; + } + + /** + * Configure request subnet name for the request. + * + * @param subnetId subnetId for cluster + * + * @return CreateClusterRequest + */ + public CreateClusterRequest withSubnetId(String subnetId) { + this.setSubnetId(subnetId); + return this; + } + + /** + * Configure request availabilityZone of creating cluster. + * + * @param availabilityZone cluster availabilityZone + * + * @return CreateClusterRequest + */ + public CreateClusterRequest withAvailabilityZone(String availabilityZone) { + this.setAvailabilityZone(availabilityZone); + return this; + } + + /** + * Configure request security group for the request. + * + * @param securityGroup securityGroup for cluster + * + * @return CreateClusterRequest + */ + public CreateClusterRequest withSecurityGroup(String securityGroup) { + this.setSecurityGroup(securityGroup); + return this; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/CreateClusterResponse.java b/src/main/java/com/baidubce/services/bmr/model/CreateClusterResponse.java index 40a68503..4483a3e3 100644 --- a/src/main/java/com/baidubce/services/bmr/model/CreateClusterResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/CreateClusterResponse.java @@ -16,7 +16,7 @@ /** * Represent the response for the CreateClusterRequest. - * + *

* The response contains the ID of the newly created cluster. */ public class CreateClusterResponse extends AbstractBceResponse { diff --git a/src/main/java/com/baidubce/services/bmr/model/CreateSchedulePlanRequest.java b/src/main/java/com/baidubce/services/bmr/model/CreateSchedulePlanRequest.java new file mode 100644 index 00000000..ffce4de2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/CreateSchedulePlanRequest.java @@ -0,0 +1,90 @@ +package com.baidubce.services.bmr.model; + +import java.util.Date; +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonFormat; + +public class CreateSchedulePlanRequest extends AbstractBceRequest { + + private String name; + + private String templateId; + + private List steps; + + private Integer period; + + private String timeUnit; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + startTime; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + endTime; + + //public CreateSchedulePlanRequest with + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public List getSteps() { + return steps; + } + + public void setSteps(List steps) { + this.steps = steps; + } + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Integer getPeriod() { + return period; + } + + public void setPeriod(Integer period) { + this.period = period; + } + + public String getTimeUnit() { + return timeUnit; + } + + public void setTimeUnit(String timeUnit) { + this.timeUnit = timeUnit; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/CreateTemplateRequest.java b/src/main/java/com/baidubce/services/bmr/model/CreateTemplateRequest.java new file mode 100644 index 00000000..253ef232 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/CreateTemplateRequest.java @@ -0,0 +1,389 @@ +package com.baidubce.services.bmr.model; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class CreateTemplateRequest extends AbstractBceRequest { + private String name; + private String payType; + private List applications; + private Boolean autoTerminate = false; + private String imageType; + private String imageVersion; + private List instanceGroups; + private String logUri; + private List steps; + private String adminPassword; + private String availabilityZone; + private String vpcId; + private String subnetId; + private String systemSecurityGroup; + private Boolean serviceHaEnabled = false; + private Boolean safeModeEnabled = false; + private String templateType; + + + /** + * Configure the template type for the cluster. + * + * @param templateType The template type for cluster + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withTemplateType(String templateType) { + this.setTemplateType(templateType); + return this; + } + + /** + * Configure the image type for the cluster. + * + * @param imageType The image type for cluster's instances. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withImageType(String imageType) { + this.setImageType(imageType); + return this; + } + + /** + * Configure image version for the cluster. + * + * @param imageVersion The image version for the cluster's instance. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withImageVersion(String imageVersion) { + this.setImageVersion(imageVersion); + return this; + } + + /** + * Configure auto-terminate property for the cluster. If set the autoTerminate as true, then + * the cluster will be terminated when all the steps are done. And the autoTerminate is true by default. + * + * @param autoTerminate true if the cluster should be auto terminated. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withAutoTerminate(boolean autoTerminate) { + this.setAutoTerminate(autoTerminate); + return this; + } + + /** + * Configure optional BOS uri for logs of steps. If the uri is not set, then the logs for the cluster and + * steps are not saved in the BOS. + * + * @param logUri The valid BOS uri for the logs. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withLogUri(String logUri) { + this.setLogUri(logUri); + return this; + } + + /** + * Configure optional name of the cluster.If not set, then the name of the cluster will be + * "my-cluster" by default. + * + * @param name The name for the cluster. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withName(String name) { + this.setName(name); + return this; + } + + /** + * Configure optional service HA enable of the cluster. If true will create a ha cluster, default is false. + * + * @param serviceHaEnabled true if the serivce ha enable, default is false. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withServiceHaEnabled(boolean serviceHaEnabled) { + this.setServiceHaEnabled(serviceHaEnabled); + return this; + } + + /** + * Configure optional safe mode enable of the cluster. If true will create a cluster running as safe mode, + * default is false. + * + * @param safeModeEnabled true if the safe mode enable, default is false. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withSafeModeEnabled(boolean safeModeEnabled) { + this.setSafeModeEnabled(safeModeEnabled); + return this; + } + + /** + * Configure the instance group for the cluster. + * + * @param instanceGroup An InstanceGroupConfig instance. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withInstanceGroup(InstanceGroupConfig instanceGroup) { + if (this.instanceGroups == null) { + this.instanceGroups = new ArrayList(); + } + this.instanceGroups.add(instanceGroup); + return this; + } + + /** + * Configure optional application for the cluster. BMR provides applications such as Hive、Pig、HBase for the cluster. + * + * @param application An ApplicationConfig instance. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withApplication(Application application) { + if (this.applications == null) { + this.applications = new ArrayList(); + } + this.applications.add(application); + return this; + } + + /** + * Configure optional step for the cluster. The step will be scheduled and executed after the cluster is ACTIVE. + * And the step also can be added to the cluster by sending AddStepsRequest. + * + * @param step a StepConfig instance to be added. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withStep(StepConfig step) { + if (this.steps == null) { + this.steps = new ArrayList(); + } + this.steps.add(step); + return this; + } + + /** + * Configure the steps to be added. This method will replace the CreateClusterRequest instance's + * steps by the @param steps totally, thus it should be invoked ahead of withStep method if both + * of them are used for the same CreateClusterRequest instance. + * + * @param steps a List of StepConfig instances to be added. + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withSteps(List steps) { + this.setSteps(steps); + return this; + } + + /** + * Configure request adminPassword for the request. + * + * @param adminPassword adminPassword for example bmrtest@123 + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withAdminPassword(String adminPassword) { + this.setAdminPassword(adminPassword); + return this; + } + + /** + * Configure request vpc network name for the request. + * + * @param vpcId vpcId for cluster + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withVpcId(String vpcId) { + this.setVpcId(vpcId); + return this; + } + + /** + * Configure request subnet name for the request. + * + * @param subnetId subnetId for cluster + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withSubnetId(String subnetId) { + this.setSubnetId(subnetId); + return this; + } + + /** + * Configure request availabilityZone of creating cluster. + * + * @param availabilityZone availabilityZone for cluster + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withAvailabilityZone(String availabilityZone) { + this.setAvailabilityZone(availabilityZone); + return this; + } + + /** + * Configure request security group for the request. + * + * @param securityGroup securityGroup for cluster + * + * @return CreateClusterRequest + */ + public CreateTemplateRequest withSecurityGroup(String securityGroup) { + this.setSystemSecurityGroup(securityGroup); + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPayType() { + return payType; + } + + public void setPayType(String payType) { + this.payType = payType; + } + + public List getApplications() { + return applications; + } + + public void setApplications(List applications) { + this.applications = applications; + } + + public Boolean getAutoTerminate() { + return autoTerminate; + } + + public void setAutoTerminate(Boolean autoTerminate) { + this.autoTerminate = autoTerminate; + } + + public String getImageType() { + return imageType; + } + + public void setImageType(String imageType) { + this.imageType = imageType; + } + + public String getImageVersion() { + return imageVersion; + } + + public void setImageVersion(String imageVersion) { + this.imageVersion = imageVersion; + } + + public List getInstanceGroups() { + return instanceGroups; + } + + public void setInstanceGroups(List instanceGroups) { + this.instanceGroups = instanceGroups; + } + + public String getLogUri() { + return logUri; + } + + public void setLogUri(String logUri) { + this.logUri = logUri; + } + + public List getSteps() { + return steps; + } + + public void setSteps(List steps) { + this.steps = steps; + } + + public String getAdminPassword() { + return adminPassword; + } + + public void setAdminPassword(String adminPassword) { + this.adminPassword = adminPassword; + } + + public String getAvailabilityZone() { + return availabilityZone; + } + + public void setAvailabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getSystemSecurityGroup() { + return systemSecurityGroup; + } + + public void setSystemSecurityGroup(String systemSecurityGroup) { + this.systemSecurityGroup = systemSecurityGroup; + } + + public Boolean getServiceHaEnabled() { + return serviceHaEnabled; + } + + public void setServiceHaEnabled(Boolean serviceHaEnabled) { + this.serviceHaEnabled = serviceHaEnabled; + } + + public Boolean getSafeModeEnabled() { + return safeModeEnabled; + } + + public void setSafeModeEnabled(Boolean safeModeEnabled) { + this.safeModeEnabled = safeModeEnabled; + } + + public String getTemplateType() { + return templateType; + } + + public void setTemplateType(String templateType) { + this.templateType = templateType; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/CreateTemplateResponse.java b/src/main/java/com/baidubce/services/bmr/model/CreateTemplateResponse.java new file mode 100644 index 00000000..1de891c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/CreateTemplateResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +public class CreateTemplateResponse extends AbstractBceResponse { + private String templateId; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/DruidApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/DruidApplicationConfig.java new file mode 100644 index 00000000..140828c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/DruidApplicationConfig.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bmr.model; + +public class DruidApplicationConfig extends ApplicationConfig { + private static final String DRUID_APPLICATION = "druid"; + private static final String METASTORE = "metastore"; + private static final String HOST = "host"; + private static final String PORT = "port"; + private static final String DATABASE = "database"; + private static final String USERNAME = "userName"; + private static final String PASSWORD = "password"; + + public DruidApplicationConfig() { + this.setName(DRUID_APPLICATION); + } + + /** + * Configure the version of druid. + * The reference version is as follows: + *

+ * image type | image version | druid version supported + * hadoop | 2.0.0 | 0.12.1 + * + * @param version The version of druid. + * + * @return DruidApplicationConfig + */ + public DruidApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } + + /** + * Configure the metastore of druid Server。 By default, the inner metastore is used. + * And you can also use MySQL by set the metastore to "mysql". If so, you must provide + * other properties at the same time, including host and port for the MySQL service, the + * database name, the username and password for accessing MySQL database. + * + * @param metastore The type of metastore. Use "default" or "mysql". + * + * @return DruidApplicationConfig + */ + public DruidApplicationConfig withMetastore(String metastore) { + this.addProperty(METASTORE, metastore); + return this; + } + + /** + * Configure the host for MySQL service used by druid metastore. + * This configuration is needed only if the metastore is "mysql". + * + * @param host The host on which the MySQL service runs. + * + * @return DruidApplicationConfig + */ + public DruidApplicationConfig withHost(String host) { + this.addProperty(HOST, host); + return this; + + } + + /** + * Configure the port for MySQL service used by druid metastore. + * This configuration is needed only if the metastore is "mysql". + * + * @param port The port on which the MySQL service listens. + * + * @return DruidApplicationConfig + */ + public DruidApplicationConfig withPort(int port) { + this.addProperty(PORT, port); + return this; + } + + /** + * Configure the database name for the druid metastore. + * This configuration is needed only if the metastore is "mysql". + * + * @param database The database's name for druid metastore. + * + * @return DruidApplicationConfig + */ + public DruidApplicationConfig withDatabase(String database) { + this.addProperty(DATABASE, database); + return this; + } + + /** + * Configure the username for accessing MySQL database. + * This configuration is needed only if the metastore is "mysql". + * + * @param username The username for accessing MySQL database. + * + * @return DruidApplicationConfig + */ + public DruidApplicationConfig withUserName(String username) { + this.addProperty(USERNAME, username); + return this; + } + + /** + * Configure the password for accessing MySQL database. + * This configuration is needed only if the metastore is "mysql". + * + * @param password The password for accessing MySQL database. + * + * @return DruidApplicationConfig + */ + public DruidApplicationConfig withPassword(String password) { + this.addProperty(PASSWORD, password); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/EdpResultResponse.java b/src/main/java/com/baidubce/services/bmr/model/EdpResultResponse.java new file mode 100644 index 00000000..1396beb7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/EdpResultResponse.java @@ -0,0 +1,38 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +public class EdpResultResponse extends AbstractBceResponse { + private Boolean success = true; + private int status = 200; + private T result; + + public EdpResultResponse() { + } + + public Boolean getSuccess() { + return this.success; + } + + public int getStatus() { + return this.status; + } + + public T getResult() { + return this.result; + } + + public void setResult(T result) { + this.result = result; + } + + public EdpResultResponse withResult(T result) { + this.result = result; + return this; + } + + public String toString() { + return "EdpResultResponse{success=" + this.success + ", status=" + this.status + ", result=" + this.result + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/EipBindRequest.java b/src/main/java/com/baidubce/services/bmr/model/EipBindRequest.java new file mode 100644 index 00000000..f8bd31a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/EipBindRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class EipBindRequest extends AbstractBceRequest { + + private String clusterId; + private String instanceId; + private String eip; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/EipRequest.java b/src/main/java/com/baidubce/services/bmr/model/EipRequest.java new file mode 100644 index 00000000..26205523 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/EipRequest.java @@ -0,0 +1,40 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class EipRequest extends AbstractBceRequest { + private String clusterId; + private String instanceId; + + public EipRequest withClusterId(String clusterId) { + this.setClusterId(clusterId); + return this; + } + + public EipRequest withInstanceId(String instanceId) { + this.setInstanceId(instanceId); + return this; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/EipUnBindRequest.java b/src/main/java/com/baidubce/services/bmr/model/EipUnBindRequest.java new file mode 100644 index 00000000..baf391d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/EipUnBindRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class EipUnBindRequest extends AbstractBceRequest { + + private String clusterId; + private String instanceId; + private String eip; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/GetClusterRequest.java b/src/main/java/com/baidubce/services/bmr/model/GetClusterRequest.java index 82b2e2e4..2d494a77 100644 --- a/src/main/java/com/baidubce/services/bmr/model/GetClusterRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/GetClusterRequest.java @@ -33,6 +33,7 @@ public void setClusterId(String clusterId) { * Configure the cluster ID for the request. * * @param clusterId The ID of BMR cluster. + * * @return GetClusterRequest */ public GetClusterRequest withClusterId(String clusterId) { @@ -44,6 +45,7 @@ public GetClusterRequest withClusterId(String clusterId) { * Configure request credential for the request. * * @param credentials a valid instance of BceCredentials. + * * @return GetClusterRequest */ public GetClusterRequest withRequestCredentials(BceCredentials credentials) { diff --git a/src/main/java/com/baidubce/services/bmr/model/GetClusterResponse.java b/src/main/java/com/baidubce/services/bmr/model/GetClusterResponse.java index 6fac6fde..dce35274 100644 --- a/src/main/java/com/baidubce/services/bmr/model/GetClusterResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/GetClusterResponse.java @@ -12,13 +12,13 @@ */ package com.baidubce.services.bmr.model; -import com.baidubce.model.AbstractBceResponse; - import java.util.List; +import com.baidubce.model.AbstractBceResponse; + /** * Represent the response of GetClusterRequest. - * + *

* The response contains the properties of the target cluster, such as: * id, imageType, imageVersion, logUri, name, autoTerminate, status, applications. */ @@ -30,7 +30,81 @@ public class GetClusterResponse extends AbstractBceResponse { private String name; private boolean autoTerminate; private ClusterStatus status; + private String orderId; private List applications; + private boolean serviceHaEnabled; + private boolean safeModeEnabled; + private String payType; + private String availabilityZone; + private String vpcId; + private String subnetId; + private String securityGroupId; + private boolean enableAutoScale; + private List instanceGroups; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public List getInstanceGroups() { + return instanceGroups; + } + + public void setInstanceGroups(List instanceGroups) { + this.instanceGroups = instanceGroups; + } + + public boolean isEnableAutoScale() { + return enableAutoScale; + } + + public void setEnableAutoScale(boolean enableAutoScale) { + this.enableAutoScale = enableAutoScale; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getAvailabilityZone() { + return availabilityZone; + } + + public void setAvailabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + } + + public String getPayType() { + return payType; + } + + public void setPayType(String payType) { + this.payType = payType; + } public String getId() { return id; @@ -52,6 +126,10 @@ public String getImageVersion() { return imageVersion; } + public void setImageVersion(String imageVersion) { + this.imageVersion = imageVersion; + } + public String getName() { return name; } @@ -68,10 +146,6 @@ public void setLogUri(String logUri) { this.logUri = logUri; } - public void setImageVersion(String imageVersion) { - this.imageVersion = imageVersion; - } - public boolean getAutoTerminate() { return autoTerminate; } @@ -95,4 +169,20 @@ public List getApplications() { public void setApplications(List applications) { this.applications = applications; } + + public boolean getServiceHaEnabled() { + return serviceHaEnabled; + } + + public void setServiceHaEnabled(boolean serviceHaEnabled) { + this.serviceHaEnabled = serviceHaEnabled; + } + + public boolean getSafeModeEnabled() { + return safeModeEnabled; + } + + public void setSafeModeEnabled(boolean safeModeEnabled) { + this.safeModeEnabled = safeModeEnabled; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/GetStepRequest.java b/src/main/java/com/baidubce/services/bmr/model/GetStepRequest.java index 2d423772..4062dc8d 100644 --- a/src/main/java/com/baidubce/services/bmr/model/GetStepRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/GetStepRequest.java @@ -17,7 +17,7 @@ /** * Provides options for describing a step. - * + *

* The essential options are cluster ID and step ID. */ public class GetStepRequest extends AbstractBceRequest { @@ -44,6 +44,7 @@ public void setStepId(String stepId) { * Configure the cluster ID for the request. * * @param clusterId The ID of cluster which executes the target step. + * * @return GetStepRequest */ public GetStepRequest withClusterId(String clusterId) { @@ -55,6 +56,7 @@ public GetStepRequest withClusterId(String clusterId) { * Configure the step ID for the request. * * @param stepId The ID of the step. + * * @return GetStepRequest */ public GetStepRequest withStepId(String stepId) { @@ -66,6 +68,7 @@ public GetStepRequest withStepId(String stepId) { * Configure request credential for the request. * * @param credentials a valid instance of BceCredentials. + * * @return GetStepRequest */ public GetStepRequest withRequestCredentials(BceCredentials credentials) { diff --git a/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java b/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java index c2d53eb7..244ce9fc 100644 --- a/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java @@ -12,13 +12,14 @@ */ package com.baidubce.services.bmr.model; -import com.baidubce.model.AbstractBceResponse; - +import java.util.List; import java.util.Map; +import com.baidubce.model.AbstractBceResponse; + /** * Represent the response of GetStepRequest. - * + *

* The response contains the properties of the target step, such as: * id, actionOnFailure, name, type, properties and status. */ diff --git a/src/main/java/com/baidubce/services/bmr/model/HBaseApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/HBaseApplicationConfig.java index 60120dbb..7328f2f9 100644 --- a/src/main/java/com/baidubce/services/bmr/model/HBaseApplicationConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/HBaseApplicationConfig.java @@ -14,7 +14,7 @@ /** * Represent an HBase application. - * + *

* An HBase application can be configured with properties about backup and restore. */ public class HBaseApplicationConfig extends ApplicationConfig { @@ -34,12 +34,13 @@ public HBaseApplicationConfig() { /** * Configure the version of HBase. * The reference version is as follows: - * - * image type | image version | hbase version supported - * hadoop | 0.1.0 | 0.98.0 - * hadoop | 0.1.0 | 0.98.0 + *

+ * image type | image version | hbase version supported + * hadoop | 0.1.0 | 0.98.0 + * hadoop | 0.1.0 | 0.98.0 * * @param version The version of HBase. + * * @return HBaseApplicationConfig */ public HBaseApplicationConfig withVersion(String version) { @@ -52,6 +53,7 @@ public HBaseApplicationConfig withVersion(String version) { * the properties of backup-location, backup-internal and backup start time should be set. * * @param backupEnabled The switch of backup. Turn it on by setting true. + * * @return HBaseApplicationConfig */ public HBaseApplicationConfig withBackupEnabled(boolean backupEnabled) { @@ -64,6 +66,7 @@ public HBaseApplicationConfig withBackupEnabled(boolean backupEnabled) { * This property must be set if the backupEnabled is set true. * * @param backupLocation The BOS path for backup. + * * @return HBaseApplicationConfig */ public HBaseApplicationConfig withBackupLocation(String backupLocation) { @@ -76,6 +79,7 @@ public HBaseApplicationConfig withBackupLocation(String backupLocation) { * This property must be set if the backupEnabled is set true. * * @param minutes The number of minutes for backup interval time. + * * @return HBaseApplicationConfig */ public HBaseApplicationConfig withBackupIntervalInMinutes(int minutes) { @@ -88,6 +92,7 @@ public HBaseApplicationConfig withBackupIntervalInMinutes(int minutes) { * This property must be set if the backupEnabled is set true. * * @param startDatetime The start date time for HBase backup. + * * @return HBaseApplicationConfig */ public HBaseApplicationConfig withBackupStartDatetime(String startDatetime) { @@ -101,6 +106,7 @@ public HBaseApplicationConfig withBackupStartDatetime(String startDatetime) { * If restore is not enabled, then the HBase will be a purely new one. * * @param restoreEnabled The switch of restore. Turn it on by setting true. + * * @return HBaseApplicationConfig */ public HBaseApplicationConfig withRestoreEnabled(boolean restoreEnabled) { @@ -113,6 +119,7 @@ public HBaseApplicationConfig withRestoreEnabled(boolean restoreEnabled) { * This property must be set if the restoreEnabled is set true. * * @param restoreLocation The BOS path for restore. + * * @return HBaseApplicationConfig */ public HBaseApplicationConfig withRestoreLocation(String restoreLocation) { @@ -125,6 +132,7 @@ public HBaseApplicationConfig withRestoreLocation(String restoreLocation) { * This property must be set if the restoreEnabled is set true. * * @param restoreVersion The version of HBase backup files. + * * @return HBaseApplicationConfig */ public HBaseApplicationConfig withRestoreVersion(String restoreVersion) { diff --git a/src/main/java/com/baidubce/services/bmr/model/HdfsApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/HdfsApplicationConfig.java new file mode 100644 index 00000000..0c9f8b34 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/HdfsApplicationConfig.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bmr.model; + +/** + * Represent a Hdfs application. + *

+ * A Hdfs application can be configured with property of version. + */ +public class HdfsApplicationConfig extends ApplicationConfig { + private static final String HDFS_APPLICATION = "hdfs"; + + public HdfsApplicationConfig() { + this.setName(HDFS_APPLICATION); + } + + /** + * Configure the version of Hdfs. + * The reference version is as follows: + *

+ * image type | image version | hdfs version supported + * hadoop | 1.0.0/1.1.0/1.2.0 | 2.7.1 + * hadoop | 2.0.0 | 3.1.1 + * + * @param version The version of HDFS. + * + * @return HdfsApplicationConfig + */ + public HdfsApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/HiveApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/HiveApplicationConfig.java index b5a8f380..75c8acda 100644 --- a/src/main/java/com/baidubce/services/bmr/model/HiveApplicationConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/HiveApplicationConfig.java @@ -14,7 +14,7 @@ /** * Represent a Hive application. - * + *

* A Hive application can be configured with properties such as: * version, meta-store, host, port, database, username, password */ @@ -34,12 +34,13 @@ public HiveApplicationConfig() { /** * Configure the version of Hive. * The reference version is as follows: - * - * image type | image version | hive version supported - * hadoop | 0.1.0 | 0.13.0 - * hadoop | 0.2.0 | 0.14.0 + *

+ * image type | image version | hive version supported + * hadoop | 0.1.0 | 0.13.0 + * hadoop | 0.2.0 | 0.14.0 * * @param version The version of Hive. + * * @return HiveApplicationConfig */ public HiveApplicationConfig withVersion(String version) { @@ -54,6 +55,7 @@ public HiveApplicationConfig withVersion(String version) { * database name, the username and password for accessing MySQL database. * * @param metastore The type of metastore. Use "default" or "mysql". + * * @return HiveApplicationConfig */ public HiveApplicationConfig withMetastore(String metastore) { @@ -66,6 +68,7 @@ public HiveApplicationConfig withMetastore(String metastore) { * This configuration is needed only if the metastore is "mysql". * * @param host The host on which the MySQL service runs. + * * @return HiveApplicationConfig */ public HiveApplicationConfig withHost(String host) { @@ -79,6 +82,7 @@ public HiveApplicationConfig withHost(String host) { * This configuration is needed only if the metastore is "mysql". * * @param port The port on which the MySQL service listens. + * * @return HiveApplicationConfig */ public HiveApplicationConfig withPort(int port) { @@ -91,6 +95,7 @@ public HiveApplicationConfig withPort(int port) { * This configuration is needed only if the metastore is "mysql". * * @param database The database's name for Hive metastore. + * * @return HiveApplicationConfig */ public HiveApplicationConfig withDatabase(String database) { @@ -103,6 +108,7 @@ public HiveApplicationConfig withDatabase(String database) { * This configuration is needed only if the metastore is "mysql". * * @param username The username for accessing MySQL database. + * * @return HiveApplicationConfig */ public HiveApplicationConfig withUserName(String username) { @@ -115,6 +121,7 @@ public HiveApplicationConfig withUserName(String username) { * This configuration is needed only if the metastore is "mysql". * * @param password The password for accessing MySQL database. + * * @return HiveApplicationConfig */ public HiveApplicationConfig withPassword(String password) { diff --git a/src/main/java/com/baidubce/services/bmr/model/HiveStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/HiveStepConfig.java index b595f994..2dfdeda0 100644 --- a/src/main/java/com/baidubce/services/bmr/model/HiveStepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/HiveStepConfig.java @@ -14,7 +14,7 @@ /** * Represent configuration for a hive step. - * + *

* A hive step can be configured with name, actionOnFailure, script, input, output and arguments. * The essential options are script and actionOnFailure, * and the optional ones are name, input, output and arguments. @@ -34,6 +34,7 @@ public HiveStepConfig() { * Configure the input path of the hive step. * * @param input The input path of the hive step. + * * @return HiveStepConfig */ public HiveStepConfig withInput(String input) { @@ -45,6 +46,7 @@ public HiveStepConfig withInput(String input) { * Configure the script path of the hive step. * * @param script The script path of the hive step. + * * @return HiveStepConfig */ public HiveStepConfig withScript(String script) { @@ -56,6 +58,7 @@ public HiveStepConfig withScript(String script) { * Configure the output path of the hive step. * * @param output The output path of the hive step. + * * @return HiveStepConfig */ public HiveStepConfig withOutput(String output) { @@ -67,6 +70,7 @@ public HiveStepConfig withOutput(String output) { * Configure the arguments of the hive step. * * @param arguments The arguments of the hive step. + * * @return HiveStepConfig */ public HiveStepConfig withArguments(String arguments) { @@ -78,6 +82,7 @@ public HiveStepConfig withArguments(String arguments) { * Configure the name of the hive step. * * @param name The name of the hive step. + * * @return HiveStepConfig */ public HiveStepConfig withName(String name) { @@ -88,15 +93,29 @@ public HiveStepConfig withName(String name) { /** * Configure the action on failure for the hive step. * This property is set to enum value: - * "Continue": continue to execute other steps. - * "TerminateCluster": terminate the cluster when this step fails. - * "CancelAndWait": cancel the other pending steps and set the cluster's status to WAITING. + * "Continue": continue to execute other steps. + * "TerminateCluster": terminate the cluster when this step fails. + * "CancelAndWait": cancel the other pending steps and set the cluster's status to WAITING. * * @param actionOnFailure The action on step's failure. + * * @return HiveStepConfig */ public HiveStepConfig withActionOnFailure(String actionOnFailure) { this.setActionOnFailure(actionOnFailure); return this; } + + /** + * Configure the additional file for the step. + * + * @param remote The remote file of the additional file. + * @param local The local file of the additional file. + * + * @return HiveStepConfig + */ + public HiveStepConfig withAdditionalFile(String remote, String local) { + this.addAdditionalFile(remote, local); + return this; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/HostInfo.java b/src/main/java/com/baidubce/services/bmr/model/HostInfo.java new file mode 100644 index 00000000..8ba99b50 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/HostInfo.java @@ -0,0 +1,41 @@ +package com.baidubce.services.bmr.model; + +public class HostInfo { + + private String hostName; + private String id; + private String publicIP; + private String privateIP; + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPublicIP() { + return publicIP; + } + + public void setPublicIP(String publicIP) { + this.publicIP = publicIP; + } + + public String getPrivateIP() { + return privateIP; + } + + public void setPrivateIP(String privateIP) { + this.privateIP = privateIP; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bmr/model/HueApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/HueApplicationConfig.java index b60baf25..fb40be2a 100644 --- a/src/main/java/com/baidubce/services/bmr/model/HueApplicationConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/HueApplicationConfig.java @@ -14,7 +14,7 @@ /** * Represent a HUE applicaton. - * + *

* A HUE application can be configured with property of version. */ public class HueApplicationConfig extends ApplicationConfig { @@ -27,12 +27,13 @@ public HueApplicationConfig() { /** * Configure the version of HUE. * The reference version is as follows: - * - * image type | image version | HUE version supported - * hadoop | 0.1.0 | 3.7.1 - * hadoop | 0.2.0 | 3.7.1 + *

+ * image type | image version | HUE version supported + * hadoop | 0.1.0 | 3.7.1 + * hadoop | 0.2.0 | 3.7.1 * * @param version The version of HUE. + * * @return HueApplicationConfig */ public HueApplicationConfig withVersion(String version) { diff --git a/src/main/java/com/baidubce/services/bmr/model/ImpalaApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/ImpalaApplicationConfig.java new file mode 100644 index 00000000..0165c363 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ImpalaApplicationConfig.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bmr.model; + +/** + * Represent a impala applicaton. + *

+ * A impala application can be configured with property of version. + */ +public class ImpalaApplicationConfig extends ApplicationConfig { + private static final String IMPALA_APPLICATION = "impala"; + + public ImpalaApplicationConfig() { this.setName(IMPALA_APPLICATION); } + + /** + * Configure the version of impala. + * The reference version is as follows: + *

+ * image type | image version | impala version supported + * hadoop | 2.0.0 | 3.2.0 + * + * @param version The version of impala. + * + * @return ImpalaApplicationConfig + */ + public ImpalaApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/Instance.java b/src/main/java/com/baidubce/services/bmr/model/Instance.java index 163133e2..ed0b08ef 100644 --- a/src/main/java/com/baidubce/services/bmr/model/Instance.java +++ b/src/main/java/com/baidubce/services/bmr/model/Instance.java @@ -14,30 +14,85 @@ public class Instance { private String id; + private String bccInstanceId; + private String instanceName; private String privateIpAddress; private String publicIpAddress; + private Status status; + private String privateDnsName; + private String publicDnsName; + private int sshPort; - public void setId(String id) { - this.id = id; + public String getBccInstanceId() { + return bccInstanceId; + } + + public void setBccInstanceId(String bccInstanceId) { + this.bccInstanceId = bccInstanceId; + } + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public Status getStatus() { + return status; } + public void setStatus(Status status) { + this.status = status; + } + + public String getPrivateDnsName() { + return privateDnsName; + } + + public void setPrivateDnsName(String privateDnsName) { + this.privateDnsName = privateDnsName; + } + + public String getPublicDnsName() { + return publicDnsName; + } + + public void setPublicDnsName(String publicDnsName) { + this.publicDnsName = publicDnsName; + } + + public int getSshPort() { + return sshPort; + } + + public void setSshPort(int sshPort) { + this.sshPort = sshPort; + } + + public String getId() { return this.id; } - public void setPrivateIpAddress(String privateIpAddress) { - this.privateIpAddress = privateIpAddress; + public void setId(String id) { + this.id = id; } public String getPrivateIpAddress() { return this.privateIpAddress; } - public void setPublicIpAddress(String publicIpAddress) { - this.publicIpAddress = publicIpAddress; + public void setPrivateIpAddress(String privateIpAddress) { + this.privateIpAddress = privateIpAddress; } public String getPublicIpAddress() { return this.publicIpAddress; } + + public void setPublicIpAddress(String publicIpAddress) { + this.publicIpAddress = publicIpAddress; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/InstanceGroup.java b/src/main/java/com/baidubce/services/bmr/model/InstanceGroup.java index 9118b6cb..77a17de6 100644 --- a/src/main/java/com/baidubce/services/bmr/model/InstanceGroup.java +++ b/src/main/java/com/baidubce/services/bmr/model/InstanceGroup.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Baidu, Inc. + * Copyright 2014-2019 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -12,50 +12,227 @@ */ package com.baidubce.services.bmr.model; +import java.util.ArrayList; +import java.util.List; + +/** + * instanceGroup is the group of instance which is configured identically + */ public class InstanceGroup { private String id; private String instanceType; private String name; private String type; + private String spec; + private int cpu; + private int memory; + private boolean isSpot; + private String bidModel; + private String bidPrice; + private List cds = new ArrayList(); + private String diskType; + private int localDiskSize; + private int rootDiskSizeInGB; + private String rootDiskMediumType; private int requestedInstanceCount; + private int totalInstanceCount; + private int runningInstanceCount; + private int maxCount; + private int minCount; + private int canExpand; + private int canShrink; + private String code; + private String message; - public void setId(String id) { - this.id = id; + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public int getCpu() { + return cpu; + } + + public void setCpu(int cpu) { + this.cpu = cpu; + } + + public int getMemory() { + return memory; + } + + public void setMemory(int memory) { + this.memory = memory; + } + + public boolean isSpot() { + return isSpot; + } + + public void setSpot(boolean spot) { + isSpot = spot; + } + + public String getBidModel() { + return bidModel; + } + + public void setBidModel(String bidModel) { + this.bidModel = bidModel; + } + + public String getBidPrice() { + return bidPrice; + } + + public void setBidPrice(String bidPrice) { + this.bidPrice = bidPrice; + } + + public String getDiskType() { + return diskType; + } + + public void setDiskType(String diskType) { + this.diskType = diskType; + } + + public int getLocalDiskSize() { + return localDiskSize; + } + + public void setLocalDiskSize(int localDiskSize) { + this.localDiskSize = localDiskSize; + } + + public int getTotalInstanceCount() { + return totalInstanceCount; + } + + public void setTotalInstanceCount(int totalInstanceCount) { + this.totalInstanceCount = totalInstanceCount; + } + + public int getRunningInstanceCount() { + return runningInstanceCount; + } + + public void setRunningInstanceCount(int runningInstanceCount) { + this.runningInstanceCount = runningInstanceCount; + } + + public int getMaxCount() { + return maxCount; + } + + public void setMaxCount(int maxCount) { + this.maxCount = maxCount; + } + + public int getMinCount() { + return minCount; + } + + public void setMinCount(int minCount) { + this.minCount = minCount; + } + + public int getCanExpand() { + return canExpand; + } + + public void setCanExpand(int canExpand) { + this.canExpand = canExpand; + } + + public int getCanShrink() { + return canShrink; + } + + public void setCanShrink(int canShrink) { + this.canShrink = canShrink; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; } public String getId() { return this.id; } - public void setInstanceType(String instanceType) { - this.instanceType = instanceType; + public void setId(String id) { + this.id = id; } public String getInstanceType() { return this.instanceType; } - public void setName(String name) { - this.name = name; + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; } public String getName() { return this.name; } - public void setRequestedInstanceCount(int requestedInstanceCount) { - this.requestedInstanceCount = requestedInstanceCount; + public void setName(String name) { + this.name = name; } public int getRequestedInstanceCount() { return this.requestedInstanceCount; } - public void setType(String type) { - this.type = type; + public void setRequestedInstanceCount(int requestedInstanceCount) { + this.requestedInstanceCount = requestedInstanceCount; } public String getType() { return this.type; } + + public void setType(String type) { + this.type = type; + } + + public int getRootDiskSizeInGB() { + return rootDiskSizeInGB; + } + + public void setRootDiskSizeInGB(int rootDiskSizeInGB) { + this.rootDiskSizeInGB = rootDiskSizeInGB; + } + + public String getRootDiskMediumType() { + return rootDiskMediumType; + } + + public void setRootDiskMediumType(String rootDiskMediumType) { + this.rootDiskMediumType = rootDiskMediumType; + } + + public List getCds() { + return cds; + } + + public void setCds(List cds) { + this.cds = cds; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/InstanceGroupConfig.java b/src/main/java/com/baidubce/services/bmr/model/InstanceGroupConfig.java index 0c764127..af9f8293 100644 --- a/src/main/java/com/baidubce/services/bmr/model/InstanceGroupConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/InstanceGroupConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Baidu, Inc. + * Copyright 2014-2019 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -12,9 +12,12 @@ */ package com.baidubce.services.bmr.model; +import java.util.ArrayList; +import java.util.List; + /** * Represent the configuration for an instance group. - * + *

* An instance group can be configured with name, type, instance type and instance count. * And the type, instance type and count are essential options. */ @@ -23,6 +26,9 @@ public class InstanceGroupConfig { private String type; private String instanceType; private int instanceCount; + private int rootDiskSizeInGB; + private String rootDiskMediumType; + private List cds = new ArrayList(); public String getName() { return name; @@ -60,6 +66,7 @@ public void setInstanceCount(int instanceCount) { * Configure the name of the instance group. * * @param name The name of the instance group. + * * @return InstanceGroupConfig */ public InstanceGroupConfig withName(String name) { @@ -72,6 +79,7 @@ public InstanceGroupConfig withName(String name) { * The type of instance group can be one of "Master", "Core" or "Task". * * @param type The type of the instance group. + * * @return InstanceGroupConfig */ public InstanceGroupConfig withType(String type) { @@ -82,12 +90,13 @@ public InstanceGroupConfig withType(String type) { /** * Configure the instances'type in the target instance group. * The instance's type can be one of the following options: - * "g.small": 2 CPU(cores) 8 GB mem 200 GB disk - * "c.large": 8 CPU(cores) 32 GB mem 600 GB disk - * "m.medium": 4 CPU(cores) 32 GB mem 400 GB disk - * "s.medium": 4 CPU(cores) 16 GB mem 1000 GB disk + * "g.small": 2 CPU(cores) 8 GB mem 200 GB disk + * "c.large": 8 CPU(cores) 32 GB mem 600 GB disk + * "m.medium": 4 CPU(cores) 32 GB mem 400 GB disk + * "s.medium": 4 CPU(cores) 16 GB mem 1000 GB disk * * @param instanceType The instances' type for the instance group. + * * @return InstanceGroupConfig */ public InstanceGroupConfig withInstanceType(String instanceType) { @@ -99,10 +108,53 @@ public InstanceGroupConfig withInstanceType(String instanceType) { * Configure the instance count for the instance group. * * @param instanceCount The instance count for the instance group. + * * @return InstanceGroupConfig */ public InstanceGroupConfig withInstanceCount(int instanceCount) { this.setInstanceCount(instanceCount); return this; } + + public int getRootDiskSizeInGB() { + return rootDiskSizeInGB; + } + + public void setRootDiskSizeInGB(int rootDiskSizeInGB) { + this.rootDiskSizeInGB = rootDiskSizeInGB; + } + + public InstanceGroupConfig withRootDiskSizeInGB(int rootDiskSizeInGB) { + this.rootDiskSizeInGB = rootDiskSizeInGB; + return this; + } + + public String getRootDiskMediumType() { + return rootDiskMediumType; + } + + public void setRootDiskMediumType(String rootDiskMediumType) { + this.rootDiskMediumType = rootDiskMediumType; + } + + public InstanceGroupConfig withRootDiskMediumType(String rootDiskMediumType) { + this.rootDiskMediumType = rootDiskMediumType; + return this; + } + + public List getCds() { + return cds; + } + + public void setCds(List cds) { + this.cds = cds; + } + + public InstanceGroupConfig withCds(CdsItem cdsItem) { + if (this.cds == null) { + this.cds = new ArrayList(); + } + this.cds.add(cdsItem); + return this; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/InstanceGroupSummary.java b/src/main/java/com/baidubce/services/bmr/model/InstanceGroupSummary.java new file mode 100644 index 00000000..bae0defa --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/InstanceGroupSummary.java @@ -0,0 +1,94 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bmr.model; + +import java.util.ArrayList; +import java.util.List; + +/** + * instanceGroup is the group of instance which is configured identically + */ +public class InstanceGroupSummary { + private String id; + private String instanceType; + private String name; + private String type; + private int instanceCount; + private int rootDiskSizeInGB; + private String rootDiskMediumType; + private List cds = new ArrayList(); + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInstanceType() { + return this.instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public int getInstanceCount() { + return this.instanceCount; + } + + public void setInstanceCount(int requestedInstanceCount) { + this.instanceCount = requestedInstanceCount; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public int getRootDiskSizeInGB() { + return rootDiskSizeInGB; + } + + public void setRootDiskSizeInGB(int rootDiskSizeInGB) { + this.rootDiskSizeInGB = rootDiskSizeInGB; + } + + public String getRootDiskMediumType() { + return rootDiskMediumType; + } + + public void setRootDiskMediumType(String rootDiskMediumType) { + this.rootDiskMediumType = rootDiskMediumType; + } + + public List getCds() { + return cds; + } + + public void setCds(List cds) { + this.cds = cds; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/JavaStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/JavaStepConfig.java index ce29dc78..3d7707df 100644 --- a/src/main/java/com/baidubce/services/bmr/model/JavaStepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/JavaStepConfig.java @@ -14,7 +14,7 @@ /** * Represent configuration for a custom jar step. - * + *

* A custom jar step can be configured with name, actionOnFailure, jar, main class and arguments. * The essential options are jar, main class and actionOnFailure, * and the optional ones are name and arguments. @@ -33,6 +33,7 @@ public JavaStepConfig() { * Configure the BOS path for step's .jar file. * * @param jar The BOS path for the step's .jar file. + * * @return JavaStepConfig */ public JavaStepConfig withJar(String jar) { @@ -44,6 +45,7 @@ public JavaStepConfig withJar(String jar) { * Configure the main class for the step. * * @param mainClass The main class for the step. + * * @return JavaStepConfig */ public JavaStepConfig withMainClass(String mainClass) { @@ -55,6 +57,7 @@ public JavaStepConfig withMainClass(String mainClass) { * Configure the arguments for the step. * * @param arguments The arguments for the step. + * * @return JavaStepConfig */ public JavaStepConfig withArguments(String arguments) { @@ -65,11 +68,12 @@ public JavaStepConfig withArguments(String arguments) { /** * Configure the action on failure for the java step. * This property is set to enum value: - * "Continue": continue to execute other steps. - * "TerminateCluster": terminate the cluster when this step fails. - * "CancelAndWait": cancel the other pending steps and set the cluster's status to WAITING. + * "Continue": continue to execute other steps. + * "TerminateCluster": terminate the cluster when this step fails. + * "CancelAndWait": cancel the other pending steps and set the cluster's status to WAITING. * * @param actionOnFailure The action on step's failure. + * * @return JavaStepConfig */ public JavaStepConfig withActionOnFailure(String actionOnFailure) { @@ -81,10 +85,24 @@ public JavaStepConfig withActionOnFailure(String actionOnFailure) { * Configure the name of the step. * * @param name The name of the step. + * * @return JavaStepConfig */ public JavaStepConfig withName(String name) { this.setName(name); return this; } + + /** + * Configure the additional file for the step. + * + * @param remote The remote file of the additional file. + * @param local The local file of the additional file. + * + * @return JavaStepConfig + */ + public JavaStepConfig withAdditionalFile(String remote, String local) { + this.addAdditionalFile(remote, local); + return this; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/KafkaApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/KafkaApplicationConfig.java new file mode 100644 index 00000000..71d2be5d --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/KafkaApplicationConfig.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bmr.model; + +/** + * Represent a kafka applicaton. + *

+ * A kafka application can be configured with property of version. + */ +public class KafkaApplicationConfig extends ApplicationConfig { + private static final String KAFKA_APPLICATION = "kafka"; + + public KafkaApplicationConfig() { this.setName(KAFKA_APPLICATION); } + + /** + * Configure the version of kafka. + * The reference version is as follows: + *

+ * image type | image version | kafka version supported + * hadoop | 2.1.0 | 2.0.1 + * + * @param version The version of kafka. + * + * @return KafkaApplicationConfig + */ + public KafkaApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/KafkaManagerApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/KafkaManagerApplicationConfig.java new file mode 100644 index 00000000..a709ea68 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/KafkaManagerApplicationConfig.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bmr.model; + +/** + * Represent a kafka-manager applicaton. + *

+ * A kafka-manager application can be configured with property of version. + */ +public class KafkaManagerApplicationConfig extends ApplicationConfig { + private static final String KAFKA_APPLICATION = "kafka-manager"; + + public KafkaManagerApplicationConfig() { this.setName(KAFKA_APPLICATION); } + + /** + * Configure the version of kafka-manager. + * The reference version is as follows: + *

+ * image type | image version | kafka-manager version supported + * hadoop | 2.1.0 | 2.0.0.2 + * + * @param version The version of kafka-manager. + * + * @return KafkaManagerApplicationConfig + */ + public KafkaManagerApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/LdapApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/LdapApplicationConfig.java new file mode 100644 index 00000000..11ae0729 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/LdapApplicationConfig.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ + +package com.baidubce.services.bmr.model; + +/** + * Represent a ldap application. + *

+ * A ldap application can be configured with property of version. + */ +public class LdapApplicationConfig extends ApplicationConfig { + + private static final String LDAP_APPLICATION = "ldap"; + + public LdapApplicationConfig() { this.setName(LDAP_APPLICATION); } + + /** + * Configure the version of ldap. + * The reference version is as follows: + *

+ * image type | image version | ldap version supported + * hadoop | 2.1.0 | 2.4.28 + * + * @param version The version of ldap. + * + * @return LdapApplicationConfig + */ + public LdapApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bmr/model/ListClusterHostsRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListClusterHostsRequest.java new file mode 100644 index 00000000..78fb2c9b --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ListClusterHostsRequest.java @@ -0,0 +1,43 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class ListClusterHostsRequest extends AbstractBceRequest { + + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + + /** + * Configure the ID of the target cluster for the request. + * + * @param clusterId The ID of the target cluster. + * + * @return ListClusterHostsRequest + */ + public ListClusterHostsRequest withClusterId(String clusterId) { + this.setClusterId(clusterId); + return this; + } + + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * + * @return ListClusterHostsRequest + */ + public ListClusterHostsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bmr/model/ListClusterHostsResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListClusterHostsResponse.java new file mode 100644 index 00000000..8c227d05 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ListClusterHostsResponse.java @@ -0,0 +1,34 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; +import java.util.List; + + +/** + * Represent the response of ListClusterHosts. + *

+ * The response contains an array of BMR Instance Info objects. + */ +public class ListClusterHostsResponse extends AbstractBceResponse { + + private String clusterId; + + private List hosts; + + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public List getHosts() { + return hosts; + } + + public void setHosts(List hosts) { + this.hosts = hosts; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java old mode 100644 new mode 100755 index 600e5440..3674028f --- a/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java @@ -17,7 +17,7 @@ /** * Provides options for listing clusters. - * + *

* The optional query parameters are marker and max keys. */ public class ListClustersRequest extends AbstractBceRequest { @@ -44,7 +44,8 @@ public void setMaxKeys(int maxKeys) { * Configure the marker for the query request. * The marker marks the starting point for the query. * - * @param marker + * @param marker the marker + * * @return ListClustersRequest */ public ListClustersRequest withMarker(String marker) { @@ -58,6 +59,7 @@ public ListClustersRequest withMarker(String marker) { * reset to 1000. * * @param maxKeys The max count for each response page. + * * @return ListClustersRequest */ public ListClustersRequest withMaxKeys(int maxKeys) { @@ -69,6 +71,7 @@ public ListClustersRequest withMaxKeys(int maxKeys) { * Configure request credential for the request. * * @param credentials a valid instance of BceCredentials. + * * @return ListClustersRequest */ public ListClustersRequest withRequestCredentials(BceCredentials credentials) { diff --git a/src/main/java/com/baidubce/services/bmr/model/ListClustersResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListClustersResponse.java index 02be361c..b9c494e3 100644 --- a/src/main/java/com/baidubce/services/bmr/model/ListClustersResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListClustersResponse.java @@ -12,23 +12,21 @@ */ package com.baidubce.services.bmr.model; +import java.util.List; + import com.baidubce.model.AbstractBceResponse; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - /** * Represent the response of ListClustersRequest. - * + *

* The response contains a array of BMR Cluster objects. */ public class ListClustersResponse extends AbstractBceResponse { private String marker; private String nextMarker; - private int maxKeys; private boolean isTruncated; private List clusters; - public String getMarker() { return marker; } @@ -37,14 +35,6 @@ public void setMarker(String marker) { this.marker = marker; } - public int getMaxKeys() { - return maxKeys; - } - - public void setMaxKeys(int maxKeys) { - this.maxKeys = maxKeys; - } - public String getNextMarker() { return nextMarker; } @@ -57,8 +47,7 @@ public boolean isTruncated() { return this.isTruncated; } - @JsonProperty("isTruncated") - public void setTruncated(boolean isTruncated) { + @JsonProperty("isTruncated") public void setTruncated(boolean isTruncated) { this.isTruncated = isTruncated; } diff --git a/src/main/java/com/baidubce/services/bmr/model/ListHistorySchedulePlanResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListHistorySchedulePlanResponse.java new file mode 100644 index 00000000..3cb62511 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ListHistorySchedulePlanResponse.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +public class ListHistorySchedulePlanResponse extends AbstractBceResponse { + private String code; + private String msg; + private ScheduleHistoryModelsVo historyModels; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public ScheduleHistoryModelsVo getHistoryModels() { + return historyModels; + } + + public void setHistoryModels(ScheduleHistoryModelsVo historyModels) { + this.historyModels = historyModels; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsRequest.java index 1e4b5082..a41bedfe 100644 --- a/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsRequest.java @@ -17,24 +17,25 @@ /** * Provide options for getting the instance groups of the target cluster. - * + *

* The essential option is the ID of cluster. */ public class ListInstanceGroupsRequest extends AbstractBceRequest { private String clusterId; - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - public String getClusterId() { return this.clusterId; } + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + /** * Configure the cluster ID for the request. * * @param clusterId The ID of the target cluster. + * * @return ListInstanceGroupsRequest */ public ListInstanceGroupsRequest withClusterId(String clusterId) { @@ -46,6 +47,7 @@ public ListInstanceGroupsRequest withClusterId(String clusterId) { * Configure request credential for the request. * * @param credentials a valid instance of BceCredentials. + * * @return ListInstanceGroupsRequest */ public ListInstanceGroupsRequest withRequestCredentials(BceCredentials credentials) { diff --git a/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsResponse.java index deb0c791..f9009529 100644 --- a/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsResponse.java @@ -12,23 +12,23 @@ */ package com.baidubce.services.bmr.model; -import com.baidubce.model.AbstractBceResponse; - import java.util.List; +import com.baidubce.model.AbstractBceResponse; + /** * Represent the response of ListInstanceGroupsRequest. - * + *

* The response contains a array of BMR InstanceGroup objects. */ public class ListInstanceGroupsResponse extends AbstractBceResponse { private List instanceGroups; - public void setInstanceGroups(List instanceGroups) { - this.instanceGroups = instanceGroups; - } - public List getInstanceGroups() { return this.instanceGroups; } + + public void setInstanceGroups(List instanceGroups) { + this.instanceGroups = instanceGroups; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/ListInstancesRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListInstancesRequest.java index 7606828a..43681f60 100644 --- a/src/main/java/com/baidubce/services/bmr/model/ListInstancesRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListInstancesRequest.java @@ -19,26 +19,27 @@ public class ListInstancesRequest extends AbstractBceRequest { private String clusterId; private String instanceGroupId; - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - public String getClusterId() { return this.clusterId; } - public void setInstanceGroupId(String instanceGroupId) { - this.instanceGroupId = instanceGroupId; + public void setClusterId(String clusterId) { + this.clusterId = clusterId; } public String getInstanceGroupId() { return this.instanceGroupId; } + public void setInstanceGroupId(String instanceGroupId) { + this.instanceGroupId = instanceGroupId; + } + /** * Configure the ID of the target cluster for the request. * * @param clusterId The ID of the target cluster. + * * @return ListInstancesRequest */ public ListInstancesRequest withClusterId(String clusterId) { @@ -50,16 +51,19 @@ public ListInstancesRequest withClusterId(String clusterId) { * Configure the ID of the target instance group for the request. * * @param instanceGroupId The ID of the instance group. + * * @return ListInstancesRequest */ public ListInstancesRequest withInstanceGroupId(String instanceGroupId) { this.setInstanceGroupId(instanceGroupId); return this; } + /** * Configure request credential for the request. * * @param credentials a valid instance of BceCredentials. + * * @return ListInstancesRequest */ public ListInstancesRequest withRequestCredentials(BceCredentials credentials) { diff --git a/src/main/java/com/baidubce/services/bmr/model/ListInstancesResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListInstancesResponse.java index a6f656a5..792248ea 100644 --- a/src/main/java/com/baidubce/services/bmr/model/ListInstancesResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListInstancesResponse.java @@ -12,13 +12,13 @@ */ package com.baidubce.services.bmr.model; -import com.baidubce.model.AbstractBceResponse; - import java.util.List; +import com.baidubce.model.AbstractBceResponse; + /** * Represent the response of ListInstancesRequest. - * + *

* The response contains an array of BMR Instance objects. */ public class ListInstancesResponse extends AbstractBceResponse { diff --git a/src/main/java/com/baidubce/services/bmr/model/ListScheduleDetailRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListScheduleDetailRequest.java new file mode 100644 index 00000000..93af62a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ListScheduleDetailRequest.java @@ -0,0 +1,12 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class ListScheduleDetailRequest extends AbstractBceRequest { + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java old mode 100644 new mode 100755 index ded14eab..57447ac2 --- a/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java @@ -17,42 +17,43 @@ /** * Provides options for listing steps. - * + *

* The essential option is cluster ID, and the optional query parameters are marker and max keys. */ public class ListStepsRequest extends AbstractBceRequest { private String clusterId; - private String marker; - private int maxKeys = -1; + private int pageNo; + private int pageSize; - public String getClusterId() { - return clusterId; + public int getPageNo() { + return pageNo; } - public void setClusterId(String clusterId) { - this.clusterId = clusterId; + public void setPageNo(int pageNo) { + this.pageNo = pageNo; } - public String getMarker() { - return marker; + public int getPageSize() { + return pageSize; } - public void setMarker(String marker) { - this.marker = marker; + public void setPageSize(int pageSize) { + this.pageSize = pageSize; } - public int getMaxKeys() { - return maxKeys; + public String getClusterId() { + return clusterId; } - public void setMaxKeys(int maxKeys) { - this.maxKeys = maxKeys; + public void setClusterId(String clusterId) { + this.clusterId = clusterId; } /** * Configure the cluster ID on which the target steps run. * * @param clusterId The cluster ID. + * * @return ListStepsRequest */ public ListStepsRequest withClusterId(String clusterId) { @@ -60,35 +61,11 @@ public ListStepsRequest withClusterId(String clusterId) { return this; } - /** - * Configure the marker for the query request. - * The marker marks the starting point for the query. - * - * @param marker - * @return ListStepsRequest - */ - public ListStepsRequest withMarker(String marker) { - this.setMarker(marker); - return this; - } - - /** - * Configure the max count for each response page. - * The max keys can not more than 1000, any number exceeding 1000 will be - * reset to 1000. - * - * @param maxKeys The max count for each response page. - * @return ListStepsRequest - */ - public ListStepsRequest withMaxKeys(int maxKeys) { - this.setMaxKeys(maxKeys); - return this; - } - /** * Configure request credential for the request. * * @param credentials a valid instance of BceCredentials. + * * @return ListStepsRequest */ public ListStepsRequest withRequestCredentials(BceCredentials credentials) { diff --git a/src/main/java/com/baidubce/services/bmr/model/ListStepsResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListStepsResponse.java index 35d0b2a6..18e634ea 100644 --- a/src/main/java/com/baidubce/services/bmr/model/ListStepsResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListStepsResponse.java @@ -12,45 +12,44 @@ */ package com.baidubce.services.bmr.model; +import java.util.List; + import com.baidubce.model.AbstractBceResponse; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - /** * Represent the response of ListStepsRequest. - * + *

* The response contains a array of BMR Step objects. */ public class ListStepsResponse extends AbstractBceResponse { - private boolean isTruncated; - private String marker; - private String nextMarker; + private int pageNo; + private int pageSize; + private int total; private List steps; - public boolean isTruncated() { - return this.isTruncated; + public int getPageNo() { + return pageNo; } - @JsonProperty("isTruncated") - public void setTruncated(boolean isTruncated) { - this.isTruncated = isTruncated; + public void setPageNo(int pageNo) { + this.pageNo = pageNo; } - public String getMarker() { - return marker; + public int getPageSize() { + return pageSize; } - public void setMarker(String marker) { - this.marker = marker; + public void setPageSize(int pageSize) { + this.pageSize = pageSize; } - public String getNextMarker() { - return nextMarker; + public int getTotal() { + return total; } - public void setNextMarker(String nextMarker) { - this.nextMarker = nextMarker; + public void setTotal(int total) { + this.total = total; } public List getSteps() { diff --git a/src/main/java/com/baidubce/services/bmr/model/MapReduce2ApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/MapReduce2ApplicationConfig.java new file mode 100644 index 00000000..ef88ed87 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/MapReduce2ApplicationConfig.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bmr.model; + +/** + * Represent a MapReduce2 application. + *

+ * A MapReduce2 application can be configured with property of version. + */ +public class MapReduce2ApplicationConfig extends ApplicationConfig { + private static final String MAPREDUCE2_APPLICATION = "mapreduce2"; + + public MapReduce2ApplicationConfig() { + this.setName(MAPREDUCE2_APPLICATION); + } + + /** + * Configure the version of MapReduce2. + * The reference version is as follows: + *

+ * image type | image version | mapreduce2 version supported + * hadoop | 1.0.0/1.1.0/1.2.0 | 2.7.1 + * hadoop | 2.0.0 | 3.1.1 + * + * @param version The version of MapReduce2. + * + * @return MapReduce2ApplicationConfig + */ + public MapReduce2ApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bmr/model/ModifyInstanceGroupConfig.java b/src/main/java/com/baidubce/services/bmr/model/ModifyInstanceGroupConfig.java new file mode 100644 index 00000000..13a05e0f --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ModifyInstanceGroupConfig.java @@ -0,0 +1,28 @@ +package com.baidubce.services.bmr.model; + +/** + * Represent configuration for modify instance group operation. + *

+ * The essential options are id and instance count. + */ +public class ModifyInstanceGroupConfig { + private String id; + + private int instanceCount; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getInstanceCount() { + return instanceCount; + } + + public void setInstanceCount(int instanceCount) { + this.instanceCount = instanceCount; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ModifyInstanceGroupsRequest.java b/src/main/java/com/baidubce/services/bmr/model/ModifyInstanceGroupsRequest.java new file mode 100644 index 00000000..34812497 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ModifyInstanceGroupsRequest.java @@ -0,0 +1,110 @@ +package com.baidubce.services.bmr.model; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Provide options for modifying instance groups of the target cluster. + *

+ * The essential option is the ID of cluster, and the List of instanceGroups can be constructed by + * calling the methods of ModifyInstanceGroupConfig. + */ +public class ModifyInstanceGroupsRequest extends AbstractBceRequest { + private String clientToken; + private String clusterId; + private List instanceGroups; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public List getInstanceGroups() { + return instanceGroups; + } + + public void setInstanceGroups(List instanceGroups) { + this.instanceGroups = instanceGroups; + } + + /** + * Configure the ID of the cluster. + * + * @param clusterId The ID of the cluster. + * + * @return ModifyInstanceGroupsRequest + */ + public ModifyInstanceGroupsRequest withClusterId(String clusterId) { + this.setClusterId(clusterId); + return this; + } + + /** + * Configure the instance group to be modified. + * + * @param instanceGroup an instance group config to be added. + * + * @return ModifyInstanceGroupsRequest + */ + public ModifyInstanceGroupsRequest withInstanceGroup(ModifyInstanceGroupConfig instanceGroup) { + if (this.instanceGroups == null) { + this.instanceGroups = new ArrayList(); + } + this.instanceGroups.add(instanceGroup); + return this; + } + + /** + * Configure the instance groups to be modified. This method will replace the ModifyInstanceGroupsRequest + * instance's instanceGroups by the @param instanceGroups totally, thus it should be + * invoked ahead of withInstanceGroup method, if both of them are used for the same + * ModifyInstanceGroupsRequest instance. + * + * @param instanceGroups an instance group config to be added. + * + * @return ModifyInstanceGroupsRequest + */ + public ModifyInstanceGroupsRequest withInstanceGroups(List instanceGroups) { + this.setInstanceGroups(instanceGroups); + return this; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * + * @param clientToken An ASCII string whose length is less than 64. + * + * @return ModifyInstanceGroupsRequest + */ + public ModifyInstanceGroupsRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * + * @return ModifyInstanceGroupsRequest + */ + public ModifyInstanceGroupsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bmr/model/NormalResponse.java b/src/main/java/com/baidubce/services/bmr/model/NormalResponse.java new file mode 100644 index 00000000..0fd7f808 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/NormalResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +public class NormalResponse extends AbstractBceResponse { + private Boolean success; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/PeriodUnitType.java b/src/main/java/com/baidubce/services/bmr/model/PeriodUnitType.java new file mode 100644 index 00000000..4e12623c --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/PeriodUnitType.java @@ -0,0 +1,55 @@ +package com.baidubce.services.bmr.model; + +/** + * Created by xushiyue on 2015/11/23. + */ +public enum PeriodUnitType { + MINUTE("/%s * * * *", "*/%s * * * *", "/([0-9]+) \\* \\* \\* \\*", 60 * 1000l, 5, Integer.MAX_VALUE), + HOUR("* /%s * * *", "* */%s * * *", "\\* /([0-9]+) \\* \\* \\*", 60 * 60 * 1000l, 1, Integer.MAX_VALUE), + DAY("* * /%s * *", "* * */%s * *", "\\* \\* /([0-9]+) \\* \\*", 24 * 60 * 60 * 1000l, 1, Integer.MAX_VALUE); + + private String format; + + private String bmrFormat; + + private String pattern; + + private Long unitInMs; + + private int maxValue; + + private int minValue; + + private PeriodUnitType(String format, String bmrFormat, String Pattern, Long unitInMs, int minValue, int maxValue) { + this.format = format; + this.bmrFormat = bmrFormat; + this.pattern = Pattern; + this.unitInMs = unitInMs; + this.maxValue = maxValue; + this.minValue = minValue; + } + + public String getFormat() { + return format; + } + + public String getBmrFormat() { + return bmrFormat; + } + + public String getPattern() { + return pattern; + } + + public Long getUnitInMs() { + return unitInMs; + } + + public int getMaxValue() { + return maxValue; + } + + public int getMinValue() { + return minValue; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/PigApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/PigApplicationConfig.java index b3a56600..af473e66 100644 --- a/src/main/java/com/baidubce/services/bmr/model/PigApplicationConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/PigApplicationConfig.java @@ -14,7 +14,7 @@ /** * Represent a Pig application. - * + *

* A Pig application can be configured with property of version. */ public class PigApplicationConfig extends ApplicationConfig { @@ -27,12 +27,13 @@ public PigApplicationConfig() { /** * Configure the version of Pig. * The reference version is as follows: - * - * image type | image version | pig version supported - * hadoop | 0.1.0 | 0.11.0 - * hadoop | 0.2.0 | 0.14.0 + *

+ * image type | image version | pig version supported + * hadoop | 0.1.0 | 0.11.0 + * hadoop | 0.2.0 | 0.14.0 * * @param version The version of Pig. + * * @return PigApplicationConfig */ public PigApplicationConfig withVersion(String version) { diff --git a/src/main/java/com/baidubce/services/bmr/model/PigStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/PigStepConfig.java index bfc9ebd0..94801d31 100644 --- a/src/main/java/com/baidubce/services/bmr/model/PigStepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/PigStepConfig.java @@ -14,7 +14,7 @@ /** * Represent configuration for a pig step. - * + *

* A pig step can be configured with name, actionOnFailure, script, input, output and arguments. * The essential options are script and actionOnFailure, * and the optional ones are name, input, output and arguments. @@ -26,7 +26,6 @@ public class PigStepConfig extends StepConfig { private static final String OUTPUT = "output"; private static final String ARGUMENTS = "arguments"; - public PigStepConfig() { this.setType(PIG_STEP); } @@ -35,6 +34,7 @@ public PigStepConfig() { * Configure the input path of the pig step. * * @param input The input path of the pig step. + * * @return PigStepConfig */ public PigStepConfig withInput(String input) { @@ -46,6 +46,7 @@ public PigStepConfig withInput(String input) { * Configure the script path of the pig step. * * @param script The script path of the pig step. + * * @return PigStepConfig */ public PigStepConfig withScript(String script) { @@ -57,6 +58,7 @@ public PigStepConfig withScript(String script) { * Configure the output path of the pig step. * * @param output The output path of the pig step. + * * @return PigStepConfig */ public PigStepConfig withOutput(String output) { @@ -68,36 +70,52 @@ public PigStepConfig withOutput(String output) { * Configure the arguments of the pig step. * * @param arguments The arguments of the pig step. + * * @return PigStepConfig */ public PigStepConfig withArguments(String arguments) { this.addProperty(ARGUMENTS, arguments); return this; } - + /** * Configure the name of the pig step. * * @param name The name of the pig step. + * * @return PigStepConfig */ public PigStepConfig withName(String name) { this.setName(name); return this; } - + /** * Configure the action on failure for the pig step. * This property is set to enum value: - * "Continue": continue to execute other steps. - * "TerminateCluster": terminate the cluster when this step fails. - * "CancelAndWait": cancel the other pending steps and set the cluster's status to WAITING. + * "Continue": continue to execute other steps. + * "TerminateCluster": terminate the cluster when this step fails. + * "CancelAndWait": cancel the other pending steps and set the cluster's status to WAITING. * * @param actionOnFailure The action on step's failure. + * * @return PigStepConfig */ public PigStepConfig withActionOnFailure(String actionOnFailure) { this.setActionOnFailure(actionOnFailure); return this; } + + /** + * Configure the additional file for the step. + * + * @param remote The remote file of the additional file. + * @param local The local file of the additional file. + * + * @return PigStepConfig + */ + public PigStepConfig withAdditionalFile(String remote, String local) { + this.addAdditionalFile(remote, local); + return this; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/PrestoApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/PrestoApplicationConfig.java new file mode 100644 index 00000000..8cb1103a --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/PrestoApplicationConfig.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bmr.model; + +public class PrestoApplicationConfig extends ApplicationConfig{ + private static final String Presto_APPLICATION = "presto"; + + + public PrestoApplicationConfig() { + this.setName(Presto_APPLICATION); + } + + + /** + * Configure the version of presto. + * The reference version is as follows: + *

+ * image type | image version | presto version supported + * hadoop | 2.0.0 | 0.219 + * @param version The version of presto. + * + * @return PrestoApplicationConfig + */ + public PrestoApplicationConfig withVersion(String version){ + this .setVersion(version); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/RangerApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/RangerApplicationConfig.java new file mode 100644 index 00000000..9a81a4da --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/RangerApplicationConfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bmr.model; + +/** + * Represent a Ranger applicaton. + *

+ * A Ranger application can be configured with property of version. + */ +public class RangerApplicationConfig extends ApplicationConfig { + private static final String Ranger_APPLICATION = "ranger"; + + public RangerApplicationConfig() { + this.setName(Ranger_APPLICATION); + } + + /** + * Configure the version of Ranger. + * The reference version is as follows: + *

+ * image type | image version | Ranger version supported + * hadoop | 1.2.0 | 0.11 + * + * @param version The version of Ranger. + * + * @return RangerApplicationConfig + */ + public RangerApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/Reminder.java b/src/main/java/com/baidubce/services/bmr/model/Reminder.java new file mode 100644 index 00000000..8ca9075b --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/Reminder.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bmr.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; + +public class Reminder extends ReminderConfig { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + lastDateTime; + + public Date getLastDateTime() { + return lastDateTime; + } + + public void setLastDateTime(Date lastDateTime) { + this.lastDateTime = lastDateTime; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ReminderConfig.java b/src/main/java/com/baidubce/services/bmr/model/ReminderConfig.java new file mode 100644 index 00000000..e2f20652 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ReminderConfig.java @@ -0,0 +1,49 @@ +package com.baidubce.services.bmr.model; + +import java.util.List; + +public class ReminderConfig { + // @NotNull + private Boolean enabled; + + // @NotEmpty + private String action; + + private List media; + + // @NotNull + // @Min(1) + private Integer duration; + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public List getMedia() { + return media; + } + + public void setMedia(List media) { + this.media = media; + } + + public Integer getDuration() { + return duration; + } + + public void setDuration(Integer duration) { + this.duration = duration; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/RenameCluseterRequest.java b/src/main/java/com/baidubce/services/bmr/model/RenameCluseterRequest.java new file mode 100644 index 00000000..a469ea56 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/RenameCluseterRequest.java @@ -0,0 +1,40 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class RenameCluseterRequest extends AbstractBceRequest { + private String clusterId; + private String newName; + + public RenameCluseterRequest withClusterId(String clusterId) { + this.setClusterId(clusterId); + return this; + } + + public RenameCluseterRequest withNewName(String newName) { + this.setNewName(newName); + return this; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getNewName() { + return newName; + } + + public void setNewName(String newName) { + this.newName = newName; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ScaleStatus.java b/src/main/java/com/baidubce/services/bmr/model/ScaleStatus.java new file mode 100644 index 00000000..c7937ac7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ScaleStatus.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bmr.model; + +public class ScaleStatus { + private String orderId; + + private String scaleType; + + private String state; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getScaleType() { + return scaleType; + } + + public void setScaleType(String scaleType) { + this.scaleType = scaleType; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/Schedule.java b/src/main/java/com/baidubce/services/bmr/model/Schedule.java new file mode 100644 index 00000000..4b39e609 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/Schedule.java @@ -0,0 +1,78 @@ +package com.baidubce.services.bmr.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; + +public class Schedule { + + private Integer period; + + private String periodUnit; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + startTime; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + endTime; + + /** + * 构造方法 + */ + public Schedule() { + + } + + public Schedule withPeriod(int period) { + this.setPeriod(period); + return this; + } + + public Schedule withPeriodUnit(String periodUnit) { + this.setPeriodUnit(periodUnit); + return this; + } + + public Schedule withStartTime(Date startTime) { + this.setStartTime(startTime); + return this; + } + + public Schedule withEndTime(Date endTime) { + this.setEndTime(endTime); + return this; + } + + public Integer getPeriod() { + return period; + } + + public void setPeriod(Integer period) { + this.period = period; + } + + public String getPeriodUnit() { + return periodUnit; + } + + public void setPeriodUnit(String periodUnit) { + this.periodUnit = periodUnit; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ScheduleCreateResponse.java b/src/main/java/com/baidubce/services/bmr/model/ScheduleCreateResponse.java new file mode 100644 index 00000000..48ea6b41 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ScheduleCreateResponse.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +public class ScheduleCreateResponse extends AbstractBceResponse { + private String scheduleId; + private String code; + private String msg; + + public String getScheduleId() { + return scheduleId; + } + + public void setScheduleId(String scheduleId) { + this.scheduleId = scheduleId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ScheduleHistoryModelVo.java b/src/main/java/com/baidubce/services/bmr/model/ScheduleHistoryModelVo.java new file mode 100644 index 00000000..4a7410ad --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ScheduleHistoryModelVo.java @@ -0,0 +1,81 @@ +package com.baidubce.services.bmr.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; + +public class ScheduleHistoryModelVo { + private Long id; + private String serviceType; + private Long scheduleId; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + startTime; + private String status; + private String code; + private String clusterId; + private String clusterName; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public Long getScheduleId() { + return scheduleId; + } + + public void setScheduleId(Long scheduleId) { + this.scheduleId = scheduleId; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ScheduleHistoryModelsVo.java b/src/main/java/com/baidubce/services/bmr/model/ScheduleHistoryModelsVo.java new file mode 100644 index 00000000..86aa8644 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ScheduleHistoryModelsVo.java @@ -0,0 +1,42 @@ +package com.baidubce.services.bmr.model; + +import java.util.List; + +public class ScheduleHistoryModelsVo { + private List models; + private Integer pageNo; + private Integer pageSize; + private Integer total; + + public List getModels() { + return models; + } + + public void setModels(List models) { + this.models = models; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/SchedulePlanDetailListResponse.java b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanDetailListResponse.java new file mode 100644 index 00000000..bd6ac73f --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanDetailListResponse.java @@ -0,0 +1,35 @@ +package com.baidubce.services.bmr.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +public class SchedulePlanDetailListResponse extends AbstractBceResponse { + private List listSchedulePlan; + private Integer pageNo; + private Integer pageSize; + + public List getListSchedulePlan() { + return listSchedulePlan; + } + + public void setListSchedulePlan(List listSchedulePlan) { + this.listSchedulePlan = listSchedulePlan; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/SchedulePlanDetailResponse.java b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanDetailResponse.java new file mode 100644 index 00000000..067d2922 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanDetailResponse.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +public class SchedulePlanDetailResponse extends AbstractBceResponse { + private String code; + private String msg; + private SchedulePlanModelVo ctx; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public SchedulePlanModelVo getCtx() { + return ctx; + } + + public void setCtx(SchedulePlanModelVo ctx) { + this.ctx = ctx; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/SchedulePlanModelVo.java b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanModelVo.java new file mode 100644 index 00000000..d317f6bc --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanModelVo.java @@ -0,0 +1,13 @@ +package com.baidubce.services.bmr.model; + +public class SchedulePlanModelVo extends SchedulePlanSummaryModelVo { + private ClusterTemplateInfoVo clusterTemplate; + + public ClusterTemplateInfoVo getClusterTemplate() { + return clusterTemplate; + } + + public void setClusterTemplate(ClusterTemplateInfoVo clusterTemplate) { + this.clusterTemplate = clusterTemplate; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/SchedulePlanRequest.java b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanRequest.java new file mode 100644 index 00000000..d353b8cc --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanRequest.java @@ -0,0 +1,56 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class SchedulePlanRequest extends AbstractBceRequest { + private String schedulePlanId; + + private Integer pageNo; + + private Integer pageSize; + + public SchedulePlanRequest withSchedulePlanId(String schedulePlanId) { + this.setSchedulePlanId(schedulePlanId); + return this; + } + + public SchedulePlanRequest withPageNo(int pageNo) { + this.setPageNo(pageNo); + return this; + } + + public SchedulePlanRequest withPageSize(int pageSize) { + this.setPageSize(pageSize); + return this; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public String getSchedulePlanId() { + return schedulePlanId; + } + + public void setSchedulePlanId(String schedulePlanId) { + this.schedulePlanId = schedulePlanId; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/SchedulePlanSummaryModelVo.java b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanSummaryModelVo.java new file mode 100644 index 00000000..675a6d16 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanSummaryModelVo.java @@ -0,0 +1,102 @@ +package com.baidubce.services.bmr.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; + +public class SchedulePlanSummaryModelVo { + private String id; + private String name; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + createTime; + private Integer period; + private PeriodUnitType periodUnit; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + startTime; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + endTime; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + nextExecuteTime; + private Boolean isEnabled; + private Boolean isCopyable; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Integer getPeriod() { + return period; + } + + public void setPeriod(Integer period) { + this.period = period; + } + + public PeriodUnitType getPeriodUnit() { + return periodUnit; + } + + public void setPeriodUnit(PeriodUnitType periodUnit) { + this.periodUnit = periodUnit; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Date getNextExecuteTime() { + return nextExecuteTime; + } + + public void setNextExecuteTime(Date nextExecuteTime) { + this.nextExecuteTime = nextExecuteTime; + } + + public Boolean getEnabled() { + return isEnabled; + } + + public void setEnabled(Boolean enabled) { + isEnabled = enabled; + } + + public Boolean getCopyable() { + return isCopyable; + } + + public void setCopyable(Boolean copyable) { + isCopyable = copyable; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/SchedulePlanSummaryResponse.java b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanSummaryResponse.java new file mode 100644 index 00000000..954ee520 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SchedulePlanSummaryResponse.java @@ -0,0 +1,121 @@ +package com.baidubce.services.bmr.model; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; + +public class SchedulePlanSummaryResponse extends AbstractBceResponse { + private String code; + private String msg; + private String id; + private String name; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + createTime; + private Integer period; + private PeriodUnitType periodUnit; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + startTime; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + endTime; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + nextExecuteTime; + private Boolean isEnabled; + private Boolean isCopyable; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Integer getPeriod() { + return period; + } + + public void setPeriod(Integer period) { + this.period = period; + } + + public PeriodUnitType getPeriodUnit() { + return periodUnit; + } + + public void setPeriodUnit(PeriodUnitType periodUnit) { + this.periodUnit = periodUnit; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Date getNextExecuteTime() { + return nextExecuteTime; + } + + public void setNextExecuteTime(Date nextExecuteTime) { + this.nextExecuteTime = nextExecuteTime; + } + + public Boolean getEnabled() { + return isEnabled; + } + + public void setEnabled(Boolean enabled) { + isEnabled = enabled; + } + + public Boolean getCopyable() { + return isCopyable; + } + + public void setCopyable(Boolean copyable) { + isCopyable = copyable; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ScheduleResultResponse.java b/src/main/java/com/baidubce/services/bmr/model/ScheduleResultResponse.java new file mode 100644 index 00000000..5223e868 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ScheduleResultResponse.java @@ -0,0 +1,33 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +public class ScheduleResultResponse extends AbstractBceResponse { + private String code; + private String msg; + private Boolean success; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/SparkApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/SparkApplicationConfig.java new file mode 100644 index 00000000..38fb7cbd --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SparkApplicationConfig.java @@ -0,0 +1,41 @@ +package com.baidubce.services.bmr.model; + +/** + * Represent a SPARK applicaton. + *

+ * A SPARK application can be configured with property of version. + */ +public class SparkApplicationConfig extends ApplicationConfig { + + private static final String SPARK_APPLICATION = "spark"; + + public SparkApplicationConfig() { + this.setName(SPARK_APPLICATION); + } + + /** + * Configure the version of spark. + * The reference version is as follows: + *

+ * image type | image version | spark version supported + * hadoop | 1.0.0 | 1.6.0 + * hadoop | 1.1.0 | 2.1.0 + * hadoop | 1.2.0 | 2.1.0 + * hadoop | 2.0.0 | 2.3.2 + * + * @param version The version of Spark. + * + * @return SparkApplicationConfig + */ + public SparkApplicationConfig withVersion(String version) { + if (version.equalsIgnoreCase("2.1.0") || version.equalsIgnoreCase("2.3.2") || + version.equalsIgnoreCase("2.4.4")) { + this.setName("spark2"); + this.setVersion(version); + } else { + this.setVersion(version); + } + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bmr/model/SparkStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/SparkStepConfig.java new file mode 100644 index 00000000..742e6e5c --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SparkStepConfig.java @@ -0,0 +1,96 @@ +package com.baidubce.services.bmr.model; + +/** + * Represent configuration for a spark step. + *

+ * A spark step can be configured with name, actionOnFailure, jar, submitOptions and arguments. + * The essential options are mapper, input, output and actionOnFailure, + * and the optional ones are name and arguments. + */ +public class SparkStepConfig extends StepConfig { + private static final String SPARK_STEP = "Spark"; + private static final String JAR = "jar"; + private static final String SUBMIT_OPITONS = "submitOptions"; + private static final String ARGUMENTS = "arguments"; + + public SparkStepConfig() { + this.setType(SPARK_STEP); + } + + /** + * Configure the BOS path for step's .jar file. + * + * @param jar The BOS path for the step's .jar file. + * + * @return SparkStepConfig + */ + public SparkStepConfig withJar(String jar) { + this.addProperty(JAR, jar); + return this; + } + + /** + * Configure the submit options for the step. + * + * @param submitOptions The main class for the step. + * + * @return SparkStepConfig + */ + public SparkStepConfig withSubmitOptions(String submitOptions) { + this.addProperty(SUBMIT_OPITONS, submitOptions); + return this; + } + + /** + * Configure the arguments for the step. + * + * @param arguments The arguments for the step. + * + * @return SparkStepConfig + */ + public SparkStepConfig withArguments(String arguments) { + this.addProperty(ARGUMENTS, arguments); + return this; + } + + /** + * Configure the action on failure for the java step. + * This property is set to enum value: + * "Continue": continue to execute other steps. + * "TerminateCluster": terminate the cluster when this step fails. + * "CancelAndWait": cancel the other pending steps and set the cluster's status to WAITING. + * + * @param actionOnFailure The action on step's failure. + * + * @return SparkStepConfig + */ + public SparkStepConfig withActionOnFailure(String actionOnFailure) { + this.setActionOnFailure(actionOnFailure); + return this; + } + + /** + * Configure the name of the step. + * + * @param name The name of the step. + * + * @return SparkStepConfig + */ + public SparkStepConfig withName(String name) { + this.setName(name); + return this; + } + + /** + * Configure the additional file for the step. + * + * @param remote The remote file of the additional file. + * @param local The local file of the additional file. + * + * @return SparkStepConfig + */ + public SparkStepConfig withAdditionalFile(String remote, String local) { + this.addAdditionalFile(remote, local); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/Status.java b/src/main/java/com/baidubce/services/bmr/model/Status.java new file mode 100644 index 00000000..ac437d30 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/Status.java @@ -0,0 +1,66 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bmr.model; + +import java.util.Date; + +public class Status { + private String state; + private String code; + private String message; + + private Date creationDateTime; + private Date endDateTime; + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Date getCreationDateTime() { + return creationDateTime; + } + + public void setCreationDateTime(Date creationDateTime) { + this.creationDateTime = creationDateTime; + } + + public Date getEndDateTime() { + return endDateTime; + } + + public void setEndDateTime(Date endDateTime) { + this.endDateTime = endDateTime; + } + + +} diff --git a/src/main/java/com/baidubce/services/bmr/model/Step.java b/src/main/java/com/baidubce/services/bmr/model/Step.java index f8a54a88..648406e9 100644 --- a/src/main/java/com/baidubce/services/bmr/model/Step.java +++ b/src/main/java/com/baidubce/services/bmr/model/Step.java @@ -12,18 +12,27 @@ */ package com.baidubce.services.bmr.model; +import java.util.List; import java.util.Map; /** * Represent a BMR step. */ public class Step { + private String clusterId; + private String launcherJobId; + private StepStatus status; + private String logUri; + private String stderr; + private String stdout; + private String syslog; private String id; - private String actionOnFailure; + private String name; private String type; + private String actionOnFailure; + private List additionalFiles; + private Map properties; - private String name; - private StepStatus status; public String getId() { return id; @@ -72,4 +81,20 @@ public StepStatus getStatus() { public void setStatus(StepStatus status) { this.status = status; } + + public String getLogUri() { + return this.logUri; + } + + public void setLogUri(String logUri) { + this.logUri = logUri; + } + + public List getAdditionalFiles() { + return additionalFiles; + } + + public void setAdditionalFiles(List additionalFiles) { + this.additionalFiles = additionalFiles; + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/StepConfig.java b/src/main/java/com/baidubce/services/bmr/model/StepConfig.java index 5a89739f..6ab86df8 100644 --- a/src/main/java/com/baidubce/services/bmr/model/StepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/StepConfig.java @@ -13,6 +13,8 @@ package com.baidubce.services.bmr.model; import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; /** @@ -24,6 +26,32 @@ public class StepConfig { private String type; private Map properties; private String name; + private List additionalFiles; + + public StepConfig withActionOnFailure(String actionOnFailure) { + this.setActionOnFailure(actionOnFailure); + return this; + } + + public StepConfig withType(String type) { + this.setType(type); + return this; + } + + public StepConfig withProperties(Map properties) { + this.setProperties(properties); + return this; + } + + public StepConfig withName(String name) { + this.setName(name); + return this; + } + + public StepConfig withAdditionalFiles(List additionalFiles) { + this.setAdditionalFiles(additionalFiles); + return this; + } public String getActionOnFailure() { return actionOnFailure; @@ -63,4 +91,19 @@ public void addProperty(String key, String value) { } this.properties.put(key, value); } + + public List getAdditionalFiles() { + return additionalFiles; + } + + public void setAdditionalFiles(List additionalFiles) { + this.additionalFiles = additionalFiles; + } + + public void addAdditionalFile(String remote, String local) { + if (this.additionalFiles == null) { + this.additionalFiles = new LinkedList(); + } + this.additionalFiles.add(new AdditionalFile().withRemote(remote).withLocal(local)); + } } diff --git a/src/main/java/com/baidubce/services/bmr/model/StepStatus.java b/src/main/java/com/baidubce/services/bmr/model/StepStatus.java index 01a29f18..3d2d2ee5 100644 --- a/src/main/java/com/baidubce/services/bmr/model/StepStatus.java +++ b/src/main/java/com/baidubce/services/bmr/model/StepStatus.java @@ -22,6 +22,25 @@ public class StepStatus { private Date endDateTime; private Date startDateTime; private String state; + private String code; + private String message; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + public Date getCreateDateTime() { return createDateTime; diff --git a/src/main/java/com/baidubce/services/bmr/model/StreamingStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/StreamingStepConfig.java index d3b764d2..1a455fc8 100644 --- a/src/main/java/com/baidubce/services/bmr/model/StreamingStepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/StreamingStepConfig.java @@ -14,7 +14,7 @@ /** * Represent configuration for a streaming step. - * + *

* A streaming step can be configured with name, actionOnFailure, mapper, reducer, * input, output and arguments. * The essential options are mapper, input, output and actionOnFailure, @@ -37,6 +37,7 @@ public StreamingStepConfig() { * Configure the input for the step. * * @param input The input path for the step. + * * @return StreamingStepConfig */ public StreamingStepConfig withInput(String input) { @@ -48,6 +49,7 @@ public StreamingStepConfig withInput(String input) { * Configure the mapper program for the step. * * @param mapper The mapper program for the step. + * * @return StreamingStepConfig */ public StreamingStepConfig withMapper(String mapper) { @@ -59,6 +61,7 @@ public StreamingStepConfig withMapper(String mapper) { * Configure the output for the step. * * @param output The output path for the step. + * * @return StreamingStepConfig */ public StreamingStepConfig withOutput(String output) { @@ -70,6 +73,7 @@ public StreamingStepConfig withOutput(String output) { * Configure the arguments for the step. * * @param arguments The arguments for the step. + * * @return StreamingStepConfig */ public StreamingStepConfig withArguments(String arguments) { @@ -81,6 +85,7 @@ public StreamingStepConfig withArguments(String arguments) { * Configure the reducer program for the step. * * @param reducer The reducer program for the step. + * * @return StreamingStepConfig */ public StreamingStepConfig withReducer(String reducer) { @@ -92,6 +97,7 @@ public StreamingStepConfig withReducer(String reducer) { * Configure the name for the step. * * @param name The name for the step. + * * @return StreamingStepConfig */ public StreamingStepConfig withName(String name) { @@ -102,11 +108,12 @@ public StreamingStepConfig withName(String name) { /** * Configure the action on failure for the streaming step. * This property is set to enum value: - * "Continue": continue to execute other steps. - * "TerminateCluster": terminate the cluster when this step fails. - * "CancelAndWait": cancel the other pending steps and set the cluster's status to WAITING. + * "Continue": continue to execute other steps. + * "TerminateCluster": terminate the cluster when this step fails. + * "CancelAndWait": cancel the other pending steps and set the cluster's status to WAITING. * * @param actionOnFailure The action on step's failure. + * * @return StreamingStepConfig */ public StreamingStepConfig withActionOnFailure(String actionOnFailure) { diff --git a/src/main/java/com/baidubce/services/bmr/model/SubnetInfo.java b/src/main/java/com/baidubce/services/bmr/model/SubnetInfo.java new file mode 100644 index 00000000..2ad26b8d --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SubnetInfo.java @@ -0,0 +1,76 @@ +package com.baidubce.services.bmr.model; + +public class SubnetInfo { + private String name = ""; + private String subnetId = ""; + private String az = ""; + private String cidr = ""; + private String vpcId = ""; + private String accountId = ""; + private String subnetUuid = ""; + private String description = ""; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getAz() { + return az; + } + + public void setAz(String az) { + this.az = az; + } + + public String getCidr() { + return cidr; + } + + public void setCidr(String cidr) { + this.cidr = cidr; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getSubnetUuid() { + return subnetUuid; + } + + public void setSubnetUuid(String subnetUuid) { + this.subnetUuid = subnetUuid; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/Tag.java b/src/main/java/com/baidubce/services/bmr/model/Tag.java new file mode 100644 index 00000000..0383015f --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/Tag.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bmr.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class Tag { + private String tagKey; + private String tagValue; + + public String getTagKey() { + return tagKey; + } + + public void setTagKey(String tagKey) { + this.tagKey = tagKey; + } + + public String getTagValue() { + return tagValue; + } + + public void setTagValue(String tagValue) { + this.tagValue = tagValue; + } + + public Tag withTagKey(String tagKey) { + this.tagKey = tagKey; + return this; + } + + public Tag withTagValue(String tagValue) { + this.tagValue = tagValue; + return this; + } + + @Override + public String toString() { + return "Tag{" + + "tagKey='" + tagKey + '\'' + + ", tagValue='" + tagValue + '\'' + + " }"; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/TemplateClusterRequest.java b/src/main/java/com/baidubce/services/bmr/model/TemplateClusterRequest.java new file mode 100644 index 00000000..539b5406 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/TemplateClusterRequest.java @@ -0,0 +1,38 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * + * + */ +public class TemplateClusterRequest extends AbstractBceRequest { + + private String clusterId; + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + /** + * Configure the cluster ID for the request. + * + * @param clusterId The ID of BMR cluster. + * + * @return GetClusterRequest + */ + public TemplateClusterRequest withClusterId(String clusterId) { + this.setClusterId(clusterId); + return this; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/TemplateClusterResponse.java b/src/main/java/com/baidubce/services/bmr/model/TemplateClusterResponse.java new file mode 100644 index 00000000..9684dbc2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/TemplateClusterResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * + * + * + */ +public class TemplateClusterResponse extends AbstractBceResponse { + + private String templateId; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/TemplateIdRequest.java b/src/main/java/com/baidubce/services/bmr/model/TemplateIdRequest.java new file mode 100644 index 00000000..01d89c0a --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/TemplateIdRequest.java @@ -0,0 +1,40 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class TemplateIdRequest extends AbstractBceRequest { + private String templateId; + private String adminPassword; + + public String getAdminPassword() { + return adminPassword; + } + + public void setAdminPassword(String adminPassword) { + this.adminPassword = adminPassword; + } + + public TemplateIdRequest withTemplateId(String templateId) { + this.setTemplateId(templateId); + return this; + } + + public TemplateIdRequest withAdminPassword(String adminPassword) { + this.setAdminPassword(adminPassword); + return this; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/TemplateIdResponse.java b/src/main/java/com/baidubce/services/bmr/model/TemplateIdResponse.java new file mode 100644 index 00000000..79b5f56f --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/TemplateIdResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.model.AbstractBceResponse; + +public class TemplateIdResponse extends AbstractBceResponse { + private String templateId; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/TemplateInfoResponse.java b/src/main/java/com/baidubce/services/bmr/model/TemplateInfoResponse.java new file mode 100644 index 00000000..b46c3651 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/TemplateInfoResponse.java @@ -0,0 +1,246 @@ +package com.baidubce.services.bmr.model; + +import java.util.Date; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; + +public class TemplateInfoResponse extends AbstractBceResponse { + List steps; + private Boolean alarmEnabled; + private Boolean autoTerminate; + private String logUri; + private String payType; + private Reminder reminder; + private Boolean sendMessage; + private Boolean terminationProtected; + private String availabilityZone; + private VpcInfo vpc; + private SubnetInfo subnet; + private BmrSecurityGroupVo systemSecurityGroup; + private Boolean serviceHaEnabled; + private Boolean safeModeEnabled; + private String imageDescription; + private boolean isCopyable; + private boolean abandoned; + private List applications; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + creationDateTime; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") private Date + updateDateTime; + private String id; + private String name; + private boolean shared; + private String imageType; + private String imageVersion; + private List instanceGroups; + + public List getSteps() { + return steps; + } + + public void setSteps(List steps) { + this.steps = steps; + } + + public Boolean getAlarmEnabled() { + return alarmEnabled; + } + + public void setAlarmEnabled(Boolean alarmEnabled) { + this.alarmEnabled = alarmEnabled; + } + + public Boolean getAutoTerminate() { + return autoTerminate; + } + + public void setAutoTerminate(Boolean autoTerminate) { + this.autoTerminate = autoTerminate; + } + + public String getLogUri() { + return logUri; + } + + public void setLogUri(String logUri) { + this.logUri = logUri; + } + + public String getPayType() { + return payType; + } + + public void setPayType(String payType) { + this.payType = payType; + } + + public Reminder getReminder() { + return reminder; + } + + public void setReminder(Reminder reminder) { + this.reminder = reminder; + } + + public Boolean getSendMessage() { + return sendMessage; + } + + public void setSendMessage(Boolean sendMessage) { + this.sendMessage = sendMessage; + } + + public Boolean getTerminationProtected() { + return terminationProtected; + } + + public void setTerminationProtected(Boolean terminationProtected) { + this.terminationProtected = terminationProtected; + } + + public String getAvailabilityZone() { + return availabilityZone; + } + + public void setAvailabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + } + + public VpcInfo getVpc() { + return vpc; + } + + public void setVpc(VpcInfo vpc) { + this.vpc = vpc; + } + + public SubnetInfo getSubnet() { + return subnet; + } + + public void setSubnet(SubnetInfo subnet) { + this.subnet = subnet; + } + + public BmrSecurityGroupVo getSystemSecurityGroup() { + return systemSecurityGroup; + } + + public void setSystemSecurityGroup(BmrSecurityGroupVo systemSecurityGroup) { + this.systemSecurityGroup = systemSecurityGroup; + } + + public Boolean getServiceHaEnabled() { + return serviceHaEnabled; + } + + public void setServiceHaEnabled(Boolean serviceHaEnabled) { + this.serviceHaEnabled = serviceHaEnabled; + } + + public Boolean getSafeModeEnabled() { + return safeModeEnabled; + } + + public void setSafeModeEnabled(Boolean safeModeEnabled) { + this.safeModeEnabled = safeModeEnabled; + } + + public String getImageDescription() { + return imageDescription; + } + + public void setImageDescription(String imageDescription) { + this.imageDescription = imageDescription; + } + + public boolean isCopyable() { + return isCopyable; + } + + public void setCopyable(boolean copyable) { + isCopyable = copyable; + } + + public boolean isAbandoned() { + return abandoned; + } + + public void setAbandoned(boolean abandoned) { + this.abandoned = abandoned; + } + + public List getApplications() { + return applications; + } + + public void setApplications(List applications) { + this.applications = applications; + } + + public Date getCreationDateTime() { + return creationDateTime; + } + + public void setCreationDateTime(Date creationDateTime) { + this.creationDateTime = creationDateTime; + } + + public Date getUpdateDateTime() { + return updateDateTime; + } + + public void setUpdateDateTime(Date updateDateTime) { + this.updateDateTime = updateDateTime; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isShared() { + return shared; + } + + public void setShared(boolean shared) { + this.shared = shared; + } + + public String getImageType() { + return imageType; + } + + public void setImageType(String imageType) { + this.imageType = imageType; + } + + public String getImageVersion() { + return imageVersion; + } + + public void setImageVersion(String imageVersion) { + this.imageVersion = imageVersion; + } + + public List getInstanceGroups() { + return instanceGroups; + } + + public void setInstanceGroups(List instanceGroups) { + this.instanceGroups = instanceGroups; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/TemplateListRequest.java b/src/main/java/com/baidubce/services/bmr/model/TemplateListRequest.java new file mode 100644 index 00000000..ec085de8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/TemplateListRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class TemplateListRequest extends AbstractBceRequest { + private String username; + + public TemplateListRequest withUsername(String username) { + this.setUsername(username); + return this; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/TemplateListResponse.java b/src/main/java/com/baidubce/services/bmr/model/TemplateListResponse.java new file mode 100644 index 00000000..85e8a596 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/TemplateListResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.bmr.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +public class TemplateListResponse extends AbstractBceResponse { + private List result; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/TerminateClusterRequest.java b/src/main/java/com/baidubce/services/bmr/model/TerminateClusterRequest.java index abcb8fd2..8319539b 100644 --- a/src/main/java/com/baidubce/services/bmr/model/TerminateClusterRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/TerminateClusterRequest.java @@ -33,6 +33,7 @@ public void setClusterId(String clusterId) { * Configure the cluster ID for the request. * * @param clusterId The ID of cluster that to be terminated. + * * @return TerminateClusterRequest */ public TerminateClusterRequest withClusterId(String clusterId) { @@ -44,6 +45,7 @@ public TerminateClusterRequest withClusterId(String clusterId) { * Configure request credential for the request. * * @param credentials a valid instance of BceCredentials. + * * @return TerminateClusterRequest */ public TerminateClusterRequest withRequestCredentials(BceCredentials credentials) { diff --git a/src/main/java/com/baidubce/services/bmr/model/UpdateSchedulePlanRequest.java b/src/main/java/com/baidubce/services/bmr/model/UpdateSchedulePlanRequest.java new file mode 100644 index 00000000..c0ba21e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/UpdateSchedulePlanRequest.java @@ -0,0 +1,58 @@ +package com.baidubce.services.bmr.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class UpdateSchedulePlanRequest extends AbstractBceRequest { + private String schedulePlanId; // 定时任务id + + private List steps; // 定时任务步骤 + + private Schedule schedule; // 定时任务调度策略 + + public UpdateSchedulePlanRequest withSchedulePlanId(String schedulePlanId) { + this.setSchedulePlanId(schedulePlanId); + return this; + } + + public UpdateSchedulePlanRequest withSteps(List steps) { + this.setSteps(steps); + return this; + } + + public UpdateSchedulePlanRequest withSchedule(Schedule schedule) { + this.setSchedule(schedule); + return this; + } + + public String getSchedulePlanId() { + return schedulePlanId; + } + + public void setSchedulePlanId(String schedulePlanId) { + this.schedulePlanId = schedulePlanId; + } + + public List getSteps() { + return steps; + } + + public void setSteps(List steps) { + this.steps = steps; + } + + public Schedule getSchedule() { + return schedule; + } + + public void setSchedule(Schedule schedule) { + this.schedule = schedule; + } + + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/VpcInfo.java b/src/main/java/com/baidubce/services/bmr/model/VpcInfo.java new file mode 100644 index 00000000..da8475e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/VpcInfo.java @@ -0,0 +1,49 @@ +package com.baidubce.services.bmr.model; + +public class VpcInfo { + private String vpcId = ""; + private String name = ""; + private String cidr = ""; + private String description = ""; + private boolean defaultVpc = false; + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCidr() { + return cidr; + } + + public void setCidr(String cidr) { + this.cidr = cidr; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isDefaultVpc() { + return defaultVpc; + } + + public void setDefaultVpc(boolean defaultVpc) { + this.defaultVpc = defaultVpc; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/YarnApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/YarnApplicationConfig.java new file mode 100644 index 00000000..4879e65e --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/YarnApplicationConfig.java @@ -0,0 +1,31 @@ +package com.baidubce.services.bmr.model; + +/** + * Represent a Yarn application. + *

+ * A Yarn application can be configured with property of version. + */ +public class YarnApplicationConfig extends ApplicationConfig { + private static final String YARN_APPLICATION = "yarn"; + + public YarnApplicationConfig() { + this.setName(YARN_APPLICATION); + } + + /** + * Configure the version of Yarn. + * The reference version is as follows: + *

+ * image type | image version | yarn version supported + * hadoop | 1.0.0/1.1.0/1.2.0 | 2.7.1 + * hadoop | 2.0.0 | 3.1.1 + * + * @param version The version of YARN. + * + * @return YARNApplicationConfig + */ + public YarnApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ZeppelinApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/ZeppelinApplicationConfig.java new file mode 100644 index 00000000..488f2c4b --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ZeppelinApplicationConfig.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bmr.model; + +public class ZeppelinApplicationConfig extends ApplicationConfig{ + + private static final String ZEPPELIN_APPLICATION = "zeppelin"; + + + public ZeppelinApplicationConfig() { + this.setName(ZEPPELIN_APPLICATION); + } + + + /** + * Configure the version of zeppelin. + * The reference version is as follows: + *

+ * image type | image version | zeppelin version supported + * hadoop | 2.0.0 | 0.8.0 + * @param version The version of zeppelin. + * + * @return ZeppelinApplicationConfig + */ + public ZeppelinApplicationConfig withVersion(String version){ + this .setVersion(version); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/model/ZookeeperApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/ZookeeperApplicationConfig.java new file mode 100644 index 00000000..2bd8fb0a --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ZookeeperApplicationConfig.java @@ -0,0 +1,30 @@ +package com.baidubce.services.bmr.model; + +/** + * Represent a Zookeeper application. + *

+ * A Zookeeper application can be configured with property of version. + */ +public class ZookeeperApplicationConfig extends ApplicationConfig { + private static final String ZOOKEEPER_APPLICATION = "zookeeper"; + + public ZookeeperApplicationConfig() { + this.setName(ZOOKEEPER_APPLICATION); + } + + /** + * Configure the version of Zookeeper. + * The reference version is as follows: + *

+ * image type | image version | zookeeper version supported + * hadoop | 1.0.0/1.1.0/1.2.0/2.0.0 | 3.4.6 + * + * @param version The version of Zookeeper. + * + * @return ZookeeperApplicationConfig + */ + public ZookeeperApplicationConfig withVersion(String version) { + this.setVersion(version); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/BosClient.java b/src/main/java/com/baidubce/services/bos/BosClient.java index 417fc942..e8fd77df 100644 --- a/src/main/java/com/baidubce/services/bos/BosClient.java +++ b/src/main/java/com/baidubce/services/bos/BosClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Baidu, Inc. + * Copyright 2014-2020 Baidu, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -30,9 +30,12 @@ import com.baidubce.model.AbstractBceRequest; import com.baidubce.model.User; import com.baidubce.services.bos.model.*; + +import com.baidubce.services.lss.model.Bos; import com.baidubce.util.*; import com.baidubce.util.HttpUtils; import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.collect.Lists; import org.apache.commons.codec.binary.Base64; @@ -44,12 +47,25 @@ import java.io.*; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; +import java.net.URLEncoder; import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import static com.google.common.base.Preconditions.checkNotNull; @@ -62,7 +78,7 @@ public class BosClient extends AbstractBceClient { /** * Responsible for handling httpResponses from all Bos service calls. */ - private static final HttpResponseHandler[] bos_handlers = new HttpResponseHandler[] { + private static final HttpResponseHandler[] bos_handlers = new HttpResponseHandler[]{ new BceMetadataResponseHandler(), new BosMetadataResponseHandler(), new BceErrorResponseHandler(), new BosObjectResponseHandler(), new BceJsonResponseHandler()}; @@ -74,7 +90,42 @@ public class BosClient extends AbstractBceClient { /** * Infrequent access BOS storage class */ - public static final String STORAGE_CLASS_STANDARD_IA = "STANDARD_IA"; + public static final String STORAGE_CLASS_STANDARD_IA = "STANDARD_IA"; + + /** + * Cold access BOS storage class + */ + public static final String STORAGE_CLASS_COLD = "COLD"; + + /** + * Archive access BOS storage class + */ + public static final String STORAGE_CLASS_ARCHIVE = "ARCHIVE"; + + /** + * Standard restore tier + */ + public static final String RESTORE_TIER_STANDARD = "Standard"; + + /** + * Expedited restore tier + */ + public static final String RESTORE_TIER_EXPEDITED = "Expedited"; + + /** + * LowCost restore tier + */ + public static final String RESTORE_TIER_LOWCOST = "LowCost"; + + /** + * Generate signature with specified headers + */ + private static final String[] HEADERS_TO_SIGN = {Headers.HOST}; + + /** + * the part size when upload super object file + */ + private static final long CHUNK_SIZE = 1024 * 1024 * 5L; /** * Constructs a new client to invoke service methods on Bos. @@ -90,7 +141,7 @@ public BosClient() { * connects to Bos (e.g. proxy settings, retry counts, etc). */ public BosClient(BosClientConfiguration clientConfiguration) { - super(clientConfiguration, bos_handlers, true); + super(clientConfiguration, bos_handlers, clientConfiguration.isEnableHttpAsyncPut()); } /** @@ -156,7 +207,7 @@ public ListBucketsResponse listBuckets(ListBucketsRequest request) { * Creates a new Bos bucket with the specified name. * * @param bucketName The name of the bucket to create. - * All buckets in Bos share a single namespace; ensure the bucket is given a unique name. + * All buckets in Bos share a single namespace; ensure the bucket is given a unique name. * @return The newly created bucket. */ public CreateBucketResponse createBucket(String bucketName) { @@ -174,6 +225,9 @@ public CreateBucketResponse createBucket(CreateBucketRequest request) { InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); this.setZeroContentLength(internalRequest); + if (request.getBucketTags() != null) { + internalRequest.addHeader(Headers.BCE_TAG_LIST, request.getBucketTags()); + } BosResponse response = this.invokeHttpClient(internalRequest, BosResponse.class); CreateBucketResponse result = new CreateBucketResponse(); result.setName(request.getBucketName()); @@ -194,7 +248,7 @@ public CreateBucketResponse createBucket(CreateBucketRequest request) { * * @param bucketName The name of the bucket to check. * @return The value true if the specified bucket exists in Bos; - * the value false if there is no bucket in Bos with that name. + * the value false if there is no bucket in Bos with that name. */ public boolean doesBucketExist(String bucketName) { return this.doesBucketExist(new DoesBucketExistRequest(bucketName)); @@ -213,7 +267,7 @@ public boolean doesBucketExist(String bucketName) { * * @param request The request object containing all options for checking a Bos bucket. * @return The value true if the specified bucket exists in Bos; - * the value false if there is no bucket in Bos with that name. + * the value false if there is no bucket in Bos with that name. */ public boolean doesBucketExist(DoesBucketExistRequest request) { checkNotNull(request, "request should not be null."); @@ -310,6 +364,85 @@ public GetBucketLocationResponse getBucketLocation(GetBucketLocationRequest requ return response; } + /** + * Sets the default storageClass for the specified Bos bucket. + * + *

+ * A json style of bucket storageClass + * provides a storageClass to configure an bucket. + * + * @param bucketName The name of the bucket whose storageClass is being set. + * @param storageClass The pre-configured storageClass to set for the specified bucket. + */ + public void putBucketStorageClass(String bucketName, String storageClass) { + this.putBucketStorageClass(new PutBucketStorageClassRequest(bucketName, storageClass)); + } + + /** + * Sets the default storageClass for the specified Bos bucket. + * + *

+ * A json style of bucket storageClass + * provides a storageClass to configure an bucket. + * + * @param request The request containing the name of the bucket and the default storageClass. + */ + public void putBucketStorageClass(PutBucketStorageClassRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("storageClass", null); + + if (request.getStorageClass() == "") { + request.setStorageClass(STORAGE_CLASS_STANDARD); + } + byte[] json = null; + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("storageClass", request.getStorageClass()); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + + this.invokeHttpClient(internalRequest, BosResponse.class); + } + + /** + * Gets the default storageClass for the specified Bos bucket. + * + * @param bucketName The bucket whose storageClass to to get. + */ + public GetBucketStorageClassResponse getBucketStorageClass(String bucketName) { + return this.getBucketStorageClass(new GetBucketStorageClassRequest(bucketName)); + } + + /** + * Gets the default storageClass for the specified Bos bucket. + * + * @param request The request object containing the specified bucket to get bucket logging. + */ + public GetBucketStorageClassResponse getBucketStorageClass(GetBucketStorageClassRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("storageClass", null); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + GetBucketStorageClassResponse response = + this.invokeHttpClient(internalRequest, GetBucketStorageClassResponse.class); + return response; + } /** * Sets the json style of bucket acl for the specified Bos bucket using one of @@ -321,7 +454,7 @@ public GetBucketLocationResponse getBucketLocation(GetBucketLocationRequest requ * access control policies. * * @param bucketName The name of the bucket whose ACL is being set. - * @param jsonAcl The pre-configured CannedAccessControlLists to set for the specified bucket. + * @param jsonAcl The pre-configured CannedAccessControlLists to set for the specified bucket. */ public void setBucketAcl(String bucketName, String jsonAcl) { this.setBucketAcl(new SetBucketAclRequest(bucketName, jsonAcl)); @@ -337,7 +470,7 @@ public void setBucketAcl(String bucketName, String jsonAcl) { * access control policies. * * @param bucketName The name of the bucket whose ACL is being set. - * @param acl The pre-configured CannedAccessControlLists to set for the specified bucket. + * @param acl The pre-configured CannedAccessControlLists to set for the specified bucket. */ public void setBucketAcl(String bucketName, CannedAccessControlList acl) { this.setBucketAcl(new SetBucketAclRequest(bucketName, acl)); @@ -367,6 +500,7 @@ public void setBucketAcl(SetBucketAclRequest request) { jsonGenerator.writeArrayFieldStart("accessControlList"); for (Grant grant : grants) { jsonGenerator.writeStartObject(); + // set grant jsonGenerator.writeArrayFieldStart("grantee"); for (Grantee grantee : grant.getGrantee()) { jsonGenerator.writeStartObject(); @@ -374,11 +508,90 @@ public void setBucketAcl(SetBucketAclRequest request) { jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); + // set permission jsonGenerator.writeArrayFieldStart("permission"); for (Permission permission : grant.getPermission()) { jsonGenerator.writeString(permission.toString()); } jsonGenerator.writeEndArray(); + // set resource + if (grant.getResource() != null) { + jsonGenerator.writeArrayFieldStart("resource"); + for (String resource : grant.getResource()) { + jsonGenerator.writeString(resource); + } + + jsonGenerator.writeEndArray(); + } + // set notResource + if (grant.getNotResource() != null) { + jsonGenerator.writeArrayFieldStart("notResource"); + for (String notResource : grant.getNotResource()) { + jsonGenerator.writeString(notResource); + } + + jsonGenerator.writeEndArray(); + } + // set condition + if (grant.getCondition() != null && grant.getCondition().getReferer() != null) { + if (grant.getCondition().getReferer().getStringLike() != null + || grant.getCondition().getReferer().getStringEquals() != null) { + jsonGenerator.writeObjectFieldStart("condition"); + jsonGenerator.writeObjectFieldStart("referer"); + // set refer stringLike + if (grant.getCondition().getReferer().getStringLike() != null) { + jsonGenerator.writeArrayFieldStart("stringLike"); + for (String stringLike : grant.getCondition().getReferer().getStringLike()) { + jsonGenerator.writeString(stringLike); + } + jsonGenerator.writeEndArray(); + } + // set refer stringEquals + if (grant.getCondition().getReferer().getStringEquals() != null) { + jsonGenerator.writeArrayFieldStart("stringEquals"); + for (String stringEquals : grant.getCondition().getReferer().getStringEquals()) { + jsonGenerator.writeString(stringEquals); + } + jsonGenerator.writeEndArray(); + } + jsonGenerator.writeEndObject(); + + if (grant.getCondition().getIpAddress() != null) { + jsonGenerator.writeArrayFieldStart("ipAddress"); + for (String ipAddress : grant.getCondition().getIpAddress()) { + jsonGenerator.writeString(ipAddress); + } + jsonGenerator.writeEndArray(); + } + jsonGenerator.writeBooleanField("secureTransport", + grant.getCondition().isSecureTransport()); + jsonGenerator.writeEndObject(); + } + } + if (grant.getCondition() != null && grant.getCondition().getReferer() == null + && grant.getCondition().getIpAddress() != null) { + jsonGenerator.writeObjectFieldStart("condition"); + jsonGenerator.writeArrayFieldStart("ipAddress"); + for (String ipAddress : grant.getCondition().getIpAddress()) { + jsonGenerator.writeString(ipAddress); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeBooleanField("secureTransport", + grant.getCondition().isSecureTransport()); + jsonGenerator.writeEndObject(); + } + if (grant.getCondition() != null && grant.getCondition().getReferer() == null + && grant.getCondition().getIpAddress() == null) { + jsonGenerator.writeObjectFieldStart("condition"); + jsonGenerator.writeBooleanField("secureTransport", + grant.getCondition().isSecureTransport()); + jsonGenerator.writeEndObject(); + } + + // set effect + if (grant.getEffect() != null) { + jsonGenerator.writeStringField("effect", grant.getEffect()); + } jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); @@ -393,7 +606,7 @@ public void setBucketAcl(SetBucketAclRequest request) { throw new BceClientException("Fail to get UTF-8 bytes", e); } internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); - internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json"); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); internalRequest.setContent(RestartableInputStream.wrap(json)); } else if (request.getJsonAcl() != null) { byte[] json = null; @@ -402,1440 +615,3541 @@ public void setBucketAcl(SetBucketAclRequest request) { } catch (UnsupportedEncodingException e) { throw new BceClientException("Fail to get UTF-8 bytes", e); } - internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); - internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json"); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); internalRequest.setContent(RestartableInputStream.wrap(json)); } else { checkNotNull(null, "request.acl should not be null."); } - this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Deletes the specified bucket. All objects in the bucket must be deleted before the bucket itself - * can be deleted. - * - *

- * Only the owner of a bucket can delete it, regardless of the bucket's access control policy. + * Sets the Logging for the specified Bos bucket. * - * @param bucketName The name of the bucket to delete. + * @param request The request object containing the Logging to set into specified bucket. */ - public void deleteBucket(String bucketName) { - this.deleteBucket(new DeleteBucketRequest(bucketName)); + public void setBucketLogging(SetBucketLoggingRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("logging", null); + + if (request.getJsonPutBucketLogging() != null) { + byte[] json = null; + try { + json = request.getJsonPutBucketLogging().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else { + byte[] json = null; + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("targetBucket", request.getTargetBucket()); + if (request.getTargetPrefix() != null) { + jsonGenerator.writeStringField("targetPrefix", request.getTargetPrefix()); + } + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Deletes the specified bucket. All objects in the bucket must be deleted before the bucket itself - * can be deleted. + * Gets the Logging for the specified Bos bucket. * - *

- * Only the owner of a bucket can delete it, regardless of the bucket's access control policy. - * - * @param request The request object containing all options for deleting a Bos bucket. + * @param request The request object containing the specified bucket to get bucket logging. */ - public void deleteBucket(DeleteBucketRequest request) { + public GetBucketLoggingResponse getBucketLogging(GetBucketLoggingRequest request) { checkNotNull(request, "request should not be null."); - this.invokeHttpClient(this.createRequest(request, HttpMethodName.DELETE), BosResponse.class); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("logging", null); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + GetBucketLoggingResponse response = this.invokeHttpClient(internalRequest, GetBucketLoggingResponse.class); + return response; } /** - * Returns a pre-signed URL for accessing a Bos resource. + * Delete the Logging for the specified Bos bucket. * - * @param bucketName The name of the bucket containing the desired object. - * @param key The key in the specified bucket under which the desired object is stored. - * @param expirationInSeconds The expiration after which the returned pre-signed URL will expire. - * @return A pre-signed URL which expires at the specified time, and can be - * used to allow anyone to download the specified object from Bos, - * without exposing the owner's Bce secret access key. + * @param request The request object containing the specified bucket to delete bucket logging. */ - public URL generatePresignedUrl(String bucketName, String key, int expirationInSeconds) { - return this.generatePresignedUrl(bucketName, key, expirationInSeconds, HttpMethodName.GET); + public void deleteBucketLogging(DeleteBucketLoggingRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter("logging", null); + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Returns a pre-signed URL for accessing a Bos resource. + * Sets the CORS for the specified Bos bucket. * - * @param bucketName The name of the bucket containing the desired object. - * @param key The key in the specified bucket under which the desired object is stored. - * @param expirationInSeconds The expiration after which the returned pre-signed URL will expire. - * @param method The HTTP method verb to use for this URL - * @return A pre-signed URL which expires at the specified time, and can be - * used to allow anyone to download the specified object from Bos, - * without exposing the owner's Bce secret access key. + * @param request The request object containing the CORS to set into specified bucket. */ - public URL generatePresignedUrl(String bucketName, String key, int expirationInSeconds, HttpMethodName method) { - GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, key, method); - request.setExpiration(expirationInSeconds); + public void setBucketCors(SetBucketCorsRequest request) { - return this.generatePresignedUrl(request); - } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("cors", null); + if (request.getJsonBucketCors() != null) { + byte[] json = null; + try { + json = request.getJsonBucketCors().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else if (request.getCorsConfigurationsList() != null) { + byte[] json = null; + List corsConfigurations = request.getCorsConfigurationsList(); + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("corsConfiguration"); + for (CorsConfiguration corsConfiguration : corsConfigurations) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("allowedOrigins"); + for (String allowOrigin : corsConfiguration.getAllowedOrigins()) { + jsonGenerator.writeString(allowOrigin); + } + jsonGenerator.writeEndArray(); - /** - * Returns a pre-signed URL for accessing a Bos resource. - * - * @param request The request object containing all the options for generating a - * pre-signed URL (bucket name, key, expiration date, etc). - * @return A pre-signed URL which expires at the specified time, and can be - * used to allow anyone to download the specified object from Bos, - * without exposing the owner's Bce secret access key. - */ - public URL generatePresignedUrl(GeneratePresignedUrlRequest request) { - checkNotNull(request, "The request parameter must be specified when generating a pre-signed URL"); + jsonGenerator.writeArrayFieldStart("allowedMethods"); + for (AllowedMethods allowedMethod : corsConfiguration.getAllowedMethods()) { + jsonGenerator.writeString(allowedMethod.toString()); + } + jsonGenerator.writeEndArray(); - HttpMethodName httpMethod = HttpMethodName.valueOf(request.getMethod().toString()); + jsonGenerator.writeArrayFieldStart("allowedHeaders"); + if (corsConfiguration.getAllowedHeaders() != null) { + for (String allowHead : corsConfiguration.getAllowedHeaders()) { + jsonGenerator.writeString(allowHead); + } + } - // If the key starts with a slash character itself, the following method - // will actually add another slash before the resource path to prevent - // the HttpClient mistakenly treating the slash as a path delimiter. - // For presigned request, we need to remember to remove this extra slash - // before generating the URL. - InternalRequest internalRequest = new InternalRequest(httpMethod, HttpUtils - .appendUri(this.getEndpoint(), URL_PREFIX, request.getBucketName(), request.getKey())); - internalRequest.setCredentials(request.getRequestCredentials()); - SignOptions options = new SignOptions(); - options.setExpirationInSeconds(request.getExpiration()); + jsonGenerator.writeEndArray(); - for (Entry entry : request.getRequestHeaders().entrySet()) { - if (entry.getValue() == null) { - internalRequest.addHeader(entry.getKey(), ""); - } else { - internalRequest.addHeader(entry.getKey(), entry.getValue()); + jsonGenerator.writeArrayFieldStart("allowedExposeHeaders"); + if (corsConfiguration.getAllowedExposeHeaders() != null) { + for (String allowedExposeHeader : corsConfiguration.getAllowedExposeHeaders()) { + jsonGenerator.writeString(allowedExposeHeader); + } + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeNumberField("maxAgeSeconds", corsConfiguration.getMaxAgeSeconds()); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); } - } - - for (Entry entry : request.getRequestParameters().entrySet()) { - if (entry.getValue() == null) { - internalRequest.addParameter(entry.getKey(), ""); - } else { - internalRequest.addParameter(entry.getKey(), entry.getValue()); + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else { + checkNotNull(request, "request should not be null."); } - - if (request.getContentType() != null) { - internalRequest.addHeader(Headers.CONTENT_TYPE, request.getContentType()); - } - - if (request.getContentMd5() != null) { - internalRequest.addHeader(Headers.CONTENT_MD5, request.getContentMd5()); - } - - addResponseHeaderParameters(internalRequest, request.getResponseHeaders()); - - Signer signer = new BceV1Signer(); - signer.sign(internalRequest, this.config.getCredentials(), options); - - // Remove the leading slash (if any) in the resource-path - return convertRequestToUrl(internalRequest); + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Returns ListObjectsResponse containing a list of summary information about the objects in the specified buckets. - * List results are always returned in lexicographic (alphabetical) order. + * Gets the CORS for the specified Bos bucket. * - * @param bucketName The name of the Bos bucket to list. - * @return ListObjectsResponse containing a listing of the objects in the specified bucket, along with any - * other associated information, such as common prefixes (if a delimiter was specified), the original - * request parameters, etc. + * @param request The request object containing the specified bucket to get bucket CORS. */ - public ListObjectsResponse listObjects(String bucketName) { - return this.listObjects(new ListObjectsRequest(bucketName)); + public GetBucketCorsResponse getBucketCros(GetBucketCorsRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("cors", null); + GetBucketCorsResponse response = this.invokeHttpClient(internalRequest, GetBucketCorsResponse.class); + return response; } /** - * Returns ListObjectsResponse containing a list of summary information about the objects in the specified buckets. - * List results are always returned in lexicographic (alphabetical) order. + * Delete the CORS for the specified Bos bucket. * - * @param bucketName The name of the Bos bucket to list. - * @param prefix An optional parameter restricting the response to keys beginning with the specified prefix. - * Use prefixes to separate a bucket into different sets of keys, similar to how a file system - * organizes files into directories. - * @return ListObjectsResponse containing a listing of the objects in the specified bucket, along with any - * other associated information, such as common prefixes (if a delimiter was specified), the original - * request parameters, etc. + * @param request The request object containing the specified bucket to delete bucket CORS. */ - public ListObjectsResponse listObjects(String bucketName, String prefix) { - return this.listObjects(new ListObjectsRequest(bucketName, prefix)); + public void deleteBucketCors(DeleteBucketCorsRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter("cors", null); + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Returns ListObjectsResponse containing a list of summary information about the objects in the specified buckets. - * List results are always returned in lexicographic (alphabetical) order. + * Sets the replication for the specified Bos bucket with specified replicationId. * - * @param request The request object containing all options for listing the objects in a specified bucket. - * @return ListObjectsResponse containing a listing of the objects in the specified bucket, along with any - * other associated information, such as common prefixes (if a delimiter was specified), the original - * request parameters, etc. + * @param request */ - public ListObjectsResponse listObjects(ListObjectsRequest request) { - checkNotNull(request, "request should not be null."); - - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); - if (request.getPrefix() != null) { - internalRequest.addParameter("prefix", request.getPrefix()); - } - if (request.getMarker() != null) { - internalRequest.addParameter("marker", request.getMarker()); - } - if (request.getDelimiter() != null) { - internalRequest.addParameter("delimiter", request.getDelimiter()); - } - if (request.getMaxKeys() >= 0) { - internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); - } + public void setBucketReplication(SetBucketReplicationRequest request) { + checkNotNull(request.getId(), "the replication id should not be null."); + checkNotNull(request.getStatus(), "the replication status should not be null"); + checkNotNull(request.getResource(), "the replication source should not be null"); + checkNotNull(request.getDestination(), "the replication destination should not be null"); + checkNotNull(request.getDestination().getBucket(), "the replication dest bucket shoule not be null"); + checkNotNull(request.getReplicateDeletes(), "the replication deletes should not be null"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("replication", null); + internalRequest.addParameter("id", request.getId()); + if (request.getJsonBucketReplication() != null) { + byte[] json = null; + try { + json = request.getJsonBucketReplication().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else if (request.getId() != null) { + byte[] json = null; + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + // set status + jsonGenerator.writeStringField("status", request.getStatus()); + // set resource + jsonGenerator.writeArrayFieldStart("resource"); + for (String resource : request.getResource()) { + jsonGenerator.writeString(resource); + } + jsonGenerator.writeEndArray(); + // set destination + jsonGenerator.writeObjectFieldStart("destination"); + jsonGenerator.writeStringField("bucket", request.getDestination().getBucket()); + if (request.getDestination().getStorageClass() != null) { + jsonGenerator.writeStringField("storageClass", request.getDestination().getStorageClass()); + } + jsonGenerator.writeEndObject(); + // set replicateHistory + if (request.getReplicateHistory() != null) { + jsonGenerator.writeObjectFieldStart("replicateHistory"); + if (request.getReplicateHistory().getStorageClass() != null) { + jsonGenerator.writeObjectField("storageClass", request.getReplicateHistory().getStorageClass()); + } + jsonGenerator.writeEndObject(); + } - ListObjectsResponse response = this.invokeHttpClient(internalRequest, ListObjectsResponse.class); + // set replicateDeletes + if (request.getReplicateDeletes() != null) { + jsonGenerator.writeStringField("replicateDeletes", request.getReplicateDeletes()); + } + // set id + jsonGenerator.writeStringField("id", request.getId()); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); - response.setBucketName(request.getBucketName()); - List contents = response.getContents(); - for (BosObjectSummary object : contents) { - object.setBucketName(request.getBucketName()); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else { + checkNotNull(request, "request should not be null."); } + this.invokeHttpClient(internalRequest, BosResponse.class); + } + /** + * Gets the replication for the specified Bos bucket with specified replicationId. + */ + public GetBucketReplicationResponse getBucketReplication(GetBucketReplicationRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("replication", null); + internalRequest.addParameter("id", request.getId()); + GetBucketReplicationResponse response = this.invokeHttpClient(internalRequest, + GetBucketReplicationResponse.class); return response; } /** - * Provides an easy way to continue a truncated object listing and retrieve the next page of results. - * - * @param previousResponse The previous truncated ListObjectsResponse. If a non-truncated - * ListObjectsResponse is passed in, an empty ListObjectsResponse - * is returned without ever contacting Bos. - * @return The next set of ListObjectsResponse results, beginning immediately - * after the last result in the specified previous ListObjectsResponse. + * Deletes the replication for the specified Bos bucket with specified replicationId. */ - public ListObjectsResponse listNextBatchOfObjects(ListObjectsResponse previousResponse) { - checkNotNull(previousResponse, "previousResponse should not be null."); - - if (!previousResponse.isTruncated()) { - ListObjectsResponse emptyResponse = new ListObjectsResponse(); - emptyResponse.setBucketName(previousResponse.getBucketName()); - emptyResponse.setDelimiter(previousResponse.getDelimiter()); - emptyResponse.setMarker(previousResponse.getNextMarker()); - emptyResponse.setMaxKeys(previousResponse.getMaxKeys()); - emptyResponse.setPrefix(previousResponse.getPrefix()); - emptyResponse.setTruncated(false); - return emptyResponse; - } + public void deleteBucketReplication(DeleteBucketReplicationRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getId(), "replication id should not be null"); - return this.listObjects(new ListObjectsRequest(previousResponse.getBucketName()) - .withPrefix(previousResponse.getPrefix()) - .withMarker(previousResponse.getNextMarker()) - .withDelimiter(previousResponse.getDelimiter()) - .withMaxKeys(previousResponse.getMaxKeys())); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter("replication", null); + internalRequest.addParameter("id", request.getId()); + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Gets the object stored in Bos under the specified bucket and key. - * - * @param bucketName The name of the bucket containing the desired object. - * @param key The key under which the desired object is stored. - * @return The object stored in Bos in the specified bucket and key. + * Gets the bucket replication progress for the specified Bos bucket with specified replicationId */ - public BosObject getObject(String bucketName, String key) { - return this.getObject(new GetObjectRequest(bucketName, key)); + public BucketReplicationProgress getBucketReplicationProgress(GetBucketReplicationProgressRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("replicationProgress", null); + internalRequest.addParameter("id", request.getId()); + BucketReplicationProgress response = this.invokeHttpClient(internalRequest, BucketReplicationProgress.class); + return response; } /** - * Gets the object metadata for the object stored in Bos under the specified bucket and key, - * and saves the object contents to the specified file. - * Returns null if the specified constraints weren't met. - * - * @param bucketName The name of the bucket containing the desired object. - * @param key The key under which the desired object is stored. - * @param destinationFile Indicates the file (which might already exist) - * where to save the object content being downloading from Bos. - * @return All Bos object metadata for the specified object. - * Returns null if constraints were specified but not met. + * List all bucket replication */ - public ObjectMetadata getObject(String bucketName, String key, File destinationFile) { - return this.getObject(new GetObjectRequest(bucketName, key), destinationFile); + public ListBucketReplicationResponse listBucketReplication(ListBucketReplicationRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("replication", null); + internalRequest.addParameter("list", null); + ListBucketReplicationResponse response = this.invokeHttpClient(internalRequest, + ListBucketReplicationResponse.class); + return response; } /** - * Gets the object stored in Bos under the specified bucket and key. + * Sets the Lifecycle for the specified Bos bucket. * - * @param request The request object containing all the options on how to download the object. - * @return The object stored in Bos in the specified bucket and key. + * @param request The request object containing the Lifecycle to set into specified bucket. */ - public BosObject getObject(GetObjectRequest request) { - checkNotNull(request, "request should not be null."); - - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); - long[] range = request.getRange(); - if (range != null) { - internalRequest.addHeader(Headers.RANGE, "bytes=" + range[0] + "-" + range[1]); - } - - GetObjectResponse response = this.invokeHttpClient(internalRequest, GetObjectResponse.class); + public void setBucketLifecycle(SetBucketLifecycleRequest request) { - BosObject bosObject = response.getObject(); - bosObject.setBucketName(request.getBucketName()); - bosObject.setKey(request.getKey()); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("lifecycle", null); + if (request.getJsonBucketLifecycle() != null) { + byte[] json = null; + try { + json = request.getJsonBucketLifecycle().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else if (request.getRuleList() != null) { + byte[] json = null; + List rules = request.getRuleList(); + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("rule"); + for (Rule rule : rules) { + jsonGenerator.writeStartObject(); + // set id + jsonGenerator.writeStringField("id", rule.getId()); + // set status + jsonGenerator.writeStringField("status", rule.getStatus()); + // set resource + jsonGenerator.writeArrayFieldStart("resource"); + + for (String resource : rule.getResource()) { + jsonGenerator.writeString(resource); + } - return bosObject; + jsonGenerator.writeEndArray(); + // set condition + jsonGenerator.writeObjectFieldStart("condition"); + jsonGenerator.writeObjectFieldStart("time"); + jsonGenerator.writeStringField("dateGreaterThan", + rule.getCondition().getTime().getDateGreaterThan()); + jsonGenerator.writeEndObject(); + jsonGenerator.writeEndObject(); + // set action + jsonGenerator.writeObjectFieldStart("action"); + jsonGenerator.writeStringField("name", rule.getAction().getName()); + if (rule.getAction().getStorageClass() != null) { + jsonGenerator.writeStringField("storageClass", rule.getAction().getStorageClass()); + } + jsonGenerator.writeEndObject(); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else { + checkNotNull(request, "request should not be null."); + } + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Gets the object metadata for the object stored in Bos under the specified bucket and key, - * and saves the object contents to the specified file. - * Returns null if the specified constraints weren't met. + * Gets Lifecycle for the specified Bos bucket. * - * @param request The request object containing all the options on how to download the Bos object content. - * @param destinationFile Indicates the file (which might already exist) where to save the object - * content being downloading from Bos. - * @return All Bos object metadata for the specified object. - * Returns null if constraints were specified but not met. + * @param request The request object containing the specified bucket to get bucket Lifecycle. */ - public ObjectMetadata getObject(GetObjectRequest request, File destinationFile) { + public GetBucketLifecycleResponse getBucketLifecycle(GetBucketLifecycleRequest request) { checkNotNull(request, "request should not be null."); - checkNotNull(destinationFile, "destinationFile should not be null."); - BosObject bosObject = this.getObject(request); - this.downloadObjectToFile(bosObject, destinationFile, request.getRange() == null); - return bosObject.getObjectMetadata(); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("lifecycle", null); + GetBucketLifecycleResponse response = this.invokeHttpClient(internalRequest, GetBucketLifecycleResponse.class); + return response; } /** - * Gets the object content stored in Bos under the specified bucket and key. + * Delete the Lifecycle for the specified Bos bucket. * - * @param bucketName The name of the bucket containing the desired object. - * @param key The key under which the desired object is stored. - * @return The object content stored in Bos in the specified bucket and key. + * @param request The request object containing the specified bucket to delete bucket Lifecycle. */ - public byte[] getObjectContent(String bucketName, String key) { - return this.getObjectContent(new GetObjectRequest(bucketName, key)); - } + public void deleteBucketLifecycle(DeleteBucketLifecycleRequest request) { + checkNotNull(request, "request should not be null."); - /** - * Gets the object content stored in Bos under the specified bucket and key. - * - * @param request The request object containing all the options on how to download the Bos object content. - * @return The object content stored in Bos in the specified bucket and key. - */ - public byte[] getObjectContent(GetObjectRequest request) { - BosObjectInputStream content = this.getObject(request).getObjectContent(); - try { - return IOUtils.toByteArray(content); - } catch (IOException e) { - try { - content.close(); - } catch (IOException e1) { - // ignore, throw e not e1. - } - throw new BceClientException("Fail read object content", e); - } finally { - try { - content.close(); - } catch (IOException e) { - // ignore - } - } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter("lifecycle", null); + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Gets the metadata for the specified Bos object without actually fetching the object itself. - * This is useful in obtaining only the object metadata, and avoids wasting bandwidth on fetching - * the object data. + * Deletes the specified bucket. All objects in the bucket must be deleted before the bucket itself + * can be deleted. * *

- * The object metadata contains information such as content type, content disposition, etc., - * as well as custom user metadata that can be associated with an object in Bos. + * Only the owner of a bucket can delete it, regardless of the bucket's access control policy. * - * @param bucketName The name of the bucket containing the object's whose metadata is being retrieved. - * @param key The key of the object whose metadata is being retrieved. - * @return All Bos object metadata for the specified object. + * @param bucketName The name of the bucket to delete. */ - public ObjectMetadata getObjectMetadata(String bucketName, String key) { - return this.getObjectMetadata(new GetObjectMetadataRequest(bucketName, key)); + public void deleteBucket(String bucketName) { + this.deleteBucket(new DeleteBucketRequest(bucketName)); } /** - * Gets the metadata for the specified Bos object without actually fetching the object itself. - * This is useful in obtaining only the object metadata, and avoids wasting bandwidth on fetching - * the object data. + * Deletes the specified bucket. All objects in the bucket must be deleted before the bucket itself + * can be deleted. * *

- * The object metadata contains information such as content type, content disposition, etc., - * as well as custom user metadata that can be associated with an object in Bos. + * Only the owner of a bucket can delete it, regardless of the bucket's access control policy. * - * @param request The request object specifying the bucket, key whose metadata is being retrieved. - * @return All Bos object metadata for the specified object. + * @param request The request object containing all options for deleting a Bos bucket. */ - public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest request) { + public void deleteBucket(DeleteBucketRequest request) { checkNotNull(request, "request should not be null."); - return this.invokeHttpClient(this.createRequest(request, HttpMethodName.HEAD), GetObjectResponse.class) - .getObject().getObjectMetadata(); + this.invokeHttpClient(this.createRequest(request, HttpMethodName.DELETE), BosResponse.class); } /** - * Uploads the specified file to Bos under the specified bucket and key name. + * Returns a pre-signed URL for accessing a Bos resource. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param file The file containing the data to be uploaded to Bos. - * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of the bucket containing the desired object. + * @param key The key in the specified bucket under which the desired object is stored. + * @param expirationInSeconds The expiration after which the returned pre-signed URL will expire. + * @return A pre-signed URL which expires at the specified time, and can be + * used to allow anyone to download the specified object from Bos, + * without exposing the owner's Bce secret access key. */ - public PutObjectResponse putObject(String bucketName, String key, File file) { - return this.putObject(new PutObjectRequest(bucketName, key, file)); + public URL generatePresignedUrl(String bucketName, String key, int expirationInSeconds) { + return this.generatePresignedUrl(bucketName, key, expirationInSeconds, HttpMethodName.GET); } /** - * Uploads the specified file and object metadata to Bos under the specified bucket and key name. + * Returns a pre-signed URL for accessing a Bos resource. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param file The file containing the data to be uploaded to Bos. - * @param metadata Additional metadata instructing Bos how to handle the uploaded data - * (e.g. custom user metadata, hooks for specifying content type, etc.). - * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of the bucket containing the desired object. + * @param key The key in the specified bucket under which the desired object is stored. + * @param expirationInSeconds The expiration after which the returned pre-signed URL will expire. + * @param method The HTTP method verb to use for this URL + * @return A pre-signed URL which expires at the specified time, and can be + * used to allow anyone to download the specified object from Bos, + * without exposing the owner's Bce secret access key. */ - public PutObjectResponse putObject(String bucketName, String key, File file, ObjectMetadata metadata) { - return this.putObject(new PutObjectRequest(bucketName, key, file, metadata)); + public URL generatePresignedUrl(String bucketName, String key, int expirationInSeconds, HttpMethodName method) { + GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, key, method); + request.setExpiration(expirationInSeconds); + + return this.generatePresignedUrl(request); } /** - * Uploads the specified string to Bos under the specified bucket and key name. + * Returns a pre-signed URL for accessing a Bos resource. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param value The string containing the value to be uploaded to Bos. - * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @param request The request object containing all the options for generating a + * pre-signed URL (bucket name, key, expiration date, etc). + * @return A pre-signed URL which expires at the specified time, and can be + * used to allow anyone to download the specified object from Bos, + * without exposing the owner's Bce secret access key. */ - public PutObjectResponse putObject(String bucketName, String key, String value) { - try { - return this.putObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), new ObjectMetadata()); - } catch (UnsupportedEncodingException e) { - throw new BceClientException("Fail to get bytes.", e); + public URL generatePresignedUrl(GeneratePresignedUrlRequest request) { + checkNotNull(request, "The request parameter must be specified when generating a pre-signed URL"); + + HttpMethodName httpMethod = HttpMethodName.valueOf(request.getMethod().toString()); + + // If the key starts with a slash character itself, the following method + // will actually add another slash before the resource path to prevent + // the HttpClient mistakenly treating the slash as a path delimiter. + // For presigned request, we need to remember to remove this extra slash + // before generating the URL. + String bucketName = ((BosClientConfiguration) this.config).isCnameEnabled() ? null : request.getBucketName(); + URI uri = this.getEndpoint(); + if (bucketName != null) { + if (this.getBktVirEndpoint(bucketName) == null) { + this.computeBktVirEndpoint(bucketName); + } + if (this.getBktVirEndpoint(bucketName) != null && + !((BosClientConfiguration) this.config).isPathStyleAccessEnable()) { + uri = this.getBktVirEndpoint(bucketName); + bucketName = null; + } + } + InternalRequest internalRequest = new InternalRequest(httpMethod, HttpUtils + .appendUri(uri, URL_PREFIX, bucketName, request.getKey())); + + internalRequest.setCredentials(request.getRequestCredentials()); + SignOptions options = new SignOptions(); + options.setUseStsHeader(false); + options.setExpirationInSeconds(request.getExpiration()); + + if (httpMethod != HttpMethodName.GET && httpMethod != HttpMethodName.HEAD) { + options.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + } + + for (Entry entry : request.getRequestHeaders().entrySet()) { + if (entry.getValue() == null) { + internalRequest.addHeader(entry.getKey(), ""); + } else { + internalRequest.addHeader(entry.getKey(), entry.getValue()); + } + options.addHeadersToSign(entry.getKey()); + } + + for (Entry entry : request.getRequestParameters().entrySet()) { + if (entry.getValue() == null) { + internalRequest.addParameter(entry.getKey(), ""); + } else { + internalRequest.addParameter(entry.getKey(), entry.getValue()); + } + } + + if (request.getContentType() != null) { + internalRequest.addHeader(Headers.CONTENT_TYPE, request.getContentType()); + } + + if (request.getContentMd5() != null) { + internalRequest.addHeader(Headers.CONTENT_MD5, request.getContentMd5()); } + + addResponseHeaderParameters(internalRequest, request.getResponseHeaders()); + + Signer signer = new BceV1Signer(); + signer.sign(internalRequest, this.config.getCredentials(), options); + + // Remove the leading slash (if any) in the resource-path + return convertRequestToUrl(internalRequest); } /** - * Uploads the specified string and object metadata to Bos under the specified bucket and key name. + * Returns ListObjectsResponse containing a list of summary information about the objects in the specified buckets. + * List results are always returned in lexicographic (alphabetical) order. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param value The string containing the value to be uploaded to Bos. - * @param metadata Additional metadata instructing Bos how to handle the uploaded data - * (e.g. custom user metadata, hooks for specifying content type, etc.). - * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of the Bos bucket to list. + * @return ListObjectsResponse containing a listing of the objects in the specified bucket, along with any + * other associated information, such as common prefixes (if a delimiter was specified), the original + * request parameters, etc. */ - public PutObjectResponse putObject(String bucketName, String key, String value, ObjectMetadata metadata) { - try { - return this.putObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), metadata); - } catch (UnsupportedEncodingException e) { - throw new BceClientException("Fail to get bytes.", e); - } + public ListObjectsResponse listObjects(String bucketName) { + return this.listObjects(new ListObjectsRequest(bucketName)); } /** - * Uploads the specified bytes to Bos under the specified bucket and key name. + * Returns ListObjectsResponse containing a list of summary information about the objects in the specified buckets. + * List results are always returned in lexicographic (alphabetical) order. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param value The bytes containing the value to be uploaded to Bos. - * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of the Bos bucket to list. + * @param prefix An optional parameter restricting the response to keys beginning with the specified prefix. + * Use prefixes to separate a bucket into different sets of keys, similar to how a file system + * organizes files into directories. + * @return ListObjectsResponse containing a listing of the objects in the specified bucket, along with any + * other associated information, such as common prefixes (if a delimiter was specified), the original + * request parameters, etc. */ - public PutObjectResponse putObject(String bucketName, String key, byte[] value) { - return this.putObject(bucketName, key, value, new ObjectMetadata()); + public ListObjectsResponse listObjects(String bucketName, String prefix) { + return this.listObjects(new ListObjectsRequest(bucketName, prefix)); } /** - * Uploads the specified bytes and object metadata to Bos under the specified bucket and key name. + * Returns ListObjectsResponse containing a list of summary information about the objects in the specified buckets. + * List results are always returned in lexicographic (alphabetical) order. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param value The bytes containing the value to be uploaded to Bos. - * @param metadata Additional metadata instructing Bos how to handle the uploaded data - * (e.g. custom user metadata, hooks for specifying content type, etc.). - * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @param request The request object containing all options for listing the objects in a specified bucket. + * @return ListObjectsResponse containing a listing of the objects in the specified bucket, along with any + * other associated information, such as common prefixes (if a delimiter was specified), the original + * request parameters, etc. */ - public PutObjectResponse putObject(String bucketName, String key, byte[] value, ObjectMetadata metadata) { - if (metadata.getContentLength() == -1) { - metadata.setContentLength(value.length); + public ListObjectsResponse listObjects(ListObjectsRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + if (((BosClientConfiguration) this.config).getConsistencyView() != null) { + internalRequest.addHeader(Headers.BCE_CONSISTENCY_VIEW, + ((BosClientConfiguration) this.config).getConsistencyView()); } - return this.putObject(new PutObjectRequest(bucketName, key, RestartableInputStream.wrap(value), metadata)); + if (request.getPrefix() != null) { + internalRequest.addParameter("prefix", request.getPrefix()); + } + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getDelimiter() != null) { + internalRequest.addParameter("delimiter", request.getDelimiter()); + } + if (request.getMaxKeys() >= 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (request.isNeedExtMeta()) { + internalRequest.addHeader(Headers.BCE_LIST_WITH_EXT_META, String.valueOf(request.isNeedExtMeta())); + } + + return this.invokeHttpClient(internalRequest, ListObjectsResponse.class); } /** - * Uploads the specified input stream to Bos under the specified bucket and key name. + * Provides an easy way to continue a truncated object listing and retrieve the next page of results. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param input The input stream containing the value to be uploaded to Bos. - * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @param previousResponse The previous truncated ListObjectsResponse. If a non-truncated + * ListObjectsResponse is passed in, an empty ListObjectsResponse + * is returned without ever contacting Bos. + * @return The next set of ListObjectsResponse results, beginning immediately + * after the last result in the specified previous ListObjectsResponse. */ - public PutObjectResponse putObject(String bucketName, String key, InputStream input) { - return this.putObject(new PutObjectRequest(bucketName, key, input)); + public ListObjectsResponse listNextBatchOfObjects(ListObjectsResponse previousResponse) { + checkNotNull(previousResponse, "previousResponse should not be null."); + + if (!previousResponse.isTruncated()) { + ListObjectsResponse emptyResponse = new ListObjectsResponse(); + emptyResponse.setBucketName(previousResponse.getBucketName()); + emptyResponse.setDelimiter(previousResponse.getDelimiter()); + emptyResponse.setMarker(previousResponse.getNextMarker()); + emptyResponse.setMaxKeys(previousResponse.getMaxKeys()); + emptyResponse.setPrefix(previousResponse.getPrefix()); + emptyResponse.setTruncated(false); + return emptyResponse; + } + + return this.listObjects(new ListObjectsRequest(previousResponse.getBucketName()) + .withPrefix(previousResponse.getPrefix()) + .withMarker(previousResponse.getNextMarker()) + .withDelimiter(previousResponse.getDelimiter()) + .withMaxKeys(previousResponse.getMaxKeys())); } /** - * Uploads the specified input stream and object metadata to Bos under the specified bucket and key name. + * Gets the object stored in Bos under the specified bucket and key. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param input The input stream containing the value to be uploaded to Bos. - * @param metadata Additional metadata instructing Bos how to handle the uploaded data - * (e.g. custom user metadata, hooks for specifying content type, etc.). - * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of the bucket containing the desired object. + * @param key The key under which the desired object is stored. + * @return The object stored in Bos in the specified bucket and key. */ - public PutObjectResponse putObject(String bucketName, String key, InputStream input, ObjectMetadata metadata) { - return this.putObject(new PutObjectRequest(bucketName, key, input, metadata)); + public BosObject getObject(String bucketName, String key) { + return this.getObject(new GetObjectRequest(bucketName, key)); } /** - * Uploads a new object to the specified Bos bucket. The PutObjectRequest contains all the - * details of the request, including the bucket to upload to, the key the object will be uploaded under, - * and the file or input stream containing the data to upload. + * Gets the object metadata for the object stored in Bos under the specified bucket and key, + * and saves the object contents to the specified file. + * Returns null if the specified constraints weren't met. * - * @param request The request object containing all the parameters to upload a new object to Bos. - * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of the bucket containing the desired object. + * @param key The key under which the desired object is stored. + * @param destinationFile Indicates the file (which might already exist) + * where to save the object content being downloading from Bos. + * @return All Bos object metadata for the specified object. + * Returns null if constraints were specified but not met. */ - public PutObjectResponse putObject(PutObjectRequest request) { + public ObjectMetadata getObject(String bucketName, String key, File destinationFile) { + return this.getObject(new GetObjectRequest(bucketName, key), destinationFile); + } + + /** + * Gets the object stored in Bos under the specified bucket and key. + * + * @param request The request object containing all the options on how to download the object. + * @return The object stored in Bos in the specified bucket and key. + */ + public BosObject getObject(GetObjectRequest request) { checkNotNull(request, "request should not be null."); - assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + long[] range = request.getRange(); + if (range != null) { + internalRequest.addHeader(Headers.RANGE, "bytes=" + range[0] + "-" + range[1]); + } + if (request.getTrafficLimitBitPS() > 0) { + internalRequest.addHeader(Headers.BOS_TRAFFIC_LIMIT, String.valueOf(request.getTrafficLimitBitPS())); + } - BosResponse response = uploadObject(request, internalRequest); - PutObjectResponse result = new PutObjectResponse(); - result.setETag(response.getMetadata().getETag()); + GetObjectResponse response = this.invokeHttpClient(internalRequest, GetObjectResponse.class); - return result; + BosObject bosObject = response.getObject(); + bosObject.setBucketName(request.getBucketName()); + bosObject.setKey(request.getKey()); + + return bosObject; } /** - * Copies a source object to a new destination in Bos. + * Gets the object metadata for the object stored in Bos under the specified bucket and key, + * and saves the object contents to the specified file. + * Returns null if the specified constraints weren't met. * - * @param sourceBucketName The name of the bucket containing the source object to copy. - * @param sourceKey The key in the source bucket under which the source object is stored. - * @param destinationBucketName The name of the bucket in which the new object will be created. - * This can be the same name as the source bucket's. - * @param destinationKey The key in the destination bucket under which the new object will be created. - * @return A CopyObjectResponse object containing the information returned by Bos for the newly created object. + * @param request The request object containing all the options on how to download the Bos object content. + * @param destinationFile Indicates the file (which might already exist) where to save the object + * content being downloading from Bos. + * @return All Bos object metadata for the specified object. + * Returns null if constraints were specified but not met. */ - public CopyObjectResponse copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, - String destinationKey) { - return this.copyObject(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, - destinationKey)); + public ObjectMetadata getObject(GetObjectRequest request, File destinationFile) { + checkNotNull(request, "request should not be null."); + checkNotNull(destinationFile, "destinationFile should not be null."); + + BosObject bosObject = this.getObject(request); + this.downloadObjectToFile(bosObject, destinationFile, request.getRange() == null, request.getProgressCallback()); + return bosObject.getObjectMetadata(); } /** - * Copies a source object to a new destination in Bos. + * Gets the object content stored in Bos under the specified bucket and key. * - * @param request The request object containing all the options for copying an Bos object. - * @return A CopyObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of the bucket containing the desired object. + * @param key The key under which the desired object is stored. + * @return The object content stored in Bos in the specified bucket and key. */ - public CopyObjectResponse copyObject(CopyObjectRequest request) { - checkNotNull(request, "request should not be null."); - assertStringNotNullOrEmpty(request.getSourceKey(), "object key should not be null or empty"); - - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + public byte[] getObjectContent(String bucketName, String key) { + return this.getObjectContent(new GetObjectRequest(bucketName, key)); + } - String copySourceHeader = "/" + request.getSourceBucketName() + "/" + request.getSourceKey(); - copySourceHeader = HttpUtils.normalizePath(copySourceHeader); - internalRequest.addHeader(Headers.BCE_COPY_SOURCE, copySourceHeader); - if (request.getETag() != null) { - internalRequest.addHeader(Headers.BCE_COPY_SOURCE_IF_MATCH, - "\"" + request.getETag() + "\""); - } - if (request.getNoneMatchETagConstraint() != null) { - internalRequest.addHeader( - Headers.BCE_COPY_SOURCE_IF_NONE_MATCH, "\"" + request.getNoneMatchETagConstraint() + "\""); - } - if (request.getUnmodifiedSinceConstraint() != null) { - internalRequest.addHeader( - Headers.BCE_COPY_SOURCE_IF_UNMODIFIED_SINCE, request.getUnmodifiedSinceConstraint()); - } - if (request.getModifiedSinceConstraint() != null) { - internalRequest.addHeader( - Headers.BCE_COPY_SOURCE_IF_MODIFIED_SINCE, request.getModifiedSinceConstraint()); - } - if (request.getStorageClass() != null) { - internalRequest.addHeader(Headers.BCE_STORAGE_CLASS, request.getStorageClass()); - } - ObjectMetadata newObjectMetadata = request.getNewObjectMetadata(); - if (newObjectMetadata != null) { - internalRequest.addHeader(Headers.BCE_COPY_METADATA_DIRECTIVE, "replace"); - populateRequestMetadata(internalRequest, newObjectMetadata); - } else { - internalRequest.addHeader(Headers.BCE_COPY_METADATA_DIRECTIVE, "copy"); + /** + * Gets the object content stored in Bos under the specified bucket and key. + * + * @param request The request object containing all the options on how to download the Bos object content. + * @return The object content stored in Bos in the specified bucket and key. + */ + public byte[] getObjectContent(GetObjectRequest request) { + BosObjectInputStream content = this.getObject(request).getObjectContent(); + try { + return IOUtils.toByteArray(content); + } catch (IOException e) { + try { + content.close(); + } catch (IOException e1) { + // ignore, throw e not e1. + } + throw new BceClientException("Fail read object content", e); + } finally { + try { + content.close(); + } catch (IOException e) { + // ignore + } } + } - this.setZeroContentLength(internalRequest); - - CopyObjectResponseWithExceptionInfo intermidiateRes = this.invokeHttpClient(internalRequest, - CopyObjectResponseWithExceptionInfo.class); - // handle exception - if (intermidiateRes.getETag() == null - && intermidiateRes.getLastModified() == null) { - if (intermidiateRes.getMessage() != null) { - BceServiceException bse = new BceServiceException(intermidiateRes.getMessage()); - bse.setErrorCode(intermidiateRes.getCode()); - bse.setRequestId(intermidiateRes.getRequestId()); - if (bse.getErrorCode() == "InternalError") { - bse.setErrorType(ErrorType.Service); - } else { - bse.setErrorType(ErrorType.Client); - } - bse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); - throw bse; + /** + * Checks if the specified object exists. use this method to determine + * if a specified object already exists + * + *

+ * If invalid security credentials are used to execute this method, the + * client is not able to distinguish between bucket permission errors and + * invalid credential errors, and this method could return an incorrect + * result. + * + * @param bucketName The name of the bucket + * @param key The name of the object to check. + * @return The value true if the specified object exists in Bos; + * the value false if there is no object in Bos with that name. + */ + public boolean doesObjectExist(String bucketName, String key) { + try { + getObjectMetadata(bucketName, key); + return true; + } catch (BceServiceException e) { + if (e.getStatusCode() == StatusCodes.NOT_FOUND) { + return false; } + throw e; } - return (CopyObjectResponse) intermidiateRes; } /** - * Deletes the specified object in the specified bucket. + * Gets the metadata for the specified Bos object without actually fetching the object itself. + * This is useful in obtaining only the object metadata, and avoids wasting bandwidth on fetching + * the object data. * - * @param bucketName The name of the Bos bucket containing the object to delete. - * @param key The key of the object to delete. + *

+ * The object metadata contains information such as content type, content disposition, etc., + * as well as custom user metadata that can be associated with an object in Bos. + * + * @param bucketName The name of the bucket containing the object's whose metadata is being retrieved. + * @param key The key of the object whose metadata is being retrieved. + * @return All Bos object metadata for the specified object. */ - public void deleteObject(String bucketName, String key) { - this.deleteObject(new DeleteObjectRequest(bucketName, key)); + public ObjectMetadata getObjectMetadata(String bucketName, String key) { + return this.getObjectMetadata(new GetObjectMetadataRequest(bucketName, key)); } /** - * Deletes the specified object in the specified bucket. + * Gets the metadata for the specified Bos object without actually fetching the object itself. + * This is useful in obtaining only the object metadata, and avoids wasting bandwidth on fetching + * the object data. * - * @param request The request object containing all options for deleting a Bos object. + *

+ * The object metadata contains information such as content type, content disposition, etc., + * as well as custom user metadata that can be associated with an object in Bos. + * + * @param request The request object specifying the bucket, key whose metadata is being retrieved. + * @return All Bos object metadata for the specified object. */ - public void deleteObject(DeleteObjectRequest request) { + public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest request) { checkNotNull(request, "request should not be null."); - assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); - this.invokeHttpClient(this.createRequest(request, HttpMethodName.DELETE), BosResponse.class); + return this.invokeHttpClient(this.createRequest(request, HttpMethodName.HEAD), GetObjectResponse.class) + .getObject().getObjectMetadata(); } /** - * Initiates a multipart upload and returns an InitiateMultipartUploadResponse - * which contains an upload ID. This upload ID associates all the parts in - * the specific upload and is used in each of your subsequent uploadPart requests. - * You also include this upload ID in the final request to either complete, or abort the multipart - * upload request. + * Uploads the specified file to Bos under the specified bucket and key name. * - * @param bucketName The name of the Bos bucket containing the object to initiate. - * @param key The key of the object to initiate. - * @return An InitiateMultipartUploadResponse from Bos. + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param file The file containing the data to be uploaded to Bos. + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. */ - public InitiateMultipartUploadResponse initiateMultipartUpload(String bucketName, String key) { - return this.initiateMultipartUpload(new InitiateMultipartUploadRequest(bucketName, key)); + public PutObjectResponse putObject(String bucketName, String key, File file) { + return this.putObject(new PutObjectRequest(bucketName, key, file)); } /** - * Initiates a multipart upload and returns an InitiateMultipartUploadResponse - * which contains an upload ID. This upload ID associates all the parts in - * the specific upload and is used in each of your subsequent uploadPart requests. - * You also include this upload ID in the final request to either complete, or abort the multipart - * upload request. + * Uploads the specified file and object metadata to Bos under the specified bucket and key name. * - * @param request The InitiateMultipartUploadRequest object that specifies all the parameters of this operation. - * @return An InitiateMultipartUploadResponse from Bos. + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param file The file containing the data to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. */ - public InitiateMultipartUploadResponse initiateMultipartUpload(InitiateMultipartUploadRequest request) { - checkNotNull(request, "request should not be null."); - - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); - internalRequest.addParameter("uploads", null); - if (request.getStorageClass() != null) { - internalRequest.addHeader(Headers.BCE_STORAGE_CLASS, request.getStorageClass()); - } - this.setZeroContentLength(internalRequest); - - if (request.getObjectMetadata() != null) { - populateRequestMetadata(internalRequest, request.getObjectMetadata()); - } - - return this.invokeHttpClient(internalRequest, InitiateMultipartUploadResponse.class); + public PutObjectResponse putObject(String bucketName, String key, File file, ObjectMetadata metadata) { + return this.putObject(new PutObjectRequest(bucketName, key, file, metadata)); } /** - * Uploads a part in a multipart upload. You must initiate a multipart - * upload before you can upload any part. + * Uploads the specified string to Bos under the specified bucket and key name. * - * @param request The UploadPartRequest object that specifies all the parameters of this operation. - * @return An UploadPartResponse from Bos containing the part number and ETag of the new part. + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The string containing the value to be uploaded to Bos. + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. */ - public UploadPartResponse uploadPart(UploadPartRequest request) { - checkNotNull(request, "request should not be null."); - checkNotNull(request.getPartSize(), "partSize should not be null"); - checkNotNull(request.getPartNumber(), "partNumber should not be null"); - - if (request.getPartSize() > 5 * 1024 * 1024 * 1024L) { - throw new BceClientException("PartNumber " + request.getPartNumber() - + " : Part Size should not be more than 5GB."); - } - - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); - internalRequest.addParameter("uploadId", request.getUploadId()); - internalRequest.addParameter("partNumber", String.valueOf(request.getPartNumber())); - internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(request.getPartSize())); - - InputStream input = request.getInputStream(); - MD5DigestCalculatingInputStream md5DigestStream = null; - if (request.getMd5Digest() == null) { - try { - md5DigestStream = new MD5DigestCalculatingInputStream(input); - input = md5DigestStream; - } catch (NoSuchAlgorithmException e) { - logger.warn("Unable to verify data integrity.", e); - } + public PutObjectResponse putObject(String bucketName, String key, String value) { + try { + return this.putObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), new ObjectMetadata()); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get bytes.", e); } + } + /** + * Uploads the specified string and object metadata to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The string containing the value to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + */ + public PutObjectResponse putObject(String bucketName, String key, String value, ObjectMetadata metadata) { try { - internalRequest.setContent(this.wrapRestartableInputStream(input)); - BosResponse response = this.invokeHttpClient(internalRequest, BosResponse.class); - - if (md5DigestStream != null) { - byte[] clientSideHash = md5DigestStream.getMd5Digest(); - byte[] serverSideHash; - try { - serverSideHash = Hex.decodeHex(response.getMetadata().getETag().toCharArray()); - } catch (Exception e) { - throw new BceClientException("Unable to verify integrity of data upload.", e); - } - if (!Arrays.equals(clientSideHash, serverSideHash)) { - throw new BceClientException("Unable to verify integrity of data upload. " - + "Client calculated content hash didn't match hash calculated by " - + "BOS. " + "You may need to delete the data stored in BOS."); - } - } - - UploadPartResponse result = new UploadPartResponse(); - result.setETag(response.getMetadata().getETag()); - result.setPartNumber(request.getPartNumber()); - return result; - } finally { - if (input != null) { - try { - input.close(); - } catch (Exception e) { - } - } + return this.putObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), metadata); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get bytes.", e); } } /** - * Lists the parts that have been uploaded for a specific multipart upload. + * Uploads the specified bytes to Bos under the specified bucket and key name. * - * @param bucketName The name of the bucket containing the multipart upload whose parts are being listed. - * @param key The key of the associated multipart upload whose parts are being listed. - * @param uploadId The ID of the multipart upload whose parts are being listed. - * @return Returns a ListPartsResponse from Bos. + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The bytes containing the value to be uploaded to Bos. + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. */ - public ListPartsResponse listParts(String bucketName, String key, String uploadId) { - return this.listParts(new ListPartsRequest(bucketName, key, uploadId)); + public PutObjectResponse putObject(String bucketName, String key, byte[] value) { + return this.putObject(bucketName, key, value, new ObjectMetadata()); } /** - * Lists the parts that have been uploaded for a specific multipart upload. + * Uploads the specified bytes and object metadata to Bos under the specified bucket and key name. * - * @param request The ListPartsRequest object that specifies all the parameters of this operation. - * @return Returns a ListPartsResponse from Bos. + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The bytes containing the value to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. */ - public ListPartsResponse listParts(ListPartsRequest request) { - checkNotNull(request, "request should not be null."); - - InternalRequest interrnalRequest = this.createRequest(request, HttpMethodName.GET); - interrnalRequest.addParameter("uploadId", request.getUploadId()); - int maxParts = request.getMaxParts(); - if (maxParts >= 0) { - interrnalRequest.addParameter("maxParts", String.valueOf(maxParts)); + public PutObjectResponse putObject(String bucketName, String key, byte[] value, ObjectMetadata metadata) { + if (metadata.getContentLength() == -1) { + metadata.setContentLength(value.length); } - interrnalRequest.addParameter("partNumberMarker", String.valueOf(request.getPartNumberMarker())); - - ListPartsResponse response = this.invokeHttpClient(interrnalRequest, ListPartsResponse.class); - response.setBucketName(request.getBucketName()); - return response; + return this.putObject(new PutObjectRequest(bucketName, key, RestartableInputStream.wrap(value), metadata)); } /** - * Completes a multipart upload by assembling previously uploaded parts. + * Uploads the specified input stream to Bos under the specified bucket and key name. * - * @param bucketName The name of the bucket containing the multipart upload to complete. - * @param key The key of the multipart upload to complete. - * @param uploadId The ID of the multipart upload to complete. - * @param partETags The list of part numbers and ETags to use when completing the multipart upload. - * @return A CompleteMultipartUploadResponse from Bos containing the ETag for - * the new object composed of the individual parts. + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param input The input stream containing the value to be uploaded to Bos. + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. */ - public CompleteMultipartUploadResponse completeMultipartUpload(String bucketName, String key, String uploadId, - List partETags) { - return this.completeMultipartUpload(new CompleteMultipartUploadRequest(bucketName, key, uploadId, partETags)); + public PutObjectResponse putObject(String bucketName, String key, InputStream input) { + return this.putObject(new PutObjectRequest(bucketName, key, input)); } /** - * Completes a multipart upload by assembling previously uploaded parts. + * Uploads the specified input stream and object metadata to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param input The input stream containing the value to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + */ + public PutObjectResponse putObject(String bucketName, String key, InputStream input, ObjectMetadata metadata) { + return this.putObject(new PutObjectRequest(bucketName, key, input, metadata)); + } + + /** + * Uploads the specified input stream and object metadata to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param input The input stream containing the value to be uploaded to Bos. + * @param progressCallback The BosProgressCallback, which used for get progress information. + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + */ + public PutObjectResponse putObject(String bucketName, String key, InputStream input, + BosProgressCallback progressCallback) { + return this.putObject(new PutObjectRequest(bucketName, key, input, progressCallback)); + } + + /** + * Uploads a new object to the specified Bos bucket. The PutObjectRequest contains all the + * details of the request, including the bucket to upload to, the key the object will be uploaded under, + * and the file or input stream containing the data to upload. + * + * @param request The request object containing all the parameters to upload a new object to Bos. + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + */ + public PutObjectResponse putObject(PutObjectRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getBucketName(), "bucket name should not be null or empty"); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + + BosResponse response = uploadObject(request, internalRequest); + PutObjectResponse result = new PutObjectResponse(); + result.setETag(response.getMetadata().getETag()); + result.setCallback(response.getCallback()); + + return result; + } + + /** + * Copies a source object to a new destination in Bos. + * + * @param sourceBucketName The name of the bucket containing the source object to copy. + * @param sourceKey The key in the source bucket under which the source object is stored. + * @param destinationBucketName The name of the bucket in which the new object will be created. + * This can be the same name as the source bucket's. + * @param destinationKey The key in the destination bucket under which the new object will be created. + * @return A CopyObjectResponse object containing the information returned by Bos for the newly created object. + */ + public CopyObjectResponse copyObject(String sourceBucketName, String sourceKey, String destinationBucketName, + String destinationKey) { + return this.copyObject(new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, + destinationKey)); + } + + /** + * Copies a source object to a new destination in Bos. + * + * @param request The request object containing all the options for copying an Bos object. + * @return A CopyObjectResponse object containing the information returned by Bos for the newly created object. + */ + public CopyObjectResponse copyObject(CopyObjectRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getSourceKey(), "object key should not be null or empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + + String copySourceHeader = "/" + request.getSourceBucketName() + "/" + request.getSourceKey(); + copySourceHeader = HttpUtils.normalizePath(copySourceHeader); + internalRequest.addHeader(Headers.BCE_COPY_SOURCE, copySourceHeader); + if (request.getETag() != null) { + internalRequest.addHeader(Headers.BCE_COPY_SOURCE_IF_MATCH, + "\"" + request.getETag() + "\""); + } + if (request.getNoneMatchETagConstraint() != null) { + internalRequest.addHeader( + Headers.BCE_COPY_SOURCE_IF_NONE_MATCH, "\"" + request.getNoneMatchETagConstraint() + "\""); + } + if (request.getUnmodifiedSinceConstraint() != null) { + internalRequest.addHeader( + Headers.BCE_COPY_SOURCE_IF_UNMODIFIED_SINCE, request.getUnmodifiedSinceConstraint()); + } + if (request.getModifiedSinceConstraint() != null) { + internalRequest.addHeader( + Headers.BCE_COPY_SOURCE_IF_MODIFIED_SINCE, request.getModifiedSinceConstraint()); + } + if (request.getStorageClass() != null) { + internalRequest.addHeader(Headers.BCE_STORAGE_CLASS, request.getStorageClass()); + } + if (request.getTrafficLimitBitPS() > 0) { + internalRequest.addHeader(Headers.BOS_TRAFFIC_LIMIT, String.valueOf(request.getTrafficLimitBitPS())); + } + if (request.getxBceCrc32cFlag()) { + internalRequest.addHeader(Headers.BCE_CONTENT_CRC32C_FLAG, String.valueOf(request.getxBceCrc32cFlag())); + } + ObjectMetadata newObjectMetadata = request.getNewObjectMetadata(); + if (newObjectMetadata != null) { + internalRequest.addHeader(Headers.BCE_COPY_METADATA_DIRECTIVE, "replace"); + populateRequestMetadata(internalRequest, newObjectMetadata); + } else { + internalRequest.addHeader(Headers.BCE_COPY_METADATA_DIRECTIVE, "copy"); + } + + this.setZeroContentLength(internalRequest); + + CopyObjectResponseWithExceptionInfo intermidiateRes = this.invokeHttpClient(internalRequest, + CopyObjectResponseWithExceptionInfo.class); + // handle exception + if (intermidiateRes.getETag() == null + && intermidiateRes.getLastModified() == null) { + if (intermidiateRes.getMessage() != null) { + BceServiceException bse = new BceServiceException(intermidiateRes.getMessage()); + bse.setErrorCode(intermidiateRes.getCode()); + bse.setRequestId(intermidiateRes.getRequestId()); + if (bse.getErrorCode() == "InternalError") { + bse.setErrorType(ErrorType.Service); + } else { + bse.setErrorType(ErrorType.Client); + } + bse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); + throw bse; + } + } + return (CopyObjectResponse) intermidiateRes; + } + + /** + * Fetches a source object to a new destination in Bos. + * + * @param bucketName The name of the bucket in which the new object will be created. + * @param key The key in the destination bucket under which the new object will be created. + * @param sourceUrl The url full path for fetching. + * @return A FetchObjectResponse object containing the information returned by Bos for the newly fetching. + */ + public FetchObjectResponse fetchObject(String bucketName, String key, String sourceUrl) { + FetchObjectRequest request = new FetchObjectRequest(bucketName, key, sourceUrl); + return this.fetchObject(request); + } + + /** + * Fetches a source object to a new destination in Bos. + * + * @param bucketName The name of the bucket in which the new object will be created. + * @param key The key in the destination bucket under which the new object will be created. + * @param sourceUrl The url full path for fetching. + * @param mode The mode path for fetching. + * @return A FetchObjectResponse object containing the information returned by Bos for the newly fetching. + */ + public FetchObjectResponse fetchObject(String bucketName, String key, String sourceUrl, String mode) { + FetchObjectRequest request = new FetchObjectRequest(bucketName, key, sourceUrl).withMode(mode); + return this.fetchObject(request); + } + + /** + * Fetches a source object to a new destination in Bos. + * + * @param request The request object containing all the options for fetching url to a Bos object. + * @return A FetchObjectResponse object containing the information returned by Bos for the newly fetching. + */ + public FetchObjectResponse fetchObject(FetchObjectRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getSourceUrl(), "source should not be null or empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter("fetch", null); + + internalRequest.addHeader(Headers.BCE_FETCH_SOURCE, request.getSourceUrl()); + if (request.getMode() != null) { + internalRequest.addHeader(Headers.BCE_FETCH_MODE, request.getMode()); + } + if (request.getStorageClass() != null) { + internalRequest.addHeader(Headers.BCE_STORAGE_CLASS, request.getStorageClass()); + } + if (request.getCallbackAddress() != null) { + internalRequest.addHeader(Headers.BCE_FETCH_CALLBACK_ADDRESS, request.getCallbackAddress()); + } + if (request.getReferer() != null) { + internalRequest.addHeader(Headers.BCE_REFERER, request.getReferer()); + } + if (request.getUserAgent() != null) { + internalRequest.addHeader(Headers.BCE_FETCH_USER_AGENT, request.getUserAgent()); + } + this.setZeroContentLength(internalRequest); + + FetchObjectResponse response = this.invokeHttpClient(internalRequest, FetchObjectResponse.class); + return response; + } + + /** + * Deletes the specified object in the specified bucket. + * + * @param bucketName The name of the Bos bucket containing the object to delete. + * @param key The key of the object to delete. + */ + public void deleteObject(String bucketName, String key) { + this.deleteObject(new DeleteObjectRequest(bucketName, key)); + } + + /** + * Deletes the specified object in the specified bucket. + * + * @param request The request object containing all options for deleting a Bos object. + */ + public void deleteObject(DeleteObjectRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + + this.invokeHttpClient(this.createRequest(request, HttpMethodName.DELETE), BosResponse.class); + } + + /** + * Set the specified object symlink in the specified bucket. + * + * @param bucketName The name of the Bos bucket containing the object + * @param key The object's symlink name + * @param symlinkTarget The target object of the symlink + * @return + */ + public SetObjectSymlinkResponse setObjectSymlink(String bucketName, String key, String symlinkTarget) { + return this.setObjectSymlink(new SetObjectSymlinkRequest(bucketName, key, symlinkTarget)); + } + + /** + * Set the specified object symlink in the specified bucket. + * + * @param request The request object containing all options for setting a symlink of target object. + * @return + */ + public SetObjectSymlinkResponse setObjectSymlink(SetObjectSymlinkRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getSymlinkTarget(), "object key should not be null or empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("symlink", null); + + try { + internalRequest.addHeader(Headers.BCE_SYMLINK_TARGET, + URLEncoder.encode(request.getSymlinkTarget(), "UTF-8")); + } catch (Exception e) { + throw new BceClientException("Fail to encode SymlinkTarget"); + } + if (request.isForbidOverwrite() == false) { + internalRequest.addHeader(Headers.BCE_FORBID_OVERWRITE, "false"); + } else { + internalRequest.addHeader(Headers.BCE_FORBID_OVERWRITE, "true"); + } + if (request.getStorageClass() != null) { + internalRequest.addHeader(Headers.BCE_STORAGE_CLASS, request.getStorageClass()); + } + Map userMetadata = request.getUserMetadata(); + if (userMetadata != null) { + for (Entry entry : userMetadata.entrySet()) { + String key = entry.getKey(); + if (key == null) { + continue; + } + String value = entry.getValue(); + if (value == null) { + value = ""; + } + if (key.length() + value.length() > 1024 * 32) { + throw new BceClientException("MetadataTooLarge"); + } + internalRequest.addHeader(Headers.BCE_USER_METADATA_PREFIX + HttpUtils.normalize(key.trim()), + HttpUtils.normalize(value)); + } + } + + this.setZeroContentLength(internalRequest); + BosResponse response = this.invokeHttpClient(internalRequest, BosResponse.class); + SetObjectSymlinkResponse result = new SetObjectSymlinkResponse(); + result.setETag(response.getMetadata().getETag()); + return result; + } + + /** + * Gets the specified object symlink in the specified bucket + * + * @param bucketName The name of the Bos bucket containing the symlink object + * @param key The symlink name + * @return The symlink target Object + */ + public GetObjectSymlinkResponse getObjectSymlink(String bucketName, String key) { + return this.getObjectSymlink(new GetObjectSymlinkRequest(bucketName, key)); + } + + /** + * Gets the specified object symlink in the specified bucket + * + * @param request The request object containing all options for getting a symlink of target object. + * @return The symlink target Object + */ + public GetObjectSymlinkResponse getObjectSymlink(GetObjectSymlinkRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getBucketName(), "bucketName should not be null or empty"); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("symlink", null); + + BosResponse response = this.invokeHttpClient(internalRequest, BosResponse.class); + GetObjectSymlinkResponse result = new GetObjectSymlinkResponse(); + result.setSymlinkTarget(response.getMetadata().getSymlinkTarget()); + return result; + } + + /** + * Deletes the specified directory in the specified namespace bucket. + * + * @param bucketName The name of the Bos bucket containing the object to delete. + * @param key The path of the directory to delete. + * @param isDeleteRecursive Whether delete a dir in namespace + */ + public DeleteDirectoryResponse deleteDirectory(String bucketName, String key, boolean isDeleteRecursive) { + return this.deleteDirectory(new DeleteDirectoryRequest(bucketName, key, isDeleteRecursive)); + } + + /** + * Deletes the specified object in the specified bucket. + * + * @param bucketName The directory of the Bos bucket containing the object to delete. + * @param key The path of the directory to delete. + * @param isDeleteRecursive Whether delete a dir in namespace + * @param marker The marker position of delete begin, must be sub of key + */ + public DeleteDirectoryResponse deleteDirectory(String bucketName, String key, boolean isDeleteRecursive, + String marker) { + return this.deleteDirectory(new DeleteDirectoryRequest(bucketName, key, isDeleteRecursive, marker)); + } + + /** + * Deletes the specified directory in the specified namespace bucket. + * + * @param request The request containing all options for deleting a Bos object. + */ + public DeleteDirectoryResponse deleteDirectory(DeleteDirectoryRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + if (request.isDeleteRecursive()) { + internalRequest.addHeader(Headers.BCE_DELETE_RECURSIVE, String.valueOf(true)); + if (request.getDeleteMarker() != null) { + internalRequest.addHeader(Headers.BCE_DELETE_TOKEN, request.getDeleteMarker()); + } + } + + DeleteDirectoryResponse response = this.invokeHttpClient(internalRequest, DeleteDirectoryResponse.class); + return response; + } + + /** + * Deletes the multiple specified objects in the specified bucket. + * + * @param request The request object containing all options for deleting a Bos multiple objects. + */ + public DeleteMultipleObjectsResponse deleteMultipleObjects(DeleteMultipleObjectsRequest request) { + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter("delete", ""); + if (request.getJsonDeleteObjects() != null) { + byte[] json = null; + try { + json = request.getJsonDeleteObjects().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else if (request.getObjectKeys() != null) { + if (request.getObjectKeys().size() > 1000) { + throw new BceClientException("The delete objects number must not more than 1000."); + } + List objectKeys = request.getObjectKeys(); + byte[] json = null; + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("objects"); + for (String object : objectKeys) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("key", object); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else { + checkNotNull(request, "request should not be null."); + } + DeleteMultipleObjectsResponse response = this.invokeHttpClient(internalRequest, + DeleteMultipleObjectsResponse.class); + return response; + } + + /** + * Set Object Acl for specified object in the specified bucket. + * + * @param bucketName + * @param objectKey + * @param jsonObjectAcl The json format of specified object. + */ + public void setObjectAcl(String bucketName, String objectKey, String jsonObjectAcl) { + this.setObjectAcl(new SetObjectAclRequest(bucketName, objectKey, jsonObjectAcl)); + } + + /** + * Set Object Acl for specified object in the specified bucket. + * + * @param bucketName + * @param objectKey + * @param acl The CannedAccessControlList of specified object. + */ + public void setObjectAcl(String bucketName, String objectKey, CannedAccessControlList acl) { + this.setObjectAcl(new SetObjectAclRequest(bucketName, objectKey, acl)); + } + + /** + * Set Object Acl for specified object in the specified bucket. + * + * @param request The request object containing all options for setting a Bos object acl. + */ + public void setObjectAcl(SetObjectAclRequest request) { + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("acl", null); + if (request.getVersionId() != null) { + internalRequest.addParameter("versionId", request.getVersionId()); + } + + if (request.getCannedAcl() != null) { + internalRequest.addHeader(Headers.BCE_ACL, request.getCannedAcl().toString()); + this.setZeroContentLength(internalRequest); + } else if (request.getAccessControlList() != null) { + byte[] json = null; + List grants = request.getAccessControlList(); + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("accessControlList"); + for (Grant grant : grants) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("grantee"); + for (Grantee grantee : grant.getGrantee()) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("id", grantee.getId()); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeArrayFieldStart("permission"); + for (Permission permission : grant.getPermission()) { + jsonGenerator.writeString(permission.toString()); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else if (request.getJsonObjectAcl() != null) { + byte[] json = null; + try { + json = request.getJsonObjectAcl().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else if (request.getxBceGrantRead() != null) { + internalRequest.addHeader(Headers.BCE_ACL_GRANT_READ, request.getxBceGrantRead()); + this.setZeroContentLength(internalRequest); + } else if (request.getxBceGrantFullControl() != null) { + internalRequest.addHeader(Headers.BCE_ACL_GRANT_FULL_CONTROL, request.getxBceGrantFullControl()); + this.setZeroContentLength(internalRequest); + } else { + checkNotNull(null, "request.acl should not be null."); + } + this.invokeHttpClient(internalRequest, BosResponse.class); + } + + /** + * Get Object Acl for specified object in the specified bucket. + * + * @param request The request object containing all options for getting a Bos object acl. + */ + public GetObjectAclResponse getObjectAcl(GetObjectAclRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("acl", null); + if (request.getVersionId() != null) { + internalRequest.addParameter("versionId", request.getVersionId()); + } + + + GetObjectAclResponse response = this.invokeHttpClient(internalRequest, GetObjectAclResponse.class); + if (response.getVersion() > response.MAX_SUPPORTED_ACL_VERSION) { + throw new BceClientException("Unsupported acl version."); + } + return response; + } + + /** + * Delete Object Acl for specified object in the specified bucket. + * + * @param request The request object containing all options for deleting a Bos object acl. + */ + public void deleteObjectAcl(DeleteObjectAclRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter("acl", null); + this.invokeHttpClient(internalRequest, BosResponse.class); + } + + /** + * Initiates a multipart upload and returns an InitiateMultipartUploadResponse + * which contains an upload ID. This upload ID associates all the parts in + * the specific upload and is used in each of your subsequent uploadPart requests. + * You also include this upload ID in the final request to either complete, or abort the multipart + * upload request. + * + * @param bucketName The name of the Bos bucket containing the object to initiate. + * @param key The key of the object to initiate. + * @return An InitiateMultipartUploadResponse from Bos. + */ + public InitiateMultipartUploadResponse initiateMultipartUpload(String bucketName, String key) { + return this.initiateMultipartUpload(new InitiateMultipartUploadRequest(bucketName, key)); + } + + /** + * Initiates a multipart upload and returns an InitiateMultipartUploadResponse + * which contains an upload ID. This upload ID associates all the parts in + * the specific upload and is used in each of your subsequent uploadPart requests. + * You also include this upload ID in the final request to either complete, or abort the multipart + * upload request. + * + * @param request The InitiateMultipartUploadRequest object that specifies all the parameters of this operation. + * @return An InitiateMultipartUploadResponse from Bos. + */ + public InitiateMultipartUploadResponse initiateMultipartUpload(InitiateMultipartUploadRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter("uploads", null); + if (request.getStorageClass() != null) { + internalRequest.addHeader(Headers.BCE_STORAGE_CLASS, request.getStorageClass()); + } + this.setZeroContentLength(internalRequest); + + if (request.getObjectMetadata() != null) { + populateRequestMetadata(internalRequest, request.getObjectMetadata()); + } + if (!internalRequest.getHeaders().containsKey(Headers.CONTENT_TYPE)) { + internalRequest.addHeader(Headers.CONTENT_TYPE, Mimetypes.getInstance().getMimetype(request.getKey())); + } + + return this.invokeHttpClient(internalRequest, InitiateMultipartUploadResponse.class); + } + + /** + * Uploads a part in a multipart upload. You must initiate a multipart + * upload before you can upload any part. + * + * @param request The UploadPartRequest object that specifies all the parameters of this operation. + * @return An UploadPartResponse from Bos containing the part number and ETag of the new part. + */ + public UploadPartResponse uploadPart(UploadPartRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getPartSize(), "partSize should not be null"); + checkNotNull(request.getPartNumber(), "partNumber should not be null"); + + if (request.getPartSize() > 5 * 1024 * 1024 * 1024L) { + throw new BceClientException("PartNumber " + request.getPartNumber() + + " : Part Size should not be more than 5GB."); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("uploadId", request.getUploadId()); + internalRequest.addParameter("partNumber", String.valueOf(request.getPartNumber())); + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(request.getPartSize())); + if (request.getxBceCrc() != null) { + internalRequest.addHeader(Headers.BCE_CONTENT_CRC32, request.getxBceCrc()); + } + if (request.getxBceCrc32c() != null) { + internalRequest.addHeader(Headers.BCE_CONTENT_CRC32C, request.getxBceCrc32c()); + } + if (request.getxBceCrc32cFlag()) { + internalRequest.addHeader(Headers.BCE_CONTENT_CRC32C_FLAG, String.valueOf(request.getxBceCrc32cFlag())); + } + if (request.getTrafficLimitBitPS() > 0) { + internalRequest.addHeader(Headers.BOS_TRAFFIC_LIMIT, String.valueOf(request.getTrafficLimitBitPS())); + } + if (request.getProgressCallback() != null && request.getProgressCallback().getTotalSize() <= 0L) { + request.getProgressCallback().setCurrentSize(0L); + request.getProgressCallback().setTotalSize(request.getPartSize()); + } + + InputStream input = request.getInputStream(); + MD5DigestCalculatingInputStream md5DigestStream = null; + if (request.getMd5Digest() == null) { + try { + md5DigestStream = new MD5DigestCalculatingInputStream(input, request.getPartSize()); + input = md5DigestStream; + } catch (NoSuchAlgorithmException e) { + logger.warn("Unable to verify data integrity.", e); + } + } + + try { + if (request.getProgressCallback() == null) { + internalRequest.setContent(this.wrapRestartableInputStream(input, request.getPartSize())); + } else { + internalRequest.setContent(this.wrapRestartableInputStream(input, request.getPartSize(), + request.getProgressCallback())); + } + + BosResponse response = this.invokeHttpClient(internalRequest, BosResponse.class); + if (md5DigestStream != null) { + byte[] clientSideHash = md5DigestStream.getMd5Digest(); + byte[] serverSideHash; + try { + serverSideHash = Hex.decodeHex(response.getMetadata().getETag().toCharArray()); + } catch (Exception e) { + throw new BceClientException("Unable to verify integrity of data upload.", e); + } + if (!Arrays.equals(clientSideHash, serverSideHash)) { + throw new BceClientException("Unable to verify integrity of data upload. " + + "Client calculated content hash didn't match hash calculated by " + + "BOS. " + "You may need to delete the data stored in BOS."); + } + } + UploadPartResponse result = new UploadPartResponse(); + result.setETag(response.getMetadata().getETag()); + result.setPartNumber(request.getPartNumber()); + return result; + } finally { + if (input != null) { + try { + input.close(); + } catch (Exception e) { + } + } + } + } + + /** + * Uploads a copy part in a multipart upload. You must initiate a multipart + * upload before you can upload any part. + * + * @param request The UploadPartCopyRequest object that specifies all the parameters of this operation. + * @return An UploadPartCopyResponse from Bos containing the part number and ETag of the new part. + */ + public UploadPartCopyResponse uploadPartCopy(UploadPartCopyRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getPartNumber(), "partNumber should not be null"); + checkNotNull(request.getSourceBucketName(), "sourceBucketName should not be null"); + checkNotNull(request.getSourceKey(), "sourceKey should not be null"); + + if (request.getPartSize() > 5 * 1024 * 1024 * 1024L) { + throw new BceClientException("PartNumber " + request.getPartNumber() + + " : Part Size should not be more than 5GB."); + } + + String bceCopySource = "/" + request.getSourceBucketName() + "/" + request.getSourceKey(); + bceCopySource = HttpUtils.normalizePath(bceCopySource); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("uploadId", request.getUploadId()); + internalRequest.addParameter("partNumber", String.valueOf(request.getPartNumber())); + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(0)); + internalRequest.addHeader(Headers.BCE_COPY_SOURCE, bceCopySource); + if (request.getTrafficLimitBitPS() > 0) { + internalRequest.addHeader(Headers.BOS_TRAFFIC_LIMIT, String.valueOf(request.getTrafficLimitBitPS())); + } + if (request.getxBceCrc() != null) { + internalRequest.addHeader(Headers.BCE_CONTENT_CRC32, request.getxBceCrc()); + } + if (request.getxBceCrc32c() != null) { + internalRequest.addHeader(Headers.BCE_CONTENT_CRC32C, request.getxBceCrc32c()); + } + if (request.getxBceCrc32cFlag()) { + internalRequest.addHeader(Headers.BCE_CONTENT_CRC32C_FLAG, String.valueOf(request.getxBceCrc32cFlag())); + } + if (request.getPartSize() != 0) { + long offSet = request.getOffSet(); + long partSize = request.getPartSize(); + String bceCopySourceRange = "bytes" + "=" + String.valueOf(offSet) + + "-" + String.valueOf(offSet + partSize - 1); + internalRequest.addHeader(Headers.BCE_COPY_SOURCE_RANGE, bceCopySourceRange); + } + UploadPartCopyResponse response = this.invokeHttpClient(internalRequest, UploadPartCopyResponse.class); + return response; + } + + /** + * Lists the parts that have been uploaded for a specific multipart upload. + * + * @param bucketName The name of the bucket containing the multipart upload whose parts are being listed. + * @param key The key of the associated multipart upload whose parts are being listed. + * @param uploadId The ID of the multipart upload whose parts are being listed. + * @return Returns a ListPartsResponse from Bos. + */ + public ListPartsResponse listParts(String bucketName, String key, String uploadId) { + return this.listParts(new ListPartsRequest(bucketName, key, uploadId)); + } + + /** + * Lists the parts that have been uploaded for a specific multipart upload. + * + * @param request The ListPartsRequest object that specifies all the parameters of this operation. + * @return Returns a ListPartsResponse from Bos. + */ + public ListPartsResponse listParts(ListPartsRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + + if (((BosClientConfiguration) this.config).getConsistencyView() != null) { + internalRequest.addHeader(Headers.BCE_CONSISTENCY_VIEW, + ((BosClientConfiguration) this.config).getConsistencyView()); + } + + internalRequest.addParameter("uploadId", request.getUploadId()); + int maxParts = request.getMaxParts(); + if (maxParts >= 0) { + internalRequest.addParameter("maxParts", String.valueOf(maxParts)); + } + internalRequest.addParameter("partNumberMarker", String.valueOf(request.getPartNumberMarker())); + + ListPartsResponse response = this.invokeHttpClient(internalRequest, ListPartsResponse.class); + response.setBucketName(request.getBucketName()); + return response; + } + + /** + * Completes a multipart upload by assembling previously uploaded parts. + * + * @param bucketName The name of the bucket containing the multipart upload to complete. + * @param key The key of the multipart upload to complete. + * @param uploadId The ID of the multipart upload to complete. + * @param partETags The list of part numbers and ETags to use when completing the multipart upload. + * @return A CompleteMultipartUploadResponse from Bos containing the ETag for + * the new object composed of the individual parts. + */ + public CompleteMultipartUploadResponse completeMultipartUpload(String bucketName, String key, String uploadId, + List partETags) { + return this.completeMultipartUpload(new CompleteMultipartUploadRequest(bucketName, key, uploadId, partETags)); + } + + /** + * Completes a multipart upload by assembling previously uploaded parts. * * @param bucketName The name of the bucket containing the multipart upload to complete. - * @param key The key of the multipart upload to complete. - * @param uploadId The ID of the multipart upload to complete. - * @param partETags The list of part numbers and ETags to use when completing the multipart upload. - * @param metadata Additional metadata instructing Bos how to handle the uploaded data - * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @param key The key of the multipart upload to complete. + * @param uploadId The ID of the multipart upload to complete. + * @param partETags The list of part numbers and ETags to use when completing the multipart upload. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return A CompleteMultipartUploadResponse from Bos containing the ETag for + * the new object composed of the individual parts. + */ + public CompleteMultipartUploadResponse completeMultipartUpload(String bucketName, String key, String uploadId, + List partETags, ObjectMetadata metadata) { + return this.completeMultipartUpload(new CompleteMultipartUploadRequest(bucketName, key, uploadId, partETags, + metadata)); + } + + /** + * Completes a multipart upload by assembling previously uploaded parts. + * + * @param request The CompleteMultipartUploadRequest object that specifies all the parameters of this operation. * @return A CompleteMultipartUploadResponse from Bos containing the ETag for - * the new object composed of the individual parts. + * the new object composed of the individual parts. + */ + public CompleteMultipartUploadResponse completeMultipartUpload(CompleteMultipartUploadRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter("uploadId", request.getUploadId()); + + ObjectMetadata metadata = request.getObjectMetadata(); + if (metadata != null) { + populateRequestMetadata(internalRequest, metadata); + } + if (request.getxBceCrc32cFlag()) { + internalRequest.addHeader(Headers.BCE_CONTENT_CRC32C_FLAG, String.valueOf(request.getxBceCrc32cFlag())); + } + + byte[] json = null; + List partETags = request.getPartETags(); + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("parts"); + for (PartETag partETag : partETags) { + jsonGenerator.writeStartObject(); + jsonGenerator.writeNumberField("partNumber", partETag.getPartNumber()); + jsonGenerator.writeStringField("eTag", partETag.getETag()); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + + CompleteMultipartUploadResponse response = + this.invokeHttpClient(internalRequest, CompleteMultipartUploadResponse.class); + response.setBucketName(request.getBucketName()); + return response; + } + + /** + * Aborts a multipart upload. After a multipart upload is aborted, no + * additional parts can be uploaded using that upload ID. The storage + * consumed by any previously uploaded parts will be freed. However, if any + * part uploads are currently in progress, those part uploads may or may not + * succeed. As a result, it may be necessary to abort a given multipart + * upload multiple times in order to completely free all storage consumed by + * all parts. + * + * @param bucketName The name of the bucket containing the multipart upload to abort. + * @param key The key of the multipart upload to abort. + * @param uploadId The ID of the multipart upload to abort. + */ + public void abortMultipartUpload(String bucketName, String key, String uploadId) { + this.abortMultipartUpload(new AbortMultipartUploadRequest(bucketName, key, uploadId)); + } + + /** + * Aborts a multipart upload. After a multipart upload is aborted, no + * additional parts can be uploaded using that upload ID. The storage + * consumed by any previously uploaded parts will be freed. However, if any + * part uploads are currently in progress, those part uploads may or may not + * succeed. As a result, it may be necessary to abort a given multipart + * upload multiple times in order to completely free all storage consumed by + * all parts. + * + * @param request The AbortMultipartUploadRequest object that specifies all the parameters of this operation. + */ + public void abortMultipartUpload(AbortMultipartUploadRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter("uploadId", request.getUploadId()); + + this.invokeHttpClient(internalRequest, BosResponse.class); + } + + /** + * Lists in-progress multipart uploads. An in-progress multipart upload is a multipart upload that has + * been initiated, using the InitiateMultipartUpload request, but has not yet been completed or aborted. + * + * @param bucketName The name of the bucket containing the uploads to list. + * @return A ListMultipartUploadsResponse from Bos. + */ + public ListMultipartUploadsResponse listMultipartUploads(String bucketName) { + return this.listMultipartUploads(new ListMultipartUploadsRequest(bucketName)); + } + + /** + * Lists in-progress multipart uploads. An in-progress multipart upload is a multipart upload that has + * been initiated, using the InitiateMultipartUpload request, but has not yet been completed or aborted. + * + * @param request The ListMultipartUploadsRequest object that specifies all the parameters of this operation. + * @return A ListMultipartUploadsResponse from Bos. + */ + public ListMultipartUploadsResponse listMultipartUploads(ListMultipartUploadsRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("uploads", null); + String keyMarker = request.getKeyMarker(); + if (keyMarker != null) { + internalRequest.addParameter("keyMarker", keyMarker); + } + int maxUploads = request.getMaxUploads(); + if (maxUploads >= 0) { + internalRequest.addParameter("maxUploads", String.valueOf(maxUploads)); + } + String delimiter = request.getDelimiter(); + if (delimiter != null) { + internalRequest.addParameter("delimiter", delimiter); + } + String prefix = request.getPrefix(); + if (prefix != null) { + internalRequest.addParameter("prefix", prefix); + } + + ListMultipartUploadsResponse response = + this.invokeHttpClient(internalRequest, ListMultipartUploadsResponse.class); + response.setBucketName(request.getBucketName()); + return response; + } + + /** + * Populates the specified request object with the appropriate headers from the ObjectMetadata object. + * + * @param request The request to populate with headers. + * @param metadata The metadata containing the header information to include in the request. + */ + private static void populateRequestMetadata(InternalRequest request, ObjectMetadata metadata) { + if (metadata.getContentType() != null) { + request.addHeader(Headers.CONTENT_TYPE, metadata.getContentType()); + } + if (metadata.getContentMd5() != null) { + request.addHeader(Headers.CONTENT_MD5, metadata.getContentMd5()); + } + if (metadata.getContentEncoding() != null) { + request.addHeader(Headers.CONTENT_ENCODING, metadata.getContentEncoding()); + } + if (metadata.getBceContentSha256() != null) { + request.addHeader(Headers.BCE_CONTENT_SHA256, metadata.getBceContentSha256()); + } + if (metadata.getContentDisposition() != null) { + request.addHeader(Headers.CONTENT_DISPOSITION, metadata.getContentDisposition()); + } + if (metadata.getETag() != null) { + request.addHeader(Headers.ETAG, metadata.getETag()); + } + if (metadata.getExpires() != null) { + request.addHeader(Headers.EXPIRES, metadata.getExpires()); + } + if (metadata.getCacheControl() != null) { + request.addHeader(Headers.CACHE_CONTROL, metadata.getCacheControl()); + } + if (metadata.getStorageClass() != null) { + request.addHeader(Headers.BCE_STORAGE_CLASS, metadata.getStorageClass()); + } + if (metadata.getxBceAcl() != null) { + request.addHeader(Headers.BCE_ACL, String.valueOf(metadata.getxBceAcl())); + } + if (metadata.getxBceCrc() != null) { + request.addHeader(Headers.BCE_CONTENT_CRC32, metadata.getxBceCrc()); + } + if (metadata.getxBceCrc32c() != null) { + request.addHeader(Headers.BCE_CONTENT_CRC32C, metadata.getxBceCrc32c()); + } + + Map userMetadata = metadata.getUserMetadata(); + if (userMetadata != null) { + for (Entry entry : userMetadata.entrySet()) { + String key = entry.getKey(); + if (key == null) { + continue; + } + String value = entry.getValue(); + if (value == null) { + value = ""; + } + if (key.length() + value.length() > 1024 * 32) { + throw new BceClientException("MetadataTooLarge"); + } + request.addHeader(Headers.BCE_USER_METADATA_PREFIX + HttpUtils.normalize(key.trim()), + HttpUtils.normalize(value)); + } + } + } + + /** + * Creates and initializes a new request object for the specified Bos resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod) { + String bucketName = null; + String key = null; + URI uri = this.getEndpoint(); + // when custom_endpoint, bucketName should be null when set up InternalRequest. + if (bceRequest instanceof GenericBucketRequest && !((BosClientConfiguration) this.config).isCnameEnabled()) { + bucketName = ((GenericBucketRequest) bceRequest).getBucketName(); + if (this.getBktVirEndpoint(bucketName) == null) { + this.computeBktVirEndpoint(bucketName); + } + if (this.getBktVirEndpoint(bucketName) != null && + !((BosClientConfiguration) this.config).isPathStyleAccessEnable()) { + uri = this.getBktVirEndpoint(bucketName); + bucketName = null; + } + } + + if (bceRequest instanceof GenericObjectRequest) { + key = ((GenericObjectRequest) bceRequest).getKey(); + } + InternalRequest request = + new InternalRequest(httpMethod, HttpUtils.appendUri(uri, URL_PREFIX, bucketName, key)); + request.setCredentials(bceRequest.getRequestCredentials()); + request.setMaxRedirects(((BosClientConfiguration) this.config).getMaxRedirects()); + request.setRedirectsEnabled(this.config.isRedirectsEnabled()); + request.addHeader(Headers.BCE_REQUEST_ID, UUID.randomUUID().toString()); + return request; + } + + private void downloadObjectToFile(BosObject bosObject, File destinationFile, boolean verifyIntegrity, BosProgressCallback progressCallback) { + // attempt to create the parent if it doesn't exist + File parentDirectory = destinationFile.getParentFile(); + if (parentDirectory != null && !parentDirectory.exists()) { + parentDirectory.mkdirs(); + } + + OutputStream outputStream = null; + try { + outputStream = new BufferedOutputStream(new FileOutputStream(destinationFile)); + byte[] buffer = new byte[this.getStreamBufferSize()]; + int bytesRead; + if (progressCallback != null) { + progressCallback.setTotalSize(bosObject.getObjectMetadata().getContentLength()); + progressCallback.setCurrentSize(0L); + } + while ((bytesRead = bosObject.getObjectContent().read(buffer)) > -1) { + if (progressCallback != null) { + progressCallback.addCurrentSize(bytesRead); + } + outputStream.write(buffer, 0, bytesRead); + } + } catch (IOException e) { + try { + bosObject.getObjectContent().close(); + } catch (IOException abortException) { + logger.warn("Couldn't abort stream", abortException); + } + throw new BceClientException("Unable to write to disk", e); + } finally { + try { + if (outputStream != null) { + outputStream.close(); + } + } catch (Exception e) { + } + try { + bosObject.getObjectContent().close(); + } catch (Exception e) { + } + } + if (verifyIntegrity) { + byte[] serverSideHash = null; + byte[] clientSideHash = null; + ObjectMetadata objectMetadata = bosObject.getObjectMetadata(); + try { + if (objectMetadata.getBceContentSha256() != null) { + serverSideHash = Hex.decodeHex(objectMetadata.getBceContentSha256().toCharArray()); + clientSideHash = HashUtils.computeSha256Hash(new FileInputStream(destinationFile)); + } else if (objectMetadata.getContentMd5() != null) { + serverSideHash = Base64.decodeBase64(objectMetadata.getContentMd5().getBytes(DEFAULT_ENCODING)); + clientSideHash = HashUtils.computeMd5Hash(new FileInputStream(destinationFile)); + } + } catch (Exception e) { + logger.warn("Unable to verify the integrity of the downloaded file", e); + } + if (serverSideHash != null && clientSideHash != null && !Arrays.equals(clientSideHash, serverSideHash)) { + throw new BceClientException("Integrity verification failed! " + + "Client calculated content hash didn't match hash from server. " + + "The data stored in '" + destinationFile.getAbsolutePath() + "' may be corrupt."); + } + } + } + + private List readAll(InputStream input, ObjectMetadata metadata) { + List result = Lists.newArrayList(); + int bufferSize = this.getStreamBufferSize(); + long length = 0; + for (; ; ) { + byte[] buffer = new byte[bufferSize]; + result.add(buffer); + int off = 0; + while (off < bufferSize) { + int count; + try { + count = input.read(buffer, off, bufferSize - off); + } catch (IOException e) { + throw new BceClientException("Fail to read data.", e); + } + if (count < 0) { + metadata.setContentLength(length); + return result; + } + length += count; + off += count; + } + } + } + + private RestartableInputStream wrapRestartableInputStream(InputStream input) { + if (input.markSupported()) { + return new RestartableResettableInputStream(input); + } else { + return new RestartableNonResettableInputStream(input, this.getStreamBufferSize()); + } + } + + private RestartableInputStream wrapRestartableInputStream(InputStream input, BosProgressCallback progressCallback) { + if (input.markSupported()) { + return new RestartableResettableInputStream(input, progressCallback); + } else { + return new RestartableNonResettableInputStream(input, this.getStreamBufferSize(), progressCallback); + } + } + + private RestartableInputStream wrapRestartableInputStream(InputStream input, Long bufferSize) { + if (input.markSupported()) { + return new RestartableResettableInputStream(input); + } else { + int size = bufferSize > this.getStreamBufferSize() ? this.getStreamBufferSize() : bufferSize.intValue(); + return new RestartableNonResettableInputStream(input, size); + } + } + + private RestartableInputStream wrapRestartableInputStream(InputStream input, Long bufferSize, + BosProgressCallback progressCallback) { + if (input.markSupported()) { + return new RestartableResettableInputStream(input, progressCallback); + } else { + int size = bufferSize > this.getStreamBufferSize() ? this.getStreamBufferSize() : bufferSize.intValue(); + return new RestartableNonResettableInputStream(input, size, progressCallback); + } + } + + private void setZeroContentLength(InternalRequest req) { + req.addHeader(Headers.CONTENT_LENGTH, String.valueOf(0)); + } + + private int getStreamBufferSize() { + return ((BosClientConfiguration) this.config).getStreamBufferSize(); + } + + /** + * Asserts that the specified parameter value is not null or empty and if it is, + * throws an IllegalArgumentException with the specified error message. + * + * @param parameterValue The parameter value being checked. + * @param errorMessage The error message to include in the IllegalArgumentException + * if the specified parameter is null. + */ + private void assertStringNotNullOrEmpty(String parameterValue, String errorMessage) { + if (parameterValue == null) { + throw new IllegalArgumentException(errorMessage); + } + if (parameterValue.isEmpty()) { + throw new IllegalArgumentException(errorMessage); + } + } + + /** + * Adds response headers parameters to the request given, if non-null. + * + * @param request The request to add the response header parameters to. + * @param responseHeaders The full set of response headers to add, or null for none. + */ + private void addResponseHeaderParameters(InternalRequest request, ResponseHeaderOverrides responseHeaders) { + if (responseHeaders != null) { + if (responseHeaders.getCacheControl() != null) { + request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CACHE_CONTROL, + responseHeaders.getCacheControl()); + } + if (responseHeaders.getContentDisposition() != null) { + request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_DISPOSITION, + responseHeaders.getContentDisposition()); + } + if (responseHeaders.getContentEncoding() != null) { + request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_ENCODING, + responseHeaders.getContentEncoding()); + } + if (responseHeaders.getContentLanguage() != null) { + request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_LANGUAGE, + responseHeaders.getContentLanguage()); + } + if (responseHeaders.getContentType() != null) { + request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_TYPE, + responseHeaders.getContentType()); + } + if (responseHeaders.getExpires() != null) { + request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_EXPIRES, responseHeaders.getExpires()); + } + } + } + + /** + * Converts the specified request object into a URL, containing all the + * specified parameters, the specified request endpoint, etc. + * + * @param request The request to convert into a URL. + * @return A new URL representing the specified request. + */ + private URL convertRequestToUrl(InternalRequest request) { + String resourcePath = HttpUtils.normalizePath(request.getUri().getPath()); + + // Removed the padding "/" that was already added into the request's resource path. + if (resourcePath.startsWith("/")) { + resourcePath = resourcePath.substring(1); + } + + // Some http client libraries (e.g. Apache HttpClient) cannot handle + // consecutive "/"s between URL authority and path components. + // So we escape "////..." into "/%2F%2F%2F...", in the same way as how + // we treat consecutive "/"s in AmazonS3Client#presignRequest(...) + String urlPath = "/" + resourcePath; + urlPath = urlPath.replaceAll("(?<=/)/", "%2F"); +// String urlString = this.getEndpoint() + urlPath; + String port = ""; + if (request.getUri().getPort() != -1) { + port = ":" + request.getUri().getPort(); + } + String urlString = request.getUri().getScheme() + "://" + request.getUri().getHost() + port + urlPath; + + boolean firstParam = true; + for (String param : request.getParameters().keySet()) { + if (firstParam) { + urlString += "?"; + firstParam = false; + } else { + urlString += "&"; + } + + String value = request.getParameters().get(param); + urlString += HttpUtils.normalize(param) + "=" + HttpUtils.normalize(value); + } + + String authorization = request.getHeaders().get(Headers.AUTHORIZATION); + if (authorization != null) { + if (firstParam) { + urlString += "?"; + } else { + urlString += "&"; + } + urlString += "authorization" + "=" + HttpUtils.normalize(authorization); + } + + try { + return new URL(urlString); + } catch (MalformedURLException e) { + throw new BceClientException("Unable to convert request to well formed URL: " + e.getMessage(), e); + } + } + + /** + * Uploads the specified appendable file to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param file The appendable file containing the data to be uploaded to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, File file) { + return this.appendObject(new AppendObjectRequest(bucketName, key, file)); + } + + /** + * Uploads the specified appendable file to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param file The file containing the data to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, File file, ObjectMetadata metadata) { + return this.appendObject(new AppendObjectRequest(bucketName, key, file, metadata)); + } + + /** + * Uploads the specified string to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The string containing the value to be uploaded to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, String value) { + try { + return this.appendObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), new ObjectMetadata()); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get bytes.", e); + } + } + + /** + * Uploads the specified string and object metadata to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The string containing the value to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, String value, ObjectMetadata metadata) { + try { + return this.appendObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), metadata); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get bytes.", e); + } + } + + /** + * Uploads the specified bytes to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The bytes containing the value to be uploaded to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, byte[] value) { + return this.appendObject(bucketName, key, value, new ObjectMetadata()); + } + + /** + * Uploads the appendable bytes and object metadata to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The bytes containing the value to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject( + String bucketName, String key, byte[] value, ObjectMetadata metadata) { + checkNotNull(metadata, "metadata should not be null."); + if (metadata.getContentLength() == -1) { + metadata.setContentLength(value.length); + } + return this.appendObject( + new AppendObjectRequest(bucketName, key, RestartableInputStream.wrap(value), metadata)); + } + + /** + * Uploads the appendable input stream to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param input The input stream containing the value to be uploaded to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, InputStream input) { + return this.appendObject(new AppendObjectRequest(bucketName, key, input)); + } + + /** + * Uploads the appendable input stream and object metadata to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param input The input stream containing the value to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject( + String bucketName, String key, InputStream input, ObjectMetadata metadata) { + return this.appendObject(new AppendObjectRequest(bucketName, key, input, metadata)); + } + + /** + * Uploads a new object to the specified Bos bucket. The AppendObjectRequest contains all the + * details of the request, including the bucket to upload to, the key the object will be uploaded under, + * and the file or input stream containing the data to upload. + * + * @param request The request object containing all the parameters to upload a new appendable object to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(AppendObjectRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter("append", null); + if (request.getOffset() != null) { + internalRequest.addParameter("offset", request.getOffset().toString()); + } + BosResponse response = uploadObject(request, internalRequest); + AppendObjectResponse result = new AppendObjectResponse(); + result.setNextAppendOffset(response.getMetadata().getNextAppendOffset()); + result.setContentMd5(response.getMetadata().getContentMd5()); + result.setETag(response.getMetadata().getETag()); + return result; + } + + /** + * Restore an archive object to the specified Bos bucket + * + * @param bucketName The name of rsestore an archive object. + * @param key The key of rsestore an archive object. + */ + public void restoreObject(String bucketName, String key) { + restoreObject(new RestoreObjectRequest(bucketName, key)); + } + + /** + * Restore an archive object to the specified Bos bucket + * + * @param bucketName The name of rsestore an archive object. + * @param key The key of rsestore an archive object. + * @param restoreDays The times after restore an archive object. + * @param restoreTier The speed of rsestore an archive object. + */ + public void restoreObject(String bucketName, String key, int restoreDays, String restoreTier) { + restoreObject(new RestoreObjectRequest(bucketName, key, restoreDays, restoreTier)); + } + + + /** + * Restore an archive object to the specified Bos bucket + * + * @param request The request object containing all the parameters to restore an archive object + */ + public void restoreObject(RestoreObjectRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + if (request.getRestoreDays() != null && request.getRestoreDays() <= 0) { + throw new BceClientException("invalid restore days"); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter("restore", null); + if (request.getRestoreDays() != null) { + internalRequest.addHeader(Headers.BCE_RESTORE_DAYS, Integer.toString(request.getRestoreDays())); + } + if (request.getRestoreTier() != null) { + internalRequest.addHeader(Headers.BCE_RESTORE_TIER, request.getRestoreTier()); + } + this.setZeroContentLength(internalRequest); + this.invokeHttpClient(internalRequest, BosResponse.class); + } + + /** + * Set bucket encryption + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param encryption The encryption of bucket + */ + public void setBucketEncryption(String bucketName, BucketEncryption encryption) { + this.setBucketEncryption(new SetBucketEncryptionRequest(bucketName, encryption)); + } + + /** + * Set bucket encryption + */ + public void setBucketEncryption(SetBucketEncryptionRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter(Constants.ENCRYPTION, null); + + if (request.getJsonBucketEncryption() != null) { + byte[] json = null; + try { + json = request.getJsonBucketEncryption().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else { + byte[] json = null; + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + if (request.getBucketEncryption() != null) { + jsonGenerator.writeStringField("encryptionAlgorithm", request.getBucketEncryption(). + getEncryptionAlgorithm()); + } + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } + this.invokeHttpClient(internalRequest, BosResponse.class); + } + + /** + * Get Bucket Encryption + * + * @param bucketName The name of an existing bucket + * @return + */ + public GetBucketEncryptionResponse getBucketEncryption(String bucketName) { + return this.getBucketEncryption(new GetBucketEncryptionRequest(bucketName)); + } + + /** + * Get Bucket Encryption + * + * @param request + * @return + */ + public GetBucketEncryptionResponse getBucketEncryption(GetBucketEncryptionRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter(Constants.ENCRYPTION, null); + GetBucketEncryptionResponse response = this.invokeHttpClient(internalRequest, + GetBucketEncryptionResponse.class); + return response; + } + + /** + * Delete Bucket Encryption + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + */ + public void deleteBucketEncryption(String bucketName) { + this.deleteBucketEncryption(new DeleteBucketEncryptionRequest(bucketName)); + } + + /** + * Delete Bucket Encryption + * + * @param request + */ + public void deleteBucketEncryption(DeleteBucketEncryptionRequest request) { + checkNotNull(request, "request should not be null"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter(Constants.ENCRYPTION, null); + this.invokeHttpClient(internalRequest, BosResponse.class); + + } + + /** + * Set bucket website + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param index The index page for staticwebsite + * @param notfound The notFound page for staticwebsite + */ + public void setBucketStaticWebSite(String bucketName, String index, String notfound) { + this.setBucketStaticWebSite(new SetBucketStaticWebsiteRequest(bucketName, index, notfound)); + } + + /** + * Set bucket website + * + * @param request + */ + public void setBucketStaticWebSite(SetBucketStaticWebsiteRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter(Constants.WEBSITE, null); + if (request.getJsonBucketStaticWebsite() != null) { + byte[] json = null; + try { + json = request.getJsonBucketStaticWebsite().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else { + byte[] json = null; + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + if (request.getIndex() != null) { + jsonGenerator.writeStringField("index", request.getIndex()); + } + if (request.getNotFound() != null) { + jsonGenerator.writeStringField("notFound", request.getNotFound()); + } + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } + this.invokeHttpClient(internalRequest, BosResponse.class); + } + + /** + * Get bucket static website + * + * @param bucketName The name of an existing bucket, to which you have Read permission. + * @return + */ + public GetBucketStaticWebsiteResponse getBucketStaticWebsite(String bucketName) { + return this.getBucketStaticWebsite(new GetBucketStaticWebsiteRequest(bucketName)); + } + + /** + * Get bucket static website + * + * @param request + * @return + */ + public GetBucketStaticWebsiteResponse getBucketStaticWebsite(GetBucketStaticWebsiteRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter(Constants.WEBSITE, null); + GetBucketStaticWebsiteResponse response = this.invokeHttpClient(internalRequest, + GetBucketStaticWebsiteResponse.class); + return response; + } + + /** + * Delete bucket static website + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + */ + public void deleteBucketStaticWebSite(String bucketName) { + this.deleteBucketStaticWebSite(new DeleteBucketStaticWebsiteRequest(bucketName)); + } + + /** + * Delete bucket static website + * + * @param request + * @return + */ + public void deleteBucketStaticWebSite(DeleteBucketStaticWebsiteRequest request) { + checkNotNull(request, "request should not be null"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter(Constants.WEBSITE, null); + this.invokeHttpClient(internalRequest, BosResponse.class); + } + + /** + * Set bucket CopyrightProtection + * + * @param bucketName The name of an existing bucket, to which you have Write permission + * @param resources The resourceList of Bucket CopyrightProtection + */ + public void setBucketCopyrightProtection(String bucketName, List resources) { + this.setBucketCopyrightProtection(new SetBucketCopyrightProtectionRequest(bucketName, resources)); + } + + /** + * Set bucket CopyrightProtection + */ + public void setBucketCopyrightProtection(SetBucketCopyrightProtectionRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter(Constants.COPYRIGHTPROTECTION, null); + if (request.getJsonBucketCopyrightProtection() != null) { + byte[] json = null; + try { + json = request.getJsonBucketCopyrightProtection().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } else { + byte[] json = null; + StringWriter writer = new StringWriter(); + List resources = request.getResource(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeArrayFieldStart("resource"); + if (resources != null) { + for (String resource : resources) { + jsonGenerator.writeString(resource); + } + } + jsonGenerator.writeEndArray(); + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } + this.invokeHttpClient(internalRequest, BosResponse.class); + } + + /** + * Get bucket copyrightprotection + * + * @param bucketName The name of an existing bucket, to which you have Read permission + * @return */ - public CompleteMultipartUploadResponse completeMultipartUpload(String bucketName, String key, String uploadId, - List partETags, ObjectMetadata metadata) { - return this.completeMultipartUpload(new CompleteMultipartUploadRequest(bucketName, key, uploadId, partETags, - metadata)); + public GetBucketCopyrightProtectionResponse getBucketCopyrightProtection(String bucketName) { + return this.getBucketCopyrightProtection(new GetBucketCopyrightProtectionRequest(bucketName)); } /** - * Completes a multipart upload by assembling previously uploaded parts. + * Get bucket copyrightprotection * - * @param request The CompleteMultipartUploadRequest object that specifies all the parameters of this operation. - * @return A CompleteMultipartUploadResponse from Bos containing the ETag for - * the new object composed of the individual parts. + * @param request + * @return */ - public CompleteMultipartUploadResponse completeMultipartUpload(CompleteMultipartUploadRequest request) { + public GetBucketCopyrightProtectionResponse getBucketCopyrightProtection(GetBucketCopyrightProtectionRequest + request) { checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter(Constants.COPYRIGHTPROTECTION, null); + GetBucketCopyrightProtectionResponse response = this.invokeHttpClient(internalRequest, + GetBucketCopyrightProtectionResponse.class); + return response; + } - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); - internalRequest.addParameter("uploadId", request.getUploadId()); + /** + * Delete Bucket copyrightprotection + * + * @param bucketName The name of an existing bucket, to which you have Write permission + */ + public void deleteBucketCopyrightProtection(String bucketName) { + this.deleteBucketCopyrightProtection(new DeleteBucketCopyrightProtectionRequest(bucketName)); + } + + /** + * Delete Bucket copyrightprotection + * + * @param request + */ + public void deleteBucketCopyrightProtection(DeleteBucketCopyrightProtectionRequest request) { + checkNotNull(request, "request should not be null"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter(Constants.COPYRIGHTPROTECTION, null); + this.invokeHttpClient(internalRequest, BosResponse.class); + } + /** + * Uploads a object to Bos bucket. The PutObjcetRequest contains all the details of the request.The internalRequest + * represents a request being send to a BCE Service. + * + * @param request The request object containing all the parameters to upload a new appendable object to Bos. + * @param internalRequest Represents a request being sent to a BCE Service, including the parameters being + * sent as part of the request, the endpoint to which the request should be sent, etc. + * @return A BosResponse object containing the bos-metadata information returned by Bos for the newly created + * object + */ + private BosResponse uploadObject(PutObjectRequest request, InternalRequest internalRequest) { ObjectMetadata metadata = request.getObjectMetadata(); - if (metadata != null) { - populateRequestMetadata(internalRequest, metadata); + InputStream input = request.getInputStream(); + if (request.getFile() != null) { + File file = request.getFile(); + + if (file.length() > 5 * 1024 * 1024 * 1024L) { + BceServiceException bse = new BceServiceException("Your proposed upload exceeds the maximum allowed " + + "object size."); + bse.setStatusCode(400); + bse.setErrorCode("EntityTooLarge"); + bse.setErrorType(BceServiceException.ErrorType.Client); + throw bse; + } + + // Always set the content length, even if it's already set + if (metadata.getContentLength() < 0) { + metadata.setContentLength(file.length()); + } + + if (metadata.getContentType() == null) { + metadata.setContentType(Mimetypes.getInstance().getMimetype(file)); + } + + if (metadata.getContentLength() == file.length()) { + FileInputStream fileInputStream = null; + try { + fileInputStream = new FileInputStream(file); + metadata.setBceContentSha256( + new String(Hex.encodeHex(HashUtils.computeSha256Hash(fileInputStream)))); + } catch (Exception e) { + throw new BceClientException("Unable to calculate SHA-256 hash", e); + } finally { + try { + if (fileInputStream != null) { + fileInputStream.close(); + } + } catch (Exception e) { + logger.warn("The inputStream accured error"); + } + } + } + try { + if (request.getProgressCallback() == null) { + internalRequest.setContent(new RestartableFileInputStream(file)); + } else { + internalRequest.setContent(new RestartableFileInputStream(file, request.getProgressCallback())); + } + } catch (FileNotFoundException e) { + throw new BceClientException("Unable to find file to upload", e); + } + } else { + checkNotNull(input, "Either file or inputStream should be set."); + if (metadata.getContentLength() < 0) { + logger.warn("No content length specified for stream data. Trying to read them all into memory."); + List data = this.readAll(input, metadata); + if (request.getProgressCallback() == null) { + internalRequest.setContent(new RestartableMultiByteArrayInputStream(data, + metadata.getContentLength())); + } else { + internalRequest.setContent(new RestartableMultiByteArrayInputStream(data, + metadata.getContentLength(), request.getProgressCallback())); + } + + } else if (input instanceof RestartableInputStream) { + internalRequest.setContent((RestartableInputStream) input); + } else { + if (request.getProgressCallback() == null) { + internalRequest.setContent(this.wrapRestartableInputStream(input)); + } else { + internalRequest.setContent(this.wrapRestartableInputStream(input, request.getProgressCallback())); + } + } + if (metadata.getContentType() == null) { + metadata.setContentType(Mimetypes.getInstance().getMimetype(request.getKey())); + } + } + if (request.getProgressCallback() != null && request.getProgressCallback().getTotalSize() <= 0L) { + request.getProgressCallback().setCurrentSize(0L); + request.getProgressCallback().setTotalSize(metadata.getContentLength()); } - byte[] json = null; - List partETags = request.getPartETags(); - StringWriter writer = new StringWriter(); + if (request.getStorageClass() != null) { + metadata.setStorageClass(request.getStorageClass()); + } + + if (request.getTrafficLimitBitPS() > 0) { + internalRequest.addHeader(Headers.BOS_TRAFFIC_LIMIT, String.valueOf(request.getTrafficLimitBitPS())); + } + + if (request.getVideoProcess() != null) { + internalRequest.addHeader(Headers.BOS_PROCESS, request.getVideoProcess()); + } + + if (request.getxBceAcl() != null) { + internalRequest.addHeader(Headers.BCE_ACL, request.getxBceAcl()); + } + + if (request.getxBceCrc32cFlag()) { + internalRequest.addHeader(Headers.BCE_CONTENT_CRC32C_FLAG, String.valueOf(request.getxBceCrc32cFlag())); + } + + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(metadata.getContentLength())); + internalRequest.addParameter(Headers.BOS_PROCESS, request.getxBceProcess()); + + populateRequestMetadata(internalRequest, metadata); + + BosResponse response; try { - JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); - jsonGenerator.writeStartObject(); - jsonGenerator.writeArrayFieldStart("parts"); - for (PartETag partETag : partETags) { - jsonGenerator.writeStartObject(); - jsonGenerator.writeNumberField("partNumber", partETag.getPartNumber()); - jsonGenerator.writeStringField("eTag", partETag.getETag()); - jsonGenerator.writeEndObject(); + response = this.invokeHttpClient(internalRequest, BosResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + logger.warn("Fail to close input stream", e); } - jsonGenerator.writeEndArray(); - jsonGenerator.writeEndObject(); - jsonGenerator.close(); - } catch (IOException e) { - throw new BceClientException("Fail to generate json", e); } + return response; + } + + /** + * The Encapsulation of three-step upload when put Super Object from file + * + * @param file super object + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param objectKey The key under which to store the specified file. + * @return + */ + public boolean putSuperObjectFromFile(File file, String bucketName, String objectKey) { + int processors = Runtime.getRuntime().availableProcessors(); + return putSuperObjectFromFile(new PutSuperObjectRequest(bucketName, objectKey, file, CHUNK_SIZE, processors)); + } + + /** + * The Encapsulation of three-step upload when put Super Object from file + * + * @param file super object + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param objectKey The key under which to store the specified file. + * @param chunksize the part size when upload super object file + * @return + */ + public boolean putSuperObjectFromFile(File file, String bucketName, String objectKey, long chunksize) { + int processors = Runtime.getRuntime().availableProcessors(); + return putSuperObjectFromFile(new PutSuperObjectRequest(bucketName, objectKey, file, chunksize, processors)); + } + + /** + * The Encapsulation of three-step upload when put Super Object from file + * + * @param file super object + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param objectKey The key under which to store the specified file. + * @param nThreads The num of threads in thread pool + * @return + */ + public boolean putSuperObjectFromFile(File file, String bucketName, String objectKey, + int nThreads) { + return putSuperObjectFromFile(new PutSuperObjectRequest(bucketName, objectKey, file, CHUNK_SIZE, nThreads)); + } + + /** + * The Encapsulation of three-step upload when put Super Object from file + * + * @param file super object + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param objectKey The key under which to store the specified file. + * @param chunksize the part size when upload super object file + * @param nThreads The num of threads in thread pool + * @return + */ + public boolean putSuperObjectFromFile(File file, String bucketName, String objectKey, long chunksize, + int nThreads) { + return putSuperObjectFromFile(new PutSuperObjectRequest(bucketName, objectKey, file, chunksize, nThreads)); + } + + public boolean putSuperObjectFromFile(PutSuperObjectRequest putSuperObjectRequest) { + boolean success = true; + File file = putSuperObjectRequest.getFile(); + long chunksize = putSuperObjectRequest.getChunkSize(); + if (chunksize <= 0) { + throw new BceClientException("the chunksize must be greater than 0"); + } + String bucketName = putSuperObjectRequest.getBucketName(); + String objectKey = putSuperObjectRequest.getKey(); + int nThreads = putSuperObjectRequest.getnThreads(); + AtomicBoolean isSuperObjectUploadCanced = putSuperObjectRequest.getIsSuperObjectUploadCanced(); + long fileLength = file.length(); + int parts = (int) (fileLength / chunksize); + if (fileLength % chunksize > 0) { + parts++; + } + if (parts > Constants.MAX_PARTS) { + throw new BceClientException("Total parts count should not exceed 10000"); + } + if (putSuperObjectRequest.getProgressCallback() != null && + putSuperObjectRequest.getProgressCallback().getTotalSize() <= 0L) { + putSuperObjectRequest.getProgressCallback().setCurrentSize(0L); + putSuperObjectRequest.getProgressCallback().setTotalSize(fileLength); + } + + // Get upload id + InitiateMultipartUploadRequest initiateMultipartUploadRequest = + new InitiateMultipartUploadRequest(bucketName, objectKey); + initiateMultipartUploadRequest.setObjectMetadata(putSuperObjectRequest.getObjectMetadata()); + String uploadId = initiateMultipartUpload(initiateMultipartUploadRequest).getUploadId(); + putSuperObjectRequest.setUploadId(uploadId); + ExecutorService pool = Executors.newFixedThreadPool(nThreads); + List> futures = new ArrayList>(); + List partETags = Collections.synchronizedList(new ArrayList()); + for (int i = 0; i < parts; i++) { + futures.add(pool.submit(new UploadPartTask(this, putSuperObjectRequest, i, partETags))); + } + // wait all part completed + for (int i = 0; i < futures.size(); i++) { + Future future = futures.get(i); + try { + if (future.get()) { + logger.debug("The upload task [ " + i + "] completed."); + } else { + logger.error("The upload task [ " + i + "] failed."); + success = false; + break; + } + } catch (Exception e) { + success = false; + break; + } + } + pool.shutdown(); try { - json = writer.toString().getBytes(DEFAULT_ENCODING); - } catch (UnsupportedEncodingException e) { - throw new BceClientException("Fail to get UTF-8 bytes", e); + if (!pool.awaitTermination(500, TimeUnit.MILLISECONDS)) { + pool.shutdownNow(); + } + } catch (InterruptedException e) { + throw new BceClientException("close thread pool fail exception", e); + } + if (isSuperObjectUploadCanced.get() || partETags.size() != parts) { + success = false; + } + if (success) { + Collections.sort(partETags, new Comparator() { + @Override + public int compare(PartETag a, PartETag b) { + return a.getPartNumber() - b.getPartNumber(); + } + }); + CompleteMultipartUploadRequest completeMultipartUploadRequest = + new CompleteMultipartUploadRequest(bucketName, objectKey, uploadId, partETags); + completeMultipartUploadRequest.setxBceCrc32cFlag(putSuperObjectRequest.getxBceCrc32cFlag()); + CompleteMultipartUploadResponse response = completeMultipartUpload(completeMultipartUploadRequest); + logger.debug("Success to upload file: " + file.getAbsolutePath() + " to BOS with ETag: " + + response.getETag()); + } else { + AbortMultipartUploadRequest abortMultipartUploadRequest = + new AbortMultipartUploadRequest(bucketName, objectKey, uploadId); + abortMultipartUpload(abortMultipartUploadRequest); + logger.error("Failed to upload file: " + file.getAbsolutePath()); + } + return success; + } + + public boolean uploadFilePart(PutSuperObjectRequest putSuperObjectRequest, int partNum, List partETags) { + int tryCount = 3; + File file = putSuperObjectRequest.getFile(); + long chunksize = putSuperObjectRequest.getChunkSize(); + String bucketName = putSuperObjectRequest.getBucketName(); + String objectKey = putSuperObjectRequest.getKey(); + String uploadId = putSuperObjectRequest.getUploadId(); + AtomicBoolean isCancel = putSuperObjectRequest.getIsSuperObjectUploadCanced(); + while (tryCount > 0) { + if (isCancel.get()) { + break; + } + FileInputStream fis = null; + try { + fis = new FileInputStream(file); + long skipBytes = chunksize * partNum; + fis.skip(skipBytes); + long partSize = (chunksize < file.length() - skipBytes) ? chunksize : file.length() - skipBytes; + UploadPartRequest uploadPartRequest = new UploadPartRequest(); + uploadPartRequest.setBucketName(bucketName); + uploadPartRequest.setKey(objectKey); + uploadPartRequest.setUploadId(uploadId); + uploadPartRequest.setInputStream(fis); + uploadPartRequest.setPartSize(partSize); + uploadPartRequest.setPartNumber(partNum + 1); + if (putSuperObjectRequest.getxBceCrc32cFlag()) { + uploadPartRequest.setxBceCrc32cFlag(putSuperObjectRequest.getxBceCrc32cFlag()); + } + if (putSuperObjectRequest.getProgressCallback() != null) { + uploadPartRequest.setProgressCallback(putSuperObjectRequest.getProgressCallback()); + } + if (putSuperObjectRequest.getTrafficLimitBitPS() > 0) { + uploadPartRequest.setTrafficLimitBitPS(putSuperObjectRequest.getTrafficLimitBitPS()); + } + if (isCancel.get()) { // if exist threads to uploadPart, may the uploadId is invalid + break; + } + UploadPartResponse uploadPartResponse = uploadPart(uploadPartRequest); + partETags.add(uploadPartResponse.getPartETag()); + logger.debug("Complete upload with ETag: " + uploadPartResponse.getPartETag()); + } catch (IOException e) { + logger.error("Failed to upload the part " + partNum + " [tryCount] = " + tryCount); + tryCount--; + continue; + } finally { + if (fis != null) { + try { + fis.close(); + } catch (Exception e) { + // ignore + } + } + } + if (tryCount > 0) { + break; + } + } + if (isCancel.get()) { + logger.info("Request is canceled"); + } else if (tryCount == 0) { + logger.error("Failed to upload the part " + partNum); + } else { + logger.info("Success to upload the part " + partNum); + } + return (tryCount > 0 && !isCancel.get()); + } + + private static class UploadPartTask implements Callable { + BosClient client; + PutSuperObjectRequest putSuperObjectRequest; + int partNum; + List partETags; + + UploadPartTask(BosClient client, PutSuperObjectRequest putSuperObjectRequest, int partNum, + List partETags) { + this.client = client; + this.putSuperObjectRequest = putSuperObjectRequest; + this.partNum = partNum; + this.partETags = partETags; + } + + @Override + public Boolean call() { + return client.uploadFilePart(putSuperObjectRequest, partNum, partETags); } + } + public SelectObjectResponse selectObject(SelectObjectRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + assertStringNotNullOrEmpty(request.getSelectType(), "selectType should not be null or empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter("select", null); + internalRequest.addParameter("type", request.getSelectType()); + // compose request body + byte[] json; + json = request.buildBody(); internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); - internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json"); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); internalRequest.setContent(RestartableInputStream.wrap(json)); - - CompleteMultipartUploadResponse response = - this.invokeHttpClient(internalRequest, CompleteMultipartUploadResponse.class); - response.setBucketName(request.getBucketName()); + SelectObjectResponse response = this.invokeHttpClient(internalRequest, SelectObjectResponse.class); + ; + if (request.getOutputValue(Constants.RECORD_DELIMITER) != null) { + response.setRecordDelimiter(request.getOutputValue(Constants.RECORD_DELIMITER)); + } + // Parsing query results + response.initMessages(response.getObject()); return response; } + public StateSummaryResponse stateSummary(String bucketName) { + return stateSummary(new StateSummaryRequest(bucketName)); + } + + public StateSummaryResponse stateSummary(String bucketName, String prefix) { + return stateSummary((new StateSummaryRequest(bucketName, prefix))); + } + + public StateSummaryResponse stateSummary(StateSummaryRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getBucketName(), "BucketName should not be null or empty"); + + long[] summary = new long[]{0L, 0L, 0L}; // length, objectCount, fileCount + String prefix = request.getPrefix(); + String priorLastKey = null; + String bucketName = request.getBucketName(); + + ListObjectsRequest r = new ListObjectsRequest(bucketName); + r.setDelimiter(null); + r.setPrefix(prefix); + ListObjectsResponse objects = null; + + // list objects + do { + r.setMarker(priorLastKey); + objects = this.listObjects(r); + for (BosObjectSummary object : objects.getContents()) { + if (object.getKey() != null && object.getKey().length() > 0) { + summary[0] += object.getSize(); // size + summary[1] += 1; // objectsCount + summary[2] += object.getKey().endsWith("/") ? 0 : 1; // filesCount + } + } + priorLastKey = objects.getNextMarker(); + } while (priorLastKey != null && priorLastKey.length() > 0); + + return new StateSummaryResponse(bucketName, prefix, summary[0], summary[1], summary[2]); + } + /** - * Aborts a multipart upload. After a multipart upload is aborted, no - * additional parts can be uploaded using that upload ID. The storage - * consumed by any previously uploaded parts will be freed. However, if any - * part uploads are currently in progress, those part uploads may or may not - * succeed. As a result, it may be necessary to abort a given multipart - * upload multiple times in order to completely free all storage consumed by - * all parts. + * Gets the res whether the bucket exists, bucket type * - * @param bucketName The name of the bucket containing the multipart upload to abort. - * @param key The key of the multipart upload to abort. - * @param uploadId The ID of the multipart upload to abort. + * @param bucketName The name of the checked bucket + * @return The HeadBucketResponse for the specified Bos bucket. */ - public void abortMultipartUpload(String bucketName, String key, String uploadId) { - this.abortMultipartUpload(new AbortMultipartUploadRequest(bucketName, key, uploadId)); + public HeadBucketResponse headBucket(String bucketName) { + return this.headBucket(new HeadBucketRequest(bucketName)); } /** - * Aborts a multipart upload. After a multipart upload is aborted, no - * additional parts can be uploaded using that upload ID. The storage - * consumed by any previously uploaded parts will be freed. However, if any - * part uploads are currently in progress, those part uploads may or may not - * succeed. As a result, it may be necessary to abort a given multipart - * upload multiple times in order to completely free all storage consumed by - * all parts. + * Gets the res whether the bucket exists, bucket type * - * @param request The AbortMultipartUploadRequest object that specifies all the parameters of this operation. + * @param request containing the name the checked bucket + * @return The HeadBucketResponse for the specified Bos bucket. */ - public void abortMultipartUpload(AbortMultipartUploadRequest request) { + public HeadBucketResponse headBucket(HeadBucketRequest request) { checkNotNull(request, "request should not be null."); - - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); - internalRequest.addParameter("uploadId", request.getUploadId()); - - this.invokeHttpClient(internalRequest, BosResponse.class); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.HEAD); + HeadBucketResponse response = this.invokeHttpClient(internalRequest, HeadBucketResponse.class); + return response; } /** - * Lists in-progress multipart uploads. An in-progress multipart upload is a multipart upload that has - * been initiated, using the InitiateMultipartUpload request, but has not yet been completed or aborted. + * Gets the Bos bucket mirroring description. * - * @param bucketName The name of the bucket containing the uploads to list. - * @return A ListMultipartUploadsResponse from Bos. + * @param bucketName The name of an existing bucket, to which you have permission + * @return The GetBucketMirroringResponse for the Bos bucket. */ - public ListMultipartUploadsResponse listMultipartUploads(String bucketName) { - return this.listMultipartUploads(new ListMultipartUploadsRequest(bucketName)); + public GetBucketMirroringResponse getBucketMirroring(String bucketName) { + return this.getBucketMirroring(new GetBucketMirroringRequest(bucketName)); } /** - * Lists in-progress multipart uploads. An in-progress multipart upload is a multipart upload that has - * been initiated, using the InitiateMultipartUpload request, but has not yet been completed or aborted. + * Gets the Bos bucket mirroring description. * - * @param request The ListMultipartUploadsRequest object that specifies all the parameters of this operation. - * @return A ListMultipartUploadsResponse from Bos. + * @param request The GetBucketMirroringRequest you create + * @return The GetBucketMirroringResponse for the Bos bucket. */ - public ListMultipartUploadsResponse listMultipartUploads(ListMultipartUploadsRequest request) { + public GetBucketMirroringResponse getBucketMirroring(GetBucketMirroringRequest request) { checkNotNull(request, "request should not be null."); InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); - internalRequest.addParameter("uploads", null); - String keyMarker = request.getKeyMarker(); - if (keyMarker != null) { - internalRequest.addParameter("keyMarker", keyMarker); - } - int maxUploads = request.getMaxUploads(); - if (maxUploads >= 0) { - internalRequest.addParameter("maxUploads", String.valueOf(maxUploads)); - } - String delimiter = request.getDelimiter(); - if (delimiter != null) { - internalRequest.addParameter("delimiter", delimiter); - } - String prefix = request.getPrefix(); - if (prefix != null) { - internalRequest.addParameter("prefix", prefix); - } + internalRequest.addParameter("mirroring", null); - ListMultipartUploadsResponse response = - this.invokeHttpClient(internalRequest, ListMultipartUploadsResponse.class); - response.setBucketName(request.getBucketName()); + GetBucketMirroringResponse response = this.invokeHttpClient(internalRequest, GetBucketMirroringResponse.class); return response; } /** - * Populates the specified request object with the appropriate headers from the ObjectMetadata object. + * Set the Bos bucket mirroring. * - * @param request The request to populate with headers. - * @param metadata The metadata containing the header information to include in the request. + * @param bucketName The name of an existing bucket, to which you have permission + * @param bucketMirroringConfigurations The bucketMirroringConfigurations object that your create */ - private static void populateRequestMetadata(InternalRequest request, ObjectMetadata metadata) { - if (metadata.getContentType() != null) { - request.addHeader(Headers.CONTENT_TYPE, metadata.getContentType()); - } - if (metadata.getContentMd5() != null) { - request.addHeader(Headers.CONTENT_MD5, metadata.getContentMd5()); - } - if (metadata.getContentEncoding() != null) { - request.addHeader(Headers.CONTENT_ENCODING, metadata.getContentEncoding()); - } - if (metadata.getBceContentSha256() != null) { - request.addHeader(Headers.BCE_CONTENT_SHA256, metadata.getBceContentSha256()); - } - if (metadata.getContentDisposition() != null) { - request.addHeader(Headers.CONTENT_DISPOSITION, metadata.getContentDisposition()); - } - if (metadata.getETag() != null) { - request.addHeader(Headers.ETAG, metadata.getETag()); - } - if (metadata.getExpires() != null) { - request.addHeader(Headers.EXPIRES, metadata.getExpires()); - } - if (metadata.getCacheControl() != null) { - request.addHeader(Headers.CACHE_CONTROL, metadata.getCacheControl()); - } - if (metadata.getStorageClass() != null) { - request.addHeader(Headers.BCE_STORAGE_CLASS, metadata.getStorageClass()); - } - - Map userMetadata = metadata.getUserMetadata(); - if (userMetadata != null) { - for (Entry entry : userMetadata.entrySet()) { - String key = entry.getKey(); - if (key == null) { - continue; - } - String value = entry.getValue(); - if (value == null) { - value = ""; - } - if (key.length() + value.length() > 1024 * 32) { - throw new BceClientException("MetadataTooLarge"); - } - request.addHeader(Headers.BCE_USER_METADATA_PREFIX + HttpUtils.normalize(key.trim()), - HttpUtils.normalize(value)); - } - } + public void putBucketMirroring(String bucketName, + List bucketMirroringConfigurations) { + this.putBucketMirroring(new PutBucketMirroringRequest(bucketName, bucketMirroringConfigurations)); } /** - * Creates and initializes a new request object for the specified Bos resource. This method is responsible - * for determining the right way to address resources. + * Set the Bos bucket mirroring. * - * @param bceRequest The original request, as created by the user. - * @param httpMethod The HTTP method to use when sending the request. - * @return A new request object, populated with endpoint, resource path, ready for callers to populate - * any additional headers or parameters, and execute. + * @param bucketName The name of an existing bucket, to which you have permission + * @param jsonBucketMirroringConfigurations The bucketMirroringConfigurations json string that your create */ - private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod) { - String bucketName = null; - String key = null; - if (bceRequest instanceof GenericBucketRequest) { - bucketName = ((GenericBucketRequest) bceRequest).getBucketName(); - } - if (bceRequest instanceof GenericObjectRequest) { - key = ((GenericObjectRequest) bceRequest).getKey(); - } - InternalRequest request = - new InternalRequest(httpMethod, HttpUtils.appendUri(this.getEndpoint(), URL_PREFIX, bucketName, key)); - request.setCredentials(bceRequest.getRequestCredentials()); - return request; + public void putBucketMirroring(String bucketName, String jsonBucketMirroringConfigurations) { + this.putBucketMirroring(new PutBucketMirroringRequest(bucketName, jsonBucketMirroringConfigurations)); } + /** + * Set the Bos bucket mirroring. + * + * @param request The PutBucketMirroringRequest you create + */ + public void putBucketMirroring(PutBucketMirroringRequest request) { + checkNotNull(request, "request should not be null."); - private void downloadObjectToFile(BosObject bosObject, File destinationFile, boolean verifyIntegrity) { - // attempt to create the parent if it doesn't exist - File parentDirectory = destinationFile.getParentFile(); - if (parentDirectory != null && !parentDirectory.exists()) { - parentDirectory.mkdirs(); - } - - OutputStream outputStream = null; - try { - outputStream = new BufferedOutputStream(new FileOutputStream(destinationFile)); - byte[] buffer = new byte[this.getStreamBufferSize()]; - int bytesRead; - while ((bytesRead = bosObject.getObjectContent().read(buffer)) > -1) { - outputStream.write(buffer, 0, bytesRead); - } - } catch (IOException e) { - try { - bosObject.getObjectContent().close(); - } catch (IOException abortException) { - logger.warn("Couldn't abort stream", abortException); - } - throw new BceClientException("Unable to write to disk", e); - } finally { - try { - if (outputStream != null) { - outputStream.close(); - } - } catch (Exception e) { - } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("mirroring", null); + byte[] json; + if (request.getJsonBucketMirroringConfiguration() != null) { try { - bosObject.getObjectContent().close(); - } catch (Exception e) { + json = request.getJsonBucketMirroringConfiguration().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); } - } - if (verifyIntegrity) { - byte[] serverSideHash = null; - byte[] clientSideHash = null; - ObjectMetadata objectMetadata = bosObject.getObjectMetadata(); + } else { try { - if (objectMetadata.getBceContentSha256() != null) { - serverSideHash = Hex.decodeHex(objectMetadata.getBceContentSha256().toCharArray()); - clientSideHash = HashUtils.computeSha256Hash(new FileInputStream(destinationFile)); - } else if (objectMetadata.getContentMd5() != null) { - serverSideHash = Base64.decodeBase64(objectMetadata.getContentMd5().getBytes(DEFAULT_ENCODING)); - clientSideHash = HashUtils.computeMd5Hash(new FileInputStream(destinationFile)); - } - } catch (Exception e) { - logger.warn("Unable to verify the integrity of the downloaded file", e); - } - if (serverSideHash != null && clientSideHash != null && !Arrays.equals(clientSideHash, serverSideHash)) { - throw new BceClientException("Integrity verification failed! " - + "Client calculated content hash didn't match hash from server. " - + "The data stored in '" + destinationFile.getAbsolutePath() + "' may be corrupt."); + json = JsonUtils.getObjectMapper().writeValueAsString(request).getBytes(DEFAULT_ENCODING); + } catch (JsonProcessingException e) { + throw new BceClientException("Fail to generate json", e); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); } } - } - private List readAll(InputStream input, ObjectMetadata metadata) { - List result = Lists.newArrayList(); - int bufferSize = this.getStreamBufferSize(); - long length = 0; - for (; ; ) { - byte[] buffer = new byte[bufferSize]; - result.add(buffer); - int off = 0; - while (off < bufferSize) { - int count; - try { - count = input.read(buffer, off, bufferSize - off); - } catch (IOException e) { - throw new BceClientException("Fail to read data.", e); - } - if (count < 0) { - metadata.setContentLength(length); - return result; - } - length += count; - off += count; - } - } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + this.invokeHttpClient(internalRequest, BosResponse.class); } - private RestartableInputStream wrapRestartableInputStream(InputStream input) { - if (input.markSupported()) { - return new RestartableResettableInputStream(input); - } else { - return new RestartableNonResettableInputStream(input, this.getStreamBufferSize()); - } + /** + * Delete the Bos bucket mirroring setting. + * + * @param bucketName The name of an existing bucket, to which you have permission + */ + public void deleteBucketMirroring(String bucketName) { + this.deleteBucketMirroring(new DeleteBucketMirroringRequest(bucketName)); } - private void setZeroContentLength(InternalRequest req) { - req.addHeader(Headers.CONTENT_LENGTH, String.valueOf(0)); - } + /** + * Delete the Bos bucket mirroring setting. + * + * @param request The DeleteBucketMirroringRequest you create + */ + public void deleteBucketMirroring(DeleteBucketMirroringRequest request) { + checkNotNull(request, "request should not be null."); - private int getStreamBufferSize() { - return ((BosClientConfiguration) this.config).getStreamBufferSize(); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter("mirroring", null); + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Asserts that the specified parameter value is not null or empty and if it is, - * throws an IllegalArgumentException with the specified error message. + * Gets the Bos bucket tagging description. * - * @param parameterValue The parameter value being checked. - * @param errorMessage The error message to include in the IllegalArgumentException - * if the specified parameter is null. + * @param bucketName The name of an existing bucket, to which you have permission + * @return The GetBucketTaggingResponse for the Bos bucket. */ - private void assertStringNotNullOrEmpty(String parameterValue, String errorMessage) { - if (parameterValue == null) { - throw new IllegalArgumentException(errorMessage); - } - if (parameterValue.isEmpty()) { - throw new IllegalArgumentException(errorMessage); - } + public GetBucketTaggingResponse getBucketTagging(String bucketName) { + return this.getBucketTagging(new GetBucketTaggingRequest(bucketName)); } /** - * Adds response headers parameters to the request given, if non-null. + * Gets the Bos bucket tagging description. * - * @param request The request to add the response header parameters to. - * @param responseHeaders The full set of response headers to add, or null for none. + * @param request The GetBucketTaggingRequest you create + * @return The GetBucketTaggingResponse for the Bos bucket. */ - private void addResponseHeaderParameters(InternalRequest request, ResponseHeaderOverrides responseHeaders) { - if (responseHeaders != null) { - if (responseHeaders.getCacheControl() != null) { - request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CACHE_CONTROL, - responseHeaders.getCacheControl()); - } - if (responseHeaders.getContentDisposition() != null) { - request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_DISPOSITION, - responseHeaders.getContentDisposition()); - } - if (responseHeaders.getContentEncoding() != null) { - request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_ENCODING, - responseHeaders.getContentEncoding()); - } - if (responseHeaders.getContentLanguage() != null) { - request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_LANGUAGE, - responseHeaders.getContentLanguage()); - } - if (responseHeaders.getContentType() != null) { - request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_TYPE, - responseHeaders.getContentType()); - } - if (responseHeaders.getExpires() != null) { - request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_EXPIRES, responseHeaders.getExpires()); - } - } + public GetBucketTaggingResponse getBucketTagging(GetBucketTaggingRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("tagging", null); + + GetBucketTaggingResponse response = this.invokeHttpClient(internalRequest, GetBucketTaggingResponse.class); + return response; + } + + /** + * Delete the Bos bucket tagging setting. + * + * @param bucketName The name of an existing bucket, to which you have permission + */ + public void deleteBucketTagging(String bucketName) { + this.deleteBucketTagging(new DeleteBucketTaggingRequest(bucketName)); } /** - * Converts the specified request object into a URL, containing all the - * specified parameters, the specified request endpoint, etc. + * Delete the Bos bucket tagging setting. * - * @param request The request to convert into a URL. - * @return A new URL representing the specified request. + * @param request The DeleteBucketTaggingRequest you create */ - private URL convertRequestToUrl(InternalRequest request) { - String resourcePath = HttpUtils.normalizePath(request.getUri().getPath()); + public void deleteBucketTagging(DeleteBucketTaggingRequest request) { + checkNotNull(request, "request should not be null."); - // Removed the padding "/" that was already added into the request's resource path. - if (resourcePath.startsWith("/")) { - resourcePath = resourcePath.substring(1); - } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter("tagging", null); + this.invokeHttpClient(internalRequest, BosResponse.class); + } - // Some http client libraries (e.g. Apache HttpClient) cannot handle - // consecutive "/"s between URL authority and path components. - // So we escape "////..." into "/%2F%2F%2F...", in the same way as how - // we treat consecutive "/"s in AmazonS3Client#presignRequest(...) - String urlPath = "/" + resourcePath; - urlPath = urlPath.replaceAll("(?<=/)/", "%2F"); - String urlString = this.getEndpoint() + urlPath; - boolean firstParam = true; - for (String param : request.getParameters().keySet()) { - if (firstParam) { - urlString += "?"; - firstParam = false; - } else { - urlString += "&"; - } + /** + * Set the Bos bucket tagging. + * + * @param bucketName The name of an existing bucket, to which you have permission + * @param jsonBucketTags The bucket tagging json string that your create + */ + public void putBucketTagging(String bucketName, String jsonBucketTags) { + this.putBucketTagging(new PutBucketTaggingRequest(bucketName, jsonBucketTags)); + } - String value = request.getParameters().get(param); - urlString += param + "=" + HttpUtils.normalize(value); - } + /** + * Set the Bos bucket tagging. + * + * @param bucketName The name of an existing bucket, to which you have permission + * @param tags The bucket tagging object that your create + */ + public void putBucketTagging(String bucketName, List tags) { + this.putBucketTagging(new PutBucketTaggingRequest(bucketName, tags)); + } - String authorization = request.getHeaders().get(Headers.AUTHORIZATION); - if (authorization != null) { - if (firstParam) { - urlString += "?"; - } else { - urlString += "&"; + /** + * Set the Bos bucket tagging. + * + * @param request The PutBucketTaggingRequest you create + */ + public void putBucketTagging(PutBucketTaggingRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("tagging", null); + byte[] json; + if (request.getJsonBucketTags() != null) { + try { + json = request.getJsonBucketTags().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } else { + try { + json = JsonUtils.getObjectMapper().writeValueAsString(request).getBytes(DEFAULT_ENCODING); + } catch (JsonProcessingException e) { + throw new BceClientException("Fail to generate json", e); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); } - urlString += "authorization" + "=" + HttpUtils.normalize(authorization); } - try { - return new URL(urlString); - } catch (MalformedURLException e) { - throw new BceClientException("Unable to convert request to well formed URL: " + e.getMessage(), e); - } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + this.invokeHttpClient(internalRequest, BosResponse.class); } + /** - * Uploads the specified appendable file to Bos under the specified bucket and key name. + * Set the Bos bucket trash. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param file The appendable file containing the data to be uploaded to Bos. - * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of an existing bucket, to which you have permission + * @param trashDir The bucket trash name that your want to create */ - public AppendObjectResponse appendObject(String bucketName, String key, File file) { - return this.appendObject(new AppendObjectRequest(bucketName, key, file)); + public void putBucketTrash(String bucketName, String trashDir) { + this.putBucketTrash(new PutBucketTrashRequest(bucketName, trashDir)); } /** - * Uploads the specified appendable file to Bos under the specified bucket and key name. + * Set the Bos bucket trash. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param file The file containing the data to be uploaded to Bos. - * @param metadata Additional metadata instructing Bos how to handle the uploaded data - * (e.g. custom user metadata, hooks for specifying content type, etc.). - * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of an existing bucket, to which you have permission */ - public AppendObjectResponse appendObject(String bucketName, String key, File file, ObjectMetadata metadata) { - return this.appendObject(new AppendObjectRequest(bucketName, key, file, metadata)); + public void putBucketTrash(String bucketName) { + this.putBucketTrash(new PutBucketTrashRequest(bucketName)); } /** - * Uploads the specified string to Bos under the specified bucket and key name. + * Set the Bos bucket trash. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param value The string containing the value to be uploaded to Bos. - * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + * @param request The PutBucketTrashRequest you create */ - public AppendObjectResponse appendObject(String bucketName, String key, String value) { + public void putBucketTrash(PutBucketTrashRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("trash", null); + byte[] json; + try { - return this.appendObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), new ObjectMetadata()); + json = JsonUtils.getObjectMapper().writeValueAsString(request).getBytes(DEFAULT_ENCODING); + } catch (JsonProcessingException e) { + throw new BceClientException("Fail to generate json", e); } catch (UnsupportedEncodingException e) { - throw new BceClientException("Fail to get bytes.", e); + throw new BceClientException("Fail to get UTF-8 bytes", e); } + + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Uploads the specified string and object metadata to Bos under the specified bucket and key name. + * Get the Bos bucket trash. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param value The string containing the value to be uploaded to Bos. - * @param metadata Additional metadata instructing Bos how to handle the uploaded data - * (e.g. custom user metadata, hooks for specifying content type, etc.). - * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of an existing bucket, to which you have permission */ - public AppendObjectResponse appendObject(String bucketName, String key, String value, ObjectMetadata metadata) { - try { - return this.appendObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), metadata); - } catch (UnsupportedEncodingException e) { - throw new BceClientException("Fail to get bytes.", e); - } + public GetBucketTrashResponse getBucketTrash(String bucketName) { + return this.getBucketTrash(new GetBucketTrashRequest(bucketName)); } /** - * Uploads the specified bytes to Bos under the specified bucket and key name. + * Get the Bos bucket trash. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param value The bytes containing the value to be uploaded to Bos. - * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + * @param request The GetBucketTrashRequest you create */ - public AppendObjectResponse appendObject(String bucketName, String key, byte[] value) { - return this.appendObject(bucketName, key, value, new ObjectMetadata()); + public GetBucketTrashResponse getBucketTrash(GetBucketTrashRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("trash", null); + + GetBucketTrashResponse response = this.invokeHttpClient(internalRequest, GetBucketTrashResponse.class); + return response; } + /** - * Uploads the appendable bytes and object metadata to Bos under the specified bucket and key name. + * Delete the Bos bucket trash. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param value The bytes containing the value to be uploaded to Bos. - * @param metadata Additional metadata instructing Bos how to handle the uploaded data - * (e.g. custom user metadata, hooks for specifying content type, etc.). - * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of an existing bucket, to which you have permission */ - public AppendObjectResponse appendObject( - String bucketName, String key, byte[] value, ObjectMetadata metadata) { - checkNotNull(metadata, "metadata should not be null."); - if (metadata.getContentLength() == -1) { - metadata.setContentLength(value.length); - } - return this.appendObject( - new AppendObjectRequest(bucketName, key, RestartableInputStream.wrap(value), metadata)); + public void deleteBucketTrash(String bucketName) { + this.deleteBucketTrash(new DeleteBucketTrashRequest(bucketName)); } + /** - * Uploads the appendable input stream to Bos under the specified bucket and key name. + * Delete the Bos bucket trash. * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param input The input stream containing the value to be uploaded to Bos. - * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + * @param request The DeleteBucketTrashRequest you create */ - public AppendObjectResponse appendObject(String bucketName, String key, InputStream input) { - return this.appendObject(new AppendObjectRequest(bucketName, key, input)); + public void deleteBucketTrash(DeleteBucketTrashRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE); + internalRequest.addParameter("trash", null); + this.invokeHttpClient(internalRequest, BosResponse.class); } /** - * Uploads the appendable input stream and object metadata to Bos under the specified bucket and key name. + * renameObject support rename one object key to another * - * @param bucketName The name of an existing bucket, to which you have Write permission. - * @param key The key under which to store the specified file. - * @param input The input stream containing the value to be uploaded to Bos. - * @param metadata Additional metadata instructing Bos how to handle the uploaded data - * (e.g. custom user metadata, hooks for specifying content type, etc.). - * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param sourceKey The origin key of object + * @param destinationKey The destination key of object + * @return An RenameObjectResponse containing the information returned by Bos for rename operation */ - public AppendObjectResponse appendObject( - String bucketName, String key, InputStream input, ObjectMetadata metadata) { - return this.appendObject(new AppendObjectRequest(bucketName, key, input, metadata)); + public RenameObjectResponse renameObject(String bucketName, String sourceKey, String destinationKey) { + return this.renameObject(new RenameObjectRequest(bucketName, sourceKey, destinationKey)); } /** - * Uploads a new object to the specified Bos bucket. The AppendObjectRequest contains all the - * details of the request, including the bucket to upload to, the key the object will be uploaded under, - * and the file or input stream containing the data to upload. + * renameObject support rename one object key to another. The ARenameObjectRequest contains all the + * details of the request, including the source key and destination key * - * @param request The request object containing all the parameters to upload a new appendable object to Bos. - * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + * @param request The request object containing all the parameters to rename object + * @return An RenameObjectResponse object containing the information returned by Bos for for rename operation */ - public AppendObjectResponse appendObject(AppendObjectRequest request) { + public RenameObjectResponse renameObject(RenameObjectRequest request) { checkNotNull(request, "request should not be null."); - assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + this.assertStringNotNullOrEmpty(request.getSourceKey(), "object key should not be null or empty"); InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); - internalRequest.addParameter("append", null); - if (request.getOffset() != null) { - internalRequest.addParameter("offset", request.getOffset().toString()); - } - BosResponse response = uploadObject(request, internalRequest); - AppendObjectResponse result = new AppendObjectResponse(); - result.setNextAppendOffset(response.getMetadata().getNextAppendOffset()); - result.setContentMd5(response.getMetadata().getContentMd5()); - result.setETag(response.getMetadata().getETag()); - return result; + String renameSourceHeader = request.getSourceKey(); + renameSourceHeader = HttpUtils.normalizePath(renameSourceHeader); + internalRequest.addHeader("x-bce-rename-key", renameSourceHeader); + this.setZeroContentLength(internalRequest); + return this.invokeHttpClient(internalRequest, RenameObjectResponse.class); } - /** - * Uploads a object to Bos bucket. The PutObjcetRequest contains all the details of the request.The internalRequest - * represents a request being send to a BCE Service. - * - * @param request The request object containing all the parameters to upload a new appendable object to Bos. - * @param internalRequest Represents a request being sent to a BCE Service, including the parameters being - * sent as part of the request, the endpoint to which the request should be sent, etc. - * @return A BosResponse object containing the bos-metadata information returned by Bos for the newly created - * object - */ - private BosResponse uploadObject(PutObjectRequest request, InternalRequest internalRequest) { - ObjectMetadata metadata = request.getObjectMetadata(); - InputStream input = request.getInputStream(); - if (request.getFile() != null) { - File file = request.getFile(); - - if (file.length() > 5 * 1024 * 1024 * 1024L) { - BceServiceException bse = new BceServiceException("Your proposed upload exceeds the maximum allowed " - + "object size."); - bse.setStatusCode(400); - bse.setErrorCode("EntityTooLarge"); - bse.setErrorType(BceServiceException.ErrorType.Client); - throw bse; - } + public void putBucketVersioning(String bucketName, String status) { + this.putBucketVersioning(new PutBucketVersioningRequest(bucketName, status)); + } - // Always set the content length, even if it's already set - if (metadata.getContentLength() < 0) { - metadata.setContentLength(file.length()); - } + public void putBucketVersioning(PutBucketVersioningRequest request) { + checkNotNull(request, "request should not be null."); - if (metadata.getContentType() == null) { - metadata.setContentType(Mimetypes.getInstance().getMimetype(file)); - } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); + internalRequest.addParameter("versioning", null); + byte[] json; - if (metadata.getContentLength() == file.length()) { - FileInputStream fileInputStream = null; - try { - fileInputStream = new FileInputStream(file); - metadata.setBceContentSha256( - new String(Hex.encodeHex(HashUtils.computeSha256Hash(fileInputStream)))); - } catch (Exception e) { - throw new BceClientException("Unable to calculate SHA-256 hash", e); - } finally { - try { - if (fileInputStream != null) { - fileInputStream.close(); - } - } catch (Exception e) { - logger.warn("The inputStream accured error"); - } - } - } - try { - internalRequest.setContent(new RestartableFileInputStream(file)); - } catch (FileNotFoundException e) { - throw new BceClientException("Unable to find file to upload", e); - } - } else { - checkNotNull(input, "Either file or inputStream should be set."); - if (metadata.getContentLength() < 0) { - logger.warn("No content length specified for stream data. Trying to read them all into memory."); - List data = this.readAll(input, metadata); - internalRequest.setContent(new RestartableMultiByteArrayInputStream(data, metadata.getContentLength())); - } else if (input instanceof RestartableInputStream) { - internalRequest.setContent((RestartableInputStream) input); - } else { - internalRequest.setContent(this.wrapRestartableInputStream(input)); - } - if (metadata.getContentType() == null) { - metadata.setContentType(Mimetypes.getInstance().getMimetype(request.getKey())); - } - } - if (request.getStorageClass() != null) { - metadata.setStorageClass(request.getStorageClass()); + try { + json = JsonUtils.getObjectMapper().writeValueAsString(request).getBytes(DEFAULT_ENCODING); + } catch (JsonProcessingException e) { + throw new BceClientException("Fail to generate json", e); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); } - internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(metadata.getContentLength())); + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + this.invokeHttpClient(internalRequest, BosResponse.class); + } - populateRequestMetadata(internalRequest, metadata); + public GetBucketVersioningResponse getBucketVersioning(String bucketName) { + return this.getBucketVersioning(new GetBucketVersioningRequest(bucketName)); + } - BosResponse response; - try { - response = this.invokeHttpClient(internalRequest, BosResponse.class); - } finally { - try { - internalRequest.getContent().close(); - } catch (Exception e) { - logger.warn("Fail to close input stream", e); - } - } + public GetBucketVersioningResponse getBucketVersioning(GetBucketVersioningRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET); + internalRequest.addParameter("versioning", null); + + GetBucketVersioningResponse response = this.invokeHttpClient(internalRequest, GetBucketVersioningResponse.class); return response; } + + } diff --git a/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java b/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java index 675f26b5..cfe150db 100644 --- a/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java +++ b/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Baidu, Inc. + * Copyright 2014-2019 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -24,7 +24,61 @@ public class BosClientConfiguration extends BceClientConfiguration { public static final int DEFAULT_STREAM_BUFFER_SIZE = 5 * 1024 * 1024; + + public static final String STRONG_CONSISTENCY_VIEW = "strong"; + + /** + * determines whether redirects should be handled automatically + * + * @return + */ + private boolean redirectsEnabled = true; + + /** + * determines the redirects times. + * + * @return + */ + private int maxRedirects = 1; + private int streamBufferSize = DEFAULT_STREAM_BUFFER_SIZE; + private static final String DEFAULT_ENDPOINT = "bj.bcebos.com"; + + /** + * whether to enable using cname to visit bos resource. If user use custom domain as the endpoint, the cnameEnabled + * should be true. + */ + private boolean cnameEnabled; + + /** + * whether to enable using nio to http async put, default value is true for async put + */ + private boolean enableHttpAsyncPut = false; + + /** + * whether use path style host in BOS. .bcebos.com + */ + private boolean pathStyleAccessEnable = false; + + private String consistencyView; + + /** + * whether use path style host in BOS. .bcebos.com + * + * @return the result of use path style host in BOS. + */ + public boolean isPathStyleAccessEnable() { + return pathStyleAccessEnable; + } + + /** + * Set whether use path style host in BOS. .bcebos.com + * + * @param pathStyleAccessEnable whether use path style host in BOS. + */ + public void setPathStyleAccessEnable(boolean pathStyleAccessEnable) { + this.pathStyleAccessEnable = pathStyleAccessEnable; + } public int getStreamBufferSize() { return this.streamBufferSize; @@ -32,16 +86,17 @@ public int getStreamBufferSize() { public BosClientConfiguration() { super(); + this.setEndpoint(DEFAULT_ENDPOINT); } - + public BosClientConfiguration(BceClientConfiguration clientConfiguration) { super(clientConfiguration, null); } - + public BosClientConfiguration(BceClientConfiguration clientConfiguration, String bosEndpoint) { super(clientConfiguration, bosEndpoint); } - + public void setStreamBufferSize(int streamBufferSize) { checkArgument(streamBufferSize > 0, "streamBufferSize should be positive."); this.streamBufferSize = streamBufferSize; @@ -52,6 +107,53 @@ public BosClientConfiguration withStreamBufferSize(int streamBufferSize) { return this; } + + /** + * Returns whether to enable using cname to visit bos resource. + * + * @return whether to enable using cname to visit bos resource. + */ + public boolean isCnameEnabled() { + return this.cnameEnabled; + } + + /** + * Sets whether to enable using cname to visit bos resource. + * + * @param cnameEnabled whether to enable using cname to visit bos resource. + */ + public void setCnameEnabled(boolean cnameEnabled) { + this.cnameEnabled = cnameEnabled; + } + + public BosClientConfiguration withCnameEnabled(boolean cnameEnabled) { + this.setCnameEnabled(cnameEnabled); + return this; + } + + /** + * Returns whether to enable http async put + * + * @return whether to enable http async put + */ + public boolean isEnableHttpAsyncPut() { + return enableHttpAsyncPut; + } + + /** + * Set whether to enable http async put + * + * @param enableHttpAsyncPut whether to enable http async put + */ + public void setEnableHttpAsyncPut(boolean enableHttpAsyncPut) { + this.enableHttpAsyncPut = enableHttpAsyncPut; + } + + public BosClientConfiguration withEnableHttpAsyncPut(boolean enableHttpAsyncPut) { + this.setEnableHttpAsyncPut(enableHttpAsyncPut); + return this; + } + @Override public BosClientConfiguration withProtocol(Protocol protocol) { this.setProtocol(protocol); @@ -160,4 +262,54 @@ public BosClientConfiguration withCredentials(BceCredentials credentials) { this.setCredentials(credentials); return this; } + + public String getConsistencyView() { + return consistencyView; + } + + public void setConsistencyView(String consistencyView) { + this.consistencyView = consistencyView; + } + + /** + * Gets the flag of redirection times + * + * @return + */ + public int getMaxRedirects() { + return this.maxRedirects; + } + + /** + * Sets the flag of redirection times + * + * @param maxRedirects + */ + public void setMaxRedirects(int maxRedirects) { + this.maxRedirects = maxRedirects; + } + + /** + * Gets the flag of http redirection + * + * @return + */ + public boolean isRedirectsEnabled() { + return redirectsEnabled; + } + + /** + * Sets the flag of http redirection + * + * @param redirectsEnabled + */ + public void setRedirectsEnabled(boolean redirectsEnabled) { + this.redirectsEnabled = redirectsEnabled; + } + + public BosClientConfiguration withConsistencyView(String consistencyView) { + this.setConsistencyView(consistencyView); + return this; + } + } diff --git a/src/main/java/com/baidubce/services/bos/BosMetadataResponseHandler.java b/src/main/java/com/baidubce/services/bos/BosMetadataResponseHandler.java index 03a4b11a..97ebd168 100644 --- a/src/main/java/com/baidubce/services/bos/BosMetadataResponseHandler.java +++ b/src/main/java/com/baidubce/services/bos/BosMetadataResponseHandler.java @@ -32,7 +32,9 @@ public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response if (httpResponse.getHeader(Headers.LOCATION) != null) { metadata.setLocation(httpResponse.getHeader(Headers.LOCATION)); } - + if (httpResponse.getHeader(Headers.BCE_VERSION_ID) != null) { + metadata.setxBceVersionId(httpResponse.getHeader(Headers.BCE_VERSION_ID)); + } } return false; } diff --git a/src/main/java/com/baidubce/services/bos/BosObjectResponseHandler.java b/src/main/java/com/baidubce/services/bos/BosObjectResponseHandler.java index 5019fd65..beb1ceda 100644 --- a/src/main/java/com/baidubce/services/bos/BosObjectResponseHandler.java +++ b/src/main/java/com/baidubce/services/bos/BosObjectResponseHandler.java @@ -50,6 +50,12 @@ public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response objectMetadata.setAppendOffset(httpResponse.getHeaderAsLong(Headers.BCE_NEXT_APPEND_OFFSET)); objectMetadata.setContentDisposition(httpResponse.getHeader(Headers.CONTENT_DISPOSITION)); objectMetadata.setCacheControl(httpResponse.getHeader(Headers.CACHE_CONTROL)); + objectMetadata.setxBceCrc(httpResponse.getHeader(Headers.BCE_CONTENT_CRC32)); + objectMetadata.setxBceCrc32c(httpResponse.getHeader(Headers.BCE_CONTENT_CRC32C)); + objectMetadata.setRestore(httpResponse.getHeader(Headers.BCE_RESTORE)); + if (httpResponse.getHeader(Headers.BCE_VERSION_ID) != null) { + objectMetadata.setVersionId(httpResponse.getHeader(Headers.BCE_VERSION_ID)); + } // set whatever the BOS server returns if not null String storageClass = httpResponse.getHeader(Headers.BCE_STORAGE_CLASS); if (storageClass == null) { diff --git a/src/main/java/com/baidubce/services/bos/callback/ProgressCallback.java b/src/main/java/com/baidubce/services/bos/callback/ProgressCallback.java new file mode 100644 index 00000000..3fa31e99 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/callback/ProgressCallback.java @@ -0,0 +1,8 @@ +package com.baidubce.services.bos.callback; + +/** + * Callback interface used for get progress information + */ +public interface ProgressCallback { + void onProgress(long currentSize, long totalSize, T data); +} diff --git a/src/main/java/com/baidubce/services/bos/demo/AppendObjectDemo.java b/src/main/java/com/baidubce/services/bos/demo/AppendObjectDemo.java new file mode 100644 index 00000000..b4f8a622 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/AppendObjectDemo.java @@ -0,0 +1,73 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.AppendObjectRequest; +import com.baidubce.services.bos.model.AppendObjectResponse; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** + * BOS以追加方式上传object的demo + */ +public class AppendObjectDemo { + // 通过AppendObject方式上传示例 + public static void appendObject() throws FileNotFoundException { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 获取指定文件 + File file = new File("/path/to/file.zip"); + // 获取数据流 + InputStream inputStream = new FileInputStream("/path/to/test.zip"); + byte[] byte0 = new byte[0]; + + // 以文件形式上传Object + AppendObjectResponse appendObjectFromFileResponse = + client.appendObject("bucketName", "file-objectKey", file); + // 以数据流形式上传Object + AppendObjectResponse appendObjectResponseFromInputStream = + client.appendObject("bucketName", "inputStream-objectKey", inputStream); + // 以二进制串上传Object + AppendObjectResponse appendObjectResponseFromByte = + client.appendObject("bucketName", "byte-objectKey", byte0); + // 以字符串上传Object + AppendObjectResponse appendObjectResponseFromString = + client.appendObject("bucketName", "string-objectKey", "hello world"); + + // 打印ETag + System.out.println(appendObjectFromFileResponse.getETag()); + // 打印NextAppendOffset + System.out.println(appendObjectFromFileResponse.getNextAppendOffset()); + // 打印ContentMd5 + System.out.println(appendObjectFromFileResponse.getContentMd5()); + + // 追加上传的示例,需要在请求中加上下次追加写的位置 + Long nextAppendOffset = appendObjectFromFileResponse.getNextAppendOffset(); + AppendObjectRequest appendObjectFromFileRequest = + new AppendObjectRequest("bucketName","file-objectKey",file); + appendObjectFromFileRequest.setOffset(nextAppendOffset); + AppendObjectResponse response = client.appendObject(appendObjectFromFileRequest); + + // 打印ETag + System.out.println(appendObjectFromFileResponse.getETag()); + // 打印NextAppendOffset + System.out.println(appendObjectFromFileResponse.getNextAppendOffset()); + // 打印ContentMd5 + System.out.println(appendObjectFromFileResponse.getContentMd5()); + + // 关闭客户端 + client.shutdown(); + } +} diff --git a/src/main/java/com/baidubce/services/bos/demo/BucketSampleDemo.java b/src/main/java/com/baidubce/services/bos/demo/BucketSampleDemo.java new file mode 100644 index 00000000..1e1d85fd --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/BucketSampleDemo.java @@ -0,0 +1,99 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.BucketSummary; + +import java.util.List; + +/** + * 关于Bucket的创建、删除、列举、是否存在的demo + */ +public class BucketSampleDemo { + // 创建Bucket + public static void createBucket() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + client.createBucket("create-bucketName"); // 指定Bucket名称 + + // 关闭客户端 + client.shutdown(); + } + + // 删除Bucket + public static void deleteBucket () { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + client.deleteBucket("delete-bucketName"); // 指定Bucket名称 + + // 关闭客户端 + client.shutdown(); + } + + // 列举Bucket + public static void listBuckets () { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 获取用户的Bucket列表 + List buckets = client.listBuckets().getBuckets(); + + // 遍历Bucket + for (BucketSummary bucket : buckets) { + System.out.println(bucket.getName()); + } + + // 关闭客户端 + client.shutdown(); + } + + // 查询Bucket是否存在 + public static void doesBucketExist () { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 获取Bucket的存在信息 + boolean exists = client.doesBucketExist("isExist-bucketName"); //指定Bucket名称 + + // 输出结果 + if (exists) { + System.out.println("Bucket exists"); + } else { + System.out.println("Bucket not exists"); + } + + // 关闭客户端 + client.shutdown(); + } +} diff --git a/src/main/java/com/baidubce/services/bos/demo/CopyObjectDemo.java b/src/main/java/com/baidubce/services/bos/demo/CopyObjectDemo.java new file mode 100644 index 00000000..69b1c7b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/CopyObjectDemo.java @@ -0,0 +1,105 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 简单拷贝、分块拷贝的demo + */ +public class CopyObjectDemo { + // 小于5G的文件直接简单拷贝 + public static void copyObjectSimple() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 创建CopyObjectRequest对象 + CopyObjectRequest copyObjectRequest = + new CopyObjectRequest("srcBucketName", "srcKey", "destBucketName", "destKey"); + + // 也可以设置新的Metadata + Map userMetadata = new HashMap(); + userMetadata.put("user-meta-key", "user-meta-value"); + ObjectMetadata meta = new ObjectMetadata(); + meta.setUserMetadata(userMetadata); + copyObjectRequest.setNewObjectMetadata(meta); + + // 复制Object + CopyObjectResponse copyObjectResponse = client.copyObject(copyObjectRequest); + + System.out.println("ETag: " + copyObjectResponse.getETag() + " LastModified: " + copyObjectResponse.getLastModified()); + + // 关闭客户端 + client.shutdown(); + } + + // 大于5G的文件、网络差、需要支持断点拷贝的建议使用分块拷贝 + public static void copyObjectMultipart() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 第一步 init + InitiateMultipartUploadRequest initiateMultipartUploadRequest = + new InitiateMultipartUploadRequest("targetBucketName","targetObjectName"); + InitiateMultipartUploadResponse initiateMultipartUploadResponse = + client.initiateMultipartUpload(initiateMultipartUploadRequest); + + // 第二步 分块拷贝 + long left_size=client.getObjectMetadata("sourceBucketName","sourceObjectName").getContentLength(); + long skipBytes = 0; + int partNumber = 1; + List partETags = new ArrayList(); + + while (left_size > 0) { + long partSize = 1024 * 1024 * 1L; + if (left_size < partSize) { + partSize = left_size; + } + UploadPartCopyRequest uploadPartCopyRequest = new UploadPartCopyRequest(); + uploadPartCopyRequest.setBucketName("targetBucketName"); + uploadPartCopyRequest.setKey("targetObjectName"); + uploadPartCopyRequest.setSourceBucketName("sourceBucketName"); + uploadPartCopyRequest.setSourceKey("sourceObjectName"); + uploadPartCopyRequest.setUploadId(initiateMultipartUploadResponse.getUploadId()); + uploadPartCopyRequest.setPartSize(partSize); + uploadPartCopyRequest.setOffSet(skipBytes); + uploadPartCopyRequest.setPartNumber(partNumber); + UploadPartCopyResponse uploadPartCopyResponse = client.uploadPartCopy(uploadPartCopyRequest); + // 将返回的PartETag保存到List中 + PartETag partETag = new PartETag(partNumber,uploadPartCopyResponse.getETag()); + partETags.add(partETag); + left_size -= partSize; + skipBytes += partSize; + partNumber+=1; + } + + // 第三步 complete + CompleteMultipartUploadRequest completeMultipartUploadRequest = + new CompleteMultipartUploadRequest("targetBucketName", "targetObjectName", initiateMultipartUploadResponse.getUploadId(), partETags); + CompleteMultipartUploadResponse completeMultipartUploadResponse = + client.completeMultipartUpload(completeMultipartUploadRequest); + + // 关闭客户端 + client.shutdown(); + } +} diff --git a/src/main/java/com/baidubce/services/bos/demo/DeleteObjectDemo.java b/src/main/java/com/baidubce/services/bos/demo/DeleteObjectDemo.java new file mode 100644 index 00000000..fa0cf8d5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/DeleteObjectDemo.java @@ -0,0 +1,67 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.DeleteMultipleObjectsRequest; +import com.baidubce.services.bos.model.DeleteMultipleObjectsResponse; + +import java.util.ArrayList; +import java.util.List; + +/** + * 删除单个文件、多个文件的demo + */ +public class DeleteObjectDemo { + // 删除单个文件 + public static void delSingleObject() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 删除Object + client.deleteObject("bucketName", "objectKey"); //指定要删除的Object所在Bucket名称和该Object名称 + + // 关闭客户端 + client.shutdown(); + } + + // 删除多个文件 + public static void delObjects() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 1、以Json格式的字符串 + String jsonObjectKeys = "{\"objects\": ["+"{\"key\": \"token1.h\"},"+"{\"key\": \"token2.h\"}"+"]}"; + DeleteMultipleObjectsRequest request = new DeleteMultipleObjectsRequest(); + request.setBucketName("bucketName"); + request.setJsonDeleteObjects(jsonObjectKeys); + client.deleteMultipleObjects(request); + + // 2、用户只需指定指定参数即可 + List objectKeys = new ArrayList(); + objectKeys.add("token1.h"); + objectKeys.add("token2.h"); + DeleteMultipleObjectsRequest request2 = new DeleteMultipleObjectsRequest(); + request2.setBucketName("bucketName"); + request2.setObjectKeys(objectKeys); + // 返回的消息体中只包含删除过程中出错的Object结果;如果所有Object都删除都成功的话,则没有消息体。 + DeleteMultipleObjectsResponse response = client.deleteMultipleObjects(request2); + + // 关闭客户端 + client.shutdown(); + } +} diff --git a/src/main/java/com/baidubce/services/bos/demo/GetObjectDemo.java b/src/main/java/com/baidubce/services/bos/demo/GetObjectDemo.java new file mode 100644 index 00000000..bd7905f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/GetObjectDemo.java @@ -0,0 +1,77 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.BceServiceException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.BosObject; +import com.baidubce.services.bos.model.GetObjectRequest; +import com.baidubce.services.bos.model.ObjectMetadata; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +/** + * 下载object的demo + */ +public class GetObjectDemo { + // 读Object到一个流 + public static void getObjectToStream() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 获取Object,返回结果为BosObject对象 + BosObject object = client.getObject("bucketName", "objectKey"); + + // 获取ObjectMeta + ObjectMetadata meta = object.getObjectMetadata(); + + // 获取Object的输入流 + InputStream objectContent = object.getObjectContent(); + + // 处理这个流... + + // 关闭流 + try { + if (objectContent != null) { + objectContent.close(); + } + } catch (IOException e) { + throw new BceServiceException("", e); + } + + // 关闭客户端 + client.shutdown(); + } + + // 读Object到一个文件 + public static void getObjectToFile() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 新建GetObjectRequest + GetObjectRequest getObjectRequest = new GetObjectRequest("bucketName", "objectKey"); + + // 下载Object到文件 + ObjectMetadata objectMetadata = + client.getObject(getObjectRequest, new File("/path/to/file","filename")); + + // 关闭客户端 + client.shutdown(); + } +} diff --git a/src/main/java/com/baidubce/services/bos/demo/GetObjectMetaDemo.java b/src/main/java/com/baidubce/services/bos/demo/GetObjectMetaDemo.java new file mode 100644 index 00000000..feb37667 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/GetObjectMetaDemo.java @@ -0,0 +1,35 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.ObjectMetadata; + +/** + * 获取ObjectMetadata的demo + */ +public class GetObjectMetaDemo { + // 只获取ObjectMetadata而不获取Object的实体 + public static void getObjectMeta() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + ObjectMetadata objectMetadata = client.getObjectMetadata("bucketName", "objectKey"); + // 查看object元信息 + System.out.println("contentType: " + objectMetadata.getContentType() + "\n" + + "contentLength: " + objectMetadata.getContentLength() + "\n" + + "contentMd5: " + objectMetadata.getContentMd5() + "\n" + + "etag: " + objectMetadata.getETag() + "\n" + + "storageClass: " + objectMetadata.getStorageClass() + "\n"); + + // 关闭客户端 + client.shutdown(); + } +} diff --git a/src/main/java/com/baidubce/services/bos/demo/ListObjectsDemo.java b/src/main/java/com/baidubce/services/bos/demo/ListObjectsDemo.java new file mode 100644 index 00000000..7f719e92 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/ListObjectsDemo.java @@ -0,0 +1,138 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.BosObjectSummary; +import com.baidubce.services.bos.model.ListObjectsRequest; +import com.baidubce.services.bos.model.ListObjectsResponse; + +/** + * 列出bucket下的objects、列出指定dir下的文件的demo + */ +public class ListObjectsDemo { + // 简单快速列举出所需的文件,默认情况下,如果Bucket中的Object数量大于1000,则只会返回1000个Object + public static void listObjectsSimple() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 获取指定Bucket下的所有Object信息 + ListObjectsResponse listing = client.listObjects("bucketName"); + + // 遍历所有Object + for (BosObjectSummary objectSummary : listing.getContents()) { + System.out.println("ObjectKey: " + objectSummary.getKey()); + } + + // 关闭客户端 + client.shutdown(); + } + + // 设置参数,灵活列举 + public static void listObjectsWithArgs() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + ListObjectsRequest listObjectsRequest = new ListObjectsRequest("bucketName"); + // 指定最大返回条数为500 + listObjectsRequest.withMaxKeys(500); + // 指定返回前缀为test的object + listObjectsRequest.withPrefix("obj"); + // 从"object"其之后开始返回 + listObjectsRequest.withMarker("object"); + + ListObjectsResponse listObjectsResponse = client.listObjects(listObjectsRequest); + for(BosObjectSummary objectSummary :listObjectsResponse.getContents()) { + System.out.println("ObjectKey:" + objectSummary.getKey()); + } + + // 关闭客户端 + client.shutdown(); + } + + // 分页列举所有的Object + public static void listAllObjects() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 用户可设置每页最多500条记录 + ListObjectsRequest listObjectsRequest = new ListObjectsRequest("bucketName"); + ListObjectsResponse listObjectsResponse; + listObjectsRequest.withMaxKeys(500); + boolean isTruncated = true; + while (isTruncated) { + listObjectsResponse = client.listObjects(listObjectsRequest); + + for(BosObjectSummary objectSummary :listObjectsResponse.getContents()) { + System.out.println("ObjectKey:" + objectSummary.getKey()); + } + isTruncated = listObjectsResponse.isTruncated(); + if (listObjectsResponse.getNextMarker() != null) { + listObjectsRequest.withMarker(listObjectsResponse.getNextMarker()); + } + } + + // 关闭客户端 + client.shutdown(); + } + + // 查看目录下的文件和子目录 + public static void listObjectsAndDir() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 构造ListObjectsRequest请求 + ListObjectsRequest listObjectsRequest = new ListObjectsRequest("bucketName"); + + // "/" 为文件夹的分隔符 + listObjectsRequest.setDelimiter("/"); + + // 列出fun目录下的文件和文件夹 + listObjectsRequest.setPrefix("fun/"); + + ListObjectsResponse listing = client.listObjects(listObjectsRequest); + + // 遍历Object + System.out.println("Objects:"); + for (BosObjectSummary objectSummary : listing.getContents()) { + System.out.println(objectSummary.getKey()); + } + + // 遍历CommonPrefix(文件夹) + System.out.println("\nCommonPrefixs:"); + for (String commonPrefix : listing.getCommonPrefixes()) { + System.out.println(commonPrefix); + } + + // 关闭客户端 + client.shutdown(); + } +} diff --git a/src/main/java/com/baidubce/services/bos/demo/MultipartUploadDemo.java b/src/main/java/com/baidubce/services/bos/demo/MultipartUploadDemo.java new file mode 100644 index 00000000..403a074c --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/MultipartUploadDemo.java @@ -0,0 +1,178 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.BceServiceException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * + */ +public class MultipartUploadDemo { + public static void main(String[] args) { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + String uploadId = initMultipartUpload(client); + List partETags = uploadPart(client, uploadId); + completePart(client, uploadId, partETags); + + // 关闭客户端 + client.shutdown(); + } + + // 初始化Multipart Upload + public static String initMultipartUpload(BosClient client) { + // 开始Multipart Upload + InitiateMultipartUploadRequest initiateMultipartUploadRequest = + new InitiateMultipartUploadRequest("bucketName", "objectKey"); + InitiateMultipartUploadResponse initiateMultipartUploadResponse = + client.initiateMultipartUpload(initiateMultipartUploadRequest); + + // 打印UploadId,它是区分分块上传事件的唯一标识,在后面的操作中,我们将用到它。 + String uploadId = initiateMultipartUploadResponse.getUploadId(); + System.out.println("UploadId: " + uploadId); + + return uploadId; + } + + // 分块上传 + public static List uploadPart(BosClient client, String uploadId) { + // 设置每块为 5MB + final long partSize = 1024 * 1024 * 5L; + + File partFile = new File("/path/to/file.zip"); + + // 计算分块数目 + int partCount = (int) (partFile.length() / partSize); + if (partFile.length() % partSize != 0){ + partCount++; + } + + // 新建一个List保存每个分块上传后的ETag和PartNumber + List partETags = new ArrayList(); + + try { + for(int i = 0; i < partCount; i++){ + // 获取文件流 + FileInputStream fis = new FileInputStream(partFile); + + // 跳到每个分块的开头 + long skipBytes = partSize * i; + fis.skip(skipBytes); + + // 计算每个分块的大小 + long size = Math.min(partSize, partFile.length() - skipBytes); + + // 创建UploadPartRequest,上传分块 + UploadPartRequest uploadPartRequest = new UploadPartRequest(); + uploadPartRequest.setBucketName("bucketName"); + uploadPartRequest.setKey("objectKey"); + uploadPartRequest.setUploadId(uploadId); + uploadPartRequest.setInputStream(fis); + uploadPartRequest.setPartSize(size); + uploadPartRequest.setPartNumber(i + 1); + UploadPartResponse uploadPartResponse = client.uploadPart(uploadPartRequest); + + // 将返回的PartETag保存到List中。 + partETags.add(uploadPartResponse.getPartETag()); + + // 关闭文件 + fis.close(); + } + } catch (IOException e) { + throw new BceServiceException("", e); + } + + + // PartETag 对象,它是上传块的ETag与块编号(PartNumber)的组合,在后续完成分块上传的步骤中会用到它 + // 返回List + return partETags; + } + + // 完成分块上传 + public static void completePart(BosClient client, String uploadId, List partETags) { + // 分块上传结束之后,当所有的数据Part验证通过后,BOS将把这些数据part组合成一个完整的Object + CompleteMultipartUploadRequest completeMultipartUploadRequest = + new CompleteMultipartUploadRequest("bucketName", "objectKey", uploadId, partETags); + CompleteMultipartUploadResponse completeMultipartUploadResponse = + client.completeMultipartUpload(completeMultipartUploadRequest); + + // 打印Object的ETag + System.out.println(completeMultipartUploadResponse.getETag()); + } + + // 取消分块上传 + public static void abortPartUploadDemo(BosClient client, String uploadId) { + // 可以使用abortMultipartUpload方法取消分块上传 + AbortMultipartUploadRequest abortMultipartUploadRequest = + new AbortMultipartUploadRequest("bucketName", "objectKey", uploadId); + + client.abortMultipartUpload(abortMultipartUploadRequest); + } + + // 获取未完成的分块上传事件 + public static void listMultipartUploads(BosClient client) { + ListMultipartUploadsRequest listMultipartUploadsRequest = + new ListMultipartUploadsRequest("bucketName"); + + // 获取Bucket内未完成的分块上传事件 + ListMultipartUploadsResponse listing = client.listMultipartUploads(listMultipartUploadsRequest); + + // 遍历所有上传事件 + for (MultipartUploadSummary multipartUpload : listing.getMultipartUploads()) { + System.out.println("Key: " + multipartUpload.getKey() + " UploadId: " + multipartUpload.getUploadId()); + } + } + + // 获取所有已上传的块信息 + public static void listParts(BosClient client, String uploadId) { + ListPartsRequest listPartsRequest = new ListPartsRequest("bucketName", "objectKey", uploadId); + + // 获取上传的所有Part信息 + ListPartsResponse partListing = client.listParts(listPartsRequest); + + // 遍历所有Part + for (PartSummary part : partListing.getParts()) { + System.out.println("PartNumber: " + part.getPartNumber() + " ETag: " + part.getETag()); + } + + // 查看Object的存储类型 + String storageClass = partListing.getStorageClass(); + System.out.println("storage class: " + storageClass); + } + + // 封装分块上传,一个接口完成分块上传 + public static void putSuperObject() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + File file = new File("/path/to/file.zip"); + PutSuperObjectRequest request = new PutSuperObjectRequest("bucketName", "objectKey", file); + client.putSuperObjectFromFile(request); + + // 关闭客户端 + client.shutdown(); + } +} diff --git a/src/main/java/com/baidubce/services/bos/demo/PutObjectDemo.java b/src/main/java/com/baidubce/services/bos/demo/PutObjectDemo.java new file mode 100644 index 00000000..29616104 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/PutObjectDemo.java @@ -0,0 +1,95 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.ObjectMetadata; +import com.baidubce.services.bos.model.PutObjectResponse; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** + * 简单上传object,包括以文件、数据流、二进制串、字符串方式;上传时设置object元信息的demo + */ +public class PutObjectDemo { + // 简单上传,支持以指定文件形式、以数据流方式、以二进制串方式、以字符串方式执行Object上传 + public static void putObjectSimple() throws FileNotFoundException { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 获取指定文件 + File file = new File("/path/to/file.zip"); + // 获取数据流 + InputStream inputStream = new FileInputStream("/path/to/test.zip"); + byte[] byte0 = new byte[0]; + + // 以文件形式上传Object + PutObjectResponse putObjectFromFileResponse = + client.putObject("bucketName", "file-objectKey", file); + // 以数据流形式上传Object + PutObjectResponse putObjectResponseFromInputStream = + client.putObject("bucketName", "inputStream-objectKey", inputStream); + // 以二进制串上传Object + PutObjectResponse putObjectResponseFromByte = + client.putObject("bucketName", "byte-objectKey", byte0); + // 以字符串上传Object + PutObjectResponse putObjectResponseFromString = + client.putObject("bucketName", "string-objectKey", "hello world"); + + // 打印ETag + System.out.println(putObjectFromFileResponse.getETag()); + System.out.println(putObjectResponseFromInputStream.getETag()); + System.out.println(putObjectResponseFromByte.getETag()); + System.out.println(putObjectResponseFromString.getETag()); + + // 关闭客户端 + client.shutdown(); + } + + // 上传object时设置文件元信息meta + public static void putObjectWithMeta() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 获取指定文件 + File file = new File("/path/to/file.zip"); + + // 初始化上传输入流 + ObjectMetadata meta = new ObjectMetadata(); + // 设置ContentLength大小 + meta.setContentLength(1000); + // 设置ContentType + meta.setContentType("application/json"); + // 设置cache-control + meta.setCacheControl("no-cache"); + // 设置x-bce-content-crc32 + meta.setxBceCrc("crc"); + + // 设置自定义元数据name的值为my-data + meta.addUserMetadata("name", "my-data"); + + // 上传Object + client.putObject("bucketName", "objectKey", file, meta); + + // 关闭客户端 + client.shutdown(); + } + +} diff --git a/src/main/java/com/baidubce/services/bos/demo/SelectContentDemo.java b/src/main/java/com/baidubce/services/bos/demo/SelectContentDemo.java new file mode 100644 index 00000000..c79a068a --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/SelectContentDemo.java @@ -0,0 +1,143 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.InputSerialization; +import com.baidubce.services.bos.model.OutputSerialization; +import com.baidubce.services.bos.model.SelectObjectRequest; +import com.baidubce.services.bos.model.SelectObjectResponse; + +import java.io.ByteArrayInputStream; + +/** + * 选取特定文件内容的demo + */ +public class SelectContentDemo { + // 选取CSV文件类型的内容 + public static void selectCsv() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + final String csvContent = "header1,header2,header3\r\n" + + "1,2,3.4\r\n" + + "a,b,c\r\n" + + "\"d\",\"e\",\"f\"\r\n" + + "true,false,true\r\n" + + "2006-01-02 15:04:06,2006-01-02 16:04:06,2006-01-02 17:04:06"; + client.putObject("bucketName", "test-csv", new ByteArrayInputStream(csvContent.getBytes())); + + SelectObjectRequest request = new SelectObjectRequest("bucketName", "test-csv") + .withSelectType("csv") + .withExpression("select * from BosObject limit 3") + .withInputSerialization(new InputSerialization() + .withCompressionType("NONE") + .withFileHeaderInfo("NONE") + .withRecordDelimiter("\r\n") + .withFieldDelimiter(",") + .withQuoteCharacter("\"") + .withCommentCharacter("#")) + .withOutputSerialization(new OutputSerialization() + .withOutputHeader(false) + .withQuoteFields("ALWAYS") + .withRecordDelimiter("\n") + .withFieldDelimiter(",") + .withQuoteCharacter("\"")) + .withRequestProgress(false); + SelectObjectResponse response = client.selectObject(request); + + // 输出返回的记录 + SelectObjectResponse.Messages messages = response.getMessages(); + while (messages.hasNext()) { + SelectObjectResponse.CommonMessage message = messages.next(); + if (message.Type.equals("Records")) { + for (String record: message.getRecords()) { + System.out.println(record); + } + } + } + + /** + * 输出结果: + * + * "header1","header2","header3" + * "1","2","3.4" + * "a","b","c" + * + */ + + // 关闭客户端 + client.shutdown(); + } + + // 选取JSON文件类型的内容 + public static void selectJson() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + final String jsonContent = "{\n" + + "\t\"name\": \"Smith\",\n" + + "\t\"age\": 16,\n" + + "\t\"org\": null\n" + + "}\n" + + "{\n" + + "\t\"name\": \"charles\",\n" + + "\t\"age\": 27,\n" + + "\t\"org\": \"baidu\"\n" + + "}\n" + + "{\n" + + "\t\"name\": \"jack\",\n" + + "\t\"age\": 35,\n" + + "\t\"org\": \"bos\"\n" + + "}"; + client.putObject("bucketName", "test-json", new ByteArrayInputStream(jsonContent.getBytes())); + + SelectObjectRequest request = new SelectObjectRequest("bucketName", "test-json") + .withSelectType("json") + .withExpression("select * from BosObject where age > 20") + .withInputSerialization(new InputSerialization() + .withCompressionType("NONE") + .withJsonType("LINES")) + .withOutputSerialization(new OutputSerialization() + .withRecordDelimiter("\n")) + .withRequestProgress(false); + SelectObjectResponse response = client.selectObject(request); + + // 输出返回的记录 + SelectObjectResponse.Messages messages = response.getMessages(); + while (messages.hasNext()) { + SelectObjectResponse.CommonMessage message = messages.next(); + if (message.Type.equals("Records")) { + for (String record: message.getRecords()) { + System.out.println(record); + } + } + } + + /** + * 输出结果: + * + * {"name":"charles","age":27,"org":"baidu"} + * {"name":"jack","age":35,"org":"bos"} + * + */ + + // 关闭客户端 + client.shutdown(); + } + +} diff --git a/src/main/java/com/baidubce/services/bos/demo/SetObjectAclDemo.java b/src/main/java/com/baidubce/services/bos/demo/SetObjectAclDemo.java new file mode 100644 index 00000000..4f32a95c --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/demo/SetObjectAclDemo.java @@ -0,0 +1,88 @@ +package com.baidubce.services.bos.demo; + +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.*; + +import java.util.ArrayList; +import java.util.List; + +/** + * BOS支持两种方式设置ACL。第一种是使用Canned Acl,第二种方式是上传一个ACL文件。 + */ +public class SetObjectAclDemo { + // 通过使用头域的"x-bce-acl"或者"x-bce-grant-permission'来设置object访问权限 + public static void setAclByCanned() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 1. 设置为public read + SetObjectAclRequest setObjectAclRequest1 = new SetObjectAclRequest("bucketName","objectKey-publicRead", CannedAccessControlList.PublicRead); + client.setObjectAcl(setObjectAclRequest1); + + // 2. 设置为user_id1、user_id2可访问 + String xBceGrantRead = "id=\"user_id1\""+",id=\"user_id2\""; + SetObjectAclRequest setObjectAclRequest2 = new SetObjectAclRequest(); + setObjectAclRequest2.withBucketName("yourBucketName"); + setObjectAclRequest2.withKey("objectKey"); + setObjectAclRequest2.setxBceGrantRead(xBceGrantRead); + client.setObjectAcl(setObjectAclRequest2); + + // 3. 设置为user_id1、user_id2有full control权限 + String xBceGrantFullControl = "id=\"user_id1\""+",id=\"user_id2\""; + SetObjectAclRequest setObjectAclRequest3 = new SetObjectAclRequest(); + setObjectAclRequest3.withBucketName("yourBucketName"); + setObjectAclRequest3.withKey("objectKey"); + setObjectAclRequest3.setxBceGrantFullControl(xBceGrantFullControl); + client.setObjectAcl(setObjectAclRequest3); + + // 关闭客户端 + client.shutdown(); + } + + // 通过setObjectAcl设置object访问权限 + public static void setAclByArgs() { + String ACCESS_KEY_ID = "akxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Access Key ID + String SECRET_ACCESS_KEY = "skxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // 用户的Secret Access Key + String ENDPOINT = "bj.bcebos.com"; // 用户自己指定的域名,参考说明文档 + + // 初始化一个BosClient + BosClientConfiguration config = new BosClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY)); + config.setEndpoint(ENDPOINT); + BosClient client = new BosClient(config); + + // 1. 以jason字符串方式 + String jsonObjectAcl = + "{\"accessControlList\":["+ + "{\"grantee\":[{\"id\":\"*\"}], "+ + "\"permission\":[\"FULL_CONTROL\"]"+ "}]}"; + SetObjectAclRequest setObjectAclRequest1 = new SetObjectAclRequest("yourBucketName","objectKey",jsonObjectAcl); + client.setObjectAcl(setObjectAclRequest1); + + // 2. 指定参数方式 + List grants = new ArrayList(); + List grantees = new ArrayList(); + List permissions = new ArrayList(); + // 授权给特定用户 + grantees.add(new Grantee("user_id1")); + grantees.add(new Grantee("user_id2")); + grantees.add(new Grantee("user_id3")); + // 设置权限 + permissions.add(Permission.READ); + grants.add(new Grant().withGrantee(grantees).withPermission(permissions)); + SetObjectAclRequest setObjectAclRequest2 = new SetObjectAclRequest("yourBucketName","objectKey", grants); + client.setObjectAcl(setObjectAclRequest2); + + // 关闭客户端 + client.shutdown(); + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/Action.java b/src/main/java/com/baidubce/services/bos/model/Action.java new file mode 100644 index 00000000..b485c40b --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/Action.java @@ -0,0 +1,93 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * For Bos Bucket Lifecycle. + * Operation actions performed on the resource. + * Required Parameters: actionName. + * Optional Parameters: actionStorageClass. + */ +public class Action { + + /** + * The performed operation name. + * Values are Transition, DeleteObject, AbortMultipartUpload. + */ + private String name; + + /** + * Object storage type. + * When the action is Transition, it can be set to STANDARD_IA or COLD, + * indicating that the transition from the original storage type to low, + * frequency storage or cold storage. + */ + private String storageClass; + + /** + * Gets the name of the bucket Lifecycle, just for Lifecycle json + * @return the name of the bucket Lifecycle. + */ + public String getName() { + return name; + } + + /** + * Sets the name of the bucket Lifecycle, just for Lifecycle json + * @param name of the bucket Lifecycle. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Sets the name of the Action. + * @param name The name of the Action + * @return this object + */ + public Action withName(String name) { + this.name = name; + return this; + } + + /** + * Gets the storageClass of the bucket Lifecycle, just for Lifecycle json + * @return the storageClass of the bucket Lifecycle. + */ + public String getStorageClass() { + return storageClass; + } + + /** + * Sets the storageClass of the bucket Lifecycle Action,just for Lifecycle json + * @param storageClass The storageClass if the Bucket Lifecycel Action. + */ + public void setStorageClass(String storageClass) { + this.storageClass = storageClass; + } + + /** + * sets the storageClass of the Bucket Lifecycle Action + * @param storageClass The storageClass if the Bucket Lifecycel Action. + * @return this object + */ + public Action withStorageClass(String storageClass) { + this.storageClass = storageClass; + return this; + } + + @Override + public String toString() { + return "Action{" + "name='" + name + '\'' + ", storageClass='" + storageClass + '\'' + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/AllowedMethods.java b/src/main/java/com/baidubce/services/bos/model/AllowedMethods.java new file mode 100644 index 00000000..5c148a1e --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/AllowedMethods.java @@ -0,0 +1,26 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * For Bucket CORS(Cross-Origin Resource Sharing). + * Specifying a method for allowing cross-domain requests. + * Type: Enumeration,with values GET, PUT, DELETE,POST,HEAD. + */ +public enum AllowedMethods { + GET, + PUT, + DELETE, + POST, + HEAD; +} diff --git a/src/main/java/com/baidubce/services/bos/model/AppendObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/AppendObjectRequest.java index 082c060a..6ceea2cb 100644 --- a/src/main/java/com/baidubce/services/bos/model/AppendObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/AppendObjectRequest.java @@ -35,6 +35,11 @@ public class AppendObjectRequest extends PutObjectRequest { */ private Long offset; + /** + * The BosProgressCallback used for get progress information + */ + private BosProgressCallback progressCallback = null; + /** * Constructs a new AppendObjectRequest object to upload a file to the * specified bucket and key. After constructing the request, @@ -236,4 +241,30 @@ public AppendObjectRequest withKey(String key) { this.setKey(key); return this; } + + /** + * Gets the BosProgressCallback which used for Get upload progress. + * @return The BosProgressCallback which used for get progress information. + */ + public BosProgressCallback getProgressCallback() { + return progressCallback; + } + + /** + * Sets the BosProgressCallback which used for Get upload progress. + * @param progressCallback The BosProgressCallback, which used for get progress information. + */ + public void setProgressCallback(BosProgressCallback progressCallback) { + this.progressCallback = progressCallback; + } + + /** + * + * @param progressCallback The BosProgressCallback, which used for get progress information. + * @return This AppendObjectRequest, so that additional method calls can be chained together + */ + public AppendObjectRequest withProgressCallback(BosProgressCallback progressCallback) { + this.setProgressCallback(progressCallback); + return this; + } } diff --git a/src/main/java/com/baidubce/services/bos/model/BosObjectSummary.java b/src/main/java/com/baidubce/services/bos/model/BosObjectSummary.java index c4613fdb..ca8b4cc4 100644 --- a/src/main/java/com/baidubce/services/bos/model/BosObjectSummary.java +++ b/src/main/java/com/baidubce/services/bos/model/BosObjectSummary.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Date; +import java.util.Map; /** * Contains the summary of an object stored in a Baidu Bos bucket. This object doesn't contain contain the @@ -59,6 +60,9 @@ public class BosObjectSummary { */ protected String storageClass; + protected Map userMeta; + + /** * Gets the name of the Baidu Bos bucket in which this object is stored. * @@ -186,6 +190,14 @@ public void setStorageClass(String storageClass) { this.storageClass = storageClass; } + public Map getUserMeta() { + return userMeta; + } + + public void setUserMeta(Map userMeta) { + this.userMeta = userMeta; + } + @Override public String toString() { return "BosObjectSummary [\n bucketName=" + bucketName + ", \n key=" + key diff --git a/src/main/java/com/baidubce/services/bos/model/BosPrefixInfo.java b/src/main/java/com/baidubce/services/bos/model/BosPrefixInfo.java new file mode 100644 index 00000000..fb31549e --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/BosPrefixInfo.java @@ -0,0 +1,36 @@ +package com.baidubce.services.bos.model; + +import java.util.Date; + +import java.util.Map; + +public class BosPrefixInfo { + protected String prefix; + protected Date lastModified = null; + + protected Map userMeta; + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public Map getUserMeta() { + return userMeta; + } + + public void setUserMeta(Map userMeta) { + this.userMeta = userMeta; + } + + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/BosProgressCallback.java b/src/main/java/com/baidubce/services/bos/model/BosProgressCallback.java new file mode 100644 index 00000000..5b61b514 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/BosProgressCallback.java @@ -0,0 +1,58 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.services.bos.callback.ProgressCallback; + +import java.util.concurrent.atomic.AtomicLong; + +/** + * Callback interface used for get progress information + */ + +public abstract class BosProgressCallback implements ProgressCallback { + private AtomicLong currentSize = new AtomicLong(0L); + private AtomicLong totalSize = new AtomicLong(0L);; + private T data = null; + + @Override + public void onProgress(long currentSize, long totalSize, T data) { + } + + public void setData(T data) { + this.data = data; + } + + public T getData() { + return this.data; + } + + public BosProgressCallback withData(T data) { + this.setData(data); + return this; + } + + public long getCurrentSize() { + return currentSize.get(); + } + + public void setCurrentSize(long currentSize) { + this.currentSize.set(currentSize); + } + + public void addCurrentSize(long size) { + if (currentSize.get() + size > totalSize.get()) { + currentSize.set(totalSize.get()); + } else { + currentSize.addAndGet(size); + } + onProgress(currentSize.get(), totalSize.get(), data); + } + + public long getTotalSize() { + return totalSize.get(); + } + + public void setTotalSize(long totalSize) { + this.totalSize.set(totalSize); + } +} + diff --git a/src/main/java/com/baidubce/services/bos/model/BosResponse.java b/src/main/java/com/baidubce/services/bos/model/BosResponse.java index 94af7587..0ea7e128 100644 --- a/src/main/java/com/baidubce/services/bos/model/BosResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/BosResponse.java @@ -13,14 +13,40 @@ package com.baidubce.services.bos.model; import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; public class BosResponse extends AbstractBceResponse { public BosResponse() { this.metadata = new BosResponseMetadata(); + this.callback = new Callback(); } @Override public BosResponseMetadata getMetadata() { return (BosResponseMetadata) this.metadata; } + + @JsonProperty("callback") + private Callback callback; + + public void setCallback(Callback callback) { + this.callback = callback; + } + + public Callback getCallback() { + return callback; + } + + @Data + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Callback { + @JsonProperty("result") + private String result; + } } diff --git a/src/main/java/com/baidubce/services/bos/model/BosResponseMetadata.java b/src/main/java/com/baidubce/services/bos/model/BosResponseMetadata.java index 4bf3da72..ed44ff32 100644 --- a/src/main/java/com/baidubce/services/bos/model/BosResponseMetadata.java +++ b/src/main/java/com/baidubce/services/bos/model/BosResponseMetadata.java @@ -20,6 +20,10 @@ public class BosResponseMetadata extends BceResponseMetadata { private Long nextAppendOffset; + private String xBceVersioning; + + private String xBceVersionId; + public String getBosDebugId() { return this.debugId; } @@ -36,5 +40,19 @@ public void setNextAppendOffset(Long nextAppendOffset) { this.nextAppendOffset = nextAppendOffset; } + public String getxBceVersioning() { + return xBceVersioning; + } + + public void setxBceVersioning(String xBceVersioning) { + this.xBceVersioning = xBceVersioning; + } + + public String getxBceVersionId() { + return xBceVersionId; + } + public void setxBceVersionId(String xBceVersionId) { + this.xBceVersionId = xBceVersionId; + } } diff --git a/src/main/java/com/baidubce/services/bos/model/BucketEncryption.java b/src/main/java/com/baidubce/services/bos/model/BucketEncryption.java new file mode 100644 index 00000000..f14bed73 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/BucketEncryption.java @@ -0,0 +1,63 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Bucket encryption + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BucketEncryption { + + private String encryptionAlgorithm; + private String kmsMasterKeyId; + + /** + * Creates a default instance + */ + public BucketEncryption() { + + } + + public BucketEncryption(String encryptionAlgorithm, String kmsMasterKeyId) { + this.encryptionAlgorithm = encryptionAlgorithm; + this.kmsMasterKeyId = kmsMasterKeyId; + } + + public String getEncryptionAlgorithm() { + return encryptionAlgorithm; + } + + public void setEncryptionAlgorithm(String encryptionAlgorithm) { + this.encryptionAlgorithm = encryptionAlgorithm; + } + + public BucketEncryption withEncryptionAlgorithm(String encryptionAlgorithm) { + setEncryptionAlgorithm(encryptionAlgorithm); + return this; + } + + public String getKmsMasterKeyId() { + return kmsMasterKeyId; + } + + public void setKmsMasterKeyId(String kmsMasterKeyId) { + this.kmsMasterKeyId = kmsMasterKeyId; + } + + public BucketEncryption withKmsMasterKeyId(String kmsMasterKeyId) { + setKmsMasterKeyId(kmsMasterKeyId); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/BucketMirroringConfiguration.java b/src/main/java/com/baidubce/services/bos/model/BucketMirroringConfiguration.java new file mode 100644 index 00000000..b6012d58 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/BucketMirroringConfiguration.java @@ -0,0 +1,34 @@ +package com.baidubce.services.bos.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * Specifies a BucketMirroringConfiguration, use to setting bos bucket mirroring. + * (https://cloud.baidu.com/doc/BOS/s/Ylha9sbks) + */ +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Data +public class BucketMirroringConfiguration { + private String mode; + private String sourceUrl; + private String backSourceUrl; + private String resource; + private String prefix; + private String suffix; + private String fixedKey; + private String version; + private String prefixReplace; + private String passQueryString; + private List customHeaders; + private String storageClass; + private String allHeader; + private List ignoreHeaders; + private List passHeaders; +} diff --git a/src/main/java/com/baidubce/services/bos/model/BucketReplicationProgress.java b/src/main/java/com/baidubce/services/bos/model/BucketReplicationProgress.java new file mode 100644 index 00000000..f4423a4b --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/BucketReplicationProgress.java @@ -0,0 +1,71 @@ +/* + * Copyright 2014-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Bucket Replication Progress + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BucketReplicationProgress extends BosResponse { + + /** + * The flags of enable bucket replications, Options is enabled or disabled; + */ + private String status; + + /** + * The history replicate percent + */ + private int historyReplicationPercent; + + /** + * The latest replication Time + */ + private long latestReplicationTime; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public int getHistoryReplicationPercent() { + return historyReplicationPercent; + } + + public void setHistoryReplicationPercent(int historyReplicationPercent) { + this.historyReplicationPercent = historyReplicationPercent; + } + + public long getLatestReplicationTime() { + return latestReplicationTime; + } + + public void setLatestReplicationTime(long latestReplicationTime) { + this.latestReplicationTime = latestReplicationTime; + } + + @Override + public String toString() { + return "BucketReplicationProgress{" + + "status='" + status + '\'' + + ", historyReplicationPercent=" + historyReplicationPercent + + ", latestReplicationTime=" + latestReplicationTime + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/bos/model/BucketTag.java b/src/main/java/com/baidubce/services/bos/model/BucketTag.java new file mode 100644 index 00000000..b4979279 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/BucketTag.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bos.model; + +import com.fasterxml.jackson.annotation.JsonAlias; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Data +public class BucketTag { + @JsonAlias({"tag_key"}) + private String tagKey; + @JsonAlias({"tag_value"}) + private String tagValue; +} diff --git a/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadRequest.java b/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadRequest.java index e3f01e86..ccbfc5e4 100644 --- a/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadRequest.java @@ -39,6 +39,11 @@ public class CompleteMultipartUploadRequest extends GenericUploadRequest { */ private List partETags; + /** + * The xBceCrc32cFlag, whether to calculate crc32c + */ + private boolean xBceCrc32cFlag = false; + public CompleteMultipartUploadRequest() { super(); } @@ -204,4 +209,20 @@ public CompleteMultipartUploadRequest withPartETags(List partETags) { this.setPartETags(partETags); return this; } + + /** + * Gets xBceCrc32cFlag of the object + * @return xBceCrc32cFlag of the object. + */ + public boolean getxBceCrc32cFlag() { + return xBceCrc32cFlag; + } + + /** + * Sets xBceCrc32cFlag of the object + * @param xBceCrc32cFlag whether to calculate crc32c. + */ + public void setxBceCrc32cFlag(boolean xBceCrc32cFlag) { + this.xBceCrc32cFlag = xBceCrc32cFlag; + } } diff --git a/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java b/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java old mode 100644 new mode 100755 index f22be91f..d5e04355 --- a/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java @@ -78,6 +78,8 @@ public void setBucketName(String bucketName) { /** * Gets the key by which the newly created object is stored. + * + * @return the key value */ public String getKey() { return this.key; @@ -85,6 +87,8 @@ public String getKey() { /** * Sets the key of the newly created object. + * + * @param key the key of the newly created object. */ public void setKey(String key) { this.key = key; diff --git a/src/main/java/com/baidubce/services/bos/model/Condition.java b/src/main/java/com/baidubce/services/bos/model/Condition.java new file mode 100644 index 00000000..76af18fd --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/Condition.java @@ -0,0 +1,190 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * The Conditon For Bucket Acl and Bucket Lifecycle. + * conditonTime for Bucket Lifecycle, the time restrictions, Implemented by the defined dateGreaterThan. + * referer for Bucket Acl, Identifies the referer that is granted access permission. + * ipAddress for Bucket Acl, Identifies the ip that is granted access permission. + */ +public class Condition { + + /** + * the conditonTime of Bucket Lifecycle. + */ + private Time time; + + /** + * the referer of Bucket Acl. + */ + private Referer referer; + + /** + * the ipAddress of Bucket Acl, just for Bucket Acl json + */ + private List ipAddress; + + /** + * the notIpAddress of Bucket Acl, just for Bucket Acl json + */ + private List notIpAddress; + + /** + * the secureTransport of Bucket Acl + */ + private boolean secureTransport; + + /** + * Gets time of Bucket Lifecycle. + * @return time of Bucket Lifecycle. + */ + public Time getTime() { + return time; + } + + /** + * Sets time of Bucket Lifecycle. + * @param time The time of Bucket Lifecycle. + */ + public void setTime(Time time) { + this.time = time; + } + + /** + * Sets time of Bucket Lifecycle. + * @param time The time of Bucket Lifecycle. + * @return this object. + */ + public Condition withTime(Time time) { + this.setTime(time); + return this; + } + + /** + * Gets notIpAddress of Bucket Acl, just for Bucket Acl json + * @return notIpAddress of Bucket Acl. + */ + public List getNotIpAddress() { + return notIpAddress; + } + + /** + * Sets notIpAddress of Bucket Acl, just for Bucket Acl json + * @param notIpAddress The ipAddress of Bucket Acl. + */ + public void setNotIpAddress(List notIpAddress) { + this.notIpAddress = notIpAddress; + } + + /** + * Sets notIpAddress of Bucket Acl, just for Bucket Acl json + * @param notIpAddress The ipAddress of Bucket Acl. + * @return this object. + */ + public Condition withNotIpAddress(List notIpAddress) { + this.setNotIpAddress(notIpAddress); + return this; + } + + /** + * Gets ipAddress of Bucket Acl, just for Bucket Acl json + * @return ipAddress of Bucket Acl. + */ + public List getIpAddress() { + return ipAddress; + } + + /** + * Sets ipAddress of Bucket Acl, just for Bucket Acl json + * @param ipAddress The ipAddress of Bucket Acl. + */ + public void setIpAddress(List ipAddress) { + this.ipAddress = ipAddress; + } + + /** + * Sets ipAddress of Bucket Acl, just for Bucket Acl json + * @param ipAddress The ipAddress of Bucket Acl. + * @return this object. + */ + public Condition withIpAddress(List ipAddress) { + this.setIpAddress(ipAddress); + return this; + } + + /** + * Gets referer of Bucket Acl. + * @return referer of Bucket Acl. + */ + public Referer getReferer() { + return referer; + } + + /** + * Sets referer of Bucket Acl. + * @param referer The referer of Bucket Acl. + */ + public void setReferer(Referer referer) { + this.referer = referer; + } + + /** + * Sets referer of Bucket Acl. + * @param referer The referer of Bucket Acl. + * @return this object. + */ + public Condition withReferer(Referer referer) { + this.setReferer(referer); + return this; + } + + /** + * Gets secureTransport of Bucket Acl. + * @return secureTransport of Bucket Acl + */ + public boolean isSecureTransport() { + return secureTransport; + } + + /** + * Sets secureTransport of Bucket Acl. + * @param secureTransport + */ + public void setSecureTransport(boolean secureTransport) { + this.secureTransport = secureTransport; + } + + /** + * Sets secureTransport of Bucket Acl. + * @param secureTransport The secureTransport of Bucket Acl + * @return this object. + */ + public Condition withSecureTransport(boolean secureTransport) { + this.setSecureTransport(secureTransport); + return this; + } + + + @Override + public String toString() { + return "Condition{" + + "time=" + time + + ", referer=" + referer + + ", ipAddress=" + ipAddress + + '}'; + } +} + diff --git a/src/main/java/com/baidubce/services/bos/model/Constants.java b/src/main/java/com/baidubce/services/bos/model/Constants.java new file mode 100644 index 00000000..03e0a578 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/Constants.java @@ -0,0 +1,51 @@ +/* + * Copyright 2014-2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * Contains constants of bos source code + */ +public class Constants { + + public static final String APPLICATION_JSON = "application/json"; + + public static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + public static final String ENCRYPTION = "encryption"; + + public static final String WEBSITE = "website"; + + public static final String COPYRIGHTPROTECTION = "copyrightProtection"; + + public static final int MAX_PARTS = 10000; + + public static final String SELECT_TYPE_CSV = "csv"; + + public static final String SELECT_TYPE_JSON = "json"; + + public static final String SELECT_TYPE_PARQUET = "parquet"; + + public static final String FILE_HEADER_INFO = "fileHeaderInfo"; + + public static final String RECORD_DELIMITER = "recordDelimiter"; + + public static final String FIELD_DELIMITER = "fieldDelimiter"; + + public static final String QUOTE_CHARACTER = "quoteCharacter"; + + public static final String COMMENT_CHARACTER = "commentCharacter"; + + public static final String QUOTE_FIELDS = "quoteFields"; + + public static final String MESSAGE_TYPE = "message-type"; +} diff --git a/src/main/java/com/baidubce/services/bos/model/CopyObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/CopyObjectRequest.java old mode 100644 new mode 100755 index 8b1bb22f..d9d2ae0c --- a/src/main/java/com/baidubce/services/bos/model/CopyObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/CopyObjectRequest.java @@ -18,7 +18,6 @@ /** * Provides options for copying an Baidu Bos object from a source location to a new destination. - * *

* All CopyObjectRequests must specify a source bucket and key, along with a destination bucket and key. */ @@ -58,7 +57,7 @@ public class CopyObjectRequest extends GenericObjectRequest { private String unmodifiedSinceConstraint; /** - * If the value of the modifiedSinceConstraint is less than the actual file modification + * If the value of the modifiedSinceConstraint is less than the actual file modification * time, then take the normal file transfer process. */ private String modifiedSinceConstraint; @@ -69,13 +68,18 @@ public class CopyObjectRequest extends GenericObjectRequest { */ private String storageClass; + /** + * The xBceCrc32cFlag, whether to calculate crc32c + */ + private boolean xBceCrc32cFlag = false; + /** * Constructs a new CopyObjectRequest with only basic options. * * @param sourceBucketName The name of the Bos bucket containing the object to copy. - * @param sourceKey The source bucket key under which the object to copy is stored. - * @param bucketName The name of the Bos bucket to which the new object will be copied. - * @param key The destination bucket key under which the new object will be copied. + * @param sourceKey The source bucket key under which the object to copy is stored. + * @param bucketName The name of the Bos bucket to which the new object will be copied. + * @param key The destination bucket key under which the new object will be copied. */ public CopyObjectRequest(String sourceBucketName, String sourceKey, String bucketName, String key) { super(bucketName, key); @@ -108,7 +112,7 @@ public void setSourceBucketName(String sourceBucketName) { * * @param sourceBucketName The name of the bucket containing the source object to be copied. * @return This CopyObjectRequest instance, - * enabling additional method calls to be chained together. + * enabling additional method calls to be chained together. */ public CopyObjectRequest withSourceBucketName(String sourceBucketName) { this.setSourceBucketName(sourceBucketName); @@ -235,7 +239,7 @@ public String getETag() { * in order for the copy object request to be executed. * * @param eTag The optional ETag that when present must be a match for the source object's current ETag - * in order for this request to be executed. + * in order for this request to be executed. */ public void setETag(String eTag) { this.eTag = eTag; @@ -246,7 +250,7 @@ public void setETag(String eTag) { * in order for the copy object request to be executed. * * @param eTag The optional ETag that when present must be a match for the source object's current ETag - * in order for this request to be executed. + * in order for this request to be executed. * @return This CopyObjectRequest, enabling additional method calls to be chained together. */ public CopyObjectRequest withETag(String eTag) { @@ -256,8 +260,8 @@ public CopyObjectRequest withETag(String eTag) { /** * Gets the storageClass of the input file which is to be copyed to Baidu Bos. - * - * @return storageClass The storageClass is an identification that distinguish between infrequent access bos + * + * @return storageClass The storageClass is an identification that distinguish between infrequent access bos * and standard bos. */ public String getStorageClass() { @@ -266,8 +270,8 @@ public String getStorageClass() { /** * Sets the storageClass of the input file which is to be copyed to Baidu Bos. - * - * @param storageClass The storageClass is an identification that distinguish between infrequent access bos + * + * @param storageClass The storageClass is an identification that distinguish between infrequent access bos * and standard bos. */ public void setStorageClass(String storageClass) { @@ -277,7 +281,7 @@ public void setStorageClass(String storageClass) { /** * Sets the storageClass of the input file which is to be copyed to Baidu Bos. * - * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos + * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos * and standard bos. * @return This CopyObjectRequest, so that additional method calls can be chained together. */ @@ -297,10 +301,10 @@ public String getUnmodifiedSinceConstraint() { } /** - * Sets the the value of the unmodifiedSinceConstraint,if the value is equal to or later than the actual + * Sets the value of the unmodifiedSinceConstraint,if the value is equal to or later than the actual * file modification time, then take the normal file transfer process. * - * @param unmodifiedSinceConstraint + * @param unmodifiedSinceConstraint the value of the unmodifiedSinceConstraint */ public void setUnmodifiedSinceConstraint(String unmodifiedSinceConstraint) { this.unmodifiedSinceConstraint = unmodifiedSinceConstraint; @@ -310,7 +314,7 @@ public void setUnmodifiedSinceConstraint(String unmodifiedSinceConstraint) { * Sets the the value of the unmodifiedSinceConstraint,if the value is equal to or later than the actual * file modification time, then take the normal file transfer process. * - * @param unmodifiedSinceConstraint + * @param unmodifiedSinceConstraint the value of the unmodifiedSinceConstraint * @return This CopyObjectRequest, enabling additional method calls to be chained together. */ public CopyObjectRequest withUnmodifiedSinceConstraint(String unmodifiedSinceConstraint) { @@ -321,6 +325,7 @@ public CopyObjectRequest withUnmodifiedSinceConstraint(String unmodifiedSinceCon /** * Gets the the value of the modifiedSinceConstraint,if the value is less than the actual file modification * time, then take the normal file transfer process. + * * @return modifiedSinceConstraint */ public String getModifiedSinceConstraint() { @@ -328,9 +333,10 @@ public String getModifiedSinceConstraint() { } /** - * Sets the the value of the modifiedSinceConstraint,if the value is less than the actual file modification + * Sets the value of the modifiedSinceConstraint,if the value is less than the actual file modification * time, then take the normal file transfer process. - * @param modifiedSinceConstraint + * + * @param modifiedSinceConstraint the value of the modifiedSinceConstraint */ public void setModifiedSinceConstraint(String modifiedSinceConstraint) { this.modifiedSinceConstraint = modifiedSinceConstraint; @@ -340,7 +346,7 @@ public void setModifiedSinceConstraint(String modifiedSinceConstraint) { * Sets the the value of the modifiedSinceConstraint,if the value is less than the actual file modification * time, then take the normal file transfer process. * - * @param modifiedSinceConstraint + * @param modifiedSinceConstraint the value of the modifiedSinceConstraint * @return This CopyObjectRequest, enabling additional method calls to be chained together. */ public CopyObjectRequest withModifiedSinceConstraint(String modifiedSinceConstraint) { @@ -349,8 +355,9 @@ public CopyObjectRequest withModifiedSinceConstraint(String modifiedSinceConstra } /** - * Gets the optional ETag that, when present, must be not a match for the source object's current + * Gets the optional ETag that, when present, must be not a match for the source object's current * ETag in order for the copy object request to be executed. + * * @return noneMatchETagConstraint */ public String getNoneMatchETagConstraint() { @@ -358,23 +365,66 @@ public String getNoneMatchETagConstraint() { } /** - * Sets the optional ETag that, when present, must be not a match for the source object's current + * Sets the optional ETag that, when present, must be not a match for the source object's current * ETag in order for the copy object request to be executed. - * @param noneMatchETagConstraint + * + * @param noneMatchETagConstraint the constraint value */ public void setNoneMatchETagConstraint(String noneMatchETagConstraint) { this.noneMatchETagConstraint = noneMatchETagConstraint; } /** - * Sets the optional ETag that, when present, must be not a match for the source object's current + * Sets the optional ETag that, when present, must be not a match for the source object's current * ETag in order for the copy object request to be executed. * - * @param noneMatchETagConstraint + * @param noneMatchETagConstraint the constraint value * @return This CopyObjectRequest, enabling additional method calls to be chained together. */ public CopyObjectRequest withNoMatchingETagConstraint(String noneMatchETagConstraint) { this.setNoneMatchETagConstraint(noneMatchETagConstraint); return this; } + + /** + * Gets the limit of put object speed. + * @return the limit of put object speed. unit: bit/s + */ + public long getTrafficLimitBitPS() { + return trafficLimitBitPS; + } + + /** + * Sets Gets the limit of put object speed. range: 819200 bit/s ~ 838860800 bit/s + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s + */ + public void setTrafficLimitBitPS(long trafficLimitBitPS) { + this.trafficLimitBitPS = trafficLimitBitPS; + } + + /** + * + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s, range: 819200 bit/s ~ 838860800 bit/s + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public CopyObjectRequest withTrafficLimitBitPS(long trafficLimitBitPS) { + this.setTrafficLimitBitPS(trafficLimitBitPS); + return this; + } + + /** + * Gets xBceCrc32cFlag of the newly uploaded part. + * @return xBceCrc32cFlag of the newly uploaded part. + */ + public boolean getxBceCrc32cFlag() { + return xBceCrc32cFlag; + } + + /** + * Sets xBceCrc32cFlag of the newly uploaded part. + * @param xBceCrc32cFlag whether to calculate crc32c + */ + public void setxBceCrc32cFlag(boolean xBceCrc32cFlag) { + this.xBceCrc32cFlag = xBceCrc32cFlag; + } } diff --git a/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java b/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java old mode 100644 new mode 100755 index 4f5fbce6..e9360555 --- a/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java +++ b/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java @@ -30,7 +30,8 @@ public class CopyObjectResponseWithExceptionInfo extends CopyObjectResponse { /** * Gets the detail error message. - * + * + * @return the detail error message. */ public String getMessage() { return message; @@ -38,44 +39,44 @@ public String getMessage() { /** * Sets the error message. - * + * * @param message the detail error message. */ public void setMessage(String message) { this.message = message; } - + /** * Returns the error code which represents the error type. - * + * * @return the bos error code which represents the error type. */ public String getCode() { return code; } - + /** * Sets the error code which represents the error type; - * + * * @param code the bos error code which represents the error type. */ public void setCode(String code) { this.code = code; } - + /** * Returns the requestID. - * + * * @return the bos requestID. */ public String getRequestId() { return requestId; } - + /** - * Sets the requestID. - * - * @param requestId + * Sets the request ID. + * + * @param requestId the request ID */ public void setRequestId(String requestId) { this.requestId = requestId; diff --git a/src/main/java/com/baidubce/services/bos/model/CorsConfiguration.java b/src/main/java/com/baidubce/services/bos/model/CorsConfiguration.java new file mode 100644 index 00000000..134efd65 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/CorsConfiguration.java @@ -0,0 +1,218 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * CorsConfiguration for Bucket CORS(Cross-Origin Resource Sharing). + * Bucket's CORS rule container. + * Allow up to 100 rules. + * If there are multiple configurations, the order of execution is from top to bottom. + * Required Parameters: allowedOrigins. + * Required Parameters: allowedMethods. + * Optional Parameters: allowedHeaders. + * Optional Parameters: allowedExposeHeaders. + * Optional Parameters: maxAgeSeconds. + */ +public class CorsConfiguration { + + /** + * the allowedOrigins of Bucket CORS. + */ + private List allowedOrigins; + + /** + * the allowedMethods of Bucket CORS. + */ + private List allowedMethods; + + /** + * the allowedHeaders of Bucket CORS. + */ + private List allowedHeaders; + + /** + * the allowedExposeHeaders of Bucket CORS. + */ + private List allowedExposeHeaders; + + /** + * the maxAgeSeconds of Bucket CORS. + */ + private int maxAgeSeconds; + + /** + * Gets allowedOrigins of Bucket CORS. + * @return allowedOrigins of Bucket CORS. + */ + public List getAllowedOrigins() { + return allowedOrigins; + } + + /** + * Sets allowedOrigins of Bucket CORS. + * @param allowedOrigins The allowedOrigins of Bucket CORS. + */ + public void setAllowedOrigins(List allowedOrigins) { + this.allowedOrigins = allowedOrigins; + } + + /** + * Sets allowedOrigins of Bucket CORS. + * @param allowedOrigins The allowedOrigins of Bucket CORS. + * @return this object. + */ + public CorsConfiguration withAllowedOrigins(List allowedOrigins) { + this.setAllowedOrigins(allowedOrigins); + return this; + } + + /** + * Gets allowedMethods of Bucket CORS. + * @return allowedMethods of Bucket CORS. + */ + public List getAllowedMethods() { + return allowedMethods; + } + + /** + * Sets allowedMethods of Bucket CORS. + * @param allowedMethods The allowedMethods of Bucket CORS. + */ + public void setAllowedMethods(List allowedMethods) { + this.allowedMethods = allowedMethods; + } + + /** + * Sets allowedMethods of Bucket CORS. + * @param allowedMethods The allowedMethods of Bucket CORS. + * @return this object. + */ + public CorsConfiguration withAllowedMethods(List allowedMethods) { + this.setAllowedMethods(allowedMethods); + return this; + } + + /** + * Gets allowedHeaders of Bucket CORS. + * @return allowedHeaders of Bucket CORS. + */ + public List getAllowedHeaders() { + return allowedHeaders; + } + + /** + * Sets allowedHeaders of Bucket CORS. + * @param allowedHeaders The allowedHeaders of Bucket CORS. + */ + public void setAllowedHeaders(List allowedHeaders) { + this.allowedHeaders = allowedHeaders; + } + + /** + * Sets allowedHeaders of Bucket CORS. + * @param allowedHeaders The allowedHeaders of Bucket CORS. + * @return this object. + */ + public CorsConfiguration withAllowedHeaders(List allowedHeaders) { + this.setAllowedHeaders(allowedHeaders); + return this; + } + + /** + * Gets allowedExposeHeaders of Bucket CORS. + * @return allowedExposeHeaders of Bucket CORS. + */ + public List getAllowedExposeHeaders() { + return allowedExposeHeaders; + } + + /** + * Sets allowedExposeHeaders of Bucket CORS. + * @param allowedExposeHeaders The allowedExposeHeaders of Bucket CORS. + */ + public void setAllowedExposeHeaders(List allowedExposeHeaders) { + this.allowedExposeHeaders = allowedExposeHeaders; + } + + /** + * Sets allowedExposeHeaders of Bucket CORS. + * @param allowedExposeHeaders The allowedExposeHeaders of Bucket CORS. + * @return this object. + */ + public CorsConfiguration withAllowedExposeHeaders(List allowedExposeHeaders) { + this.setAllowedExposeHeaders(allowedExposeHeaders); + return this; + } + + /** + * Gets maxAgeSeconds of Bucket CORS. + * @return maxAgeSeconds of Bucket CORS. + */ + public int getMaxAgeSeconds() { + return maxAgeSeconds; + } + + /** + * Sets maxAgeSeconds of Bucket CORS. + * @param maxAgeSeconds The maxAgeSeconds of Bucket CORS. + */ + public void setMaxAgeSeconds(int maxAgeSeconds) { + this.maxAgeSeconds = maxAgeSeconds; + } + + /** + * Sets maxAgeSeconds of Bucket CORS. + * @param maxAgeSeconds The maxAgeSeconds of Bucket CORS. + * @return this object. + */ + public CorsConfiguration withMaxAgeSeconds(int maxAgeSeconds) { + this.setMaxAgeSeconds(maxAgeSeconds); + return this; + } + + /** + * The void Constructor of Bucket CORS. + */ + public CorsConfiguration() { + } + + /** + * The Constructor of Bucket CORS. + * @param allowedOrigins The allowedOrigins of Bucket CROS. + * @param allowedMethods The allowedMethods of Bucket CROS. + * @param allowedHeaders The allowedHeaders of Bucket CROS. + * @param allowedExposeHeaders The allowedExposeHeaders of Bucket CROS. + * @param maxAgeSeconds The maxAgeSeconds of Bucket CROS. + */ + public CorsConfiguration(List allowedOrigins, List allowedMethods, + List allowedHeaders, List allowedExposeHeaders, int maxAgeSeconds) { + this.allowedOrigins = allowedOrigins; + this.allowedMethods = allowedMethods; + this.allowedHeaders = allowedHeaders; + this.allowedExposeHeaders = allowedExposeHeaders; + this.maxAgeSeconds = maxAgeSeconds; + } + + @Override + public String toString() { + return "CorsConfiguration{" + + "allowedOrigins=" + allowedOrigins + + ", allowedMethods=" + allowedMethods + + ", allowedHeaders=" + allowedHeaders + + ", allowedExposeHeaders=" + allowedExposeHeaders + + ", maxAgeSeconds=" + maxAgeSeconds + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/CreateBucketRequest.java b/src/main/java/com/baidubce/services/bos/model/CreateBucketRequest.java index a7e2acae..e5ef461b 100644 --- a/src/main/java/com/baidubce/services/bos/model/CreateBucketRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/CreateBucketRequest.java @@ -19,6 +19,8 @@ */ public class CreateBucketRequest extends GenericBucketRequest { + private String bucketTags = null; + /** * Constructs a new {@link CreateBucketRequest},ready to be executed to create the specified bucket. * @@ -37,4 +39,17 @@ public CreateBucketRequest withBucketName(String bucketName) { this.setBucketName(bucketName); return this; } + + public String getBucketTags() { + return bucketTags; + } + + public void setBucketTags(String bucketTags) { + this.bucketTags = bucketTags; + } + + public CreateBucketRequest withBucketTags(String bucketTags) { + this.setBucketTags(bucketTags); + return this; + } } diff --git a/src/main/java/com/baidubce/services/bos/model/CustomHeader.java b/src/main/java/com/baidubce/services/bos/model/CustomHeader.java new file mode 100644 index 00000000..e381fe82 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/CustomHeader.java @@ -0,0 +1,18 @@ +package com.baidubce.services.bos.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Specifies a CustomHeader, consisting of one headerName and one headerValue. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CustomHeader { + private String headerName; + private String headerValue; +} diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketCopyrightProtectionRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketCopyrightProtectionRequest.java new file mode 100644 index 00000000..49b02d45 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketCopyrightProtectionRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for deleting a Bucket CopyrightProtection + */ +public class DeleteBucketCopyrightProtectionRequest extends GenericBucketRequest { + /** + * Constructs a void constructor for DeleteBucketCopyrightProtectionRequest. + */ + public DeleteBucketCopyrightProtectionRequest() { + + } + + /** + * Constructs a DeleteBucketCopyrightProtectionRequest, ready to be executed to delete the specified Bucket + * CopyrightProtection. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket CopyrightProtection. + */ + public DeleteBucketCopyrightProtectionRequest(String bucketName) { + super(bucketName); + } + + /** + * Sets the name of the Baidu Bos bucket to delete Bucket CopyrightProtection. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket CopyrightProtection. + */ + @Override + public DeleteBucketCopyrightProtectionRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public DeleteBucketCopyrightProtectionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketCorsRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketCorsRequest.java new file mode 100644 index 00000000..1c007f66 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketCorsRequest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for deleting a Bucket CORS(Cross-Origin Resource Sharing). + */ +public class DeleteBucketCorsRequest extends GenericBucketRequest { + + /** + * Constructs a void Constructor for DeleteBucketCorsRequest. + */ + public DeleteBucketCorsRequest() { + } + + /** + * Constructs a new DeleteBucketCorsRequest, ready to be executed to delete the specified Bucket CORS. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket CORS. + */ + public DeleteBucketCorsRequest(String bucketName) { + super(bucketName); + } + + public DeleteBucketCorsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Sets the name of the Baidu Bos bucket to delete Bucket CORS. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket CORS. + */ + public DeleteBucketCorsRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketEncryptionRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketEncryptionRequest.java new file mode 100644 index 00000000..af9871e5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketEncryptionRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for deleting a Bucket Encryption. + */ +public class DeleteBucketEncryptionRequest extends GenericBucketRequest { + + /** + * Constructs a void constructor for DeleteBucketEncryptionRequest. + */ + public DeleteBucketEncryptionRequest() { + + } + + /** + * Constructs a new DeleteBucketEncryptionRequest, ready to be executed to delete the specified Bucket Encryption. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Lifecycle. + */ + public DeleteBucketEncryptionRequest(String bucketName) { + super(bucketName); + } + + /** + * Sets the name of the Baidu Bos bucket to delete Bucket Encryption. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Lifecycle. + */ + @Override + public DeleteBucketEncryptionRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public DeleteBucketEncryptionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketLifecycleRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketLifecycleRequest.java new file mode 100644 index 00000000..09db3066 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketLifecycleRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for deleting a Bucket Lifecycle. + */ +public class DeleteBucketLifecycleRequest extends GenericBucketRequest { + + /** + * Constructs a void constructor for DeleteBucketLifecycleRequest. + */ + public DeleteBucketLifecycleRequest() { + + } + + /** + * Constructs a new DeleteBucketLifecycleRequest, ready to be executed to delete the specified Bucket Lifecycle. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Lifecycle. + */ + public DeleteBucketLifecycleRequest(String bucketName) { + super(bucketName); + } + + public DeleteBucketLifecycleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Sets the name of the Baidu Bos bucket to delete Bucket Lifecycle. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Lifecycle. + */ + public DeleteBucketLifecycleRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketLoggingRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketLoggingRequest.java new file mode 100644 index 00000000..8e62415e --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketLoggingRequest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for deleting a Bucket Logging. + */ +public class DeleteBucketLoggingRequest extends GenericBucketRequest { + + /** + * Constructs a void Constructor for DeleteBucketLoggingRequest. + */ + public DeleteBucketLoggingRequest() { + } + + /** + * Constructs a new DeleteBucketLoggingRequest, ready to be executed to delete the specified Bucket Logging. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Logging. + */ + public DeleteBucketLoggingRequest(String bucketName) { + super(bucketName); + } + + public DeleteBucketLoggingRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Sets the name of the Baidu Bos bucket to delete Bucket Logging. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Logging. + */ + public DeleteBucketLoggingRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketMirroringRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketMirroringRequest.java new file mode 100644 index 00000000..a4c5bf19 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketMirroringRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * DeleteBucketMirroringRequest class + */ +public class DeleteBucketMirroringRequest extends GenericBucketRequest { + + /** + * Constructs a void Constructor for DeleteBucketMirroringRequest + */ + public DeleteBucketMirroringRequest(String bucketName) { + super(bucketName); + } + + + @Override + public DeleteBucketMirroringRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public DeleteBucketMirroringRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketReplicationRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketReplicationRequest.java new file mode 100644 index 00000000..8af339ee --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketReplicationRequest.java @@ -0,0 +1,84 @@ +/* + * Copyright 2014-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Delete Bucket Replication Request + */ +public class DeleteBucketReplicationRequest extends GenericBucketRequest { + + /** + * The replication rule name + */ + private String id; + + + /** + * Constructs a void Constructor for DeleteBucketReplicationRequest. + */ + public DeleteBucketReplicationRequest() { + } + + /** + * Constructs a new DeleteBucketReplicationRequest, ready to be executed to delete the specified Bucket Replication. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Replication. + */ + public DeleteBucketReplicationRequest(String bucketName) { + super(bucketName); + } + + /** + * Constructs a new DeleteBucketReplicationRequest, ready to be executed to delete the specified Bucket Replication. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Replication. + * @param id replication rule name + */ + public DeleteBucketReplicationRequest(String bucketName, String id) { + super(bucketName); + this.setId(id); + } + + /** + * Sets the name of the Baidu Bos bucket to delete Bucket Replication. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Replication. + */ + @Override + public DeleteBucketReplicationRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public DeleteBucketReplicationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Gets the replication rule name + * @return + */ + public String getId() { + return id; + } + + /** + * Sets the replication rule name + * @param id + */ + public void setId(String id) { + this.id = id; + } + +} diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketStaticWebsiteRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketStaticWebsiteRequest.java new file mode 100644 index 00000000..9e3bc6aa --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketStaticWebsiteRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for deleting a Bucket staticwebsite. + */ +public class DeleteBucketStaticWebsiteRequest extends GenericBucketRequest { + + /** + * Sets the name of the Baidu Bos bucket to delete Bucket StaticWebsite. + * @param bucketName The name of the Baidu Bos bucket to delete Bucket StaticWebsite. + */ + @Override + public DeleteBucketStaticWebsiteRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public DeleteBucketStaticWebsiteRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public DeleteBucketStaticWebsiteRequest() { + + } + + /** + * Constructs DeleteBucketStaticWebsiteRequest, ready to be executed to delete the specified Bucket StaticWebsite + * @param bucketName The name of the Baidu Bos bucket to delete Bucket Lifecycle. + */ + public DeleteBucketStaticWebsiteRequest(String bucketName) { + super(bucketName); + } + + +} diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketTaggingRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketTaggingRequest.java new file mode 100644 index 00000000..a56c7d84 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketTaggingRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * DeleteBucketTaggingRequest class + */ +public class DeleteBucketTaggingRequest extends GenericBucketRequest { + + + public DeleteBucketTaggingRequest(String bucketName) { + super(bucketName); + } + + @Override + public GenericBucketRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketTrashRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketTrashRequest.java new file mode 100644 index 00000000..c740e5a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketTrashRequest.java @@ -0,0 +1,22 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +public class DeleteBucketTrashRequest extends GenericBucketRequest { + + public DeleteBucketTrashRequest(String bucketName){ + super(bucketName); + } + + @Override + public DeleteBucketTrashRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public DeleteBucketTrashRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteDirectoryRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteDirectoryRequest.java new file mode 100644 index 00000000..e6b33ddc --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteDirectoryRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Used in BOS Namespace + */ +public class DeleteDirectoryRequest extends GenericObjectRequest { + + boolean isDeleteRecursive = false; + String deleteMarker; + + public DeleteDirectoryRequest(String bucketName, String key) { + super(bucketName, key); + } + + public DeleteDirectoryRequest(String bucketName, String key, boolean deleteRecursive) { + super(bucketName, key); + this.isDeleteRecursive = deleteRecursive; + } + + public DeleteDirectoryRequest(String bucketName, String key, boolean deleteRecursive, String deleteMarker) { + super(bucketName, key); + this.deleteMarker = deleteMarker; + this.isDeleteRecursive = deleteRecursive; + } + + @Override + public DeleteDirectoryRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public DeleteDirectoryRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public DeleteDirectoryRequest withKey(String key) { + this.setKey(key); + return this; + } + + public boolean isDeleteRecursive() { + return isDeleteRecursive; + } + + public void setDeleteRecursive(boolean deleteRecursive) { + isDeleteRecursive = deleteRecursive; + } + + public DeleteDirectoryRequest withDeleteRecursive(boolean deleteRecursive) { + this.setDeleteRecursive(deleteRecursive); + return this; + } + + public String getDeleteMarker() { + return deleteMarker; + } + + public void setDeleteMarker(String deleteMarker) { + this.deleteMarker = deleteMarker; + } + + public DeleteDirectoryRequest withDeleteToken(String deleteMarker) { + this.setDeleteMarker(deleteMarker); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteDirectoryResponse.java b/src/main/java/com/baidubce/services/bos/model/DeleteDirectoryResponse.java new file mode 100644 index 00000000..ca11b7a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteDirectoryResponse.java @@ -0,0 +1,133 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bos.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +public class DeleteDirectoryResponse extends BosResponse { + + /** + * The name of the Baidu Bos bucket containing the listed objects + */ + private String bucketName; + + /** + * The marker to use in order to request the next page of results - only + * populated if the isTruncated member indicates that this object listing is truncated + */ + private String nextDeleteMarker; + + /** + * Indicates if this is a complete listing, or if the caller needs to make + * additional requests to Baidu Bos to see the full object listing for an Bos bucket + */ + private boolean isTruncated; + + /** + * The number of this delete objects request have deleted. + */ + private int deleteNumber; + + + /** + * Gets the marker to use in the next DeleteObject request in order to delete + * the next objects of namespace directory. + *

+ * + * @return The marker to use in the next DeleteObject request in order to see + * the next objects of namespace directory if this directory deleting is truncated. + * Returns null if this object listing isn't truncated. + */ + public String getNextDeleteMarker() { + return this.nextDeleteMarker; + } + + /** + * For internal use only. Sets the marker to use in the next delete objects request + * in order to see the next objects of namespace directory for a truncated object deleting. + * + * @param nextDeleteMarker The marker to use in the next listObjects request in order to + * see the next objects of namespace directory for a truncated object deleting. + */ + @JsonProperty("nextDeleteToken") + public void setNextDeleteMarker(String nextDeleteMarker) { + this.nextDeleteMarker = nextDeleteMarker; + } + + /** + * Gets the name of the Baidu Bos bucket containing the objects. + * + * @return The name of the Baidu Bos bucket containing the objects. + */ + public String getBucketName() { + return this.bucketName; + } + + /** + * For internal use only. Sets the name of the Baidu Bos + * bucket containing the objects listed in this BosObjectListing. + * + * @param bucketName The name of the Baidu Bos bucket containing the objects deleted in this BosObjectDeleting. + */ + @JsonProperty("name") + public void setBucketName(String bucketName) { + this.bucketName = bucketName; + } + + /** + * Gets whether or not this objects deleting is complete. + * + * @return The value true if the object deleting is not complete. + * Returns the value false if otherwise. + * When returning true, additional calls to Baidu Bos may be needed in order to + * obtain more results. + */ + public boolean isTruncated() { + return this.isTruncated; + } + + /** + * For internal use only. Sets the truncated property for + * this object listing, indicating if this is a complete listing or not and + * whether the caller needs to make additional calls to Bos to get more + * object summaries. + * + * @param isTruncated The value true if the object listing is not complete. + * The value false if otherwise. + */ + @JsonProperty("isTruncated") + public void setTruncated(boolean isTruncated) { + this.isTruncated = isTruncated; + } + + /** + * Gets the number of this delete objects request have deleted. + * + * @return The number of this delete objects request have deleted. + */ + public int getDeleteNumber() { + return deleteNumber; + } + + /** + * For internal use only. Sets the number of this delete objects request have deleted. + * + * @param deleteNumber the number of this delete objects request have deleted. + */ + @JsonProperty("deleteNumber") + public void setDeleteNumber(int deleteNumber) { + this.deleteNumber = deleteNumber; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteMultipleObjectsRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteMultipleObjectsRequest.java new file mode 100644 index 00000000..9d9e2aec --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteMultipleObjectsRequest.java @@ -0,0 +1,85 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +import java.util.List; + +/** + * Provides options for deleting a multiple objects. + */ +public class DeleteMultipleObjectsRequest extends GenericObjectRequest { + + /** + * the object key list excepted to be deleted. + */ + private List objectKeys; + + /** + * the jsonDeleteObjects excepted to be deleted. + */ + private String jsonDeleteObjects; + + /** + * Gets the jsonDeleteObjects expected to be deleted. + * @return json format for delete multiple objects. + */ + public String getJsonDeleteObjects() { + return jsonDeleteObjects; + } + + /** + * Sets the jsonDeleteObjects expected to be deleted. + * @param jsonDeleteObjects The json format for delete multiple objects. + */ + public void setJsonDeleteObjects(String jsonDeleteObjects) { + this.jsonDeleteObjects = jsonDeleteObjects; + } + + /** + * Gets the object key list expected to be deleted. + * @return the object key list expected to be deleted. + */ + public List getObjectKeys() { + return objectKeys; + } + + /** + * Sets the object key list expected to be deleted. + * @param objectKeys The object key list expected to be deleted. + */ + public void setObjectKeys(List objectKeys) { + this.objectKeys = objectKeys; + } + + + @Override + public DeleteMultipleObjectsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public DeleteMultipleObjectsRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public DeleteMultipleObjectsRequest withKey(String key) { + this.setKey(key); + return this; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteMultipleObjectsResponse.java b/src/main/java/com/baidubce/services/bos/model/DeleteMultipleObjectsResponse.java new file mode 100644 index 00000000..a1ac3986 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteMultipleObjectsResponse.java @@ -0,0 +1,51 @@ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * Delete Multiple Objects Response + */ +public class DeleteMultipleObjectsResponse extends BosResponse { + + /** + * the errors message during DeleteMultipleObjects. + */ + private List errors; + + /** + * Gets the errors message during DeleteMultipleObjects. + * @return the errors message for delete multiple objects. + */ + public List getErrors() { + return errors; + } + + /** + * Sets the errors message during DeleteMultipleObjects. + * @param the errors for delete multiple objects. + */ + public void setErrors(List errors) { + this.errors = errors; + } + + /** + * Constructs a void constructor for delete multiple objects. + */ + public DeleteMultipleObjectsResponse() { + } + + /** + * Constructs a new DeleteMultipleObjectsResponse object for delete multiple objects. + * @param errors + */ + public DeleteMultipleObjectsResponse(List errors) { + this.errors = errors; + } + + @Override + public String toString() { + return "DeleteMultipleObjectsResponse{" + + "errors=" + errors + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteObjectAclRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteObjectAclRequest.java new file mode 100644 index 00000000..4ebb0656 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/DeleteObjectAclRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for deleting a object acl. + */ +public class DeleteObjectAclRequest extends GenericObjectRequest { + + /** + * Constructs a void Constructor for DeleteObjectAclRequest. + */ + public DeleteObjectAclRequest() { + } + + /** + * Constructs a new DeleteObjectAclRequest, ready to be executed to delete the specified object acl. + * @param bucketName The name of the Baidu Bos bucket to delete object acl. + */ + public DeleteObjectAclRequest(String bucketName, String key) { + super(bucketName, key); + } + + @Override + public DeleteObjectAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public DeleteObjectAclRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public DeleteObjectAclRequest withKey(String key) { + this.setKey(key); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bos/model/Destination.java b/src/main/java/com/baidubce/services/bos/model/Destination.java new file mode 100644 index 00000000..a2f1e61e --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/Destination.java @@ -0,0 +1,62 @@ +/* + * Copyright 2014-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * The config of dest replication for bucket replication + */ +public class Destination { + + /** + * The dest replication bucket name + */ + private String bucket; + + /** + * The dest bucket's object storageclass + */ + private String storageClass; + + /** + * Gets the dest replication bucket name + * @return + */ + public String getBucket() { + return bucket; + } + + /** + * Sets the dest replication bucket name + * @param bucket + */ + public void setBucket(String bucket) { + this.bucket = bucket; + } + + /** + * Gets the dest bucket's object storageclass + * @return + */ + public String getStorageClass() { + return storageClass; + } + + /** + * Sets the dest bucket's object storageclass + * @param storageClass + */ + public void setStorageClass(String storageClass) { + this.storageClass = storageClass; + } + +} diff --git a/src/main/java/com/baidubce/services/bos/model/Errors.java b/src/main/java/com/baidubce/services/bos/model/Errors.java new file mode 100644 index 00000000..3797e862 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/Errors.java @@ -0,0 +1,93 @@ +package com.baidubce.services.bos.model; + +/** + * The Errors class for just resolve Delete Multiple Objects response Json + */ +public class Errors { + + /** + * Object name for Delete Object wrong + */ + private String key; + + /** + * error code for Delete Object wrong + */ + private String code; + + /** + * error code for Delete Object wrong + */ + private String message; + + /** + * Gets key of Delete Multiple Objects response. + * @return key of Delete Multiple Objects response. + */ + public String getKey() { + return key; + } + + /** + * Sets key of Delete Multiple Objects response. + * @param key The key of Delete Multiple Objects response. + */ + public void setKey(String key) { + this.key = key; + } + + /** + * Gets code of Delete Multiple Objects response. + * @return code of Delete Multiple Objects response. + */ + public String getCode() { + return code; + } + + /** + * Sets code of Delete Multiple Objects response. + * @param code The code of Delete Multiple Objects response. + */ + public void setCode(String code) { + this.code = code; + } + + /** + * Gets message of Delete Multiple Objects response. + * @return message of Delete Multiple Objects response. + */ + public String getMessage() { + return message; + } + + /** + * Sets message of Delete Multiple Objects response. + * @param message The message of Delete Multiple Objects response. + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Constructs a void constructor Errors for delete multiple objects errors. + */ + public Errors() { + } + + /** + * Constructs a new Errors object for delete multiple objects errors. + * @param key + * @param code + * @param message + */ + public Errors(String key, String code, String message) { + this.key = key; + this.code = code; + this.message = message; + } + + @Override + public String toString() { + return "Errors{" + "key='" + key + '\'' + ", code='" + code + '\'' + ", message='" + message + '\'' + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/FetchObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/FetchObjectRequest.java new file mode 100644 index 00000000..477f44b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/FetchObjectRequest.java @@ -0,0 +1,219 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides options for fetching an Baidu Bos object from url. + *

+ * All FetchObjectRequest must specify a sourceUrl and mode, along with a destination bucket and key. + */ +public class FetchObjectRequest extends GenericObjectRequest { + public static final String MODE_SYNC = "sync"; + public static final String MODE_ASYNC = "async"; + + /** + * The url string of the sourceUrl to be fetched + */ + private String sourceUrl; + + /** + * The mode of this fetch job, should be sync or async. + */ + private String mode; + + /** + * The storage class is an identification that distinguish between infrequent access bos + * and standard bos. + */ + private String storageClass; + + private String callbackAddress; + + private String referer; + + private String userAgent; + + /** + * Constructs a new FetchObjectRequest with only basic options. + * + * @param bucketName The name of the Bos bucket to which the new object will be fetched. + * @param key The destination bucket key under which the new object will be fetched. + * @param sourceUrl The name of the Bos bucket containing the object to fetch. + */ + public FetchObjectRequest(String bucketName, String key, String sourceUrl) { + super(bucketName, key); + this.setSourceUrl(sourceUrl); + this.setMode(MODE_SYNC); + } + + /** + * Gets the url string of the sourceUrl to be fetched. + * + * @return The url string of the sourceUrl to be fetched. + */ + public String getSourceUrl() { + return this.sourceUrl; + } + + /** + * Sets the url string of the sourceUrl to be fetched. + * + * @param sourceUrl The url string of the sourceUrl to be fetched. + */ + public void setSourceUrl(String sourceUrl) { + checkNotNull(sourceUrl, "sourceUrl should not be null"); + this.sourceUrl = sourceUrl; + } + + /** + * Sets the url string of the sourceUrl to be fetched, + * and returns this object, enabling additional method calls to be chained together. + * + * @param sourceUrl The url string of the sourceUrl to be fetched. + * @return This FetchObjectRequest instance, + * enabling additional method calls to be chained together. + */ + public FetchObjectRequest withSourceUrl(String sourceUrl) { + this.setSourceUrl(sourceUrl); + return this; + } + + /** + * Gets the mode of this fetching job. + * + * @return The mode of this fetching job. + */ + public String getMode() { + return this.mode; + } + + /** + * Sets the mode of this fetching job. + * + * @param mode The mode of this fetching job. + */ + public void setMode(String mode) { + checkNotNull(mode, "mode should not be null"); + if (MODE_ASYNC.equals(mode) || MODE_SYNC.equals(mode)) { + this.mode = mode; + } else { + throw new IllegalArgumentException("illegal mode: " + mode); + } + } + + /** + * Sets the mode of this fetching job, enabling additional method calls to be chained together. + * + * @param mode The mode of this fetching job. + * @return This FetchObjectRequest instance, enabling additional method calls to be chained together. + */ + public FetchObjectRequest withMode(String mode) { + this.setMode(mode); + return this; + } + + @Override + public FetchObjectRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Sets the name of the destination bucket which will contain the new, + * fetched object and returns this object, enabling additional method calls + * to be chained together. + * + * @param bucketName The name of the destination bucket which will contain the new object of fetching job. + * @return This FetchObjectRequest, enabling additional method calls to be chained together. + */ + @Override + public FetchObjectRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + /** + * Sets the destination bucket key under which the new, fetched object + * will be stored and returns this object, enabling additional method calls + * can be chained together. + * + * @param key The destination bucket key under which the new, fetched object will be stored. + * @return This FetchObjectRequest, enabling additional method calls to be chained together. + */ + @Override + public FetchObjectRequest withKey(String key) { + this.setKey(key); + return this; + } + + + /** + * Gets the storageClass of the input file which is to be fetched to Baidu Bos. + * + * @return storageClass The storageClass is an identification that distinguish between infrequent access bos + * and standard bos. + */ + public String getStorageClass() { + return storageClass; + } + + /** + * Sets the storageClass of the input file which is to be fetched to Baidu Bos. + * + * @param storageClass The storageClass is an identification that distinguish between infrequent access bos + * and standard bos. + */ + public void setStorageClass(String storageClass) { + this.storageClass = storageClass; + } + + /** + * Sets the storageClass of the input file which is to be fetched to Baidu Bos. + * + * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos + * and standard bos. + * @return This FetchObjectRequest, so that additional method calls can be chained together. + */ + public FetchObjectRequest withStorageClass(String storageClass) { + this.setStorageClass(storageClass); + return this; + } + + public String getCallbackAddress() { + return callbackAddress; + } + + public void setCallbackAddress(String callbackAddress) { + this.callbackAddress = callbackAddress; + } + + public String getReferer() { + return referer; + } + + public void setReferer(String referer) { + this.referer = referer; + } + + public String getUserAgent() { + return userAgent; + } + + public void setUserAgent(String userAgent) { + this.userAgent = userAgent; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/FetchObjectResponse.java b/src/main/java/com/baidubce/services/bos/model/FetchObjectResponse.java new file mode 100644 index 00000000..4e6d268d --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/FetchObjectResponse.java @@ -0,0 +1,114 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * Contains the data returned by Baidu Bos from the + * {@link com.baidubce.services.bos.BosClient#fetchObject(FetchObjectRequest fetchObjectRequest)} call. + * This result may be ignored if not needed; otherwise, use this result + * to access information about the new object created from the fetchObject call. + */ +public class FetchObjectResponse extends BosResponse { + + /** + * The code of this fetching that was created in the associated FetchObjectRequest. + */ + private String code; + + /** + * The message of this fetching that was created in the associated FetchObjectRequest. + */ + private String message; + + /** + * The requestId of this fetching that was created in the associated FetchObjectRequest. + */ + private String requestId; + + /** + * The jobId of this fetching that was created in the associated FetchObjectRequest. + */ + private String jobId; + + /** + * Gets the code of this fetching that was created in the associated FetchObjectRequest. + * + * @return The code of the fetch object response. + */ + public String getCode() { + return code; + } + + /** + * Sets the code of this fetching that was created in the associated FetchObjectRequest. + * + * @param code The code of this fetching that was created in the associated FetchObjectRequest. + */ + public void setCode(String code) { + this.code = code; + } + + /** + * Gets the message of this fetching that was created in the associated FetchObjectRequest. + * + * @return The message of the fetch object response. + */ + public String getMessage() { + return message; + } + + /** + * Sets the message of this fetching that was created in the associated FetchObjectRequest. + * + * @param message The message of this fetching that was created in the associated FetchObjectRequest. + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Gets the requestId of this fetching that was created in the associated FetchObjectRequest. + * + * @return The requestId of the fetch object response. + */ + public String getRequestId() { + return requestId; + } + + /** + * Sets the requestId of this fetching that was created in the associated FetchObjectRequest. + * + * @param requestId The requestId of this fetching that was created in the associated FetchObjectRequest. + */ + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + /** + * Gets the jobId of this fetching that was created in the associated FetchObjectRequest. + * + * @return The jobId of the fetch object response. + */ + public String getJobId() { + return jobId; + } + + /** + * Sets the jobId of this fetching that was created in the associated FetchObjectRequest. + * + * @param jobId The jobId of this fetching that was created in the associated FetchObjectRequest. + */ + public void setJobId(String jobId) { + this.jobId = jobId; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GeneratePresignedUrlRequest.java b/src/main/java/com/baidubce/services/bos/model/GeneratePresignedUrlRequest.java index 242bc256..334e04e2 100644 --- a/src/main/java/com/baidubce/services/bos/model/GeneratePresignedUrlRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GeneratePresignedUrlRequest.java @@ -62,7 +62,7 @@ public class GeneratePresignedUrlRequest extends AbstractBceRequest { * will no longer be accepted by BOS. If not specified, a default * value will be supplied. */ - private int expirationInSeconds = -1; + private int expirationInSeconds = 1800; /** * An optional map of additional parameters to include in the pre-signed diff --git a/src/main/java/com/baidubce/services/bos/model/GenericBucketRequest.java b/src/main/java/com/baidubce/services/bos/model/GenericBucketRequest.java index abad02f5..1710af17 100644 --- a/src/main/java/com/baidubce/services/bos/model/GenericBucketRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GenericBucketRequest.java @@ -35,7 +35,10 @@ public String getBucketName() { } public void setBucketName(String bucketName) { - checkNotNull(bucketName, "bucketName should not be null."); + if (bucketName == null) { + this.bucketName = bucketName; + return; + } bucketName = bucketName.trim(); if (bucketName.length() < MIN_BUCKET_NAME_LENGTH) { throw new IllegalArgumentException("Invalid bucketName:" + bucketName + ". " + diff --git a/src/main/java/com/baidubce/services/bos/model/GenericObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/GenericObjectRequest.java index d0240bea..41ce0e8d 100644 --- a/src/main/java/com/baidubce/services/bos/model/GenericObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GenericObjectRequest.java @@ -15,11 +15,17 @@ import static com.google.common.base.Preconditions.checkNotNull; public abstract class GenericObjectRequest extends GenericBucketRequest { - private static final int MIN_OBJECT_KEY_LENGTH = 0; + private static final int MIN_OBJECT_KEY_LENGTH = 1; private static final int MAX_OBJECT_KEY_LENGTH = 1024; private String key; + /** + * The limit of put object speed. unit: bit/s + * range: 819200 bit/s ~ 838860800 bit/s + */ + protected long trafficLimitBitPS = -1; + public GenericObjectRequest() { super(); } @@ -43,6 +49,22 @@ public void setKey(String key) { throw new IllegalArgumentException("Invalid objectKey:" + key + ". " + "objectKey should not be greater than " + MAX_OBJECT_KEY_LENGTH + "."); } + + // key should not be "/////" + if (key.startsWith("/")) { + boolean isDelimiters = true; + for (int i = 1; i < key.length(); i++) { + if (key.charAt(i) != '/') { + isDelimiters = false; + break; + } + } + if (isDelimiters) { + throw new IllegalArgumentException("Invalid objectKey:" + key + ". " + + "objectKey should not be delimiter."); + } + } + this.key = key; } diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketAclResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketAclResponse.java old mode 100644 new mode 100755 index f10ba262..8ba0658b --- a/src/main/java/com/baidubce/services/bos/model/GetBucketAclResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketAclResponse.java @@ -33,6 +33,8 @@ public class GetBucketAclResponse extends BosResponse { /** * Gets the acl version. + * + * @return the acl version. */ public int getVersion() { return version; @@ -40,6 +42,8 @@ public int getVersion() { /** * Sets the acl version. + * + * @param version the acl version */ public void setVersion(int version) { this.version = version; @@ -81,4 +85,12 @@ public void setAccessControlList(List accessControlList) { this.accessControlList = accessControlList; } + @Override + public String toString() { + return "GetBucketAclResponse{" + + "version=" + version + + ", owner=" + owner + + ", accessControlList=" + accessControlList + + '}'; + } } diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketCopyrightProtectionRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketCopyrightProtectionRequest.java new file mode 100644 index 00000000..de27abea --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketCopyrightProtectionRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Request for get Bucket CopyrightProtection. + */ +public class GetBucketCopyrightProtectionRequest extends GenericBucketRequest { + + /** + * Constructs a void Constructor for GetBucketCopyrightProtectionRequest. + */ + public GetBucketCopyrightProtectionRequest() { + } + + /** + * Constructs a new GetBucketCorsRequest to get a specified Bucket CORS. + * @param bucketName + */ + public GetBucketCopyrightProtectionRequest(String bucketName) { + super(bucketName); + } + + @Override + public GetBucketCopyrightProtectionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public GetBucketCopyrightProtectionRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketCopyrightProtectionResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketCopyrightProtectionResponse.java new file mode 100644 index 00000000..4556aeaf --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketCopyrightProtectionResponse.java @@ -0,0 +1,67 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Get Bucket CopyrightProtection Response + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetBucketCopyrightProtectionResponse extends BosResponse { + + /** + * corsConfiguration of GetBucketCorsResponse. + */ + private List resource; + + /** + * Constructs a void constructor for GetBucketCopyrightProtectionResponse. + */ + public GetBucketCopyrightProtectionResponse() { + } + + /** + * Constructs a new GetBucketCopyrightProtectionResponse object . + * @param resource + */ + public GetBucketCopyrightProtectionResponse(List resource) { + this.resource = resource; + + } + + /** + * Gets CopyrightProtection of GetBucketCopyrightProtectionResponse(. + * @return CopyrightProtection of GetBucketCopyrightProtectionResponse(. + */ + public List getResource() { + return resource; + } + + /** + * Sets resource of GetBucketCorsResponse. + * @param resource . + */ + public void setResource(List resource) { + this.resource = resource; + } + + @Override + public String toString() { + return "GetBucketCopyrightProtectionResponse{" + + "resource=" + resource + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketCorsRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketCorsRequest.java new file mode 100644 index 00000000..e657a8d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketCorsRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Request for get Bucket CORS(Cross-Origin Resource Sharing). + */ +public class GetBucketCorsRequest extends GenericBucketRequest { + + /** + * Constructs a void Constructor for GetBucketCorsRequest. + */ + public GetBucketCorsRequest() { + } + + /** + * Constructs a new GetBucketCorsRequest to get a specified Bucket CORS. + * @param bucketName + */ + public GetBucketCorsRequest(String bucketName) { + super(bucketName); + } + + @Override + public GetBucketCorsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public GetBucketCorsRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketCorsResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketCorsResponse.java new file mode 100644 index 00000000..c2c56246 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketCorsResponse.java @@ -0,0 +1,51 @@ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * Get Bucket Cors Response + */ +public class GetBucketCorsResponse extends BosResponse { + + /** + * corsConfiguration of GetBucketCorsResponse. + */ + private List corsConfiguration; + + /** + * Gets corsConfiguration of GetBucketCorsResponse. + * @return corsConfiguration of GetBucketCorsResponse. + */ + public List getCorsConfiguration() { + return corsConfiguration; + } + + /** + * Sets corsConfiguration of GetBucketCorsResponse. + * @param corsConfiguration The corsConfiguration of GetBucketCorsResponse. + */ + public void setCorsConfiguration(List corsConfiguration) { + this.corsConfiguration = corsConfiguration; + } + + /** + * Constructs a void constructor for GetBucketCorsResponse. + */ + public GetBucketCorsResponse() { + } + + /** + * Constructs a new GetBucketCorsResponse object for GetBucketCorsResponse. + * @param corsConfiguration + */ + public GetBucketCorsResponse(List corsConfiguration) { + this.corsConfiguration = corsConfiguration; + } + + @Override + public String toString() { + return "GetBucketCorsResponse{" + + "corsConfiguration=" + corsConfiguration + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketEncryptionRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketEncryptionRequest.java new file mode 100644 index 00000000..4282f599 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketEncryptionRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Request for get Bucket Encryption. + */ +public class GetBucketEncryptionRequest extends GenericBucketRequest { + + /** + * Constructs a void Constructor for GetBucketEncryptionRequest. + */ + public GetBucketEncryptionRequest() { + + } + + /** + * Constructs a new GetBucketEncryptionRequest to get a specified Bucket Logging. + * @param bucketName + */ + public GetBucketEncryptionRequest(String bucketName) { + super(bucketName); + } + + @Override + public GetBucketEncryptionRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public GetBucketEncryptionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketEncryptionResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketEncryptionResponse.java new file mode 100644 index 00000000..9c5ef8fd --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketEncryptionResponse.java @@ -0,0 +1,65 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Get BucketEncryption Response + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetBucketEncryptionResponse extends BosResponse { + + /** + * The Bucket Encryption + */ + private String encryptionAlgorithm; + private String kmsMasterKeyId; + + + /** + * Constructs a void constructor for GetBucketEncryptionResponse. + */ + public GetBucketEncryptionResponse() { + + } + + public GetBucketEncryptionResponse(String encryptionAlgorithm, String kmsMasterKeyId) { + this.encryptionAlgorithm = encryptionAlgorithm; + this.kmsMasterKeyId = kmsMasterKeyId; + } + + public String getEncryptionAlgorithm() { + return encryptionAlgorithm; + } + + public void setEncryptionAlgorithm(String encryptionAlgorithm) { + this.encryptionAlgorithm = encryptionAlgorithm; + } + + public String getKmsMasterKeyId() { + return kmsMasterKeyId; + } + + public void setKmsMasterKeyId(String kmsMasterKeyId) { + this.kmsMasterKeyId = kmsMasterKeyId; + } + + @Override + public String toString() { + return "GetBucketEncryptionResponse{" + + "encryptionAlgorithm='" + encryptionAlgorithm + '\'' + + ", kmsMasterKeyId='" + kmsMasterKeyId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketLifecycleRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketLifecycleRequest.java new file mode 100644 index 00000000..0e178a66 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketLifecycleRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Request for get Bucket Lifecycle. + */ +public class GetBucketLifecycleRequest extends GenericBucketRequest { + + /** + * Constructs a void Constructor for GetBucketLifecycleRequest. + */ + public GetBucketLifecycleRequest() { + } + + /** + * Constructs a new GetBucketLifecycleRequest to get a specified Bucket Lifecycle. + * @param bucketName + */ + public GetBucketLifecycleRequest(String bucketName) { + super(bucketName); + } + + @Override + public GetBucketLifecycleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public GetBucketLifecycleRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketLifecycleResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketLifecycleResponse.java new file mode 100644 index 00000000..06392a1b --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketLifecycleResponse.java @@ -0,0 +1,51 @@ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * Get Bucket Lifecycle Response + */ +public class GetBucketLifecycleResponse extends BosResponse { + + /** + * rule of GetBucketLifecycleResponse. + */ + private List rule; + + /** + * Gets rule of GetBucketLifecycleResponse. + * @return rule of GetBucketLifecycleResponse. + */ + public List getRule() { + return rule; + } + + /** + * Sets rule of GetBucketLifecycleResponse. + * @param rule The rule of GetBucketLifecycleResponse. + */ + public void setRule(List rule) { + this.rule = rule; + } + + /** + * Constructs a void constructor for GetBucketLifecycleResponse. + */ + public GetBucketLifecycleResponse() { + } + + /** + * Constructs a new GetBucketLifecycleResponse object for GetBucketLifecycleResponse. + * @param rule + */ + public GetBucketLifecycleResponse(List rule) { + this.rule = rule; + } + + @Override + public String toString() { + return "GetBucketLifecycleResponse{" + + "rule=" + rule + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketLoggingRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketLoggingRequest.java new file mode 100644 index 00000000..ccd7e962 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketLoggingRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + + + +public class GetBucketLoggingRequest extends GenericBucketRequest { + + /** + * Constructs a void Constructor for GetBucketLoggingRequest. + */ + public GetBucketLoggingRequest() { + } + + /** + * Constructs a new GetBucketLoggingRequest to get a specified Bucket Logging. + * @param bucketName + */ + public GetBucketLoggingRequest(String bucketName) { + super(bucketName); + } + + @Override + public GetBucketLoggingRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public GetBucketLoggingRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketLoggingResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketLoggingResponse.java new file mode 100644 index 00000000..c63707ae --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketLoggingResponse.java @@ -0,0 +1,80 @@ +package com.baidubce.services.bos.model; + +/** + * Get Bucket Logging Response + */ + +public class GetBucketLoggingResponse extends BosResponse { + + /** + * status of GetBucketLoggingResponse. + */ + private String status = ""; + + /** + * targetBucket of GetBucketLoggingResponse. + */ + private String targetBucket = ""; + + /** + * targetPrefix of GetBucketLoggingResponse. + */ + private String targetPrefix = ""; + + /** + * Gets status of GetBucketLoggingResponse. + * @return status of GetBucketLoggingResponse. + */ + public String getStatus() { + return status; + } + + /** + * Sets status of GetBucketLoggingResponse. + * @param status The status of GetBucketLoggingResponse. + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * Gets targetBucket of GetBucketLoggingResponse. + * @return targetBucket of GetBucketLoggingResponse. + */ + public String getTargetBucket() { + return targetBucket; + } + + /** + * Sets targetBucket of GetBucketLoggingResponse. + * @param targetBucket The targetBucket of GetBucketLoggingResponse. + */ + public void setTargetBucket(String targetBucket) { + this.targetBucket = targetBucket; + } + + /** + * Gets targetPrefix of GetBucketLoggingResponse. + * @return targetPrefix of GetBucketLoggingResponse. + */ + public String getTargetPrefix() { + return targetPrefix; + } + + /** + * Sets targetPrefix of GetBucketLoggingResponse. + * @param targetPrefix The targetPrefix of GetBucketLoggingResponse. + */ + public void setTargetPrefix(String targetPrefix) { + this.targetPrefix = targetPrefix; + } + + @Override + public String toString() { + return "GetBucketLoggingResponse{" + + "status='" + status + '\'' + + ", targetBucket='" + targetBucket + '\'' + + ", targetPrefix='" + targetPrefix + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketMirroringRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketMirroringRequest.java new file mode 100644 index 00000000..4faa4329 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketMirroringRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * GetBucketMirroringRequest class + */ +public class GetBucketMirroringRequest extends GenericBucketRequest { + public GetBucketMirroringRequest(String bucketName) { + super(bucketName); + } + + @Override + public GetBucketMirroringRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + + @Override + public GetBucketMirroringRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketMirroringResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketMirroringResponse.java new file mode 100644 index 00000000..2a87ef7d --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketMirroringResponse.java @@ -0,0 +1,25 @@ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * GetBucketMirroringResponse class + */ +public class GetBucketMirroringResponse extends BosResponse{ + private List bucketMirroringConfiguration; + + @Override + public String toString() { + return "GetBucketMirroringResponse{" + + "bucketMirroringConfiguration=" + bucketMirroringConfiguration + + '}'; + } + + public List getBucketMirroringConfiguration() { + return bucketMirroringConfiguration; + } + + public void setBucketMirroringConfiguration(List bucketMirroringConfiguration) { + this.bucketMirroringConfiguration = bucketMirroringConfiguration; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketReplicationProgressRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketReplicationProgressRequest.java new file mode 100644 index 00000000..ced59d8b --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketReplicationProgressRequest.java @@ -0,0 +1,85 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +public class GetBucketReplicationProgressRequest extends GenericBucketRequest { + + /** + * The replication id + */ + private String id; + + /** + * Gets the replication id + * @return + */ + public String getId() { + return id; + } + + /** + * Sets the replication id + * @param id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Constructs a void Constructor for GetBucketReplicationProgressRequest. + */ + public GetBucketReplicationProgressRequest() { + + } + + /** + * Constructs a new GetBucketReplicationProgressRequest to get a specified Bucket Replication + * Progress. + */ + public GetBucketReplicationProgressRequest(String bucketName) { + super(bucketName); + } + + /** + * Constructs a new GetBucketReplicationProgressRequest to get a specified Bucket Replication id + * Progress. + */ + public GetBucketReplicationProgressRequest(String bucketName, String id) { + super(bucketName); + this.setId(id); + } + + /** + * Set the replication id + * @param id + * @return + */ + public GetBucketReplicationProgressRequest withId(String id) { + this.setId(id); + return this; + } + + @Override + public GetBucketReplicationProgressRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public GetBucketReplicationProgressRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketReplicationRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketReplicationRequest.java new file mode 100644 index 00000000..cab5674b --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketReplicationRequest.java @@ -0,0 +1,88 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Request for get Bucket's specific id Replication. + */ +public class GetBucketReplicationRequest extends GenericBucketRequest { + + /** + * The replication id + */ + private String id; + + /** + * Gets the replication id + * @return + */ + public String getId() { + return id; + } + + /** + * Sets the replication id + * @param id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Constructs a void Constructor for GetBucketReplicationRequest. + */ + public GetBucketReplicationRequest() { + + } + + /** + * Constructs a new GetBucketReplicationRequest to get a specified Bucket Replication. + * @param bucketName + */ + public GetBucketReplicationRequest(String bucketName) { + super(bucketName); + } + + /** + * Constructs a new GetBucketReplicationRequest to get a specified Bucket Replication. + * @param bucketName + */ + public GetBucketReplicationRequest(String bucketName, String id) { + super(bucketName); + this.setId(id); + } + + /** + * Set the replication id + * @param id + * @return + */ + public GetBucketReplicationRequest withId(String id) { + this.setId(id); + return this; + } + + @Override + public GetBucketReplicationRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public GetBucketReplicationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketReplicationResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketReplicationResponse.java new file mode 100644 index 00000000..efce5ae0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketReplicationResponse.java @@ -0,0 +1,204 @@ +/* + * Copyright 2014-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.Arrays; + +/** + * Get Bucket Replication Response + */ +public class GetBucketReplicationResponse extends BosResponse { + + /** + * The replication rule name + */ + private String id; + + /** + * The status of replication + */ + private String status; + + /** + * The replication prefix, it must start with bucketName + */ + private String[] resource; + + /** + * The config of dest replication + */ + private Destination destination; + + /** + * The history replication + */ + private ReplicateHistory replicateHistory; + + /** + * Whether enable sync delete + */ + private String replicateDeletes; + + /** + * The replication create time + */ + private long createTime; + + /** + * The dest bucket region + */ + private String destRegion; + + /** + * Gets the replication rule name + * @return + */ + public String getId() { + return id; + } + + /** + * Sets the replication rule name + * @param id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets the status of replication + * @return + */ + public String getStatus() { + return status; + } + + /** + * Sets the status of replication + * @param status + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * Gets the replication prefix + * @return + */ + public String[] getResource() { + return resource; + } + + /** + * Sets the replication prefix + * @param resource + */ + public void setResource(String[] resource) { + this.resource = resource; + } + + /** + * Gets the config of dest replication + * @return + */ + public Destination getDestination() { + return destination; + } + + /** + * Sets the config of dest replication + * @param destination + */ + public void setDestination(Destination destination) { + this.destination = destination; + } + + /** + * Gets the history replication + * @return + */ + public ReplicateHistory getReplicateHistory() { + return replicateHistory; + } + + /** + * Sets the history replication + * @param replicateHistory + */ + public void setReplicateHistory(ReplicateHistory replicateHistory) { + this.replicateHistory = replicateHistory; + } + + /** + * Gets the sync delete flags + * @return + */ + public String getReplicateDeletes() { + return replicateDeletes; + } + + /** + * Sets the sync delete flags + * @param replicateDeletes + */ + public void setReplicateDeletes(String replicateDeletes) { + this.replicateDeletes = replicateDeletes; + } + + /** + * Gets the replication create_time + * @return + */ + public long getCreateTime() { + return createTime; + } + + /** + * Sets the replication create_time + * @param createTime + */ + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + /** + * Gets the dest bucket region + * @return + */ + public String getDestRegion() { + return destRegion; + } + + /** + * Sets the dest bucket region + * @param destRegion + */ + public void setDestRegion(String destRegion) { + this.destRegion = destRegion; + } + + + @Override + public String toString() { + return "GetBucketReplicationResponse{" + + "id='" + id + '\'' + + ", status='" + status + '\'' + + ", resource=" + Arrays.toString(resource) + + ", destination=" + destination + + ", replicateHistory=" + replicateHistory + + ", replicateDeletes='" + replicateDeletes + '\'' + + ", createTime=" + createTime + + ", destRegion='" + destRegion + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketStaticWebsiteRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketStaticWebsiteRequest.java new file mode 100644 index 00000000..c16b0083 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketStaticWebsiteRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Request for get Bucket StaticWebsite. + */ +public class GetBucketStaticWebsiteRequest extends GenericBucketRequest { + + /** + * Constructs a void Constructor for GetBucketStaticWebsiteRequest. + */ + public GetBucketStaticWebsiteRequest() { + + } + + /** + * Constructs a new GetBucketStaticWebsiteRequest to get a specified Bucket Lifecycle. + * @param bucketName + */ + public GetBucketStaticWebsiteRequest(String bucketName) { + super(bucketName); + } + + @Override + public GetBucketStaticWebsiteRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public GetBucketStaticWebsiteRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketStaticWebsiteResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketStaticWebsiteResponse.java new file mode 100644 index 00000000..2f214a35 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketStaticWebsiteResponse.java @@ -0,0 +1,60 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Get Bucket StaticWebsite Response + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetBucketStaticWebsiteResponse extends BosResponse { + + /** + * The index page for staticwebsite + */ + private String index; + + /** + * The notFound page for staticwebsite + */ + private String notFound; + + public GetBucketStaticWebsiteResponse() { + + } + + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + public String getNotFound() { + return notFound; + } + + public void setNotFound(String notFound) { + this.notFound = notFound; + } + + @Override + public String toString() { + return "GetBucketStaticWebsiteResponse{" + + "index='" + index + '\'' + + ", notFound='" + notFound + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketStorageClassRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketStorageClassRequest.java new file mode 100644 index 00000000..da5c95e0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketStorageClassRequest.java @@ -0,0 +1,37 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +public class GetBucketStorageClassRequest extends GenericBucketRequest { + + /** + * Constructs a new PutBucketStorageClassRequest. + * After constructing the request, + * users may optionally specify storageClass. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + */ + public GetBucketStorageClassRequest(String bucketName) { + this.setBucketName(bucketName); + } + + /** + * Sets the name of the bucket where this request will upload a new + * object to. Returns this object, enabling additional method calls to be + * chained together. + * + * @param bucketName The name of an existing bucket where this request will upload a new object to. + * @return This PutObjectRequest, enabling additional method calls to be chained together. + */ + @Override + public GetBucketStorageClassRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public GetBucketStorageClassRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketStorageClassResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketStorageClassResponse.java new file mode 100644 index 00000000..a093fdea --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketStorageClassResponse.java @@ -0,0 +1,37 @@ +package com.baidubce.services.bos.model; + +public class GetBucketStorageClassResponse extends BosResponse { + + /** + * The StorageClass is an identification that distinguish between infrequent access bos + * and standard bos. + */ + private String storageClass; + + /** + * Gets the storageClass of the input file which is be uploaded to Baidu Bos. + * + * @return storageClass The StorageClass is an identification that distinguish between infrequent access bos + * and standard bos. + */ + public String getStorageClass() { + return storageClass; + } + + /** + * Sets the storageClass of the input file which is be uploaded to Baidu Bos. + * + * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos + * and standard bos. + */ + public void setStorageClass(String storageClass) { + this.storageClass = storageClass; + } + + @Override + public String toString() { + return "GetBucketStorageClassResponse{" + + "storageClass='" + storageClass + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketTaggingRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketTaggingRequest.java new file mode 100644 index 00000000..8768788b --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketTaggingRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * GetBucketTaggingRequest class + */ +public class GetBucketTaggingRequest extends GenericBucketRequest { + + + public GetBucketTaggingRequest(String bucketName) { + super(bucketName); + } + + @Override + public GenericBucketRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketTaggingResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketTaggingResponse.java new file mode 100644 index 00000000..75af5b0f --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketTaggingResponse.java @@ -0,0 +1,25 @@ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * GetBucketTaggingResponse class + */ +public class GetBucketTaggingResponse extends BosResponse { + private List tag; + + public List getTag() { + return tag; + } + + public void setTag(List tag) { + this.tag = tag; + } + + @Override + public String toString() { + return "GetBucketTaggingResponse{" + + "tag=" + tag + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketTrashRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketTrashRequest.java new file mode 100644 index 00000000..327aeb6c --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketTrashRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + + +/** + * GetBucketTrashRequest class + */ +public class GetBucketTrashRequest extends GenericBucketRequest { + + public GetBucketTrashRequest(String bucketName) { + super(bucketName); + } + + @Override + public GetBucketTrashRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public GetBucketTrashRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketTrashResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketTrashResponse.java new file mode 100644 index 00000000..a7c88179 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketTrashResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bos.model; + +/** + * GetBucketTrashResponse class + */ +public class GetBucketTrashResponse extends BosResponse { + private String trashDir; + + + public String getTrashDir() { + return trashDir; + } + + public void setTrashDir(String trashDir) { + this.trashDir = trashDir; + } + + @Override + public String toString() { + return "GetBucketTrashResponse{" + + "trashDir='" + trashDir + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketVersioningRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketVersioningRequest.java new file mode 100644 index 00000000..15d48cf1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketVersioningRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class GetBucketVersioningRequest extends GenericBucketRequest { + + public GetBucketVersioningRequest(String bucketName){ + super(bucketName); + } + + @Override + public GenericBucketRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return null; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return null; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketVersioningResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketVersioningResponse.java new file mode 100644 index 00000000..9abea4cf --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketVersioningResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.bos.model; + +public class GetBucketVersioningResponse extends BosResponse { + private String status; + + @Override + public String toString() { + return "GetBucketVersioningResponse{" + + "status=" + status + + '}'; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectAclRequest.java b/src/main/java/com/baidubce/services/bos/model/GetObjectAclRequest.java new file mode 100644 index 00000000..71457cf9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetObjectAclRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +public class GetObjectAclRequest extends GenericObjectRequest { + + /** + * For versioning + */ + private String versionId; + + + /** + * Constructs a void Constructor for GetObjectAclRequest. + */ + public GetObjectAclRequest() { + + } + + /** + * Constructs a new GetObjectAclRequest to get a specified object acl. + * @param bucketName + * @param key + */ + public GetObjectAclRequest(String bucketName, String key) { + super(bucketName, key); + } + + @Override + public GetObjectAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public GetObjectAclRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public GetObjectAclRequest withKey(String key) { + this.setKey(key); + return this; + } + + public String getVersionId() { + return versionId; + } + + public void setVersionId(String versionId) { + this.versionId = versionId; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectAclResponse.java b/src/main/java/com/baidubce/services/bos/model/GetObjectAclResponse.java new file mode 100644 index 00000000..0e418194 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetObjectAclResponse.java @@ -0,0 +1,65 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.List; + +public class GetObjectAclResponse extends BosResponse { + public static final int MAX_SUPPORTED_ACL_VERSION = 1; + /** + * The acl version.. + */ + private int version = 1; + + /** + * The accessControlList of this specified bucket/object. + */ + private List accessControlList; + + /** + * Gets the acl version. + * + * @return the acl version. + */ + public int getVersion() { + return version; + } + + /** + * Sets the acl version. + * + * @param version the acl version + */ + public void setVersion(int version) { + this.version = version; + } + + /** + * Gets the accessControlList of this bucket/object. + * + * @return The accessControlList of this bucket/object. + */ + public List getAccessControlList() { + return this.accessControlList; + } + + /** + * Sets the accessControlList of this bucket/object. + * + * @param accessControlList The accessControlList of this bucket/object. + */ + public void setAccessControlList(List accessControlList) { + this.accessControlList = accessControlList; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java old mode 100644 new mode 100755 index 2bb66b6d..daf6c28e --- a/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java @@ -18,13 +18,11 @@ /** * Provides options for downloading an Baidu Bos object. - * *

* All GetObjectRequests must specify a bucket name and key. - * Beyond that, requests can also specify: *

- *

+ * Beyond that, requests can also specify: *

    - *
  • The range of bytes within the object to download, + *
  • The range of bytes within the object to download, *
*/ public class GetObjectRequest extends GenericObjectRequest { @@ -34,6 +32,11 @@ public class GetObjectRequest extends GenericObjectRequest { */ private long[] range; + /** + * The BosProgressCallback used for get progress information + */ + private BosProgressCallback progressCallback = null; + public GetObjectRequest() { super(); } @@ -42,7 +45,7 @@ public GetObjectRequest() { * Constructs a new GetObjectRequest with all the required parameters. * * @param bucketName The name of the bucket containing the desired object. - * @param key The key in the specified bucket under which the object is stored. + * @param key The key in the specified bucket under which the object is stored. */ public GetObjectRequest(String bucketName, String key) { super(bucketName, key); @@ -86,14 +89,13 @@ public GetObjectRequest withKey(String key) { /** * Gets the optional inclusive byte range within the desired object that will be downloaded by this request. - * *

* The range is returned as a two element array, containing the start and end index of the byte range. * If no byte range has been specified, the entire object is downloaded and this method returns null. * * @return A two element array indicating the inclusive start index and end index - * within the object being downloaded by this request. - * Returns null if no range has been specified, and the whole object is to be downloaded. + * within the object being downloaded by this request. + * Returns null if no range has been specified, and the whole object is to be downloaded. */ public long[] getRange() { return this.range == null ? null : this.range.clone(); @@ -101,11 +103,9 @@ public long[] getRange() { /** * Sets the optional inclusive byte range within the desired object that will be downloaded by this request. - * *

* The first byte in an object has position 0; as an example, the first ten bytes of an object can be * downloaded by specifying a range of 0 to 9. - * *

* If no byte range is specified, this request downloads the entire object from Baidu Bos. * @@ -121,11 +121,9 @@ public void setRange(long start, long end) { /** * Sets the optional inclusive byte range within the desired object that will be downloaded by this request. * Returns this GetObjectRequest, enabling additional method calls to be chained together. - * *

* The first byte in an object has position 0; as an example, the first ten bytes of an object can be * downloaded by specifying a range of 0 to 9. - * *

* If no byte range is specified, this request downloads the entire object from Baidu Bos. * @@ -138,4 +136,58 @@ public GetObjectRequest withRange(long start, long end) { return this; } + /** + * Gets the limit of put object speed. + * @return the limit of put object speed. unit: bit/s + */ + public long getTrafficLimitBitPS() { + return trafficLimitBitPS; + } + + /** + * Sets Gets the limit of put object speed. range: 819200 bit/s ~ 838860800 bit/s + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s + */ + public void setTrafficLimitBitPS(long trafficLimitBitPS) { + this.trafficLimitBitPS = trafficLimitBitPS; + } + + /** + * + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s, range: 819200 bit/s ~ 838860800 bit/s + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public GetObjectRequest withTrafficLimitBitPS(long trafficLimitBitPS) { + this.setTrafficLimitBitPS(trafficLimitBitPS); + return this; + } + + + /** + * Gets the BosProgressCallback which used for Get object progress. + * + * @return The BosProgressCallback which used for get progress information. + */ + public BosProgressCallback getProgressCallback() { + return progressCallback; + } + + /** + * Sets the BosProgressCallback which used for Get object progress. + * + * @param progressCallback The BosProgressCallback, which used for get progress information. + */ + public void setProgressCallback(BosProgressCallback progressCallback) { + this.progressCallback = progressCallback; + } + + /** + * @param progressCallback The BosProgressCallback, which used for get object information. + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public GetObjectRequest withProgressCallback(BosProgressCallback progressCallback) { + this.setProgressCallback(progressCallback); + return this; + } + } diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectSymlinkRequest.java b/src/main/java/com/baidubce/services/bos/model/GetObjectSymlinkRequest.java new file mode 100644 index 00000000..4c62636f --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetObjectSymlinkRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for get an Baidu Bos object symlink. + *

+ * All GetObjectSymlinkRequest must specify a bucket name and key. + * Beyond that, requests can also specify: + *

    + *
  • The range of bytes within the object to download, + *
+ */ +public class GetObjectSymlinkRequest extends GenericObjectRequest { + + + public GetObjectSymlinkRequest() { super(); } + + /** + * Constructs a new GetObjectSymlinkRequest with all the required parameters. + * + * @param bucketName The name of the bucket containing the desired object. + * @param key The symlink key in the specified bucket under which the object is stored. + */ + public GetObjectSymlinkRequest(String bucketName, String key) { + super(bucketName, key); + } + + /** + * Sets the symlink key. + * Returns this GetObjectSymlinkRequest, enabling additional method calls to be chained together. + * + * @param key The symlink key + * @return This GetObjectSymlinkRequest, enabling additional method calls to be chained together. + */ + @Override + public GetObjectSymlinkRequest withKey(String key) { + this.setKey(key); + return this; + } + + /** + * Sets the name of the bucket containing the symlink object. + * Returns this GetObjectSymlinkRequest, enabling additional method calls to be chained together. + * + * @param bucketName The name of the bucket containing the object to be downloaded. + * @return This GetObjectSymlinkRequest, enabling additional method calls to be chained together. + */ + @Override + public GetObjectSymlinkRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public GetObjectSymlinkRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectSymlinkResponse.java b/src/main/java/com/baidubce/services/bos/model/GetObjectSymlinkResponse.java new file mode 100644 index 00000000..a59387e1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/GetObjectSymlinkResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * response of get object symlink + */ +public class GetObjectSymlinkResponse { + + /** + * Gets target object of the symlink object + * @return The target object of the symlink object + */ + public String getSymlinkTarget() { + return symlinkTarget; + } + + /** + * Sets target object of the symlink object + * @param symlinkTarget + */ + public void setSymlinkTarget(String symlinkTarget) { + this.symlinkTarget = symlinkTarget; + } + + /** + * The target object of the symlink object + */ + private String symlinkTarget; + + +} diff --git a/src/main/java/com/baidubce/services/bos/model/Grant.java b/src/main/java/com/baidubce/services/bos/model/Grant.java old mode 100644 new mode 100755 index a5065a6b..dec001c3 --- a/src/main/java/com/baidubce/services/bos/model/Grant.java +++ b/src/main/java/com/baidubce/services/bos/model/Grant.java @@ -12,43 +12,60 @@ */ package com.baidubce.services.bos.model; -import com.baidubce.model.User; - import java.util.List; /** * Specifies a grant, consisting of one grantee and one permission. */ public class Grant { + + /** + * grantee of Bucket Acl. + * Identify authorized person. + */ private List grantee; + + /** + * permission of Bucket Acl. + * Permissions affected by ACL configuration items. + */ private List permission; - public Grant() { - } + /** + * condtion of Bucket Acl. + * Limits Contained in ACL Configuration Items, Supporting Configuration of IP Address and Referrer List. + */ + private Condition condition; /** - * Constructs a new Grant object using the specified grantee and permission objects. - * - * @param grantee The grantee being granted a permission by this grant. - * @param permission The permission being granted to the grantee by this grant. + * resources of Bucket Acl. + * Resources Affected by ACL Configuration Items. + * Indicates to set access to the resources specified by resource. */ - public Grant(List grantee, List permission) { - this.setGrantee(grantee); - this.setPermission(permission); - } + private List resource; + + /** + * notResources of Bucket Acl. + * Resources Affected by ACL Configuration Items. + * Indicates setting access to a resource except the one specified by notResource. + */ + private List notResource; + + /** + * the effect of Bucket Acl (Allow or Deny) + */ + private String effect; /** * Gets the grantee being granted a permission by this grant. - * * @return The grantee being granted a permission by this grant. */ public List getGrantee() { - return this.grantee; + return grantee; } /** * Sets the grantee being granted a permission by this grant. - * * @param grantee The grantee being granted a permission by this grant. */ public void setGrantee(List grantee) { @@ -57,8 +74,8 @@ public void setGrantee(List grantee) { /** * Sets the grantee being granted a permission by this grant. - * * @param grantee The grantee being granted a permission by this grant. + * @return this object. */ public Grant withGrantee(List grantee) { this.setGrantee(grantee); @@ -67,16 +84,14 @@ public Grant withGrantee(List grantee) { /** * Gets the permission being granted to the grantee by this grant. - * * @return The permission being granted to the grantee by this grant. */ public List getPermission() { - return this.permission; + return permission; } /** * Sets the permission being granted to the grantee by this grant. - * * @param permission The permission being granted to the grantee by this grant. */ public void setPermission(List permission) { @@ -85,14 +100,135 @@ public void setPermission(List permission) { /** * Sets the permission being granted to the grantee by this grant. - * * @param permission The permission being granted to the grantee by this grant. + * @return this object */ public Grant withPermission(List permission) { this.setPermission(permission); return this; } + /** + * Gets the condition of Bucket Acl. + * @return the condition of Bucket Acl. + */ + public Condition getCondition() { + return condition; + } + + /** + * Sets the condition of Bucket Acl. + * @param condition The condtion of Bucket Acl. + */ + public void setCondition(Condition condition) { + this.condition = condition; + } + + /** + * Sets the condtion of Bucket Acl. + * @param condition The condtion of Bucket Acl. + * @return this object. + */ + public Grant withCondition(Condition condition) { + this.setCondition(condition); + return this; + } + + /** + * Gets the resource of Bucket Acl. + * @return the resource of Bucket Acl. + */ + public List getResource() { + return resource; + } + + /** + * Sets the resource of Bucket Acl. + * @param resource The resource of Bucket Acl. + */ + public void setResource(List resource) { + this.resource = resource; + } + + /** + * Sets the resource of Bucket Acl. + * @param resource The resource of Bucket Acl. + * @return this object. + */ + public Grant withResource(List resource) { + this.setResource(resource); + return this; + } + + /** + * Gets notResource of Bucket Acl. + * @return the notResource if Bucket Acl. + */ + public List getNotResource() { + return notResource; + } + + /** + * Sets notResource of Bucket Acl. + * @param notResource The notResource if Bucket Acl. + */ + public void setNotResource(List notResource) { + this.notResource = notResource; + } + + /** + * Sets notResource of Bucket Acl. + * @param notResource The notResource of Bucket Acl. + * @return this object. + */ + public Grant withNotResource(List notResource) { + this.setNotResource(notResource); + return this; + } + + /** + * Constructs a new Grant object using the specified grantee and permission objects. + * + * @param grantee The grantee being granted a permission by this grant. + * @param permission The permission being granted to the grantee by this grant. + */ + public Grant(List grantee, List permission) { + this.grantee = grantee; + this.permission = permission; + } + + /** + * Gets effect of Bucket Acl + * @return the effect of Bucket Acl + */ + public String getEffect() { + return effect; + } + + /** + * Sets effect of Bucket Acl + * @param effect + */ + public void setEffect(String effect) { + this.effect = effect; + } + + /** + * Sets effect of Bucket Acl + * @param effect + * @return this object + */ + public Grant withEffect(String effect) { + this.setEffect(effect); + return this; + } + + /** + * Constructs a void Constructor for Bucket Acl Grant. + */ + public Grant() { + } + @Override public int hashCode() { final int prime = 31; @@ -129,6 +265,12 @@ public boolean equals(Object obj) { @Override public String toString() { - return "Grant [grantee=" + this.grantee + ", permission=" + this.permission + "]"; + return "Grant{" + + "grantee=" + grantee + + ", permission=" + permission + + ", condition=" + condition + + ", resource=" + resource + + ", notResource=" + notResource + + '}'; } } diff --git a/src/main/java/com/baidubce/services/bos/model/Grantee.java b/src/main/java/com/baidubce/services/bos/model/Grantee.java old mode 100644 new mode 100755 index 83b92feb..398abe21 --- a/src/main/java/com/baidubce/services/bos/model/Grantee.java +++ b/src/main/java/com/baidubce/services/bos/model/Grantee.java @@ -16,6 +16,7 @@ * Represents the grantee of an Baidu Bos bucket. */ public class Grantee { + private String id; /** @@ -27,7 +28,7 @@ public Grantee() { /** * Constructs a new grantee with the specified ID. * - * @param id The ID for the user. + * @param id The ID for the user. */ public Grantee(String id) { this.setId(id); @@ -55,6 +56,7 @@ public void setId(String id) { * Sets the ID of the grantee. * * @param id The ID of the grantee. + * @return this object */ public Grantee withId(String id) { this.setId(id); diff --git a/src/main/java/com/baidubce/services/bos/model/HeadBucketRequest.java b/src/main/java/com/baidubce/services/bos/model/HeadBucketRequest.java new file mode 100644 index 00000000..e668c469 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/HeadBucketRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +public class HeadBucketRequest extends GenericBucketRequest { + /** + * Constructs a new GetBucketLocationRequest object, ready to retrieve the Location + * for the specified bucket when executed. + * + * @param bucketName The name of the bucket whose Location will be retrieved by this + * request when executed. + */ + public HeadBucketRequest(String bucketName) { + super(bucketName); + } + + public HeadBucketRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public HeadBucketRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/HeadBucketResponse.java b/src/main/java/com/baidubce/services/bos/model/HeadBucketResponse.java new file mode 100644 index 00000000..96a9bd95 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/HeadBucketResponse.java @@ -0,0 +1,4 @@ +package com.baidubce.services.bos.model; + +public class HeadBucketResponse extends BosResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/InputSerialization.java b/src/main/java/com/baidubce/services/bos/model/InputSerialization.java new file mode 100644 index 00000000..a76012bd --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/InputSerialization.java @@ -0,0 +1,131 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.util.Base64Utils; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import java.util.HashMap; +import java.util.Map; + +/** + * InputSerialization for selecting object request + */ +@JsonPropertyOrder({"compressionType", + Constants.SELECT_TYPE_CSV, + Constants.SELECT_TYPE_JSON, + Constants.SELECT_TYPE_PARQUET}) +public class InputSerialization { + /** + * Specifies whether the object of the query is compressed + */ + private String compressionType; + + /** + * the params of csv, json or parquet in inputSerialization + */ + @JsonIgnore + private Map params = new HashMap(); + + /** + * when select csv object, csvParams = params; for composing json string + */ + @JsonProperty(Constants.SELECT_TYPE_CSV) + private Map csvParams; + + /** + * when select json object, jsonParams = params; for composing json string + */ + @JsonProperty(Constants.SELECT_TYPE_JSON) + private Map jsonParams; + + /** + * when select parquet object, parquetParams = params; for composing json string + */ + @JsonProperty(Constants.SELECT_TYPE_PARQUET) + private Map parquetParams; + + public void setCompressionType(String compressionType) { + this.compressionType = compressionType; + } + + public String getCompressionType() { + return this.compressionType; + } + + public InputSerialization withCompressionType(String compressionType) { + this.setCompressionType(compressionType); + return this; + } + + public InputSerialization withFileHeaderInfo(String fileHeaderInfo) { + params.put(Constants.FILE_HEADER_INFO, fileHeaderInfo); + return this; + } + + public InputSerialization withRecordDelimiter(String recordDelimiter) { + params.put(Constants.RECORD_DELIMITER, Base64Utils.encode(recordDelimiter)); + return this; + } + + public InputSerialization withFieldDelimiter(String fieldDelimiter) { + params.put(Constants.FIELD_DELIMITER, Base64Utils.encode(fieldDelimiter)); + return this; + } + + public InputSerialization withQuoteCharacter(String quoteCharacter) { + params.put(Constants.QUOTE_CHARACTER, Base64Utils.encode(quoteCharacter)); + return this; + } + + public InputSerialization withCommentCharacter(String commentCharacter) { + params.put(Constants.COMMENT_CHARACTER, Base64Utils.encode(commentCharacter)); + return this; + } + + // set json args + public InputSerialization withJsonType(String type) { + params.put("type", type); + return this; + } + + public Map getCsvParams() { + return csvParams; + } + + public void setCsvParams(Map csvParams) { + this.csvParams = csvParams; + } + + public Map getJsonParams() { + return jsonParams; + } + + public void setJsonParams(Map jsonParams) { + this.jsonParams = jsonParams; + } + + public Map getParquetParams() { + return parquetParams; + } + + public void setParquetParams(Map parquetParams) { + this.parquetParams = parquetParams; + } + + public Map getParams() { + return params; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/ListBucketReplicationRequest.java b/src/main/java/com/baidubce/services/bos/model/ListBucketReplicationRequest.java new file mode 100644 index 00000000..1bf4263f --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/ListBucketReplicationRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Container for the the parameters of the List Bucket Replication. + * + * Required Parameters: BucketName + */ +public class ListBucketReplicationRequest extends GenericBucketRequest { + + /** + * Constructs a void ListBucketReplicationRequest + */ + public ListBucketReplicationRequest() { + + } + + /** + * Constructs a new ListBucketReplicationRequest with all the required parameters. + * + * @param bucketName The name of the bucket containing the desired object. + */ + public ListBucketReplicationRequest(String bucketName) { + super(bucketName); + } + + @Override + public ListBucketReplicationRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public ListBucketReplicationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/ListBucketReplicationResponse.java b/src/main/java/com/baidubce/services/bos/model/ListBucketReplicationResponse.java new file mode 100644 index 00000000..8c214f79 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/ListBucketReplicationResponse.java @@ -0,0 +1,140 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.Arrays; +import java.util.List; + +/** + * Response for list bucket replication + */ +public class ListBucketReplicationResponse extends BosResponse { + + /** + * The list of bucket replication + */ + private List rules; + + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + } + + @Override + public String toString() { + return "ListBucketReplicationResponse{" + + "rules=" + rules + + '}'; + } + + private static class Rule { + + private String status; + + private String[] resource; + + private Destination destination; + + private ReplicateHistory replicateHistory; + + private String replicateDeletes; + + private String id; + + private long createTime; + + private String destRegion; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String[] getResource() { + return resource; + } + + public void setResource(String[] resource) { + this.resource = resource; + } + + public Destination getDestination() { + return destination; + } + + public void setDestination(Destination destination) { + this.destination = destination; + } + + public ReplicateHistory getReplicateHistory() { + return replicateHistory; + } + + public void setReplicateHistory(ReplicateHistory replicateHistory) { + this.replicateHistory = replicateHistory; + } + + public String getReplicateDeletes() { + return replicateDeletes; + } + + public void setReplicateDeletes(String replicateDeletes) { + this.replicateDeletes = replicateDeletes; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public String getDestRegion() { + return destRegion; + } + + public void setDestRegion(String destRegion) { + this.destRegion = destRegion; + } + + @Override + public String toString() { + return "Rule{" + + "status='" + status + '\'' + + ", resource=" + Arrays.toString(resource) + + ", destination=" + destination + + ", replicateHistory=" + replicateHistory + + ", replicateDeletes='" + replicateDeletes + '\'' + + ", id='" + id + '\'' + + ", createTime=" + createTime + + ", destRegion='" + destRegion + '\'' + + '}'; + } + } + +} diff --git a/src/main/java/com/baidubce/services/bos/model/ListObjectsRequest.java b/src/main/java/com/baidubce/services/bos/model/ListObjectsRequest.java index f7b50d95..2fde7575 100644 --- a/src/main/java/com/baidubce/services/bos/model/ListObjectsRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/ListObjectsRequest.java @@ -55,6 +55,8 @@ public class ListObjectsRequest extends GenericBucketRequest { */ private int maxKeys = -1; + private boolean needExtMeta = false; + /** * Constructs a new ListObjectsRequest object and initializes all required and optional object fields. * @@ -253,4 +255,12 @@ public ListObjectsRequest withMaxKeys(int maxKeys) { return this; } + public boolean isNeedExtMeta() { + return needExtMeta; + } + + public void setNeedExtMeta(boolean needExtMeta) { + this.needExtMeta = needExtMeta; + } + } diff --git a/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java b/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java old mode 100644 new mode 100755 index 9495a901..f6df8c50 --- a/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java @@ -12,7 +12,6 @@ */ package com.baidubce.services.bos.model; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.common.collect.Lists; @@ -25,6 +24,7 @@ * request, information describing if this is a complete or partial * listing, and the original request parameters. */ +@JsonDeserialize(using = ListObjectsResponseDeserializer.class) public class ListObjectsResponse extends BosResponse { /** @@ -58,9 +58,11 @@ public class ListObjectsResponse extends BosResponse { * A list of the common prefixes included in this object listing - common * prefixes will only be populated for requests that specified a delimiter. */ - @JsonDeserialize(using = CommonPrefixesDeserializer.class) + // @JsonDeserialize(using = CommonPrefixesDeserializer.class) private List commonPrefixes; + private List commonPrefixesWithExtMeta; + /** * The marker parameter originally specified by the caller when this object listing was returned */ @@ -99,7 +101,6 @@ public void setContents(List contents) { /** * Gets the common prefixes included in this object listing. Common * prefixes are only present if a delimiter was specified in the original request. - * *

* Each common prefix represents a set of keys in the Bos bucket that have * been condensed and omitted from the object summary results. This allows @@ -107,7 +108,7 @@ public void setContents(List contents) { * similar to how a file system organizes files into directories. * * @return The list of common prefixes included in this object listing, - * which might be an empty list if no common prefixes were found. + * which might be an empty list if no common prefixes were found. */ public List getCommonPrefixes() { return this.commonPrefixes; @@ -126,15 +127,14 @@ public void setCommonPrefixes(List commonPrefixes) { /** * Gets the marker to use in the next listObjects request in order to see * the next page of results. - * *

* If an object listing is not truncated, this method will return null. For * truncated requests, this value is equal to the greatest lexicographical value of the * object keys and common prefixes included in this listing. * * @return The marker to use in the next listObjects request in order to see - * the next page of results if this object listing is truncated. - * Returns null if this object listing isn't truncated. + * the next page of results if this object listing is truncated. + * Returns null if this object listing isn't truncated. */ public String getNextMarker() { return this.nextMarker; @@ -145,7 +145,7 @@ public String getNextMarker() { * in order to see the next page of results for a truncated object listing. * * @param nextMarker The marker to use in the next listObjects request in order to - * see the next page of results for a truncated object listing. + * see the next page of results for a truncated object listing. */ public void setNextMarker(String nextMarker) { this.nextMarker = nextMarker; @@ -166,7 +166,7 @@ public String getBucketName() { * * @param bucketName The name of the Baidu Bos bucket containing the objects listed in this BosObjectListing. */ - @JsonProperty("name") + // @JsonProperty("name") public void setBucketName(String bucketName) { this.bucketName = bucketName; } @@ -174,12 +174,11 @@ public void setBucketName(String bucketName) { /** * Gets the prefix parameter originally used to request this object listing, or * null if no prefix was specified. - * *

* All objects and common prefixes included in this object listing start with the specified prefix. * * @return The prefix parameter originally used to request this object - * listing. Returns null if no prefix was specified. + * listing. Returns null if no prefix was specified. */ public String getPrefix() { return this.prefix; @@ -202,7 +201,7 @@ public void setPrefix(String prefix) { * alphabetically after the specified marker. * * @return The marker parameter originally used to request this object - * listing. Returns null if no marker was specified. + * listing. Returns null if no marker was specified. */ public String getMarker() { return this.marker; @@ -226,9 +225,9 @@ public void setMarker(String marker) { * listing. An object listing will never contain more objects plus common * prefixes than indicated by the maxKeys, but can of course contain less. * - * @return The maxKeysmaxKeys value applied by Baidu Bos if - * no value was specified. + * @return The maxKeys parameter originally used to request this object + * listing. Returns the default maxKeys value applied by Baidu Bos if + * no value was specified. */ public int getMaxKeys() { return this.maxKeys; @@ -241,8 +240,8 @@ public int getMaxKeys() { * applied by Baidu Bos if the requester didn't specify a value. * * @param maxKeys The maxKeys parameter originally used to request this object - * listing, or the default maxKeys value applied by Baidu Bos if - * the requester didn't specify a value. + * listing, or the default maxKeys value applied by Baidu Bos if + * the requester didn't specify a value. */ public void setMaxKeys(int maxKeys) { this.maxKeys = maxKeys; @@ -251,7 +250,6 @@ public void setMaxKeys(int maxKeys) { /** * Gets the delimiter parameter originally used to request this object * listing, or null if no delimiter specified. - * *

* The delimiter value allows * callers to condense Bos keys into common prefix listings. For example, if @@ -262,7 +260,7 @@ public void setMaxKeys(int maxKeys) { * one entry for the common prefix. * * @return The delimiter parameter originally used to request this object - * listing. Returns null if no delimiter was specified. + * listing. Returns null if no delimiter was specified. */ public String getDelimiter() { return this.delimiter; @@ -282,9 +280,9 @@ public void setDelimiter(String delimiter) { * Gets whether or not this object listing is complete. * * @return The value true if the object listing is not complete. - * Returns the value false if otherwise. - * When returning true, additional calls to Baidu Bos may be needed in order to - * obtain more results. + * Returns the value false if otherwise. + * When returning true, additional calls to Baidu Bos may be needed in order to + * obtain more results. */ public boolean isTruncated() { return this.isTruncated; @@ -297,11 +295,19 @@ public boolean isTruncated() { * object summaries. * * @param isTruncated The value true if the object listing is not complete. - * The value false if otherwise. + * The value false if otherwise. */ - @JsonProperty("isTruncated") + // @JsonProperty("isTruncated") public void setTruncated(boolean isTruncated) { this.isTruncated = isTruncated; } + public List getCommonPrefixesWithExtMeta() { + return commonPrefixesWithExtMeta; + } + + public void setCommonPrefixesWithExtMeta(List commonPrefixesWithExtMeta) { + this.commonPrefixesWithExtMeta = commonPrefixesWithExtMeta; + } + } diff --git a/src/main/java/com/baidubce/services/bos/model/ListObjectsResponseDeserializer.java b/src/main/java/com/baidubce/services/bos/model/ListObjectsResponseDeserializer.java new file mode 100644 index 00000000..fd5828a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/ListObjectsResponseDeserializer.java @@ -0,0 +1,161 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.http.Headers; +import com.baidubce.model.User; +import com.baidubce.util.DateUtils; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.deser.BeanDeserializer; +import com.fasterxml.jackson.databind.deser.BeanDeserializerFactory; +import com.fasterxml.jackson.databind.deser.DefaultDeserializationContext; +import com.fasterxml.jackson.databind.introspect.BasicBeanDescription; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +public class ListObjectsResponseDeserializer extends BeanDeserializer { + public ListObjectsResponseDeserializer() { + super(createBeanDeserializer(ListObjectsResponse.class), true); + } + + public ListObjectsResponseDeserializer(Class beanClass) { + super(createBeanDeserializer(beanClass), true); + } + + @Override + public ListObjectsResponse deserialize(JsonParser parser, DeserializationContext ctx, Object bean) + throws IOException, JsonProcessingException { + JsonNode node = parser.getCodec().readTree(parser); + ListObjectsResponse listObjectsResponse = (ListObjectsResponse) bean; + if (node.has("name")) { + listObjectsResponse.setBucketName(node.get("name").asText()); + } + if (node.has("prefix")) { + listObjectsResponse.setPrefix(node.get("prefix").asText()); + } + if (node.has("delimiter")) { + listObjectsResponse.setDelimiter(node.get("delimiter").asText()); + } + if (node.has("marker")) { + listObjectsResponse.setMarker(node.get("marker").asText()); + } + if (node.has("nextMarker")) { + listObjectsResponse.setNextMarker(node.get("nextMarker").asText()); + } + if (node.has("maxKeys")) { + listObjectsResponse.setMaxKeys(node.get("maxKeys").asInt()); + } + if (node.has("isTruncated")) { + listObjectsResponse.setTruncated(node.get("isTruncated").asBoolean()); + } + + if (node.has("contents")) { + JsonNode contentsNode = node.get("contents"); + List contents = new ArrayList(); + for (Iterator it = contentsNode.elements(); it.hasNext(); ) { + JsonNode content = it.next(); + BosObjectSummary bosObjectSummary = new BosObjectSummary(); + bosObjectSummary.setBucketName(listObjectsResponse.getBucketName()); + if (content.has("key")) { + bosObjectSummary.setKey(content.get("key").asText()); + } + if (content.has("lastModified") && !content.get("lastModified").asText().isEmpty()) { + bosObjectSummary.setLastModified(DateUtils.parseAlternateIso8601Date(content.get("lastModified").asText())); + } + if (content.has("eTag")) { + bosObjectSummary.setETag(content.get("eTag").asText()); + } + if (content.has("size")) { + bosObjectSummary.setSize(content.get("size").asLong()); + } + User owner = new User(); + if (content.has("owner")) { + if (content.get("owner").has("id")) { + owner.setId(content.get("owner").get("id").asText()); + } + if (content.get("owner").has("displayName")) { + owner.setDisplayName(content.get("owner").get("displayName").asText()); + } + } + bosObjectSummary.setOwner(owner); + if (content.has("storageClass")) { + bosObjectSummary.setStorageClass(content.get("storageClass").asText()); + } + if (content.has("userMeta")) { + Map userMeta = new HashMap(); + for (Iterator userMetaIterator = content.get("userMeta").fieldNames(); userMetaIterator.hasNext(); ) { + String name = userMetaIterator.next(); + String userMetaKey = name; + if (name.startsWith(Headers.BCE_USER_METADATA_PREFIX)) { + userMetaKey = name.substring(Headers.BCE_USER_METADATA_PREFIX.length()); + } + userMeta.put(userMetaKey, content.get("userMeta").get(name).asText()); + } + bosObjectSummary.setUserMeta(userMeta); + } + contents.add(bosObjectSummary); + } + listObjectsResponse.setContents(contents); + } + + if (node.has("commonPrefixes")) { + JsonNode commonPrefixesNode = node.get("commonPrefixes"); + List commonPrefixes = new ArrayList(); + List commonPrefixesWithExtMeta = new ArrayList(); + for (Iterator it = commonPrefixesNode.elements(); it.hasNext(); ) { + JsonNode commonPrefix = it.next(); + if (commonPrefix.has("prefix")) { + commonPrefixes.add(commonPrefix.get("prefix").asText()); + } + BosPrefixInfo bosPrefixInfo = new BosPrefixInfo(); + if (commonPrefix.has("prefix")) { + bosPrefixInfo.setPrefix(commonPrefix.get("prefix").asText()); + } + if (commonPrefix.has("lastModified") && !commonPrefix.get("lastModified").asText().isEmpty()) { + bosPrefixInfo.setLastModified(DateUtils.parseAlternateIso8601Date(commonPrefix.get("lastModified").asText())); + } + if (commonPrefix.has("userMeta")) { + Map userMeta = new HashMap(); + for (Iterator userMetaIterator = commonPrefix.get("userMeta").fieldNames(); userMetaIterator.hasNext(); ) { + String name = userMetaIterator.next(); + String userMetaKey = name; + if (name.startsWith(Headers.BCE_USER_METADATA_PREFIX)) { + userMetaKey = name.substring(Headers.BCE_USER_METADATA_PREFIX.length()); + } + userMeta.put(userMetaKey, commonPrefix.get("userMeta").get(name).asText()); + } + bosPrefixInfo.setUserMeta(userMeta); + } + commonPrefixesWithExtMeta.add(bosPrefixInfo); + } + listObjectsResponse.setCommonPrefixes(commonPrefixes); + listObjectsResponse.setCommonPrefixesWithExtMeta(commonPrefixesWithExtMeta); + } + + return listObjectsResponse; + } + + private static BeanDeserializer createBeanDeserializer(Class listObjectsResponse){ + try { + ObjectMapper mapper = new ObjectMapper(); + DefaultDeserializationContext defctx = (DefaultDeserializationContext) mapper.getDeserializationContext(); + DefaultDeserializationContext ctxt = defctx.createInstance(mapper.getDeserializationConfig(), null, null); + JavaType type = ctxt.constructType(listObjectsResponse); + BasicBeanDescription beanDesc = (BasicBeanDescription) ctxt.getConfig().introspect(type); + BeanDeserializerFactory factory = (BeanDeserializerFactory) ctxt.getFactory(); + BeanDeserializer beanDeserializer = (BeanDeserializer) factory.buildBeanDeserializer(ctxt, type, beanDesc); + beanDeserializer.resolve(ctxt); + return beanDeserializer; + } catch (Exception e) { + throw new ExceptionInInitializerError(e); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/NotResource.java b/src/main/java/com/baidubce/services/bos/model/NotResource.java new file mode 100644 index 00000000..588ce81c --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/NotResource.java @@ -0,0 +1,54 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * notResource of Bucket Acl. + * Resource Affected by ACL Configuration Items. + * Indicates setting access to a resource except the one specified by notResource. + */ +public class NotResource { + + /** + * the notResource of Bucket Acl + */ + private List notResource; + + /** + * Gets the notResource of Bucket Acl. + * @return the notResource of Bucket Acl. + */ + public List getNotResource() { + return notResource; + } + + /** + * Sets the notResource of Bucket Acl. + * @param notResource The resources of Bucket Acl. + */ + public void setNotResource(List notResource) { + this.notResource = notResource; + } + + /** + * Sets the notResource of Bucket Acl. + * @param notResource The resources of Bucket Acl. + * @return this Object. + */ + public NotResource withNotResource(List notResource) { + this.setNotResource(notResource); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java b/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java old mode 100644 new mode 100755 index 8130d70d..25f78054 --- a/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java +++ b/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java @@ -99,6 +99,31 @@ public class ObjectMetadata { private String storageClass; + /** + * The CRC value of the object. CRC(Cyclic Redundancy Check) + */ + private String xBceCrc; + + /** + * The archive object restore status + */ + private String restore; + + /** + * The canned acl of the object, private or public-read + */ + private String xBceAcl; + + /** + * The CRC32C value of the object. CRC(Cyclic Redundancy Check) + */ + private String xBceCrc32c; + + /** + * The version id + */ + private String versionId; + public ObjectMetadata() { } @@ -120,6 +145,10 @@ public ObjectMetadata(ObjectMetadata other) { this.setObjectType(other.getObjectType()); this.setCacheControl(other.getCacheControl()); this.setStorageClass(other.getStorageClass()); + this.setxBceCrc(other.getxBceCrc()); + this.setRestore(other.getRestore()); + this.setxBceAcl(other.getxBceAcl()); + this.setVersionId(other.getVersionId()); } /** @@ -135,7 +164,7 @@ public Map getUserMetadata() { * Sets the custom user-metadata for the associated object. * * @param userMetadata The custom user-metadata for the associated object. Note that - * the key should not include the internal Bos HTTP header prefix. + * the key should not include the internal Bos HTTP header prefix. */ public void setUserMetadata(Map userMetadata) { checkNotNull(userMetadata, "userMetadata should not be null."); @@ -148,7 +177,7 @@ public void setUserMetadata(Map userMetadata) { * specified key, it will be replaced with these new contents. * * @param key The key for the custom user metadata entry. Note that the key - * should not include the internal Bos HTTP header prefix. + * should not include the internal Bos HTTP header prefix. * @param value The value for the custom user-metadata entry. */ public void addUserMetadata(String key, String value) { @@ -157,6 +186,9 @@ public void addUserMetadata(String key, String value) { /** * For internal use only. Returns the value of the userMetadata for the specified key. + * + * @param key the key of the userMetadata + * @return the value of the userMetadata */ public String getUserMetaDataOf(String key) { return this.userMetadata == null ? null : this.userMetadata.get(key); @@ -204,7 +236,7 @@ public void setBceContentSha256(String bceContentSha256) { * for the object to be saved as. * * @return The value of the Content-Disposition header. - * Returns null if the Content-Disposition header hasn't been set. + * Returns null if the Content-Disposition header hasn't been set. */ public String getContentDisposition() { return this.contentDisposition; @@ -250,7 +282,7 @@ public void setContentEncoding(String contentEncoding) { * associated object in bytes. * * @return The Content-Length HTTP header indicating the size of the - * associated object in bytes. Returns null if it hasn't been set yet. + * associated object in bytes. Returns null if it hasn't been set yet. */ public long getContentLength() { return this.contentLength; @@ -261,7 +293,7 @@ public long getContentLength() { * associated object in bytes. * * @param contentLength The Content-Length HTTP header indicating the size of the - * associated object in bytes. + * associated object in bytes. */ public void setContentLength(long contentLength) { this.contentLength = contentLength; @@ -274,7 +306,7 @@ public void setContentLength(long contentLength) { * Baidu Bos is the same data that the caller sent. * * @return The base64 encoded MD5 hash of the content for the associated - * object. Returns null if the MD5 hash of the content hasn't been set. + * object. Returns null if the MD5 hash of the content hasn't been set. */ public String getContentMd5() { return this.contentMd5; @@ -288,7 +320,7 @@ public String getContentMd5() { * MD5 digest is removed from the metadata. * * @param contentMd5 The base64 encoded MD5 hash of the content for the object - * associated with this metadata. + * associated with this metadata. */ public void setContentMd5(String contentMd5) { this.contentMd5 = contentMd5; @@ -300,7 +332,7 @@ public void setContentMd5(String contentMd5) { * MIME type. * * @return The HTTP Content-Type header, indicating the type of content - * stored in the associated Bos object. Returns null if it hasn't been set. + * stored in the associated Bos object. Returns null if it hasn't been set. */ public String getContentType() { return this.contentType; @@ -312,7 +344,7 @@ public String getContentType() { * MIME type. * * @param contentType The HTTP Content-Type header indicating the type of content - * stored in the associated Bos object. + * stored in the associated Bos object. */ public void setContentType(String contentType) { this.contentType = contentType; @@ -323,14 +355,13 @@ public void setContentType(String contentType) { * according to RFC 1864. This data is used as an integrity check to verify * that the data received by the caller is the same data that was sent by * Baidu Bos. - * *

* This field represents the hex encoded 128-bit MD5 digest of an object's * content as calculated by Baidu Bos. The ContentMD5 field represents the * base64 encoded 128-bit MD5 digest as calculated on the caller's side. * * @return The hex encoded MD5 hash of the content for the associated object - * as calculated by Baidu Bos. Returns null if it hasn't been set yet. + * as calculated by Baidu Bos. Returns null if it hasn't been set yet. */ public String getETag() { return this.eTag; @@ -341,14 +372,13 @@ public String getETag() { * according to RFC 1864. This data is used as an integrity check to verify * that the data received by the caller is the same data that was sent by * Baidu Bos. - * *

* This field represents the hex encoded 128-bit MD5 digest of an object's * content as calculated by Baidu Bos. The ContentMD5 field represents the * base64 encoded 128-bit MD5 digest as calculated on the caller's side. * * @param eTag The hex encoded MD5 hash of the content for the associated object - * as calculated by Baidu Bos. + * as calculated by Baidu Bos. */ public void setETag(String eTag) { this.eTag = eTag; @@ -357,6 +387,8 @@ public void setETag(String eTag) { /** * Returns the physical length of the entire object stored in Bos. * This is useful during, for example, a range get operation. + * + * @return the physical length of the entire object */ public long getInstanceLength() { return this.instanceLength; @@ -365,7 +397,7 @@ public long getInstanceLength() { /** * Sets the physical length of the entire object stored in Bos. * - * @param instanceLength + * @param instanceLength the physical length of the entire object */ public void setInstanceLength(long instanceLength) { this.instanceLength = instanceLength; @@ -377,8 +409,8 @@ public void setInstanceLength(long instanceLength) { * associated object. * * @return The date and time at which Baidu Bos last recorded a modification - * to the associated object. Returns null if - * the Last-Modified header hasn't been set. + * to the associated object. Returns null if + * the Last-Modified header hasn't been set. */ public Date getLastModified() { return this.lastModified; @@ -390,7 +422,7 @@ public Date getLastModified() { * modification to the associated object. * * @param lastModified The date and time at which Baidu Bos last recorded a - * modification to the associated object. + * modification to the associated object. */ public void setLastModified(Date lastModified) { this.lastModified = lastModified; @@ -433,6 +465,21 @@ public String toString() { if (this.storageClass != null) { builder.append(", storageClass=").append(this.storageClass); } + if (this.xBceCrc != null) { + builder.append(", xBceCrc=").append(this.xBceCrc); + } + if (this.objectType != null) { + builder.append(", objectType=").append(this.objectType); + } + if (this.restore != null) { + builder.append(", restore=").append(this.restore); + } + if (this.xBceAcl != null) { + builder.append(", xBceAcl=").append(this.xBceAcl); + } + if (this.versionId != null) { + builder.append(", versionId=").append(this.versionId); + } builder.append(']'); return builder.toString(); } @@ -476,4 +523,94 @@ public String getStorageClass() { public void setStorageClass(String storageClass) { this.storageClass = storageClass; } + + /** + * Gets the crc of object. + * + * @return the crc of object. + */ + public String getxBceCrc() { + return xBceCrc; + } + + /** + * Sets the crc of object. + * + * @return the crc of object. + */ + public void setxBceCrc(String xBceCrc) { + this.xBceCrc = xBceCrc; + } + + /** + * Gets archive object restore status + * + * @return + */ + public String getRestore() { + return restore; + } + + /** + * Sets archive object restore status + * + * @param restore + */ + public void setRestore(String restore) { + this.restore = restore; + } + + /** + * Get the canned acl of object. + * + * @return the canned acl of object. + */ + public String getxBceAcl() { + return xBceAcl; + } + + /** + * Set the canned acl of object. + */ + public void setxBceAcl(String xBceAcl) { + this.xBceAcl = xBceAcl; + } + + /** + * Gets the crc32c of object. + * + * @return the crc32c of object. + */ + public String getxBceCrc32c() { + return xBceCrc32c; + } + + /** + * Sets the crc32c of object. + * + * @return the crc32c of object. + */ + public void setxBceCrc32c(String xBceCrc32c) { + this.xBceCrc32c = xBceCrc32c; + } + + /** + * Gets the versionId of object. + * + * @return the versionId of object. + */ + public String getVersionId() { + return versionId; + } + + /** + * Sets the versionId of object. + * + * @return the versionId of object. + */ + public void setVersionId(String versionId) { + this.versionId = versionId; + } + + } diff --git a/src/main/java/com/baidubce/services/bos/model/OutputSerialization.java b/src/main/java/com/baidubce/services/bos/model/OutputSerialization.java new file mode 100644 index 00000000..e2f0cde0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/OutputSerialization.java @@ -0,0 +1,108 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.util.Base64Utils; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import java.util.HashMap; +import java.util.Map; + +/** + * OutputSerialization for selecting object request + */ +@JsonPropertyOrder({"outputHeader", Constants.SELECT_TYPE_CSV, Constants.SELECT_TYPE_JSON}) +public class OutputSerialization { + /** + * Output CSV header information at the beginning of the returned result. + * The default is false. The value of fileHeaderInfo field is use + */ + private boolean outputHeader = false; + + /** + * the params of csv or json in outputSerialization + */ + @JsonIgnore + private Map params = new HashMap(); + + /** + * when select csv object, csvParams = params; for composing json string + */ + @JsonProperty(Constants.SELECT_TYPE_CSV) + private Map csvParams; + + /** + * when select json object, jsonParams = params; for composing json string + */ + @JsonProperty(Constants.SELECT_TYPE_JSON) + private Map jsonParams; + + public void setOutputHeader(boolean outputHeader) { + this.outputHeader = outputHeader; + } + + public boolean getOutputHeader() { + return outputHeader; + } + + public OutputSerialization withOutputHeader(boolean outputHeader) { + this.setOutputHeader(outputHeader); + return this; + } + + public OutputSerialization withQuoteFields(String quoteFields) { + params.put(Constants.QUOTE_FIELDS, quoteFields); + return this; + } + + public OutputSerialization withRecordDelimiter(String recordDelimiter) { + params.put(Constants.RECORD_DELIMITER, Base64Utils.encode(recordDelimiter)); + return this; + } + + public OutputSerialization withFieldDelimiter(String fieldDelimiter) { + params.put(Constants.FIELD_DELIMITER, Base64Utils.encode(fieldDelimiter)); + return this; + } + + public OutputSerialization withQuoteCharacter(String quoteCharacter) { + params.put(Constants.QUOTE_CHARACTER, Base64Utils.encode(quoteCharacter)); + return this; + } + + public Map getCsvParams() { + return csvParams; + } + + public void setCsvParams(Map csvParams) { + this.csvParams = csvParams; + } + + public Map getJsonParams() { + return jsonParams; + } + + public void setJsonParams(Map jsonParams) { + this.jsonParams = jsonParams; + } + + public String getValue(String key) { + return this.params.get(key); + } + + public Map getParams() { + return params; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/Permission.java b/src/main/java/com/baidubce/services/bos/model/Permission.java index 4c768aca..c82f5411 100644 --- a/src/main/java/com/baidubce/services/bos/model/Permission.java +++ b/src/main/java/com/baidubce/services/bos/model/Permission.java @@ -12,14 +12,82 @@ */ package com.baidubce.services.bos.model; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + /** * Specifies constants defining an access permission,. Only a limited set of permission are available; * each one is represented as a value in this enumeration. */ +@JsonIgnoreProperties(ignoreUnknown = true) public enum Permission { FULL_CONTROL, READ, WRITE, LIST, - GetObject; + MODIFY, + + // Object + GetObject, + GetObjectMeta, + PutObject, + DeleteObject, + RenameObject, + RestoreObject, + PutObjectAcl, + GetObjectAcl, + PutObjectTagging, + GetObjectTagging, + DeleteObjectTagging, + ListParts, + + // Bucket + GetBucket, + PutBucket, + ListBucket, + GetBucketAcl, + PutBucketAcl, + GetBucketCors, + PutBucketCors, + GetBucketStyle, + PutBucketStyle, + GetBucketMirroring, + PutBucketMirroring, + GetCopyRightProtection, + PutCopyRightProtection, + GetObjectVersion, + DeleteObjectVersion, + ListObjectVersions, + GetObjectVersionAcl, + PutObjectVersionAcl, + PutBucketVersioning, + GetBucketVersioning, + PutBucketLifecycle, + GetBucketLifecycle, + PutBucketReplication, + GetBucketReplication, + PutBucketEncryption, + GetBucketEncryption, + PutBucketStaticWebsite, + GetBucketStaticWebsite, + PutBucketLogging, + GetBucketLogging, + PutBucketRequestPayment, + GetBucketRequestPayment, + PutBucketTagging, + GetBucketTagging, + PutNotification, + GetNotification, + PutBucketObjectLock, + GetBucketObjectLock, + PutBucketInventory, + GetBucketInventory, + GetBucketStorageAnalysis, + PutBucketStorageAnalysis, + GetBucketStorageClass, + PutBucketStorageClass, + PutBucketTrash, + GetBucketTrash, + PutBucketQuota, + GetBucketQuota; } + diff --git a/src/main/java/com/baidubce/services/bos/model/PutBucketMirroringRequest.java b/src/main/java/com/baidubce/services/bos/model/PutBucketMirroringRequest.java new file mode 100644 index 00000000..45f2fd24 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/PutBucketMirroringRequest.java @@ -0,0 +1,70 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +/** + * PutBucketMirroringRequest class + */ +@JsonIgnoreProperties({"bucketName"}) +public class PutBucketMirroringRequest extends GenericBucketRequest { + /** + * The BucketMirroringConfiguration + */ + private List bucketMirroringConfiguration; + + /** + * The json format for BucketMirroringConfiguration + */ + private String jsonBucketMirroringConfiguration; + + /** + * Constructs a void Constructor for PutBucketMirroringRequest + */ + public PutBucketMirroringRequest() { + + } + + public PutBucketMirroringRequest(String bucketName, + List bucketMirroringConfiguration) { + super(bucketName); + this.bucketMirroringConfiguration = bucketMirroringConfiguration; + } + + public PutBucketMirroringRequest(String bucketName, String jsonBucketMirroringConfiguration) { + super(bucketName); + this.jsonBucketMirroringConfiguration = jsonBucketMirroringConfiguration; + } + + + @Override + public PutBucketMirroringRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public PutBucketMirroringRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + + public List getBucketMirroringConfiguration() { + return bucketMirroringConfiguration; + } + + public void setBucketMirroringConfiguration(List bucketMirroringConfiguration) { + this.bucketMirroringConfiguration = bucketMirroringConfiguration; + } + + public String getJsonBucketMirroringConfiguration() { + return jsonBucketMirroringConfiguration; + } + + public void setJsonBucketMirroringConfiguration(String jsonBucketMirroringConfiguration) { + this.jsonBucketMirroringConfiguration = jsonBucketMirroringConfiguration; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/PutBucketStorageClassRequest.java b/src/main/java/com/baidubce/services/bos/model/PutBucketStorageClassRequest.java new file mode 100644 index 00000000..5d0404b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/PutBucketStorageClassRequest.java @@ -0,0 +1,65 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +public class PutBucketStorageClassRequest extends GenericBucketRequest { + /** + * The StorageClass is an identification that distinguish between infrequent access bos + * and standard bos. + */ + private String storageClass; + + /** + * Constructs a new PutBucketStorageClassRequest. + * After constructing the request, + * users may optionally specify storageClass. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param storageClass The key is an identification + * that distinguish between infrequent access bos and standard bos. + */ + public PutBucketStorageClassRequest(String bucketName, String storageClass) { + this.setBucketName(bucketName); + this.setStorageClass(storageClass); + } + + /** + * Gets the storageClass of the input file which is be uploaded to Baidu Bos. + * + * @return storageClass The StorageClass is an identification that distinguish between infrequent access bos + * and standard bos. + */ + public String getStorageClass() { + return storageClass; + } + + /** + * Sets the storageClass of the input file which is be uploaded to Baidu Bos. + * + * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos + * and standard bos. + */ + public void setStorageClass(String storageClass) { + this.storageClass = storageClass; + } + + /** + * Sets the name of the bucket where this request will upload a new + * object to. Returns this object, enabling additional method calls to be + * chained together. + * + * @param bucketName The name of an existing bucket where this request will upload a new object to. + * @return This PutObjectRequest, enabling additional method calls to be chained together. + */ + @Override + public PutBucketStorageClassRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public PutBucketStorageClassRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/PutBucketTaggingRequest.java b/src/main/java/com/baidubce/services/bos/model/PutBucketTaggingRequest.java new file mode 100644 index 00000000..b4349c50 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/PutBucketTaggingRequest.java @@ -0,0 +1,69 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +/** + * PutBucketTaggingRequest class + */ +@JsonIgnoreProperties({"bucketName"}) +public class PutBucketTaggingRequest extends GenericBucketRequest { + /** + * The BucketTag object + */ + private List tags; + + /** + * The json format for BucketTag + */ + private String jsonBucketTags; + + /** + * Constructs a void Constructor for PutBucketTaggingRequest + */ + public PutBucketTaggingRequest() { + + } + + public PutBucketTaggingRequest(String bucketName, List tags) { + super(bucketName); + this.tags = tags; + } + + public PutBucketTaggingRequest(String bucketName, String jsonBucketTags) { + super(bucketName); + this.jsonBucketTags = jsonBucketTags; + } + + + @Override + public GenericBucketRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public String getJsonBucketTags() { + return jsonBucketTags; + } + + public void setJsonBucketTags(String jsonBucketTags) { + this.jsonBucketTags = jsonBucketTags; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/PutBucketTrashRequest.java b/src/main/java/com/baidubce/services/bos/model/PutBucketTrashRequest.java new file mode 100644 index 00000000..34703884 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/PutBucketTrashRequest.java @@ -0,0 +1,53 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; +import com.fasterxml.jackson.annotation.JsonAlias; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + + +/** + * PutBucketTrashRequest class + */ +@JsonIgnoreProperties({"bucketName"}) +public class PutBucketTrashRequest extends GenericBucketRequest { + + /** + * The BucketTrashName + */ + @JsonAlias({"trashDir"}) + private String trashDir; + + public PutBucketTrashRequest(){}; + + public PutBucketTrashRequest(String bucketName) { + super(bucketName); + } + + + public PutBucketTrashRequest(String bucketName, String trashDir) { + super(bucketName); + this.trashDir = trashDir; + } + + + @Override + public PutBucketTrashRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public PutBucketTrashRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getTrashDir() { + return trashDir; + } + + public void setTrashDir(String trashDir) { + this.trashDir = trashDir; + } +} + diff --git a/src/main/java/com/baidubce/services/bos/model/PutBucketVersioningRequest.java b/src/main/java/com/baidubce/services/bos/model/PutBucketVersioningRequest.java new file mode 100644 index 00000000..7e5381c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/PutBucketVersioningRequest.java @@ -0,0 +1,47 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonAlias; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties({"bucketName"}) +public class PutBucketVersioningRequest extends GenericBucketRequest { + + @JsonAlias({"status"}) + private String status; + + public PutBucketVersioningRequest() { + } + + + public PutBucketVersioningRequest(String bucketName) { + super(bucketName); + } + + + public PutBucketVersioningRequest(String bucketName, String status) { + super(bucketName); + this.status = status; + } + + @Override + public GenericBucketRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return null; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return null; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/PutObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/PutObjectRequest.java index 840c9d8b..8176e969 100644 --- a/src/main/java/com/baidubce/services/bos/model/PutObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/PutObjectRequest.java @@ -54,18 +54,43 @@ public class PutObjectRequest extends GenericObjectRequest { /** * The StorageClass is an identification that distinguish between infrequent access bos - * and standard bos. + * and standard bos. */ private String storageClass; + /** + * Used to Audio and video processing interface + */ + private String videoProcess = null; + + /** + * The BosProgressCallback used for get progress information + */ + private BosProgressCallback progressCallback = null; + + /** + * xBceAcl to control acl. + */ + private String xBceAcl = null; + + /** + * xBceProcess to set callback. + */ + private String xBceProcess = null; + + /** + * The xBceCrc32cFlag, whether to calculate crc32c + */ + private boolean xBceCrc32cFlag = false; + /** * Constructs a new PutObjectRequest object to upload a file to the * specified bucket and key. After constructing the request, * users may optionally specify object metadata or a canned ACL as well. * * @param bucketName The name of an existing bucket to which the new object will be uploaded. - * @param key The key under which to store the new object. - * @param file The path of the file to upload to Baidu Bos. + * @param key The key under which to store the new object. + * @param file The path of the file to upload to Baidu Bos. */ public PutObjectRequest(String bucketName, String key, File file) { this(bucketName, key, file, null, new ObjectMetadata()); @@ -78,10 +103,10 @@ public PutObjectRequest(String bucketName, String key, File file) { * users may optionally specify object metadata or a canned ACL as well. * * @param bucketName The name of an existing bucket to which the new object will be uploaded. - * @param key The key under which to store the new object. - * @param file The path of the file to upload to Baidu Bos. - * @param metadata The object metadata. At minimum this specifies the - * content length for the stream of data being uploaded. + * @param key The key under which to store the new object. + * @param file The path of the file to upload to Baidu Bos. + * @param metadata The object metadata. At minimum this specifies the + * content length for the stream of data being uploaded. */ public PutObjectRequest(String bucketName, String key, File file, ObjectMetadata metadata) { this(bucketName, key, file, null, metadata); @@ -94,8 +119,8 @@ public PutObjectRequest(String bucketName, String key, File file, ObjectMetadata * the specified bucket and key. After constructing the request, * users may optionally specify object metadata or a canned ACL as well. * - * @param bucketName The name of an existing bucket to which the new object will be uploaded. - * @param key The key under which to store the new object. + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. * @param inputStream The stream of data to upload to Baidu Bos. */ public PutObjectRequest(String bucketName, String key, InputStream inputStream) { @@ -108,11 +133,28 @@ public PutObjectRequest(String bucketName, String key, InputStream inputStream) * the specified bucket and key. After constructing the request, * users may optionally specify object metadata or a canned ACL as well. * - * @param bucketName The name of an existing bucket to which the new object will be uploaded. - * @param key The key under which to store the new object. + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. + * @param inputStream The stream of data to upload to Baidu Bos. + * @param progressCallback The BosProgressCallback, which used for get progress information. + */ + public PutObjectRequest(String bucketName, String key, InputStream inputStream, + BosProgressCallback progressCallback) { + this(bucketName, key, null, inputStream, new ObjectMetadata()); + checkNotNull(inputStream, "inputStream should not be null."); + this.setProgressCallback(progressCallback); + } + + /** + * Constructs a new PutObjectRequest object to upload a stream of data to + * the specified bucket and key. After constructing the request, + * users may optionally specify object metadata or a canned ACL as well. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. * @param inputStream The stream of data to upload to Baidu Bos. - * @param metadata The object metadata. At minimum this specifies the - * content length for the stream of data being uploaded. + * @param metadata The object metadata. At minimum this specifies the + * content length for the stream of data being uploaded. */ public PutObjectRequest(String bucketName, String key, InputStream inputStream, ObjectMetadata metadata) { this(bucketName, key, null, inputStream, metadata); @@ -125,15 +167,15 @@ public PutObjectRequest(String bucketName, String key, InputStream inputStream, * the specified bucket and key. After constructing the request, * users may optionally specify object metadata or a canned ACL as well. * - * @param bucketName The name of an existing bucket to which the new object will be uploaded. - * @param key The key under which to store the new object. - * @param file The path of the file to upload to Baidu Bos. - * @param inputStream The stream of data to upload to Baidu Bos. + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. + * @param file The path of the file to upload to Baidu Bos. + * @param inputStream The stream of data to upload to Baidu Bos. * @param objectMetadata The object metadata. At minimum this specifies the - * content length for the stream of data being uploaded. + * content length for the stream of data being uploaded. */ protected PutObjectRequest(String bucketName, String key, File file, InputStream inputStream, - ObjectMetadata objectMetadata) { + ObjectMetadata objectMetadata) { super(bucketName, key); this.file = file; this.inputStream = inputStream; @@ -225,7 +267,7 @@ public PutObjectRequest withFile(File file) { * impacts. * * @return The optional metadata instructing Baidu Bos how to handle the - * uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.). + * uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.). */ public ObjectMetadata getObjectMetadata() { return this.objectMetadata; @@ -244,7 +286,7 @@ public ObjectMetadata getObjectMetadata() { * impacts. * * @param objectMetadata The optional metadata instructing Baidu Bos how to handle the - * uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.). + * uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.). */ public void setObjectMetadata(ObjectMetadata objectMetadata) { this.objectMetadata = objectMetadata; @@ -264,7 +306,7 @@ public void setObjectMetadata(ObjectMetadata objectMetadata) { * impacts. * * @param objectMetadata The optional metadata instructing Baidu Bos how to handle the - * uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.). + * uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.). * @return This PutObjectRequest, enabling additional method calls to be chained together. */ public PutObjectRequest withObjectMetadata(ObjectMetadata objectMetadata) { @@ -279,8 +321,8 @@ public PutObjectRequest withObjectMetadata(ObjectMetadata objectMetadata) { * uploaded to Baidu Bos; both cannot be specified. * * @return The input stream containing the data to be uploaded to Baidu Bos. - * Either specify a file or an input stream containing the - * data to be uploaded to Baidu Bos, not both. + * Either specify a file or an input stream containing the + * data to be uploaded to Baidu Bos, not both. */ public InputStream getInputStream() { return this.inputStream; @@ -292,7 +334,8 @@ public InputStream getInputStream() { * uploaded to Baidu Bos; both cannot be specified. * * @param inputStream The input stream containing the data to be uploaded to Baidu Bos. - * Either specify a file or an input stream containing the data to be uploaded to Baidu Bos, not both. + * Either specify a file or an input stream containing the data to be uploaded to Baidu Bos, + * not both. */ public void setInputStream(InputStream inputStream) { this.inputStream = inputStream; @@ -313,9 +356,10 @@ public PutObjectRequest withInputStream(InputStream inputStream) { this.setInputStream(inputStream); return this; } + /** * Gets the storageClass of the input file which is be uploaded to Baidu Bos. - * + * * @return storageClass The StorageClass is an identification that distinguish between infrequent access bos * and standard bos. */ @@ -325,9 +369,9 @@ public String getStorageClass() { /** * Sets the storageClass of the input file which is be uploaded to Baidu Bos. - * - * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos - * and standard bos. + * + * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos + * and standard bos. */ public void setStorageClass(String storageClass) { this.storageClass = storageClass; @@ -335,13 +379,143 @@ public void setStorageClass(String storageClass) { /** * Sets the storageClass of the input file which is be uploaded to Baidu Bos. - * - * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos - * and standard bos. + * + * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos + * and standard bos. * @return This PutObjectRequest, so that additional method calls can be chained together. */ public PutObjectRequest withStorageClass(String storageClass) { this.setStorageClass(storageClass); return this; } + + /** + * Gets the BosProgressCallback which used for Get upload progress. + * + * @return The BosProgressCallback which used for get progress information. + */ + public BosProgressCallback getProgressCallback() { + return progressCallback; + } + + /** + * Sets the BosProgressCallback which used for Get upload progress. + * + * @param progressCallback The BosProgressCallback, which used for get progress information. + */ + public void setProgressCallback(BosProgressCallback progressCallback) { + this.progressCallback = progressCallback; + } + + /** + * @param progressCallback The BosProgressCallback, which used for get progress information. + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public PutObjectRequest withProgressCallback(BosProgressCallback progressCallback) { + this.setProgressCallback(progressCallback); + return this; + } + + /** + * Gets the limit of put object speed. + * + * @return the limit of put object speed. unit: bit/s + */ + public long getTrafficLimitBitPS() { + return trafficLimitBitPS; + } + + /** + * Sets Gets the limit of put object speed. range: 819200 bit/s ~ 838860800 bit/s + * + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s + */ + public void setTrafficLimitBitPS(long trafficLimitBitPS) { + this.trafficLimitBitPS = trafficLimitBitPS; + } + + /** + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s, range: 819200 bit/s ~ 838860800 bit/s + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public PutObjectRequest withTrafficLimitBitPS(long trafficLimitBitPS) { + this.setTrafficLimitBitPS(trafficLimitBitPS); + return this; + } + + /** + * Gets the parameter of Audio and video processing + * + * @return the parameter of Audio and video processing + */ + public String getVideoProcess() { + return videoProcess; + } + + /** + * @param videoProcess The parameter of Audio and video processing + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public void setVideoProcess(String videoProcess) { + this.videoProcess = videoProcess; + } + + /** + * @param videoProcess The parameter of Audio and video processing + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public PutObjectRequest withVideoProcess(String videoProcess) { + this.setVideoProcess(videoProcess); + return this; + } + + /** + * Gets xBceCrc32cFlag of the object + * + * @return xBceCrc32cFlag of the object. + */ + public boolean getxBceCrc32cFlag() { + return xBceCrc32cFlag; + } + + /** + * Sets xBceCrc32cFlag of the object + * + * @param xBceCrc32cFlag whether to calculate crc32c. + */ + public void setxBceCrc32cFlag(boolean xBceCrc32cFlag) { + this.xBceCrc32cFlag = xBceCrc32cFlag; + } + + /** + * Gets xBceAcl of the object + * + * @return xBceAcl of the object. + */ + public String getxBceAcl() { + return this.xBceAcl; + } + + /** + * Sets xBceAcl of the object + */ + public void setxBceAcl(String acl) { + this.xBceAcl = acl; + } + + /** + * Gets xBceProcess of the object + * + * @return xBceProcess of the object. + */ + public String getxBceProcess() { + return this.xBceProcess; + } + + /** + * Sets xBceProcess of the object + */ + public void setxBceProcess(String xBceProcess) { + this.xBceProcess = xBceProcess; + } } diff --git a/src/main/java/com/baidubce/services/bos/model/PutObjectResponse.java b/src/main/java/com/baidubce/services/bos/model/PutObjectResponse.java index 4cddf0fd..c7545d3c 100644 --- a/src/main/java/com/baidubce/services/bos/model/PutObjectResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/PutObjectResponse.java @@ -24,6 +24,11 @@ public class PutObjectResponse { */ private String eTag; + /** + * The callback value of the new object + */ + private BosResponse.Callback callback; + /** * Gets the ETag value for the newly created object. * @@ -43,4 +48,24 @@ public void setETag(String eTag) { this.eTag = eTag; } + /** + * Sets the callback value for the new object that was created from the + * associated putObject request. + * + * @param callback The ETag value for the new object. + */ + public void setCallback(BosResponse.Callback callback) { + this.callback = callback; + } + + /** + * Gets the callback value for the newly created object. + * + * @return The callback value for the new object. + */ + public BosResponse.Callback getCallback() { + return this.callback; + } + + } \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/PutSuperObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/PutSuperObjectRequest.java new file mode 100644 index 00000000..67129f7d --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/PutSuperObjectRequest.java @@ -0,0 +1,301 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.io.File; +import java.util.concurrent.atomic.AtomicBoolean; + +import com.baidubce.auth.BceCredentials; + +/** + * Request object containing all the options for put Super Object to bucket. + */ +public class PutSuperObjectRequest extends GenericObjectRequest { + + /** + * the part size when upload super object file + */ + private long chunkSize; + + /** + * The num of threads in thread pool + */ + private int nThreads; + + /** + * whether cancel upload super object file + */ + private AtomicBoolean isSuperObjectUploadCanced = new AtomicBoolean(false); + + /** + * The super object file containing the data to be uploaded to Baidu Bos. + */ + private File file; + + /** + * The uploadId used for complete + */ + private String uploadId; + + /** + * the part size when upload super object file + */ + private static final long CHUNK_SIZE = 1024 * 1024 * 5L; + + /** + * Additional information about the new object being created, such as + * content type, content encoding, user metadata, etc. + */ + private ObjectMetadata objectMetadata = new ObjectMetadata(); + + private static final int AVAILABLEPROCESSORS = Runtime.getRuntime().availableProcessors(); + + /** + * The BosProgressCallback used for get progress information + */ + private BosProgressCallback progressCallback = null; + + /** + * The xBceCrc32cFlag, whether to calculate crc32c + */ + private boolean xBceCrc32cFlag = false; + + public PutSuperObjectRequest(String bucketName, String key, File file) { + this(bucketName, key, file, CHUNK_SIZE, AVAILABLEPROCESSORS); + } + + public PutSuperObjectRequest(String bucketName, String key, File file, long chunkSize) { + this(bucketName, key, file, chunkSize, AVAILABLEPROCESSORS); + } + + public PutSuperObjectRequest(String bucketName, String key, File file, int nThreads) { + this(bucketName, key, file, CHUNK_SIZE, nThreads); + } + + /** + * Constructs a new PutSuperObjectRequest object to upload a super object file and a stream of data to + * the specified bucket and key. After constructing the request, + * users may optionally specify object metadata or a canned ACL as well. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. + * @param file The path of the super object file to upload to Baidu Bos. + * @param chunkSize the part size when upload super object file + * @param nThreads the number of thread in thread pool + */ + public PutSuperObjectRequest(String bucketName, String key, File file, long chunkSize, + int nThreads) { + super(bucketName, key); + this.file = file; + this.chunkSize = chunkSize; + this.nThreads = nThreads; + } + + public void cancel() { + isSuperObjectUploadCanced.set(true); + } + + public long getChunkSize() { + return chunkSize; + } + + public void setChunkSize(long chunkSize) { + this.chunkSize = chunkSize; + } + + @Override + public PutSuperObjectRequest withKey(String key) { + this.setKey(key); + return this; + } + + @Override + public PutSuperObjectRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public PutSuperObjectRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Gets the path and name of the file containing the data to be uploaded to Baidu Bos. + * Either specify a file or an input stream containing the data to be + * uploaded to Baidu Bos; both cannot be specified. + * + * @return The path and name of the file containing the data to be uploaded to Baidu Bos. + */ + public File getFile() { + return this.file; + } + + /** + * Sets the path and name of the file + * containing the data to be uploaded to Baidu Bos. + * Either specify a file or an input stream containing the data to be + * uploaded to Baidu Bos; both cannot be specified. + * + * @param file The path and name of the file containing the data to be uploaded to Baidu Bos. + */ + public void setFile(File file) { + this.file = file; + } + + /** + * Sets the file containing the data to be uploaded to Baidu Bos. + * Returns this PutObjectRequest, enabling additional method calls to be chained together. + * + *

+ * Either specify a file or an input stream containing the data to + * be uploaded to Baidu Bos; both cannot be specified. + * + * @param file The file containing the data to be uploaded to Baidu Bos. + * @return This PutObjectRequest, enabling additional method calls to be chained together. + */ + public PutSuperObjectRequest withFile(File file) { + this.setFile(file); + return this; + } + + public int getnThreads() { + return nThreads; + } + + public void setnThreads(int nThreads) { + this.nThreads = nThreads; + } + + public PutSuperObjectRequest withnThreads(int nThreads) { + this.setnThreads(nThreads); + return this; + } + + public AtomicBoolean getIsSuperObjectUploadCanced() { + return isSuperObjectUploadCanced; + } + + public void setIsSuperObjectUploadCanced(AtomicBoolean isSuperObjectUploadCanced) { + this.isSuperObjectUploadCanced = isSuperObjectUploadCanced; + } + + public PutSuperObjectRequest withIsSuperObjectUploadCanced(AtomicBoolean isSuperObjectUploadCanced) { + this.setIsSuperObjectUploadCanced(isSuperObjectUploadCanced); + return this; + } + + public String getUploadId() { + return uploadId; + } + + public void setUploadId(String uploadId) { + this.uploadId = uploadId; + } + + public PutSuperObjectRequest withUploadId(String uploadId) { + this.setUploadId(uploadId); + return this; + } + + /** + * Returns the additional information about the new object being created, + * such as content type, content encoding, user metadata, etc. + * + * @return The additional information about the new object being created, + * such as content type, content encoding, user metadata, etc. + */ + public ObjectMetadata getObjectMetadata() { + return objectMetadata; + } + + /** + * Sets the additional information about the new object being created, such + * as content type, content encoding, user metadata, etc. + * + * @param objectMetadata Additional information about the new object being created, + * such as content type, content encoding, user metadata, etc. + */ + public void setObjectMetadata(ObjectMetadata objectMetadata) { + this.objectMetadata = objectMetadata; + } + + /** + * Gets the BosProgressCallback which used for Get upload progress. + * @return The BosProgressCallback which used for get progress information. + */ + public BosProgressCallback getProgressCallback() { + return progressCallback; + } + + /** + * Sets the BosProgressCallback which used for Get upload progress. + * @param progressCallback The BosProgressCallback, which used for get progress information. + */ + public void setProgressCallback(BosProgressCallback progressCallback) { + this.progressCallback = progressCallback; + } + + /** + * + * @param progressCallback The BosProgressCallback, which used for get progress information. + * @return This PutSuperObjectRequest, so that additional method calls can be chained together + */ + public PutSuperObjectRequest withProgressCallback(BosProgressCallback progressCallback) { + this.setProgressCallback(progressCallback); + return this; + } + + /** + * Gets the limit of put object speed. + * @return the limit of put object speed. unit: bit/s + */ + public long getTrafficLimitBitPS() { + return trafficLimitBitPS; + } + + /** + * Sets Gets the limit of put object speed. range: 819200 bit/s ~ 838860800 bit/s + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s + */ + public void setTrafficLimitBitPS(long trafficLimitBitPS) { + this.trafficLimitBitPS = trafficLimitBitPS; + } + + /** + * + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s, range: 819200 bit/s ~ 838860800 bit/s + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public PutSuperObjectRequest withTrafficLimitBitPS(long trafficLimitBitPS) { + this.setTrafficLimitBitPS(trafficLimitBitPS); + return this; + } + + /** + * Gets xBceCrc32cFlag of the object + * @return xBceCrc32cFlag of the object. + */ + public boolean getxBceCrc32cFlag() { + return xBceCrc32cFlag; + } + + /** + * Sets xBceCrc32cFlag of the object + * @param xBceCrc32cFlag whether to calculate crc32c. + */ + public void setxBceCrc32cFlag(boolean xBceCrc32cFlag) { + this.xBceCrc32cFlag = xBceCrc32cFlag; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/Referer.java b/src/main/java/com/baidubce/services/bos/model/Referer.java new file mode 100644 index 00000000..16706827 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/Referer.java @@ -0,0 +1,92 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * For Bucket Acl Condition. + * Identifies the referer that is granted access permission. + */ +public class Referer { + + /** + * Identify the fuzzy matching address in the referer's whitelist. + */ + private List stringLike; + + /** + * Identify the exact matching address in the referer's whitelist. + */ + private List stringEquals; + + /** + * Gets the stringLike of Bucket Acl Condition Referer. + * @return the stringLike of Bucket Acl Condition Referer. + */ + public List getStringLike() { + return stringLike; + } + + /** + * Sets the stringLike of Bucket Acl Condition Referer. + * @param stringLike The stringLike of Bucket Acl Condition Referer. + */ + public void setStringLike(List stringLike) { + this.stringLike = stringLike; + } + + /** + * Sets the stringLike of Bucket Acl Condition Referer. + * @param stringLike The stringLike of Bucket Acl Condition Referer. + * @return this object. + */ + public Referer withStringLike (List stringLike) { + this.setStringLike(stringLike); + return this; + } + + /** + * Gets the stringEquals of Bucket Acl Condition Referer. + * @return the stringEquals of Bucket Acl Condition Referer. + */ + public List getStringEquals() { + return stringEquals; + } + + /** + * Sets the stringEquals of Bucket Acl Condition Referer. + * @param stringEquals The stringEquals of Bucket Acl Condition Referer. + */ + public void setStringEquals(List stringEquals) { + this.stringEquals = stringEquals; + } + + /** + * Sets the stringEquals of Bucket Acl Condition Referer. + * @param stringEquals The stringEquals of Bucket Acl Condition Referer. + * @return this object. + */ + public Referer withStringEquals (List stringEquals) { + this.setStringEquals(stringEquals); + return this; + } + + @Override + public String toString() { + return "Referer{" + + "stringLike=" + stringLike + + ", stringEquals=" + stringEquals + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/RenameObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/RenameObjectRequest.java new file mode 100644 index 00000000..1c38ffd4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/RenameObjectRequest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; +import com.google.common.base.Preconditions; + +/** + * Request object for rename Bos object's key + */ +public class RenameObjectRequest extends GenericObjectRequest { + + /** + * The origin key of object + */ + private String sourceKey; + + /** + * Constructs a new RenameObjectRequest object to rename Bos object + * specified bucket, sourceKey and key. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param sourceKey The origin key of object + * @param key The destination key of object + */ + public RenameObjectRequest(String bucketName, String sourceKey, String key) { + super(bucketName, key); + this.setSourceKey(sourceKey); + } + + /** + * Get the object origin key + * + * @return The origin Key + */ + public String getSourceKey() { + return this.sourceKey; + } + + /** + * Set the sourceKey of the Request + * + * @param sourceKey the key of Baidu bos object + */ + public void setSourceKey(String sourceKey) { + Preconditions.checkNotNull(sourceKey, "sourceKey should not be null"); + this.sourceKey = sourceKey; + } + + /** + * Set the sourceKey of the Request + * Returns this RenameObjectRequest, enabling additional method calls to be chained together. + * + * @param sourceKey the key of Baidu bos object + * @return This RenameObjectRequest, enabling additional method calls to be chained together. + */ + public RenameObjectRequest withSourceKey(String sourceKey) { + this.setSourceKey(sourceKey); + return this; + } + + @Override + public RenameObjectRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Sets the name of the bucket where this request will upload a new + * object to. Returns this object, enabling additional method calls to be + * chained together. + * + * @param bucketName The name of an existing bucket where this request will upload a new object to. + * @return This PutObjectRequest, enabling additional method calls to be chained together. + */ + @Override + public RenameObjectRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + /** + * Sets the key under which to store the new object. Returns this object, + * enabling additional method calls to be chained together. + * + * @param key The key under which to store the new object. + * @return This PutObjectRequest, enabling additional method calls to be chained together. + */ + @Override + public RenameObjectRequest withKey(String key) { + this.setKey(key); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/RenameObjectResponse.java b/src/main/java/com/baidubce/services/bos/model/RenameObjectResponse.java new file mode 100644 index 00000000..807dfc12 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/RenameObjectResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * Contains the data returned by Baidu Bos from the renameObject operation. + * default is empty + */ +public class RenameObjectResponse extends BosResponse { + +} + diff --git a/src/main/java/com/baidubce/services/bos/model/ReplicateHistory.java b/src/main/java/com/baidubce/services/bos/model/ReplicateHistory.java new file mode 100644 index 00000000..8a9b98eb --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/ReplicateHistory.java @@ -0,0 +1,40 @@ +/* + * Copyright 2014-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * The ReplicateHistory of bucket replication + */ +public class ReplicateHistory { + + /** + * The history object storageclass + */ + private String storageClass; + + /** + * Gets the history object storageclass + * @return + */ + public String getStorageClass() { + return storageClass; + } + + /** + * Sets the history object storageclass + * @param storageClass + */ + public void setStorageClass(String storageClass) { + this.storageClass = storageClass; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/Resource.java b/src/main/java/com/baidubce/services/bos/model/Resource.java new file mode 100644 index 00000000..f7454f60 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/Resource.java @@ -0,0 +1,75 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * resources of Bucket Acl. + * Resources Affected by ACL Configuration Items. + * Indicates to set access to the resources specified by resource. + */ +public class Resource { + + /** + * resources of Bucket Acl + */ + private List resource; + + /** + * Constructs a void constructor for Resource. + */ + public Resource() { + } + + /** + * Constructs a new Resource object for Resource. + * @param rule + */ + public Resource(List resource) { + this.resource = resource; + } + + /** + * Gets the resources of Bucket Acl. + * @return the resources of Bucket Acl. + */ + public List getResource() { + return resource; + } + + /** + * Sets the resources of Bucket Acl. + * @param resource The resources of Bucket Acl. + */ + public void setResource(List resource) { + this.resource = resource; + } + + /** + * Sets the resources of Bucket Acl. + * @param resource The resources of Bucket Acl. + * @return this Object. + */ + public Resource withResource(List resource) { + this.setResource(resource); + return this; + } + + @Override + public String toString() { + return "Resource{" + + "resource=" + resource.toString() + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java b/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java old mode 100644 new mode 100755 index a010a56c..e566c198 --- a/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java +++ b/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java @@ -21,7 +21,6 @@ * a GetObjectRequest or a GeneratePresignedUrlRequest in order * to control particular HTTP headers in the service response from those service * interfaces. - * *

* For example, a client could dynamically change the apparent * Content-Disposition header of a single object, so that it appears to have a @@ -72,7 +71,7 @@ public ResponseHeaderOverrides withRequestCredentials(BceCredentials credentials * specified, or null otherwise. * * @return Returns the content type response header override if it has been - * specified, or null otherwise. + * specified, or null otherwise. * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_TYPE */ public String getContentType() { @@ -82,6 +81,7 @@ public String getContentType() { /** * Sets the content type response header override. * + * @param contentType the content type response header * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_TYPE */ public void setContentType(String contentType) { @@ -91,6 +91,7 @@ public void setContentType(String contentType) { /** * Sets the content type response header override. * + * @param contentType the content type response header * @return This {@link ResponseHeaderOverrides} object for method chaining. * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_TYPE */ @@ -104,7 +105,7 @@ public ResponseHeaderOverrides withContentType(String contentType) { * specified, or null otherwise. * * @return Returns the content language response header override if it has - * been specified, or null otherwise. + * been specified, or null otherwise. * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_LANGUAGE */ public String getContentLanguage() { @@ -114,6 +115,7 @@ public String getContentLanguage() { /** * Sets the content language response header override * + * @param contentLanguage the content language response * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_LANGUAGE */ public void setContentLanguage(String contentLanguage) { @@ -123,6 +125,7 @@ public void setContentLanguage(String contentLanguage) { /** * Sets the content language response header override * + * @param contentLanguage the content language response * @return This {@link ResponseHeaderOverrides} object for method chaining. * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_LANGUAGE */ @@ -136,7 +139,7 @@ public ResponseHeaderOverrides withContentLanguage(String contentLanguage) { * null otherwise. * * @return Returns the expires response header override if it has been - * specified, or null otherwise. + * specified, or null otherwise. * @see ResponseHeaderOverrides#RESPONSE_HEADER_EXPIRES */ public String getExpires() { @@ -146,6 +149,7 @@ public String getExpires() { /** * Sets the expires response header override. * + * @param expires the expires response header * @see ResponseHeaderOverrides#RESPONSE_HEADER_EXPIRES */ public void setExpires(String expires) { @@ -155,6 +159,7 @@ public void setExpires(String expires) { /** * Sets the expires response header override. * + * @param expires the expires response header * @return This {@link ResponseHeaderOverrides} object for method chaining. * @see ResponseHeaderOverrides#RESPONSE_HEADER_EXPIRES */ @@ -168,7 +173,7 @@ public ResponseHeaderOverrides withExpires(String expires) { * specified, or null otherwise. * * @return Returns the cache control response header override if it has been - * specified, or null otherwise. + * specified, or null otherwise. * @see ResponseHeaderOverrides#RESPONSE_HEADER_CACHE_CONTROL */ public String getCacheControl() { @@ -178,6 +183,7 @@ public String getCacheControl() { /** * Sets the cache control response header. * + * @param cacheControl the cache control response header * @see ResponseHeaderOverrides#RESPONSE_HEADER_CACHE_CONTROL */ public void setCacheControl(String cacheControl) { @@ -187,6 +193,7 @@ public void setCacheControl(String cacheControl) { /** * Sets the cache control response header. * + * @param cacheControl the cache control response header * @return This {@link ResponseHeaderOverrides} object for method chaining. * @see ResponseHeaderOverrides#RESPONSE_HEADER_CACHE_CONTROL */ @@ -210,6 +217,7 @@ public String getContentDisposition() { /** * Sets the content disposition response header override. * + * @param contentDisposition the content disposition response header * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_DISPOSITION */ public void setContentDisposition(String contentDisposition) { @@ -219,6 +227,7 @@ public void setContentDisposition(String contentDisposition) { /** * Sets the content disposition response header override. * + * @param contentDisposition the content disposition response header * @return This {@link ResponseHeaderOverrides} object for method chaining. * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_DISPOSITION */ @@ -232,7 +241,7 @@ public ResponseHeaderOverrides withContentDisposition(String contentDisposition) * specified, or null otherwise. * * @return Returns the content encoding response header override if it has - * been specified, or null otherwise. + * been specified, or null otherwise. * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_ENCODING */ public String getContentEncoding() { @@ -242,6 +251,7 @@ public String getContentEncoding() { /** * Sets the content encoding response header override. * + * @param contentEncoding the content encoding response header * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_ENCODING */ public void setContentEncoding(String contentEncoding) { @@ -251,6 +261,7 @@ public void setContentEncoding(String contentEncoding) { /** * Sets the content encoding response header override. * + * @param contentEncoding the content encoding response header * @return This {@link ResponseHeaderOverrides} object for method chaining. * @see ResponseHeaderOverrides#RESPONSE_HEADER_CONTENT_ENCODING */ diff --git a/src/main/java/com/baidubce/services/bos/model/RestoreObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/RestoreObjectRequest.java new file mode 100644 index 00000000..d6fb6942 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/RestoreObjectRequest.java @@ -0,0 +1,151 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Restore object request for restoring archive object + */ +public class RestoreObjectRequest extends GenericObjectRequest { + + /** + * restore days kept after restoring archive object + */ + private Integer restoreDays; + /** + * restore tier used when restoring archive object + */ + private String restoreTier; + + /** + * Sets the bucket and key of RestoreObjectRequest + * + * @param bucketName The name of the bucket in which to restore object + * @param key The key by which to be restored + */ + public RestoreObjectRequest(String bucketName, String key) { + super(bucketName, key); + } + + public RestoreObjectRequest(String bucketName, String key, int restoreDays, String restoreTier) { + super(bucketName, key); + this.setRestoreDays(restoreDays); + this.setRestoreTier(restoreTier); + } + + /** + * Sets the key by which to restore, and hence, the + * eventual object restored from RestoreObjectRequest. + * + *

+ * Returns this updated RestoreObjectRequest so that + * additional method calls can be chained together. + * + * @param key The key by which to be restored + * @return This updated RestoreObjectRequest object. + */ + @Override + public RestoreObjectRequest withKey(String key) { + this.setKey(key); + return this; + } + + /** + * Sets the name of the bucket in which to restore object, + * and hence, the eventual object restored from RestoreObjectRequest. + * + *

+ * Returns this updated RestoreObjectRequest so that + * additional method calls can be chained together. + * + * @param bucketName The name of the bucket in which to restore object + * @return This updated RestoreObjectRequest object. + */ + @Override + public RestoreObjectRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + /** + * Sets the optional credentials to use for this request, overriding the default credentials set at the client + * level. + * + * @param credentials The optional BCE security credentials to use for this request, overriding the default + * credentials set at the client level. + */ + @Override + public RestoreObjectRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Gets the restore days for this request + * + * @return restoreDays Days kept after restoring object + */ + public Integer getRestoreDays() { + return restoreDays; + } + + /** + * Sets the restore days for this request + * + * @param restoreDays Days kept after restoring object + */ + public void setRestoreDays(Integer restoreDays) { + this.restoreDays = restoreDays; + } + + /** + * Sets the restore days for this request + * + * @param restoreDays Days kept after restoring object + * @return This RestoreObjectRequest, so that additional method calls to be chained together. + */ + public RestoreObjectRequest withRestoreDays(Integer restoreDays) { + this.setRestoreDays(restoreDays); + return this; + } + + /** + * Get the restore tier used in this request + * + * @return restoreTier The restore tier used in restoring object + */ + public String getRestoreTier() { + return restoreTier; + } + + /** + * Set the restore tier used in this request + * + * @param restoreTier The restore tier used in restoring object + */ + public void setRestoreTier(String restoreTier) { + this.restoreTier = restoreTier; + } + + /** + * Set the restore tier used in this request + * + * @param restoreTier The restore tier used in restoring object + * @return This RestoreObjectRequest, so that additional method calls to be chained together. + */ + public RestoreObjectRequest withRestoreTier(String restoreTier) { + this.setRestoreTier(restoreTier); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/Rule.java b/src/main/java/com/baidubce/services/bos/model/Rule.java new file mode 100644 index 00000000..a67be66e --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/Rule.java @@ -0,0 +1,198 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.List; + +/** + * The Rule for Bucket Lifecycle. + */ +public class Rule { + + /** + * The identifier of the rule. + * The bucket id must be unique within the same bucket and cannot be duplicated. + * If the user does not fill in the system will automatically generate one for the user. + */ + private String id; + + /** + * The status of the rule. + * The value is either enabled or disabled. + * When the rule is disabled, the rule does not take effect. + */ + private String status; + + /** + * The resource of the rule. + */ + private List resource; + + /** + * Rules depend on the conditions. + * Currently only the time format is supported. + */ + private Condition condition; + + /** + * The operation action performed on the resource. + * Include Required param name.(The name of the operation performed), + * The name value is Transition、DeleteObject、AbortMultipartUpload. + * Include Include param storageClass(Object storage type), + * When the action is Transition, it can be set to STANDARD_IA or COLD, + * which means it changes from the original storage type to low frequency storage or cold storage. + */ + private Action action; + + /** + * Gets the rule id of Bucket Lifecycle. + * @return the rule id of Bucket Lifecycle. + */ + public String getId() { + return id; + } + + /** + * Sets the rule id of Bucket Lifecycle. + * @param id The rule id of Bucket Lifecycle. + */ + public void setId(String id) { + this.id = id; + } + + /** + * Sets the rule id of Bucket Lifecycle. + * @param id The rule id of Bucket Lifecycle. + * @return this object. + */ + public Rule withId(String id) { + this.setId(id); + return this; + } + + /** + * Gets the status of Bucket Lifecycle. + * @return the status of Bucket Lifecycle. + */ + public String getStatus() { + return status; + } + + /** + * Sets the status of Bucket Lifecycle. + * @param status The status of Bucket Lifecycle. + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * Sets the status of Bucket Lifecycle. + * @param status The status of Bucket Lifecycle. + * @return this object. + */ + public Rule withStatus(String status) { + this.setStatus(status); + return this; + } + + /** + * Which resources the rules take effect. + * + */ + public List getResource() { + return resource; + } + + /** + * Sets the resource of Bucket Lifecycle. + * @param resource The resource of Bucket Lifecycle. + */ + public void setResource(List resource) { + this.resource = resource; + } + + /** + * Sets the resource of Bucket Lifecycle. + * @param resource The resources of Bucket Lifecycle. + * @return this object. + */ + public Rule withResource(List resource) { + this.setResource(resource); + return this; + } + + + /** + * Gets the condtion of Bucket Lifecycle. + * @return the condtion of Bucket Lifecycle. + */ + public Condition getCondition() { + return condition; + } + + /** + * Sets the condtion of Bucket Lifecycle. + * @param condition The condtion of Bucket Lifecycle. + */ + public void setCondition(Condition condition) { + this.condition = condition; + } + + /** + * Sets the condtion of Bucket Lifecycle. + * @param condition The condtion of Bucket Lifecycle. + * @return this object. + */ + public Rule withCondtion(Condition condition) { + this.setCondition(condition); + return this; + } + + /** + * Gets the action of Bucket Lifecycle. + * @return the action of Bucket Lifecycle. + */ + public Action getAction() { + return action; + } + + /** + * Sets the action of Bucket Lifecycle. + * @param action The action of Bucket Lifecycle. + */ + public void setAction(Action action) { + this.action = action; + } + + /** + * Sets the action of Bucket Lifecycle. + * @param action The action of Bucket Lifecycle. + * @return this object. + */ + public Rule withAction(Action action) { + this.setAction(action); + return this; + } + + @Override + public String toString() { + return "Rule{" + + "id='" + id + '\'' + + ", status='" + status + '\'' + + ", resource=" + resource + + ", condtion=" + condition + + ", action=" + action + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/SelectObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/SelectObjectRequest.java new file mode 100644 index 00000000..76d4bc66 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SelectObjectRequest.java @@ -0,0 +1,226 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.util.Base64Utils; +import com.baidubce.util.JsonUtils; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; + +import java.io.UnsupportedEncodingException; + +/** + * The request used to encapsulate the query object + */ +@JsonRootName("selectRequest") +@JsonPropertyOrder({"expression", "expressionType", "inputSerialization", "outputSerialization", "requestProgress"}) +public class SelectObjectRequest extends GenericObjectRequest { + @JsonIgnore + private String key; + + /** + * Type of target object,json or csv + */ + @JsonIgnore + private String selectType; + + /** + * SQL statement to be executed,will automatically convert to base64 code when set this + */ + private String expression; + + /** + * Syntax type of query statement, only "SQL" is supported + */ + private ExpressionType expressionType = ExpressionType.SQL; + + /** + * Input flow node, whose child node describes the object format information of query + */ + private InputSerialization inputSerialization; + + /** + * Output flow node, whose child node describes the format information returned by query results + */ + private OutputSerialization outputSerialization; + + /** + * Select progress information node, whose child nodes describe the execution progress of select operation, + * and return to the user regularly in 3S + */ + private RequestProgress requestProgress = new RequestProgress(); + + public SelectObjectRequest(String bucketName, String key) { + super(bucketName, key); + } + + @Override + public String getKey() { + return key; + } + + @Override + public void setKey(String key) { + this.key = key; + } + + public void setSelectType(String selectType) { + this.selectType = selectType.toLowerCase(); + } + + public String getSelectType() { + return selectType; + } + + public SelectObjectRequest withSelectType(String selectType) { + this.setSelectType(selectType); + return this; + } + + @Override + public SelectObjectRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public SelectObjectRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public enum ExpressionType { + SQL, + } + + @Override + public GenericObjectRequest withKey(String key) { + this.setKey(key); + return this; + } + + public void setExpression(String expression) { + this.expression = Base64Utils.encode(expression); + } + + public String getExpression() { + return this.expression; + } + + public SelectObjectRequest withExpression(String expression) { + this.setExpression(expression); + return this; + } + + public void setInputSerialization(InputSerialization inputSerialization) { + this.inputSerialization = inputSerialization; + } + + public InputSerialization getInputSerialization() { + return inputSerialization; + } + + public SelectObjectRequest withInputSerialization(InputSerialization inputSerialization) { + this.setInputSerialization(inputSerialization); + return this; + } + + public OutputSerialization getOutputSerialization() { + return outputSerialization; + } + + public void setOutputSerialization(OutputSerialization outputSerialization) { + this.outputSerialization = outputSerialization; + } + + public SelectObjectRequest withOutputSerialization(OutputSerialization outputSerialization) { + this.setOutputSerialization(outputSerialization); + return this; + } + + public void setRequestProgress(boolean enabled) { + this.requestProgress.setEnabled(enabled); + } + + public RequestProgress getRequestProgress() { + return this.requestProgress; + } + + public SelectObjectRequest withRequestProgress(boolean enabled) { + this.setRequestProgress(enabled); + return this; + } + + public void setExpressionType(ExpressionType expressionType) { + this.expressionType = expressionType; + } + + public ExpressionType getExpressionType() { + return this.expressionType; + } + + public SelectObjectRequest withExpressionType(ExpressionType expressionType) { + this.setExpressionType(expressionType); + return this; + } + + public String getOutputValue(String key) { + return outputSerialization.getValue(key); + } + + /** + * Build the request body according to the request parameters + * @return json body + */ + public byte[] buildBody() { + byte[] requestBody = null; + + if (this.selectType.equals(Constants.SELECT_TYPE_CSV)) { + inputSerialization.setCsvParams(inputSerialization.getParams()); + outputSerialization.setCsvParams(outputSerialization.getParams()); + } else if (this.selectType.equals(Constants.SELECT_TYPE_JSON)) { + inputSerialization.setJsonParams(inputSerialization.getParams()); + outputSerialization.setJsonParams(outputSerialization.getParams()); + } else if (this.selectType.equals(Constants.SELECT_TYPE_PARQUET)) { + inputSerialization.setParquetParams(inputSerialization.getParams()); + outputSerialization.setJsonParams(outputSerialization.getParams()); + } else { + throw new IllegalArgumentException("selectType should be one of csv/json/parquet"); + } + + String writer = JsonUtils.toJsonStringWithRootName(this); + try { + requestBody = writer.getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + + return requestBody; + } + + public class RequestProgress { + private boolean enabled = false; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/SelectObjectResponse.java b/src/main/java/com/baidubce/services/bos/model/SelectObjectResponse.java new file mode 100644 index 00000000..34fb2f10 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SelectObjectResponse.java @@ -0,0 +1,354 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.services.bos.BosObjectInputStream; +import com.baidubce.util.Base64Utils; + +import java.io.IOException; +import java.nio.ByteBuffer; + +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import java.util.Iterator; + +/** + * response of select object, including the parsed query result + */ +public class SelectObjectResponse extends GetObjectResponse { + /** + * user specified line break + */ + private String recordDelimiter; + + /** + * Message body of query result + */ + private Messages messages; + + public Messages getMessages() { + return messages; + } + + public void initMessages(BosObject object) { + if (this.messages != null) { + return; + } + this.messages = new Messages(object); + } + + public String getRecordDelimiter() { + return recordDelimiter; + } + + public void setRecordDelimiter(String delimiterBase64) { + this.recordDelimiter = delimiterBase64; + } + + public class Messages implements Iterator { + BosObject object; + BosObjectInputStream inputStream; + boolean isEnd = false; + private String messageType = ""; + + Messages(BosObject object) { + this.object = object; + inputStream = object.getObjectContent(); + } + + public boolean readFromStream(byte[] b) { + int readed = 0; + try { + int n = 0; + while (readed < b.length) { + n = inputStream.read(b, readed, b.length - readed); + if (n == -1) { + break; + } + readed += n; + } + } catch (IOException e) { + return false; + } + return readed == b.length; + } + + + @Override + public boolean hasNext() { + if ("End".equals(messageType) || "EndMessage lost".equals(messageType) || isEnd) { + try { + if (inputStream != null) { + inputStream.close(); + inputStream = null; + } + } catch (IOException e) { + throw new IllegalStateException("the EndMessage may have been lost.", e); + } + return false; + } + return true; + } + + @Override + public CommonMessage next() { + // parseMessage + try { + byte[] temp_4 = new byte[4]; + // totalLen + if (!readFromStream(temp_4)) { + isEnd = true; + throw new IllegalStateException("the Message may have been lost."); + } + int totalLen = ByteBuffer.wrap(temp_4).getInt(); + + // headersLen + if (!readFromStream(temp_4)) { + isEnd = true; + throw new IllegalStateException("the Message may have been lost."); + } + int headerLen = ByteBuffer.wrap(temp_4).getInt(); + + // headersVal + byte[] temp_headers = new byte[headerLen]; + if (!readFromStream(temp_headers)) { + isEnd = true; + throw new IllegalStateException("the Message may have been lost."); + } + Map headers = parseMessages(temp_headers); + if (headers.get(Constants.MESSAGE_TYPE).equals("Records")) { + this.messageType = "Records"; + + // payload part + int payloadLen = totalLen - headerLen - 12; + byte[] temp_payLoad = new byte[payloadLen]; + if (!readFromStream(temp_payLoad)) { + isEnd = true; + throw new IllegalStateException("the Message may have been lost."); + } + String payload = new String(temp_payLoad); + + // crc + if (!readFromStream(temp_4)) { + isEnd = true; + throw new IllegalStateException("the Message may have been lost."); + } + int crc = ByteBuffer.wrap(temp_4).getInt(); + Prelude prelude = new Prelude(totalLen, headerLen); + + // default \n + String delimiter = "\n"; + if (recordDelimiter != null) { + delimiter = Base64Utils.decode(recordDelimiter); + } + + return new RecordsMessage(prelude, headers, payload.split(delimiter), crc); + } + + if (headers.get(Constants.MESSAGE_TYPE).equals("Cont")) { + this.messageType = "Cont"; + byte[] temp_8 = new byte[8]; + + if (!readFromStream(temp_8)) { + isEnd = true; + throw new IllegalStateException("the Message may have been lost."); + } + int bytesScanned = ByteBuffer.wrap(temp_8).getInt(); + + if (!readFromStream(temp_8)) { + isEnd = true; + throw new IllegalStateException("the Message may have been lost."); + } + int bytesReturned = ByteBuffer.wrap(temp_8).getInt(); + + if (!readFromStream(temp_4)) { + isEnd = true; + throw new IllegalStateException("the Message may have been lost."); + } + int crc = ByteBuffer.wrap(temp_4).getInt(); + + Prelude prelude = new Prelude(totalLen, headerLen); + + return new ContinuationMessage(prelude, headers, bytesScanned, bytesReturned, crc); + } + + if (headers.get(Constants.MESSAGE_TYPE).equals("End")) { + this.messageType = "End"; + if (!readFromStream(temp_4)) { + isEnd = true; + throw new IllegalStateException("the Message may have been lost."); + } + + int crc = ByteBuffer.wrap(temp_4).getInt(); + Prelude prelude = new Prelude(totalLen, headerLen); + + inputStream.close(); + inputStream = null; + + return new EndMessage(prelude, headers, crc); + } + } catch (IOException e) { + throw new IllegalStateException("Failed to parse parameters.", e); + } + + this.messageType = "EndMessage lost"; + + return null; + } + + @Override + @Deprecated + public void remove() { + // This method is not supported + } + + } + + public class Prelude { + int TotalLen; + int HeadersLen; + + Prelude(int totalLen, int headersLen) { + this.TotalLen = totalLen; + this.HeadersLen = headersLen; + } + + @Override + public String toString() { + return "Prelude{" + + "TotalLen=" + TotalLen + + ", HeadersLen=" + HeadersLen + + '}'; + } + } + + public class CommonMessage { + public String Type; + public Prelude Prelude; + public Map Headers; + private int Crc32; + private String[] Records; + + CommonMessage(Prelude prelude, Map headers, int crc32) { + this.Prelude = prelude; + this.Headers = headers; + this.Crc32 = crc32; + } + + public int getCrc32() { + return Crc32; + } + + public void setCrc32(int crc32) { + Crc32 = crc32; + } + + public String[] getRecords() { + return Records; + } + + public void setRecords(String[] records) { + Records = records; + } + } + + public class RecordsMessage extends CommonMessage { + RecordsMessage(Prelude prelude, Map headers, String[] records, int crc32) { + super(prelude, headers, crc32); + super.setRecords(records); + super.Type = "Records"; + } + + @Override + public String toString() { + return "RecordsMessage{" + + "Prelude=" + Prelude.toString() + + ", Headers=" + Headers + + ", Records=" + Arrays.toString(super.getRecords()) + + ", Crc32=" + super.getCrc32() + + '}'; + } + } + + public class ContinuationMessage extends CommonMessage { + public int BytesScanned; + public int BytesReturned; + + ContinuationMessage(Prelude prelude, Map headers, + int bytesScanned, int bytesReturned, int crc32) { + super(prelude, headers, crc32); + super.Type = "Cont"; + this.BytesScanned = bytesScanned; + this.BytesReturned = bytesReturned; + } + + @Override + public String toString() { + return "ContinuationMessage{" + + "Prelude=" + Prelude.toString() + + ", Headers=" + Headers + + ", BytesScanned=" + BytesScanned + + ", BytesReturned=" + BytesReturned + + ", Crc32=" + super.getCrc32() + + '}'; + } + } + + public class EndMessage extends CommonMessage { + EndMessage(Prelude prelude, Map headers, int crc32) { + super(prelude, headers, crc32); + super.Type = "End"; + } + + @Override + public String toString() { + return "EndMessage{" + + "Prelude=" + Prelude.toString() + + ", Headers=" + Headers + + ", Crc32=" + super.getCrc32() + + '}'; + } + } + + private Map parseMessages(byte[] headers) { + Map map = new HashMap(); + int index = 0; + + while (index < headers.length) { + // headers key length + int keyLen = headers[index] & 0xff; + index += 1; + + // headers key + String headerKey = new String(Arrays.copyOfRange(headers, index, index + keyLen)); + index += keyLen; + + // headers value length + byte[] v = new byte[4]; + v[0] = 0; + v[1] = 0; + v[2] = headers[index]; + v[3] = headers[index + 1]; + int valLen = ByteBuffer.wrap(v).getInt(); + index += 2; + + // headers value + String headerVal = new String(Arrays.copyOfRange(headers, index, index + valLen)); + index += valLen; + map.put(headerKey, headerVal); + } + + return map; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/SetBucketAclRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketAclRequest.java old mode 100644 new mode 100755 index 957564f9..5a102f85 --- a/src/main/java/com/baidubce/services/bos/model/SetBucketAclRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/SetBucketAclRequest.java @@ -41,8 +41,8 @@ public class SetBucketAclRequest extends GenericBucketRequest { * canned ACL on the specified bucket when this request is executed. * * @param bucketName The name of the bucket whose ACL will be set by this request. - * @param cannedAcl The Canned Access Control List to apply to the specified - * bucket when this request is executed. + * @param cannedAcl The Canned Access Control List to apply to the specified + * bucket when this request is executed. */ public SetBucketAclRequest(String bucketName, CannedAccessControlList cannedAcl) { super(bucketName); @@ -54,8 +54,8 @@ public SetBucketAclRequest(String bucketName, CannedAccessControlList cannedAcl) * canned ACL on the specified bucket when this request is executed. * * @param bucketName The name of the bucket whose ACL will be set by this request. - * @param jsonAcl The json style of acl to apply to the specified - * bucket when this request is executed. + * @param jsonAcl The json style of acl to apply to the specified + * bucket when this request is executed. */ public SetBucketAclRequest(String bucketName, String jsonAcl) { super(bucketName); @@ -68,7 +68,7 @@ public SetBucketAclRequest(String bucketName, String jsonAcl) { * * @param bucketName The name of the bucket whose ACL will be set by this request. * @param accessControlList The custom Access Control List containing the access rules to - * apply to the specified bucket when this request is executed. + * apply to the specified bucket when this request is executed. */ public SetBucketAclRequest(String bucketName, List accessControlList) { super(bucketName); @@ -103,7 +103,7 @@ public CannedAccessControlList getCannedAcl() { * request is executed. * * @param cannedAcl The canned ACL to be applied to the specified bucket when this - * request is executed. + * request is executed. */ public void setCannedAcl(CannedAccessControlList cannedAcl) { this.cannedAcl = cannedAcl; @@ -114,7 +114,8 @@ public void setCannedAcl(CannedAccessControlList cannedAcl) { * request is executed. * * @param cannedAcl The canned ACL to be applied to the specified bucket when this - * request is executed. + * request is executed. + * @return this object */ public SetBucketAclRequest withCannedAcl(CannedAccessControlList cannedAcl) { this.setCannedAcl(cannedAcl); @@ -127,7 +128,7 @@ public SetBucketAclRequest withCannedAcl(CannedAccessControlList cannedAcl) { * ACL, but not both. * * @return The custom ACL to be applied to the specified bucket when this - * request is executed. + * request is executed. */ public List getAccessControlList() { return accessControlList; @@ -138,7 +139,7 @@ public List getAccessControlList() { * apply to the specified bucket when this request is executed. * * @param accessControlList The custom Access Control List containing the access rules to - * apply to the specified bucket when this request is executed. + * apply to the specified bucket when this request is executed. */ public void setAccessControlList(List accessControlList) { this.accessControlList = accessControlList; @@ -149,7 +150,8 @@ public void setAccessControlList(List accessControlList) { * apply to the specified bucket when this request is executed. * * @param accessControlList The custom Access Control List containing the access rules to - * apply to the specified bucket when this request is executed. + * apply to the specified bucket when this request is executed. + * @return this object */ public SetBucketAclRequest withAccessControlList(List accessControlList) { this.setAccessControlList(accessControlList); @@ -163,7 +165,7 @@ public SetBucketAclRequest withAccessControlList(List accessControlList) * ACL, but not both. * * @return The custom json style of ACL to be applied to the specified bucket when this - * request is executed. + * request is executed. */ public String getJsonAcl() { return this.jsonAcl; @@ -174,7 +176,7 @@ public String getJsonAcl() { * apply to the specified bucket when this request is executed. * * @param jsonAcl The custom json style of acl containing the access rules to - * apply to the specified bucket when this request is executed. + * apply to the specified bucket when this request is executed. */ public void setJsonAcl(String jsonAcl) { this.jsonAcl = jsonAcl; @@ -185,7 +187,8 @@ public void setJsonAcl(String jsonAcl) { * apply to the specified bucket when this request is executed. * * @param jsonAcl The custom json style of acl containing the access rules to - * apply to the specified bucket when this request is executed. + * apply to the specified bucket when this request is executed. + * @return this object */ public SetBucketAclRequest withJsonAcl(String jsonAcl) { this.setJsonAcl(jsonAcl); diff --git a/src/main/java/com/baidubce/services/bos/model/SetBucketCopyrightProtectionRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketCopyrightProtectionRequest.java new file mode 100644 index 00000000..2c5a5d6c --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetBucketCopyrightProtectionRequest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import java.util.List; +import com.baidubce.auth.BceCredentials; + +/** + * Request object containing all the options for setting a bucket's CopyrightProtection. + */ +public class SetBucketCopyrightProtectionRequest extends GenericBucketRequest { + + /** + * The resourceList of Bucket CopyrightProtection. + */ + private List resource; + + /** + * The json format for Bucket CopyrightProtection. + */ + private String jsonBucketCopyrightProtection; + + @Override + public SetBucketCopyrightProtectionRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + + @Override + public SetBucketCopyrightProtectionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + + /** + * Constructs a void Constructor for SetBucketCopyrightProtectionRequest. + */ + public SetBucketCopyrightProtectionRequest() { + + } + + public SetBucketCopyrightProtectionRequest(String bucketName) { + super(bucketName); + } + + /** + * Constructs a new SetBucketCopyrightProtectionRequest object, ready to set the specified Bucket Lifecycle. + * @param bucketName + * @param resource The resource of Bucket Lifecycle. + */ + public SetBucketCopyrightProtectionRequest(String bucketName, List resource) { + super(bucketName); + this.resource = resource; + } + + /** + * Constructs a SetBucketCopyrightProtectionRequest object, ready to set the specified Bucket CopyrightProtection. + * @param bucketName + * @param jsonBucketCopyrightProtection The jsonBucketCopyrightProtection of Bucket Lifecycle. + */ + public SetBucketCopyrightProtectionRequest(String bucketName, String jsonBucketCopyrightProtection) { + super(bucketName); + this.jsonBucketCopyrightProtection = jsonBucketCopyrightProtection; + } + + + public List getResource() { + return resource; + } + + public void setResource(List resource) { + this.resource = resource; + } + + public String getJsonBucketCopyrightProtection() { + return jsonBucketCopyrightProtection; + } + + public void setJsonBucketCopyrightProtection(String jsonBucketCopyrightProtection) { + this.jsonBucketCopyrightProtection = jsonBucketCopyrightProtection; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/SetBucketCorsRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketCorsRequest.java new file mode 100644 index 00000000..dc241c28 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetBucketCorsRequest.java @@ -0,0 +1,105 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +import java.util.List; + +/** + * Request object containing all the options for setting a bucket's CORS(Cross-Origin Resource Sharing). + */ +public class SetBucketCorsRequest extends GenericBucketRequest { + + + /** + * The json format for Bucket CORS. + */ + private String jsonBucketCors; + + /** + * The corsConfigurationsList of Bucket CORS. + */ + private List corsConfigurationsList; + + + /** + * Constructs a void Constructor for SetBucketCorsRequest. + */ + public SetBucketCorsRequest() { + } + + /** + * Constructs a new SetBucketCorsRequest object, ready to set the specified Bucket CORS. + * @param bucketName + * @param jsonBucketCors The jsonBucketCors of Bucket CORS. + */ + public SetBucketCorsRequest(String bucketName, String jsonBucketCors) { + super(bucketName); + this.jsonBucketCors = jsonBucketCors; + } + + /** + * Constructs a new SetBucketCorsRequest object, ready to set the specified Bucket CORS. + * @param bucketName + * @param corsConfigurationsList The corsConfigurationsList of Bucket CORS. + */ + public SetBucketCorsRequest(String bucketName, List corsConfigurationsList) { + super(bucketName); + this.corsConfigurationsList = corsConfigurationsList; + } + + @Override + public SetBucketCorsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public SetBucketCorsRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + /** + * Gets the jsonBucketCors for Bucket CORS. + * @return the jsonBucketCors for Bucket CORS. + */ + public String getJsonBucketCors() { + return jsonBucketCors; + } + + /** + * Sets the jsonBucketCors for Bucket CORS. + * @param jsonBucketCors The jsonBucketCors for Bucket CORS. + */ + public void setJsonBucketCors(String jsonBucketCors) { + this.jsonBucketCors = jsonBucketCors; + } + + /** + * Gets the corsConfigurationsList for Bucket CORS. + * @return the corsConfigurationsList of Bucket CORS. + */ + public List getCorsConfigurationsList() { + return corsConfigurationsList; + } + + /** + * Sets the corsConfigurationsList for Bucket CORS. + * @param corsConfigurationsList The corsConfigurationsList of Bucket CORS. + */ + public void setCorsConfigurationsList(List corsConfigurationsList) { + this.corsConfigurationsList = corsConfigurationsList; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/SetBucketEncryptionRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketEncryptionRequest.java new file mode 100644 index 00000000..649859b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetBucketEncryptionRequest.java @@ -0,0 +1,91 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Request object containing all the options for setting a bucket's Encryption. + */ +public class SetBucketEncryptionRequest extends GenericBucketRequest { + + /** + * The json format for bucketEncryption + */ + private String jsonBucketEncryption; + + /** + * The Bucket Encryption + */ + private BucketEncryption bucketEncryption; + + /** + * Constructs a void Constructor for SetBucketEncryptionRequest + */ + public SetBucketEncryptionRequest() { + + } + + public SetBucketEncryptionRequest(String bucketName) { + super(bucketName); + } + + public SetBucketEncryptionRequest(String bucketName, BucketEncryption bucketEncryption) { + super(bucketName); + this.bucketEncryption = bucketEncryption; + } + + public SetBucketEncryptionRequest(String bucketName, String jsonBucketEncryption) { + super(bucketName); + this.jsonBucketEncryption = jsonBucketEncryption; + } + + + public String getJsonBucketEncryption() { + return jsonBucketEncryption; + } + + public void setJsonBucketEncryption(String jsonBucketEncryption) { + this.jsonBucketEncryption = jsonBucketEncryption; + } + + public SetBucketEncryptionRequest withJsonBucketEncryption(String jsonBucketEncryption) { + this.setJsonBucketEncryption(jsonBucketEncryption); + return this; + } + + public BucketEncryption getBucketEncryption() { + return bucketEncryption; + } + + public void setBucketEncryption(BucketEncryption bucketEncryption) { + this.bucketEncryption = bucketEncryption; + } + + public SetBucketEncryptionRequest withBucketEncryption(BucketEncryption bucketEncryption) { + setBucketEncryption(bucketEncryption); + return this; + } + + @Override + public SetBucketEncryptionRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public SetBucketEncryptionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/SetBucketLifecycleRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketLifecycleRequest.java new file mode 100644 index 00000000..40ac390b --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetBucketLifecycleRequest.java @@ -0,0 +1,104 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +import java.util.List; + +/** + * Request object containing all the options for setting a bucket's Lifecycle. + */ +public class SetBucketLifecycleRequest extends GenericBucketRequest { + + /** + * The json format for Bucket Lifecycle. + */ + private String jsonBucketLifecycle; + + /** + * The ruleList of Bucket Lifecycle. + */ + private List ruleList; + + /** + * Constructs a void Constructor for SetBucketLifecycleRequest. + */ + public SetBucketLifecycleRequest() { + + } + + /** + * Constructs a new SetBucketLifecycleRequest object, ready to set the specified Bucket Lifecycle. + * @param bucketName + * @param jsonBucketLifecycle The jsonBucketLifecycle of Bucket Lifecycle. + */ + public SetBucketLifecycleRequest(String bucketName, String jsonBucketLifecycle) { + super(bucketName); + this.jsonBucketLifecycle = jsonBucketLifecycle; + } + + /** + * Constructs a new SetBucketLifecycleRequest object, ready to set the specified Bucket Lifecycle. + * @param bucketName + * @param ruleList The ruleList of Bucket Lifecycle. + */ + public SetBucketLifecycleRequest(String bucketName, List ruleList) { + super(bucketName); + this.ruleList = ruleList; + } + + @Override + public SetBucketLifecycleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public SetBucketLifecycleRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + /** + * Gets the jsonBucketLifecycle of Bucket Lifecycle. + * @return the jsonBucketLifecycle of Bucket Lifecycle. + */ + public String getJsonBucketLifecycle() { + return jsonBucketLifecycle; + } + + /** + * Sets the jsonBucketLifecycle of Bucket Lifecycle. + * @param jsonBucketLifecycle The jsonBucketLifecycle of Bucket Lifecycle. + */ + public void setJsonBucketLifecycle(String jsonBucketLifecycle) { + this.jsonBucketLifecycle = jsonBucketLifecycle; + } + + /** + * Gets the ruleList of Bucket Lifecycle. + * @return the ruleList of Bucket Lifecycle. + */ + public List getRuleList() { + return ruleList; + } + + /** + * Sets the ruleList of Bucket Lifecycle. + * @param ruleList The ruleList of Bucket Lifecycle. + */ + public void setRuleList(List ruleList) { + this.ruleList = ruleList; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/SetBucketLoggingRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketLoggingRequest.java new file mode 100644 index 00000000..b21e3f22 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetBucketLoggingRequest.java @@ -0,0 +1,122 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Request object containing all the options for setting a bucket's Logging. + */ +public class SetBucketLoggingRequest extends GenericBucketRequest { + + /** + * The targetBucket for Bucket Logging. + */ + private String targetBucket; + + /** + * The targetPrefix for Bucket Logging. + */ + private String targetPrefix; + + /** + * The json format Logging for Bucket Logging. + */ + private String jsonPutBucketLogging; + + public SetBucketLoggingRequest() { + + } + + /** + * Constructs a new SetBucketLoggingRequest object, ready to set the specified Bucket Logging. + * @param bucketName + * @param targetBucket The targetBucket of Bucket Logging. + * @param targetPrefix The targetPrefix of Bucket Logging. + */ + public SetBucketLoggingRequest(String bucketName, String targetBucket, String targetPrefix) { + super(bucketName); + this.targetBucket = targetBucket; + this.targetPrefix = targetPrefix; + } + + /** + * Constructs a new SetBucketLoggingRequest object, ready to set the specified Bucket Logging. + * @param bucketName + * @param jsonPutBucketLogging The jsonPutBucketLogging of Bucket Logging. + */ + public SetBucketLoggingRequest(String bucketName, String jsonPutBucketLogging) { + super(bucketName); + this.jsonPutBucketLogging = jsonPutBucketLogging; + } + + @Override + public SetBucketLoggingRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public SetBucketLoggingRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + /** + * Gets the targetBucket of Bucket Logging. + * @return the targetBucket of Bucket Logging. + */ + public String getTargetBucket() { + return targetBucket; + } + + /** + * Sets the targetBucket of Bucket Logging. + * @param targetBucket The targetBucket of Bucket Logging. + */ + public void setTargetBucket(String targetBucket) { + this.targetBucket = targetBucket; + } + + /** + * Gets the targetPrefix of Bucket Logging. + * @return the targetPrefix of Bucket Logging. + */ + public String getTargetPrefix() { + return targetPrefix; + } + + /** + * Sets the targetPrefix of Bucket Logging. + * @param targetPrefix The targetBucket of Bucket Logging. + */ + public void setTargetPrefix(String targetPrefix) { + this.targetPrefix = targetPrefix; + } + + /** + * Gets the jsonPutBucketLogging of Bucket Logging. + * @return the jsonPutBucketLogging of Bucket Logging. + */ + public String getJsonPutBucketLogging() { + return jsonPutBucketLogging; + } + + /** + * Sets the jsonPutBucketLogging of Bucket Logging. + * @param jsonPutBucketLogging The targetBucket of Bucket Logging. + */ + public void setJsonPutBucketLogging(String jsonPutBucketLogging) { + this.jsonPutBucketLogging = jsonPutBucketLogging; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/SetBucketReplicationRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketReplicationRequest.java new file mode 100644 index 00000000..be4da44a --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetBucketReplicationRequest.java @@ -0,0 +1,266 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Request object containing all the options for setting a bucket's replication. + */ +public class SetBucketReplicationRequest extends GenericBucketRequest { + + /** + * The json format for Bucket Replication. + */ + private String jsonBucketReplication; + + /** + * The status of replication + */ + private String status; + + /** + * The replication prefix, it must start with bucketName + */ + private String[] resource; + + /** + * The config of dest replication + */ + private Destination destination; + + /** + * The history replication + */ + private ReplicateHistory replicateHistory; + + /** + * Whether enable sync delete + */ + private String replicateDeletes; + + /** + * The replication rule name + */ + private String id; + + /** + * Constructs a void Constructor for SetBucketReplicationRequest. + */ + public SetBucketReplicationRequest() { + } + + /** + * Constructs a new SetBucketReplicationRequest to get a specified Bucket Lifecycle. + * @param bucketName + */ + public SetBucketReplicationRequest(String bucketName) { + super(bucketName); + } + + /** + * Gets the status of replication + * @return + */ + public String getStatus() { + return status; + } + + /** + * Sets the status of replication + * @param status + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * Sets the status bucket replication + * and returns this object, enabling additional method calls + * to be chained together. + * + * @param status The status bucket replication. + * @return This SetBucketReplicationRequest, enabling additional method calls to be chained together. + */ + public SetBucketReplicationRequest withStatus(String status) { + this.setStatus(status); + return this; + } + /** + * Gets the replication prefix + * @return + */ + public String[] getResource() { + return resource; + } + + /** + * Sets the replication prefix + * @param resource + */ + public void setResource(String[] resource) { + this.resource = resource; + } + + /** + * Gets json formot bucket replication + * @return + */ + public String getJsonBucketReplication() { + return jsonBucketReplication; + } + + /** + * Sets json formot bucket replication + * @param jsonBucketReplication + */ + public void setJsonBucketReplication(String jsonBucketReplication) { + this.jsonBucketReplication = jsonBucketReplication; + } + + /** + * Sets json formot bucket replication + * @param jsonBucketReplication json formot bucket replication + * @return This SetBucketReplicationRequest, enabling additional method calls to be chained together. + */ + public SetBucketReplicationRequest withJsonBucketReplication(String jsonBucketReplication) { + this.setJsonBucketReplication(jsonBucketReplication); + return this; + } + + /** + * Sets the replication prefix + * @param resource the replication prefix + * @return This SetBucketReplicationRequest, enabling additional method calls to be chained together. + */ + public SetBucketReplicationRequest withResource(String[] resource) { + this.setResource(resource); + return this; + } + /** + * Gets the config of dest replication + * @return + */ + public Destination getDestination() { + return destination; + } + + /** + * Sets the config of dest replication + * @param destination + */ + public void setDestination(Destination destination) { + this.destination = destination; + } + + /** + * Sets the config of dest replication + * @param destination the config of dest replication + * @return This SetBucketReplicationRequest, enabling additional method calls to be chained together. + */ + public SetBucketReplicationRequest withDestination(Destination destination) { + this.setDestination(destination); + return this; + } + /** + * Gets the history replication + * @return + */ + public ReplicateHistory getReplicateHistory() { + return replicateHistory; + } + + /** + * Sets the history replication + * @param replicateHistory + */ + public void setReplicateHistory( + ReplicateHistory replicateHistory) { + this.replicateHistory = replicateHistory; + } + + /** + * Sets the history replication + * @param replicateHistory the history replication + * @return This SetBucketReplicationRequest, enabling additional method calls to be chained together. + */ + public SetBucketReplicationRequest withReplicationHistory(ReplicateHistory replicateHistory) { + this.setReplicateHistory(replicateHistory); + return this; + } + + /** + * Gets the status of sync delete + * @return + */ + public String getReplicateDeletes() { + return replicateDeletes; + } + + /** + * Sets the status of sync delete + * @param replicateDeletes + */ + public void setReplicateDeletes(String replicateDeletes) { + this.replicateDeletes = replicateDeletes; + } + + /** + * Sets the status of sync delete + * @param replicateDeletes the status of sync delete + * @return This SetBucketReplicationRequest, enabling additional method calls to be chained together. + */ + public SetBucketReplicationRequest withReplicationDeletes(String replicateDeletes) { + this.setReplicateDeletes(replicateDeletes); + return this; + } + /** + * Gets the replication rule name + * @return + */ + public String getId() { + return id; + } + + /** + * Sets the replication rule name + * @param id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Sets the id of Bucket Replication. + * @param id The id of Bucket Replication. + * @return this object. + */ + public SetBucketReplicationRequest withId(String id) { + this.setId(id); + return this; + } + + @Override + public SetBucketReplicationRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public SetBucketReplicationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/bos/model/SetBucketStaticWebsiteRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketStaticWebsiteRequest.java new file mode 100644 index 00000000..ac36fee3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetBucketStaticWebsiteRequest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2014-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + + +/** + * Request object containing all the options for setting a bucket's staticwebsite. + */ +public class SetBucketStaticWebsiteRequest extends GenericBucketRequest { + + /** + * The index page for staticwebsite + */ + private String index; + + /** + * The notFound page for staticwebsite + */ + private String notFound; + + /** + * The json format bucket staticwebsite for bucket + */ + private String jsonBucketStaticWebsite; + + public SetBucketStaticWebsiteRequest() { + + } + + /** + * Constructs a new SetBucketStaticWebsiteRequest object, ready to set the specified Bucket StaticWebsite config. + * @param bucketName + * @param index The index page for staticwebsite. + * @param notFound The notFound page for staticwebsite. + */ + public SetBucketStaticWebsiteRequest(String bucketName, String index, String notFound) { + super(bucketName); + this.index = index; + this.notFound = notFound; + } + + public SetBucketStaticWebsiteRequest(String bucketName, String jsonBucketStaticWebsite) { + this.setBucketName(bucketName); + this.jsonBucketStaticWebsite = jsonBucketStaticWebsite; + } + + @Override + public SetBucketStaticWebsiteRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public SetBucketStaticWebsiteRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + public String getNotFound() { + return notFound; + } + + public void setNotFound(String notFound) { + this.notFound = notFound; + } + + public String getJsonBucketStaticWebsite() { + return jsonBucketStaticWebsite; + } + + public void setJsonBucketStaticWebsite(String jsonBucketStaticWebsite) { + this.jsonBucketStaticWebsite = jsonBucketStaticWebsite; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/SetObjectAclRequest.java b/src/main/java/com/baidubce/services/bos/model/SetObjectAclRequest.java new file mode 100644 index 00000000..7e49f85d --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetObjectAclRequest.java @@ -0,0 +1,205 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +import java.util.List; + +/** + * Request object containing all the options for setting a Object's Access Control List (ACL). + */ +public class SetObjectAclRequest extends GenericObjectRequest { + + /** + * For versioning + */ + private String versionId; + + /** + * The json format for Object Acl. + */ + private String jsonObjectAcl; + + /** + * The accessControlList of this specified Object. + */ + private List accessControlList; + + /** + * The canned ACL to apply to the specified Object. + */ + private CannedAccessControlList cannedAcl; + + /** + * The xBceGrantRead apply to the specified Object. + */ + private String xBceGrantRead; + + /** + * The xBceGrantFullControl apply to the specified Object. + */ + private String xBceGrantFullControl; + + /** + * Constructs a void Constructor for SetObjectAclRequest. + */ + public SetObjectAclRequest() { + + } + + /** + * Constructs a new SetObjectAclRequest object, ready to set the specified + * jsonObjectAcl on the specified bucket/object when this request is executed. + * @param bucketName The name of the bucket whose Object will be set Acl by this request. + * @param key The name of the Object whose ACL will be set by this request. + * @param jsonObjectAcl The json style of acl to apply to the specified object when this request is executed. + */ + public SetObjectAclRequest(String bucketName, String key, String jsonObjectAcl) { + super(bucketName, key); + this.jsonObjectAcl = jsonObjectAcl; + } + + /** + * Constructs a new SetObjectAclRequest object, ready to set the specified + * ACL on the specified bucket/object when this request is executed. + * @param bucketName The name of the bucket whose Object acl will be set by this request. + * @param key The name of the Object whose ACL will be set by this request. + * @param accessControlList The custom Access Control List containing the access rules to, + * apply to the specified bucket/object when this request is executed. + */ + public SetObjectAclRequest(String bucketName, String key, List accessControlList) { + super(bucketName, key); + this.accessControlList = accessControlList; + } + + /** + * Constructs a new SetObjectAclRequest object, ready to set the specified, + * canned ACL on the specified bucket/object when this request is executed. + * @param bucketName The name of the bucket whose Object acl will be set by this request. + * @param key The name of the Object whose ACL will be set by this request. + * @param cannedAcl The Canned Access Control List to apply to the specified, + * bucket/object when this request is executed. + */ + public SetObjectAclRequest(String bucketName, String key, CannedAccessControlList cannedAcl) { + super(bucketName, key); + this.cannedAcl = cannedAcl; + } + + @Override + public SetObjectAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public SetObjectAclRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public SetObjectAclRequest withKey(String key) { + this.setKey(key); + return this; + } + + /** + * Gets the json format of Object Acl. + * @return the json format of Object Acl. + */ + public String getJsonObjectAcl() { + return jsonObjectAcl; + } + + /** + * Sets the json format of Object Acl. + * @param jsonObjectAcl The json format of Object Acl. + */ + public void setJsonObjectAcl(String jsonObjectAcl) { + this.jsonObjectAcl = jsonObjectAcl; + } + + /** + * Gets the accessControlList of Object Acl. + * @return the accessControlList of Object Acl. + */ + public List getAccessControlList() { + return accessControlList; + } + + /** + * Sets the accessControlList of Object Acl. + * @param accessControlList The accessControlList of Object Acl. + */ + public void setAccessControlList(List accessControlList) { + this.accessControlList = accessControlList; + } + + /** + * Gets the cannedAcl of Object Acl. + * @return the cannedAcl of Object Acl. + */ + public CannedAccessControlList getCannedAcl() { + return cannedAcl; + } + + /** + * Sets the cannedAcl of Object Acl. + * @param cannedAcl The cannedAcl of Object Acl. + */ + public void setCannedAcl(CannedAccessControlList cannedAcl) { + this.cannedAcl = cannedAcl; + } + + /** + * Gets the xBceGrantRead of Object Acl. + * @return the xBceGrantRead of Object Acl. + */ + public String getxBceGrantRead() { + return xBceGrantRead; + } + + /** + * Sets the xBceGrantRead of Object Acl. + * @param xBceGrantRead The xBceGrantRead of Object Acl. + */ + public void setxBceGrantRead(String xBceGrantRead) { + this.xBceGrantRead = xBceGrantRead; + } + + /** + * Gets the xBceGrantFullControl of Object Acl. + * @return the xBceGrantFullControl of Object Acl. + */ + public String getxBceGrantFullControl() { + return xBceGrantFullControl; + } + + /** + * Sets the xBceGrantFullControl of Object Acl. + * @param xBceGrantFullControl The xBceGrantRead of Object Acl. + */ + public void setxBceGrantFullControl(String xBceGrantFullControl) { + this.xBceGrantFullControl = xBceGrantFullControl; + } + + public String getVersionId() { + return versionId; + } + + public void setVersionId(String versionId) { + this.versionId = versionId; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/SetObjectSymlinkRequest.java b/src/main/java/com/baidubce/services/bos/model/SetObjectSymlinkRequest.java new file mode 100644 index 00000000..85055fff --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetObjectSymlinkRequest.java @@ -0,0 +1,173 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Map; +import com.baidubce.auth.BceCredentials; +import com.google.common.collect.Maps; + +/** + * Request object containing all the options for setting a object symlink. + */ +public class SetObjectSymlinkRequest extends GetObjectRequest { + + /** + * The symlink of target object. + */ + private String symlinkTarget; + + /** + * Whether to overwrite the object with the same name when creating a soft link + */ + private boolean forbidOverwrite; + + /** + * The storageClass of symlink + */ + private String storageClass; + + /** + * Custom user metadata, represented in responses with the x-bce-meta- header prefix + */ + private Map userMetadata = Maps.newHashMap(); + + public SetObjectSymlinkRequest(String bucketName, String key, String symlinkTarget) { + super(bucketName, key); + this.setSymlinkTarget(symlinkTarget); + } + + /** + * Gets the symlink of target object + * @return + */ + public String getSymlinkTarget() { + return this.symlinkTarget; + } + + /** + * Sets the symlink of target object + * @param symlinkTarget + */ + public void setSymlinkTarget(String symlinkTarget) { + checkNotNull(symlinkTarget, "symlinkTarget should not be null"); + this.symlinkTarget = symlinkTarget; + } + + /** + * Sets the symlink of target object, + * and returns this object, enabling additional method calls to be chained together. + */ + public SetObjectSymlinkRequest withSymlinkTarget(String symlinkTarget) { + this.setSymlinkTarget(symlinkTarget); + return this; + } + + /** + * Gets the flag of forbid overwrite + * @return + */ + public boolean isForbidOverwrite() { + return this.forbidOverwrite; + } + + /** + * Set the flag of forbid overwrite + * @param forbidOverwrite + */ + public void setForbidOverwrite(boolean forbidOverwrite) { + checkNotNull(forbidOverwrite, "forbidOverwrite should not be null"); + this.forbidOverwrite = forbidOverwrite; + } + + /** + * Sets the flag of forbid overwrite + * and returns this object, enabling additional method calls to be chained together. + */ + public SetObjectSymlinkRequest withForbidOverwrite(boolean forbidOverwrite) { + this.setForbidOverwrite(forbidOverwrite); + return this; + } + + /** + * Sets the symlink storageClass + * @param storageClass + */ + public void setStorageClass(String storageClass) { + this.storageClass = storageClass; + } + + /** + * Gets the symlink storageClass + * @return + */ + public String getStorageClass() { + return this.storageClass; + } + + /** + * Sets the symlink storageClass + * and returns this object, enabling additional method calls to be chained together. + * @param storageClass + * @return + */ + public SetObjectSymlinkRequest withStorageClass(String storageClass) { + this.setStorageClass(storageClass); + return this; + } + + /** + * Gets the user-meta of symlink + * @return + */ + public Map getUserMetadata() { + return userMetadata; + } + + /** + * Sets the user-meta of symlink + * @param userMetadata + */ + public void setUserMetadata(Map userMetadata) { + this.userMetadata = userMetadata; + } + + /** + * Sets user-meta of symlink + * and returns this object, enabling additional method calls to be chained together. + * @param userMetadata + * @return + */ + public SetObjectSymlinkRequest withUserMetadata(Map userMetadata) { + this.setUserMetadata(userMetadata); + return this; + } + + @Override + public SetObjectSymlinkRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public SetObjectSymlinkRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public SetObjectSymlinkRequest withKey(String key) { + this.setKey(key); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/SetObjectSymlinkResponse.java b/src/main/java/com/baidubce/services/bos/model/SetObjectSymlinkResponse.java new file mode 100644 index 00000000..27de88f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/SetObjectSymlinkResponse.java @@ -0,0 +1,43 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * response of set object symlink + */ +public class SetObjectSymlinkResponse { + + /** + * The ETag value of the symlink object + */ + private String eTag; + + /** + * Gets the ETag value for the newly created symlink object. + * + * @return The ETag value for the symlink object. + */ + public String getETag() { + return this.eTag; + } + + /** + * Sets the ETag value for the symlink object that was created from the + * associated SetObjectSymlink request. + * + * @param eTag The ETag value for the new object. + */ + public void setETag(String eTag) { + this.eTag = eTag; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/StateSummaryRequest.java b/src/main/java/com/baidubce/services/bos/model/StateSummaryRequest.java new file mode 100644 index 00000000..9f1da345 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/StateSummaryRequest.java @@ -0,0 +1,54 @@ +package com.baidubce.services.bos.model; + +import com.baidubce.auth.BceCredentials; + +/** + * The request used to stat size, objects, files begin with the prefix + */ +public class StateSummaryRequest extends GenericBucketRequest { + + /** + * Optional parameter restricting the response to keys which begin with the specified prefix. + * default: null, stat the whole bucket + * "pre" , stat the objects begin with "pre" + */ + private String prefix; + + public StateSummaryRequest(String bucketName, String prefix) { + super(bucketName); + this.setPrefix(prefix); + } + + public StateSummaryRequest(String bucketName) { + this(bucketName, null); + } + + public StateSummaryRequest() { + + } + + public String getPrefix() { + return this.prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public StateSummaryRequest withPrefix(String prefix) { + this.setPrefix(prefix); + return this; + } + + @Override + public StateSummaryRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + @Override + public StateSummaryRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/StateSummaryResponse.java b/src/main/java/com/baidubce/services/bos/model/StateSummaryResponse.java new file mode 100644 index 00000000..266e5c44 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/StateSummaryResponse.java @@ -0,0 +1,86 @@ +package com.baidubce.services.bos.model; + +/** + * Contains options to return a summary information about the contents begin with the prefix. + */ +public class StateSummaryResponse extends BosResponse { + + /** + * The name of the bucket containing the listed parts, as specified in the + * original request. + */ + private String bucketName; + + /** + * Optional parameter restricting the response to keys which begin with the specified prefix. + * equals to StatContentsRequest's + */ + private String prefix; + + /** + * The size of all objects begin with the prefix. + */ + private long totalSize; + + /** + * The number of all objects (including file and directory) begin with the prefix. + */ + private long objectsCount; + + /** + * The number of files begin with the prefix. + */ + private long filesCount; + + public StateSummaryResponse() { + + } + + public StateSummaryResponse(String bucketName, String prefix, long totalSize, long objectsCount, long filesCount) { + this.bucketName = bucketName; + this.prefix = prefix; + this.totalSize = totalSize; + this.objectsCount = objectsCount; + this.filesCount = filesCount; + } + + public String getBucketName() { + return bucketName; + } + + public void setBucketName(String bucketName) { + this.bucketName = bucketName; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public long getFilesCount() { + return filesCount; + } + + public void setFilesCount(int filesCount) { + this.filesCount = filesCount; + } + + public long getTotalSize() { + return totalSize; + } + + public void setTotalSize(long totalSize) { + this.totalSize = totalSize; + } + + public long getObjectsCount() { + return objectsCount; + } + + public void setObjectsCount(long objectsCount) { + this.objectsCount = objectsCount; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/Time.java b/src/main/java/com/baidubce/services/bos/model/Time.java new file mode 100644 index 00000000..50c949c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/Time.java @@ -0,0 +1,59 @@ +package com.baidubce.services.bos.model; + +/** + * the conditonTime of Bucket Lifecycle. + */ +public class Time { + + /** + * dateGreaterThan of the conditonTime of Bucket Lifecycle. + */ + private String dateGreaterThan; + + /** + * Gets dateGreaterThan of the conditonTime of Bucket Lifecycle. + * @return dateGreaterThan of the conditonTime of Bucket Lifecycle. + */ + public String getDateGreaterThan() { + return dateGreaterThan; + } + + /** + * Sets dateGreaterThan of the conditonTime of Bucket Lifecycle. + * @param dateGreaterThan The dateGreaterThan of the conditonTime of Bucket Lifecycle. + */ + public void setDateGreaterThan(String dateGreaterThan) { + this.dateGreaterThan = dateGreaterThan; + } + + /** + * sets the dateGreaterThan of the conditonTime of Bucket Lifecycle. + * @param dateGreaterThan The dateGreaterThan of the conditonTime of Bucket Lifecycle. + * @return this object + */ + public Time withDateGreaterThan(String dateGreaterThan) { + this.setDateGreaterThan(dateGreaterThan); + return this; + } + + /** + * Constructs a void Constructor for Time of Bucket Lifecycle. + */ + public Time() { + } + + /** + * Constructs a new Time object for Time of Bucket Lifecycle. + * @param dateGreaterThan + */ + public Time(String dateGreaterThan) { + this.dateGreaterThan = dateGreaterThan; + } + + @Override + public String toString() { + return "Time{" + + "dateGreaterThan='" + dateGreaterThan + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/UploadPartCopyRequest.java b/src/main/java/com/baidubce/services/bos/model/UploadPartCopyRequest.java new file mode 100644 index 00000000..da826231 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/UploadPartCopyRequest.java @@ -0,0 +1,294 @@ +package com.baidubce.services.bos.model; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.baidubce.auth.BceCredentials; + +/** + * Contains the parameters used for the UploadPartCopy operation on Baidu Bos. + * + *

+ * Required Parameters: BucketName, Key, sourceBucketName, sourcetkey, UploadId, + * PartNumber, partSize, offSet + */ +public class UploadPartCopyRequest extends GenericUploadRequest { + + /** + * The part number describing this part's position relative to the other + * parts in the multipart upload. Part number must be between 1 and 10,000 + * (inclusive). + */ + private int partNumber; + + /** + * The size of this part, in bytes. + */ + private long partSize; + + /** + * The offset describing skipBytes for this object in bytes. + */ + private long offSet; + + /** + * The sourceBucketName describing the source bucket for uploadCopyPart operation. + */ + private String sourceBucketName; + + /** + * The sourcetkey describing the source object for uploadCopyPart operation. + */ + private String sourcetkey; + + private String xBceCrc; + + public String getxBceCrc() { + return xBceCrc; + } + + public void setxBceCrc(String xBceCrc) { + this.xBceCrc = xBceCrc; + } + + /** + * The xBceCrc32c of the newly uploadCopyPart + */ + private String xBceCrc32c; + + /** + * The xBceCrc32cFlag, whether to calculate crc32c + */ + private boolean xBceCrc32cFlag = false; + + public UploadPartCopyRequest() { + super(); + } + + /** + * Constructs a new UploadPartCopyRequest object to copy a stream of data to the + * specified bucket and key, + * + * @param bucketName The name of the bucket containing the initiated multipart upload with + * which this new part will be associated. + * @param key The key of the initiated multipart upload. + * @param sourcetBucketName The sourceBucketName describing the source bucket for uploadCopyPart operation. + * @param sourcetkey The sourcetkey describing the source object for uploadCopyPart operation. + * @param uploadId The ID of an existing, initiated multipart upload, with which this new + * part will be associated. + * @param partNumber The part number describing this part's position relative to the other + * parts in the multipart upload. Part number must be between 1 and 10,000 (inclusive). + * @param partSize The size of this part, in bytes. + * @param offSet The offset describing skipBytes for this object in bytes. + */ + public UploadPartCopyRequest(String bucketName, String key, String sourcetBucketName, String sourcetkey, + String uploadId, int partNumber, long partSize, long offSet) { + super(bucketName, key, uploadId); + this.setSourceBucketName(sourcetBucketName); + this.setSourceKey(sourcetkey); + this.setPartNumber(partNumber); + this.setPartSize(partSize); + this.setOffSet(offSet); + } + + @Override + public UploadPartCopyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Sets the name of the bucket containing the existing, initiated multipart + * upload, with which this new part will be associated, and returns this + * updated object so that additional method calls can be chained together. + * + * @param bucketName the name of the bucket containing the existing, initiated + * multipart upload, with which this new part will be associated. + * @return This updated UploadPartCopyRequest object. + */ + @Override + public UploadPartCopyRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + /** + * Sets the key of the initiated multipart upload, and returns this updated + * object so that additional method calls can be chained together. + * + * @param key the key of the initiated multipart upload. + * @return This updated UploadPartCopyRequest object. + */ + @Override + public UploadPartCopyRequest withKey(String key) { + this.setKey(key); + return this; + } + + /** + * Sets the ID of the existing, initiated multipart upload with which this + * new part will be associated, and returns this updated UploadPartRequest + * object so that additional method calls can be chained together. + * + * @param uploadId the ID of the existing, initiated multipart upload with which + * this new part will be associated. + * @return This updated UploadPartCopyRequest object. + */ + @Override + public UploadPartCopyRequest withUploadId(String uploadId) { + this.setUploadId(uploadId); + return this; + } + + /** + * Returns the part number describing this part's position relative to the + * other parts in the multipart upload. Part number must be between 1 and + * 10,000 (inclusive). + * + * @return the part number describing this part's position relative to the + * other parts in the multipart upload. Part number must be between + * 1 and 10,000 (inclusive). + */ + public int getPartNumber() { + return this.partNumber; + } + + /** + * Sets the part number describing this part's position relative to the + * other parts in the multipart upload. Part number must be between 1 and + * 10,000 (inclusive). + * + * @param partNumber the part number describing this part's position relative to + * the other parts in the multipart upload. Part number must be + * between 1 and 10,000 (inclusive). + */ + public void setPartNumber(int partNumber) { + checkArgument(partNumber > 0, "partNumber should be positive, but is %s", partNumber); + this.partNumber = partNumber; + } + + public UploadPartCopyRequest withPartNumber(int partNumber) { + this.setPartNumber(partNumber); + return this; + } + + /** + * Returns the size of this part, in bytes. + * + * @return the size of this part, in bytes. + */ + public long getPartSize() { + return this.partSize; + } + + /** + * Sets the size of this part, in bytes. + * + * @param partSize the size of this part, in bytes. + */ + public void setPartSize(long partSize) { + checkArgument(partSize >= 0, "partSize should not be negative."); + this.partSize = partSize; + } + + public UploadPartCopyRequest withPartSize(long partSize) { + this.setPartSize(partSize); + return this; + } + + public long getOffSet() { + return this.offSet; + } + + public void setOffSet(long offSet) { + this.offSet = offSet; + } + + public UploadPartCopyRequest withOffSet(long offSet) { + this.setOffSet(offSet); + return this; + } + + public String getSourceBucketName() { + return this.sourceBucketName; + } + + public void setSourceBucketName(String sourceBucketName) { + this.sourceBucketName = sourceBucketName; + } + + public UploadPartCopyRequest withSourceBucketName(String sourceBucketName) { + this.setSourceBucketName(sourceBucketName); + return this; + } + + public String getSourceKey() { + return this.sourcetkey; + } + + public void setSourceKey(String sourcetkey) { + this.sourcetkey = sourcetkey; + } + + public UploadPartCopyRequest withSourceKey(String sourcetkey) { + this.setSourceKey(sourcetkey); + return this; + } + + /** + * Gets the limit of put object speed. + * @return the limit of put object speed. unit: bit/s + */ + public long getTrafficLimitBitPS() { + return trafficLimitBitPS; + } + + /** + * Sets Gets the limit of put object speed. range: 819200 bit/s ~ 838860800 bit/s + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s + */ + public void setTrafficLimitBitPS(long trafficLimitBitPS) { + this.trafficLimitBitPS = trafficLimitBitPS; + } + + /** + * + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s, range: 819200 bit/s ~ 838860800 bit/s + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public UploadPartCopyRequest withTrafficLimitBitPS(long trafficLimitBitPS) { + this.setTrafficLimitBitPS(trafficLimitBitPS); + return this; + } + + /** + * Gets xBceCrc32c of the newly uploaded part. + * @return xBceCrc32c of the newly uploaded part. + */ + public String getxBceCrc32c() { + return xBceCrc32c; + } + + /** + * Sets xBceCrc32c of the newly uploaded part. + * @param xBceCrc32c The xBceCrc of the newly uploaded part. + */ + public void setxBceCrc32c(String xBceCrc32c) { + this.xBceCrc32c = xBceCrc32c; + } + + /** + * Gets xBceCrc32cFlag of the newly uploaded part. + * @return xBceCrc32cFlag of the newly uploaded part. + */ + public boolean getxBceCrc32cFlag() { + return xBceCrc32cFlag; + } + + /** + * Sets xBceCrc32cFlag of the newly uploaded part. + * @param xBceCrc32cFlag whether to calculate crc32c + */ + public void setxBceCrc32cFlag(boolean xBceCrc32cFlag) { + this.xBceCrc32cFlag = xBceCrc32cFlag; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/UploadPartCopyResponse.java b/src/main/java/com/baidubce/services/bos/model/UploadPartCopyResponse.java new file mode 100644 index 00000000..f975ce70 --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/UploadPartCopyResponse.java @@ -0,0 +1,70 @@ +package com.baidubce.services.bos.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Contains the details returned from Baidu Bos after calling the UploadPartCopy + * operation. + */ +public class UploadPartCopyResponse extends BosResponse { + + /** + * The part number of the newly uploaded part + */ + private int partNumber; + + /** + * The entity tag generated from the content of the upload part + */ + private String eTag; + + /** + * Returns the part number of the newly uploaded part. + * + * @return The part number of the newly uploaded part. + */ + public int getPartNumber() { + return this.partNumber; + } + + /** + * Sets the part number of the newly uploaded part. + * + * @param partNumber the part number of the newly uploaded part. + */ + public void setPartNumber(int partNumber) { + this.partNumber = partNumber; + } + + /** + * Returns the entity tag of the newly uploaded part. The entity tag is + * needed later when the multipart upload is completed. + * + * @return the entity tag of the newly uploaded part. + */ + public String getETag() { + return this.eTag; + } + + /** + * Sets the entity tag of the newly uploaded part. + * + * @param eTag the entity tag of the newly uploaded part. + */ + @JsonProperty("eTag") + public void setETag(String eTag) { + this.eTag = eTag; + } + + /** + * Returns an identifier which identifies the upload part by its part number + * and the entity tag computed from the part's data. This information is + * later needed to complete a multipart upload. + * + * @return An identifier which identifies the upload part by its part number + * and the entity tag computed from the part's data. + */ + public PartETag getPartETag() { + return new PartETag(this.partNumber, this.eTag); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/UploadPartRequest.java b/src/main/java/com/baidubce/services/bos/model/UploadPartRequest.java index 6ee5ade4..cb225fba 100644 --- a/src/main/java/com/baidubce/services/bos/model/UploadPartRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/UploadPartRequest.java @@ -52,6 +52,42 @@ public class UploadPartRequest extends GenericUploadRequest { */ private InputStream inputStream; + /** + * The xBceCrc of the newly uploaded part + */ + private String xBceCrc; + + /** + * The BosProgressCallback used for get progress information + */ + private BosProgressCallback progressCallback = null; + + /** + * Gets xBceCrc of the newly uploaded part. + * @return xBceCrc of the newly uploaded part. + */ + public String getxBceCrc() { + return xBceCrc; + } + + /** + * Sets xBceCrc of the newly uploaded part. + * @param xBceCrc The xBceCrc of the newly uploaded part. + */ + public void setxBceCrc(String xBceCrc) { + this.xBceCrc = xBceCrc; + } + + /** + * The xBceCrc32c of the newly uploaded part + */ + private String xBceCrc32c; + + /** + * The xBceCrc32cFlag, whether to calculate crc32c + */ + private boolean xBceCrc32cFlag = false; + public UploadPartRequest() { super(); } @@ -280,4 +316,88 @@ public UploadPartRequest withInputStream(InputStream inputStream) { this.setInputStream(inputStream); return this; } + + /** + * Gets the BosProgressCallback which used for Get upload progress. + * @return The BosProgressCallback which used for get progress information. + */ + public BosProgressCallback getProgressCallback() { + return progressCallback; + } + + /** + * Sets the BosProgressCallback which used for Get upload progress. + * @param progressCallback The BosProgressCallback, which used for get progress information. + */ + public void setProgressCallback(BosProgressCallback progressCallback) { + this.progressCallback = progressCallback; + } + + /** + * + * @param progressCallback The BosProgressCallback, which used for get progress information. + * @return This UploadPartRequest, so that additional method calls can be chained together + */ + public UploadPartRequest withProgressCallback(BosProgressCallback progressCallback) { + this.setProgressCallback(progressCallback); + return this; + } + + /** + * Gets the limit of put object speed. + * @return the limit of put object speed. unit: bit/s + */ + public long getTrafficLimitBitPS() { + return trafficLimitBitPS; + } + + /** + * Sets Gets the limit of put object speed. range: 819200 bit/s ~ 838860800 bit/s + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s + */ + public void setTrafficLimitBitPS(long trafficLimitBitPS) { + this.trafficLimitBitPS = trafficLimitBitPS; + } + + /** + * + * @param trafficLimitBitPS the limit of put object speed. unit: bit/s, range: 819200 bit/s ~ 838860800 bit/s + * @return This PutObjectRequest, so that additional method calls can be chained together + */ + public UploadPartRequest withTrafficLimitBitPS(long trafficLimitBitPS) { + this.setTrafficLimitBitPS(trafficLimitBitPS); + return this; + } + + /** + * Gets xBceCrc32c of the newly uploaded part. + * @return xBceCrc32c of the newly uploaded part. + */ + public String getxBceCrc32c() { + return xBceCrc32c; + } + + /** + * Sets xBceCrc32c of the newly uploaded part. + * @param xBceCrc32c The xBceCrc of the newly uploaded part. + */ + public void setxBceCrc32c(String xBceCrc32c) { + this.xBceCrc32c = xBceCrc32c; + } + + /** + * Gets xBceCrc32cFlag of the newly uploaded part. + * @return xBceCrc32cFlag of the newly uploaded part. + */ + public boolean getxBceCrc32cFlag() { + return xBceCrc32cFlag; + } + + /** + * Sets xBceCrc32cFlag of the newly uploaded part. + * @param xBceCrc32cFlag whether to calculate crc32c + */ + public void setxBceCrc32cFlag(boolean xBceCrc32cFlag) { + this.xBceCrc32cFlag = xBceCrc32cFlag; + } } diff --git a/src/main/java/com/baidubce/services/bvw/BvwClient.java b/src/main/java/com/baidubce/services/bvw/BvwClient.java new file mode 100644 index 00000000..f05efe17 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/BvwClient.java @@ -0,0 +1,1170 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.model.common.ListByPageResponse; +import com.baidubce.services.bvw.model.keyframe.KeyFrameDescAddRequest; +import com.baidubce.services.bvw.model.keyframe.KeyFrameDescGetResponse; +import com.baidubce.services.bvw.model.keyframe.KeyFrameUrlResponse; +import com.baidubce.services.bvw.model.matlib.DraftListRequest; +import com.baidubce.services.bvw.model.matlib.GetDraftRequest; +import com.baidubce.services.bvw.model.matlib.GetDraftResponse; +import com.baidubce.services.bvw.model.matlib.MaterialBaseResponse; +import com.baidubce.services.bvw.model.matlib.MaterialGetRequest; +import com.baidubce.services.bvw.model.matlib.MaterialGetResponse; +import com.baidubce.services.bvw.model.matlib.MaterialPresetGetRequest; +import com.baidubce.services.bvw.model.matlib.MaterialPresetGetResponse; +import com.baidubce.services.bvw.model.matlib.MaterialPresetSearchRequest; +import com.baidubce.services.bvw.model.matlib.MaterialPresetSearchResponse; +import com.baidubce.services.bvw.model.matlib.MaterialPresetUploadResponse; +import com.baidubce.services.bvw.model.matlib.MaterialSearchRequest; +import com.baidubce.services.bvw.model.matlib.MaterialSearchResponse; +import com.baidubce.services.bvw.model.matlib.MatlibConfigBaseRequest; +import com.baidubce.services.bvw.model.matlib.MatlibConfigBaseResponse; +import com.baidubce.services.bvw.model.matlib.MatlibConfigGetResponse; +import com.baidubce.services.bvw.model.matlib.MatlibTaskGetResponse; +import com.baidubce.services.bvw.model.matlib.MatlibTaskRequest; +import com.baidubce.services.bvw.model.matlib.MatlibTaskResponse; +import com.baidubce.services.bvw.model.matlib.MatlibUploadRequest; +import com.baidubce.services.bvw.model.matlib.MatlibUploadResponse; +import com.baidubce.services.bvw.model.matlib.Text2AudioRequest; +import com.baidubce.services.bvw.model.matlib.Text2AudioResponse; +import com.baidubce.services.bvw.model.matlib.VideoGenerationRequest; +import com.baidubce.services.bvw.model.matlib.VideoGenerationResponse; +import com.baidubce.services.bvw.model.media.MediaBaseRequest; +import com.baidubce.services.bvw.model.media.MediaBaseResponse; +import com.baidubce.services.bvw.model.media.MediaBatchDeleteRequest; +import com.baidubce.services.bvw.model.media.MediaGetResponse; +import com.baidubce.services.bvw.model.media.MediaInstanceListResponse; +import com.baidubce.services.bvw.model.media.MediaListRequest; +import com.baidubce.services.bvw.model.media.MediaListResponse; +import com.baidubce.services.bvw.model.media.MediaProcessRequest; +import com.baidubce.services.bvw.model.media.MediaProcessResponse; +import com.baidubce.services.bvw.model.media.MediaUpdateRequest; +import com.baidubce.services.bvw.model.notification.AuthType; +import com.baidubce.services.bvw.model.notification.NotificationBaseRequest; +import com.baidubce.services.bvw.model.notification.NotificationBaseResponse; +import com.baidubce.services.bvw.model.notification.NotificationCreateRequest; +import com.baidubce.services.bvw.model.notification.NotificationGetResponse; +import com.baidubce.services.bvw.model.notification.NotificationListRequest; +import com.baidubce.services.bvw.model.notification.NotificationListResponse; +import com.baidubce.services.bvw.model.notification.NotificationStatus; +import com.baidubce.services.bvw.model.notification.NotificationUpdateRequest; +import com.baidubce.services.bvw.model.videoedit.VideoEditCreateRequest; +import com.baidubce.services.bvw.model.videoedit.VideoEditCreateResponse; +import com.baidubce.services.bvw.model.videoedit.VideoEditPollingRequest; +import com.baidubce.services.bvw.model.videoedit.VideoEditPollingResponse; +import com.baidubce.services.bvw.model.workflow.WorkflowBaseRequest; +import com.baidubce.services.bvw.model.workflow.WorkflowBaseResponse; +import com.baidubce.services.bvw.model.workflow.WorkflowCreateRequest; +import com.baidubce.services.bvw.model.workflow.WorkflowGetResponse; +import com.baidubce.services.bvw.model.workflow.WorkflowListRequest; +import com.baidubce.services.bvw.model.workflow.WorkflowListResponse; +import com.baidubce.services.bvw.model.workflow.WorkflowUpdateRequest; +import com.baidubce.services.bvw.model.workflow.instance.InstanceBaseRequest; +import com.baidubce.services.bvw.model.workflow.instance.InstanceGetResponse; +import com.baidubce.services.bvw.model.workflow.instance.InstanceGetTaskUrlsResponse; +import com.baidubce.services.bvw.model.workflow.task.TaskBaseRequest; +import com.baidubce.services.bvw.model.workflow.task.TaskGetResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import org.apache.commons.lang.time.DateFormatUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Provides the client for accessing the Baidu VideoWorks(BVW). + */ +public class BvwClient extends AbstractBceClient { + + /** + * The request paths. + */ + private static final String VERSION = "v1"; + private static final String WORKFLOW = "workflow"; + private static final String MEDIA = "media"; + private static final String INSTANCE = "instance"; + private static final String TASK = "task"; + private static final String NOTIFICATION = "notification"; + private static final String MATLIB = "matlib"; + private static final String MATERIAL_LIBRARY = "materialLibrary"; + private static final String MATERIAL_LIBRARY_PRESET = "preset"; + private static final String MATLIB_VIDEO_GENERATION = "videoGenerationTask"; + private static final String MATLIB_TIMELINE_RESOURCE = "draftAndTimeline"; + private static final String VIDEO_EDIT = "videoEdit"; + private static final String VIDEO_EDIT_CREATE = "createNewVideo"; + private static final String VIDEO_EDIT_POLLING = "pollingVideo"; + + /** + * The request queries. + */ + private static final String LIST_PAGE_NO = "pageNo"; + private static final String LIST_PAGE_SIZE = "pageSize"; + private static final String LIST_BEGIN_TIME = "beginTime"; + private static final String LIST_END_TIME = "endTime"; + private static final String WORKFLOW_LIST_STATUS = "status"; + private static final String WORKFLOW_LIST_NAME = "name"; + private static final String WORKFLOW_ENABLE = "enable"; + private static final String WORKFLOW_DISABLE = "disable"; + private static final String MEDIA_PROCESS = "process"; + private static final String MEDIA_INSTANCES = "queryMediaInstanceList"; + private static final String MEDIA_BAN = "ban"; + private static final String MEDIA_UNBAN = "unban"; + private static final String MEDIA_LIST_STATUS = "status"; + private static final String MEDIA_LIST_INSTANCE_STATUS = "instanceStatus"; + private static final String MEDIA_LIST_MEDIA_ID = "mediaId"; + private static final String MEDIA_LIST_TITLE = "title"; + private static final String MEDIA_LIST_ORDER = "order"; + private static final String MEDIA_LIST_ORDER_BY = "orderBy"; + private static final String MEDIA_BATCH_DELETE = "mediaIds"; + private static final String INSTANCE_TASK_URLS = "queryStageTaskUrlList"; + private static final String INSTANCE_KEYFRAME_DESC_URLS = "queryKeyFrameDescList"; + private static final String INSTANCE_KEYFRAME_URLS = "queryKeyFrameUrlList"; + private static final String INSTANCE_KEYFRAME_ADD = "addKeyFrameDesc"; + private static final String INSTANCE_PRE_SIGN_FLAG = "preSign"; + private static final String NOTIFICATION_LIST_STATUS = "status"; + private static final String NOTIFICATION_ENABLE = "enable"; + private static final String NOTIFICATION_DISABLE = "disable"; + private static final String MATLIB_UPLOAD = "upload"; + private static final String MATLIB_CONFIG = "config"; + private static final String MATLIB_SPEECH = "speech"; + private static final String MATERIAL_TITLE_KEYWORD = "titleKeyword"; + private static final String MATERIAL_PRESET_TYPE = "type"; + private static final String MATERIAL_SOURCE_TYPE = "sourceType"; + private static final String MATERIAL_INFO_TYPE = "infoType"; + private static final String MATERIAL_MEDIA_TYPE = "mediaType"; + private static final String MATERIAL_STATUS = "status"; + private static final String MATERIAL_CREATETIME_BEGIN = "begin"; + private static final String MATERIAL_CREATETIME_END = "end"; + private static final String MATERIAL_PAGENO = "pageNo"; + private static final String MATERIAL_SIZE = "size"; + private static final String MATERIAL_PAGESIZE = "pageSize"; + private static final String MATLIB_DRAFT_TIMELINE = "draftAndTimeline"; + + /** + * Responsible for handling httpResponses from all Bos service calls. + */ + private static final HttpResponseHandler[] BVW_HANDLES = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BvwMetadataResponseHandler(), + new BvwErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new bvw client using the client configuration to access bvw. + * + * @param config The bvw client configuration options controlling how this client + * connects to bvw (e.g. proxy settings, retry counts, etc). + */ + public BvwClient(BceClientConfiguration config) { + super(config, BVW_HANDLES, true); + } + + /** + * Creates and initializes a new request object for the specified bcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + if (httpMethod == HttpMethodName.POST + || httpMethod == HttpMethodName.PUT) { + fillPayload(request, bceRequest); + } + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * Create workflow with specified parameter. + * + * @param workflowCreateRequest The creating workflow request + * @return A creating workflow response + */ + public WorkflowBaseResponse createWorkflow(WorkflowCreateRequest workflowCreateRequest) { + InternalRequest request = this.createRequest(workflowCreateRequest, HttpMethodName.POST, WORKFLOW); + return this.invokeHttpClient(request, WorkflowBaseResponse.class); + } + + /** + * Get workflow with specified workflow name. + * + * @param workflowName The workflow name + * @return A getting workflow response + */ + public WorkflowGetResponse getWorkflow(String workflowName) { + WorkflowBaseRequest getRequest = WorkflowBaseRequest.of(workflowName); + return this.getWorkflow(getRequest); + } + + /** + * Get workflow with specified getting workflow request. + * + * @param getRequest The getting workflow request + * @return A getting workflow response + */ + public WorkflowGetResponse getWorkflow(WorkflowBaseRequest getRequest) { + InternalRequest request = this.createRequest(getRequest, HttpMethodName.GET, WORKFLOW, + getRequest.getName()); + return this.invokeHttpClient(request, WorkflowGetResponse.class); + } + + /** + * Delete workflow with specified workflow name. + * + * @param workflowName The workflow name + * @return A deleting workflow response + */ + public WorkflowBaseResponse deleteWorkflow(String workflowName) { + WorkflowBaseRequest deleteRequest = WorkflowBaseRequest.of(workflowName); + return this.deleteWorkflow(deleteRequest); + } + + /** + * Get workflow with specified deleting workflow request. + * + * @param deleteRequest The deleting workflow request + * @return A deleting workflow response + */ + public WorkflowBaseResponse deleteWorkflow(WorkflowBaseRequest deleteRequest) { + InternalRequest request = this.createRequest(deleteRequest, HttpMethodName.DELETE, WORKFLOW, + deleteRequest.getName()); + return this.invokeHttpClient(request, WorkflowBaseResponse.class); + } + + /** + * Update workflow with specified updating workflow request. + * + * @param updateRequest The updating workflow request + * @return A updating workflow response + */ + public WorkflowBaseResponse updateWorkflow(WorkflowUpdateRequest updateRequest) { + InternalRequest request = this.createRequest(updateRequest, HttpMethodName.PUT, WORKFLOW, + updateRequest.getName()); + return this.invokeHttpClient(request, WorkflowBaseResponse.class); + } + + /** + * List workflow with specified listing workflow request. + * + * @param listRequest The listing workflow request + * @return A listing workflow response + */ + public ListByPageResponse listWorkflow(WorkflowListRequest listRequest) { + InternalRequest request = this.createRequest(listRequest, HttpMethodName.GET, WORKFLOW); + request.addParameter(LIST_PAGE_NO, String.valueOf(listRequest.getPageNo())); + request.addParameter(LIST_PAGE_SIZE, String.valueOf(listRequest.getPageSize())); + if (null != listRequest.getStatus()) { + request.addParameter(WORKFLOW_LIST_STATUS, String.valueOf(listRequest.getStatus())); + } + if (StringUtils.isNotBlank(listRequest.getBeginTime())) { + request.addParameter(LIST_BEGIN_TIME, listRequest.getBeginTime()); + } + if (StringUtils.isNotBlank(listRequest.getEndTime())) { + request.addParameter(LIST_END_TIME, listRequest.getEndTime()); + } + if (StringUtils.isNotBlank(listRequest.getName())) { + request.addParameter(WORKFLOW_LIST_NAME, listRequest.getName()); + } + return this.invokeHttpClient(request, ListByPageResponse.class); + } + + /** + * Enable workflow with specified enabling workflow request. + * + * @param enableRequest Enabling workflow request + * @return A enabling workflow response + */ + public WorkflowBaseResponse enableWorkflow(WorkflowBaseRequest enableRequest) { + InternalRequest request = this.createRequest(enableRequest, HttpMethodName.PUT, WORKFLOW, + enableRequest.getName()); + request.addParameter(WORKFLOW_ENABLE, null); + return this.invokeHttpClient(request, WorkflowBaseResponse.class); + } + + /** + * Enable workflow with specified workflow name. + * + * @param workflowName Workflow name + * @return A enabling workflow response + */ + public WorkflowBaseResponse enableWorkflow(String workflowName) { + WorkflowBaseRequest enableRequest = WorkflowBaseRequest.of(workflowName); + return enableWorkflow(enableRequest); + } + + /** + * Disable workflow with specified enabling workflow request. + * + * @param disableRequest Disabling workflow request + * @return A disabling workflow response + */ + public WorkflowBaseResponse disableWorkflow(WorkflowBaseRequest disableRequest) { + InternalRequest request = this.createRequest(disableRequest, HttpMethodName.PUT, WORKFLOW, + disableRequest.getName()); + request.addParameter(WORKFLOW_DISABLE, null); + return this.invokeHttpClient(request, WorkflowBaseResponse.class); + } + + /** + * Disable workflow with specified workflow name. + * + * @param workflowName Workflow name + * @return A disabling workflow response + */ + public WorkflowBaseResponse disableWorkflow(String workflowName) { + WorkflowBaseRequest disableRequest = WorkflowBaseRequest.of(workflowName); + return disableWorkflow(disableRequest); + } + + /** + * Process media with specified processing media request. + * + * @param processRequest processing media request + * @return A processing media response + */ + public MediaProcessResponse processMedia(MediaProcessRequest processRequest) { + InternalRequest request = this.createRequest(processRequest, HttpMethodName.POST, MEDIA); + request.addParameter(MEDIA_PROCESS, null); + return this.invokeHttpClient(request, MediaProcessResponse.class); + } + + /** + * Get media with specified getting media request. + * + * @param getRequest getting media request + * @return A getting media response + */ + public MediaGetResponse getMedia(MediaBaseRequest getRequest) { + InternalRequest request = this.createRequest(getRequest, HttpMethodName.GET, MEDIA, getRequest.getMediaId()); + return this.invokeHttpClient(request, MediaGetResponse.class); + } + + /** + * Get media with specified media id. + * + * @param mediaId Media id + * @return A getting media response + */ + public MediaGetResponse getMedia(String mediaId) { + MediaBaseRequest getRequest = MediaBaseRequest.of(mediaId); + return getMedia(getRequest); + } + + /** + * Update media with specified updating media request. + * + * @param updateRequest The updating media request + * @return A updating media response + */ + public MediaBaseResponse updateMedia(MediaUpdateRequest updateRequest) { + InternalRequest request = this.createRequest(updateRequest, HttpMethodName.PUT, MEDIA, + updateRequest.getMediaId()); + return this.invokeHttpClient(request, MediaBaseResponse.class); + } + + /** + * Get instance list of media. + * + * @param getRequest The getting instance list of media request + * @return A getting instance list of media response + */ + public MediaInstanceListResponse getMediaInstanceList(MediaBaseRequest getRequest) { + InternalRequest request = this.createRequest(getRequest, HttpMethodName.GET, MEDIA, getRequest.getMediaId()); + request.addParameter(MEDIA_INSTANCES, null); + return this.invokeHttpClient(request, MediaInstanceListResponse.class); + } + + /** + * Get instance list of media. + * + * @param mediaId The media id + * @return A getting instance list of media response + */ + public MediaInstanceListResponse getMediaInstanceList(String mediaId) { + MediaBaseRequest getRequest = MediaBaseRequest.of(mediaId); + return getMediaInstanceList(getRequest); + } + + /** + * Ban media with specified banning media request. + * + * @param banRequest The banning media request + * @return A banning media response + */ + public MediaBaseResponse banMedia(MediaBaseRequest banRequest) { + InternalRequest request = this.createRequest(banRequest, HttpMethodName.PUT, MEDIA, banRequest.getMediaId()); + request.addParameter(MEDIA_BAN, null); + return this.invokeHttpClient(request, MediaBaseResponse.class); + } + + /** + * Ban media with specified media id. + * + * @param mediaId The media id + * @return A banning media response + */ + public MediaBaseResponse banMedia(String mediaId) { + MediaBaseRequest banRequest = MediaBaseRequest.of(mediaId); + return banMedia(banRequest); + } + + /** + * Unban media with specified unbanning media request. + * + * @param unbanRequest The unbanning media request + * @return A unbanning media response + */ + public MediaBaseResponse unbanMedia(MediaBaseRequest unbanRequest) { + InternalRequest request = this + .createRequest(unbanRequest, HttpMethodName.PUT, MEDIA, unbanRequest.getMediaId()); + request.addParameter(MEDIA_UNBAN, null); + return this.invokeHttpClient(request, MediaBaseResponse.class); + } + + /** + * Unban media with specified media id. + * + * @param mediaId The media id + * @return A unbanning media response + */ + public MediaBaseResponse unbanMedia(String mediaId) { + MediaBaseRequest unbanRequest = MediaBaseRequest.of(mediaId); + return unbanMedia(unbanRequest); + } + + /** + * List media with specified listing media request. + * + * @param listRequest The listing media request + * @return A listing media response + */ + public ListByPageResponse listMedia(MediaListRequest listRequest) { + InternalRequest request = this.createRequest(listRequest, HttpMethodName.GET, MEDIA); + request.addParameter(LIST_PAGE_NO, String.valueOf(listRequest.getPageNo())); + request.addParameter(LIST_PAGE_SIZE, String.valueOf(listRequest.getPageSize())); + if (StringUtils.isNotBlank(listRequest.getBeginTime())) { + request.addParameter(LIST_BEGIN_TIME, listRequest.getBeginTime()); + } + if (StringUtils.isNotBlank(listRequest.getEndTime())) { + request.addParameter(LIST_END_TIME, listRequest.getEndTime()); + } + if (null != listRequest.getStatus()) { + request.addParameter(MEDIA_LIST_STATUS, String.valueOf(listRequest.getStatus())); + } + if (null != listRequest.getInstanceStatus()) { + request.addParameter(MEDIA_LIST_INSTANCE_STATUS, String.valueOf(listRequest.getInstanceStatus())); + } + if (StringUtils.isNotBlank(listRequest.getMediaId())) { + request.addParameter(MEDIA_LIST_MEDIA_ID, listRequest.getMediaId()); + } + if (StringUtils.isNotBlank(listRequest.getTitle())) { + request.addParameter(MEDIA_LIST_TITLE, listRequest.getTitle()); + } + if (StringUtils.isNotBlank(listRequest.getOrder()) && StringUtils.isNotBlank(listRequest.getOrderBy())) { + request.addParameter(MEDIA_LIST_ORDER, listRequest.getOrder()); + request.addParameter(MEDIA_LIST_ORDER_BY, listRequest.getOrderBy()); + } + return this.invokeHttpClient(request, ListByPageResponse.class); + } + + /** + * Delete media with specified deleting media request. + * + * @param deleteRequest The deleting media request + * @return A deleting media response + */ + public MediaBaseResponse deleteMedia(MediaBaseRequest deleteRequest) { + InternalRequest request = this + .createRequest(deleteRequest, HttpMethodName.DELETE, MEDIA, deleteRequest.getMediaId()); + return this.invokeHttpClient(request, MediaBaseResponse.class); + } + + /** + * Delete media with specified media id. + * + * @param mediaId The media id + * @return A deleting media response + */ + public MediaBaseResponse deleteMedia(String mediaId) { + MediaBaseRequest deleteRequest = MediaBaseRequest.of(mediaId); + return deleteMedia(deleteRequest); + } + + /** + * Batch delete media with specified batch deleting media request. + * + * @param batchDeleteRequest The batch deleting media request + * @return A batch deleting media response + */ + public MediaBaseResponse batchDeleteMedia(MediaBatchDeleteRequest batchDeleteRequest) { + InternalRequest request = this.createRequest(batchDeleteRequest, HttpMethodName.DELETE, MEDIA); + if (StringUtils.isNotBlank(batchDeleteRequest.getMediaIds())) { + request.addParameter(MEDIA_BATCH_DELETE, batchDeleteRequest.getMediaIds()); + } + return this.invokeHttpClient(request, MediaBaseResponse.class); + } + + /** + * Batch delete media with specified media id list. + * + * @param mediaIds The media id list + * @return A batch deleting media response + */ + public MediaBaseResponse batchDeleteMedia(List mediaIds) { + MediaBatchDeleteRequest batchDeleteRequest = MediaBatchDeleteRequest.of(mediaIds); + return batchDeleteMedia(batchDeleteRequest); + } + + /** + * Get instance with specified getting instance request. + * + * @param getRequest The getting instance request + * @return A getting instance response + */ + public InstanceGetResponse getInstance(InstanceBaseRequest getRequest) { + InternalRequest request = this + .createRequest(getRequest, HttpMethodName.GET, INSTANCE, getRequest.getInstanceId()); + return this.invokeHttpClient(request, InstanceGetResponse.class); + } + + /** + * Get instance with specified instance id. + * + * @param instanceId The instance id + * @return A getting instance response + */ + public InstanceGetResponse getInstance(String instanceId) { + InstanceBaseRequest getRequest = InstanceBaseRequest.of(instanceId); + return getInstance(getRequest); + } + + /** + * Get url resource from a instance with specified getting request. + * + * @param getRequest The getting instance task urls request + * @return A getting instance task urls response + */ + public InstanceGetTaskUrlsResponse getInstanceTaskUrls(InstanceBaseRequest getRequest) { + InternalRequest request = this + .createRequest(getRequest, HttpMethodName.GET, INSTANCE, getRequest.getInstanceId()); + request.addParameter(INSTANCE_TASK_URLS, null); + return this.invokeHttpClient(request, InstanceGetTaskUrlsResponse.class); + } + + /** + * Get url resource from a instance with specified instance id. + * + * @param instanceId The instance id + * @return A getting instance task urls response + */ + public InstanceGetTaskUrlsResponse getInstanceTaskUrls(String instanceId) { + InstanceBaseRequest getRequest = InstanceBaseRequest.of(instanceId); + return getInstanceTaskUrls(getRequest); + } + + /** + * Get task with specified getting task request. + * + * @param getRequest The getting task request + * @return A getting task request + */ + public TaskGetResponse getTask(TaskBaseRequest getRequest) { + InternalRequest request = this + .createRequest(getRequest, HttpMethodName.GET, TASK, getRequest.getTaskId()); + return this.invokeHttpClient(request, TaskGetResponse.class); + } + + /** + * Get task with specified task id. + * + * @param taskId The task id + * @return A getting task request + */ + public TaskGetResponse getTask(String taskId) { + TaskBaseRequest getRequest = TaskBaseRequest.of(taskId); + return getTask(getRequest); + } + + /** + * Create notification with specified creating notification request. + * + * @param createRequest The creating notification request + * @return A creating notification response + */ + public NotificationBaseResponse createNotification(NotificationCreateRequest createRequest) { + InternalRequest request = this.createRequest(createRequest, HttpMethodName.POST, NOTIFICATION); + return this.invokeHttpClient(request, NotificationBaseResponse.class); + } + + /** + * Create notification with specified parameters.(No authentication) + * + * @param name The notification name + * @param endpoint The notification endpoint + * @return A creating notification response + */ + public NotificationBaseResponse createNotification(String name, String endpoint) { + NotificationCreateRequest createRequest = NotificationCreateRequest.of(name, endpoint); + return createNotification(createRequest); + } + + /** + * Create notification with specified parameters. + * @param name The notification name + * @param endpoint The notification endpoint + * @param token The notification authentication token + * @param authType The notification auth type + * @return A creating notification response + */ + public NotificationBaseResponse createNotification(String name, String endpoint, String token, AuthType authType) { + NotificationCreateRequest createRequest = NotificationCreateRequest.of(name, endpoint, token, authType); + return createNotification(createRequest); + } + + /** + * Get notification with specified parameters. + * + * @param getRequest The getting notification request + * @return A getting notification response + */ + public NotificationGetResponse getNotification(NotificationBaseRequest getRequest) { + InternalRequest request = this + .createRequest(getRequest, HttpMethodName.GET, NOTIFICATION, getRequest.getName()); + return this.invokeHttpClient(request, NotificationGetResponse.class); + } + + /** + * Get notification with specified notification name. + * + * @param name The notification name + * @return A getting notification response + */ + public NotificationGetResponse getNotification(String name) { + NotificationBaseRequest getRequest = NotificationBaseRequest.of(name); + return getNotification(getRequest); + } + + /** + * List notification with specified listing request. + * + * @param listRequest The listing notification request. + * @return A listing notification response. + */ + public NotificationListResponse listNotification(NotificationListRequest listRequest) { + InternalRequest request = this.createRequest(listRequest, HttpMethodName.GET, NOTIFICATION); + if (null != listRequest.getStatus()) { + request.addParameter(NOTIFICATION_LIST_STATUS, String.valueOf(listRequest.getStatus())); + } + return this.invokeHttpClient(request, NotificationListResponse.class); + } + + /** + * List notification with specified notification status. + * + * @param status The notification status + * @return A listing notification response. + */ + public NotificationListResponse listNotification(NotificationStatus status) { + NotificationListRequest listRequest = NotificationListRequest.of(status); + return listNotification(listRequest); + } + + /** + * List all of the notifications. + * + * @return A listing notification response. + */ + public NotificationListResponse listNotification() { + NotificationListRequest listRequest = NotificationListRequest.of(null); + return listNotification(listRequest); + } + + /** + * Update notification with specified updating request. + * + * @param updateRequest The updating notification request + * @return A updating notification response + */ + public NotificationBaseResponse updateNotification(NotificationUpdateRequest updateRequest) { + InternalRequest request = this + .createRequest(updateRequest, HttpMethodName.PUT, NOTIFICATION, updateRequest.getName()); + return this.invokeHttpClient(request, NotificationBaseResponse.class); + } + + /** + * Update notification with specified parameters. + * + * @param name The notification name + * @param endpoint The notification endpoint to update + * @return A updating notification response + */ + public NotificationBaseResponse updateNotification(String name, String endpoint) { + NotificationUpdateRequest updateRequest = NotificationUpdateRequest.of(name, endpoint); + return updateNotification(updateRequest); + } + + /** + * Update notification with specified parameters. + * + * @param name The notification name + * @param endpoint The notification endpoint to update + * @param token The notification token to update + * @param authType The notification authentication type to update + * @return A updating notification response + */ + public NotificationBaseResponse updateNotification(String name, String endpoint, String token, AuthType authType) { + NotificationUpdateRequest updateRequest = NotificationUpdateRequest.of(name, endpoint, token, authType); + return updateNotification(updateRequest); + } + + /** + * Enable notification with specified enabling request. + * + * @param enableRequest The enabling notification request + * @return A enabling notification response + */ + public NotificationBaseResponse enableNotification(NotificationBaseRequest enableRequest) { + InternalRequest request = this. + createRequest(enableRequest, HttpMethodName.PUT, NOTIFICATION, enableRequest.getName()); + request.addParameter(NOTIFICATION_ENABLE, null); + return this.invokeHttpClient(request, NotificationBaseResponse.class); + } + + /** + * Enable notification with specified notification name. + * + * @param name The notification name + * @return A enabling notification response + */ + public NotificationBaseResponse enableNotification(String name) { + NotificationBaseRequest enableRequest = NotificationBaseRequest.of(name); + return enableNotification(enableRequest); + } + + /** + * Disable notification with specified enabling request. + * + * @param disableRequest The disabling notification request + * @return A disabling notification response + */ + public NotificationBaseResponse disableNotification(NotificationBaseRequest disableRequest) { + InternalRequest request = this. + createRequest(disableRequest, HttpMethodName.PUT, NOTIFICATION, disableRequest.getName()); + request.addParameter(NOTIFICATION_DISABLE, null); + return this.invokeHttpClient(request, NotificationBaseResponse.class); + } + + /** + * Enable notification with specified notification name. + * + * @param name The notification name + * @return A disabling notification response + */ + public NotificationBaseResponse disableNotification(String name) { + NotificationBaseRequest disableRequest = NotificationBaseRequest.of(name); + return disableNotification(disableRequest); + } + + /** + * Delete notification with specified deleting request. + * + * @param deleteRequest The deleting notification request + * @return A deleting notification response + */ + public NotificationBaseResponse deleteNotification(NotificationBaseRequest deleteRequest) { + InternalRequest request = this + .createRequest(deleteRequest, HttpMethodName.DELETE, NOTIFICATION, deleteRequest.getName()); + return this.invokeHttpClient(request, NotificationBaseResponse.class); + } + + /** + * Delete notification with specified notification name. + * + * @param name The notification name + * @return A deleting notification response + */ + public NotificationBaseResponse deleteNotification(String name) { + NotificationBaseRequest deleteRequest = NotificationBaseRequest.of(name); + return deleteNotification(deleteRequest); + } + + /** + * Upload media to material library. + * + * @param matlibUploadRequest The uploading request + * @return A uploading response + */ + public MatlibUploadResponse upload2Material(MatlibUploadRequest matlibUploadRequest) { + InternalRequest request = this.createRequest(matlibUploadRequest, HttpMethodName.POST, MATLIB); + request.addParameter(MATLIB_UPLOAD, null); + return this.invokeHttpClient(request, MatlibUploadResponse.class); + } + + /** + * Get material from material library. + * @param materialId The material id + * @return A getting material response + */ + public MaterialGetResponse getMaterial(String materialId) { + MaterialGetRequest materialGetRequest = new MaterialGetRequest(materialId); + InternalRequest request = this.createRequest(materialGetRequest, HttpMethodName.GET, MATERIAL_LIBRARY, + materialId); + return invokeHttpClient(request, MaterialGetResponse.class); + } + + /** + * Delete material from material library. + * @param materialId The material id + * @return A deleting material response + */ + public MaterialBaseResponse deleteMaterial(String materialId) { + MaterialGetRequest materialGetRequest = new MaterialGetRequest(materialId); + InternalRequest request = this.createRequest(materialGetRequest, HttpMethodName.DELETE, MATERIAL_LIBRARY, + materialId); + return invokeHttpClient(request, MaterialBaseResponse.class); + } + + /** + * Search material from material library. + * @param materialSearchRequest search parameters + * @return material list response + */ + public MaterialSearchResponse searchMaterial(MaterialSearchRequest materialSearchRequest) { + InternalRequest request = this.createRequest(materialSearchRequest, HttpMethodName.GET, MATERIAL_LIBRARY); + if (null != materialSearchRequest.getInfoType()) { + request.addParameter(MATERIAL_INFO_TYPE, materialSearchRequest.getInfoType()); + } + if (null != materialSearchRequest.getMediaType()) { + request.addParameter(MATERIAL_MEDIA_TYPE, materialSearchRequest.getMediaType()); + } + if (null != materialSearchRequest.getSourceType()) { + request.addParameter(MATERIAL_SOURCE_TYPE, materialSearchRequest.getSourceType()); + } + if (null != materialSearchRequest.getStatus()) { + request.addParameter(MATERIAL_STATUS, materialSearchRequest.getStatus()); + } + if (StringUtils.isNotBlank(materialSearchRequest.getTitleKeyword())) { + request.addParameter(MATERIAL_TITLE_KEYWORD, materialSearchRequest.getTitleKeyword()); + } + if (null != materialSearchRequest.getBegin()) { + request.addParameter(MATERIAL_CREATETIME_BEGIN, materialSearchRequest.getBegin()); + } + if (null != materialSearchRequest.getEnd()) { + request.addParameter(MATERIAL_CREATETIME_END, materialSearchRequest.getEnd()); + } + if (null != materialSearchRequest.getPageNo()) { + request.addParameter(MATERIAL_PAGENO, + materialSearchRequest.getPageNo() + ""); + } + if (null != materialSearchRequest.getSize()) { + request.addParameter(MATERIAL_SIZE, + materialSearchRequest.getSize() + ""); + } + return invokeHttpClient(request, MaterialSearchResponse.class); + } + + /** + * Upload media preset to material library. + * + * @param matlibUploadRequest The uploading request + * @return A uploading response + */ + public MaterialPresetUploadResponse uploadMaterialPreset(String type, MatlibUploadRequest matlibUploadRequest) { + InternalRequest request = this.createRequest(matlibUploadRequest, HttpMethodName.POST, + MATERIAL_LIBRARY, MATERIAL_LIBRARY_PRESET, type); + request.addParameter(MATLIB_UPLOAD, null); + return this.invokeHttpClient(request, MaterialPresetUploadResponse.class); + } + + /** + * Get material preset from material library. + * @param id The material preset id + * @return A getting material preset response + */ + public MaterialPresetGetResponse getMaterialPreset(String id) { + MaterialPresetGetRequest materialPresetGetRequest = new MaterialPresetGetRequest(id); + InternalRequest request = this.createRequest(materialPresetGetRequest, HttpMethodName.GET, MATERIAL_LIBRARY, + MATERIAL_LIBRARY_PRESET, id); + return invokeHttpClient(request, MaterialPresetGetResponse.class); + } + + /** + * Delete material from material library. + * @param id The material preset id + * @return A deleting material preset response + */ + public MaterialBaseResponse deleteMaterialPreset(String id) { + MaterialPresetGetRequest materialPresetGetRequest = new MaterialPresetGetRequest(id); + InternalRequest request = this.createRequest(materialPresetGetRequest, HttpMethodName.DELETE, MATERIAL_LIBRARY, + MATERIAL_LIBRARY_PRESET, id); + return invokeHttpClient(request, MaterialBaseResponse.class); + } + + /** + * Search material preset from material library. + * @param materialPresetSearchRequest search parameters + * @return material list response + */ + public MaterialPresetSearchResponse searchMaterialPreset(MaterialPresetSearchRequest materialPresetSearchRequest) { + InternalRequest request = this.createRequest(materialPresetSearchRequest, HttpMethodName.GET, MATERIAL_LIBRARY, + MATERIAL_LIBRARY_PRESET); + if (null != materialPresetSearchRequest.getSourceType()) { + request.addParameter(MATERIAL_SOURCE_TYPE, materialPresetSearchRequest.getSourceType()); + } + if (null != materialPresetSearchRequest.getStatus()) { + request.addParameter(MATERIAL_STATUS, materialPresetSearchRequest.getStatus()); + } + if (null != materialPresetSearchRequest.getType()) { + request.addParameter(MATERIAL_PRESET_TYPE, materialPresetSearchRequest.getType()); + } + if (null != materialPresetSearchRequest.getPageNo()) { + request.addParameter(MATERIAL_PAGENO, materialPresetSearchRequest.getPageNo() + ""); + } + if (null != materialPresetSearchRequest.getPageSize()) { + request.addParameter(MATERIAL_PAGESIZE, materialPresetSearchRequest.getPageSize() + ""); + } + return invokeHttpClient(request, MaterialPresetSearchResponse.class); + } + + /** + * Create matlib config. + * + * @param baseRequest The creating matlib config request. + * @return A creating matlib config response. + */ + public MatlibConfigBaseResponse createMatlibConfig(MatlibConfigBaseRequest baseRequest) { + InternalRequest request = this.createRequest(baseRequest, HttpMethodName.POST, MATLIB, MATLIB_CONFIG); + return invokeHttpClient(request, MatlibConfigBaseResponse.class); + } + + /** + * Update matlib config. + * @param baseRequest The updating matlib config request. + * @return A updating matlib config response. + */ + public MatlibConfigBaseResponse updateMatlibConfig(MatlibConfigBaseRequest baseRequest) { + InternalRequest request = this.createRequest(baseRequest, HttpMethodName.PUT, MATLIB, MATLIB_CONFIG); + return invokeHttpClient(request, MatlibConfigBaseResponse.class); + } + + /** + * Get matlib config. + * + * @return A matlib config response. + */ + public MatlibConfigGetResponse getMatlibConfig() { + InternalRequest request = this.createRequest(new MatlibConfigBaseRequest(), HttpMethodName.GET, MATLIB, + MATLIB_CONFIG); + return invokeHttpClient(request, MatlibConfigGetResponse.class); + } + + /** + * Transfer a list of text to audio. + * If you want to use this function, please set matlib bucket config first, + * + * @param text2AudioRequest The text to audio request + * @return A text to audio response + */ + public Text2AudioResponse text2Audio(Text2AudioRequest text2AudioRequest) { + InternalRequest request = this.createRequest(text2AudioRequest, HttpMethodName.POST, MATLIB, MATLIB_SPEECH); + return invokeHttpClient(request, Text2AudioResponse.class); + } + + /** + * create a task of video edit + * The cmd Object in VideoEditCreateRequest + * 1> do not need to modify it by your self, you only put the json string to Map to it(From web FE) + * 2> if you want to construct it by yourself, make object by Map + * + * @param videoEditCreateRequest + * @return A response of job create result + */ + public VideoEditCreateResponse createVideoEdit(VideoEditCreateRequest videoEditCreateRequest) { + InternalRequest request = this.createRequest(videoEditCreateRequest, HttpMethodName.POST, VIDEO_EDIT, + VIDEO_EDIT_CREATE); + return invokeHttpClient(request, VideoEditCreateResponse.class); + } + + /** + * get edit job status + * + * @param editId + * @return A job desc of this editId + */ + public VideoEditPollingResponse pollingVideoEdit(long editId) { + VideoEditPollingRequest videoEditPollingRequest = new VideoEditPollingRequest(editId); + InternalRequest request = this.createRequest(videoEditPollingRequest, HttpMethodName.GET, + VIDEO_EDIT, VIDEO_EDIT_POLLING, String.format("%d", editId)); + return invokeHttpClient(request, VideoEditPollingResponse.class); + } + + /** + * create a video with materials and subtitles + * + * @param videoGenerationRequest videoGenerationResponse + * @return VideoGenerationResponse + */ + public VideoGenerationResponse createVideoGenerationTask(VideoGenerationRequest videoGenerationRequest) { + InternalRequest request = this.createRequest(videoGenerationRequest, HttpMethodName.POST, MATLIB, + MATLIB_VIDEO_GENERATION); + return invokeHttpClient(request, VideoGenerationResponse.class); + } + + /** + * get keyframe list from the transcoding task or no transcoding task in the instance + * @param instanceId workflowInstanceId + * @return keyframe list + */ + public KeyFrameDescGetResponse queryKeyFrameDescList(String instanceId) { + InstanceBaseRequest getRequest = InstanceBaseRequest.of(instanceId); + InternalRequest request = this.createRequest(getRequest, HttpMethodName.GET, INSTANCE, instanceId); + request.addParameter(INSTANCE_KEYFRAME_DESC_URLS, null); + return invokeHttpClient(request, KeyFrameDescGetResponse.class); + } + + /** + * add keyframe for workflowInstance + * @param instanceId workflowInstanceId + * @param keyFrameDescAddRequest keyframe desc + */ + public void addKeyFrameDesc(String instanceId, KeyFrameDescAddRequest keyFrameDescAddRequest) { + InternalRequest request = this.createRequest(keyFrameDescAddRequest, HttpMethodName.POST, INSTANCE, + instanceId); + request.addParameter(INSTANCE_KEYFRAME_ADD, null); + invokeHttpClient(request, AbstractBceResponse.class); + } + + /** + * get target bos key's preSign url + * @param instanceId workflowInstanceId + * @return keyFrame info list + */ + public KeyFrameUrlResponse queryKeyFrameUrlList(String instanceId) { + InstanceBaseRequest getRequest = InstanceBaseRequest.of(instanceId); + InternalRequest request = this.createRequest(getRequest, HttpMethodName.GET, INSTANCE, + getRequest.getInstanceId()); + request.addParameter(INSTANCE_KEYFRAME_URLS, null); + request.addParameter(INSTANCE_PRE_SIGN_FLAG, String.valueOf(true)); + return invokeHttpClient(request, KeyFrameUrlResponse.class); + } + + /** + * create draft + * @param matlibTaskRequest + * @return + */ + public MatlibTaskResponse createDraft(MatlibTaskRequest matlibTaskRequest) { + InternalRequest request = this.createRequest(matlibTaskRequest, HttpMethodName.POST, MATLIB); + return invokeHttpClient(request, MatlibTaskResponse.class); + } + + /** + * update draft + * @return + */ + public void updateDraft(long draftId, MatlibTaskRequest matlibTaskRequest) { + + InternalRequest request = this.createRequest(matlibTaskRequest, HttpMethodName.PUT, MATLIB, + String.valueOf(draftId), MATLIB_TIMELINE_RESOURCE); + invokeHttpClient(request, AbstractBceResponse.class); + } + + /** + * List all of the draft. + */ + public ListByPageResponse getDraftList(DraftListRequest listRequest) { + InternalRequest request = this.createRequest(listRequest, HttpMethodName.GET, MATLIB); + request.addParameter(LIST_PAGE_NO, String.valueOf(listRequest.getPageNo())); + request.addParameter(LIST_PAGE_SIZE, String.valueOf(listRequest.getPageSize())); + if (listRequest.getStatus() != null) { + request.addParameter(MATERIAL_STATUS, listRequest.getStatus().toString()); + } + if (listRequest.getBeginTime() != null) { + request.addParameter(LIST_BEGIN_TIME, + DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(listRequest.getBeginTime())); + } + if (listRequest.getEndTime() != null) { + request.addParameter(LIST_END_TIME, + DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(listRequest.getEndTime())); + } + return invokeHttpClient(request, ListByPageResponse.class); + } + + /** + * Get a single draft. + */ + public GetDraftResponse getSingleDraft(long id) { + GetDraftRequest request = GetDraftRequest.of(id); + InternalRequest draftAndTimeline = this.createRequest(request, HttpMethodName.GET, MATLIB, + String.valueOf(request.getId()), MATLIB_DRAFT_TIMELINE); + return invokeHttpClient(draftAndTimeline, GetDraftResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/BvwClientConfiguration.java b/src/main/java/com/baidubce/services/bvw/BvwClientConfiguration.java new file mode 100644 index 00000000..f712ad70 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/BvwClientConfiguration.java @@ -0,0 +1,44 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.auth.DefaultBceCredentials; + +/** + * Extended client configuration for bvw service. + */ +public class BvwClientConfiguration extends BceClientConfiguration { + + /** + * Set bvw credentials. + * + * @param credentials The default credentials + * @return A BvwClientConfiguration instance. + */ + public BvwClientConfiguration withCredentials(DefaultBceCredentials credentials) { + this.setCredentials(credentials); + return this; + } + + /** + * Set bvw endpoint. + * @param endpoint The service endpoint URL to which the client will connect. + * @return A BvwClientConfiguration instance. + */ + public BvwClientConfiguration withEndpoint(String endpoint) { + this.setEndpoint(endpoint); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/BvwErrorResponseHandler.java b/src/main/java/com/baidubce/services/bvw/BvwErrorResponseHandler.java new file mode 100644 index 00000000..6aad969d --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/BvwErrorResponseHandler.java @@ -0,0 +1,76 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw; + +import java.io.InputStream; + +import com.baidubce.BceErrorResponse; +import com.baidubce.BceServiceException; +import com.baidubce.BceServiceException.ErrorType; +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.util.JsonUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * HTTP error response handler for Baidu BCE responses. + */ +public class BvwErrorResponseHandler implements HttpResponseHandler { + + private static Logger logger = LoggerFactory.getLogger(BvwErrorResponseHandler.class); + + /** + * Bvw Implementation of HttpResponseHandler. + * + * @param httpResponse The http response + * @param response The bce response + * @return If there is a next handle + * @throws Exception JsonMappingException or JsonParseException + */ + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + if (httpResponse.getStatusCode() / 100 == HttpStatus.SC_OK / 100) { + // not an error + return false; + } + BceServiceException bse = null; + InputStream content = httpResponse.getContent(); + if (content != null && (response.getMetadata().getContentLength() > 0 + || "chunked".equalsIgnoreCase(response.getMetadata().getTransferEncoding()) + && response.getMetadata().getContentType().toLowerCase().contains("application/json"))) { + BceErrorResponse bceErrorResponse = JsonUtils.loadFrom(content, BceErrorResponse.class); + if (bceErrorResponse.getMessage() != null) { + bse = new BceServiceException(bceErrorResponse.getMessage()); + bse.setErrorCode(bceErrorResponse.getCode()); + bse.setRequestId(bceErrorResponse.getRequestId()); + } + content.close(); + } + if (bse == null) { + bse = new BceServiceException(httpResponse.getStatusText()); + bse.setRequestId(response.getMetadata().getBceRequestId()); + } + bse.setStatusCode(httpResponse.getStatusCode()); + if (bse.getStatusCode() >= 500) { + bse.setErrorType(ErrorType.Service); + } else { + bse.setErrorType(ErrorType.Client); + } + logger.error("Response metadata: {}", response.getMetadata()); + throw bse; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/BvwMetadataResponseHandler.java b/src/main/java/com/baidubce/services/bvw/BvwMetadataResponseHandler.java new file mode 100644 index 00000000..d8a6a879 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/BvwMetadataResponseHandler.java @@ -0,0 +1,62 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.model.media.MediaBaseResponse; +import com.baidubce.services.bvw.model.notification.NotificationBaseResponse; +import com.baidubce.services.bvw.model.workflow.WorkflowBaseResponse; + +/** + * The bvw metadata response handler. + */ +public class BvwMetadataResponseHandler implements HttpResponseHandler { + + /** + * Bvw Implementation of HttpResponseHandler. When server return a empty body, + * wo should set content-length to 0 and transfer-encoding to null. + * + * @param httpResponse The http response + * @param response The bce response + * @return If there is a next handle + * @throws Exception JsonMappingException or JsonParseException + */ + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + if (response.getMetadata() instanceof BvwResponseMetadata) { + BvwResponseMetadata metadata = (BvwResponseMetadata) response.getMetadata(); + if (null != httpResponse.getHeader("x-bce-error-code")) { + metadata.setBceErrorCode(httpResponse.getHeader("x-bce-error-code")); + } + if (null != httpResponse.getHeader("x-bce-error-message")) { + metadata.setBceErrorMessage(httpResponse.getHeader("x-bce-error-message")); + } + } + if (!(response instanceof NotificationBaseResponse + || response instanceof MediaBaseResponse + || response instanceof WorkflowBaseResponse)) { + return false; + } + if ((null != response.getMetadata().getContentType() + && response.getMetadata().getContentType().toLowerCase().contains("text/plain")) + && -1 == response.getMetadata().getContentLength()) { + response.getMetadata().setContentType(null); + response.getMetadata().setContentLength(0); + response.getMetadata().setTransferEncoding(null); + } + return false; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/BvwResponseMetadata.java b/src/main/java/com/baidubce/services/bvw/BvwResponseMetadata.java new file mode 100644 index 00000000..12be7713 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/BvwResponseMetadata.java @@ -0,0 +1,57 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw; + +import com.baidubce.BceResponseMetadata; + +/** + * The bvw response metadata. + */ +public class BvwResponseMetadata extends BceResponseMetadata { + + /** + * The x-bce-error-code in http header. + */ + private String bceErrorCode; + /** + * The x-bce-error-message in http header. + */ + private String bceErrorMessage; + + public String getBceErrorCode() { + return bceErrorCode; + } + + public void setBceErrorCode(String bceErrorCode) { + this.bceErrorCode = bceErrorCode; + } + + public String getBceErrorMessage() { + return bceErrorMessage; + } + + public void setBceErrorMessage(String bceErrorMessage) { + this.bceErrorMessage = bceErrorMessage; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(super.toString()); + sb.deleteCharAt(sb.lastIndexOf("]")); + return sb.append(",\n") + .append(" bceErrorCode=").append(bceErrorCode).append(",\n") + .append(" bceErrorMessage=").append(bceErrorMessage).append("]") + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/constants/MatlibConstants.java b/src/main/java/com/baidubce/services/bvw/constants/MatlibConstants.java new file mode 100644 index 00000000..153cf3bb --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/constants/MatlibConstants.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.constants; + +public class MatlibConstants { + + public static final String PREFIX_360P = "360p"; + public static final String PREFIX_720P = "720p"; + public static final String PREFIX_AUDIO = "audio"; + public static final String SUFFIX_VIDEO = ".mp4"; + public static final String SUFFIX_AUDIO = ".mp3"; + public static final String DATE_MINUTE_FORMAT = "yyyyMMddHHmm"; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bvw/model/common/ListByPageResponse.java b/src/main/java/com/baidubce/services/bvw/model/common/ListByPageResponse.java new file mode 100644 index 00000000..c57d9292 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/common/ListByPageResponse.java @@ -0,0 +1,92 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.common; + +import java.util.Collection; +import java.util.LinkedList; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * List By Page Response, contains page content, page number, + * page size and total count. + * @param The page content model. + */ +public class ListByPageResponse extends AbstractBceResponse { + + /** + * The list page content. + */ + private Collection data = new LinkedList(); + /** + * The page number of list by page request. + */ + private int pageNo = 1; + /** + * The number of element in each page. + */ + private int pageSize = 0; + /** + * The total count. + */ + private long totalCount = 0L; + + public ListByPageResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public Collection getData() { + return data; + } + + public void setData(Collection data) { + this.data = data; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public long getTotalCount() { + return totalCount; + } + + public void setTotalCount(long totalCount) { + this.totalCount = totalCount; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("data", data) + .append("pageNo", pageNo) + .append("pageSize", pageSize) + .append("totalCount", totalCount) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/common/UtcTime.java b/src/main/java/com/baidubce/services/bvw/model/common/UtcTime.java new file mode 100644 index 00000000..148b323d --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/common/UtcTime.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.fasterxml.jackson.annotation.JacksonAnnotationsInside; +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * Json format timestamp to utc. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@JacksonAnnotationsInside +@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") +public @interface UtcTime { +} diff --git a/src/main/java/com/baidubce/services/bvw/model/keyframe/CdnDomainVO.java b/src/main/java/com/baidubce/services/bvw/model/keyframe/CdnDomainVO.java new file mode 100644 index 00000000..3be9ca62 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/keyframe/CdnDomainVO.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.keyframe; + +/** + * model of cdn domain + */ +public class CdnDomainVO { + /** + * cdn's name + */ + private String domain; + /** + * support https or not + */ + private boolean enableHttps; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public boolean isEnableHttps() { + return enableHttps; + } + + public void setEnableHttps(boolean enableHttps) { + this.enableHttps = enableHttps; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameDescAddRequest.java b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameDescAddRequest.java new file mode 100644 index 00000000..d419e8e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameDescAddRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.keyframe; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * request model for add keyframe + */ +public class KeyFrameDescAddRequest extends AbstractBceRequest { + + private List tasks; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public static class TaskAndKeyFrameDesc { + /** + * taskIds in videoWorks + */ + private List taskIds; + /** + * keyframe's detail + */ + private List keyFrameDesc; + + public List getTaskIds() { + return taskIds; + } + + public void setTaskIds(List taskIds) { + this.taskIds = taskIds; + } + + public List getKeyFrameDesc() { + return keyFrameDesc; + } + + public void setKeyFrameDesc(List keyFrameDesc) { + this.keyFrameDesc = keyFrameDesc; + } + } + + public List getTasks() { + return tasks; + } + + public void setTasks( + List tasks) { + this.tasks = tasks; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameDescGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameDescGetResponse.java new file mode 100644 index 00000000..3085d43d --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameDescGetResponse.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.keyframe; + +import java.util.Collections; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * response of keyframe description + */ +public class KeyFrameDescGetResponse extends AbstractBceResponse { + /** + * mediaId in videoWorks + */ + private String mediaId; + /** + * workflowInstance's id + */ + private String instanceId; + /** + * keyframe's detail + */ + private List tasks; + + public static KeyFrameDescGetResponse of(String mediaId, String instanceId, List tasks) { + KeyFrameDescGetResponse keyFrameDescGetResponse = new KeyFrameDescGetResponse(); + keyFrameDescGetResponse.setMediaId(mediaId); + keyFrameDescGetResponse.setInstanceId(instanceId); + keyFrameDescGetResponse.setTasks(tasks); + return keyFrameDescGetResponse; + } + + public static KeyFrameDescGetResponse of(String mediaId, String instanceId) { + return of(mediaId, instanceId, Collections.EMPTY_LIST); + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameDescVO.java b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameDescVO.java new file mode 100644 index 00000000..b77f5d59 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameDescVO.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.keyframe; + +/** + * keyframe detail vo + */ +public class KeyFrameDescVO { + /** + * keyframe's offset + */ + private Long offset; + /** + * "{\"desc\":\"keyframe description\",\"objectKey\":\"bos thumbnail key\",\"thumb\":\"thumbnail url\", + * \"duration\":1}" + */ + private String content; + + public Long getOffset() { + return offset; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameTaskVO.java b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameTaskVO.java new file mode 100644 index 00000000..7a8a0c2e --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameTaskVO.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bvw.model.keyframe; + +import java.util.List; + +/** + * keyframe task vo + */ +public class KeyFrameTaskVO { + /** + * taskId in videoWorks + */ + private String taskId; + /** + * taskStage's name in videoWorks + */ + private String stageName; + /** + * bos bucket + */ + private String targetBucket; + /** + * bos keyframe' thumbnail key in bucket + */ + private List targetKeys; + /** + * cdn's List + */ + private List domains; + /** + * keyframe list + */ + private List keyFrameDesc; + /** + * video's preSign url + */ + private List preSignedUrls; + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + public String getTargetBucket() { + return targetBucket; + } + + public void setTargetBucket(String targetBucket) { + this.targetBucket = targetBucket; + } + + public List getTargetKeys() { + return targetKeys; + } + + public void setTargetKeys(List targetKeys) { + this.targetKeys = targetKeys; + } + + public List getDomains() { + return domains; + } + + public void setDomains(List domains) { + this.domains = domains; + } + + public List getKeyFrameDesc() { + return keyFrameDesc; + } + + public void setKeyFrameDesc(List keyFrameDesc) { + this.keyFrameDesc = keyFrameDesc; + } + + public List getPreSignedUrls() { + return preSignedUrls; + } + + public void setPreSignedUrls(List preSignedUrls) { + this.preSignedUrls = preSignedUrls; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameUrlResponse.java b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameUrlResponse.java new file mode 100644 index 00000000..b3e72dbb --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/keyframe/KeyFrameUrlResponse.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.bvw.model.keyframe; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * response of keyframe task description + */ +public class KeyFrameUrlResponse extends AbstractBceResponse { + /** + * mediaId in videoworks + */ + private String mediaId; + /** + * workflow instance id in videoworks + */ + private String instanceId; + /** + * task list + */ + private List tasks; + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/DraftListRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/DraftListRequest.java new file mode 100644 index 00000000..2ffdb499 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/DraftListRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bvw.model.matlib; + +import java.util.Date; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class DraftListRequest extends AbstractBceRequest { + + private MatlibTaskStatus status; + + private Date beginTime; + + private Date endTime; + + private int pageNo; + + private int pageSize; + + public static DraftListRequest of(int pageNo, int pageSize) { + return of(pageNo, pageSize, null, null, null); + } + + public static DraftListRequest of(int pageNo, int pageSize, MatlibTaskStatus status, Date beginTime, Date endTime) { + DraftListRequest request = new DraftListRequest(); + request.setStatus(status); + request.setBeginTime(beginTime); + request.setEndTime(endTime); + request.setPageNo(pageNo); + request.setPageSize(pageSize); + return request; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/GetDraftRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/GetDraftRequest.java new file mode 100644 index 00000000..4a778047 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/GetDraftRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Draft request. + */ +public class GetDraftRequest extends AbstractBceRequest { + private long id; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public GetDraftRequest(long id) { + this.id = id; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public static GetDraftRequest of(long id) { + return new GetDraftRequest(id); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/GetDraftResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/GetDraftResponse.java new file mode 100644 index 00000000..1531dd70 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/GetDraftResponse.java @@ -0,0 +1,95 @@ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.model.matlib.timeline.Timeline; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.Collections; +import java.util.List; + +/** + * Get a single draft response. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class GetDraftResponse extends AbstractBceResponse { + private Timeline timeline = new Timeline(); + + private List resourceList = Collections.emptyList(); + + private String title; + + private String ratio; + + private String coverBucket; + + private String coverKey; + + private String endpoint; + + private String lastUpdateTime; + + public Timeline getTimeline() { + return timeline; + } + + public void setTimeline(Timeline timeline) { + this.timeline = timeline; + } + + public List getResourceList() { + return resourceList; + } + + public void setResourceList(List resourceList) { + this.resourceList = resourceList; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getRatio() { + return ratio; + } + + public void setRatio(String ratio) { + this.ratio = ratio; + } + + public String getCoverBucket() { + return coverBucket; + } + + public void setCoverBucket(String coverBucket) { + this.coverBucket = coverBucket; + } + + public String getCoverKey() { + return coverKey; + } + + public void setCoverKey(String coverKey) { + this.coverKey = coverKey; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(String lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/GetMaterialResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/GetMaterialResponse.java new file mode 100644 index 00000000..c4c53fc4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/GetMaterialResponse.java @@ -0,0 +1,264 @@ +package com.baidubce.services.bvw.model.matlib; + +import java.util.List; + +/** + * Material response. + */ +public class GetMaterialResponse { + + private String id; + private String userId; + private String actualUserId; + private String saasType; + private String infoType; + private String mediaType; + private String sourceType; + private String status; + private String title; + private String sourceUrl; + private String sourceUrl360p; + private String audioUrl; + private List thumbnailList; + private List subtitleUrls; + private String createTime; + private String updateTime; + private Double duration; + private Integer height; + private Integer width; + private Long fileSizeInByte; + private String bucket; + private String key; + private String key360p; + private String key720p; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getActualUserId() { + return actualUserId; + } + + public void setActualUserId(String actualUserId) { + this.actualUserId = actualUserId; + } + + public String getSaasType() { + return saasType; + } + + public void setSaasType(String saasType) { + this.saasType = saasType; + } + + public String getInfoType() { + return infoType; + } + + public void setInfoType(String infoType) { + this.infoType = infoType; + } + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getSourceType() { + return sourceType; + } + + public void setSourceType(String sourceType) { + this.sourceType = sourceType; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSourceUrl() { + return sourceUrl; + } + + public void setSourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + } + + public String getSourceUrl360p() { + return sourceUrl360p; + } + + public void setSourceUrl360p(String sourceUrl360p) { + this.sourceUrl360p = sourceUrl360p; + } + + public String getAudioUrl() { + return audioUrl; + } + + public void setAudioUrl(String audioUrl) { + this.audioUrl = audioUrl; + } + + public List getThumbnailList() { + return thumbnailList; + } + + public void setThumbnailList(List thumbnailList) { + this.thumbnailList = thumbnailList; + } + + public List getSubtitleUrls() { + return subtitleUrls; + } + + public void setSubtitleUrls(List subtitleUrls) { + this.subtitleUrls = subtitleUrls; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public Double getDuration() { + return duration; + } + + public void setDuration(Double duration) { + this.duration = duration; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public Long getFileSizeInByte() { + return fileSizeInByte; + } + + public void setFileSizeInByte(Long fileSizeInByte) { + this.fileSizeInByte = fileSizeInByte; + } + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getKey360p() { + return key360p; + } + + public void setKey360p(String key360p) { + this.key360p = key360p; + } + + public String getKey720p() { + return key720p; + } + + public void setKey720p(String key720p) { + this.key720p = key720p; + } + + public String getAudioKey() { + return audioKey; + } + + public void setAudioKey(String audioKey) { + this.audioKey = audioKey; + } + + public List getThumbnailKeys() { + return thumbnailKeys; + } + + public void setThumbnailKeys(List thumbnailKeys) { + this.thumbnailKeys = thumbnailKeys; + } + + public List getSubtitles() { + return subtitles; + } + + public void setSubtitles(List subtitles) { + this.subtitles = subtitles; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + private String audioKey; + private List thumbnailKeys; + private List subtitles; + private String endpoint; + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialBaseResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialBaseResponse.java new file mode 100644 index 00000000..987d5453 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialBaseResponse.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019-2021 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; + +/** + * Base material response. + */ +public class MaterialBaseResponse extends AbstractBceResponse { + + public MaterialBaseResponse() { + this.metadata = new BvwResponseMetadata(); + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialGetRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialGetRequest.java new file mode 100644 index 00000000..4b4dacbb --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialGetRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request of getting material from material library. + */ +public class MaterialGetRequest extends AbstractBceRequest { + + /** + * The material id in material library. + */ + private String materialId; + + public MaterialGetRequest() { + } + + public MaterialGetRequest(String materialId) { + this.materialId = materialId; + } + + public String getMaterialId() { + return materialId; + } + + public void setMaterialId(String materialId) { + this.materialId = materialId; + } + + @Override + public String toString() { + return "MaterialGetRequest{" + + "materialId='" + materialId + '\'' + + '}'; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialGetResponse.java new file mode 100644 index 00000000..a9d40d23 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialGetResponse.java @@ -0,0 +1,333 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response of getting material from material library. + */ +public class MaterialGetResponse extends AbstractBceResponse { + + /** + * The material id + */ + private String id; + /** + * The user id + */ + private String userId; + /** + * The info type of material, only support ENTERTAINMENT now. + */ + private String infoType; + /** + * The media type, contains video/audio/image. + */ + private String mediaType; + /** + * The media source type, contains USER/SERVICE. + */ + private String sourceType; + /** + * The statue of processing media source, contains PROCESSING/FAILED/FINISHED. + */ + private String status; + /** + * The material title. + */ + private String title; + /** + * The media source url. + */ + private String sourceUrl; + /** + * The 360p preview url of media source. + */ + private String sourceUrl360p; + /** + * The thumbnails preview urls of media source. + */ + private List thumbnailList; + /** + * The subtitles preview urls of media source. + */ + private List subtitleUrls; + /** + * The create time of this material. + */ + private String createTime; + /** + * The update time of this material. + */ + private String updateTime; + /** + * The video or audio duration of media source. + */ + private Double duration; + /** + * The video of image height of media source. + */ + private Integer height; + /** + * The video of image width of media source. + */ + private Integer width; + /** + * The bos bucket to storage media source and process result. + */ + private String bucket; + /** + * The bos key of media source. + */ + private String key; + /** + * The bos key of 360p result. + */ + private String key360p; + /** + * The bos key of 720p result. + */ + private String key720p; + /** + * The bos key of audio result. + */ + private String audioKey; + /** + * The bos keys of thumbnail results. + */ + private List thumbnailKeys; + /** + * The bos key of subtitle results. + */ + private List subtitles; + + public MaterialGetResponse() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getInfoType() { + return infoType; + } + + public void setInfoType(String infoType) { + this.infoType = infoType; + } + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getSourceType() { + return sourceType; + } + + public void setSourceType(String sourceType) { + this.sourceType = sourceType; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSourceUrl() { + return sourceUrl; + } + + public void setSourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + } + + public String getSourceUrl360p() { + return sourceUrl360p; + } + + public void setSourceUrl360p(String sourceUrl360p) { + this.sourceUrl360p = sourceUrl360p; + } + + public List getThumbnailList() { + return thumbnailList; + } + + public void setThumbnailList(List thumbnailList) { + this.thumbnailList = thumbnailList; + } + + public List getSubtitleUrls() { + return subtitleUrls; + } + + public void setSubtitleUrls(List subtitleUrls) { + this.subtitleUrls = subtitleUrls; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public Double getDuration() { + return duration; + } + + public void setDuration(Double duration) { + this.duration = duration; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getKey360p() { + return key360p; + } + + public void setKey360p(String key360p) { + this.key360p = key360p; + } + + public String getKey720p() { + return key720p; + } + + public void setKey720p(String key720p) { + this.key720p = key720p; + } + + public String getAudioKey() { + return audioKey; + } + + public void setAudioKey(String audioKey) { + this.audioKey = audioKey; + } + + public List getThumbnailKeys() { + return thumbnailKeys; + } + + public void setThumbnailKeys(List thumbnailKeys) { + this.thumbnailKeys = thumbnailKeys; + } + + public List getSubtitles() { + return subtitles; + } + + public void setSubtitles(List subtitles) { + this.subtitles = subtitles; + } + + @Override + public String toString() { + return "MaterialGetResponse{" + + "id='" + id + '\'' + + ", userId='" + userId + '\'' + + ", infoType='" + infoType + '\'' + + ", mediaType='" + mediaType + '\'' + + ", sourceType='" + sourceType + '\'' + + ", status='" + status + '\'' + + ", title='" + title + '\'' + + ", sourceUrl='" + sourceUrl + '\'' + + ", sourceUrl360p='" + sourceUrl360p + '\'' + + ", thumbnailList=" + thumbnailList + + ", subtitleUrls=" + subtitleUrls + + ", createTime='" + createTime + '\'' + + ", updateTime='" + updateTime + '\'' + + ", duration=" + duration + + ", height=" + height + + ", width=" + width + + ", bucket='" + bucket + '\'' + + ", key='" + key + '\'' + + ", key360p='" + key360p + '\'' + + ", key720p='" + key720p + '\'' + + ", audioKey='" + audioKey + '\'' + + ", thumbnailKeys=" + thumbnailKeys + + ", subtitles=" + subtitles + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetGetRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetGetRequest.java new file mode 100644 index 00000000..56ff7b90 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetGetRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2019-2021 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request of getting material preset from material library. + */ +public class MaterialPresetGetRequest extends AbstractBceRequest { + + /** + * The material preset id in material library. + */ + private String id; + + public MaterialPresetGetRequest() { + } + + public MaterialPresetGetRequest(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public String toString() { + return "MaterialPresetGetRequest{" + + "id='" + id + '\'' + + '}'; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetGetResponse.java new file mode 100644 index 00000000..6fa05b54 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetGetResponse.java @@ -0,0 +1,98 @@ +/* + * Copyright 2019-2021 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.HashMap; + +/** + * The response of getting material fpreset rom material library. + */ +@Data +public class MaterialPresetGetResponse extends AbstractBceResponse { + + /** + * The material preset id + */ + private String id; + /** + * The statue of processing media source, contains PROCESSING/FAILED/FINISHED. + */ + private String status; + /** + * The user id + */ + private String userId; + /** + * The material preset title. + */ + private String title; + /** + * The material preset tag. + */ + private String tag; + /** + * The material preset type. + */ + private String type; + /** + * The source type. + */ + private String sourceType; + /** + * The ids of preview materials. + */ + private HashMap previewMaterialIds; + /** + * The buckets of preview materials. + */ + private HashMap previewBucket; + /** + * The keys of preview materials. + */ + private HashMap previewKeys; + /** + * The signed urls of preview materials. + */ + private HashMap previewUrls; + /** + * The id of material. + */ + private String materialId; + /** + * The bucket of material. + */ + private String bucket; + /** + * The key of material. + */ + private String key; + /** + * The url of material. + */ + private String sourceUrl; + /** + * The config of material preset. + */ + private String config; + /** + * The create time of material preset. + */ + private String createTime; + /** + * The update time of material preset. + */ + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetSearchRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetSearchRequest.java new file mode 100644 index 00000000..1b62ac83 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetSearchRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2019-2021 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request of searching material from material library. + */ +@Data +public class MaterialPresetSearchRequest extends AbstractBceRequest { + + /** + * The source type of material preset. + */ + private String sourceType; + /** + * The status of material preset. + */ + private String status; + /** + * The type of material preset. + */ + private String type; + /** + * The pageNo. + */ + private Integer pageNo; + /** + * The size for one page. + */ + private Integer pageSize; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetSearchResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetSearchResponse.java new file mode 100644 index 00000000..7f94655a --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetSearchResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright 2019-2021 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * The response of searching material from material library. + */ +@Data +public class MaterialPresetSearchResponse extends AbstractBceResponse { + + private List result; + + private int pageNo = 1; + private int pageSize = 0; + private long totalCount = 0L; + + @Data + public static class PresetResponseWrapper { + private String type; + private List addons; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetUploadResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetUploadResponse.java new file mode 100644 index 00000000..e0f9e847 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialPresetUploadResponse.java @@ -0,0 +1,49 @@ +/* + * Copyright 2019-2021 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of uploading media preset to material library. + */ +public class MaterialPresetUploadResponse extends AbstractBceResponse { + + /** + * The material preset id. + */ + private String id; + + public MaterialPresetUploadResponse() { + } + + public MaterialPresetUploadResponse(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public String toString() { + return "MatlibPresetUploadResponse{" + + "iId='" + id + '\'' + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialSearchRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialSearchRequest.java new file mode 100644 index 00000000..e99a51f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialSearchRequest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2019-2021 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request of searching material from material library. + */ +@Data +public class MaterialSearchRequest extends AbstractBceRequest { + + /** + * The info type of material. + */ + private String infoType; + /** + * The media type of material. + */ + private String mediaType; + /** + * The source type of material. + */ + private String sourceType; + /** + * The status of material. + */ + private String status; + /** + * A Part of title of target material. + */ + private String titleKeyword; + /** + * The pageNo. + */ + private Integer pageNo; + /** + * The size for one page. + */ + private Integer size; + /** + * The range of createTime. + * eg. "2019-04-07T16:00:00Z" + */ + private String begin; + /** + * The range of createTime. + * eg. "2019-04-07T16:00:00Z" + */ + private String end; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialSearchResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialSearchResponse.java new file mode 100644 index 00000000..a0f4b2ba --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MaterialSearchResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019-2021 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * The response of searching material from material library. + */ +@Data +public class MaterialSearchResponse extends AbstractBceResponse { + + private List items; + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConfigBaseRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConfigBaseRequest.java new file mode 100644 index 00000000..e216a7c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConfigBaseRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The base request of matlib config. + */ +public class MatlibConfigBaseRequest extends AbstractBceRequest { + + /** + * The matlib storage bucket. + */ + private String bucket; + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public MatlibConfigBaseRequest() { + } + + public MatlibConfigBaseRequest(String bucket) { + this.bucket = bucket; + } + + @Override + public String toString() { + return "MatlibConfigCreateRequest{" + + "bucket='" + bucket + '\'' + + '}'; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConfigBaseResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConfigBaseResponse.java new file mode 100644 index 00000000..27c97e46 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConfigBaseResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; + +/** + * The base response of matlib config. + */ +public class MatlibConfigBaseResponse extends AbstractBceResponse { + + public MatlibConfigBaseResponse() { + this.metadata = new BvwResponseMetadata(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConfigGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConfigGetResponse.java new file mode 100644 index 00000000..db2203f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConfigGetResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of get matlib config. + */ +public class MatlibConfigGetResponse extends AbstractBceResponse { + + /** + * The matlib storage bucket. + */ + private String bucket; + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + @Override + public String toString() { + return "MatlibConfigGetResponse{" + + "bucket='" + bucket + '\'' + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConstants.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConstants.java new file mode 100644 index 00000000..6a0caca3 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibConstants.java @@ -0,0 +1,9 @@ +package com.baidubce.services.bvw.model.matlib; + +/** + * Matlib constant summary. + */ +public class MatlibConstants { + public static final String PREPROCESS_WORKFLOW_BASIC = "videoworks_system_preprocess_basic"; + public static final String PREPROCESS_WORKFLOW_AUDIO = "videoworks_system_preprocess_audio"; +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskGetResponse.java new file mode 100644 index 00000000..ebe155e5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskGetResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bvw.model.matlib; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Setter +@Getter +@ToString +@NoArgsConstructor +public class MatlibTaskGetResponse extends AbstractBceResponse { + + private Long id; + + private String resMaterialId; + + private String userId; + + private String title; + + private String status; + + private String errorMessage; + + private String coverUrl ; + + private Date lastUpdateTime; + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskRequest.java new file mode 100644 index 00000000..da8b147a --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bvw.model.matlib; + +import static com.baidubce.services.bvw.constants.MatlibConstants.DATE_MINUTE_FORMAT; + +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import org.apache.commons.lang.time.DateFormatUtils; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bvw.model.matlib.timeline.Timeline; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * The request of create videoedit's draft. + */ +@Setter +@Getter +@NoArgsConstructor +public class MatlibTaskRequest extends AbstractBceRequest { + private String title = "新建作品-" + DateFormatUtils.format(System.currentTimeMillis(), DATE_MINUTE_FORMAT); + + private String ratio = "16:9"; + + private String duration = "0"; + + private Timeline timeline = new Timeline(); + + private List resourceList = Collections.emptyList(); + + private String coverBucket; + + private String coverKey; + + private Date lastUpdateTime; + + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskResponse.java new file mode 100644 index 00000000..810d49bd --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@NoArgsConstructor +@ToString +@Setter +@Getter +public class MatlibTaskResponse extends AbstractBceResponse { + + private Long id; + private Error error; +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskStatus.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskStatus.java new file mode 100644 index 00000000..f775e87f --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibTaskStatus.java @@ -0,0 +1,50 @@ +package com.baidubce.services.bvw.model.matlib; + + +public enum MatlibTaskStatus { + /** + * vidpress生产中 + */ + VIDPRESS_MAKING("pre_making"), + + /** + * 二次编辑合成中 + */ + EDITOR_MAKING("post_making"), + + /** + * 预处理中 + */ + PREPROCESS("pre_process"), + + /** + * 手动编辑中 (待合成) + */ + EDITING("editing"), + + /** + * 待入库 + */ + SUCCESS("success"), + + /** + * 已入库 + */ + SAVED("saved"), + + /** + * 已失败 + */ + FAILED("failed"); + + private String externalDescription; + + MatlibTaskStatus(String externalDescription) { + this.externalDescription = externalDescription; + } + + @Override + public String toString() { + return externalDescription; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibUploadRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibUploadRequest.java new file mode 100644 index 00000000..0234df2a --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibUploadRequest.java @@ -0,0 +1,120 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request of uploading media to material library. + */ +public class MatlibUploadRequest extends AbstractBceRequest { + + /** + * The media type,video/audio/image. + */ + private String mediaType; + /** + * The material title. + */ + private String title; + /** + * The source media in bos bucket. + */ + private String bucket; + /** + * The source media in bos key. + */ + private String key; + /** + * The notification name which to callback when process of uploading media is completed; + * if none, will not callback. + */ + private String notification; + + public MatlibUploadRequest() { + } + + public MatlibUploadRequest(String mediaType, String title, String bucket, String key) { + this.mediaType = mediaType; + this.title = title; + this.bucket = bucket; + this.key = key; + } + + public MatlibUploadRequest(String mediaType, String title, String bucket, String key, String notification) { + this.mediaType = mediaType; + this.title = title; + this.bucket = bucket; + this.key = key; + this.notification = notification; + } + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + @Override + public String toString() { + return "MatlibUploadRequest{" + + "mediaType='" + mediaType + '\'' + + ", title='" + title + '\'' + + ", bucket='" + bucket + '\'' + + ", key='" + key + '\'' + + ", notification='" + notification + '\'' + + '}'; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibUploadResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibUploadResponse.java new file mode 100644 index 00000000..7bb46671 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/MatlibUploadResponse.java @@ -0,0 +1,49 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of uploading media to material library. + */ +public class MatlibUploadResponse extends AbstractBceResponse { + + /** + * The material id. + */ + private String materialId; + + public MatlibUploadResponse() { + } + + public MatlibUploadResponse(String materialId) { + this.materialId = materialId; + } + + public String getMaterialId() { + return materialId; + } + + public void setMaterialId(String materialId) { + this.materialId = materialId; + } + + @Override + public String toString() { + return "MatlibUploadResponse{" + + "materialId='" + materialId + '\'' + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/Per.java b/src/main/java/com/baidubce/services/bvw/model/matlib/Per.java new file mode 100644 index 00000000..1ebfc156 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/Per.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +/** + * The class to enumerate all the supported speech style in text to video. + */ +public enum Per { + + BASE_DUXIAOYU("基础语音库——度小宇", 1), + BASE_DUXIAOMEI("基础语音库——度小美", 0), + BASE_DUXIAOYAO("基础语音库——度逍遥", 3), + BASE_DUYAYA("基础语音库——度丫丫", 4), + QUALITY_DUXIAOYAO("精品语音库——度逍遥", 5003), + QUALITY_DUXIAOLU("精品语音库——度小鹿", 5118), + QUALITY_DUBOWEN("精品语音库——度博文", 106), + QUALITY_DUXIAOTONG("精品语音库——度小童", 110), + QUALITY_DUXIAOMENG("精品语音库——度小萌", 111), + QUALITY_DUMIDUO("精品语音库——度米朵", 103), + QUALITY_DUXIAOJIAO("精品语音库——度小娇", 5); + + String desc; + int code; + + Per(String desc, int code) { + this.desc = desc; + this.code = code; + } + + public String getDesc() { + return desc; + } + + public int getCode() { + return code; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/Text2AudioRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/Text2AudioRequest.java new file mode 100644 index 00000000..cafde78f --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/Text2AudioRequest.java @@ -0,0 +1,132 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * The request of text to audio. + */ +public class Text2AudioRequest extends AbstractBceRequest { + + /** + * 文字内容,支持多段文字,最多100段文字,每段文字最大长度2048 + */ + private List texts; + /** + * 语速,取值0-15,默认为5中语速 + */ + private int spd = 5; + /** + * 音调,取值0-15,默认为5中语调 + */ + private int pit = 5; + /** + * 音量,取值0-15,默认为5中音量 + */ + private int vol = 5; + /** + * 发音人类型 + */ + private Per per; + /** + * 保存的bucket,若不填默认使用MatlibConfig的bucket + */ + private String bucket; + /** + * 试听,true表示为试听请求,将直接返回音频base64,不做存储 + */ + private boolean audition; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public Text2AudioRequest() { + } + + public Text2AudioRequest(List texts, Per per) { + this.texts = texts; + this.per = per; + } + + public Text2AudioRequest(List texts, int spd, int pit, int vol, Per per) { + this.texts = texts; + this.spd = spd; + this.pit = pit; + this.vol = vol; + this.per = per; + } + + public List getTexts() { + return texts; + } + + public void setTexts(List texts) { + this.texts = texts; + } + + public int getSpd() { + return spd; + } + + public void setSpd(int spd) { + this.spd = spd; + } + + public int getPit() { + return pit; + } + + public void setPit(int pit) { + this.pit = pit; + } + + public int getVol() { + return vol; + } + + public void setVol(int vol) { + this.vol = vol; + } + + public Per getPer() { + return per; + } + + public void setPer(Per per) { + this.per = per; + } + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public boolean isAudition() { + return audition; + } + + public void setAudition(boolean audition) { + this.audition = audition; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/Text2AudioResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/Text2AudioResponse.java new file mode 100644 index 00000000..2dc5e9e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/Text2AudioResponse.java @@ -0,0 +1,157 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.Arrays; +import java.util.List; + +/** + * The response of text to audio. + */ +public class Text2AudioResponse extends AbstractBceResponse { + + /** + * 文字转语音的返回结果 + */ + private List data; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + @Override + public String toString() { + return "Text2AudioResponse{" + + "data=" + data + + '}'; + } + + public static class SingleText2AudioResponse { + /** + * 输入的text + */ + private String text; + /** + * 返回错误信息, 仅异常时提供 + */ + private String result; + /** + * 返回音频二进制信息, 仅异常时提供 + */ + private byte[] data; + /** + * 音频转存bos bucket + */ + private String bucket; + /** + * 音频转存bos key + */ + private String key; + /** + * 预览链接 + */ + private String preSignUrl; + /** + * 语音时长 + */ + private Integer duration; + /** + * 语音时长(ms) + */ + private Integer durationInMs; + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + public byte[] getData() { + return data; + } + + public void setData(byte[] data) { + this.data = data; + } + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getPreSignUrl() { + return preSignUrl; + } + + public void setPreSignUrl(String preSignUrl) { + this.preSignUrl = preSignUrl; + } + + public Integer getDuration() { + return duration; + } + + public void setDuration(Integer duration) { + this.duration = duration; + } + public Integer getDurationInMs() { + return durationInMs; + } + + public void setDurationInMs(Integer durationInMs) { + this.durationInMs = durationInMs; + } + + @Override + public String toString() { + return "SingleText2AudioResponse{" + + "text='" + text + '\'' + + ", result='" + result + '\'' + + ", data=" + Arrays.toString(data) + + ", bucket='" + bucket + '\'' + + ", key='" + key + '\'' + + ", preSignUrl='" + preSignUrl + '\'' + + ", duration=" + duration + + ", durationInMs=" + durationInMs + + '}'; + } + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/VideoGenerationRequest.java b/src/main/java/com/baidubce/services/bvw/model/matlib/VideoGenerationRequest.java new file mode 100644 index 00000000..41c7813e --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/VideoGenerationRequest.java @@ -0,0 +1,125 @@ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class VideoGenerationRequest extends AbstractBceRequest { + + /** + * 一组视频生成任务的track + */ + @NotNull + private List tracks; + /** + * 发音人类型 + */ + @NotNull + private Per ttsPer; + /** + * 结果bucket + */ + @NotNull + private String resultBucket; + /** + * 片头bucket + */ + private String beginBucket; + /** + * 片头key + */ + private String beginKey; + /** + * 片尾bucket + */ + private String endBucket; + /** + * 片尾key + */ + private String endKey; + /** + * 水印bucket + */ + private String logoBucket; + /** + * 水印key + */ + private String logoKey; + /** + * 水印边缘距离,会同时指定上方和左右的距离 + */ + private Integer logoMargin = 0; + /** + * 水印位置 + */ + private String logoPos = "top-left"; + /** + * 背景音乐bucket + */ + private String bgMusicBucket; + /** + * 背景音乐key + */ + private String bgMusicKey; + + /** + * 回调通知名 + */ + private String notification; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + + @Data + @JsonInclude(value = JsonInclude.Include.NON_NULL) + private static class VideoGenerationTrack { + + /** + * 文本对应的素材一组素材 + */ + private List materials; + /** + * 素材对应的文本 + */ + private String txt; + + } + + @Data + @JsonInclude(value = JsonInclude.Include.NON_NULL) + private static class TrackMaterial { + + /** + * 素材bucket + */ + private String bucket; + /** + * 素材key + */ + private String key; + /** + * 素材类型 + */ + private Type type; + + } + + public enum Type { + video, + image + } + + + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/VideoGenerationResponse.java b/src/main/java/com/baidubce/services/bvw/model/matlib/VideoGenerationResponse.java new file mode 100644 index 00000000..d52d371b --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/VideoGenerationResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.bvw.model.matlib; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Wither; + +@Data +@Wither +@AllArgsConstructor +@NoArgsConstructor +public class VideoGenerationResponse extends AbstractBceResponse { + + /** + * 任务Id + */ + private Long editId; + /** + * 结果视频时长 + */ + private Double duration; + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/BaijiahaoTimeline.java b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/BaijiahaoTimeline.java new file mode 100644 index 00000000..0de6f0f2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/BaijiahaoTimeline.java @@ -0,0 +1,67 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib.timeline; + +import com.baidubce.services.bos.BosClient; +import lombok.Data; +import java.util.List; + + +/** + * The model of timeline information. + */ +@Data +public class BaijiahaoTimeline { + + + /** + * The video track of timeline. + */ + private List video; + /** + * The audio track of timeline. + */ + private List audio; + /** + * The sticker track of timeline. + */ + private List sticker; + /** + * The subtitle track of timeline. + */ + private List subtitle; + + /** + * Calculate url for BOS object of timeline. + * + * @param bosClient User's BOS client. + */ + public void generalSignedUrl(BosClient bosClient) { + if (video != null) { + for (MediaPair pair : video) { + pair.generalSignedUrl(bosClient); + } + } + if (audio != null) { + for (MediaPair pair : audio) { + pair.generalSignedUrl(bosClient); + } + } + if (sticker != null) { + for (MediaPair pair : sticker) { + pair.generalSignedUrl(bosClient); + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/MediaPair.java b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/MediaPair.java new file mode 100644 index 00000000..7ff10d8e --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/MediaPair.java @@ -0,0 +1,59 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib.timeline; + +import com.baidubce.services.bos.BosClient; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Wither; +import java.util.List; + +/** + * The model of material pair. + */ +@Data +@Wither +@AllArgsConstructor +@NoArgsConstructor +public class MediaPair { + + /** + * The key of track + */ + private String key; + + /** + * The material of track + */ + private List list; + + /** + * The master flag + */ + private String isMaster; + + /** + * Calculate url for BOS object of material pair. + * + * @param bosClient User's BOS client. + */ + public void generalSignedUrl(BosClient bosClient) { + if (list != null) { + for (TimelineMaterial material : list) { + material.generalSignedUrl(bosClient); + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/Timeline.java b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/Timeline.java new file mode 100644 index 00000000..e85dafde --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/Timeline.java @@ -0,0 +1,56 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib.timeline; + +import com.baidubce.services.bos.BosClient; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +/** + * The model of timeline. + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class Timeline { + + /** + * The timeline information + */ + private BaijiahaoTimeline timeline; + /** + * The timeline meta + */ + private Object meta; + + /** + * Calculate url for BOS object of timeline. + * + * @param bosClient User's BOS client. + */ + public void generalSignedUrl(BosClient bosClient) { + if (timeline != null) { + timeline.generalSignedUrl(bosClient); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/TimelineMaterial.java b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/TimelineMaterial.java new file mode 100644 index 00000000..6ea6f1cc --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/TimelineMaterial.java @@ -0,0 +1,93 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib.timeline; + +import com.baidubce.services.bos.BosClient; +import lombok.Data; + + +/** + * The model of timeline material. + */ +@Data +public class TimelineMaterial { + + /** + * The start time of material + */ + private Double start; + /** + * The end time of material + */ + private Double end; + /** + * The show start time of material + */ + private Double showStart; + /** + * The show end time of material + */ + private Double showEnd; + /** + * The duration of material + */ + private Double duration; + /** + * The x-position of material + */ + private Double xpos; + /** + * The y-position of material + */ + private Double ypos; + /** + * The show width of material + */ + private Integer width; + /** + * The show height of material + */ + private Integer height; + /** + * The mediainfo of material + */ + private TimelineMediaInfo mediaInfo; + /** + * The type of material + */ + private String type; + /** + * The uid of material + */ + private String uid; + /** + * The name of material + */ + private String name = ""; + /** + * The extra info of material + */ + private Object extInfo; + + + /** + * Calculate url for BOS object of timeline material. + * + * @param bosClient User's BOS client. + */ + public void generalSignedUrl(BosClient bosClient) { + if (mediaInfo != null) { + mediaInfo.generalSignedUrl(bosClient); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/TimelineMediaInfo.java b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/TimelineMediaInfo.java new file mode 100644 index 00000000..d1cc5706 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/matlib/timeline/TimelineMediaInfo.java @@ -0,0 +1,234 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.matlib.timeline; + +import com.baidubce.services.bos.BosClient; +import lombok.Data; +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.services.bvw.constants.MatlibConstants.PREFIX_360P; +import static com.baidubce.services.bvw.constants.MatlibConstants.PREFIX_AUDIO; +import static com.baidubce.services.bvw.constants.MatlibConstants.SUFFIX_AUDIO; +import static com.baidubce.services.bvw.constants.MatlibConstants.SUFFIX_VIDEO; + + +/** + * The model of material mediainfo. + */ +@Data +public class TimelineMediaInfo { + + /** + * The file type of material + */ + private String fileType; + /** + * The source type of material + */ + private String sourceType; + /** + * The source url of material + */ + private String sourceUrl; + /** + * The url of material's audio + */ + private String audioUrl; + /** + * The BOS bucket of material + */ + private String bucket; + /** + * The BOS key of material + */ + private String key; + /** + * The BOS key of material's audio + */ + private String audioKey; + /** + * The instanceId of material (for preprocessing) + */ + private String instanceId; + /** + * The cover of material + */ + private String coverImage; + /** + * The duration of material + */ + private Double duration; + /** + * The width of material + */ + private Integer width; + /** + * The height of material + */ + private Integer height; + /** + * The error message of material + */ + private String errmsg; + /** + * The status of material + */ + private String status; + /** + * The progress of material + */ + private String progress; + /** + * The action of material + */ + private String action; + /** + * The size of material + */ + private Integer size; + /** + * The name of material + */ + private String name = ""; + /** + * The thumbnail prefix of material + */ + private String thumbnailPrefix; + /** + * The thumbnail keys of material + */ + private List thumbnailKeys; + /** + * The thumbnail urls of material + */ + private List thumbnailList = new ArrayList(); + /** + * The subtitle keys of material + */ + private List subtitleKeys; + /** + * The media id of material + */ + private String mediaId = ""; + + /** + * offstandard is true when material has not been preprocessed + */ + private boolean offstandard; + + /** + * Calculate url for BOS object of material mediainfo. + * + * @param bosClient User's BOS client. + */ + public void generalSignedUrl (BosClient bosClient) { + + sourceUrl = ""; + audioUrl = ""; + if (!StringUtils.isBlank(bucket) && !StringUtils.isBlank(key)) { + String tmpKey = addResolutionPrefix(fileType, key, offstandard); + sourceUrl = bosClient.generatePresignedUrl(bucket, tmpKey, 7200).toString(); + if (StringUtils.isBlank(audioKey)) { + audioKey = addResolutionPrefix("audio", key); + } + audioUrl = bosClient.generatePresignedUrl(bucket, audioKey, 7200).toString(); + } + if (!StringUtils.isBlank(bucket) && thumbnailKeys != null) { + thumbnailPrefix = thumbnailPrefix == null ? "" : thumbnailPrefix; + thumbnailList = new ArrayList(); + for (String key : thumbnailKeys) { + String thumbnailUrl = bosClient.generatePresignedUrl(bucket, + thumbnailPrefix + key, 7200).toString(); + thumbnailList.add(thumbnailUrl); + } + } + // 设置封面图 + coverImage = ""; + if ("image".equals(fileType)) { + coverImage = sourceUrl; + } else if ("video".equals(fileType) + && thumbnailList != null + && thumbnailList.size() > 0) { + int index = thumbnailList.size() * 2 / 3; + coverImage = thumbnailList.get(index); + } + } + + /** + * add prefix for object name + * + * @param type file type. + * @param key object key. + * @param offstandard whether or not been preprocessed. + */ + private String addResolutionPrefix(String type, String key, Boolean offstandard) { + if (offstandard) { + return key; + } + return addResolutionPrefix(type, key); + } + + /** + * add prefix for object name + * + * @param type file type. + * @param key object key. + */ + private String addResolutionPrefix(String type, String key) { + if (type == null) { + return key; + } + if ("video".equals(type)) { + return addResolutionPrefix(PREFIX_360P, SUFFIX_VIDEO, key); + } else if ("audio".equals(type)) { + return addResolutionPrefix(PREFIX_AUDIO, SUFFIX_AUDIO, key); + } else { + return key; + } + } + + /** + * add prefix for object name + * + * @param prefix prefix of key. + * @param suffix suffix of key. + * @param key object key. + */ + private String addResolutionPrefix(String prefix, String suffix, String key) { + if (key == null) { + return null; + } + String result = key; + if (prefix != null) { + int index = result.lastIndexOf("."); + if (-1 != index) { + result = result.substring(0, index); + } + index = result.lastIndexOf("/"); + if (-1 == index) { + result = prefix + "/" + result; + } else if (0 == index) { + result = prefix + "/" + result.substring(1); + } else { + result = result.substring(0, index + 1) + prefix + "/" + + result.substring(index + 1); + } + result = result + suffix; + } + return result; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaBaseRequest.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaBaseRequest.java new file mode 100644 index 00000000..b98f02f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaBaseRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Base media request. + */ +public class MediaBaseRequest extends AbstractBceRequest { + + /** + * The media id. + */ + private String mediaId; + + /** + * Construct a base media request with specified media id. + * + * @param mediaId The media id + * @return A base media request + */ + public static MediaBaseRequest of(String mediaId) { + MediaBaseRequest baseRequest = new MediaBaseRequest(); + baseRequest.setMediaId(mediaId); + return baseRequest; + } + + @Override + public MediaBaseRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaBaseResponse.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaBaseResponse.java new file mode 100644 index 00000000..11e3a5e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaBaseResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; + +/** + * Base media response. + */ +public class MediaBaseResponse extends AbstractBceResponse { + + public MediaBaseResponse() { + this.metadata = new BvwResponseMetadata(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaBatchDeleteRequest.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaBatchDeleteRequest.java new file mode 100644 index 00000000..49593e79 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaBatchDeleteRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Batch delete media request. + */ +public class MediaBatchDeleteRequest extends AbstractBceRequest { + + /** + * The medias, multiple media id spilt with comma. + * eg. "mda-xxx,mda-yyy,mda-zzz" + */ + private String mediaIds; + + /** + * + * @param mediaIdList + * @return + */ + public static MediaBatchDeleteRequest of(List mediaIdList) { + MediaBatchDeleteRequest batchDeleteRequest = new MediaBatchDeleteRequest(); + StringBuilder mediaIds = new StringBuilder(); + for (String mediaId : mediaIdList) { + mediaIds.append(mediaId).append(","); + } + mediaIds.deleteCharAt(mediaIds.lastIndexOf(",")); + batchDeleteRequest.setMediaIds(mediaIds.toString()); + return batchDeleteRequest; + } + + @Override + public MediaBatchDeleteRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getMediaIds() { + return mediaIds; + } + + public void setMediaIds(String mediaIds) { + this.mediaIds = mediaIds; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaGetResponse.java new file mode 100644 index 00000000..e4963eeb --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaGetResponse.java @@ -0,0 +1,144 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import com.baidubce.services.bvw.model.common.UtcTime; +import com.baidubce.services.bvw.model.workflow.instance.InstanceModel; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Get media response. + */ +public class MediaGetResponse extends AbstractBceResponse { + + /** + * The media id. + */ + private String mediaId; + /** + * The media status. + */ + private MediaStatus status; + /** + * The media title. + */ + private String title; + /** + * The media description. + */ + private String description; + /** + * The source bucket name. + */ + private String sourceBucket; + /** + * The source key. + */ + private String sourceKey; + /** + * The latest media processing instance. + */ + private InstanceModel latestInstance; + /** + * The create time of media. + */ + @UtcTime + private Date createTime; + + public MediaGetResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public MediaStatus getStatus() { + return status; + } + + public void setStatus(MediaStatus status) { + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSourceBucket() { + return sourceBucket; + } + + public void setSourceBucket(String sourceBucket) { + this.sourceBucket = sourceBucket; + } + + public String getSourceKey() { + return sourceKey; + } + + public void setSourceKey(String sourceKey) { + this.sourceKey = sourceKey; + } + + public InstanceModel getLatestInstance() { + return latestInstance; + } + + public void setLatestInstance(InstanceModel latestInstance) { + this.latestInstance = latestInstance; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("mediaId", mediaId) + .append("status", status) + .append("title", title) + .append("description", description) + .append("sourceBucket", sourceBucket) + .append("sourceKey", sourceKey) + .append("latestInstance", latestInstance) + .append("createTime", createTime) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaInstanceListResponse.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaInstanceListResponse.java new file mode 100644 index 00000000..ca83101a --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaInstanceListResponse.java @@ -0,0 +1,172 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import java.util.Date; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import com.baidubce.services.bvw.model.common.UtcTime; +import com.baidubce.services.bvw.model.workflow.RunnableStatus; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * List instances of media response. + */ +public class MediaInstanceListResponse extends AbstractBceResponse { + + /** + * The instance list. + */ + private List instances; + + public MediaInstanceListResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public List getInstances() { + return instances; + } + + public void setInstances( + List instances) { + this.instances = instances; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("instances", instances) + .toString(); + } + + /** + * The instances of a media. + */ + public static class MediaInstance { + /** + * The instance id. + */ + private String instanceId; + /** + * The instance status. + */ + private RunnableStatus status; + /** + * The workflow id. + */ + private String workflowId; + /** + * The workflow name. + */ + private String workflowName; + /** + * The media id. + */ + private String mediaId; + /** + * The media source bucket name. + */ + private String sourceBucket; + /** + * The media source key. + */ + private String sourceKey; + /** + * The instance create time. + */ + @UtcTime + private Date createTime; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public RunnableStatus getStatus() { + return status; + } + + public void setStatus(RunnableStatus status) { + this.status = status; + } + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + public String getWorkflowName() { + return workflowName; + } + + public void setWorkflowName(String workflowName) { + this.workflowName = workflowName; + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getSourceBucket() { + return sourceBucket; + } + + public void setSourceBucket(String sourceBucket) { + this.sourceBucket = sourceBucket; + } + + public String getSourceKey() { + return sourceKey; + } + + public void setSourceKey(String sourceKey) { + this.sourceKey = sourceKey; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("instanceId", instanceId) + .append("status", status) + .append("workflowId", workflowId) + .append("workflowName", workflowName) + .append("mediaId", mediaId) + .append("sourceBucket", sourceBucket) + .append("sourceKey", sourceKey) + .append("createTime", createTime) + .toString(); + } + + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaListRequest.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaListRequest.java new file mode 100644 index 00000000..bd62aefb --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaListRequest.java @@ -0,0 +1,290 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bvw.model.workflow.RunnableStatus; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * List media request. + */ +public class MediaListRequest extends AbstractBceRequest { + + /** + * The page number of list by page request. + */ + private int pageNo; + /** + * The number of element in each page. + */ + private int pageSize; + /** + * The media status. + */ + private MediaStatus status; + /** + * The latest instance status. + */ + private RunnableStatus instanceStatus; + /** + * The media id. + */ + private String mediaId; + /** + * The meida title, support fuzzy query. + */ + private String title; + /** + * The begin time of creating media time, using UTC format. + * eg. "2019-04-07T16:00:00Z" + */ + private String beginTime; + /** + * The end time of creating media time, using UTC format. + * eg. "2019-04-07T16:00:00Z" + */ + private String endTime; + /** + * The order type, using comma to split multiple value. + * Support type is "asc" / "desc" (case insensitive) + */ + private String order; + /** + * The order column, using comma to split multiple column. + * eg. order = "asc,desc" and orderBy = "createTime,status", means order by createTime asc + * and order by status desc. + */ + private String orderBy; + + /** + * Construct a listing media request with specified parameters. + * + * @param pageNo The page number + * @param pageSize The page size + * @param beginTime The begin time of create media + * @param endTime The end time of create media + * @param status The media status + * @param instanceStatus The instance status + * @param mediaId The media id + * @param title The media title + * @param order The order columns + * @param orderBy The order by type of columns + * @return A listing media request + */ + public static MediaListRequest of(int pageNo, int pageSize, String beginTime, String endTime, MediaStatus status, + RunnableStatus instanceStatus, String mediaId, String title, String order, + String orderBy) { + MediaListRequest listRequest = new MediaListRequest(); + listRequest.setPageNo(pageNo); + listRequest.setPageSize(pageSize); + listRequest.setBeginTime(beginTime); + listRequest.setEndTime(endTime); + listRequest.setStatus(status); + listRequest.setInstanceStatus(instanceStatus); + listRequest.setMediaId(mediaId); + listRequest.setTitle(title); + listRequest.setOrder(order); + listRequest.setOrderBy(orderBy); + return listRequest; + } + + /** + * Construct a listing media request with specified parameters. + * + * @param pageNo The page number + * @param pageSize The page size + * @param beginTime The begin time of create media + * @param endTime The end time of create media + * @return A listing media request + */ + public static MediaListRequest ofDate(int pageNo, int pageSize, String beginTime, String endTime) { + return of(pageNo, pageSize, beginTime, endTime, null, null, null, null, null, null); + } + + /** + * Construct a listing media request with specified parameters. + * + * @param pageNo The page number + * @param pageSize The page size + * @param status The media status + * @return A listing media request + */ + public static MediaListRequest of(int pageNo, int pageSize, MediaStatus status) { + return of(pageNo, pageSize, null, null, status, null, null, null, null, null); + } + + /** + * Construct a listing media request with specified parameters. + * + * @param pageNo The page number + * @param pageSize The page size + * @param instanceStatus The instance status + * @return A listing media request + */ + public static MediaListRequest of(int pageNo, int pageSize, RunnableStatus instanceStatus) { + return of(pageNo, pageSize, null, null, null, instanceStatus, null, null, null, null); + } + + /** + * Construct a listing media request with specified parameters. + * + * @param pageNo The page number + * @param pageSize The page size + * @param mediaId The media id + * @return A listing media request + */ + public static MediaListRequest of(int pageNo, int pageSize, String mediaId) { + return of(pageNo, pageSize, null, null, null, null, mediaId, null, null, null); + } + + /** + * Construct a listing media request with specified parameters. + * + * @param pageNo The page number + * @param pageSize The page size + * @param title The media title + * @return A listing media request + */ + public static MediaListRequest ofTitle(int pageNo, int pageSize, String title) { + return of(pageNo, pageSize, null, null, null, null, null, title, null, null); + } + + /** + * Construct a listing media request with specified parameters. + * + * @param pageNo The page number + * @param pageSize The page size + * @param order The order columns + * @param orderBy The order by type of columns + * @return A listing media request + */ + public static MediaListRequest ofOrder(int pageNo, int pageSize, String order, String orderBy) { + return of(pageNo, pageSize, null, null, null, null, null, null, order, orderBy); + } + + /** + * Construct a listing media request with specified parameters. + * + * @param pageNo The page number + * @param pageSize The page size + * @return A listing media request + */ + public static MediaListRequest of(int pageNo, int pageSize) { + return of(pageNo, pageSize, null, null, null, null, null, null, null, null); + } + + @Override + public MediaListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public MediaStatus getStatus() { + return status; + } + + public void setStatus(MediaStatus status) { + this.status = status; + } + + public RunnableStatus getInstanceStatus() { + return instanceStatus; + } + + public void setInstanceStatus(RunnableStatus instanceStatus) { + this.instanceStatus = instanceStatus; + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getBeginTime() { + return beginTime; + } + + public void setBeginTime(String beginTime) { + this.beginTime = beginTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("pageNo", pageNo) + .append("pageSize", pageSize) + .append("status", status) + .append("instanceStatus", instanceStatus) + .append("mediaId", mediaId) + .append("title", title) + .append("beginTime", beginTime) + .append("endTime", endTime) + .append("order", order) + .append("orderBy", orderBy) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaListResponse.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaListResponse.java new file mode 100644 index 00000000..59f53e6b --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaListResponse.java @@ -0,0 +1,164 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import java.util.Date; + +import com.baidubce.services.bvw.model.common.UtcTime; +import com.baidubce.services.bvw.model.workflow.RunnableStatus; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Media list response. + */ +public class MediaListResponse { + + /** + * The media id. + */ + private String mediaId; + /** + * The media title. + */ + private String title; + /** + * The media status. + */ + private MediaStatus status; + /** + * The latest instance id of the processing media. + */ + private String latestInstanceId; + /** + * The latest instance status of the processing media. + */ + private RunnableStatus instanceStatus; + /** + * The latest using workflow id. + */ + private String latestWorkflowId; + /** + * The latest using workflow name. + */ + private String latestWorkflowName; + /** + * The media source bucket name. + */ + private String sourceBucket; + /** + * The media source key. + */ + private String sourceKey; + /** + * The create time of media. + */ + @UtcTime + private Date createTime; + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public MediaStatus getStatus() { + return status; + } + + public void setStatus(MediaStatus status) { + this.status = status; + } + + public String getLatestInstanceId() { + return latestInstanceId; + } + + public void setLatestInstanceId(String latestInstanceId) { + this.latestInstanceId = latestInstanceId; + } + + public RunnableStatus getInstanceStatus() { + return instanceStatus; + } + + public void setInstanceStatus(RunnableStatus instanceStatus) { + this.instanceStatus = instanceStatus; + } + + public String getLatestWorkflowId() { + return latestWorkflowId; + } + + public void setLatestWorkflowId(String latestWorkflowId) { + this.latestWorkflowId = latestWorkflowId; + } + + public String getLatestWorkflowName() { + return latestWorkflowName; + } + + public void setLatestWorkflowName(String latestWorkflowName) { + this.latestWorkflowName = latestWorkflowName; + } + + public String getSourceBucket() { + return sourceBucket; + } + + public void setSourceBucket(String sourceBucket) { + this.sourceBucket = sourceBucket; + } + + public String getSourceKey() { + return sourceKey; + } + + public void setSourceKey(String sourceKey) { + this.sourceKey = sourceKey; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("mediaId", mediaId) + .append("title", title) + .append("status", status) + .append("latestInstanceId", latestInstanceId) + .append("instanceStatus", instanceStatus) + .append("latestWorkflowId", latestWorkflowId) + .append("latestWorkflowName", latestWorkflowName) + .append("sourceBucket", sourceBucket) + .append("sourceKey", sourceKey) + .append("createTime", createTime) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaProcessRequest.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaProcessRequest.java new file mode 100644 index 00000000..64f8b92c --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaProcessRequest.java @@ -0,0 +1,235 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.Map; + +/** + * Process media request. + */ +public class MediaProcessRequest extends AbstractBceRequest { + + /** + * The media id. + */ + private String mediaId; + /** + * The source bucket name. + */ + private String sourceBucket; + /** + * The source object key. + */ + private String sourceKey; + /** + * The media title. + */ + private String title; + /** + * The media description. + */ + private String description; + /** + * The using workflow name. + */ + private String workflowName; + /** + * The dynamic params in this process. + */ + private String dynamicParams; + /** + * The dynamic params map in this process. + */ + private Map dynamicParamsMap; + + /** + * Construct a process media request with specified parameters. + * + * @param sourceBucket The source bucket name + * @param sourceKey The source object key + * @param title The media title + * @param description The media description + * @param workflowName The using workflow name + * @param dynamicParams The dynamic in this process + * @return A processing media request + */ + public static MediaProcessRequest of(String sourceBucket, String sourceKey, String title, String description, + String workflowName, String dynamicParams) { + MediaProcessRequest processRequest = new MediaProcessRequest(); + processRequest.setSourceBucket(sourceBucket); + processRequest.setSourceKey(sourceKey); + processRequest.setTitle(title); + processRequest.setDescription(description); + processRequest.setWorkflowName(workflowName); + processRequest.setDynamicParams(dynamicParams); + return processRequest; + } + + /** + * Construct a process media request with specified parameters. + * + * @param sourceBucket The source bucket name + * @param sourceKey The source object key + * @param title The media title + * @param description The media description + * @param workflowName The using workflow name + * @return A processing media request + */ + public static MediaProcessRequest of(String sourceBucket, String sourceKey, String title, String description, + String workflowName) { + return of(sourceBucket, sourceKey, title, description, workflowName, null); + } + + /** + * Construct a process media request with specified parameters. + * + * @param mediaId The media id + * @param workflowName The using workflow name + * @param dynamicParams The dynamic in this process + * @return A processing media request + */ + public static MediaProcessRequest of(String mediaId, String workflowName, String dynamicParams) { + MediaProcessRequest processRequest = new MediaProcessRequest(); + processRequest.setMediaId(mediaId); + processRequest.setWorkflowName(workflowName); + processRequest.setDynamicParams(dynamicParams); + return processRequest; + } + + /** + * Construct a process media request with specified parameters. + * + * @param mediaId The media id + * @param workflowName The using workflow name + * @param dynamicParamsMap The dynamic in this process + * @return A processing media request + */ + public static MediaProcessRequest ofDynamicMap( + String mediaId, String workflowName, Map dynamicParamsMap) { + MediaProcessRequest processRequest = new MediaProcessRequest(); + processRequest.setMediaId(mediaId); + processRequest.setWorkflowName(workflowName); + processRequest.setDynamicParamsMap(dynamicParamsMap); + return processRequest; + } + + /** + *Construct a process media request with specified parameters. + * + * @param sourceBucket The source bucket name + * @param sourceKey The source object key + * @param title The media title + * @param description The media description + * @param workflowName The using workflow name + * @param dynamicParamsMap The dynamic in this process + * @return A processing media request + */ + public static MediaProcessRequest ofDynamicMap( + String sourceBucket, String sourceKey, String title, String description, String workflowName, + Map dynamicParamsMap) { + MediaProcessRequest processRequest = new MediaProcessRequest(); + processRequest.setSourceBucket(sourceBucket); + processRequest.setSourceKey(sourceKey); + processRequest.setTitle(title); + processRequest.setDescription(description); + processRequest.setWorkflowName(workflowName); + processRequest.setDynamicParamsMap(dynamicParamsMap); + return processRequest; + } + + /** + * Construct a process media request with specified parameters. + * + * @param mediaId The media id + * @param workflowName The using workflow name + * @return A processing media request + */ + public static MediaProcessRequest of(String mediaId, String workflowName) { + return of(mediaId, workflowName, null); + } + + @Override + public MediaProcessRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getSourceBucket() { + return sourceBucket; + } + + public void setSourceBucket(String sourceBucket) { + this.sourceBucket = sourceBucket; + } + + public String getSourceKey() { + return sourceKey; + } + + public void setSourceKey(String sourceKey) { + this.sourceKey = sourceKey; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getWorkflowName() { + return workflowName; + } + + public void setWorkflowName(String workflowName) { + this.workflowName = workflowName; + } + + public String getDynamicParams() { + return dynamicParams; + } + + public void setDynamicParams(String dynamicParams) { + this.dynamicParams = dynamicParams; + } + + + public Map getDynamicParamsMap() { + return dynamicParamsMap; + } + + public void setDynamicParamsMap(Map dynamicParamsMap) { + this.dynamicParamsMap = dynamicParamsMap; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaProcessResponse.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaProcessResponse.java new file mode 100644 index 00000000..cd000bc6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaProcessResponse.java @@ -0,0 +1,61 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Process media response. + */ +public class MediaProcessResponse extends AbstractBceResponse { + + /** + * The process media id + */ + private String mediaId; + /** + * The instance of process media and using workflow. + */ + private String instanceId; + + public MediaProcessResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("mediaId", mediaId) + .append("instanceId", instanceId) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaStatus.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaStatus.java new file mode 100644 index 00000000..efb134fb --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaStatus.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +/** + * The enum class to enumerate all the supported media status in SDK. + */ +public enum MediaStatus { + + /** + * The normal status of media. + */ + NORMAL, + /** + * The banned status of media. + */ + BANNED + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/media/MediaUpdateRequest.java b/src/main/java/com/baidubce/services/bvw/model/media/MediaUpdateRequest.java new file mode 100644 index 00000000..14621a87 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/media/MediaUpdateRequest.java @@ -0,0 +1,82 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.media; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Update media request. + */ +public class MediaUpdateRequest extends AbstractBceRequest { + + /** + * The media id. + */ + private String mediaId; + /** + * The media title. + */ + private String title; + /** + * The media description. + */ + private String description; + + /** + * Construct a updating media request with specified parameters. + * + * @param mediaId The media id + * @param title The media title + * @param description The media description + * @return A updating media request + */ + public static MediaUpdateRequest of(String mediaId, String title, String description) { + MediaUpdateRequest updateRequest = new MediaUpdateRequest(); + updateRequest.setMediaId(mediaId); + updateRequest.setTitle(title); + updateRequest.setDescription(description); + return updateRequest; + } + + @Override + public MediaUpdateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/AuthType.java b/src/main/java/com/baidubce/services/bvw/model/notification/AuthType.java new file mode 100644 index 00000000..bd50dd4c --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/AuthType.java @@ -0,0 +1,30 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.notification; + +/** + * The enum class to enumerate all the supported notification auth type in SDK. + */ +public enum AuthType { + + /** + * Use notification with no authentication. + */ + NONE, + + /** + * Use notification with sign authentication. + */ + SIGN + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/NotificationBaseRequest.java b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationBaseRequest.java new file mode 100644 index 00000000..16a35241 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationBaseRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.notification; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Base notification request. + */ +public class NotificationBaseRequest extends AbstractBceRequest { + + /** + * The notification name. + */ + private String name; + + /** + * Construct a base notification request with specified parameters. + * + * @param name The notification name + * @return A base notification request + */ + public static NotificationBaseRequest of(String name) { + NotificationBaseRequest baseRequest = new NotificationBaseRequest(); + baseRequest.setName(name); + return baseRequest; + } + + @Override + public NotificationBaseRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/NotificationBaseResponse.java b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationBaseResponse.java new file mode 100644 index 00000000..5346e476 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationBaseResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.notification; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; + +/** + * Base notification response. + */ +public class NotificationBaseResponse extends AbstractBceResponse { + + public NotificationBaseResponse() { + this.metadata = new BvwResponseMetadata(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/NotificationCreateRequest.java b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationCreateRequest.java new file mode 100644 index 00000000..6aefd9b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationCreateRequest.java @@ -0,0 +1,87 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.notification; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Create notification request. + */ +public class NotificationCreateRequest extends NotificationBaseRequest { + + /** + * The notification endpoint. + */ + private String endpoint; + + /** + * The authentication token. + */ + private String token; + + /** + * The auth type. + */ + private AuthType authType = AuthType.NONE; + + /** + * Construct a creating notification request with specified parameters. + * @param name The notification name + * @param endpoint The notification endpoint + * @return A creating notification request + */ + public static NotificationCreateRequest of(String name, String endpoint) { + return of(name, endpoint, null, AuthType.NONE); + } + + public static NotificationCreateRequest of(String name, String endpoint, String token, AuthType authType) { + NotificationCreateRequest createRequest = new NotificationCreateRequest(); + createRequest.setName(name); + createRequest.setEndpoint(endpoint); + createRequest.setToken(token); + createRequest.setAuthType(authType); + return createRequest; + } + + @Override + public NotificationCreateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public AuthType getAuthType() { + return authType; + } + + public void setAuthType(AuthType authType) { + this.authType = authType; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/NotificationGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationGetResponse.java new file mode 100644 index 00000000..5129988c --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationGetResponse.java @@ -0,0 +1,118 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.notification; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import com.baidubce.services.bvw.model.common.UtcTime; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Get notification response. + */ +public class NotificationGetResponse extends AbstractBceResponse { + + /** + * The notification id. + */ + private String notificationId; + /** + * The notification name. + */ + private String name; + /** + * The notification endpoint. + */ + private String endpoint; + /** + * The notification status. + */ + private NotificationStatus status; + /** + * The create time of notification. + */ + @UtcTime + private Date createTime; + /** + * The update time of notification. + */ + @UtcTime + private Date updateTime; + + public NotificationGetResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public String getNotificationId() { + return notificationId; + } + + public void setNotificationId(String notificationId) { + this.notificationId = notificationId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public NotificationStatus getStatus() { + return status; + } + + public void setStatus(NotificationStatus status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("notificationId", notificationId) + .append("name", name) + .append("endpoint", endpoint) + .append("status", status) + .append("createTime", createTime) + .append("updateTime", updateTime) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/NotificationListRequest.java b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationListRequest.java new file mode 100644 index 00000000..406c1b29 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationListRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.bvw.model.notification; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Desc: + * + * @author guichen01 + * create date: 2019-07-23 + */ +public class NotificationListRequest extends AbstractBceRequest { + + /** + * The notification status. + */ + private NotificationStatus status; + + /** + * Construct a listing notification request with specified parameters. + * @param status The notification status + * @return A listing notification request + */ + public static NotificationListRequest of(NotificationStatus status) { + NotificationListRequest listRequest = new NotificationListRequest(); + listRequest.setStatus(status); + return listRequest; + } + + @Override + public NotificationListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public NotificationStatus getStatus() { + return status; + } + + public void setStatus(NotificationStatus status) { + this.status = status; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/NotificationListResponse.java b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationListResponse.java new file mode 100644 index 00000000..cdcb5979 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationListResponse.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.notification; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * List notificatio response. + */ +public class NotificationListResponse extends AbstractBceResponse { + + /** + * The notification list. + */ + private List notifications; + + public NotificationListResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public List getNotifications() { + return notifications; + } + + public void setNotifications(List notifications) { + this.notifications = notifications; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("notifications", notifications) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/NotificationModel.java b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationModel.java new file mode 100644 index 00000000..6f9aa2ea --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationModel.java @@ -0,0 +1,129 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.notification; + +import java.util.Date; + +import com.baidubce.services.bvw.model.common.UtcTime; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * The class of Notification model. + */ +public class NotificationModel { + + /** + * The notification id. + */ + private String notificationId; + /** + * The notification name. + */ + private String name; + /** + * The notification endpoint. + */ + private String endpoint; + /** + * The notification status. + */ + private NotificationStatus status; + /** + * The create time of notification. + */ + @UtcTime + private Date createTime; + /** + * The update time of notification. + */ + @UtcTime + private Date updateTime; + + /** + * Construct a notification model with specified parameters. + * + * @param response The getting notification response + * @return A notification model + */ + public static NotificationModel of(NotificationGetResponse response) { + NotificationModel notification = new NotificationModel(); + notification.setNotificationId(response.getNotificationId()); + notification.setName(response.getName()); + notification.setEndpoint(response.getEndpoint()); + notification.setStatus(response.getStatus()); + notification.setCreateTime(response.getCreateTime()); + notification.setUpdateTime(response.getUpdateTime()); + return notification; + } + + public String getNotificationId() { + return notificationId; + } + + public void setNotificationId(String notificationId) { + this.notificationId = notificationId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public NotificationStatus getStatus() { + return status; + } + + public void setStatus(NotificationStatus status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("notificationId", notificationId) + .append("name", name) + .append("endpoint", endpoint) + .append("status", status) + .append("createTime", createTime) + .append("updateTime", updateTime) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/NotificationStatus.java b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationStatus.java new file mode 100644 index 00000000..1e43ec0e --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationStatus.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.notification; + +/** + * The enum class to enumerate all the supported notification status in SDK. + */ +public enum NotificationStatus { + + /** + * The enable status of notification. + */ + ENABLE, + /** + * The disable status of notification. + */ + DISABLE + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/notification/NotificationUpdateRequest.java b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationUpdateRequest.java new file mode 100644 index 00000000..c6bec530 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/notification/NotificationUpdateRequest.java @@ -0,0 +1,87 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.notification; + +import com.baidubce.auth.BceCredentials; + +/** + * Update notification request. + */ +public class NotificationUpdateRequest extends NotificationBaseRequest { + + /** + * The notification endpoint. + */ + private String endpoint; + + /** + * The authentication token. + */ + private String token; + + /** + * The auth type. + */ + private AuthType authType; + + /** + * Construct a update request with specified parameters. + * + * @param name The notification name + * @param endpoint The notification endpoint + * @return A updating notification request + */ + public static NotificationUpdateRequest of(String name, String endpoint) { + return of(name, endpoint, null, null); + } + + public static NotificationUpdateRequest of(String name, String endpoint, String token, AuthType authType) { + NotificationUpdateRequest updateRequest = new NotificationUpdateRequest(); + updateRequest.setName(name); + updateRequest.setEndpoint(endpoint); + updateRequest.setToken(token); + updateRequest.setAuthType(authType); + return updateRequest; + } + + @Override + public NotificationUpdateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public AuthType getAuthType() { + return authType; + } + + public void setAuthType(AuthType authType) { + this.authType = authType; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/videoedit/CreateRetModel.java b/src/main/java/com/baidubce/services/bvw/model/videoedit/CreateRetModel.java new file mode 100644 index 00000000..55751e7a --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/videoedit/CreateRetModel.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.videoedit; + +public class CreateRetModel { + /** + * the video edit id + */ + private long editId; + + public long getEditId() { + return editId; + } + + public void setEditId(long editId) { + this.editId = editId; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/videoedit/PollingDataModel.java b/src/main/java/com/baidubce/services/bvw/model/videoedit/PollingDataModel.java new file mode 100644 index 00000000..e59674a4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/videoedit/PollingDataModel.java @@ -0,0 +1,102 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.videoedit; + +public class PollingDataModel { + /** + * the video edit id + */ + private long editId; + /** + * the video edit status: SUCCESS FAILED READY + */ + private String editStatus; + /** + * the bos bucket + */ + private String bucket; + /** + * the bos key + */ + private String key; + /** + * the edit task createTime + */ + private String createTime; + /** + * the edit task UpTime + */ + private String updateTime; + + public PollingDataModel() { + } + + public PollingDataModel(long editId, String editStatus, String bucket, String key, + String createTime, String updateTime) { + this.editId = editId; + this.editStatus = editStatus; + this.bucket = bucket; + this.key = key; + this.createTime = createTime; + this.updateTime = updateTime; + } + + public long getEditId() { + return editId; + } + + public void setEditId(long editId) { + this.editId = editId; + } + + public String getEditStatus() { + return editStatus; + } + + public void setEditStatus(String editStatus) { + this.editStatus = editStatus; + } + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/videoedit/RefererType.java b/src/main/java/com/baidubce/services/bvw/model/videoedit/RefererType.java new file mode 100644 index 00000000..a7099681 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/videoedit/RefererType.java @@ -0,0 +1,34 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.videoedit; + +/** + * Referer types + */ +public enum RefererType { + /** + * 人民日报 + */ + rmrb, + /** + * 百度 + */ + baidu, + /** + * 天脉 + */ + tianmai, + saas, + zsyh, + others +} diff --git a/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditCreateRequest.java b/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditCreateRequest.java new file mode 100644 index 00000000..50dfd2c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditCreateRequest.java @@ -0,0 +1,182 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.videoedit; + +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.Map; + +public class VideoEditCreateRequest extends AbstractBceRequest { + private static final long DefaultTaskId = 0; + private static final String BucketKey = "bucket"; + private static final String TitleKey = "title"; + private static final String TaskIdKey = "taskId"; + private static final String RefererKey = "referer"; + private static final String NotificationKey = "notification"; + private static final String CmdKey = "cmd"; + private static final String ExtInfoKey = "extInfo"; + + /** + * user store bucket + */ + private String bucket; + /** + * use edit title + */ + private String title; + /** + * user edit taskId + */ + private long taskId; + /** + * user client referer, default is baidu + */ + private String referer; + /** + * notification name + */ + private String notification; + /** + * request body + */ + private Map cmd; + /** + * extInfo body + */ + private Map extInfo; + + public String getString(Object object) { + if (object instanceof String) { + return (String) object; + } + throw new BceClientException("bucket/title not a string."); + } + + public VideoEditCreateRequest() { + } + + public VideoEditCreateRequest(Map jsonObject) { + this.cmd = jsonObject.containsKey(CmdKey) ? (Map) jsonObject.get(CmdKey) : null; + this.extInfo = jsonObject.containsKey(ExtInfoKey) ? (Map) jsonObject.get(ExtInfoKey) : null; + this.bucket = jsonObject.containsKey(BucketKey) ? getString(jsonObject.get(BucketKey)) : null; + this.title = jsonObject.containsKey(TitleKey) ? getString(jsonObject.get(TitleKey)) : null; + this.taskId = jsonObject.containsKey(TaskIdKey) ? + Long.parseLong(String.valueOf(jsonObject.get(TaskIdKey))) : DefaultTaskId; + this.referer = RefererType.baidu.name(); + } + + public VideoEditCreateRequest( + Map jsonObject, RefererType refererType) { + this.cmd = jsonObject.containsKey(CmdKey) ? (Map) jsonObject.get(CmdKey) : null; + this.extInfo = jsonObject.containsKey(ExtInfoKey) ? (Map) jsonObject.get(ExtInfoKey) : null; + this.bucket = jsonObject.containsKey(BucketKey) ? getString(jsonObject.get(BucketKey)) : null; + this.title = jsonObject.containsKey(TitleKey) ? getString(jsonObject.get(TitleKey)) : null; + this.taskId = jsonObject.containsKey(TaskIdKey) ? + Long.parseLong(String.valueOf(jsonObject.get(TaskIdKey))) : DefaultTaskId; + this.referer = refererType.name(); + } + + public VideoEditCreateRequest( + Map jsonObject, RefererType refererType, String notification) { + this.cmd = jsonObject.containsKey(CmdKey) ? (Map) jsonObject.get(CmdKey) : null; + this.extInfo = jsonObject.containsKey(ExtInfoKey) ? (Map) jsonObject.get(ExtInfoKey) : null; + this.bucket = jsonObject.containsKey(BucketKey) ? getString(jsonObject.get(BucketKey)) : null; + this.title = jsonObject.containsKey(TitleKey) ? getString(jsonObject.get(TitleKey)) : null; + this.taskId = jsonObject.containsKey(TaskIdKey) ? + Long.parseLong(String.valueOf(jsonObject.get(TaskIdKey))) : DefaultTaskId; + this.referer = refererType.name(); + this.notification = notification; + } + + public static String getCmdKey() { + return CmdKey; + } + + public String getBucket() { + return bucket; + } + + public String getTitle() { + return title; + } + + public long getTaskId() { + return taskId; + } + + public String getReferer() { + return referer; + } + + public String getNotification() { + return notification; + } + + public Map getCmd() { + return cmd; + } + + public Map getExtInfo() { + return extInfo; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setTaskId(long taskId) { + this.taskId = taskId; + } + + public void setReferer(RefererType referer) { + this.referer = referer.name(); + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public void setCmd(Map cmd) { + this.cmd = cmd; + } + + public void setExtInfo(Map extInfo) { + this.extInfo = extInfo; + } + + @Override + public String toString() { + return "VideoEditCreateRequest{" + + "bucket='" + bucket + '\'' + + ", title='" + title + '\'' + + ", taskId='" + taskId + '\'' + + ", referer='" + referer + '\'' + + ", notification='" + notification + '\'' + + ", extInfo='" + extInfo.toString() + '\'' + + ", cmd='" + cmd.toString() + '\'' + + '}'; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditCreateResponse.java b/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditCreateResponse.java new file mode 100644 index 00000000..99f9dc3d --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditCreateResponse.java @@ -0,0 +1,64 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.videoedit; + +import com.baidubce.model.AbstractBceResponse; + +public class VideoEditCreateResponse extends AbstractBceResponse { + /** + * error number , 0 is OK + */ + private int errorno; + /** + * error message + */ + private String errmsg; + /** + * Create edit video's ret content + */ + private CreateRetModel ret; + + public VideoEditCreateResponse() { + } + + public VideoEditCreateResponse(int errorno, String errmsg, CreateRetModel ret) { + this.errorno = errorno; + this.errmsg = errmsg; + this.ret = ret; + } + + public int getErrorno() { + return errorno; + } + + public void setErrorno(int errorno) { + this.errorno = errorno; + } + + public String getErrmsg() { + return errmsg; + } + + public void setErrmsg(String errmsg) { + this.errmsg = errmsg; + } + + public CreateRetModel getRet() { + return ret; + } + + public void setRet(CreateRetModel ret) { + this.ret = ret; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditPollingRequest.java b/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditPollingRequest.java new file mode 100644 index 00000000..ee75b6fe --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditPollingRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.videoedit; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class VideoEditPollingRequest extends AbstractBceRequest { + /** + * video task editId + */ + private long editId; + + public VideoEditPollingRequest() { + } + + public VideoEditPollingRequest(long editId) { + this.editId = editId; + } + + public long getEditId() { + return editId; + } + + public void setEditId(long editId) { + this.editId = editId; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + return null; + } +} diff --git a/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditPollingResponse.java b/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditPollingResponse.java new file mode 100644 index 00000000..ca626c4c --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/videoedit/VideoEditPollingResponse.java @@ -0,0 +1,64 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.videoedit; + +import com.baidubce.model.AbstractBceResponse; + +public class VideoEditPollingResponse extends AbstractBceResponse { + /** + * error number , 0 is OK + */ + private int errorno; + /** + * error message + */ + private String errmsg; + /** + * Create edit video's data content + */ + private PollingDataModel data; + + public VideoEditPollingResponse() { + } + + public VideoEditPollingResponse(int errorno, String errmsg, PollingDataModel data) { + this.errorno = errorno; + this.errmsg = errmsg; + this.data = data; + } + + public int getErrorno() { + return errorno; + } + + public void setErrorno(int errorno) { + this.errorno = errorno; + } + + public String getErrmsg() { + return errmsg; + } + + public void setErrmsg(String errmsg) { + this.errmsg = errmsg; + } + + public PollingDataModel getData() { + return data; + } + + public void setData(PollingDataModel data) { + this.data = data; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/DagModel.java b/src/main/java/com/baidubce/services/bvw/model/workflow/DagModel.java new file mode 100644 index 00000000..6538a4b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/DagModel.java @@ -0,0 +1,74 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * The class of workflow param, is a directed acyclic graph(DAG). + * DAG contains all of the job stages and the dependencies between them. + */ +public class DagModel { + + /** + * Define all of the stages. + * Structure: + */ + private Map stages; + /** + * Define the dependencies between the stages. + * Structure: + */ + private Map> dependencies; + + /** + * Construct a dag with stages. + * @param stages The stage names and stages + * @param dependencies The dependencies between stages + * @return A dag with specified stages + */ + public static DagModel of(Map stages, Map> dependencies) { + DagModel dagModel = new DagModel(); + dagModel.setStages(stages); + dagModel.setDependencies(dependencies); + return dagModel; + } + + public Map getStages() { + return stages; + } + + public void setStages(Map stages) { + this.stages = stages; + } + + public Map> getDependencies() { + return dependencies; + } + + public void setDependencies(Map> dependencies) { + this.dependencies = dependencies; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("stages", stages) + .append("dependencies", dependencies) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/RunnableStatus.java b/src/main/java/com/baidubce/services/bvw/model/workflow/RunnableStatus.java new file mode 100644 index 00000000..980d13be --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/RunnableStatus.java @@ -0,0 +1,37 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +/** + * The enum class to enumerate all the supported instance status in SDK. + */ +public enum RunnableStatus { + + /** + * The instance is ready to run. + */ + READY, + /** + * The instance is running. + */ + RUNNING, + /** + * The instance is successful. + */ + SUCCESS, + /** + * The instance is failed. + */ + FAILED + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/StageModel.java b/src/main/java/com/baidubce/services/bvw/model/workflow/StageModel.java new file mode 100644 index 00000000..92da7a5a --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/StageModel.java @@ -0,0 +1,98 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * The stage in DAG. + */ +public class StageModel { + + /** + * The stage id. + */ + private String stageId; + /** + * The stage name, is unique in the current workflow. + */ + private String name; + /** + * The stage param, is different in each type of stage, will + * be deserialize to specific type of job. + */ + private StageParamModel param; + /** + * The stage type. + */ + private StageType type; + + /** + * Construct a stage with name, param and type. + * + * @param name The stage name + * @param param The stage param + * @param type The stage type + * @return A stage with specified name, param and type + */ + public static StageModel of(String name, StageParamModel param, StageType type) { + StageModel stageModel = new StageModel(); + stageModel.setName(name); + stageModel.setParam(param); + stageModel.setType(type); + return stageModel; + } + + public String getStageId() { + return stageId; + } + + public void setStageId(String stageId) { + this.stageId = stageId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public StageParamModel getParam() { + return param; + } + + public void setParam(StageParamModel param) { + this.param = param; + } + + public StageType getType() { + return type; + } + + public void setType(StageType type) { + this.type = type; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("stageId", stageId) + .append("name", name) + .append("param", param) + .append("type", type) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/StageParamModel.java b/src/main/java/com/baidubce/services/bvw/model/workflow/StageParamModel.java new file mode 100644 index 00000000..76cc22a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/StageParamModel.java @@ -0,0 +1,81 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * The stage param in stage. + */ +public class StageParamModel { + + /** + * The input param, is serialize json of associate stage job input. + */ + private String input; + /** + * The output param. + */ + private String output; + /** + * The dynamic params, will pass-through in the process. + * It is specified when processing media. + */ + private String dynamicParams; + + /** + * Construct a stage param with input json string. + * + * @param input The input json string + * @return The Stage param with input + */ + public static StageParamModel of(String input) { + StageParamModel stageParamModel = new StageParamModel(); + stageParamModel.setInput(input); + return stageParamModel; + } + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public String getOutput() { + return output; + } + + public void setOutput(String output) { + this.output = output; + } + + public String getDynamicParams() { + return dynamicParams; + } + + public void setDynamicParams(String dynamicParams) { + this.dynamicParams = dynamicParams; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("input", input) + .append("output", output) + .append("dynamicParams", dynamicParams) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/StageType.java b/src/main/java/com/baidubce/services/bvw/model/workflow/StageType.java new file mode 100644 index 00000000..25470d05 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/StageType.java @@ -0,0 +1,70 @@ +/* + * Copyright 2019-2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +/** + * The enum class to enumerate all the supported stage type in SDK. + */ +public enum StageType { + + /** + * The stage of start. + */ + START, + + /** + * The stage of PUBLISH. + */ + PUBLISH, + + /** + * The stage of media info. + */ + MEDIAINFO, + + /** + * The stage of black border detect. + */ + BLACK_BORDER_DETECT, + + /** + * The stage of transcoding job in mct. + */ + TRANSCODING, + + /** + * The stage of thumbnail job in mct. + */ + THUMBNAIL, + + /** + * The stage of no transcoding job. + */ + NO_TRANSCODING, + + /** + * The stage of vcr job. + */ + VCR, + + /** + * The stage of vca job. + */ + VCA, + + /** + * The stage of subtitle job in mct + */ + SUBTITLE + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowBaseRequest.java b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowBaseRequest.java new file mode 100644 index 00000000..70efc2fe --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowBaseRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Base workflow request, contains a attribute of workflow name. + */ +public class WorkflowBaseRequest extends AbstractBceRequest { + + /** + * The workflow name. + */ + String name; + + @Override + public WorkflowBaseRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Construct a base workflow request with workflow name. + * @param name The workflow name + * @return A get workflow request + */ + public static WorkflowBaseRequest of(String name) { + WorkflowBaseRequest baseRequest = new WorkflowBaseRequest(); + baseRequest.setName(name); + return baseRequest; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowBaseResponse.java b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowBaseResponse.java new file mode 100644 index 00000000..ab35de03 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowBaseResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; + +/** + * Base workflow response. + */ +public class WorkflowBaseResponse extends AbstractBceResponse { + + public WorkflowBaseResponse() { + this.metadata = new BvwResponseMetadata(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowCreateRequest.java b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowCreateRequest.java new file mode 100644 index 00000000..3a10b97c --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowCreateRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Create Workflow request. + */ +public class WorkflowCreateRequest extends AbstractBceRequest { + + /** + * The workflow name. + */ + private String name; + /** + * The workflow dag expression. + */ + private DagModel expression; + + /** + * Construct a workflow with name and dag. + * + * @param name workflow name. + * @param dag workflow dag. + * @return create workflow request. + */ + public static WorkflowCreateRequest of(String name, DagModel dag) { + WorkflowCreateRequest createRequest = new WorkflowCreateRequest(); + createRequest.setName(name); + createRequest.setExpression(dag); + return createRequest; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DagModel getExpression() { + return expression; + } + + public void setExpression(DagModel expression) { + this.expression = expression; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowGetResponse.java new file mode 100644 index 00000000..961ecd05 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowGetResponse.java @@ -0,0 +1,118 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import com.baidubce.services.bvw.model.common.UtcTime; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Get workflow response. + */ +public class WorkflowGetResponse extends AbstractBceResponse { + + /** + * The workflow id. + */ + private String workflowId; + /** + * The workflow name. + */ + private String name; + /** + * The workflow dag expression. + */ + private String expression; + /** + * The workflow status. + */ + private WorkflowStatus status; + /** + * The workflow create time. + */ + @UtcTime + private Date createTime; + /** + * The workflow update time. + */ + @UtcTime + private Date updateTime; + + public WorkflowGetResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getExpression() { + return expression; + } + + public void setExpression(String expression) { + this.expression = expression; + } + + public WorkflowStatus getStatus() { + return status; + } + + public void setStatus(WorkflowStatus status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("workflowId", workflowId) + .append("name", name) + .append("expression", expression) + .append("status", status) + .append("createTime", createTime) + .append("updateTime", updateTime) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowListRequest.java b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowListRequest.java new file mode 100644 index 00000000..ab62b591 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowListRequest.java @@ -0,0 +1,175 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * List workflow request + */ +public class WorkflowListRequest extends AbstractBceRequest { + + /** + * The page number of list by page request. + */ + private int pageNo; + /** + * The number of element in each page. + */ + private int pageSize; + /** + * The workflow status. + */ + private WorkflowStatus status; + /** + * The workflow name, support fuzzy query. + */ + private String name; + /** + * The begin time of creating workflow time, using UTC format. + * eg. "2019-04-07T16:00:00Z" + */ + private String beginTime; + /** + * The end time of creating workflow time, using UTC format. + * eg. "2019-04-07T16:00:00Z" + */ + private String endTime; + + /** + * Construct a list workflow request with specified parameters.. + * + * @param pageNo The number of page + * @param pageSize The number of elements in each page + * @param status The workflow status + * @param name The workflow name + * @param beginTime The begin time of creating workflow time + * @param endTime The end time of creating workflow time + * @return A workflow list request + */ + public static WorkflowListRequest of(int pageNo, int pageSize, WorkflowStatus status, String name, String beginTime, + String endTime) { + WorkflowListRequest listRequest = new WorkflowListRequest(); + listRequest.setPageNo(pageNo); + listRequest.setPageSize(pageSize); + listRequest.setStatus(status); + listRequest.setBeginTime(beginTime); + listRequest.setEndTime(endTime); + listRequest.setName(name); + return listRequest; + } + + /** + * Construct a list workflow request with specified parameters.. + * + * @param pageNo The number of page + * @param pageSize The number of elements in each page + * @return A workflow list request + */ + public static WorkflowListRequest of(int pageNo, int pageSize) { + return of(pageNo, pageSize, null, null, null, null); + } + + /** + * Construct a list workflow request with specified parameters.. + * + * @param pageNo The number of page + * @param pageSize The number of elements in each page + * @param name The workflow name + * @return A workflow list request + */ + public static WorkflowListRequest of(int pageNo, int pageSize, String name) { + return of(pageNo, pageSize, null, name, null, null); + } + + /** + * Construct a list workflow request with specified parameters.. + * + * @param pageNo The number of page + * @param pageSize The number of elements in each page + * @param status The workflow status + * @return A workflow list request + */ + public static WorkflowListRequest of(int pageNo, int pageSize, WorkflowStatus status) { + return of(pageNo, pageSize, status, null, null, null); + } + + /** + * Construct a list workflow request with specified parameters.. + * + * @param pageNo The number of page + * @param pageSize The number of elements in each page + * @param beginTime The begin time of creating workflow time + * @param endTime The end time of creating workflow time + * @return A workflow list request + */ + public static WorkflowListRequest of(int pageNo, int pageSize, String beginTime, String endTime) { + return of(pageNo, pageSize, null, null, beginTime, endTime); + } + + @Override + public WorkflowListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public WorkflowStatus getStatus() { + return status; + } + + public void setStatus(WorkflowStatus status) { + this.status = status; + } + + public String getBeginTime() { + return beginTime; + } + + public void setBeginTime(String beginTime) { + this.beginTime = beginTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowListResponse.java b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowListResponse.java new file mode 100644 index 00000000..9297c221 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowListResponse.java @@ -0,0 +1,109 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import java.util.Date; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Workflow list response. + */ +public class WorkflowListResponse { + + /** + * The workflow id. + */ + private String workflowId; + /** + * The workflow name. + */ + private String name; + /** + * The dag expression + */ + private String expression; + /** + * The workflow status + */ + private WorkflowStatus status; + /** + * The workflow create time + */ + private Date createTime; + /** + * The workflow is using or not + */ + private boolean using; + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getExpression() { + return expression; + } + + public void setExpression(String expression) { + this.expression = expression; + } + + public WorkflowStatus getStatus() { + return status; + } + + public void setStatus(WorkflowStatus status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public boolean isUsing() { + return using; + } + + public void setUsing(boolean using) { + this.using = using; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("workflowId", workflowId) + .append("name", name) + .append("expression", expression) + .append("status", status) + .append("createTime", createTime) + .append("using", using) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowStatus.java b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowStatus.java new file mode 100644 index 00000000..44153029 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowStatus.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +/** + * The enum class to enumerate all the supported workflow status in SDK. + */ +public enum WorkflowStatus { + + /** + * The normal status of workflow. + */ + NORMAL, + /** + * The disable status of workflow. + */ + DISABLE + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowUpdateRequest.java b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowUpdateRequest.java new file mode 100644 index 00000000..ee92e6f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/WorkflowUpdateRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Update workflow request. + */ +public class WorkflowUpdateRequest extends AbstractBceRequest { + + /** + * The workflow name. + */ + private String name; + /** + * The workflow dag expression. + */ + private DagModel expression; + + @Override + public WorkflowUpdateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Construct a updating workflow request with specified dag expression. + * @param dag The workflow dag expression + * @return A updating workflow request + */ + public static WorkflowUpdateRequest of(String name, DagModel dag) { + WorkflowUpdateRequest updateRequest = new WorkflowUpdateRequest(); + updateRequest.setName(name); + updateRequest.setExpression(dag); + return updateRequest; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DagModel getExpression() { + return expression; + } + + public void setExpression(DagModel expression) { + this.expression = expression; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceBaseRequest.java b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceBaseRequest.java new file mode 100644 index 00000000..0d397670 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceBaseRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Base instance request. + */ +public class InstanceBaseRequest extends AbstractBceRequest { + + /** + * The instance id. + */ + private String instanceId; + + /** + * Construct a base instance request with specified parameters. + * + * @param instanceId The instance id + * @return A base instance response + */ + public static InstanceBaseRequest of(String instanceId) { + InstanceBaseRequest baseRequest = new InstanceBaseRequest(); + baseRequest.setInstanceId(instanceId); + return baseRequest; + } + + @Override + public InstanceBaseRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceBaseResponse.java b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceBaseResponse.java new file mode 100644 index 00000000..69eeffaa --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceBaseResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; + +/** + * The base instance response. + */ +public class InstanceBaseResponse extends AbstractBceResponse { + + public InstanceBaseResponse() { + this.metadata = new BvwResponseMetadata(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceGetResponse.java new file mode 100644 index 00000000..3134195f --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceGetResponse.java @@ -0,0 +1,250 @@ +/* + * Copyright 2019-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow.instance; + +import java.util.Map; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import com.baidubce.services.bvw.model.workflow.RunnableStatus; +import com.baidubce.services.bvw.model.workflow.StageType; +import com.baidubce.services.bvw.model.workflow.task.TaskParamModel; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Get instance response. + */ +public class InstanceGetResponse extends AbstractBceResponse { + + /** + * The instance id. + */ + private String instanceId; + /** + * The instance status. + */ + private RunnableStatus status; + /** + * The instance running error msg. + */ + private String errorMsg; + /** + * The using workflow id. + */ + private String workflowId; + /** + * The using workflow name. + */ + private String workflowName; + /** + * The processing media id. + */ + private String mediaId; + /** + * The media source bucket name. + */ + private String sourceBucket; + /** + * The media source key. + */ + private String sourceKey; + /** + * The stages in this instance. + * Structure: . + */ + private Map stages; + + /** + * The internal class for stage task. + */ + public static class StageTask { + + /** + * The task id. + */ + private String taskId; + /** + * The instance id. + */ + private String instanceId; + /** + * The task running status. + */ + private RunnableStatus status; + /** + * The stage id. + */ + private String stageId; + /** + * The stage name. + */ + private String name; + /** + * The stage task param. + */ + private TaskParamModel param; + /** + * The stage type. + */ + private StageType type; + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public RunnableStatus getStatus() { + return status; + } + + public void setStatus(RunnableStatus status) { + this.status = status; + } + + public String getStageId() { + return stageId; + } + + public void setStageId(String stageId) { + this.stageId = stageId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public TaskParamModel getParam() { + return param; + } + + public void setParam(TaskParamModel param) { + this.param = param; + } + + public StageType getType() { + return type; + } + + public void setType(StageType type) { + this.type = type; + } + + } + + public InstanceGetResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public RunnableStatus getStatus() { + return status; + } + + public void setStatus(RunnableStatus status) { + this.status = status; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + public String getWorkflowName() { + return workflowName; + } + + public void setWorkflowName(String workflowName) { + this.workflowName = workflowName; + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getSourceBucket() { + return sourceBucket; + } + + public void setSourceBucket(String sourceBucket) { + this.sourceBucket = sourceBucket; + } + + public String getSourceKey() { + return sourceKey; + } + + public void setSourceKey(String sourceKey) { + this.sourceKey = sourceKey; + } + + public Map getStages() { + return stages; + } + + public void setStages(Map stages) { + this.stages = stages; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("instanceId", instanceId) + .append("status", status) + .append("errorMsg", errorMsg) + .append("workflowId", workflowId) + .append("workflowName", workflowName) + .append("mediaId", mediaId) + .append("sourceBucket", sourceBucket) + .append("sourceKey", sourceKey) + .append("stages", stages) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceGetTaskUrlsResponse.java b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceGetTaskUrlsResponse.java new file mode 100644 index 00000000..0626c348 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceGetTaskUrlsResponse.java @@ -0,0 +1,199 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow.instance; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import com.baidubce.services.bvw.model.workflow.RunnableStatus; +import com.baidubce.services.bvw.model.workflow.StageType; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Get url resource from a instance. + */ +public class InstanceGetTaskUrlsResponse extends AbstractBceResponse { + + /** + * The task urls resource from a instance. + */ + private List stageTaskUrls; + + /** + * The internal class for task url in getting task urls response. + */ + public static class StageTaskUrl { + + /** + * The task id. + */ + private String taskId; + /** + * The stage name. + */ + private String stageName; + /** + * The stage type. + */ + private StageType stageType; + /** + * The target bucket name. + */ + private String targetBucket; + /** + * The task running status. + */ + private RunnableStatus status; + /** + * The domain list. + */ + private List domains; + /** + * The target keys. + */ + private List targetKeys; + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + public StageType getStageType() { + return stageType; + } + + public void setStageType(StageType stageType) { + this.stageType = stageType; + } + + public String getTargetBucket() { + return targetBucket; + } + + public void setTargetBucket(String targetBucket) { + this.targetBucket = targetBucket; + } + + public RunnableStatus getStatus() { + return status; + } + + public void setStatus(RunnableStatus status) { + this.status = status; + } + + public List getDomains() { + return domains; + } + + public void setDomains( + List domains) { + this.domains = domains; + } + + public List getTargetKeys() { + return targetKeys; + } + + public void setTargetKeys(List targetKeys) { + this.targetKeys = targetKeys; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("taskId", taskId) + .append("stageName", stageName) + .append("stageType", stageType) + .append("targetBucket", targetBucket) + .append("status", status) + .append("domains", domains) + .append("targetKeys", targetKeys) + .toString(); + } + + } + + /** + * The internal class for domain in task url. + */ + public static class Domain { + + /** + * The domain name. + */ + private String domain; + /** + * The domain with https or not. + */ + private boolean enableHttps; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public boolean isEnableHttps() { + return enableHttps; + } + + public void setEnableHttps(boolean enableHttps) { + this.enableHttps = enableHttps; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("domain", domain) + .append("enableHttps", enableHttps) + .toString(); + } + + } + + public InstanceGetTaskUrlsResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public List getStageTaskUrls() { + return stageTaskUrls; + } + + public void setStageTaskUrls( + List stageTaskUrls) { + this.stageTaskUrls = stageTaskUrls; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("stageTaskUrls", stageTaskUrls) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceModel.java b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceModel.java new file mode 100644 index 00000000..480c314c --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/instance/InstanceModel.java @@ -0,0 +1,121 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow.instance; + +import com.baidubce.services.bvw.model.workflow.RunnableStatus; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * The instance of processing media and workflow. + */ +public class InstanceModel { + + /** + * The instance id. + */ + private String instanceId; + /** + * The instance status. + */ + private RunnableStatus status; + /** + * The user id. + */ + private String userId; + /** + * The workflow id. + */ + private String workflowId; + /** + * The media id. + */ + private String mediaId; + /** + * The source bucket of media. + */ + private String sourceBucket; + /** + * Th source key. + */ + private String sourceKey; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public RunnableStatus getStatus() { + return status; + } + + public void setStatus(RunnableStatus status) { + this.status = status; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + public String getSourceBucket() { + return sourceBucket; + } + + public void setSourceBucket(String sourceBucket) { + this.sourceBucket = sourceBucket; + } + + public String getSourceKey() { + return sourceKey; + } + + public void setSourceKey(String sourceKey) { + this.sourceKey = sourceKey; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("instanceId", instanceId) + .append("status", status) + .append("userId", userId) + .append("workflowId", workflowId) + .append("mediaId", mediaId) + .append("sourceBucket", sourceBucket) + .append("sourceKey", sourceKey) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskBaseOutputModel.java b/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskBaseOutputModel.java new file mode 100644 index 00000000..5c0f8c4d --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskBaseOutputModel.java @@ -0,0 +1,112 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow.task; + +import java.util.Date; + +import com.baidubce.services.bvw.model.common.UtcTime; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * The stage task base output. + */ +public class TaskBaseOutputModel { + + /** + * The task id. + */ + private String taskId; + /** + * The task is successful or not. + */ + private boolean success; + /** + * The task output json string. + */ + private String output; + /** + * If task is failed, will save the error message. + */ + private String errorMsg; + /** + * The begin time of task. + */ + @UtcTime + private Date beginTime; + /** + * The end time of task. + */ + @UtcTime + private Date endTime; + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getOutput() { + return output; + } + + public void setOutput(String output) { + this.output = output; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public Date getBeginTime() { + return beginTime; + } + + public void setBeginTime(Date beginTime) { + this.beginTime = beginTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("taskId", taskId) + .append("success", success) + .append("output", output) + .append("errorMsg", errorMsg) + .append("beginTime", beginTime) + .append("endTime", endTime) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskBaseRequest.java b/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskBaseRequest.java new file mode 100644 index 00000000..4fb169dc --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskBaseRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow.task; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Base task request. + */ +public class TaskBaseRequest extends AbstractBceRequest { + + /** + * The task id. + */ + private String taskId; + + /** + * Construct a base task request with specified parameters. + * @param taskId The task id + * @return A base task request + */ + public static TaskBaseRequest of(String taskId) { + TaskBaseRequest baseRequest = new TaskBaseRequest(); + baseRequest.setTaskId(taskId); + return baseRequest; + } + + @Override + public TaskBaseRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskGetResponse.java b/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskGetResponse.java new file mode 100644 index 00000000..3a14e0e5 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskGetResponse.java @@ -0,0 +1,128 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow.task; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bvw.BvwResponseMetadata; +import com.baidubce.services.bvw.model.workflow.RunnableStatus; +import com.baidubce.services.bvw.model.workflow.StageType; +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * Stage task response + */ +public class TaskGetResponse extends AbstractBceResponse { + + /** + * The task id. + */ + private String taskId; + /** + * The instance id. + */ + private String instanceId; + /** + * The task running status. + */ + private RunnableStatus status; + /** + * The stage id. + */ + private String stageId; + /** + * The stage name. + */ + private String name; + /** + * The stage task param. + */ + private TaskParamModel param; + /** + * The stage type. + */ + private StageType type; + + public TaskGetResponse() { + this.metadata = new BvwResponseMetadata(); + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public RunnableStatus getStatus() { + return status; + } + + public void setStatus(RunnableStatus status) { + this.status = status; + } + + public String getStageId() { + return stageId; + } + + public void setStageId(String stageId) { + this.stageId = stageId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public TaskParamModel getParam() { + return param; + } + + public void setParam(TaskParamModel param) { + this.param = param; + } + + public StageType getType() { + return type; + } + + public void setType(StageType type) { + this.type = type; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("taskId", taskId) + .append("instanceId", instanceId) + .append("status", status) + .append("stageId", stageId) + .append("name", name) + .append("param", param) + .append("type", type) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskParamModel.java b/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskParamModel.java new file mode 100644 index 00000000..0149a561 --- /dev/null +++ b/src/main/java/com/baidubce/services/bvw/model/workflow/task/TaskParamModel.java @@ -0,0 +1,55 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bvw.model.workflow.task; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * The task param of the stage. + */ +public class TaskParamModel { + + /** + * The stage task input param. + */ + private String input; + /** + * The stage task output param. + */ + private TaskBaseOutputModel output; + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public TaskBaseOutputModel getOutput() { + return output; + } + + public void setOutput(TaskBaseOutputModel output) { + this.output = output; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("input", input) + .append("output", output) + .toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/CdnClient.java b/src/main/java/com/baidubce/services/cdn/CdnClient.java index 05b10c8d..b4f3ce50 100644 --- a/src/main/java/com/baidubce/services/cdn/CdnClient.java +++ b/src/main/java/com/baidubce/services/cdn/CdnClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. + * Copyright 2016-2019 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -13,50 +13,166 @@ package com.baidubce.services.cdn; -import static com.baidubce.util.Validate.checkNotNull; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.HashSet; - import com.baidubce.AbstractBceClient; -import com.baidubce.auth.SignOptions; import com.baidubce.BceClientConfiguration; import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; import com.baidubce.http.Headers; import com.baidubce.http.HttpMethodName; import com.baidubce.http.handler.BceErrorResponseHandler; -import com.baidubce.http.handler.BceJsonResponseHandler; import com.baidubce.http.handler.BceMetadataResponseHandler; import com.baidubce.http.handler.HttpResponseHandler; import com.baidubce.internal.InternalRequest; import com.baidubce.internal.RestartableInputStream; import com.baidubce.model.AbstractBceRequest; - +import com.baidubce.services.cdn.model.CdnRequest; +import com.baidubce.services.cdn.model.CdnResponse; +import com.baidubce.services.cdn.model.DescribeIpRequest; +import com.baidubce.services.cdn.model.DescribeIpResponse; +import com.baidubce.services.cdn.model.GetCacheQuotaResponse; +import com.baidubce.services.cdn.model.GetPrefetchStatusRequest; +import com.baidubce.services.cdn.model.GetPurgeStatusRequest; +import com.baidubce.services.cdn.model.GetPurgeStatusResponse; import com.baidubce.services.cdn.model.ListDomainsRequest; import com.baidubce.services.cdn.model.ListDomainsResponse; import com.baidubce.services.cdn.model.PrefetchRequest; import com.baidubce.services.cdn.model.PrefetchResponse; import com.baidubce.services.cdn.model.PurgeRequest; import com.baidubce.services.cdn.model.PurgeResponse; -import com.baidubce.services.cdn.model.GetPurgeStatusRequest; -import com.baidubce.services.cdn.model.GetPurgeStatusResponse; -import com.baidubce.services.cdn.model.GetPrefetchStatusRequest; -import com.baidubce.services.cdn.model.GetPrefetchStatusResponse; -import com.baidubce.services.cdn.model.GetStatFlowRequest; -import com.baidubce.services.cdn.model.GetStatFlowResponse; - +import com.baidubce.services.cdn.model.PurgeTask; +import com.baidubce.services.cdn.model.SetDomainOriginRequest; +import com.baidubce.services.cdn.model.SetDomainHttpsConfigRequest; +import com.baidubce.services.cdn.model.domain.CheckDomainValidResponse; +import com.baidubce.services.cdn.model.DescribeIpsResponse; +import com.baidubce.services.cdn.model.domain.CommonResponse; +import com.baidubce.services.cdn.model.domain.CreateDomainRequest; +import com.baidubce.services.cdn.model.domain.CreateDomainResponse; +import com.baidubce.services.cdn.model.domain.DisableDomainResponse; +import com.baidubce.services.cdn.model.domain.EnableDomainResponse; +import com.baidubce.services.cdn.model.domain.GetDomainAccessLimitResponse; +import com.baidubce.services.cdn.model.domain.GetDomainCacheFullUrlResponse; +import com.baidubce.services.cdn.model.domain.GetDomainCacheShareResponse; +import com.baidubce.services.cdn.model.domain.GetDomainCacheTTLRequest; +import com.baidubce.services.cdn.model.domain.GetDomainCacheTTLResponse; +import com.baidubce.services.cdn.model.domain.GetDomainClientIpResponse; +import com.baidubce.services.cdn.model.domain.GetDomainCompressResponse; +import com.baidubce.services.cdn.model.domain.GetDomainConfigResponse; +import com.baidubce.services.cdn.model.domain.GetDomainCorsResponse; +import com.baidubce.services.cdn.model.domain.GetDomainErrorPageResponse; +import com.baidubce.services.cdn.model.domain.GetDomainFileTrimResponse; +import com.baidubce.services.cdn.model.domain.GetDomainHSTSResponse; +import com.baidubce.services.cdn.model.domain.GetDomainHttpHeaderResponse; +import com.baidubce.services.cdn.model.domain.GetDomainIPv6DispatchResponse; +import com.baidubce.services.cdn.model.domain.GetDomainIpACLResponse; +import com.baidubce.services.cdn.model.domain.GetDomainLogResponse; +import com.baidubce.services.cdn.model.domain.GetDomainMediaDragResponse; +import com.baidubce.services.cdn.model.domain.GetDomainMobileAccessResponse; +import com.baidubce.services.cdn.model.domain.GetDomainOCSPSwitchResponse; +import com.baidubce.services.cdn.model.domain.GetDomainOfflineModeSwitchResponse; +import com.baidubce.services.cdn.model.domain.GetDomainOriginProtocolResponse; +import com.baidubce.services.cdn.model.domain.GetDomainQUICSwitchResponse; +import com.baidubce.services.cdn.model.domain.GetDomainRangeSwitchResponse; +import com.baidubce.services.cdn.model.domain.GetDomainRefererACLResponse; +import com.baidubce.services.cdn.model.domain.GetDomainRetryOriginResponse; +import com.baidubce.services.cdn.model.domain.GetDomainSeoSwitchResponse; +import com.baidubce.services.cdn.model.domain.GetDomainTrafficLimitResponse; +import com.baidubce.services.cdn.model.domain.GetIcpResponse; +import com.baidubce.services.cdn.model.domain.DomainConfigKeysResponse; +import com.baidubce.services.cdn.model.domain.SetDomainOriginFixedIspRequest; +import com.baidubce.services.cdn.model.domain.GetDomainUaAclResponse; +import com.baidubce.services.cdn.model.domain.GetUserDomainResponse; +import com.baidubce.services.cdn.model.domain.GetUserDomainsRequest; +import com.baidubce.services.cdn.model.domain.SetDomainAccessLimitRequest; +import com.baidubce.services.cdn.model.domain.SetDomainCacheFullUrlRequest; +import com.baidubce.services.cdn.model.domain.SetDomainCacheShareRequest; +import com.baidubce.services.cdn.model.domain.SetDomainCacheTTLRequest; +import com.baidubce.services.cdn.model.domain.SetDomainClientIpRequest; +import com.baidubce.services.cdn.model.domain.SetDomainCompressRequest; +import com.baidubce.services.cdn.model.domain.SetDomainCorsRequest; +import com.baidubce.services.cdn.model.domain.SetDomainErrorPageRequest; +import com.baidubce.services.cdn.model.domain.SetDomainFileTrimRequest; +import com.baidubce.services.cdn.model.domain.SetDomainHSTSRequest; +import com.baidubce.services.cdn.model.domain.SetDomainHttpHeaderRequest; +import com.baidubce.services.cdn.model.domain.SetDomainIPv6DispatchRequest; +import com.baidubce.services.cdn.model.domain.SetDomainIpACLRequest; +import com.baidubce.services.cdn.model.domain.SetDomainMediaDragRequest; +import com.baidubce.services.cdn.model.domain.SetDomainMobileAccessRequest; +import com.baidubce.services.cdn.model.domain.SetDomainOCSPRequest; +import com.baidubce.services.cdn.model.domain.SetDomainOfflineModeRequest; +import com.baidubce.services.cdn.model.domain.SetDomainOriginProtocolRequest; +import com.baidubce.services.cdn.model.domain.SetDomainQUICRequest; +import com.baidubce.services.cdn.model.domain.SetDomainRangeSwitchRequest; +import com.baidubce.services.cdn.model.domain.SetDomainRefererACLRequest; +import com.baidubce.services.cdn.model.domain.SetDomainRetryOriginRequest; +import com.baidubce.services.cdn.model.domain.SetDomainSeoSwitchRequest; +import com.baidubce.services.cdn.model.domain.SetDomainTrafficLimitRequest; +import com.baidubce.services.cdn.model.domain.SetDomainUaAclRequest; +import com.baidubce.services.cdn.model.domain.SetRequestAuthRequest; +import com.baidubce.services.cdn.model.domain.CopyDomainTaskStatusResponse; +import com.baidubce.services.cdn.model.domain.CopyDomainTaskResponse; +import com.baidubce.services.cdn.model.domain.SetDomainOriginTimeoutRequest; +import com.baidubce.services.cdn.model.domain.CopyDomainTaskRequest; +import com.baidubce.services.cdn.model.domain.GetDomainOriginTimeoutResponse; +import com.baidubce.services.cdn.model.domain.GetDomainOriginFixedIspResponse; +import com.baidubce.services.cdn.model.domain.GetDomainUrlRulesResponse; +import com.baidubce.services.cdn.model.domain.GetDomainLimitBandwidthResponse; +import com.baidubce.services.cdn.model.domain.SetDomainUrlRulesRequest; +import com.baidubce.services.cdn.model.domain.SetDomainLimitBandwidthRequest; +import com.baidubce.services.cdn.model.domain.GetDomainOriginResponse; +import com.baidubce.services.cdn.model.handler.CdnJsonResponseHandler; +import com.baidubce.services.cdn.model.stat.GetMonth95Response; +import com.baidubce.services.cdn.model.stat.GetStatMetricResponse; +import com.baidubce.services.cdn.model.stat.GetStatMetricRequest; +import com.baidubce.services.cdn.model.stat.GetTopStatResponse; +import com.baidubce.services.cdn.model.stat.GetErrorCodeStatResponse; +import com.baidubce.services.cdn.model.stat.GetMetricStatResponse; +import com.baidubce.services.cdn.model.stat.GetIpv6StatResponse; +import com.baidubce.services.cdn.model.stat.GetMonth95Request; +import com.baidubce.services.cdn.model.stat.GetIpv6StatRequest; +import com.baidubce.services.cdn.model.stat.GetUploadStatRequest; +import com.baidubce.services.cdn.model.stat.GetIpv6RegionStatResponse; +import com.baidubce.services.cdn.model.stat.GetUploadStatResponse; +import com.baidubce.services.cdn.model.stat.GetXcdnStatMetricResponse; +import com.baidubce.services.cdn.model.stat.GetPackageUsageListRequest; +import com.baidubce.services.cdn.model.stat.GetXcdnStatMetricRequest; +import com.baidubce.services.cdn.model.stat.GetPackageUsageListResponse; +import com.baidubce.services.cdn.model.cache.GetPrefetchStatusResponse; +import com.baidubce.services.cdn.model.cache.PrefetchTask; +import com.baidubce.services.cdn.model.certificate.BatchUploadCertRequest; +import com.baidubce.services.cdn.model.certificate.GetDomainCertResponse; +import com.baidubce.services.cdn.model.certificate.SetDomainCertRequest; +import com.baidubce.services.cdn.model.certificate.GetHttpsDomainResponse; +import com.baidubce.services.cdn.model.certificate.SetDomainCertResponse; +import com.baidubce.services.cdn.model.certificate.GetHttpsDomainRequest; +import com.baidubce.services.cdn.model.dsa.GetDsaDomainListResponse; +import com.baidubce.services.cdn.model.dsa.SetDomainDsaRequest; +import com.baidubce.services.cdn.model.dsa.SetDsaRequest; +import com.baidubce.services.cdn.model.logmodel.GetDomainListLogRequest; +import com.baidubce.services.cdn.model.logmodel.GetDomainListLogResponse; +import com.baidubce.services.cdn.model.util.GetNodeListResponse; +import com.baidubce.services.cdn.model.util.GetForbiddenUrlsResponse; +import com.baidubce.services.cdn.model.util.GetForbiddenQuota; +import com.baidubce.services.cdn.model.util.GetForbiddenUrlsRequest; +import com.baidubce.services.cdn.model.util.GetForbiddenOperateHistoriesResponse; +import com.baidubce.services.cdn.model.util.SetForbiddenUrlsRequest; +import com.baidubce.services.cdn.model.util.GetForbiddenOperateHistoriesRequest; +import com.baidubce.util.DateUtils; import com.baidubce.util.HttpUtils; import com.baidubce.util.JsonUtils; -import com.baidubce.util.DateUtils; +import com.baidubce.util.Validate; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; +import java.util.List; /** - * Client for accessing CDN Services. + * Client for accessing CDN Services. * Created by sunyixing on 2016/1/9. + * Update by changxing01 on 2019/10/15 */ public class CdnClient extends AbstractBceClient { @@ -65,7 +181,7 @@ public class CdnClient extends AbstractBceClient { * The version information for Document service APIs as URI prefix. */ private static final String VERSION = "v2"; - + /** * The common URI prefix for domain operation. */ @@ -75,30 +191,42 @@ public class CdnClient extends AbstractBceClient { * The common URI prefix for statistic services. */ private static final String STAT = "stat"; - + /** * The common URI prefix for cache operation. */ private static final String CACHE = "cache"; - + + /** + * The common URI prefix for logmodel operation. + */ + private static final String LOG = "log"; + + /** + * The common URI prefix for utils operation. + */ + private static final String UTILS = "utils"; + + private static final String USER = "user"; + /** * Generate signature with specified headers. */ private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; - - private static final HttpResponseHandler[] cdnHandlers = new HttpResponseHandler[] { + + private static final HttpResponseHandler[] cdnHandlers = new HttpResponseHandler[]{ new BceMetadataResponseHandler(), new BceErrorResponseHandler(), - new BceJsonResponseHandler() + new CdnJsonResponseHandler() }; - + /** * Constructs a new Document client to invoke service methods on CDN. */ public CdnClient() { this(new BceClientConfiguration()); } - + /** * Constructs a new client using the client configuration to access CDN services. * @@ -108,7 +236,55 @@ public CdnClient() { public CdnClient(BceClientConfiguration clientConfiguration) { super(clientConfiguration, cdnHandlers); } - + + /** + * Create a new domain acceleration. + * + * @param request The request containing user-defined domain information. + * @return Result of the createDomain operation returned by the service. + */ + public CreateDomainResponse createDomain(CreateDomainRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain()); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CreateDomainResponse.class); + } + + /** + * Start an existing domain acceleration. + * + * @return Result of the enableDomain operation returned by the service. + */ + public EnableDomainResponse enableDomain(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.POST, DOMAIN, domain); + internalRequest.addParameter("enable", ""); + return invokeHttpClient(internalRequest, EnableDomainResponse.class); + } + + /** + * Disable an existing domain acceleration. + * + * @return Result of the disableDomain operation returned by the service. + */ + public DisableDomainResponse disableDomain(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.POST, DOMAIN, domain); + internalRequest.addParameter("disable", ""); + return invokeHttpClient(internalRequest, DisableDomainResponse.class); + } + + /** + * Delete an existing domain acceleration + * + * @return Result of the deleteDomain operation returned by the service. + */ + public CommonResponse deleteDomain(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.DELETE, DOMAIN, domain); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + /** * Returns a list of all CDN domains that the authenticated sender of the request owns. * @@ -117,178 +293,1986 @@ public CdnClient(BceClientConfiguration clientConfiguration) { public ListDomainsResponse listDomains() { return this.listDomains(new ListDomainsRequest()); } - + /** * Returns a list of all CDN domains that the authenticated sender of the request owns. * * @param request The request containing all of the options related to the listing of domains. * @return All of the CDN domains owned by the authenticated sender of the request. - */ + */ public ListDomainsResponse listDomains(ListDomainsRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request, "The parameter request should NOT be null."); InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DOMAIN); return invokeHttpClient(internalRequest, ListDomainsResponse.class); } - + /** - * Post prefetch request + * Return a list of user's all CDN domains that include domain and domain status + * support domain name fuzzy matching filter and domain status filter * - * @param request The request containing all of the urls to be prefetched. - * @return The task id + * @param status search domain status (ALL | RUNNING | STOPPED | OPERATING) + * @return a list of user's all CDN domains thats filter by status */ - public PrefetchResponse prefetch(PrefetchRequest request) { - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CACHE, "prefetch"); - this.attachRequestToBody(request, internalRequest); - return this.invokeHttpClient(internalRequest, PrefetchResponse.class); + public GetUserDomainResponse getUserDomains(String status) { + return getUserDomains(new GetUserDomainsRequest().withStatus(status)); } /** - * Post purge request - * @param request The request containing all of the urls to be purged. - * @return The task id + * Return a list of user's all CDN domains that include domain and domain status + * support domain name fuzzy matching filter and domain status filter + * + * @param request The request containing all of the options related to the listing of domains. + * @return a list of user's all CDN domains thats filter by status and rule */ - public PurgeResponse purge(PurgeRequest request) { - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CACHE, "purge"); + public GetUserDomainResponse getUserDomains(GetUserDomainsRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, USER, "domains"); + internalRequest.addParameter("status", request.getStatus()); + + if (request.getRule() != null) { + internalRequest.addParameter("rule", request.getRule()); + } + + return invokeHttpClient(internalRequest, GetUserDomainResponse.class); + } + + /** + * Query whether the domain name can be added + * 查询域名是否可添加 + * + * @param domain + * @return the result of check that include isValid and fail message + */ + public CheckDomainValidResponse checkDomainValid(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "valid"); + return invokeHttpClient(internalRequest, CheckDomainValidResponse.class); + } + + /** + * Query whether the domain name has icp + * 查询域名是否备案 + * + * @param domain domain + * @return the result of check that include isValid and fail message + */ + public GetIcpResponse getIcpStatus(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "icp"); + return invokeHttpClient(internalRequest, GetIcpResponse.class); + } + + /** + * 获取domain的能复制的配置项 + * Get the replicable configuration items of the domain + * + * @param domain domain + * @return getDomainConfig of the getDomainConfig operation returned by the service. + */ + public DomainConfigKeysResponse getDomainConfigKeys(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + "config_copy", "list"); + internalRequest.addParameter(DOMAIN, domain); + return invokeHttpClient(internalRequest, DomainConfigKeysResponse.class); + } + + /** + * 提交配置复制任务 + * Submit a configuration replication task + * + * @param originDomain 提供复制配置的域名 + * @param domains 要复制的域名列表 + * @param configNames 要复制的配置列表,其中config为域名配置项对应的key + * @return + */ + public CopyDomainTaskResponse copyDomainConfig(String originDomain, List domains, + List configNames) { + return copyDomainConfig(new CopyDomainTaskRequest() + .withOriginDomain(originDomain).withDomains(domains).withConfigs(configNames)); + } + + /** + * 提交配置复制任务 + * Submit a configuration replication task + * + * @param request The request containing all of the options related to the domain. + * @return getDomainConfig of the getDomainConfig operation returned by the service. + */ + public CopyDomainTaskResponse copyDomainConfig(CopyDomainTaskRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, + "config_copy", "submit"); this.attachRequestToBody(request, internalRequest); - return this.invokeHttpClient(internalRequest, PurgeResponse.class); + return invokeHttpClient(internalRequest, CopyDomainTaskResponse.class); } - + /** - * Get purge status with specified attributes. + * 查询当前用户配置复制任务状态 + * Query the status of the current user configuration replication task * - * @param request The request containing the task id returned by purge operation. - * @return Details of tasks + * @param taskId taskId + * @return getDomainConfig of the getDomainConfig operation returned by the service. */ - public GetPurgeStatusResponse getPurgeStatus(GetPurgeStatusRequest request) { - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CACHE, "purge"); - if (request.getId() != null) { - internalRequest.addParameter("id", request.getId()); - } + public CopyDomainTaskStatusResponse getCopyDomainStatus(String taskId) { + Validate.checkStringNotEmpty(taskId, "TaskId should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + "config_copy", "status"); + internalRequest.addParameter("taskId", taskId); + return invokeHttpClient(internalRequest, CopyDomainTaskStatusResponse.class); + } - if (request.getStartTime() != null) { - internalRequest.addParameter("startTime", DateUtils.formatAlternateIso8601Date(request.getStartTime())); - } - if (request.getEndTime() != null) { - internalRequest.addParameter("endTime", DateUtils.formatAlternateIso8601Date(request.getEndTime())); - } + /** ------------- 域名操作 END --------------**/ - if (request.getMarker() != null) { - internalRequest.addParameter("marker", request.getMarker()); - } + /** ------------- 域名配置 START --------------**/ - if (request.getUrl() != null) { - internalRequest.addParameter("url", request.getUrl()); - } + /** + * Get detailed information of a domain. + * + * @param domain The request containing all of the options related to the domain. + * @return getDomainConfig of the getDomainConfig operation returned by the service. + */ + public GetDomainConfigResponse getDomainConfig(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + return invokeHttpClient(internalRequest, GetDomainConfigResponse.class); + } - return this.invokeHttpClient(internalRequest, GetPurgeStatusResponse.class); + + /** ------ 回源配置 START -------- **/ + + /** + * Update origin of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainOrigin operation returned by the service. + */ + public CommonResponse setDomainOrigin(SetDomainOriginRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getOrigin(), "Origin should NOT be null."); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("origin", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + public GetDomainOriginResponse getDomainOrigin(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("origin", ""); + return invokeHttpClient(internalRequest, GetDomainOriginResponse.class); } - + /** - * Get prefetch status with specified attributes. + * Update RangeSwitch of specified domain acceleration. * - * @param request The request containing the task id returned by prefetch operation. - * @return Details of tasks + * @param domain domain's name + * @param rangeSwitch The request containing all of the options related to the domain. + * @return Result of the setDomainRangeSwitch operation returned by the service. */ - public GetPrefetchStatusResponse getPrefetchStatus(GetPrefetchStatusRequest request) { - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CACHE, "prefetch"); - if (request.getId() != null) { - internalRequest.addParameter("id", request.getId()); - } + public CommonResponse setDomainRangeSwitch(String domain, boolean rangeSwitch) { + return setDomainRangeSwitch(new SetDomainRangeSwitchRequest() + .withDomain(domain) + .withRangeSwitch(rangeSwitch)); + } - if (request.getStartTime() != null) { - internalRequest.addParameter("startTime", DateUtils.formatAlternateIso8601Date(request.getStartTime())); - } + /** + * Update RangeSwitch of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainRangeSwitch operation returned by the service. + */ + public CommonResponse setDomainRangeSwitch(SetDomainRangeSwitchRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain request should NOT be null."); - if (request.getEndTime() != null) { - internalRequest.addParameter("endTime", DateUtils.formatAlternateIso8601Date(request.getEndTime())); - } + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("rangeSwitch", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } - if (request.getMarker() != null) { - internalRequest.addParameter("marker", request.getMarker()); - } + /** + * Get RangeSwitch of specified domain acceleration. + * + * @param domain Name of the domain. + * @return Detailed information about domain rangeSwitch. + */ + public GetDomainRangeSwitchResponse getDomainRangeSwitch(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("rangeSwitch", ""); + return invokeHttpClient(internalRequest, GetDomainRangeSwitchResponse.class); + } - if (request.getUrl() != null) { - internalRequest.addParameter("url", request.getUrl()); - } + /** + * set ClientIp config of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainClientIp operation returned by the service. + */ + public CommonResponse setDomainClientIp(SetDomainClientIpRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getClientIp(), "ClientIp should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("clientIp", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } - return this.invokeHttpClient(internalRequest, GetPrefetchStatusResponse.class); + /** + * Get ClientIp config information of specified domain acceleration. + * + * @param domain + * @return Result of the getDomainClientIp operation returned by the service. + */ + public GetDomainClientIpResponse getDomainClientIp(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("clientIp", ""); + return invokeHttpClient(internalRequest, GetDomainClientIpResponse.class); } - + /** - * Get flow statistics with specified attributes. + * set origin protocal config of specified domain acceleration. * - * @param request The request containing all the options related to the statistics. - * @return Details of statistics + * @param request + * @return */ - public GetStatFlowResponse getStatFlow(GetStatFlowRequest request) { - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "flow"); - - if (request.getStartTime() != null) { - internalRequest.addParameter("startTime", DateUtils.formatAlternateIso8601Date(request.getStartTime())); - } - - if (request.getEndTime() != null) { - internalRequest.addParameter("endTime", DateUtils.formatAlternateIso8601Date(request.getEndTime())); - } - - if (request.getDomain() != null) { - internalRequest.addParameter("domain", request.getDomain()); - } - - if (request.getPeriod() != null) { - internalRequest.addParameter("period", String.valueOf(request.getPeriod())); - } - return this.invokeHttpClient(internalRequest, GetStatFlowResponse.class); + public CommonResponse setDomainOriginProtocol(SetDomainOriginProtocolRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getOriginProtocol(), "OriginProtocol should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("originProtocol", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); } - + /** - * Creates and initializes a new request object for the specified resource. + * Get origin protocol config information of specified domain acceleration. * - * @param bceRequest The original BCE request created by the user. - * @param httpMethod The HTTP method to use when sending the request. - * @param pathVariables The optional variables used in the URI path. - * @return A new request object populated with endpoint, resource path and specific - * parameters to send. + * @param domain + * @return */ - private InternalRequest createRequest( - AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { - List path = new ArrayList(); - path.add(VERSION); + public GetDomainOriginProtocolResponse getDomainOriginProtocol(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("originProtocol", ""); + return invokeHttpClient(internalRequest, GetDomainOriginProtocolResponse.class); + } - if (pathVariables != null) { - for (String pathVariable : pathVariables) { - path.add(pathVariable); - } - } + /** + * Update retry origin of specified domain acceleration. + * + * @param request + * @return + */ + public CommonResponse setDomainRetryOrigin(SetDomainRetryOriginRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); - URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); - InternalRequest request = new InternalRequest(httpMethod, uri); - SignOptions signOptions = new SignOptions(); - signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); - request.setSignOptions(signOptions); - request.setCredentials(bceRequest.getRequestCredentials()); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + request.setDomain(null); + internalRequest.addParameter("retryOrigin", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } - return request; + /** + * Get retry origin config information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainRetryOrigin operation returned by the service. + */ + public GetDomainRetryOriginResponse getDomainRetryOrigin(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("retryOrigin", ""); + return invokeHttpClient(internalRequest, GetDomainRetryOriginResponse.class); } - + /** - * put json object into http content for put or post request. + * Configure back-to-source timeout + * 设置回源超时 * * @param request - * json object of rest request - * @param httpRequest - * http request object + * @return */ - private void attachRequestToBody(AbstractBceRequest request, InternalRequest httpRequest) { - byte[] content; - try { - content = JsonUtils.toJsonString(request).getBytes("utf-8"); - } catch (UnsupportedEncodingException e) { - throw new BceClientException("utf-8 encoding not supported!", e); - } - httpRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(content.length)); - httpRequest.addHeader(Headers.CONTENT_TYPE, "application/json; charset=utf-8"); - httpRequest.setContent(RestartableInputStream.wrap(content)); + public CommonResponse setDomainOriginTimeout(SetDomainOriginTimeoutRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getOriginTimeout(), "OriginTimeout should NOT be null."); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + request.setDomain(null); + internalRequest.addParameter("originTimeout", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get back-to-source timeout + * 查询回源超时 + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainOriginTimeout operation returned by the service. + */ + public GetDomainOriginTimeoutResponse getDomainOriginTimeout(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("originTimeout", ""); + return invokeHttpClient(internalRequest, GetDomainOriginTimeoutResponse.class); + } + + /** + * Update up the same carrier back-to-origin + * + * @param request + * @return + */ + public CommonResponse setDomainOriginFixedISP(SetDomainOriginFixedIspRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getOriginFixedISP(), "OriginFixedISP should NOT be null."); + + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("originFixedISP", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get the same carrier back-to-origin + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the GetDomainOriginFixedIspResponse operation returned by the service. + */ + public GetDomainOriginFixedIspResponse getDomainOriginFixedISP(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("originFixedISP", ""); + return invokeHttpClient(internalRequest, GetDomainOriginFixedIspResponse.class); + } + + /** ------ 回源配置 END -------- **/ + + /** ------ 访问配置 START -------- **/ + + + /** + * Update RefererACL rules of specified domain acceleration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the setDomainRefererACL operation returned by the service. + */ + public CommonResponse setDomainRefererACL(SetDomainRefererACLRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getRefererACL(), "RefererACL should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("refererACL", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get RefererACL rules of specified domain acceleration. + * + * @param domain The request containing all of the options related to the get refererACL. + * @return Result of the getDomainRefererACL operation returned by the service. + */ + public GetDomainRefererACLResponse getDomainRefererACL(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("refererACL", ""); + return invokeHttpClient(internalRequest, GetDomainRefererACLResponse.class); + } + + /** + * Update IpACL rules of specified domain acceleration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the setDomainIpACL operation returned by the service. + */ + public CommonResponse setDomainIpACL(SetDomainIpACLRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getIpACL(), "IpACL should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("ipACL", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get IpACL rules of specified domain acceleration. + * + * @param domain The request containing all of the options related to the Get IpACL. + * @return Result of the getDomainIpACL operation returned by the service. + */ + public GetDomainIpACLResponse getDomainIpACL(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("ipACL", ""); + return invokeHttpClient(internalRequest, GetDomainIpACLResponse.class); + } + + /** + * set cors config of specified domain acceleration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the setDomainCors operation returned by the service. + */ + public CommonResponse setDomainCors(SetDomainCorsRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getCors(), "Cors should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("cors", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get Cors config information of a domain + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainCors operation returned by the service. + */ + public GetDomainCorsResponse getDomainCors(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("cors", ""); + return invokeHttpClient(internalRequest, GetDomainCorsResponse.class); + } + + /** + * Set the traffic limit of specified domain acceleration. + * each response to client + * + * @param request + * @return + */ + public CommonResponse setDomainTrafficLimit(SetDomainTrafficLimitRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getTrafficLimit(), "TrafficLimit should NOT be null."); + InternalRequest internalRequest = + createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("trafficLimit", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get trafficLimit of specified domain acceleration. + * for each response + * + * @param domain + * @return + */ + public GetDomainTrafficLimitResponse getDomainTrafficLimit(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = + createRequest(new CdnRequest(), HttpMethodName.GET, DOMAIN, domain, "config"); + internalRequest.addParameter("trafficLimit", ""); + return invokeHttpClient(internalRequest, GetDomainTrafficLimitResponse.class); + } + + + /** + * Set the request authentication. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the SetRequestAuthRequest operation returned by the service. + */ + public CommonResponse setDomainRequestAuth(SetRequestAuthRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getRequestAuth(), "RequestAuth should NOT be null."); + InternalRequest internalRequest = + createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("requestAuth", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * set AccessLimit config of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainAccessLimit operation returned by the service. + */ + public CommonResponse setDomainAccessLimit(SetDomainAccessLimitRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getAccessLimit(), "AccessLimit should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("accessLimit", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get AccessLimit config information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainAccessLimit operation returned by the service. + */ + public GetDomainAccessLimitResponse getDomainAccessLimit(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("accessLimit", ""); + return invokeHttpClient(internalRequest, GetDomainAccessLimitResponse.class); + } + + /** + * Set the UA ACL of specified domain acceleration. + * + * @param request + * @return + */ + public CommonResponse setDomainUaAcl(SetDomainUaAclRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getUaAcl(), "UaAcl should NOT be null."); + InternalRequest internalRequest = + createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("uaAcl", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get UA ACL of specified domain acceleration. + * + * @param domain + * @return + */ + public GetDomainUaAclResponse getDomainUaAcl(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = + createRequest(new CdnRequest(), HttpMethodName.GET, DOMAIN, domain, "config"); + internalRequest.addParameter("uaAcl", ""); + return invokeHttpClient(internalRequest, GetDomainUaAclResponse.class); + } + + /** -------- 访问配置 END -------- **/ + + /** -------- 缓存配置 START -------- **/ + + /** + * Update cache policies of specified domain acceleration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the setDomainCacheTTL operation returned by the service. + */ + public CdnResponse setDomainCacheTTL(SetDomainCacheTTLRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getCacheTTL(), "CacheTTL should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("cacheTTL", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CdnResponse.class); + } + + + /** + * Get cache policies of specified domain acceleration. + * + * @param domain Name of the domain. + * @return Detailed information about cache policies. + */ + public GetDomainCacheTTLResponse getDomainCacheTTL(String domain) { + GetDomainCacheTTLRequest request = new GetDomainCacheTTLRequest().withDomain(domain); + return getDomainCacheTTL(request); + } + + /** + * Get cache policies of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Detailed information about cache policies. + */ + public GetDomainCacheTTLResponse getDomainCacheTTL(GetDomainCacheTTLRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("cacheTTL", ""); + return invokeHttpClient(internalRequest, GetDomainCacheTTLResponse.class); + } + + /** + * Update cache policy of specified domain acceleration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the SetDomainCacheFullUrlRequest operation returned by the service. + */ + public CommonResponse setDomainCacheFullUrl(SetDomainCacheFullUrlRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getCacheFullUrl(), "CacheFullUrl should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("cacheFullUrl", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * search domain's rule of caching filter parameter + * + * @param domain The request containing all of the options related to the get cache full url request. + * @return domain's rule of cache filter parameter + */ + public GetDomainCacheFullUrlResponse getDomainCacheFullUrl(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("cacheFullUrl", ""); + return invokeHttpClient(internalRequest, GetDomainCacheFullUrlResponse.class); + } + + /** + * add website error page to deal with exception. + * + * @param request The request containing all of the options related to the set request. + * @return Result of the setDomainErrorPage operation returned by the service. + */ + public CommonResponse setDomainErrorPage(SetDomainErrorPageRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getErrorPage(), "ErrorPage should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("errorPage", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * search domain's custom error page + * + * @param domain The request containing all of the options related to the get error page request. + * @return custom error page info list + */ + public GetDomainErrorPageResponse getDomainErrorPage(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("errorPage", ""); + return invokeHttpClient(internalRequest, GetDomainErrorPageResponse.class); + } + + /** + * Update MobileAccess of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainMobileAccess operation returned by the service. + */ + public CommonResponse setDomainMobileAccess(SetDomainMobileAccessRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be null."); + Validate.checkNotNull(request.getMobileAccess(), "MobileAccess should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("mobileAccess", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get MobileAccess of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Detailed information about domain MobileAccess. + */ + public GetDomainMobileAccessResponse getDomainMobileAccess(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be null."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("mobileAccess", ""); + return invokeHttpClient(internalRequest, GetDomainMobileAccessResponse.class); + } + + /** + * Update Domain cache share of specified domain acceleration. + * + * @param request + * @return + */ + public CommonResponse setDomainCacheShare(SetDomainCacheShareRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be empty."); + Validate.checkNotNull(request.getCacheShare(), "CacheShare should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("cacheShare", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get cache share config information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainCacheShare operation returned by the service. + */ + public GetDomainCacheShareResponse getDomainCacheShare(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("cacheShare", ""); + return invokeHttpClient(internalRequest, GetDomainCacheShareResponse.class); + } + + /** + * Update Domain URI rewrite of specified domain acceleration. + * + * @param request + * @return + */ + public CommonResponse setDomainUrlRules(SetDomainUrlRulesRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be empty."); + Validate.checkNotNull(request.getUrlRules(), "UrlRules should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + request.setDomain(null); + internalRequest.addParameter("urlRules", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + + /** + * Get Domain URI rewrite of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the GetDomainUrlRulesResponse operation returned by the service. + */ + public GetDomainUrlRulesResponse getDomainUrlRules(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("urlRules", ""); + return invokeHttpClient(internalRequest, GetDomainUrlRulesResponse.class); + } + + /** -------- 缓存配置 EDN -------- **/ + + /** -------- 高级配置 START -------- **/ + + /** + * Update HttpHeader of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainHttpHeader operation returned by the service. + */ + public CommonResponse setDomainHttpHeader(SetDomainHttpHeaderRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be empty."); + Validate.checkNotNull(request.getHttpHeader(), "HttpHeader should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("httpHeader", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get HttpHeader of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Detailed information about domain HttpHeader. + */ + public GetDomainHttpHeaderResponse getDomainHttpHeader(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("httpHeader", ""); + return invokeHttpClient(internalRequest, GetDomainHttpHeaderResponse.class); + } + + /** + * Update SeoSwitch of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainSeoSwitch operation returned by the service. + */ + public CommonResponse setDomainSeoSwitch(SetDomainSeoSwitchRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be empty."); + Validate.checkNotNull(request.getSeoSwitch(), "SeoSwitch should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("seoSwitch", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get SeoSwitch of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Detailed information about domain SeoSwitch. + */ + public GetDomainSeoSwitchResponse getDomainSeoSwitch(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("seoSwitch", ""); + return invokeHttpClient(internalRequest, GetDomainSeoSwitchResponse.class); + } + + /** + * Update MediaDrag of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainMediaDrag operation returned by the service. + */ + public CommonResponse setDomainMediaDrag(SetDomainMediaDragRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be empty."); + Validate.checkNotNull(request.getMediaDragConf(), "MediaDragConf should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("mediaDrag", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get MediaDrag of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Detailed information about domain MediaDrag. + */ + public GetDomainMediaDragResponse getDomainMediaDrag(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("mediaDrag", ""); + return invokeHttpClient(internalRequest, GetDomainMediaDragResponse.class); + } + + /** + * Update FileTrim of specified domain acceleration. + * + * @param domain Name of the domain. + * @param fileTrim Whether to enable page optimization + */ + public void setDomainFileTrim(String domain, boolean fileTrim) { + setDomainFileTrim(new SetDomainFileTrimRequest().withDomain(domain).withFileTrim(fileTrim)); + } + + /** + * Update FileTrim of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainFileTrim operation returned by the service. + */ + public CommonResponse setDomainFileTrim(SetDomainFileTrimRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("fileTrim", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get FileTrim of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Detailed information about domain FileTrim. + */ + public GetDomainFileTrimResponse getDomainFileTrim(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("fileTrim", ""); + return invokeHttpClient(internalRequest, GetDomainFileTrimResponse.class); + } + + /** + * Update Compress of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the setDomainCompress operation returned by the service. + */ + public CommonResponse setDomainCompress(SetDomainCompressRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be empty."); + Validate.checkNotNull(request.getCompress(), "Compress should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("compress", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get Compress of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Detailed information about domain Compress. + */ + public GetDomainCompressResponse getDomainCompress(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("compress", ""); + return invokeHttpClient(internalRequest, GetDomainCompressResponse.class); + } + + /** + * Update QUIC of specified domain acceleration. + * + * @param domain + * @param quic true表示开启QUIC,false表示关闭。预启用QUIC的域名必须已经开启了HTTPS。 + * @return + */ + public CommonResponse setDomainQUICSwitch(String domain, boolean quic) { + return setDomainQUICSwitch(new SetDomainQUICRequest().withDomain(domain).withQuic(quic)); + } + + /** + * Update QUIC of specified domain acceleration. + * + * @param request + * @return + */ + public CommonResponse setDomainQUICSwitch(SetDomainQUICRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getDomain(), "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("quic", ""); + attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get ipv6Dispatch config information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainClientIp operation returned by the service. + */ + public GetDomainQUICSwitchResponse getDomainQUICSwitch(String domain) { + Validate.checkNotNull(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("quic", ""); + return invokeHttpClient(internalRequest, GetDomainQUICSwitchResponse.class); + } + + /** + * Update ipv6Dispatch of specified domain acceleration. + * + * @param request + * @return + */ + public CommonResponse setDomainIPv6Dispatch(SetDomainIPv6DispatchRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("ipv6Dispatch", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get ipv6Dispatch config information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainClientIp operation returned by the service. + */ + public GetDomainIPv6DispatchResponse getDomainIPv6Dispatch(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("ipv6Dispatch", ""); + return invokeHttpClient(internalRequest, GetDomainIPv6DispatchResponse.class); + } + + + /** + * Update offline mode of specified domain acceleration. + * + * @param domain + * @param offlineMode 设置离线模式与否,true/false表示开启/关闭 + * @return + */ + public CommonResponse setDomainOfflineModeSwitch(String domain, boolean offlineMode) { + return setDomainOfflineModeSwitch(new SetDomainOfflineModeRequest() + .withDomain(domain).withOfflineMode(offlineMode)); + } + + /** + * Update offline mode of specified domain acceleration. + * + * @param request + * @return + */ + public CommonResponse setDomainOfflineModeSwitch(SetDomainOfflineModeRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("offlineMode", ""); + attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get OfflineMode config information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainClientIp operation returned by the service. + */ + public GetDomainOfflineModeSwitchResponse getDomainOfflineModeSwitch(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("offlineMode", ""); + return invokeHttpClient(internalRequest, GetDomainOfflineModeSwitchResponse.class); + } + + /** + * Update LimitBandwidth of specified domain acceleration. + * + * @param request + * @return + */ + public CommonResponse setDomainLimitBandwidth(SetDomainLimitBandwidthRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + Validate.checkNotNull(request.getLimitBandwidth(), "LimitBandwidth should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("limitBandwidth", ""); + attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get LimitBandwidth config information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the GetDomainOfflineModeSwitchResponse operation returned by the service. + */ + public GetDomainLimitBandwidthResponse getDomainLimitBandwidth(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("limitBandwidth", ""); + return invokeHttpClient(internalRequest, GetDomainLimitBandwidthResponse.class); + } + + /** -------- 高级配置 END -------- **/ + + /** -------- HTTPS配置 START -------- **/ + + /** + * Set HTTPS with certain configuration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the setHTTPSAcceleration operation returned by the service. + */ + public CommonResponse setDomainHttpsConfig(SetDomainHttpsConfigRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("https", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Update HSTS rules of specified domain acceleration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the setDomainHSTS operation returned by the service. + */ + public CommonResponse setDomainHSTS(SetDomainHSTSRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + Validate.checkNotNull(request.getHSTS(), "HSTS should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + request.setDomain(null); + internalRequest.addParameter("hsts", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get ipv6Dispatch config information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainClientIp operation returned by the service. + */ + public GetDomainHSTSResponse getDomainHSTS(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("hsts", ""); + return invokeHttpClient(internalRequest, GetDomainHSTSResponse.class); + } + + + public CommonResponse setDomainOCSPSwitch(String domain, boolean ocsp) { + return setDomainOCSPSwitch(new SetDomainOCSPRequest().withDomain(domain).withOcsp(ocsp)); + } + + /** + * Update OCSP of specified domain acceleration. + * + * @param request domain and switch + * @return + */ + public CommonResponse setDomainOCSPSwitch(SetDomainOCSPRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, + request.getDomain(), "config"); + internalRequest.addParameter("ocsp", ""); + attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + /** + * Get ipv6Dispatch config information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainClientIp operation returned by the service. + */ + public GetDomainOCSPSwitchResponse getDomainOCSPSwitch(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + DOMAIN, domain, "config"); + internalRequest.addParameter("ocsp", ""); + return invokeHttpClient(internalRequest, GetDomainOCSPSwitchResponse.class); + } + + /** -------- HTTPS配置 END -------- **/ + + /** -------- 证书配置 START -------- **/ + + /** + * add/update certificate of specified domain + * + * @param request + * @return + */ + public SetDomainCertResponse setDomainCert(SetDomainCertRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getCertificate(), "Certificate should NOT be null."); + Validate.checkStringNotEmpty(request.getHttpsEnable(), "HttpsEnable should NOT be empty."); + Validate.checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + request.getDomain(), "certificates"); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetDomainCertResponse.class); + } + + /** + * Get Domain Cert detail information of specified domain acceleration. + * + * @param domain The request containing all of the options related to the domain. + * @return Result of the getDomainClientIp operation returned by the service. + */ + public GetDomainCertResponse getDomainCert(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.GET, + domain, "certificates"); + return invokeHttpClient(internalRequest, GetDomainCertResponse.class); + } + + /** + * delete certificate of specified domain + * + * @param domain + * @return + */ + public CdnResponse deleteDomainCert(String domain) { + Validate.checkStringNotEmpty(domain, "Domain should NOT be empty."); + InternalRequest internalRequest = createRequest(new CdnRequest(), HttpMethodName.DELETE, + domain, "certificates"); + return invokeHttpClient(internalRequest, CdnResponse.class); + } + + + /** + * Get Domain Cert detail information of specified domain acceleration. + * + * @param request The request containing all of the options related to the domain. + * @return Result of the GetHttpsDomainResponse operation returned by the service. + */ + public GetHttpsDomainResponse getHttpsDomains(GetHttpsDomainRequest request) { + if (request == null) { + request = new GetHttpsDomainRequest(); + } + + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, + "httpsDomains"); + + if (request.getCertCommonName() != null) { + internalRequest.addParameter("certCommonName", request.getCertCommonName()); + } + + if (request.getCertId() != null) { + internalRequest.addParameter("certId", request.getCertId()); + } + + if (request.getCertName() != null) { + internalRequest.addParameter("certName", request.getCertName()); + } + + if (request.getDomain() != null) { + internalRequest.addParameter("domain", request.getDomain()); + } + + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", request.getPageNo().toString()); + } + + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", request.getPageSize().toString()); + } + + if (request.getStatus() != null) { + internalRequest.addParameter("status", request.getStatus().toString()); + } + + return invokeHttpClient(internalRequest, GetHttpsDomainResponse.class); + } + + /** + * add/update certificate of specified domain + * + * @param request + * @return + */ + public SetDomainCertResponse bathUploadDomainCert(BatchUploadCertRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getCertificate(), "Certificate should NOT be null."); + Validate.checkNotNull(request.getDomains(), "Domains should NOT be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, + DOMAIN, "certificate"); + internalRequest.addParameter("action", "put"); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetDomainCertResponse.class); + } + + /** -------- 证书配置 END -------- **/ + + /** -------- 缓存管理 START -------- **/ + + /** + * Post purge request + * + * @param url The URL to be purged. + * @return Result of the purge operation returned by the service. + */ + public PurgeResponse purge(String url) { + return purge(new PurgeRequest().addTask(new PurgeTask().withUrl(url))); + } + + /** + * Post purge request + * + * @param directory The directory to be purged. + * @return Result of the purge operation returned by the service. + */ + public PurgeResponse purgeDirectory(String directory) { + return purge(new PurgeRequest().addTask(new PurgeTask().withDirectory(directory))); + } + + /** + * Post purge request + * + * @param request The request containing all of the URLs to be purged. + * @return Result of the purge operation returned by the service. + */ + public PurgeResponse purge(PurgeRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getTasks(), "Task should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + CACHE, "purge"); + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, PurgeResponse.class); + } + + /** + * Get purge status with specified attributes. + * + * @param request The request containing the task id returned by purge operation. + * @return Details of tasks + */ + public GetPurgeStatusResponse getPurgeStatus(GetPurgeStatusRequest request) { + if (request == null) { + request = new GetPurgeStatusRequest(); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + CACHE, "purge"); + if (request.getId() != null) { + internalRequest.addParameter("id", request.getId()); + } + + if (request.getStartTime() != null) { + internalRequest.addParameter("startTime", + DateUtils.formatAlternateIso8601Date(request.getStartTime())); + } + + if (request.getEndTime() != null) { + internalRequest.addParameter("endTime", + DateUtils.formatAlternateIso8601Date(request.getEndTime())); + } + + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + + if (request.getUrl() != null) { + internalRequest.addParameter("url", request.getUrl()); + } + + return this.invokeHttpClient(internalRequest, GetPurgeStatusResponse.class); + } + + /** + * Get cache operation quota. + * + * @return Details of statistics + */ + public GetCacheQuotaResponse getCacheQuota() { + InternalRequest internalRequest = this.createRequest(new CdnRequest(), HttpMethodName.GET, + CACHE, "quota"); + return this.invokeHttpClient(internalRequest, GetCacheQuotaResponse.class); + } + + /** + * Post prefetch request + * + * @param url The URL to be prefetched. + * @return Result of the prefetch operation returned by the service. + */ + public PrefetchResponse prefetch(String url) { + return prefetch(new PrefetchRequest().addTask(new PrefetchTask().withUrl(url))); + } + + /** + * Post prefetch request + * + * @param request The request containing all of the URLs to be prefetched. + * @return Result of the prefetch operation returned by the service. + */ + public PrefetchResponse prefetch(PrefetchRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getTasks(), "Task should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + CACHE, "prefetch"); + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, PrefetchResponse.class); + } + + /** + * Get prefetch status with specified attributes. + * + * @param request The request containing the task id returned by prefetch operation. + * @return Details of tasks + */ + public GetPrefetchStatusResponse getPrefetchStatus(GetPrefetchStatusRequest request) { + if (request == null) { + request = new GetPrefetchStatusRequest(); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + CACHE, "prefetch"); + if (request.getId() != null) { + internalRequest.addParameter("id", request.getId()); + } + + if (request.getStartTime() != null) { + internalRequest.addParameter("startTime", + DateUtils.formatAlternateIso8601Date(request.getStartTime())); + } + + if (request.getEndTime() != null) { + internalRequest.addParameter("endTime", + DateUtils.formatAlternateIso8601Date(request.getEndTime())); + } + + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + + if (request.getUrl() != null) { + internalRequest.addParameter("url", request.getUrl()); + } + + return this.invokeHttpClient(internalRequest, GetPrefetchStatusResponse.class); + } + + /** -------- 缓存管理 END -------- **/ + + /** -------- 日志统计接口 START -------- **/ + + /** + * Get URLs of logmodel files + * + * @param domain domain info + * @param startTime startTime + * @param endTime endTime + * @return Details of statistics + */ + public GetDomainLogResponse getDomainLog(String domain, Date startTime, Date endTime) { + Validate.checkNotNull(domain, "The parameter request should NOT be null."); + Validate.checkNotNull(startTime, "StartTime should NOT be null."); + Validate.checkNotNull(endTime, "EndTime should NOT be null."); + + CdnRequest request = new CdnRequest(); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + LOG, domain, "log"); + + internalRequest.addParameter("startTime", DateUtils.formatAlternateIso8601Date(startTime)); + internalRequest.addParameter("endTime", DateUtils.formatAlternateIso8601Date(endTime)); + + return this.invokeHttpClient(internalRequest, GetDomainLogResponse.class); + } + + /** + * Get URLs of logmodel files + * + * @param domain domain info + * @param startTime startTime + * @param endTime endTime + * @return Details of statistics + */ + public GetDomainLogResponse getDomainLog(String domain, String startTime, String endTime) { + Validate.checkNotNull(domain, "The parameter request should NOT be null."); + Validate.checkNotNull(startTime, "StartTime should NOT be null."); + Validate.checkNotNull(endTime, "EndTime should NOT be null."); + + CdnRequest request = new CdnRequest(); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + LOG, domain, "log"); + + internalRequest.addParameter("startTime", startTime); + internalRequest.addParameter("endTime", endTime); + + return this.invokeHttpClient(internalRequest, GetDomainLogResponse.class); + } + + /** + * Get multiple domain URLs of logmodel files + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetDomainListLogResponse getDomainListLog(GetDomainListLogRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getStartTime(), "StartTime should NOT be null."); + Validate.checkNotNull(request.getEndTime(), "EndTime should NOT be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + LOG, "list"); + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, GetDomainListLogResponse.class); + } + + /** + * Get statistics metric with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetMetricStatResponse getStatMetricData(GetStatMetricRequest request) { + GetStatMetricResponse statMetricData = getStatMetricDefaultData(request); + return JsonUtils.fromJsonString(JsonUtils.toJsonString(statMetricData), GetMetricStatResponse.class); + } + + /** + * Get statistics metric with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetStatMetricResponse getStatMetricDefaultData(GetStatMetricRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getMetric(), "Metric should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + STAT, "query"); + // this.attachRequestToBody(request, internalRequest); + byte[] content; + try { + content = JsonUtils.toJsonString(request).getBytes("utf-8"); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("utf-8 encoding not supported!", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(content.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json; charset=utf-8"); + internalRequest.setContent(RestartableInputStream.wrap(content)); + return this.invokeHttpClient(internalRequest, GetStatMetricResponse.class); + } + + /** + * Get statistics metric with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetMonth95Response getMonth95Data(GetMonth95Request request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getType(), "Type should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, "billing"); + + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, GetMonth95Response.class); + } + + /** + * Get statistics metric with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetTopStatResponse getTopStatData(GetStatMetricRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getMetric(), "Metric should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + STAT, "query"); + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, GetTopStatResponse.class); + } + + /** + * Get statistics metric with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetIpv6StatResponse getStatIpv6Data(GetIpv6StatRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + STAT, "ipv6"); + + internalRequest.addParameter("stat_type", request.getStatType() == null ? "all" : request.getStatType()); + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, GetIpv6StatResponse.class); + } + + /** + * Get statistics metric with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetIpv6RegionStatResponse getStatRegionIpv6Data(GetIpv6StatRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + STAT, "ipv6"); + + internalRequest.addParameter("stat_type", "region"); + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, GetIpv6RegionStatResponse.class); + } + + /** + * Get statistics metric with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetErrorCodeStatResponse getErrorCodeStatData(GetStatMetricRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + GetStatMetricResponse statMetricData = getStatMetricDefaultData(request.withMetric("error")); + return JsonUtils.fromJsonString(JsonUtils.toJsonString(statMetricData), GetErrorCodeStatResponse.class); + } + + /** + * Get statistics metric with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetUploadStatResponse getUploadStatData(GetUploadStatRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + STAT, "upload_detail"); + + internalRequest.addParameter("type", request.getType() == null ? "all" : request.getType()); + this.attachRequestToBody(request, internalRequest); + + return this.invokeHttpClient(internalRequest, GetUploadStatResponse.class); + } + + /** + * Get upload stat peak with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetUploadStatResponse getUploadPeakStatData(GetUploadStatRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + + if (request.getType() != null && !"peak".equals(request.getType()) && !"95_peak".equals(request.getType()) + && !"day_peak".equals(request.getType())) { + throw new IllegalArgumentException("Type Error"); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + STAT, "upload_peak"); + + if (request.getType() != null) { + internalRequest.addParameter("type", request.getType() == null ? "peak" : request.getType()); + } + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, GetUploadStatResponse.class); + } + + /** + * Get Xcdn stat with specified attributes (stat_version_2.0). + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetXcdnStatMetricResponse getXcdnStatData(GetXcdnStatMetricRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getMetric(), "Metric should NOT be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + "xcdn", STAT, "query"); + + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, GetXcdnStatMetricResponse.class); + } + + /** -------- 日志统计接口 END -------- **/ + + /** -------- 工具接口 START -------- **/ + + /** + * Get the description of certain IP address. + * + * @param ip IP address. + * @return Details of statistics + */ + public DescribeIpResponse describeIp(String ip) { + return describeIp(new DescribeIpRequest().withIp(ip)); + } + + /** + * Get the description of certain IP address. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public DescribeIpResponse describeIp(DescribeIpRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getIp(), "IP should NOT be null."); + Validate.checkStringNotEmpty(request.getAction(), "ACTION should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, UTILS); + internalRequest.addParameter("action", request.getAction()); + internalRequest.addParameter("ip", request.getIp()); + + return this.invokeHttpClient(internalRequest, DescribeIpResponse.class); + } + + /** + * Get the description of certain IP address. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public DescribeIpsResponse describeIps(DescribeIpRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkMultyParamsNotBothEmpty(request.getIps(), "IPs should NOT be null."); + Validate.checkStringNotEmpty(request.getAction(), "ACTION should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, UTILS, "ips"); + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, DescribeIpsResponse.class); + } + + /** + * Get the node address. + * + * @return Details of statistics + */ + public GetNodeListResponse getNodeList() { + InternalRequest internalRequest = this.createRequest(new CdnRequest(), HttpMethodName.GET, + "nodes", "list"); + + return this.invokeHttpClient(internalRequest, GetNodeListResponse.class); + } + + /** + * Get the quota of forbidden. + * + * @return ForbiddenQuota + */ + public GetForbiddenQuota getForbiddenQuota() { + InternalRequest internalRequest = this.createRequest(new CdnRequest(), HttpMethodName.GET, + "firewalls", "forbidden", "quota"); + + return this.invokeHttpClient(internalRequest, GetForbiddenQuota.class); + } + + /** + * Get the quota of forbidden. + * + * @return ForbiddenQuota + */ + public GetForbiddenUrlsResponse getForbiddenUrls(GetForbiddenUrlsRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = this.createRequest(new CdnRequest(), HttpMethodName.GET, + "firewalls", "forbidden", "urls"); + + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("orderBy", request.getOrderBy()); + if (request.getUrl() != null) { + internalRequest.addParameter("url", request.getUrl()); + } + + return this.invokeHttpClient(internalRequest, GetForbiddenUrlsResponse.class); + } + + /** + * Get the quota of forbidden. + * + * @return ForbiddenQuota + */ + public GetForbiddenOperateHistoriesResponse getForbiddenOperateHistories( + GetForbiddenOperateHistoriesRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = this.createRequest(new CdnRequest(), HttpMethodName.GET, + "firewalls", "forbidden", "operateHistories"); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("orderBy", request.getOrderBy()); + + if (request.getStartTime() != null) { + internalRequest.addParameter("startTime", request.getStartTime()); + } + if (request.getEndTime() != null) { + internalRequest.addParameter("endTime", request.getEndTime()); + } + if (request.getUrl() != null) { + internalRequest.addParameter("url", request.getUrl()); + } + + return this.invokeHttpClient(internalRequest, GetForbiddenOperateHistoriesResponse.class); + } + + /** + * Get the description of certain IP address. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public CdnResponse setForbiddenBan(SetForbiddenUrlsRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getUrls(), "The parameter request should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + "firewalls", "forbidden", "ban"); + + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, CdnResponse.class); + } + + /** + * Get the description of certain IP address. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public CdnResponse setForbiddenUnBan(SetForbiddenUrlsRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkNotNull(request.getUrls(), "The parameter request should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + "firewalls", "forbidden", "unban"); + + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, CdnResponse.class); + } + + /** -------- 工具接口 EDN -------- **/ + + /** -------- 用量接口 START -------- **/ + + /** + * 用量查询 + * 本接口用于查看资源包详情。 + * + * @param request + * @return + */ + public GetPackageUsageListResponse getPackageUsageList(GetPackageUsageListRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + "package", "usagelist"); + + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, GetPackageUsageListResponse.class); + } + + /** -------- 用量接口 EDN -------- **/ + + /** -------- 动态加速接口 START -------- **/ + + /** + * Update dsa service of specified domain acceleration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the setDsa operation returned by the service. + */ + public CdnResponse setDsa(SetDsaRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + Validate.checkStringNotEmpty(request.getAction(), "Action should NOT be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, "dsa"); + this.attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, CdnResponse.class); + } + + /** + * Get Dsa Domain List. + * + * @return Details of DsaDomain + */ + public GetDsaDomainListResponse getDsaDomainList() { + CdnRequest request = new CdnRequest(); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, "dsa", DOMAIN); + return this.invokeHttpClient(internalRequest, GetDsaDomainListResponse.class); + } + + /** + * Update Dsa rules of specified domain acceleration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the setDomainDsa operation returned by the service. + */ + public void setDomainDsa(SetDomainDsaRequest request) { + Validate.checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("dsa", ""); + this.attachRequestToBody(request, internalRequest); + invokeHttpClient(internalRequest, CdnResponse.class); + } + + /** -------- 动态加速接口 END -------- **/ + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest( + AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + + return request; + } + + /** + * put json object into http content for put or post request. + * + * @param request json object of rest request + * @param httpRequest http request object + */ + private void attachRequestToBody(AbstractBceRequest request, InternalRequest httpRequest) { + byte[] content; + try { + content = JsonUtils.toJsonString(request).getBytes("utf-8"); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("utf-8 encoding not supported!", e); + } + httpRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(content.length)); + httpRequest.addHeader(Headers.CONTENT_TYPE, "application/json; charset=utf-8"); + httpRequest.setContent(RestartableInputStream.wrap(content)); + } + + private void validateAndFillRequestUrl(InternalRequest internalRequest, + String type, Date startTime, Date endTime, + String url, String marker) { + if (type != null) { + internalRequest.addParameter("type", type); + } + + if (startTime != null) { + internalRequest.addParameter("startTime", DateUtils.formatAlternateIso8601Date(startTime)); + } + + if (endTime != null) { + internalRequest.addParameter("endTime", DateUtils.formatAlternateIso8601Date(endTime)); + } + + if (url != null) { + internalRequest.addParameter("url", url); + } + + if (marker != null) { + internalRequest.addParameter("marker", String.valueOf(marker)); + } + } } diff --git a/src/main/java/com/baidubce/services/cdn/model/CdnRequest.java b/src/main/java/com/baidubce/services/cdn/model/CdnRequest.java new file mode 100644 index 00000000..fa5fc80e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/CdnRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.cdn.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +public class CdnRequest extends AbstractBceRequest { + + /** + * (non-Javadoc) + * + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public CdnRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/CdnResponse.java b/src/main/java/com/baidubce/services/cdn/model/CdnResponse.java index 12fe23bc..f3e9a690 100644 --- a/src/main/java/com/baidubce/services/cdn/model/CdnResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/CdnResponse.java @@ -12,17 +12,30 @@ */ package com.baidubce.services.cdn.model; -import com.baidubce.model.AbstractBceResponse; import com.baidubce.BceResponseMetadata; +import com.baidubce.model.AbstractBceResponse; import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; +/** + * @author yixing + * + * Base class + * + */ public class CdnResponse extends AbstractBceResponse { + /** + * @param metadata + */ public void setMetadata(BceResponseMetadata metadata) { this.metadata = metadata; } + /** + * (non-Javadoc) + * @see Object#toString() + */ @Override public String toString() { try { diff --git a/src/main/java/com/baidubce/services/cdn/model/DescribeIpRequest.java b/src/main/java/com/baidubce/services/cdn/model/DescribeIpRequest.java new file mode 100644 index 00000000..89bffe41 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/DescribeIpRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +import java.util.List; + +public class DescribeIpRequest extends CdnRequest { + private String action = "describeIp"; + private String ip; + private List ips; + + public DescribeIpRequest withAction(String action) { + setAction(action); + return this; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public DescribeIpRequest withIp(String ip) { + setIp(ip); + return this; + } + + public DescribeIpRequest withIps(List ip) { + setIps(ip); + return this; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public List getIps() { + return ips; + } + + public void setIps(List ips) { + this.ips = ips; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/StatFlowDetails.java b/src/main/java/com/baidubce/services/cdn/model/DescribeIpResponse.java similarity index 56% rename from src/main/java/com/baidubce/services/cdn/model/StatFlowDetails.java rename to src/main/java/com/baidubce/services/cdn/model/DescribeIpResponse.java index 34616f1e..bb57fd87 100644 --- a/src/main/java/com/baidubce/services/cdn/model/StatFlowDetails.java +++ b/src/main/java/com/baidubce/services/cdn/model/DescribeIpResponse.java @@ -13,34 +13,32 @@ package com.baidubce.services.cdn.model; -import java.util.Date; - -public class StatFlowDetails extends JsonObject { - private Date timestamp; - private Integer flow; - private Integer bps; +public class DescribeIpResponse extends CdnResponse { + private boolean cdnIP; + private String isp; + private String region; - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; + public boolean isCdnIP() { + return cdnIP; } - public Date getTimestamp() { - return timestamp; + public void setCdnIP(boolean cdnIP) { + this.cdnIP = cdnIP; } - public void setFlow(Integer flow) { - this.flow = flow; + public String getIsp() { + return isp; } - public Integer getFlow() { - return flow; + public void setIsp(String isp) { + this.isp = isp; } - public void setBps(Integer bps) { - this.bps = bps; + public String getRegion() { + return region; } - public Integer getBps() { - return bps; + public void setRegion(String region) { + this.region = region; } } diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatFlowResponse.java b/src/main/java/com/baidubce/services/cdn/model/DescribeIpsResponse.java similarity index 66% rename from src/main/java/com/baidubce/services/cdn/model/GetStatFlowResponse.java rename to src/main/java/com/baidubce/services/cdn/model/DescribeIpsResponse.java index 7c0c6ec8..ec9401ba 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetStatFlowResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/DescribeIpsResponse.java @@ -13,18 +13,22 @@ package com.baidubce.services.cdn.model; -import java.util.ArrayList; +import com.baidubce.services.cdn.model.util.IpDetail; + import java.util.List; -public class GetStatFlowResponse extends CdnResponse { +public class DescribeIpsResponse extends CdnResponse { + + private List ipInfo; - private List details = new ArrayList(); - - public void setDetails(List details) { - this.details = details; + public DescribeIpsResponse() { } - - public List getDetails() { - return details; + + public List getIpInfo() { + return ipInfo; + } + + public void setIpInfo(List ipInfo) { + this.ipInfo = ipInfo; } } diff --git a/src/main/java/com/baidubce/services/cdn/model/Domain.java b/src/main/java/com/baidubce/services/cdn/model/Domain.java index 892bbda8..0c7b07af 100644 --- a/src/main/java/com/baidubce/services/cdn/model/Domain.java +++ b/src/main/java/com/baidubce/services/cdn/model/Domain.java @@ -13,14 +13,24 @@ package com.baidubce.services.cdn.model; +/** + * @author yixing + * + */ public class Domain extends JsonObject { private String name = null; + /** + * @return name + */ public String getName() { return name; } + /** + * @param name + */ public void setName(String name) { this.name = name; } diff --git a/src/main/java/com/baidubce/services/cdn/model/FlowRegionData.java b/src/main/java/com/baidubce/services/cdn/model/FlowRegionData.java new file mode 100644 index 00000000..14a1c5b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/FlowRegionData.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +/** + * @author yixing + * + */ +public class FlowRegionData extends JsonObject { + private String location; + private String isp; + private Long flow; + private Long bps; + + /** + * @return location + */ + public String getLocation() { + return location; + } + + /** + * @param location + */ + public void setLocation(String location) { + this.location = location; + } + + /** + * @return isp + */ + public String getIsp() { + return isp; + } + + /** + * @param isp + */ + public void setIsp(String isp) { + this.isp = isp; + } + + /** + * @return flow + */ + public Long getFlow() { + return flow; + } + + /** + * @param flow + */ + public void setFlow(Long flow) { + this.flow = flow; + } + + /** + * @return bps + */ + public Long getBps() { + return bps; + } + + /** + * @param bps + */ + public void setBps(Long bps) { + this.bps = bps; + } + + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetCacheQuotaResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetCacheQuotaResponse.java new file mode 100644 index 00000000..9b3c9858 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetCacheQuotaResponse.java @@ -0,0 +1,97 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +/** + * @author yixing + * + */ +public class GetCacheQuotaResponse extends CdnResponse { + + /** + * 当日刷新目录限额余量 + */ + private Integer dirRemain; + + /** + * 当日刷新(含预热)URL限额余量 + */ + private Integer urlRemain; + + /** + * 刷新目录限额总量 + */ + private Integer dirQuota; + + /** + * 刷新(含预热)URL限额总量 + */ + private Integer urlQuota; + + /** + * @return dirRemain + */ + public Integer getDirRemain() { + return dirRemain; + } + + /** + * @param dirRemain + */ + public void setDirRemain(Integer dirRemain) { + this.dirRemain = dirRemain; + } + + /** + * @return urlRemain + */ + public Integer getUrlRemain() { + return urlRemain; + } + + /** + * @param urlRemain + */ + public void setUrlRemain(Integer urlRemain) { + this.urlRemain = urlRemain; + } + + /** + * @return dirQuota + */ + public Integer getDirQuota() { + return dirQuota; + } + + /** + * @param dirQuota + */ + public void setDirQuota(Integer dirQuota) { + this.dirQuota = dirQuota; + } + + /** + * @return urlQuota + */ + public Integer getUrlQuota() { + return urlQuota; + } + + /** + * @param urlQuota + */ + public void setUrlQuota(Integer urlQuota) { + this.urlQuota = urlQuota; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusRequest.java index 62ab0617..e4474fd0 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusRequest.java @@ -13,13 +13,18 @@ package com.baidubce.services.cdn.model; -import java.util.Date; import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; -public class GetPrefetchStatusRequest extends AbstractBceRequest { +import java.util.Date; + +/** + * @author yixing + * + */ +public class GetPrefetchStatusRequest extends CdnRequest { private String marker; private String id; private String url; @@ -27,83 +32,119 @@ public class GetPrefetchStatusRequest extends AbstractBceRequest { private Date endTime; private Date startTime; + /** + * @return marker + */ public String getMarker() { return marker; } + /** + * @param marker + */ public void setMarker(String marker) { this.marker = marker; } + /** + * @return id + */ public String getId() { return id; } + /** + * @param id + */ public void setId(String id) { this.id = id; } + /** + * @return returns this object + */ public String getUrl() { return url; } + /** + * @param url + */ public void setUrl(String url) { this.url = url; } + /** + * @param t + */ public void setEndTime(Date t) { this.endTime = t; } + /** + * @return endTime + */ public Date getEndTime() { return endTime; } + /** + * @param t + */ public void setStartTime(Date t) { this.startTime = t; } + /** + * @return startTime + */ public Date getStartTime() { return startTime; } + /** + * @param id + * @return returns this object + */ public GetPrefetchStatusRequest withId(String id) { this.setId(id); return this; } + /** + * @param url + * @return returns this object + */ public GetPrefetchStatusRequest withUrl(String url) { this.setUrl(url); return this; } - public GetPrefetchStatusRequest withMarker(String marker) { - this.setMarker(marker); - return this; - } - + /** + * @param startTime + * @return returns this object + */ public GetPrefetchStatusRequest withStartTime(Date startTime) { this.setStartTime(startTime); return this; } + /** + * @param endTime + * @return returns this object + */ public GetPrefetchStatusRequest withEndTime(Date endTime) { this.setEndTime(endTime); return this; } - - @Override - public GetPrefetchStatusRequest withRequestCredentials(BceCredentials credentials) { - this.setRequestCredentials(credentials); + + /** + * @param marker + * @return returns this object + */ + public GetPrefetchStatusRequest withMarker(String marker) { + this.setMarker(marker); return this; } - @Override - public String toString() { - try { - return JsonUtils.toJsonPrettyString(this); - } catch (JsonProcessingException e) { - return ""; - } - } } diff --git a/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusRequest.java index a805f40b..3a425c2f 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusRequest.java @@ -13,12 +13,17 @@ package com.baidubce.services.cdn.model; -import java.util.Date; import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.Date; + +/** + * @author yixing + * + */ public class GetPurgeStatusRequest extends AbstractBceRequest { private String marker; private String id; @@ -27,30 +32,51 @@ public class GetPurgeStatusRequest extends AbstractBceRequest { private Date endTime; private Date startTime; + /** + * @return marker + */ public String getMarker() { return marker; } + /** + * @param marker + */ public void setMarker(String marker) { this.marker = marker; } + /** + * @return id + */ public String getId() { return id; } + /** + * @param id + */ public void setId(String id) { this.id = id; } + /** + * @return url + */ public String getUrl() { return url; } + /** + * @param url + */ public void setUrl(String url) { this.url = url; } + /** + * @param t + */ public void setEndTime(Date t) { this.endTime = t; } @@ -59,45 +85,79 @@ public Date getEndTime() { return endTime; } + /** + * @param t + */ public void setStartTime(Date t) { this.startTime = t; } + /** + * @return startTime + */ public Date getStartTime() { return startTime; } + /** + * @param id + * @return returns this object + */ public GetPurgeStatusRequest withId(String id) { this.setId(id); return this; } + /** + * @param url + * @return returns this object + */ public GetPurgeStatusRequest withUrl(String url) { this.setUrl(url); return this; } + /** + * @param marker + * @return returns this object + */ public GetPurgeStatusRequest withMarker(String marker) { this.setMarker(marker); return this; } + /** + * @param startTime + * @return returns this object + */ public GetPurgeStatusRequest withStartTime(Date startTime) { this.setStartTime(startTime); return this; } + /** + * @param endTime + * @return returns this object + */ public GetPurgeStatusRequest withEndTime(Date endTime) { this.setEndTime(endTime); return this; } + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ @Override public GetPurgeStatusRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } + /** + * (non-Javadoc) + * @see Object#toString() + */ @Override public String toString() { try { diff --git a/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusResponse.java index 1de09de4..56764a70 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusResponse.java @@ -13,33 +13,52 @@ package com.baidubce.services.cdn.model; +import com.fasterxml.jackson.annotation.JsonProperty; + import java.util.ArrayList; import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - +/** + * @author yixing + * + */ public class GetPurgeStatusResponse extends CdnResponse { private String nextMarker; @JsonProperty private boolean isTruncated; private List details = new ArrayList(); + /** + * @return nextMarker + */ public String getNextMarker() { return nextMarker; } + /** + * @param nextMarker + */ public void setNextMarker(String nextMarker) { this.nextMarker = nextMarker; } + /** + * @return isTruncated + */ public boolean isTruncated() { return this.isTruncated; } + /** + * @return details + */ public List getDetails() { return details; } + /** + * @param details + */ public void setDetails(List details) { this.details = details; } diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatMetricMapping.java b/src/main/java/com/baidubce/services/cdn/model/GetStatMetricMapping.java new file mode 100644 index 00000000..4571bc9b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatMetricMapping.java @@ -0,0 +1,82 @@ +/* + * Copyright 2016-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +/** + * Provide some mapping to metric query + * + */ +public class GetStatMetricMapping { + + @JsonIgnore + public static final BiMap PROVINCE_MAP = HashBiMap.create(); + @JsonIgnore + public static final BiMap ISP_MAP = HashBiMap.create(); + + /*** + * Init PROVINCE_MAP and ISP_MAP + */ + static { + PROVINCE_MAP.put("anhui", "安徽"); + PROVINCE_MAP.put("beijing", "北京"); + PROVINCE_MAP.put("chongqing", "重庆"); + PROVINCE_MAP.put("fujian", "福建"); + PROVINCE_MAP.put("gansu", "甘肃"); + PROVINCE_MAP.put("guangdong", "广东"); + PROVINCE_MAP.put("guangxi", "广西"); + PROVINCE_MAP.put("guizhou", "贵州"); + PROVINCE_MAP.put("henan", "河南"); + PROVINCE_MAP.put("hebei", "河北"); + PROVINCE_MAP.put("heilongjiang", "黑龙江"); + PROVINCE_MAP.put("hubei", "湖北"); + PROVINCE_MAP.put("hunan", "湖南"); + PROVINCE_MAP.put("jiangsu", "江苏"); + PROVINCE_MAP.put("jiangxi", "江西"); + PROVINCE_MAP.put("jilin", "吉林"); + PROVINCE_MAP.put("liaoning", "辽宁"); + PROVINCE_MAP.put("neimenggu", "内蒙古"); + PROVINCE_MAP.put("ningxia", "宁夏"); + PROVINCE_MAP.put("qinghai", "青海"); + PROVINCE_MAP.put("shandong", "山东"); + PROVINCE_MAP.put("shanghai", "上海"); + PROVINCE_MAP.put("shannxi", "陕西"); + PROVINCE_MAP.put("shanxi", "山西"); + PROVINCE_MAP.put("sichuan", "四川"); + PROVINCE_MAP.put("tianjin", "天津"); + PROVINCE_MAP.put("unknown", "未知"); + PROVINCE_MAP.put("xinjiang", "新疆"); + PROVINCE_MAP.put("xizang", "西藏"); + PROVINCE_MAP.put("yunnan", "云南"); + PROVINCE_MAP.put("zhejiang", "浙江"); + PROVINCE_MAP.put("xianggang", "香港"); + PROVINCE_MAP.put("aomen", "澳门"); + PROVINCE_MAP.put("taiwan", "台湾"); + PROVINCE_MAP.put("hainan", "海南"); + + ISP_MAP.put("ct", "电信"); + ISP_MAP.put("cnc", "联通"); + ISP_MAP.put("cmnet", "移动"); + ISP_MAP.put("ce", "教育网"); + ISP_MAP.put("pbs", "鹏博士"); + ISP_MAP.put("oc", "广电"); + ISP_MAP.put("sjhl", "世纪互联"); + ISP_MAP.put("fdbn", "方正宽带"); + ISP_MAP.put("wasu", "华数"); + ISP_MAP.put("other", "其他"); + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/HttpCodeRegionData.java b/src/main/java/com/baidubce/services/cdn/model/HttpCodeRegionData.java new file mode 100644 index 00000000..82d0eb77 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/HttpCodeRegionData.java @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author yixing + * + */ +public class HttpCodeRegionData { + private String location; + private String isp; + private List counters = new ArrayList(); + + /** + * @return location + */ + public String getLocation() { + return location; + } + + /** + * @param location + */ + public void setLocation(String location) { + this.location = location; + } + + /** + * @return isp + */ + public String getIsp() { + return isp; + } + + /** + * @param isp + */ + public void setIsp(String isp) { + this.isp = isp; + } + + /** + * @return counters + */ + public List getCounters() { + return counters; + } + + /** + * @param counters + */ + public void setCounters(List counters) { + this.counters = counters; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/IpACL.java b/src/main/java/com/baidubce/services/cdn/model/IpACL.java new file mode 100644 index 00000000..577f3c4f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/IpACL.java @@ -0,0 +1,78 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author yixing + * + */ +public class IpACL extends JsonObject { + List blackList; + List whiteList; + + /** + * @return blackList + */ + public List getBlackList() { + return blackList; + } + + /** + * @param blackList + */ + public void setBlackList(List blackList) { + this.blackList = blackList; + } + + /** + * @param entry + * @return returns this object + */ + public IpACL addBlackList(String entry) { + if (blackList == null) { + blackList = new ArrayList(); + } + blackList.add(entry); + return this; + } + + /** + * @return whiteList + */ + public List getWhiteList() { + return whiteList; + } + + /** + * @param whiteList + */ + public void setWhiteList(List whiteList) { + this.whiteList = whiteList; + } + + /** + * @param entry + * @return returns this object + */ + public IpACL addWhiteList(String entry) { + if (whiteList == null) { + whiteList = new ArrayList(); + } + whiteList.add(entry); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/JsonObject.java b/src/main/java/com/baidubce/services/cdn/model/JsonObject.java index f8c796c0..83d7ce72 100644 --- a/src/main/java/com/baidubce/services/cdn/model/JsonObject.java +++ b/src/main/java/com/baidubce/services/cdn/model/JsonObject.java @@ -16,7 +16,15 @@ import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; +/** + * @author yixing + * + */ public class JsonObject { + /** + * (non-Javadoc) + * @see Object#toString() + */ public String toString() { try { return JsonUtils.toJsonPrettyString(this); diff --git a/src/main/java/com/baidubce/services/cdn/model/KvCounter.java b/src/main/java/com/baidubce/services/cdn/model/KvCounter.java new file mode 100644 index 00000000..99e302c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/KvCounter.java @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +/** + * @author yixing + * + */ +public class KvCounter { + private String name; + private Integer value; + + /** + * @return name + */ + public String getName() { + return name; + } + + /** + * @param name + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return value + */ + public Integer getValue() { + return value; + } + + /** + * @param value + */ + public void setValue(Integer value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/ListDomainsRequest.java b/src/main/java/com/baidubce/services/cdn/model/ListDomainsRequest.java index 358fb65e..46cf2e1e 100644 --- a/src/main/java/com/baidubce/services/cdn/model/ListDomainsRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/ListDomainsRequest.java @@ -23,33 +23,75 @@ */ public class ListDomainsRequest extends AbstractBceRequest { private String marker; + + /** + * 可选 + * 支持IP或域名源站筛选,多个源站用‘,’分隔。 + */ + private String origin; + /** + * @return marker + */ public String getMarker() { return marker; } + /** + * @param marker + */ public void setMarker(String marker) { this.marker = marker; } - /* + /** * Configure the marker for the query request. * The marker marks the starting point for the query. * * @param marker - * @return ListDomainsRequest + * @return returns this object */ public ListDomainsRequest withMarker(String marker) { this.setMarker(marker); return this; } - + + public String getOrigin() { + return origin; + } + + public void setOrigin(String origin) { + this.origin = origin; + } + + public ListDomainsRequest withOrigin(String origin) { + this.setOrigin(origin); + return this; + } + + public ListDomainsRequest addOrigin(String origin) { + if (this.origin == null || this.origin.isEmpty()) { + this.setOrigin(origin); + } else { + this.setOrigin(this.origin + "," + origin); + } + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ @Override public ListDomainsRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } + /** + * (non-Javadoc) + * @see Object#toString() + */ @Override public String toString() { try { diff --git a/src/main/java/com/baidubce/services/cdn/model/ListDomainsResponse.java b/src/main/java/com/baidubce/services/cdn/model/ListDomainsResponse.java index 27b4923c..ee19d2ab 100644 --- a/src/main/java/com/baidubce/services/cdn/model/ListDomainsResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/ListDomainsResponse.java @@ -16,41 +16,68 @@ import java.util.ArrayList; import java.util.List; +/** + * @author yixing + * + */ public class ListDomainsResponse extends CdnResponse { private List domains = new ArrayList(); - private String marker; - private boolean isTruncated; - private String nextMarker; - + + /** + * @return domains + */ + public List getDomains() { + return domains; + } + + /** + * @param domains + */ public void setDomains(List domains) { this.domains = domains; } - - public List getDomains() { return this.domains; } - + + /** + * @return marker + */ public String getMarker() { return marker; } - + + /** + * @param marker + */ public void setMarker(String marker) { this.marker = marker; } - - public boolean getIsTruncated() { - return this.isTruncated; + + /** + * @return isTruncated + */ + public boolean isTruncated() { + return isTruncated; } - - public void setIsTruncated(boolean truncated) { - this.isTruncated = truncated; + + /** + * @param isTruncated + */ + public void setTruncated(boolean isTruncated) { + this.isTruncated = isTruncated; } - + + /** + * @return nextMarker + */ public String getNextMarker() { return nextMarker; } - + + /** + * @param nextMarker + */ public void setNextMarker(String nextMarker) { this.nextMarker = nextMarker; } diff --git a/src/main/java/com/baidubce/services/cdn/model/OriginPeer.java b/src/main/java/com/baidubce/services/cdn/model/OriginPeer.java index 0fb96cf1..17dff057 100644 --- a/src/main/java/com/baidubce/services/cdn/model/OriginPeer.java +++ b/src/main/java/com/baidubce/services/cdn/model/OriginPeer.java @@ -13,14 +13,41 @@ package com.baidubce.services.cdn.model; +/** + * @author yixing + */ public class OriginPeer { - private String peer = null; - + private String peer; + private String host; + private boolean backup; + private int weight; + private String isp; + public OriginPeer withPeer(String peer) { this.peer = peer; return this; } + public OriginPeer withIsp(String isp) { + this.isp = isp; + return this; + } + + public OriginPeer withHost(String host) { + this.host = host; + return this; + } + + public OriginPeer withBackup(boolean backup) { + this.backup = backup; + return this; + } + + public OriginPeer withWeight(int weight) { + this.weight = weight; + return this; + } + public String getPeer() { return peer; } @@ -29,12 +56,35 @@ public void setPeer(String peer) { this.peer = peer; } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Domain {\n"); - sb.append(" peer: ").append(peer).append("\n"); - sb.append("}\n"); - return sb.toString(); + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public boolean isBackup() { + return backup; + } + + public void setBackup(boolean backup) { + this.backup = backup; + } + + public int getWeight() { + return weight; + } + + public void setWeight(int weight) { + this.weight = weight; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; } -} +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cdn/model/PrefetchRequest.java b/src/main/java/com/baidubce/services/cdn/model/PrefetchRequest.java index 570f4567..fc10cb8e 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PrefetchRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/PrefetchRequest.java @@ -13,47 +13,50 @@ package com.baidubce.services.cdn.model; -import java.util.List; - -import com.baidubce.auth.BceCredentials; -import com.baidubce.model.AbstractBceRequest; -import com.baidubce.util.JsonUtils; -import com.fasterxml.jackson.core.JsonProcessingException; +import com.baidubce.services.cdn.model.cache.PrefetchTask; import java.util.ArrayList; +import java.util.List; -public class PrefetchRequest extends AbstractBceRequest { +/** + * @author yixing + * + */ +public class PrefetchRequest extends CdnRequest { private List tasks; - public PrefetchRequest() { - tasks = new ArrayList(); - } - + /** + * @return tasks + */ public List getTasks() { return tasks; } + /** + * @param tasks + */ public void setTasks(List tasks) { this.tasks = tasks; } + /** + * @param tasks + * @return returns this object + */ public PrefetchRequest withTasks(List tasks) { setTasks(tasks); return this; } - @Override - public PrefetchRequest withRequestCredentials(BceCredentials credentials) { - this.setRequestCredentials(credentials); - return this; - } - - @Override - public String toString() { - try { - return JsonUtils.toJsonPrettyString(this); - } catch (JsonProcessingException e) { - return ""; + /** + * @param task + * @return returns this object + */ + public PrefetchRequest addTask(PrefetchTask task) { + if (tasks == null) { + tasks = new ArrayList(); } + tasks.add(task); + return this; } } diff --git a/src/main/java/com/baidubce/services/cdn/model/PrefetchResponse.java b/src/main/java/com/baidubce/services/cdn/model/PrefetchResponse.java index e32fcbeb..e56d555d 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PrefetchResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/PrefetchResponse.java @@ -13,13 +13,23 @@ package com.baidubce.services.cdn.model; +/** + * @author yixing + * + */ public class PrefetchResponse extends CdnResponse { private String id; + /** + * @return id + */ public String getId() { return id; } + /** + * @param id + */ public void setId(String id) { this.id = id; } diff --git a/src/main/java/com/baidubce/services/cdn/model/PurgeRequest.java b/src/main/java/com/baidubce/services/cdn/model/PurgeRequest.java index 5245a018..be9d6bc2 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PurgeRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/PurgeRequest.java @@ -13,39 +13,70 @@ package com.baidubce.services.cdn.model; -import java.util.List; import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author yixing + * + */ public class PurgeRequest extends AbstractBceRequest { private List tasks; + /** + * @return tasks + */ public List getTasks() { return tasks; } + /** + * @param tasks + */ public void setTasks(List tasks) { this.tasks = tasks; } + /** + * @param tasks + * @return returns this object + */ public PurgeRequest withTasks(List tasks) { setTasks(tasks); return this; } + /** + * @param task + * @return returns this object + */ public PurgeRequest addTask(PurgeTask task) { - this.tasks.add(task); + if (tasks == null) { + tasks = new ArrayList(); + } + tasks.add(task); return this; } + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ @Override public PurgeRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } + /** + * (non-Javadoc) + * @see Object#toString() + */ @Override public String toString() { try { diff --git a/src/main/java/com/baidubce/services/cdn/model/PurgeResponse.java b/src/main/java/com/baidubce/services/cdn/model/PurgeResponse.java index 1034b400..15d6dc57 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PurgeResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/PurgeResponse.java @@ -13,13 +13,23 @@ package com.baidubce.services.cdn.model; +/** + * @author yixing + * + */ public class PurgeResponse extends CdnResponse { private String id; + /** + * @return id + */ public String getId() { return id; } + /** + * @param id + */ public void setId(String id) { this.id = id; } diff --git a/src/main/java/com/baidubce/services/cdn/model/PurgeStatus.java b/src/main/java/com/baidubce/services/cdn/model/PurgeStatus.java index d0712582..fd2a1cb8 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PurgeStatus.java +++ b/src/main/java/com/baidubce/services/cdn/model/PurgeStatus.java @@ -15,6 +15,10 @@ import java.util.Date; +/** + * @author yixing + * + */ public class PurgeStatus extends JsonObject { private String status; private PurgeTask task; @@ -22,42 +26,72 @@ public class PurgeStatus extends JsonObject { private Date finishedAt; private int progress; + /** + * @param status + */ public void setStatus(String status) { this.status = status; } + /** + * @return status + */ public String getStatus() { return status; } + /** + * @param task + */ public void setTask(PurgeTask task) { this.task = task; } + /** + * @return task + */ public PurgeTask getTask() { return task; } + /** + * @param createdAt + */ public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } + /** + * @return createdAt + */ public Date getCreatedAt() { return createdAt; } + /** + * @param finishedAt + */ public void setFinishedAt(Date finishedAt) { this.finishedAt = finishedAt; } + /** + * @return finishedAt + */ public Date getFinishedAt() { return finishedAt; } + /** + * @param progress + */ public void setProgress(int progress) { this.progress = progress; } + /** + * @return progress + */ public int getProgress() { return progress; } diff --git a/src/main/java/com/baidubce/services/cdn/model/PurgeTask.java b/src/main/java/com/baidubce/services/cdn/model/PurgeTask.java index 8f21c937..dcc31b80 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PurgeTask.java +++ b/src/main/java/com/baidubce/services/cdn/model/PurgeTask.java @@ -13,35 +13,66 @@ package com.baidubce.services.cdn.model; +/** + * @author yixing + * + */ public class PurgeTask extends JsonObject { public static final String TYPE_FILE = "file"; public static final String TYPE_DIRECTORY = "directory"; - + + /** + * 必选项,String类型,表示需要purge的URL,如果type为directory,必须以/结尾 + */ private String url; + + /** + * 可选项,String类型,可选值为file/directory,默认为file。 + */ private String type; + /** + * @param url + */ public void setUrl(String url) { this.url = url; } + /** + * @return url + */ public String getUrl() { return url; } + /** + * @param type + */ public void setType(String type) { this.type = type; } + /** + * @return type + */ public String getType() { return type; } + /** + * @param url + * @return returns this object + */ public PurgeTask withUrl(String url) { setUrl(url); setType(TYPE_FILE); return this; } + /** + * @param url + * @return returns this object + */ public PurgeTask withDirectory(String url) { setUrl(url); setType(TYPE_DIRECTORY); diff --git a/src/main/java/com/baidubce/services/cdn/model/RefererACL.java b/src/main/java/com/baidubce/services/cdn/model/RefererACL.java new file mode 100644 index 00000000..70f24e51 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/RefererACL.java @@ -0,0 +1,100 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author yixing + * + */ +public class RefererACL extends JsonObject { + + private List blackList; + private List whiteList; + private boolean allowEmpty; + + /** + * @return blackList + */ + public List getBlackList() { + return blackList; + } + + /** + * @param blackList + */ + public void setBlackList(List blackList) { + this.blackList = blackList; + } + + /** + * @param entry + * @return returns this object + */ + public RefererACL addBlackList(String entry) { + if (blackList == null) { + blackList = new ArrayList(); + } + blackList.add(entry); + return this; + } + + /** + * @return + */ + public List getWhiteList() { + return whiteList; + } + + /** + * @param whiteList + */ + public void setWhiteList(List whiteList) { + this.whiteList = whiteList; + } + + /** + * @param entry + * @return returns this object + */ + public RefererACL addWhiteList(String entry) { + if (whiteList == null) { + whiteList = new ArrayList(); + } + whiteList.add(entry); + return this; + } + + /** + * @return allowEmpty + */ + public boolean isAllowEmpty() { + return allowEmpty; + } + + /** + * @param allowEmpty + */ + public void setAllowEmpty(boolean allowEmpty) { + this.allowEmpty = allowEmpty; + } + + public RefererACL withAllowEmpty(boolean allowEmpty) { + setAllowEmpty(allowEmpty); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/SetDomainHttpsConfigRequest.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainHttpsConfigRequest.java new file mode 100644 index 00000000..36ac3f7f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainHttpsConfigRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +import com.baidubce.services.cdn.model.domain.HttpsConfig; + +public class SetDomainHttpsConfigRequest extends CdnRequest { + private String domain; + private HttpsConfig https; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public HttpsConfig getHttps() { + return https; + } + + public void setHttps(HttpsConfig https) { + this.https = https; + } + + public SetDomainHttpsConfigRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + public SetDomainHttpsConfigRequest withHttps(HttpsConfig https) { + setHttps(https); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/SetDomainOriginRequest.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainOriginRequest.java new file mode 100644 index 00000000..2d09a0e4 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainOriginRequest.java @@ -0,0 +1,144 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.List; + +/** + * @author yixing + * update by changxing01 on 19/8/28 + */ +public class SetDomainOriginRequest extends AbstractBceRequest { + + private List origin; + private String domain; + private String defaultHost; + private boolean follow302; + + /** + * @return defaultHost + */ + public String getDefaultHost() { + return defaultHost; + } + + public boolean isFollow302() { + return follow302; + } + + public void setFollow302(boolean follow302) { + this.follow302 = follow302; + } + + /** + * @param defaultHost default back source host + */ + public void setDefaultHost(String defaultHost) { + this.defaultHost = defaultHost; + } + + /** + * @param defaultHost default back source host + * @return this object + */ + public SetDomainOriginRequest withDefaultHost(String defaultHost) { + this.defaultHost = defaultHost; + return this; + } + + /** + * @param follow302 default back source host + * @return this object + */ + public SetDomainOriginRequest withFollow302(boolean follow302) { + this.follow302 = follow302; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @return origin + */ + public List getOrigin() { + return origin; + } + + /** + * @param origin + */ + public void setOrigin(List origin) { + this.origin = origin; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainOriginRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @param origin + * @return returns this object + */ + public SetDomainOriginRequest withOrigin(List origin) { + setOrigin(origin); + return this; + } + + /** + * (non-Javadoc) + * + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public SetDomainOriginRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/cache/GetCacheDetailRequest.java b/src/main/java/com/baidubce/services/cdn/model/cache/GetCacheDetailRequest.java new file mode 100644 index 00000000..6ab267c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/cache/GetCacheDetailRequest.java @@ -0,0 +1,123 @@ +package com.baidubce.services.cdn.model.cache; + +import com.baidubce.services.cdn.model.CdnRequest; + +import java.util.Date; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetCacheDetailRequest extends CdnRequest { + private String marker; + private String type; + private String url; + + private Date endTime; + private Date startTime; + + /** + * @return marker + */ + public String getMarker() { + return marker; + } + + /** + * @param marker + */ + public void setMarker(String marker) { + this.marker = marker; + } + + /** + * @return type + */ + public String getType() { + return type; + } + + /** + * @param type + */ + public void setType(String type) { + this.type = type; + } + + /** + * @return returns this object + */ + public String getUrl() { + return url; + } + + /** + * @param url + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * @param t + */ + public void setEndTime(Date t) { + this.endTime = t; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param t + */ + public void setStartTime(Date t) { + this.startTime = t; + } + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param type + * @return returns this object + */ + public GetCacheDetailRequest withType(String type) { + this.setType(type); + return this; + } + + /** + * @param url + * @return returns this object + */ + public GetCacheDetailRequest withUrl(String url) { + this.setUrl(url); + return this; + } + + /** + * @param startTime + * @return returns this object + */ + public GetCacheDetailRequest withStartTime(Date startTime) { + this.setStartTime(startTime); + return this; + } + + /** + * @param endTime + * @return returns this object + */ + public GetCacheDetailRequest withEndTime(Date endTime) { + this.setEndTime(endTime); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/cache/GetCacheRecordsResponse.java b/src/main/java/com/baidubce/services/cdn/model/cache/GetCacheRecordsResponse.java new file mode 100644 index 00000000..59bd8620 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/cache/GetCacheRecordsResponse.java @@ -0,0 +1,56 @@ +package com.baidubce.services.cdn.model.cache; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetCacheRecordsResponse extends CdnResponse { + private List details; + private boolean isTruncated; + private String nextMarker; + + /** + * @return details + */ + public List getDetails() { + return details; + } + + /** + * @param details detail of task + */ + public void setDetails(List details) { + this.details = details; + } + + /** + * @return isTruncated + */ + public boolean isTruncated() { + return isTruncated; + } + + /** + * @param isTruncated + */ + public void setTruncated(boolean isTruncated) { + this.isTruncated = isTruncated; + } + + /** + * @return nextMarker + */ + public String getNextMarker() { + return nextMarker; + } + + /** + * @param nextMarker Subsequent list tag + */ + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusResponse.java b/src/main/java/com/baidubce/services/cdn/model/cache/GetPrefetchStatusResponse.java similarity index 78% rename from src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusResponse.java rename to src/main/java/com/baidubce/services/cdn/model/cache/GetPrefetchStatusResponse.java index 304516f3..36d19256 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/cache/GetPrefetchStatusResponse.java @@ -11,13 +11,18 @@ * specific language governing permissions and limitations under the License. */ -package com.baidubce.services.cdn.model; +package com.baidubce.services.cdn.model.cache; + +import com.baidubce.services.cdn.model.CdnResponse; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - +/** + * @author yixing + * + */ public class GetPrefetchStatusResponse extends CdnResponse { private String marker; private String nextMarker; @@ -25,30 +30,51 @@ public class GetPrefetchStatusResponse extends CdnResponse { private boolean isTruncated; private List details = new ArrayList(); + /** + * @return marker + */ public String getMarker() { return marker; } + /** + * @param marker + */ public void setMarker(String marker) { this.marker = marker; } + /** + * @return nextMarker + */ public String getNextMarker() { return nextMarker; } + /** + * @param nextMarker + */ public void setNextMarker(String nextMarker) { this.nextMarker = nextMarker; } + /** + * @return isTruncated + */ public boolean isTruncated() { return this.isTruncated; } + /** + * @return details + */ public List getDetails() { return details; } + /** + * @param details + */ public void setDetails(List details) { this.details = details; } diff --git a/src/main/java/com/baidubce/services/cdn/model/PrefetchStatus.java b/src/main/java/com/baidubce/services/cdn/model/cache/PrefetchStatus.java similarity index 66% rename from src/main/java/com/baidubce/services/cdn/model/PrefetchStatus.java rename to src/main/java/com/baidubce/services/cdn/model/cache/PrefetchStatus.java index b4d2ce03..898e756a 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PrefetchStatus.java +++ b/src/main/java/com/baidubce/services/cdn/model/cache/PrefetchStatus.java @@ -11,54 +11,104 @@ * specific language governing permissions and limitations under the License. */ -package com.baidubce.services.cdn.model; +package com.baidubce.services.cdn.model.cache; + +import com.baidubce.services.cdn.model.JsonObject; import java.util.Date; +/** + * @author yixing + * + */ public class PrefetchStatus extends JsonObject { private String status; private PrefetchTask task; - private Date createdAt; + private Date startedAt; private Date finishedAt; private int progress; - + + /** + * @return startedAt + */ + public Date getStartedAt() { + return startedAt; + } + + /** + * @param startedAt + */ + public void setStartedAt(Date startedAt) { + this.startedAt = startedAt; + } + + /** + * @param status + */ public void setStatus(String status) { this.status = status; } + /** + * @return status + */ public String getStatus() { return status; } + /** + * @param task + */ public void setTask(PrefetchTask task) { this.task = task; } + /** + * @return task + */ public PrefetchTask getTask() { return task; } + /** + * @param createdAt + */ public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } + /** + * @return createdAt + */ public Date getCreatedAt() { return createdAt; } + /** + * @param finishedAt + */ public void setFinishedAt(Date finishedAt) { this.finishedAt = finishedAt; } + /** + * @return finishedAt + */ public Date getFinishedAt() { return finishedAt; } + /** + * @param progress + */ public void setProgress(int progress) { this.progress = progress; } + /** + * @return progress + */ public int getProgress() { return progress; } diff --git a/src/main/java/com/baidubce/services/cdn/model/cache/PrefetchTask.java b/src/main/java/com/baidubce/services/cdn/model/cache/PrefetchTask.java new file mode 100644 index 00000000..ec6a8cdd --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/cache/PrefetchTask.java @@ -0,0 +1,90 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.cache; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * @author yixing + * + */ +public class PrefetchTask extends JsonObject { + + + /** + * 必选项,String类型,表示需要prefetch的URL。 + */ + private String url; + + /** + * 可选项,Int类型,表示prefetch的限速,单位为byte/s,默认为0(不限制) + */ + private int speed = 0; + + /** + * 可选项,Timestamp类型,UTC 时间,startTime必须是大于当前时间,并且在24小时内的时间,否则失败。 + * 格式为:2016-04-16Z23:00:00T, 默认为立即执行 + */ + private String startTime; + + + /** + * @param url + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * @return url + */ + public String getUrl() { + return url; + } + + /** + * @param url + * @return returns this object + */ + public PrefetchTask withUrl(String url) { + setUrl(url); + return this; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + public PrefetchTask withSpeed(int speed) { + this.speed = speed; + return this; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public PrefetchTask withStartTime(String startTime) { + this.startTime = startTime; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/cache/RecordStatus.java b/src/main/java/com/baidubce/services/cdn/model/cache/RecordStatus.java new file mode 100644 index 00000000..76732c12 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/cache/RecordStatus.java @@ -0,0 +1,144 @@ +package com.baidubce.services.cdn.model.cache; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/28 + */ +public class RecordStatus extends JsonObject { + private String status; + private String url; + private String type; + private String createdAt; + private String startedAt; + private String finishedAt; + private int progress; + private String reason; + private String operator; + + /** + * @return status + */ + public String getStatus() { + return status; + } + + /** + * @param status in-progress|completed|failed + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * @return url + */ + public String getUrl() { + return url; + } + + /** + * @param url URL record + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * @return type + */ + public String getType() { + return type; + } + + /** + * @param type record type + */ + public void setType(String type) { + this.type = type; + } + + /** + * @return createdAt + */ + public String getCreatedAt() { + return createdAt; + } + + /** + * @param createdAt task create time + */ + public void setCreatedAt(String createdAt) { + this.createdAt = createdAt; + } + + /** + * @return startedAt + */ + public String getStartedAt() { + return startedAt; + } + + /** + * @param startedAt task start time + */ + public void setStartedAt(String startedAt) { + this.startedAt = startedAt; + } + + /** + * @return finishedAt + */ + public String getFinishedAt() { + return finishedAt; + } + + /** + * @param finishedAt task finish time + */ + public void setFinishedAt(String finishedAt) { + this.finishedAt = finishedAt; + } + + /** + * @return progress + */ + public int getProgress() { + return progress; + } + + /** + * @param progress Progress percentage + */ + public void setProgress(int progress) { + this.progress = progress; + } + + /** + * @return reason + */ + public String getReason() { + return reason; + } + + /** + * @param reason Reason for preloading task failure + */ + public void setReason(String reason) { + this.reason = reason; + } + + /** + * @return operator + */ + public String getOperator() { + return operator; + } + + /** + * @param operator Operating account + */ + public void setOperator(String operator) { + this.operator = operator; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/certificate/BatchUploadCertRequest.java b/src/main/java/com/baidubce/services/cdn/model/certificate/BatchUploadCertRequest.java new file mode 100644 index 00000000..ae3c4c87 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/certificate/BatchUploadCertRequest.java @@ -0,0 +1,62 @@ +package com.baidubce.services.cdn.model.certificate; + +import com.baidubce.services.cdn.model.CdnRequest; +import com.baidubce.services.cdn.model.domain.HttpsConfig; + +import java.util.List; + +public class BatchUploadCertRequest extends CdnRequest { + + + private List domains; + + private Cert certificate; + + private HttpsConfig https; + + public BatchUploadCertRequest() { + } + + public BatchUploadCertRequest withHttps(HttpsConfig https) { + setHttps(https); + return this; + } + + public BatchUploadCertRequest withCertificate(Cert certificate) { + setCertificate(certificate); + return this; + } + + /** + * @param domains the domains name + * @return returns this object + */ + public BatchUploadCertRequest withDomains(List domains) { + setDomains(domains); + return this; + } + + public List getDomains() { + return domains; + } + + public void setDomains(List domains) { + this.domains = domains; + } + + public Cert getCertificate() { + return certificate; + } + + public void setCertificate(Cert certificate) { + this.certificate = certificate; + } + + public HttpsConfig getHttps() { + return https; + } + + public void setHttps(HttpsConfig https) { + this.https = https; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/certificate/Cert.java b/src/main/java/com/baidubce/services/cdn/model/certificate/Cert.java new file mode 100644 index 00000000..e8eb7985 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/certificate/Cert.java @@ -0,0 +1,103 @@ +package com.baidubce.services.cdn.model.certificate; + +import com.baidubce.services.cdn.model.JsonObject; + +public class Cert extends JsonObject { + + /** + * 证书的名称。长度限制为1-65个字符, + * 以字母开头,只允许包含字母、数字、’-‘、’/’、’.’、’_’、’*’, + * Java正则表达式 ^[a-zA-Z][a-zA-Z0-9\-/_\.\*]{0,64}$ + * 必须 + */ + private String certName; + + /** + * 服务器证书的数据内容 (Base64编码) + * 必须 + */ + private String certServerData; + + /** + * 证书的私钥数据内容 (Base64编码) + * 必须 + */ + private String certPrivateData; + + /** + * 证书链数据内容 (Base64编码) + * 可选 + */ + private String certLinkData; + + /** + * 证书类型,只能取1。1表示的是服务端证书,如果不传此项那么默认的取值也是1。 + * 可选 + */ + private Integer certType; + + public String getCertName() { + return certName; + } + + public void setCertName(String certName) { + this.certName = certName; + } + + public String getCertServerData() { + return certServerData; + } + + public void setCertServerData(String certServerData) { + this.certServerData = certServerData; + } + + public String getCertPrivateData() { + return certPrivateData; + } + + public void setCertPrivateData(String certPrivateData) { + this.certPrivateData = certPrivateData; + } + + public String getCertLinkData() { + return certLinkData; + } + + public void setCertLinkData(String certLinkData) { + this.certLinkData = certLinkData; + } + + public Integer getCertType() { + return certType; + } + + public void setCertType(Integer certType) { + this.certType = certType; + } + + public Cert withCertName(String certName) { + setCertName(certName); + return this; + } + + public Cert withCertServerData(String certServerData) { + setCertServerData(certServerData); + return this; + } + + public Cert withCertPrivateData(String certPrivateData) { + setCertPrivateData(certPrivateData); + return this; + } + + public Cert withCertLinkData(String certLinkData) { + setCertLinkData(certLinkData); + return this; + } + + public Cert withCertType(Integer certType) { + setCertType(certType); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/certificate/GetDomainCertResponse.java b/src/main/java/com/baidubce/services/cdn/model/certificate/GetDomainCertResponse.java new file mode 100644 index 00000000..54be1e02 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/certificate/GetDomainCertResponse.java @@ -0,0 +1,80 @@ +package com.baidubce.services.cdn.model.certificate; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.Date; + +public class GetDomainCertResponse extends CdnResponse { + private String certId; + private String certName; + private String certCommonName; + private String certDNSNames; + private Date certStartTime; + private Date certStopTime; + private Date certCreateTime; + private Date certUpdateTime; + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } + + public String getCertName() { + return certName; + } + + public void setCertName(String certName) { + this.certName = certName; + } + + public String getCertCommonName() { + return certCommonName; + } + + public void setCertCommonName(String certCommonName) { + this.certCommonName = certCommonName; + } + + public String getCertDNSNames() { + return certDNSNames; + } + + public void setCertDNSNames(String certDNSNames) { + this.certDNSNames = certDNSNames; + } + + public Date getCertStartTime() { + return certStartTime; + } + + public void setCertStartTime(Date certStartTime) { + this.certStartTime = certStartTime; + } + + public Date getCertStopTime() { + return certStopTime; + } + + public void setCertStopTime(Date certStopTime) { + this.certStopTime = certStopTime; + } + + public Date getCertCreateTime() { + return certCreateTime; + } + + public void setCertCreateTime(Date certCreateTime) { + this.certCreateTime = certCreateTime; + } + + public Date getCertUpdateTime() { + return certUpdateTime; + } + + public void setCertUpdateTime(Date certUpdateTime) { + this.certUpdateTime = certUpdateTime; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/certificate/GetHttpsDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/certificate/GetHttpsDomainRequest.java new file mode 100644 index 00000000..4a1f6f08 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/certificate/GetHttpsDomainRequest.java @@ -0,0 +1,154 @@ +package com.baidubce.services.cdn.model.certificate; + +import com.baidubce.services.cdn.model.CdnRequest; + +public class GetHttpsDomainRequest extends CdnRequest { + + /** + * 指定certCommonName查询 + * 可选 + */ + private String certCommonName; + + /** + * 指定certId查询 + * 可选 + */ + private String certId; + + /** + * 指定certName查询 + * 可选 + */ + private String certName; + + /** + * 查询指定域名。必须属于当前用户,只支持精确匹配 + * 可选 + */ + private String domain; + + /** + * 分页参数,第几页 + * 可选 + */ + private Integer pageNo; + + /** + * 分页参数,页面大小。1 <= pageSize <= 100 + * 可选 + */ + private Integer pageSize; + + /** + * 指定证书状态查询 + * 可选 + */ + private Integer status; + + + public GetHttpsDomainRequest() { + } + + public GetHttpsDomainRequest(Integer pageNo, Integer pageSize) { + this.pageNo = pageNo; + this.pageSize = pageSize; + } + + public GetHttpsDomainRequest(Integer pageNo, Integer pageSize, Integer status) { + this(pageNo, pageSize); + this.status = status; + } + + public GetHttpsDomainRequest withCertId(String certId) { + this.certId = certId; + return this; + } + + public GetHttpsDomainRequest withCertCommonName(String certCommonName) { + this.certCommonName = certCommonName; + return this; + } + + public GetHttpsDomainRequest withCertName(String certName) { + this.certName = certName; + return this; + } + + public GetHttpsDomainRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public GetHttpsDomainRequest withPageNo(Integer pageNo) { + this.pageNo = pageNo; + return this; + } + + public GetHttpsDomainRequest withPageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public GetHttpsDomainRequest withStatus(Integer status) { + this.status = status; + return this; + } + + + public String getCertCommonName() { + return certCommonName; + } + + public void setCertCommonName(String certCommonName) { + this.certCommonName = certCommonName; + } + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } + + public String getCertName() { + return certName; + } + + public void setCertName(String certName) { + this.certName = certName; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/certificate/GetHttpsDomainResponse.java b/src/main/java/com/baidubce/services/cdn/model/certificate/GetHttpsDomainResponse.java new file mode 100644 index 00000000..c8bd2d4d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/certificate/GetHttpsDomainResponse.java @@ -0,0 +1,31 @@ +package com.baidubce.services.cdn.model.certificate; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +public class GetHttpsDomainResponse extends CdnResponse { + + private long count; + + private List rows; + + public GetHttpsDomainResponse() { + } + + public long getCount() { + return count; + } + + public void setCount(long count) { + this.count = count; + } + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/certificate/HttpsDomain.java b/src/main/java/com/baidubce/services/cdn/model/certificate/HttpsDomain.java new file mode 100644 index 00000000..03d5a19b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/certificate/HttpsDomain.java @@ -0,0 +1,79 @@ +package com.baidubce.services.cdn.model.certificate; + +public class HttpsDomain { + private int status; + private String domain; + private int certType; + private String certStopTime; + private String certStartTime; + private String certName; + private String certId; + private String certCommonName; + + public HttpsDomain() { + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public int getCertType() { + return certType; + } + + public void setCertType(int certType) { + this.certType = certType; + } + + public String getCertStopTime() { + return certStopTime; + } + + public void setCertStopTime(String certStopTime) { + this.certStopTime = certStopTime; + } + + public String getCertStartTime() { + return certStartTime; + } + + public void setCertStartTime(String certStartTime) { + this.certStartTime = certStartTime; + } + + public String getCertName() { + return certName; + } + + public void setCertName(String certName) { + this.certName = certName; + } + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } + + public String getCertCommonName() { + return certCommonName; + } + + public void setCertCommonName(String certCommonName) { + this.certCommonName = certCommonName; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/certificate/SetDomainCertRequest.java b/src/main/java/com/baidubce/services/cdn/model/certificate/SetDomainCertRequest.java new file mode 100644 index 00000000..61bf3290 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/certificate/SetDomainCertRequest.java @@ -0,0 +1,63 @@ +package com.baidubce.services.cdn.model.certificate; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by hansongda on 20/12/02 + */ +public class SetDomainCertRequest extends CdnRequest { + private String domain; + + /** + * 只能取值"ON"或者"OFF",表示是否开启https支持,“ON”开启,“OFF”关闭 + */ + private String httpsEnable; + + /** + * 证书内容 + */ + private Cert certificate; + + public String getHttpsEnable() { + return httpsEnable; + } + + public void setHttpsEnable(String httpsEnable) { + this.httpsEnable = httpsEnable; + } + + public Cert getCertificate() { + return certificate; + } + + public void setCertificate(Cert certificate) { + this.certificate = certificate; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public SetDomainCertRequest withHttpsEnable(String httpsEnable) { + setHttpsEnable(httpsEnable); + return this; + } + + public SetDomainCertRequest withCertificate(Cert certificate) { + setCertificate(certificate); + return this; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainCertRequest withDomain(String domain) { + setDomain(domain); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/certificate/SetDomainCertResponse.java b/src/main/java/com/baidubce/services/cdn/model/certificate/SetDomainCertResponse.java new file mode 100644 index 00000000..102de5f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/certificate/SetDomainCertResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.cdn.model.certificate; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class SetDomainCertResponse extends CdnResponse { + private String certId; + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/AccessLimit.java b/src/main/java/com/baidubce/services/cdn/model/domain/AccessLimit.java new file mode 100644 index 00000000..38e4cf51 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/AccessLimit.java @@ -0,0 +1,66 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/27 + */ +public class AccessLimit extends JsonObject { + /** + * true表示开启IP单节点访问限频,false表示取消限频 + * 必选 + */ + private boolean enabled; + + /** + * 1秒内单个IP节点请求次数上限,enabled为true时此项默认为1000,enabled为false此项无意义 + * 可选 + */ + private int limit; + + /** + * @return enabled + */ + public boolean isEnabled() { + return enabled; + } + + /** + * @param enabled Whether to turn on IP single node access limit + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + /** + * @return enabled + */ + public int getLimit() { + return limit; + } + + /** + * @param limit Maximum number of requests per IP node in 1 second + */ + public void setLimit(int limit) { + this.limit = limit; + } + + /** + * @param enabled Whether to turn on IP single node access limit + * @return this object + */ + public AccessLimit withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * @param limit Maximum number of requests per IP node in 1 second + * @return this object + */ + public AccessLimit withLimit(int limit) { + this.limit = limit; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CacheShare.java b/src/main/java/com/baidubce/services/cdn/model/domain/CacheShare.java new file mode 100644 index 00000000..4d6df9d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CacheShare.java @@ -0,0 +1,42 @@ +package com.baidubce.services.cdn.model.domain; + +public class CacheShare { + + /** + * 是否开启缓存共享 + * 必选 + */ + private boolean enabled; + + /** + * 客户名下其他域名,开启情况下须传入该参数 + * 可选 + */ + private String domain; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public CacheShare withEnabled(boolean enabled) { + setEnabled(enabled); + return this; + } + + public CacheShare withDomain(String domain) { + setDomain(domain); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CacheTTL.java b/src/main/java/com/baidubce/services/cdn/model/domain/CacheTTL.java new file mode 100644 index 00000000..a9edaf72 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CacheTTL.java @@ -0,0 +1,157 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +/** + * @author yixing + * + * Cache TTL policy + */ +public class CacheTTL { + /** + * suffix"表示文件名后缀,"path"表示url中的目录,"origin"表示源站规则,此规则只有一条,只表示出权重即可 + * value为"-", ttl为 0,"code"表示异常码缓存,如可以配置404缓存100s ,“exactPath”表示路径完全匹配 + * 必选 + */ + private String type; + + /** + * type所指定类型的配置规则 + * 必选 + */ + private String value; + + /** + * 缓存时间,单位为秒 + * 必选 + */ + private Integer ttl; + + /** + * 权重,0-100的整数,权重越高优先级越高,默认为0,优先级在为code类型下是没有作用的,可以忽略 + * 可选 + */ + private Integer weight; + + /** + * 缓存是否遵循源站,默认true。overrideOrigin=true表示不遵循源站,按照该条配置规则缓存 + * 可选 + */ + private Boolean overrideOrigin; + + /** + * @return type + */ + public String getType() { + return type; + } + + /** + * @param type + */ + public void setType(String type) { + this.type = type; + } + + /** + * @param type + * @return returns this object + */ + public CacheTTL withType(String type) { + setType(type); + return this; + } + + /** + * @return value + */ + public String getValue() { + return value; + } + + /** + * @param value + */ + public void setValue(String value) { + this.value = value; + } + + /** + * @param value + * @return returns this object + */ + public CacheTTL withValue(String value) { + setValue(value); + return this; + } + + /** + * @return ttl + */ + public Integer getTtl() { + return ttl; + } + + /** + * @param ttl + */ + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + /** + * @param ttl + * @return returns this object + */ + public CacheTTL withTtl(Integer ttl) { + setTtl(ttl); + return this; + } + + /** + * @return weigh + */ + public Integer getWeight() { + return weight; + } + + /** + * @param weight + */ + public void setWeight(Integer weight) { + this.weight = weight; + } + + /** + * @param weight + * @return returns this object + */ + public CacheTTL withWeigth(Integer weight) { + setWeight(weight); + return this; + } + + public Boolean getOverrideOrigin() { + return overrideOrigin; + } + + public void setOverrideOrigin(Boolean overrideOrigin) { + this.overrideOrigin = overrideOrigin; + } + + public CacheTTL withOverrideOrigin(Boolean overrideOrigin) { + setOverrideOrigin(overrideOrigin); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CheckDomainValidResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/CheckDomainValidResponse.java new file mode 100644 index 00000000..16c28540 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CheckDomainValidResponse.java @@ -0,0 +1,36 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * create by changxing01 on 19/8/27 + */ +public class CheckDomainValidResponse extends CdnResponse { + + @JsonProperty("isValid") + private boolean isValid; + private String message; + + public boolean isValid() { + return isValid; + } + + public void setValid(boolean valid) { + isValid = valid; + } + + /** + * @return message + */ + public String getMessage() { + return message; + } + + /** + * @param message the reason of not + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/ClientIp.java b/src/main/java/com/baidubce/services/cdn/model/domain/ClientIp.java new file mode 100644 index 00000000..3debc3a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/ClientIp.java @@ -0,0 +1,57 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/27 + */ +public class ClientIp extends JsonObject { + private boolean enabled; + private String name; + + /** + * @return enabled + */ + public boolean isEnabled() { + return enabled; + } + + /** + * @param enabled Whether to turn on IP single node access limit + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + /** + * @param enabled Whether to turn on IP single node access limit + * @return this object + */ + public ClientIp withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * @return name + */ + public String getName() { + return name; + } + + /** + * @param name ip type, 'True-Client-Ip' or 'X-Real-IP' + */ + public void setName(String name) { + this.name = name; + } + + /** + * @param name ip type, 'True-Client-Ip' or 'X-Real-IP' + * @return this object + */ + public ClientIp withName(String name) { + this.name = name; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CommonResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/CommonResponse.java new file mode 100644 index 00000000..1cdc42de --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CommonResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by changxing01 on 19/9/3 + */ +public class CommonResponse extends CdnResponse { + private String status; + + /** + * @return status + */ + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/Compress.java b/src/main/java/com/baidubce/services/cdn/model/domain/Compress.java new file mode 100644 index 00000000..10af549b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/Compress.java @@ -0,0 +1,67 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/28 + */ +public class Compress extends JsonObject { + + /** + * true表示开启页面压缩,false表示关闭页面压缩 + * 必选 + */ + private boolean allow; + + /** + * 值为"br"或者"gzip"或者"all",分别表示支持br,gzip以及br和gzip都支持 + * 必选 + */ + private String type; + + /** + * @return allow + */ + public boolean isAllow() { + return allow; + } + + /** + * @param allow Whether to enable page compression + */ + public void setAllow(boolean allow) { + this.allow = allow; + } + + /** + * @param allow Whether to enable page compression + * @return this object + */ + public Compress withAllow(boolean allow) { + this.allow = allow; + return this; + } + + /** + * @return type + */ + public String getType() { + return type; + } + + /** + * @param type compress type + */ + public void setType(String type) { + this.type = type; + } + + /** + * @param type compress type + * @return this object + */ + public Compress withType(String type) { + this.type = type; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CompressResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/CompressResponse.java new file mode 100644 index 00000000..02636ec8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CompressResponse.java @@ -0,0 +1,57 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/28 + */ +public class CompressResponse extends JsonObject { + private String allow; + private String type; + + /** + * @return allow + */ + public String getAllow() { + return allow; + } + + /** + * @param allow Whether to enable page compression + */ + public void setAllow(String allow) { + this.allow = allow; + } + + /** + * @param allow Whether to enable page compression + * @return this object + */ + public CompressResponse withAllow(String allow) { + this.allow = allow; + return this; + } + + /** + * @return type + */ + public String getType() { + return type; + } + + /** + * @param type compress type + */ + public void setType(String type) { + this.type = type; + } + + /** + * @param type compress type + * @return this object + */ + public CompressResponse withType(String type) { + this.type = type; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/ConfigKey.java b/src/main/java/com/baidubce/services/cdn/model/domain/ConfigKey.java new file mode 100644 index 00000000..f26e8438 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/ConfigKey.java @@ -0,0 +1,33 @@ +package com.baidubce.services.cdn.model.domain; + +public class ConfigKey { + /** + * 值为switch || json || rule + */ + private String type; + + /** + * 类型为int|bool + * switch和json对应的value为bool类型,分别表示开关的开闭以及是否已经设置,rule对应的值为int,表规则的数目 + */ + private Object value; + + public ConfigKey() { + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskRequest.java new file mode 100644 index 00000000..a5915944 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskRequest.java @@ -0,0 +1,52 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; +import java.util.List; + +public class CopyDomainTaskRequest extends CdnRequest { + private String originDomain; + private List domains; + private List configs; + + public CopyDomainTaskRequest() { + } + + public String getOriginDomain() { + return originDomain; + } + + public void setOriginDomain(String originDomain) { + this.originDomain = originDomain; + } + + public List getDomains() { + return domains; + } + + public void setDomains(List domains) { + this.domains = domains; + } + + public List getConfigs() { + return configs; + } + + public void setConfigs(List configs) { + this.configs = configs; + } + + public CopyDomainTaskRequest withOriginDomain(String originDomain) { + this.originDomain = originDomain; + return this; + } + + public CopyDomainTaskRequest withDomains(List domains) { + this.domains = domains; + return this; + } + + public CopyDomainTaskRequest withConfigs(List configs) { + this.configs = configs; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskResponse.java new file mode 100644 index 00000000..8d78fcc7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class CopyDomainTaskResponse extends CdnResponse { + private String taskId; + + public CopyDomainTaskResponse() { + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskStatusRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskStatusRequest.java new file mode 100644 index 00000000..e4942a9d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskStatusRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +public class CopyDomainTaskStatusRequest extends CdnRequest { + private String taskId; + + public CopyDomainTaskStatusRequest() { + } + + public CopyDomainTaskStatusRequest(String taskId) { + this.taskId = taskId; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public CopyDomainTaskStatusRequest withTaskId(String taskId) { + this.taskId = taskId; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskStatusResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskStatusResponse.java new file mode 100644 index 00000000..c0cf531e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CopyDomainTaskStatusResponse.java @@ -0,0 +1,19 @@ +package com.baidubce.services.cdn.model.domain; + + +import java.util.List; + +public class CopyDomainTaskStatusResponse extends CommonResponse { + private List messages; + + public CopyDomainTaskStatusResponse() { + } + + public List getMessages() { + return messages; + } + + public void setMessages(List messages) { + this.messages = messages; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/Cors.java b/src/main/java/com/baidubce/services/cdn/model/domain/Cors.java new file mode 100644 index 00000000..573382ff --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/Cors.java @@ -0,0 +1,69 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +public class Cors extends JsonObject { + private String allow; + private List originList; + + /**o + * @return allow + */ + public String getAllow() { + return allow; + } + + /** + * @param allow whether cross-domain access is allowed + */ + public void setAllow(String allow) { + this.allow = allow; + } + + /** + * @return originList + */ + public List getOriginList() { + return originList; + } + + /** + * @param originList List of domain names allowed across domains + */ + public void setOriginList(List originList) { + this.originList = originList; + } + + /** + * @param allow whether cross-domain access is allowed + * @return this object + */ + public Cors withAllow(String allow) { + this.allow = allow; + return this; + } + + /** + * @param originList List of domain names allowed across domains + * @return this object + */ + public Cors withOriginList(List originList) { + setOriginList(originList); + return this; + } + + /** + * @param origin domain's name + * @return this object + */ + public Cors addOriginList(String origin) { + if (originList == null) { + originList = new ArrayList(); + } + originList.add(origin); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CreateDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/CreateDomainRequest.java new file mode 100644 index 00000000..cd55653b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CreateDomainRequest.java @@ -0,0 +1,195 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cdn.model.OriginPeer; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.List; + +/** + * Created by sunyixing on 16/1/9. + * Updated by changxing01 on 22/4/11 + */ +public class CreateDomainRequest extends AbstractBceRequest { + + private List origin; + private String domain; + private String defaultHost; + private String form; + private Boolean follow302; + + /** + * @return defaultHost + */ + public String getDefaultHost() { + return defaultHost; + } + + /** + * @param defaultHost default back source host + */ + public void setDefaultHost(String defaultHost) { + this.defaultHost = defaultHost; + } + + /** + * @param defaultHost default back source host + * @return this object + */ + public CreateDomainRequest withDefaultHost(String defaultHost) { + this.defaultHost = defaultHost; + return this; + } + + /** + * @return form + */ + public String getForm() { + return form; + } + + /** + * @param form business type + */ + public void setForm(String form) { + this.form = form; + } + + /** + * @param form business type + * @return this object + */ + public CreateDomainRequest withForm(String form) { + this.form = form; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public CreateDomainRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * @return origin list + */ + public List getOrigin() { + return origin; + } + + /** + * @param origin origin list + */ + public void setOrigin(List origin) { + this.origin = origin; + } + + /** + * @param origin + * @return returns this object + */ + public CreateDomainRequest withOrigin(List origin) { + this.origin = origin; + return this; + } + + /** + * @param peer + * @return returns this object + */ + public CreateDomainRequest addPeer(OriginPeer peer) { + origin.add(peer); + return this; + } + + /** + * @param peer + * @return returns this object + */ + public CreateDomainRequest addPeer(String peer) { + OriginPeer op = new OriginPeer().withPeer(peer); + origin.add(op); + return this; + } + + /** + * 是否开启回源follow 302 + * @return + */ + public Boolean getFollow302() { + return follow302; + } + + /** + * 是否开启回源follow 302 + * @return + */ + public void setFollow302(Boolean follow302) { + this.follow302 = follow302; + } + + /** + * 是否开启回源follow 302 + * @return returns this object + */ + public CreateDomainRequest withFollow302(Boolean follow302) { + this.follow302 = follow302; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public CreateDomainRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/CreateDomainResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/CreateDomainResponse.java new file mode 100644 index 00000000..0ec1a208 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/CreateDomainResponse.java @@ -0,0 +1,67 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * @author yixing + * update by changxing01 on 19/8/27 + */ +public class CreateDomainResponse extends CdnResponse { + private String insId; + private String cname; + private String status; + + /** + * @return cname + */ + public String getCname() { + return cname; + } + + /** + * @param cname + */ + public void setCname(String cname) { + this.cname = cname; + } + + /** + * @return insId + */ + public String getInsId() { + return insId; + } + + /** + * @param insId instance id + */ + public void setInsId(String insId) { + this.insId = insId; + } + + /** + * @return status + */ + public String getStatus() { + return status; + } + + /** + * @param status create status + */ + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/DeleteDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/DeleteDomainRequest.java new file mode 100644 index 00000000..b7362314 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/DeleteDomainRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yixing + * + */ +public class DeleteDomainRequest extends AbstractBceRequest { + + private String domain; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public DeleteDomainRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public DeleteDomainRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/DisableDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/DisableDomainRequest.java new file mode 100644 index 00000000..da3488f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/DisableDomainRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * @author yixing + * + */ +public class DisableDomainRequest extends AbstractBceRequest { + private String domain; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public DisableDomainRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public DisableDomainRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/PrefetchTask.java b/src/main/java/com/baidubce/services/cdn/model/domain/DisableDomainResponse.java similarity index 63% rename from src/main/java/com/baidubce/services/cdn/model/PrefetchTask.java rename to src/main/java/com/baidubce/services/cdn/model/domain/DisableDomainResponse.java index f2700c9b..876d2bb5 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PrefetchTask.java +++ b/src/main/java/com/baidubce/services/cdn/model/domain/DisableDomainResponse.java @@ -10,22 +10,13 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ +package com.baidubce.services.cdn.model.domain; -package com.baidubce.services.cdn.model; +import com.baidubce.services.cdn.model.CdnResponse; -public class PrefetchTask extends JsonObject { - private String url; - - public void setUrl(String url) { - this.url = url; - } - - public String getUrl() { - return url; - } - - public PrefetchTask withUrl(String url) { - setUrl(url); - return this; - } +/** + * @author yixing + * + */ +public class DisableDomainResponse extends CdnResponse { } diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/DomainConfigKeysResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/DomainConfigKeysResponse.java new file mode 100644 index 00000000..888676b8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/DomainConfigKeysResponse.java @@ -0,0 +1,23 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.Map; + +public class DomainConfigKeysResponse extends CdnResponse { + /** + * 能复制的配置项列表 + */ + private Map configs; + + public DomainConfigKeysResponse() { + } + + public Map getConfigs() { + return configs; + } + + public void setConfigs(Map configs) { + this.configs = configs; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/DomainMiddleRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/DomainMiddleRequest.java new file mode 100644 index 00000000..59894b62 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/DomainMiddleRequest.java @@ -0,0 +1,60 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Models exist for transformation + * create by changxing01 on 19/8/27 + */ +public class DomainMiddleRequest extends AbstractBceRequest { + private String domain; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public DomainMiddleRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public DomainMiddleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/Enable.java b/src/main/java/com/baidubce/services/cdn/model/domain/Enable.java new file mode 100644 index 00000000..f2da082a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/Enable.java @@ -0,0 +1,25 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +public class Enable extends JsonObject { + + /** + * true表示开启IPv6开关,false表示关闭IPv6开关 + * 必选 + */ + private boolean enable; + + public boolean isEnable() { + return enable; + } + + public void setEnable(boolean enable) { + this.enable = enable; + } + + public Enable withEnable(boolean enable) { + setEnable(enable); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/EnableDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/EnableDomainRequest.java new file mode 100644 index 00000000..85e7601e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/EnableDomainRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yixing + * + */ +public class EnableDomainRequest extends AbstractBceRequest { + private String domain; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public EnableDomainRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public EnableDomainRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/EnableDomainResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/EnableDomainResponse.java new file mode 100644 index 00000000..5d2f1ffc --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/EnableDomainResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * @author yixing + * + */ +public class EnableDomainResponse extends CdnResponse { +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/ErrorPage.java b/src/main/java/com/baidubce/services/cdn/model/domain/ErrorPage.java new file mode 100644 index 00000000..eaec7d48 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/ErrorPage.java @@ -0,0 +1,80 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/27 + */ +public class ErrorPage extends JsonObject { + + /** + * 特定的状态码,要求必须为HTTP的标准错误码,且不能是408、444、499等客户端异常/提前断开这类特殊状态码 + * 必选 + */ + private Integer code; + + /** + * 重定向目标地址 ,当出现code错误码是,重定向到这个用户自定义的url + * 必选 + */ + private String url; + + /** + * 重定向状态码,当出现code错误码时,重定向的类型。支持301和302,默认302 + * 可选 + */ + private Integer redirectCode; + + public ErrorPage() { + } + + public ErrorPage(int code, String url) { + this.code = code; + this.url = url; + } + + public ErrorPage(int code, String url, int redirectCode) { + this.code = code; + this.url = url; + this.redirectCode = redirectCode; + } + + public ErrorPage withCode(Integer code) { + this.code = code; + return this; + } + + public ErrorPage withUrl(String url) { + this.url = url; + return this; + } + + public ErrorPage withRedirectCode(Integer redirectCode) { + this.redirectCode = redirectCode; + return this; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Integer getRedirectCode() { + return redirectCode; + } + + public void setRedirectCode(Integer redirectCode) { + this.redirectCode = redirectCode; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainAccessLimitResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainAccessLimitResponse.java new file mode 100644 index 00000000..82b2743a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainAccessLimitResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by changxing01 on 19/8/27 + */ +public class GetDomainAccessLimitResponse extends CdnResponse { + private AccessLimit accessLimit; + + /** + * @return accessLimit + */ + public AccessLimit getAccessLimit() { + return accessLimit; + } + + /** + * @param accessLimit IP access frequency limit control information + */ + public void setAccessLimit(AccessLimit accessLimit) { + this.accessLimit = accessLimit; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheFullUrlResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheFullUrlResponse.java new file mode 100644 index 00000000..560ae667 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheFullUrlResponse.java @@ -0,0 +1,50 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +/** + * create by changxing01 on 19/8/27 + */ +public class GetDomainCacheFullUrlResponse extends CdnResponse { + private boolean cacheFullUrl; + private List cacheUrlArgs; + private List ignoreUrlArgs; + + /** + * @return cacheFullUrl + */ + public boolean isCacheFullUrl() { + return cacheFullUrl; + } + + /** + * @param cacheFullUrl whether full URL caching is supported + */ + public void setCacheFullUrl(boolean cacheFullUrl) { + this.cacheFullUrl = cacheFullUrl; + } + + /** + * @return cacheUrlArgs + */ + public List getCacheUrlArgs() { + return cacheUrlArgs; + } + + /** + * @param cacheUrlArgs List of reserved parameters + */ + public void setCacheUrlArgs(List cacheUrlArgs) { + this.cacheUrlArgs = cacheUrlArgs; + } + + public List getIgnoreUrlArgs() { + return ignoreUrlArgs; + } + + public void setIgnoreUrlArgs(List ignoreUrlArgs) { + this.ignoreUrlArgs = ignoreUrlArgs; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheShareResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheShareResponse.java new file mode 100644 index 00000000..1ceb0313 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheShareResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by hansongda on 20/12/01 + */ +public class GetDomainCacheShareResponse extends CdnResponse { + private CacheShare cacheShare; + + public CacheShare getCacheShare() { + return cacheShare; + } + + public void setCacheShare(CacheShare cacheShare) { + this.cacheShare = cacheShare; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheTTLRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheTTLRequest.java new file mode 100644 index 00000000..aaa7f353 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheTTLRequest.java @@ -0,0 +1,89 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * @author yixing + * + */ +public class GetDomainCacheTTLRequest extends AbstractBceRequest { + private String domain; + private boolean cacheFullUrl; + + /** + * @return cacheFullUrl + */ + public boolean isCacheFullUrl() { + return cacheFullUrl; + } + + /** + * @param cacheFullUrl + */ + public void setCacheFullUrl(boolean cacheFullUrl) { + this.cacheFullUrl = cacheFullUrl; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public GetDomainCacheTTLRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetDomainCacheTTLRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheTTLResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheTTLResponse.java new file mode 100644 index 00000000..a5369f05 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCacheTTLResponse.java @@ -0,0 +1,54 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +/** + * @author yixing + * + */ +public class GetDomainCacheTTLResponse extends CdnResponse { + private String domain; + private List cacheTTL; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @return cacheTTL + */ + public List getCacheTTL() { + return cacheTTL; + } + + /** + * @param cacheTTL + */ + public void setCacheTTL(List cacheTTL) { + this.cacheTTL = cacheTTL; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainClientIpResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainClientIpResponse.java new file mode 100644 index 00000000..9e15ddd2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainClientIpResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by changxing01 on 19/8/27 + */ +public class GetDomainClientIpResponse extends CdnResponse { + private ClientIp clientIp; + + /** + * @return clientIp + */ + public ClientIp getClientIp() { + return clientIp; + } + + /** + * @param clientIp Turn it ON or OFF and the IP type + */ + public void setClientIp(ClientIp clientIp) { + this.clientIp = clientIp; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCompressResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCompressResponse.java new file mode 100644 index 00000000..cc5c0cd8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCompressResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetDomainCompressResponse extends CdnResponse { + private CompressResponse compress; + + /** + * @return compress + */ + public CompressResponse getCompress() { + return compress; + } + + /** + * @param compress Detailed configuration of page compression + */ + public void setCompress(CompressResponse compress) { + this.compress = compress; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainConfigRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainConfigRequest.java new file mode 100644 index 00000000..6fa0db85 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainConfigRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * @author yixing + * + */ +public class GetDomainConfigRequest extends AbstractBceRequest { + private String domain; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public GetDomainConfigRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetDomainConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainConfigResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainConfigResponse.java new file mode 100644 index 00000000..512750e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainConfigResponse.java @@ -0,0 +1,162 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; +import com.baidubce.services.cdn.model.OriginPeer; + +import java.util.List; + +/** + * @author yixing + * update by changxing01 19/8/28 + * + */ +public class GetDomainConfigResponse extends CdnResponse { + private String domain; + private String cname; + private String status; + private String createTime; + private String lastModifyTime; + private Boolean isBan; + private String form; + private List origin; + private String defaultHost; + private List cacheTTL; + private Integer limitRate; + private RequestAuth requestAuth; + private HttpsConfig https; + private Boolean followProtocol; + private SeoSwitch seoSwitch; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getCname() { + return cname; + } + + public void setCname(String cname) { + this.cname = cname; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getLastModifyTime() { + return lastModifyTime; + } + + public void setLastModifyTime(String lastModifyTime) { + this.lastModifyTime = lastModifyTime; + } + + public Boolean getBan() { + return isBan; + } + + public void setBan(Boolean ban) { + isBan = ban; + } + + public String getForm() { + return form; + } + + public void setForm(String form) { + this.form = form; + } + + public List getOrigin() { + return origin; + } + + public void setOrigin(List origin) { + this.origin = origin; + } + + public String getDefaultHost() { + return defaultHost; + } + + public void setDefaultHost(String defaultHost) { + this.defaultHost = defaultHost; + } + + public List getCacheTTL() { + return cacheTTL; + } + + public void setCacheTTL(List cacheTTL) { + this.cacheTTL = cacheTTL; + } + + public Integer getLimitRate() { + return limitRate; + } + + public void setLimitRate(Integer limitRate) { + this.limitRate = limitRate; + } + + public RequestAuth getRequestAuth() { + return requestAuth; + } + + public void setRequestAuth(RequestAuth requestAuth) { + this.requestAuth = requestAuth; + } + + public HttpsConfig getHttps() { + return https; + } + + public void setHttps(HttpsConfig https) { + this.https = https; + } + + public Boolean getFollowProtocol() { + return followProtocol; + } + + public void setFollowProtocol(Boolean followProtocol) { + this.followProtocol = followProtocol; + } + + public SeoSwitch getSeoSwitch() { + return seoSwitch; + } + + public void setSeoSwitch(SeoSwitch seoSwitch) { + this.seoSwitch = seoSwitch; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCorsResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCorsResponse.java new file mode 100644 index 00000000..338805e0 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainCorsResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class GetDomainCorsResponse extends CdnResponse { + private Cors cors; + + /** + * @return cors + */ + public Cors getCors() { + return cors; + } + + /** + * @param cors the cors config of domain + */ + public void setCors(Cors cors) { + this.cors = cors; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainErrorPageResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainErrorPageResponse.java new file mode 100644 index 00000000..1ed4f60b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainErrorPageResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +public class GetDomainErrorPageResponse extends CdnResponse { + private List errorPage; + + /** + * @return errorPage + */ + public List getErrorPage() { + return errorPage; + } + + /** + * @param errorPage error page info + */ + public void setErrorPage(List errorPage) { + this.errorPage = errorPage; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainFileTrimResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainFileTrimResponse.java new file mode 100644 index 00000000..8843fd99 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainFileTrimResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetDomainFileTrimResponse extends CdnResponse { + private boolean fileTrim; + + /** + * @return fileTrim + */ + public boolean isFileTrim() { + return fileTrim; + } + + /** + * @param fileTrim Whether to enable page optimization + */ + public void setFileTrim(boolean fileTrim) { + this.fileTrim = fileTrim; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainHSTSResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainHSTSResponse.java new file mode 100644 index 00000000..7215e9f5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainHSTSResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by hansongda on 20/12/01 + */ +public class GetDomainHSTSResponse extends CdnResponse { + private Hsts HSTS; + + public Hsts getHSTS() { + return HSTS; + } + + public void setHSTS(Hsts HSTS) { + this.HSTS = HSTS; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainHttpHeaderResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainHttpHeaderResponse.java new file mode 100644 index 00000000..43a7d51d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainHttpHeaderResponse.java @@ -0,0 +1,27 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetDomainHttpHeaderResponse extends CdnResponse { + + private List httpHeader; + + /** + * @return httpHeader + */ + public List getHttpHeader() { + return httpHeader; + } + + /** + * @param httpHeader Set back source or respond to Header + */ + public void setHttpHeader(List httpHeader) { + this.httpHeader = httpHeader; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainIPv6DispatchResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainIPv6DispatchResponse.java new file mode 100644 index 00000000..34d0754e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainIPv6DispatchResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by hansongda on 20/12/01 + */ +public class GetDomainIPv6DispatchResponse extends CdnResponse { + private Enable ipv6Dispatch; + + public GetDomainIPv6DispatchResponse() { + } + + public Enable getIpv6Dispatch() { + return ipv6Dispatch; + } + + public void setIpv6Dispatch(Enable ipv6Dispatch) { + this.ipv6Dispatch = ipv6Dispatch; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainIpACLResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainIpACLResponse.java new file mode 100644 index 00000000..0ebbaf79 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainIpACLResponse.java @@ -0,0 +1,25 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; +import com.baidubce.services.cdn.model.IpACL; + +/** + * create by changxing01 on 19/9/3 + */ +public class GetDomainIpACLResponse extends CdnResponse { + private IpACL ipACL; + + /** + * @return ipACL + */ + public IpACL getIpACL() { + return ipACL; + } + + /** + * @param ipACL ip config info + */ + public void setIpACL(IpACL ipACL) { + this.ipACL = ipACL; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainLimitBandwidthResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainLimitBandwidthResponse.java new file mode 100644 index 00000000..fbe7306d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainLimitBandwidthResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class GetDomainLimitBandwidthResponse extends CdnResponse { + private LimitBandwidth limitBandwidth; + + public LimitBandwidth getLimitBandwidth() { + return limitBandwidth; + } + + public void setLimitBandwidth(LimitBandwidth limitBandwidth) { + this.limitBandwidth = limitBandwidth; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainLogRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainLogRequest.java new file mode 100644 index 00000000..b3d73f2b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainLogRequest.java @@ -0,0 +1,96 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * @author yixing + * + */ +public class GetDomainLogRequest extends CdnRequest { + private String domain; + private String startTime; + private String endTime; + + /** + * @return startTime + */ + public String getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetDomainLogRequest withStartTime(String startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return endTime + */ + public String getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetDomainLogRequest withEndTime(String endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public GetDomainLogRequest withDomain(String domain) { + this.domain = domain; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainLogResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainLogResponse.java new file mode 100644 index 00000000..9c62dbb3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainLogResponse.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; +import com.baidubce.services.cdn.model.logmodel.LogEntry; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author yixing + * + */ +public class GetDomainLogResponse extends CdnResponse { + private List logs = new ArrayList(); + + /** + * @return logs + */ + public List getLogs() { + return logs; + } + + /** + * @param logs + */ + public void setLogs(List logs) { + this.logs = logs; + } +} + + diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainMediaDragResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainMediaDragResponse.java new file mode 100644 index 00000000..6df00691 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainMediaDragResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetDomainMediaDragResponse extends CdnResponse { + private MediaDragConf mediaDragConf; + + /** + * @return mediaDragConf + */ + public MediaDragConf getMediaDragConf() { + return mediaDragConf; + } + + /** + * @param mediaDragConf Video drag settings + */ + public void setMediaDragConf(MediaDragConf mediaDragConf) { + this.mediaDragConf = mediaDragConf; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainMobileAccessResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainMobileAccessResponse.java new file mode 100644 index 00000000..71cc9626 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainMobileAccessResponse.java @@ -0,0 +1,25 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by changxing01 on 19/8/27 + */ +public class GetDomainMobileAccessResponse extends CdnResponse { + + private MobileAccess mobileAccess; + + /** + * @return mobileAccess + */ + public MobileAccess getMobileAccess() { + return mobileAccess; + } + + /** + * @param mobileAccess Mobile access control + */ + public void setMobileAccess(MobileAccess mobileAccess) { + this.mobileAccess = mobileAccess; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOCSPResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOCSPResponse.java new file mode 100644 index 00000000..9ae22dc5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOCSPResponse.java @@ -0,0 +1,22 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class GetDomainOCSPResponse extends CdnResponse { + private boolean ocspSwitchx; + + /** + * @return ocspSwitch + */ + public boolean getOCSPSwitch() { + return ocspSwitchx; + } + + /** + * @param ocspSwitch OCSP + */ + public void setOCSPSwitch(boolean ocspSwitch) { + this.ocspSwitchx = ocspSwitch; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOCSPSwitchResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOCSPSwitchResponse.java new file mode 100644 index 00000000..66df3852 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOCSPSwitchResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by hansongda on 20/12/01 + */ +public class GetDomainOCSPSwitchResponse extends CdnResponse { + private boolean ocsp; + + public boolean isOcsp() { + return ocsp; + } + + public void setOcsp(boolean ocsp) { + this.ocsp = ocsp; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOfflineModeSwitchResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOfflineModeSwitchResponse.java new file mode 100644 index 00000000..359c76a9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOfflineModeSwitchResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by hansongda on 20/12/01 + */ +public class GetDomainOfflineModeSwitchResponse extends CdnResponse { + private boolean OfflineMode; + + public boolean isOfflineMode() { + return OfflineMode; + } + + public void setOfflineMode(boolean offlineMode) { + OfflineMode = offlineMode; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginFixedIspResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginFixedIspResponse.java new file mode 100644 index 00000000..1570f6c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginFixedIspResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class GetDomainOriginFixedIspResponse extends CdnResponse { + private Boolean originFixedISP; + + public GetDomainOriginFixedIspResponse() { + } + + public Boolean getOriginFixedISP() { + return originFixedISP; + } + + public void setOriginFixedISP(Boolean originFixedISP) { + this.originFixedISP = originFixedISP; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginProtocolRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginProtocolRequest.java new file mode 100644 index 00000000..072904e6 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginProtocolRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class GetDomainOriginProtocolRequest extends AbstractBceRequest { + + private String domain; + + public GetDomainOriginProtocolRequest() { + } + + public GetDomainOriginProtocolRequest(String domain) { + this.domain = domain; + } + + public GetDomainOriginProtocolRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public String getDomain() { + return domain; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginProtocolResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginProtocolResponse.java new file mode 100644 index 00000000..dc87e1a3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginProtocolResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class GetDomainOriginProtocolResponse extends CdnResponse { + private OriginProtocol originProtocol; + + public OriginProtocol getOriginProtocol() { + return originProtocol; + } + + public void setOriginProtocol(OriginProtocol originProtocol) { + this.originProtocol = originProtocol; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginResponse.java new file mode 100644 index 00000000..483ca020 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginResponse.java @@ -0,0 +1,39 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; +import com.baidubce.services.cdn.model.OriginPeer; + +import java.util.List; + +public class GetDomainOriginResponse extends CdnResponse { + private List origin; + private String defaultHost; + private Boolean follow302; + + public GetDomainOriginResponse() { + } + + public List getOrigin() { + return origin; + } + + public void setOrigin(List origin) { + this.origin = origin; + } + + public String getDefaultHost() { + return defaultHost; + } + + public void setDefaultHost(String defaultHost) { + this.defaultHost = defaultHost; + } + + public Boolean getFollow302() { + return follow302; + } + + public void setFollow302(Boolean follow302) { + this.follow302 = follow302; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginTimeoutResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginTimeoutResponse.java new file mode 100644 index 00000000..02ed66e6 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainOriginTimeoutResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class GetDomainOriginTimeoutResponse extends CdnResponse { + private OriginTimeout originTimeout; + + public GetDomainOriginTimeoutResponse() { + } + + public OriginTimeout getOriginTimeout() { + return originTimeout; + } + + public void setOriginTimeout(OriginTimeout originTimeout) { + this.originTimeout = originTimeout; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainQUICSwitchResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainQUICSwitchResponse.java new file mode 100644 index 00000000..2a85215c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainQUICSwitchResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by hansongda on 20/12/01 + */ +public class GetDomainQUICSwitchResponse extends CdnResponse { + private boolean quic; + + public boolean isQuic() { + return quic; + } + + public void setQuic(boolean quic) { + this.quic = quic; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainRangeSwitchResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainRangeSwitchResponse.java new file mode 100644 index 00000000..c1bf6c5c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainRangeSwitchResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by changxing01 on 19/8/27 + */ +public class GetDomainRangeSwitchResponse extends CdnResponse { + private String rangeSwitch; + + /** + * @return rangeSwitch + */ + public String getRangeSwitch() { + return rangeSwitch; + } + + /** + * @param rangeSwitch Whether Range back to source + */ + public void setRangeSwitch(String rangeSwitch) { + this.rangeSwitch = rangeSwitch; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainRefererACLResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainRefererACLResponse.java new file mode 100644 index 00000000..78e40159 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainRefererACLResponse.java @@ -0,0 +1,25 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; +import com.baidubce.services.cdn.model.RefererACL; + +/** + * create by changxing01 on 19/9/3 + */ +public class GetDomainRefererACLResponse extends CdnResponse { + private RefererACL refererACL; + + /** + * @return refererACL + */ + public RefererACL getRefererACL() { + return refererACL; + } + + /** + * @param refererACL referer config rules + */ + public void setRefererACL(RefererACL refererACL) { + this.refererACL = refererACL; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainRetryOriginResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainRetryOriginResponse.java new file mode 100644 index 00000000..48d1c93c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainRetryOriginResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by hansongda on 20/12/01 + */ +public class GetDomainRetryOriginResponse extends CdnResponse { + private RetryOrigin retryOrigin; + + public RetryOrigin getRetryOrigin() { + return retryOrigin; + } + + public void setRetryOrigin(RetryOrigin retryOrigin) { + this.retryOrigin = retryOrigin; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainSeoSwitchResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainSeoSwitchResponse.java new file mode 100644 index 00000000..725eef74 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainSeoSwitchResponse.java @@ -0,0 +1,25 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetDomainSeoSwitchResponse extends CdnResponse { + private SeoSwitch seoSwitch; + + /** + * @return seoSwitch + */ + public SeoSwitch getSeoSwitch() { + return seoSwitch; + } + + /** + * @param seoSwitch Set seo switch properties + */ + public void setSeoSwitch(SeoSwitch seoSwitch) { + this.seoSwitch = seoSwitch; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainTrafficLimitRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainTrafficLimitRequest.java new file mode 100644 index 00000000..dc7f7736 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainTrafficLimitRequest.java @@ -0,0 +1,35 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class GetDomainTrafficLimitRequest extends AbstractBceRequest { + + private String domain; + + public GetDomainTrafficLimitRequest() { + } + + public GetDomainTrafficLimitRequest(String domain) { + this.domain = domain; + } + + public GetDomainTrafficLimitRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainTrafficLimitResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainTrafficLimitResponse.java new file mode 100644 index 00000000..07e4dc29 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainTrafficLimitResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class GetDomainTrafficLimitResponse extends CdnResponse { + + private TrafficLimit trafficLimit; + + public TrafficLimit getTrafficLimit() { + return trafficLimit; + } + + public void setTrafficLimit(TrafficLimit trafficLimit) { + this.trafficLimit = trafficLimit; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainUaAclResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainUaAclResponse.java new file mode 100644 index 00000000..622b9822 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainUaAclResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class GetDomainUaAclResponse extends CdnResponse { + private UaAcl uaAcl; + + public UaAcl getUaAcl() { + return uaAcl; + } + + public void setUaAcl(UaAcl uaAcl) { + this.uaAcl = uaAcl; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainUrlRulesResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainUrlRulesResponse.java new file mode 100644 index 00000000..3441706b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetDomainUrlRulesResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +public class GetDomainUrlRulesResponse extends CdnResponse { + private List urlRules; + + public GetDomainUrlRulesResponse() { + } + + public List getUrlRules() { + return urlRules; + } + + public void setUrlRules(List urlRules) { + this.urlRules = urlRules; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetIcpResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetIcpResponse.java new file mode 100644 index 00000000..62937e33 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetIcpResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class GetIcpResponse extends CdnResponse { + + @JsonProperty("IcpStatus") + private String icpStatus; + + public GetIcpResponse() { + } + + public String getIcpStatus() { + return icpStatus; + } + + public void setIcpStatus(String icpStatus) { + this.icpStatus = icpStatus; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetUserDomainResponse.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetUserDomainResponse.java new file mode 100644 index 00000000..125ab9b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetUserDomainResponse.java @@ -0,0 +1,26 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +/** + * create by changxing01 on 19/8/27 + */ +public class GetUserDomainResponse extends CdnResponse { + private List domains; + + /** + * @return domain list + */ + public List getDomains() { + return domains; + } + + /** + * @param domains user's domains + */ + public void setDomains(List domains) { + this.domains = domains; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/GetUserDomainsRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/GetUserDomainsRequest.java new file mode 100644 index 00000000..5ee85a57 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/GetUserDomainsRequest.java @@ -0,0 +1,79 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * create by changxing01 on 19/8/27 + */ +public class GetUserDomainsRequest extends AbstractBceRequest { + private String status; + private String rule; + + /** + * @return status + */ + public String getStatus() { + return status; + } + + /** + * @param status filter domain status + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * @return rule + */ + public String getRule() { + return rule; + } + + /** + * @param rule fuzzy matching content + */ + public void setRule(String rule) { + this.rule = rule; + } + + /** + * @param status filter domain status + * @return returns this object + */ + public GetUserDomainsRequest withStatus(String status) { + this.status = status; + return this; + } + + public GetUserDomainsRequest withRule(String rule) { + this.rule = rule; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/Hsts.java b/src/main/java/com/baidubce/services/cdn/model/domain/Hsts.java new file mode 100644 index 00000000..62dbf025 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/Hsts.java @@ -0,0 +1,64 @@ +package com.baidubce.services.cdn.model.domain; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Hsts { + + /** + * 配置保存时间,单位为天, 用户输入值为 0 ~ 730 或者-1,为 -1 时表示取消该配置项 + * 必选 + */ + private int maxAge; + + /** + * 是否包含子域名,默认值为 false + * 可选 + */ + private Boolean includeSubDomains; + + /** + * 是否支持preload列表,默认值为 false + * 可选 + */ + private Boolean preload; + + public int getMaxAge() { + return maxAge; + } + + public void setMaxAge(int maxAge) { + this.maxAge = maxAge; + } + + public Boolean getIncludeSubDomains() { + return includeSubDomains; + } + + public void setIncludeSubDomains(Boolean includeSubDomains) { + this.includeSubDomains = includeSubDomains; + } + + public Boolean getPreload() { + return preload; + } + + public void setPreload(Boolean preload) { + this.preload = preload; + } + + public Hsts withMaxAge(int maxAge) { + setMaxAge(maxAge); + return this; + } + + public Hsts withIncludeSubDomains(boolean includeSubDomains) { + setIncludeSubDomains(includeSubDomains); + return this; + } + + public Hsts withPreload(boolean preload) { + setPreload(preload); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/HttpHeader.java b/src/main/java/com/baidubce/services/cdn/model/domain/HttpHeader.java new file mode 100644 index 00000000..734fd7eb --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/HttpHeader.java @@ -0,0 +1,159 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/28 + */ +public class HttpHeader extends JsonObject { + + /** + * "origin"表示此header 回源生效,"response"表示给用户响应时生效 + * 必选 + */ + private String type; + + /** + * header为http头字段,一般为HTTP的标准Header,也可以是用户自定义的;如x-bce-authoriztion + * 必选 + */ + private String header; + + /** + * 指定header的值。可支持有限个数的变量,字符$开始的子串一定要有其一符合 ${x} 的模式, + * 且x必须与以下字符串之一相等:uri、host、scheme和request_uri。 + * 典型非法值: + * 1、变量不符合限制要求,如"X-REQ-${url}",我们定义的合法变量里没有url; + * 2、包含$字符但不符合${x}模式,如:"X-REQ-$uri"。 + * 注意:value不支持$纯字符的传递,如果您希望响应客户端一个包含$符号的响应头将不被允许,如"X-$"是非法的。 + * 必选 + */ + private String value; + + /** + * 表示是删除还是添加,可选remove/add,默认是add + * 可选 + */ + private String action; + + /** + * 描述,可选,可以是中文,统一使用Unicode统码;长度不能超过100个字符 + * 可选 + */ + private String describe; + + /** + * @return type + */ + public String getType() { + return type; + } + + /** + * @param type Effective type + */ + public void setType(String type) { + this.type = type; + } + + /** + * @param type Effective type + * @return this object + */ + public HttpHeader withType(String type) { + this.type = type; + return this; + } + + /** + * @return header + */ + public String getHeader() { + return header; + } + + /** + * @param header Http header field + */ + public void setHeader(String header) { + this.header = header; + } + + /** + * @param header Http header field + * @return this object + */ + public HttpHeader withHeader(String header) { + this.header = header; + return this; + } + + /** + * @return value + */ + public String getValue() { + return value; + } + + /** + * @param value Header value + */ + public void setValue(String value) { + this.value = value; + } + + /** + * @param value Header value + * @return this object + */ + public HttpHeader withValue(String value) { + this.value = value; + return this; + } + + /** + * @return action + */ + public String getAction() { + return action; + } + + /** + * @param action remove/add + */ + public void setAction(String action) { + this.action = action; + } + + /** + * @param action remove/add + * @return this object + */ + public HttpHeader withAction(String action) { + this.action = action; + return this; + } + + /** + * @return describe + */ + public String getDescribe() { + return describe; + } + + /** + * @param describe description + */ + public void setDescribe(String describe) { + this.describe = describe; + } + + /** + * @param describe description + * @return this object + */ + public HttpHeader withDescribe(String describe) { + this.describe = describe; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/HttpsConfig.java b/src/main/java/com/baidubce/services/cdn/model/domain/HttpsConfig.java new file mode 100644 index 00000000..49917b5d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/HttpsConfig.java @@ -0,0 +1,262 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +import java.util.List; + +/** + * update by changxing01 on 19/8/28 + */ +public class HttpsConfig { + + /** + * 开启HTTPS加速(服务端HTTPS认证),默认为false,当enabled=false,以下几列字段设置无效(当certId=""时certId字段是有效的) + * 必选 + */ + private boolean enabled; + + /** + * 当enabled=true时此项为必选,为SSL证书服务返回的证书ID, + * 当enablae为false且certId为""时解绑domain当前绑定的certId,否则当enabled=False时此项无效 + * 可选 + */ + private String certId; + + /** + * 为true时将HTTP请求重定向到HTTPS(重定向状态码为httpRedirectCode所配置), + * 默认为false,当enabled=false此项无效,不可与httpsRedirect同时为true + * 可选 + */ + private Boolean httpRedirect; + + /** + * 重定向状态码,可选值301/302,默认302,当enabled=false此项无效,httpRedirect=false此项无效 + * 可选 + */ + private Integer httpRedirectCode; + + /** + * 为true时将HTTPS请求重定向到HTTP重定向状态码为httpsRedirectCode所配置), + * 默认为false,当enabled=false此项无效,不可与httpRedirect同时为true + * 可选 + */ + private Boolean httpsRedirect; + + /** + * 重定向状态码,可选值301/302,默认302,当enabled=false此项无效,httpsRedirect=false此项无效 + * 可选 + */ + private Integer httpsRedirectCode; + + /** + * 开启HTTP2特性,默认true,当enabled=false此项无效 + * 可选 + */ + private Boolean http2Enabled; + + /** + * 为true时开启HTTPS双向认证。只有开启了服务端HTTPS认证时可以开启该配置,默认为false + * 可选 + */ + private Boolean verifyClient; + + /** + * 设置访问TLS版本,默认为支持从TLSv1.0到TLSv1.3的版本, + * 也可以主动设置为以下四个中的一个或多个,"TLSv1.0","TLSv1.1","TLSv1.2","TLSv1.3"。 + * 该参数不能为空list。当enabled=false时此项无效。此项一般取默认值,无需设置 + * + * 可选 + */ + private List sslProtocols; + + /** + * 跳转时排除包含该字段ua值的请求 + * 批量上传时使用 + * + * 可选 + */ + private String disableHttpsSpider; + + /** + * @param httpRedirectCode http redirect code + * @return this object + */ + public HttpsConfig withHttpRedirectCode(int httpRedirectCode) { + this.httpRedirectCode = httpRedirectCode; + return this; + } + + /** + * @param httpsRedirect https redirect + * @return this object + */ + public HttpsConfig withHttpsRedirect(boolean httpsRedirect) { + this.httpsRedirect = httpsRedirect; + return this; + } + + /** + * @param httpsRedirectCode https redirect code + * @return this object + */ + public HttpsConfig withHttpsRedirectCode(int httpsRedirectCode) { + this.httpsRedirectCode = httpsRedirectCode; + return this; + } + + /** + * @param http2Enabled enable HTTP2 feature + * @return this object + */ + public HttpsConfig withHttp2Enabled(boolean http2Enabled) { + this.http2Enabled = http2Enabled; + return this; + } + + /** + * @param enabled Turn on HTTPS acceleration + * @return this object + */ + public HttpsConfig withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * @param certId certificate id + * @return this object + */ + public HttpsConfig withCertId(String certId) { + this.certId = certId; + return this; + } + + /** + * @param disableHttpsSpider 跳转时排除包含该字段ua值的请求 + * @return this object + */ + public HttpsConfig withDisableHttpsSpider(String disableHttpsSpider) { + this.disableHttpsSpider = disableHttpsSpider; + return this; + } + + /** + * @param httpRedirect http redirect code + * @return this object + */ + public HttpsConfig withHttpRedirect(boolean httpRedirect) { + this.httpRedirect = httpRedirect; + return this; + } + + /** + * @param verifyClient HTTP protocol source + * @return this object + */ + public HttpsConfig withVerifyClient(boolean verifyClient) { + this.verifyClient = verifyClient; + return this; + } + + /** + * @param sslProtocols TLS version + * @return this object + */ + public HttpsConfig withSslProtocols(List sslProtocols) { + this.sslProtocols = sslProtocols; + return this; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } + + public Boolean getHttpRedirect() { + return httpRedirect; + } + + public void setHttpRedirect(Boolean httpRedirect) { + this.httpRedirect = httpRedirect; + } + + public Integer getHttpRedirectCode() { + return httpRedirectCode; + } + + public void setHttpRedirectCode(Integer httpRedirectCode) { + this.httpRedirectCode = httpRedirectCode; + } + + public Boolean getHttpsRedirect() { + return httpsRedirect; + } + + public void setHttpsRedirect(Boolean httpsRedirect) { + this.httpsRedirect = httpsRedirect; + } + + public Integer getHttpsRedirectCode() { + return httpsRedirectCode; + } + + public void setHttpsRedirectCode(Integer httpsRedirectCode) { + this.httpsRedirectCode = httpsRedirectCode; + } + + public Boolean getHttp2Enabled() { + return http2Enabled; + } + + public void setHttp2Enabled(Boolean http2Enabled) { + this.http2Enabled = http2Enabled; + } + + public Boolean getVerifyClient() { + return verifyClient; + } + + public void setVerifyClient(Boolean verifyClient) { + this.verifyClient = verifyClient; + } + + public List getSslProtocols() { + return sslProtocols; + } + + public void setSslProtocols(List sslProtocols) { + this.sslProtocols = sslProtocols; + } + + public String getDisableHttpsSpider() { + return disableHttpsSpider; + } + + public void setDisableHttpsSpider(String disableHttpsSpider) { + this.disableHttpsSpider = disableHttpsSpider; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/LimitBandwidth.java b/src/main/java/com/baidubce/services/cdn/model/domain/LimitBandwidth.java new file mode 100644 index 00000000..0e30c753 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/LimitBandwidth.java @@ -0,0 +1,87 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +public class LimitBandwidth extends JsonObject { + + /** + * 开启/关闭带宽封顶配置 + * 必选 + */ + private boolean enabled; + + /** + * 带宽封顶阈值,带单位G,如"1G", "200G"。enable为true时必选 + * 必选 + */ + private String threshold; + + /** + * 带宽达到阈值时触发的动作,值为deny/stop,"stop"表示stop加速域名,"deny"表示拒绝所有请求。当enabled为true时必选 + * 必选 + */ + private String action; + + /** + * 主动设置是否执行action, + * 当设置为true时,无论带宽是否达到阈值,当前周期都会触发action, + * 当设置为false时,无论带宽是否达到阈值,当前周期都不会触发action + * 必选 + */ + private boolean actived; + + public LimitBandwidth() { + } + + public LimitBandwidth withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + public LimitBandwidth withActived(boolean actived) { + this.actived = actived; + return this; + } + + public LimitBandwidth withThreshold(String threshold) { + this.threshold = threshold; + return this; + } + + public LimitBandwidth withAction(String action) { + this.action = action; + return this; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getThreshold() { + return threshold; + } + + public void setThreshold(String threshold) { + this.threshold = threshold; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public boolean isActived() { + return actived; + } + + public void setActived(boolean actived) { + this.actived = actived; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/MediaDrag.java b/src/main/java/com/baidubce/services/cdn/model/domain/MediaDrag.java new file mode 100644 index 00000000..832d905d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/MediaDrag.java @@ -0,0 +1,143 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class MediaDrag extends JsonObject { + + /** + * 百度智能云CDN支持MP4文件的伪流(pseudo-streaming)播放, + * 通常这些文件拓展名为.mp4,.m4v,.m4a,因此这个fileSuffix值为文件拓展名集合, + * 如: ["mp4", "m4v", "m4a"],type为mp4,fileSuffix默认值为["mp4"];type为flv,fileSuffix默认值为["flv"] + * 可选 + */ + private List fileSuffix; + + /** + * start参数名称,默认为“start”,您可以自定义参数名称,但是要求不能和endArgName相同 + * 可选 + */ + private String startArgName; + + /** + * end参数名称,默认为“end”,您可以自定义参数名称,但是要求不能和startArgName相同 + * 可选 + */ + private String endArgName; + + /** + * mp4类型按秒进行拖拽,flv类型按字节进行拖拽。type为flv可选择的模式为“byteAV”或”byte”;type为mp4只能是"second"模式 + * 必选 + */ + private String dragMode; + + /** + * @return fileSuffix + */ + public List getFileSuffix() { + return fileSuffix; + } + + /** + * @param fileSuffix File extension + */ + public void setFileSuffix(List fileSuffix) { + this.fileSuffix = fileSuffix; + } + + /** + * @param fileSuffix File extension list + * @return this object + */ + public MediaDrag withFileSuffix(List fileSuffix) { + this.fileSuffix = fileSuffix; + return this; + } + + /** + * @param suffix File extension + * @return this object + */ + public MediaDrag addFileSuffix(String suffix) { + if (this.fileSuffix == null) { + this.fileSuffix = new ArrayList(); + } + this.fileSuffix.add(suffix); + return this; + } + + /** + * @return startArgName + */ + public String getStartArgName() { + return startArgName; + } + + /** + * @param startArgName Start parameter name + */ + public void setStartArgName(String startArgName) { + this.startArgName = startArgName; + } + + /** + * @param startArgName Start parameter name + * @return this object + */ + public MediaDrag withStartArgName(String startArgName) { + this.startArgName = startArgName; + return this; + } + + /** + * @return endArgName + */ + public String getEndArgName() { + return endArgName; + } + + /** + * @param endArgName End parameter name + */ + public void setEndArgName(String endArgName) { + this.endArgName = endArgName; + } + + /** + * @param endArgName End parameter name + * @return this object + */ + public MediaDrag withEndArgName(String endArgName) { + this.endArgName = endArgName; + return this; + } + + /** + * @return dragMode + */ + public String getDragMode() { + return dragMode; + } + + /** + * @param dragMode Drag method type + */ + public void setDragMode(String dragMode) { + this.dragMode = dragMode; + } + + /** + * @param dragMode Drag method type + * @return this object + */ + public MediaDrag withDragMode(String dragMode) { + this.dragMode = dragMode; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/MediaDragConf.java b/src/main/java/com/baidubce/services/cdn/model/domain/MediaDragConf.java new file mode 100644 index 00000000..4469c116 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/MediaDragConf.java @@ -0,0 +1,67 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/28 + */ +public class MediaDragConf extends JsonObject { + + /** + * mp4类型伪流的拖拽设置,如果是取消设置,请不要带上这个字段 + * 可选 + */ + private MediaDrag mp4; + + /** + * flv类型伪流的拖拽设置,如果是取消设置,请不要带上这个字段 + * 可选 + */ + private MediaDrag flv; + + /** + * @return mp4 + */ + public MediaDrag getMp4() { + return mp4; + } + + /** + * @param mp4 Drag settings for mp4 type pseudo flow + */ + public void setMp4(MediaDrag mp4) { + this.mp4 = mp4; + } + + /** + * @param mp4 Drag settings for mp4 type pseudo flow + * @return this object + */ + public MediaDragConf withMp4(MediaDrag mp4) { + this.mp4 = mp4; + return this; + } + + /** + * @return flv + */ + public MediaDrag getFlv() { + return flv; + } + + /** + * @param flv Drag settings for flv type pseudo flow + */ + public void setFlv(MediaDrag flv) { + this.flv = flv; + } + + /** + * @param flv Drag settings for flv type pseudo flow + * @return this object + */ + public MediaDragConf withFlv(MediaDrag flv) { + this.flv = flv; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/MobileAccess.java b/src/main/java/com/baidubce/services/cdn/model/domain/MobileAccess.java new file mode 100644 index 00000000..753c3867 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/MobileAccess.java @@ -0,0 +1,37 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/27 + */ +public class MobileAccess extends JsonObject { + /** + * true表示有针对性地对源端(移动端或PC端等)请求的资源内容分发,false表示无特殊针对 + * 必选 + */ + private boolean distinguishClient; + + /** + * @return distinguishClient + */ + public boolean isDistinguishClient() { + return distinguishClient; + } + + /** + * @param distinguishClient Resource content distribution is requested on the source side + */ + public void setDistinguishClient(boolean distinguishClient) { + this.distinguishClient = distinguishClient; + } + + /** + * @param distinguishClient Resource content distribution is requested on the source side + * @return this object + */ + public MobileAccess withDistinguishClient(boolean distinguishClient) { + this.distinguishClient = distinguishClient; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/OriginProtocol.java b/src/main/java/com/baidubce/services/cdn/model/domain/OriginProtocol.java new file mode 100644 index 00000000..923c0b5e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/OriginProtocol.java @@ -0,0 +1,27 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +public class OriginProtocol extends JsonObject { + private String value; + + public OriginProtocol() { + } + + public OriginProtocol(String value) { + this.value = value; + } + + public OriginProtocol withValue(String value) { + this.value = value; + return this; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/OriginTimeout.java b/src/main/java/com/baidubce/services/cdn/model/domain/OriginTimeout.java new file mode 100644 index 00000000..d55a23bf --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/OriginTimeout.java @@ -0,0 +1,40 @@ +package com.baidubce.services.cdn.model.domain; + +public class OriginTimeout { + private int connectTimeout; + private int loadTimeout; + + public OriginTimeout() { + } + + public OriginTimeout(int connectTimeout, int loadTimeout) { + this.connectTimeout = connectTimeout; + this.loadTimeout = loadTimeout; + } + + public int getConnectTimeout() { + return connectTimeout; + } + + public void setConnectTimeout(int connectTimeout) { + this.connectTimeout = connectTimeout; + } + + public int getLoadTimeout() { + return loadTimeout; + } + + public void setLoadTimeout(int loadTimeout) { + this.loadTimeout = loadTimeout; + } + + public OriginTimeout withConnectTimeout(int connectTimeout) { + setConnectTimeout(connectTimeout); + return this; + } + + public OriginTimeout withLoadTimeout(int loadTimeout) { + setLoadTimeout(loadTimeout); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/RequestAuth.java b/src/main/java/com/baidubce/services/cdn/model/domain/RequestAuth.java new file mode 100644 index 00000000..e4a3ebad --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/RequestAuth.java @@ -0,0 +1,178 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +public class RequestAuth { + + /** + * a/b/c 三种鉴权方式 + * 必选 + */ + private String type; + + /** + * 主鉴权key,输入大小写字母,数字,长度6到32位 + * 必选 + */ + private String key1; + + /** + * 副鉴权Key,输入大小写字母,数字,长度6到32位 + * 可选 + */ + private String key2; + + /** + * 鉴权缓存时间,支持B或C方式设置该参数,单位为秒;URL鉴权的过期时间为指定“timestamp+timeout”;默认为1800。UTC时间 + * 可选 + */ + private Number timeout = 1800; + + /** + * 白名单列表,在该名单中的文件名不需要鉴权 + * 可选 + */ + private List whiteList; + + /** + * 签名参数名,只对typeC生效 + * 可选 + */ + private String signArg; + + /** + * 时间戳参数名,只对typeC生效 + * 可选 + */ + private String timeArg; + + /** + * 时间格式。值为10,16或者yyyyMMDDhhmm,分别表示10进制时间格式, + * 16进制时间格式以及字符串类的时间格式。其中yyyyMMDDhhmm只有type为B的时候可以为该值 + * 可选 + */ + private String timestampMetric; + + public RequestAuth withTimestampMetric(String timestampMetric) { + this.timestampMetric = timestampMetric; + return this; + } + + public RequestAuth withType(String type) { + this.type = type; + return this; + } + + public RequestAuth withKey1(String key1) { + this.key1 = key1; + return this; + } + + public RequestAuth withKey2(String key2) { + this.key2 = key2; + return this; + } + + public RequestAuth withTimeout(Number timeout) { + this.timeout = timeout; + return this; + } + + public RequestAuth addWhiteList(String entry) { + if (whiteList == null) { + whiteList = new ArrayList(); + } + whiteList.add(entry); + return this; + } + + public RequestAuth withSignArg(String signArg) { + this.signArg = signArg; + return this; + } + + public RequestAuth withTimeArg(String timeArg) { + this.timeArg = timeArg; + return this; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getKey1() { + return key1; + } + + public void setKey1(String key1) { + this.key1 = key1; + } + + public String getKey2() { + return key2; + } + + public void setKey2(String key2) { + this.key2 = key2; + } + + public Number getTimeout() { + return timeout; + } + + public void setTimeout(Number timeout) { + this.timeout = timeout; + } + + public List getWhiteList() { + return whiteList; + } + + public void setWhiteList(List whiteList) { + this.whiteList = whiteList; + } + + public String getSignArg() { + return signArg; + } + + public void setSignArg(String signArg) { + this.signArg = signArg; + } + + public String getTimeArg() { + return timeArg; + } + + public void setTimeArg(String timeArg) { + this.timeArg = timeArg; + } + + public String getTimestampMetric() { + return timestampMetric; + } + + public void setTimestampMetric(String timestampMetric) { + this.timestampMetric = timestampMetric; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/RetryOrigin.java b/src/main/java/com/baidubce/services/cdn/model/domain/RetryOrigin.java new file mode 100644 index 00000000..9ff2c6e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/RetryOrigin.java @@ -0,0 +1,32 @@ +package com.baidubce.services.cdn.model.domain; + +import java.util.ArrayList; +import java.util.List; + +public class RetryOrigin { + private List codes; + + public RetryOrigin(List codes) { + this.codes = codes; + } + + public RetryOrigin() { + } + + public List getCodes() { + return codes; + } + + public void setCodes(List codes) { + this.codes = codes; + } + + public RetryOrigin addCode(Integer code) { + if (codes == null) { + codes = new ArrayList(); + } + codes.add(code); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SeoSwitch.java b/src/main/java/com/baidubce/services/cdn/model/domain/SeoSwitch.java new file mode 100644 index 00000000..4f80939c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SeoSwitch.java @@ -0,0 +1,67 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/28 + */ +public class SeoSwitch { + + /** + * ON 表示设置直接回源,OFF 则相反 + * 可选 + */ + private String diretlyOrigin; + + /** + * ON 表示给百度搜索推送访问记录,OFF则相反 + * 可选 + */ + private String pushRecord; + + /** + * @return diretlyOrigin + */ + public String getDiretlyOrigin() { + return diretlyOrigin; + } + + /** + * @param diretlyOrigin Whether to return directly to the source + */ + public void setDiretlyOrigin(String diretlyOrigin) { + this.diretlyOrigin = diretlyOrigin; + } + + /** + * @param diretlyOrigin Whether to return directly to the source + * @return this object + */ + public SeoSwitch withDiretlyOrigin(String diretlyOrigin) { + this.diretlyOrigin = diretlyOrigin; + return this; + } + + /** + * @return pushRecord + */ + public String getPushRecord() { + return pushRecord; + } + + /** + * @param pushRecord Push access to the big search + */ + public void setPushRecord(String pushRecord) { + this.pushRecord = pushRecord; + } + + /** + * @param pushRecord Push access to the big search + * @return this object + */ + public SeoSwitch withPushRecord(String pushRecord) { + this.pushRecord = pushRecord; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainAccessLimitRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainAccessLimitRequest.java new file mode 100644 index 00000000..40f27693 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainAccessLimitRequest.java @@ -0,0 +1,84 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * create by changxing01 on 19/8/27 + */ +public class SetDomainAccessLimitRequest extends AbstractBceRequest { + + private String domain; + private AccessLimit accessLimit; + + /** + * @return accessLimit + */ + public AccessLimit getAccessLimit() { + return accessLimit; + } + + /** + * @param accessLimit IP access frequency limit control information + */ + public void setAccessLimit(AccessLimit accessLimit) { + this.accessLimit = accessLimit; + } + + /** + * @param accessLimit IP access frequency limit control information + * @return this object + */ + public SetDomainAccessLimitRequest withAccessLimit(AccessLimit accessLimit) { + this.accessLimit = accessLimit; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainAccessLimitRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCacheFullUrlRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCacheFullUrlRequest.java new file mode 100644 index 00000000..50796da4 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCacheFullUrlRequest.java @@ -0,0 +1,154 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cdn.model.CdnRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author yixing + * update by changxing01 on 19/8/28 + */ +public class SetDomainCacheFullUrlRequest extends CdnRequest { + private String domain; + + /** + * true和false,true表示支持全URL缓存,false表示忽略参数缓存(可保留部分参数) + * 必选 + */ + private Boolean cacheFullUrl; + + /** + * cacheFullUrl为true时,此项不起作用;cacheFullUrl为false时,此项表示保留的参数列表,如果为空,表示忽略所有参数 + * 可选 + */ + private List cacheUrlArgs; + + /** + * ignoreUrlArgs为true时,此项不起作用; cacheFullUrl为false时,此项表示忽略的参数列表,如果为空,表示保留所有参数 + * 可选 + */ + private List ignoreUrlArgs; + + /** + * @param ignoreUrlArgs List of reserved parameters + * @return returns this object + */ + public SetDomainCacheFullUrlRequest withIgnoreUrlArgs(List ignoreUrlArgs) { + this.ignoreUrlArgs = ignoreUrlArgs; + return this; + } + + /** + * @param ignoreUrlArg List of reserved parameter + * @return returns this object + */ + public SetDomainCacheFullUrlRequest addIgnoreUrlArgs(String ignoreUrlArg) { + if (this.ignoreUrlArgs == null) { + this.ignoreUrlArgs = new ArrayList(); + } + this.ignoreUrlArgs.add(ignoreUrlArg); + return this; + } + + /** + * @return cacheUrlArgs + */ + public List getCacheUrlArgs() { + return cacheUrlArgs; + } + + /** + * @param cacheUrlArgs List of reserved parameters + */ + public void setCacheUrlArgs(List cacheUrlArgs) { + this.cacheUrlArgs = cacheUrlArgs; + } + + /** + * @param cacheUrlArgs List of reserved parameters + * @return returns this object + */ + public SetDomainCacheFullUrlRequest withCacheUrlArgs(List cacheUrlArgs) { + this.cacheUrlArgs = cacheUrlArgs; + return this; + } + + /** + * @param cacheUrlArg List of reserved parameter + * @return returns this object + */ + public SetDomainCacheFullUrlRequest addCacheUrlArgs(String cacheUrlArg) { + if (this.cacheUrlArgs == null) { + this.cacheUrlArgs = new ArrayList(); + } + this.cacheUrlArgs.add(cacheUrlArg); + return this; + } + + public Boolean getCacheFullUrl() { + return cacheFullUrl; + } + + public void setCacheFullUrl(Boolean cacheFullUrl) { + this.cacheFullUrl = cacheFullUrl; + } + + /** + * @param cacheFullUrl + * @return this object + */ + public SetDomainCacheFullUrlRequest withCacheFullUrl(boolean cacheFullUrl) { + this.cacheFullUrl = cacheFullUrl; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainCacheFullUrlRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public List getIgnoreUrlArgs() { + return ignoreUrlArgs; + } + + public void setIgnoreUrlArgs(List ignoreUrlArgs) { + this.ignoreUrlArgs = ignoreUrlArgs; + } +} + diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCacheShareRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCacheShareRequest.java new file mode 100644 index 00000000..3827531a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCacheShareRequest.java @@ -0,0 +1,44 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * cache share between domains + */ +public class SetDomainCacheShareRequest extends CdnRequest { + private String domain; + private CacheShare cacheShare; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainCacheShareRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public CacheShare getCacheShare() { + return cacheShare; + } + + public void setCacheShare(CacheShare cacheShare) { + this.cacheShare = cacheShare; + } + + + + public SetDomainCacheShareRequest withCacheShare(CacheShare cacheShare) { + setCacheShare(cacheShare); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCacheTTLRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCacheTTLRequest.java new file mode 100644 index 00000000..165eab42 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCacheTTLRequest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author yixing + * + */ +public class SetDomainCacheTTLRequest extends AbstractBceRequest { + private String domain; + private List cacheTTL; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainCacheTTLRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * @return cacheTTL + */ + public List getCacheTTL() { + return cacheTTL; + } + + /** + * @param cacheTTL + */ + public void setCacheTTL(List cacheTTL) { + this.cacheTTL = cacheTTL; + } + + /** + * @param cacheTTL + * @return returns this object + */ + public SetDomainCacheTTLRequest withCacheTTL(List cacheTTL) { + setCacheTTL(cacheTTL); + return this; + } + + /** + * @param rule + * @return returns this object + */ + public SetDomainCacheTTLRequest addCacheTTL(CacheTTL rule) { + if (cacheTTL == null) { + cacheTTL = new ArrayList(); + } + cacheTTL.add(rule); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public SetDomainCacheTTLRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainClientIpRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainClientIpRequest.java new file mode 100644 index 00000000..f5aac13a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainClientIpRequest.java @@ -0,0 +1,57 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/27 + */ +public class SetDomainClientIpRequest extends CdnRequest { + private String domain; + private ClientIp clientIp; + + /** + * @return clientIp + */ + public ClientIp getClientIp() { + return clientIp; + } + + /** + * @param clientIp Turn it ON or OFF and the IP type + */ + public void setClientIp(ClientIp clientIp) { + this.clientIp = clientIp; + } + + /** + * @param clientIp Turn it ON or OFF and the IP type + * @return this object + */ + public SetDomainClientIpRequest withClientIp(ClientIp clientIp) { + this.clientIp = clientIp; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainClientIpRequest withDomain(String domain) { + this.domain = domain; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCompressRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCompressRequest.java new file mode 100644 index 00000000..c0d37afe --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCompressRequest.java @@ -0,0 +1,57 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/28 + */ +public class SetDomainCompressRequest extends CdnRequest { + private String domain; + private Compress compress; + + /** + * @return compress + */ + public Compress getCompress() { + return compress; + } + + /** + * @param compress Detailed configuration of page compression + */ + public void setCompress(Compress compress) { + this.compress = compress; + } + + /** + * @param compress Detailed configuration of page compression + * @return this object + */ + public SetDomainCompressRequest withCompress(Compress compress) { + this.compress = compress; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainCompressRequest withDomain(String domain) { + this.domain = domain; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCorsRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCorsRequest.java new file mode 100644 index 00000000..6db9a911 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainCorsRequest.java @@ -0,0 +1,80 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +public class SetDomainCorsRequest extends AbstractBceRequest { + private String domain; + private Cors cors; + + /** + * @return cors + */ + public Cors getCors() { + return cors; + } + + /** + * @param cors the cors config of domain + */ + public void setCors(Cors cors) { + this.cors = cors; + } + + /** + * @param cors the cors config of domain + * @return this object + */ + public SetDomainCorsRequest withCors(Cors cors) { + this.cors = cors; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainCorsRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainErrorPageRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainErrorPageRequest.java new file mode 100644 index 00000000..da2ac5aa --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainErrorPageRequest.java @@ -0,0 +1,74 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cdn.model.CdnRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.ArrayList; +import java.util.List; + +public class SetDomainErrorPageRequest extends CdnRequest { + + private String domain; + private List errorPage; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainErrorPageRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * @return errorPage + */ + public List getErrorPage() { + return errorPage; + } + + /** + * @param errorPage error page info + */ + public void setErrorPage(List errorPage) { + this.errorPage = errorPage; + } + + /** + * @param errorPage error page list + * @return this object + */ + public SetDomainErrorPageRequest withErrorPage(List errorPage) { + setErrorPage(errorPage); + return this; + } + + /** + * @param page error page info + * @return this object + */ + public SetDomainErrorPageRequest addErrorPage(ErrorPage page) { + if (errorPage == null) { + errorPage = new ArrayList(); + } + errorPage.add(page); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainFileTrimRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainFileTrimRequest.java new file mode 100644 index 00000000..64134ec0 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainFileTrimRequest.java @@ -0,0 +1,57 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/28 + */ +public class SetDomainFileTrimRequest extends CdnRequest { + private String domain; + private boolean fileTrim; + + /** + * @return fileTrim + */ + public boolean isFileTrim() { + return fileTrim; + } + + /** + * @param fileTrim Whether to enable page optimization + * @return this object + */ + public SetDomainFileTrimRequest withFileTrim(boolean fileTrim) { + this.fileTrim = fileTrim; + return this; + } + + /** + * @param fileTrim Whether to enable page optimization + */ + public void setFileTrim(boolean fileTrim) { + this.fileTrim = fileTrim; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainFileTrimRequest withDomain(String domain) { + this.domain = domain; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainFollowProtocolRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainFollowProtocolRequest.java new file mode 100644 index 00000000..d5d76cc3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainFollowProtocolRequest.java @@ -0,0 +1,57 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/27 + */ +public class SetDomainFollowProtocolRequest extends CdnRequest { + private String domain; + private boolean followProtocol; + + /** + * @return followProtocol + */ + public boolean isFollowProtocol() { + return followProtocol; + } + + /** + * @param followProtocol Whether the back source protocol is consistent with the request protocol + */ + public void setFollowProtocol(boolean followProtocol) { + this.followProtocol = followProtocol; + } + + /** + * @param followProtocol Whether the back source protocol is consistent with the request protocol + * @return this object + */ + public SetDomainFollowProtocolRequest withFollowProtocol(boolean followProtocol) { + this.followProtocol = followProtocol; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainFollowProtocolRequest withDomain(String domain) { + this.domain = domain; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainHSTSRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainHSTSRequest.java new file mode 100644 index 00000000..08886217 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainHSTSRequest.java @@ -0,0 +1,47 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * HTTP Strict Transport Security + */ +public class SetDomainHSTSRequest extends CdnRequest { + private String domain; + private Hsts HSTS; + + public Hsts getHSTS() { + return HSTS; + } + + public void setHSTS(Hsts HSTS) { + this.HSTS = HSTS; + } + + public SetDomainHSTSRequest withHSTS(Hsts HSTS) { + setHSTS(HSTS); + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainHSTSRequest withDomain(String domain) { + this.domain = domain; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainHttpHeaderRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainHttpHeaderRequest.java new file mode 100644 index 00000000..20b02fb2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainHttpHeaderRequest.java @@ -0,0 +1,72 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +import java.util.ArrayList; +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class SetDomainHttpHeaderRequest extends CdnRequest { + private String domain; + private List httpHeader; + + /** + * @return httpHeader + */ + public List getHttpHeader() { + return httpHeader; + } + + /** + * @param httpHeader Set back source or respond to Header + */ + public void setHttpHeader(List httpHeader) { + this.httpHeader = httpHeader; + } + + /** + * @param httpHeader Set back source or respond to Header + * @return this object + */ + public SetDomainHttpHeaderRequest withHttpHeader(List httpHeader) { + this.httpHeader = httpHeader; + return this; + } + + /** + * @param header Set back source or respond to Header + * @return this object + */ + public SetDomainHttpHeaderRequest addHttpHeader(HttpHeader header) { + if (this.httpHeader == null) { + this.httpHeader = new ArrayList(); + } + this.httpHeader.add(header); + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainHttpHeaderRequest withDomain(String domain) { + this.domain = domain; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainIPv6DispatchRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainIPv6DispatchRequest.java new file mode 100644 index 00000000..5e35ccae --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainIPv6DispatchRequest.java @@ -0,0 +1,48 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * IPv6 + */ +public class SetDomainIPv6DispatchRequest extends CdnRequest { + private String domain; + private Enable ipv6Dispatch; + + public Enable getIpv6Dispatch() { + return ipv6Dispatch; + } + + public void setIpv6Dispatch(Enable ipv6Dispatch) { + this.ipv6Dispatch = ipv6Dispatch; + } + + public SetDomainIPv6DispatchRequest withIPv6Dispatch(Enable enable) { + setIpv6Dispatch(enable); + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainIPv6DispatchRequest withDomain(String domain) { + this.domain = domain; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatFlowRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainIpACLRequest.java similarity index 53% rename from src/main/java/com/baidubce/services/cdn/model/GetStatFlowRequest.java rename to src/main/java/com/baidubce/services/cdn/model/domain/SetDomainIpACLRequest.java index ba5cea9f..b32791fe 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetStatFlowRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainIpACLRequest.java @@ -11,81 +11,82 @@ * specific language governing permissions and limitations under the License. */ -package com.baidubce.services.cdn.model; +package com.baidubce.services.cdn.model.domain; -import java.util.Date; import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cdn.model.IpACL; import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; -public class GetStatFlowRequest extends AbstractBceRequest { - +/** + * @author yixing + * + */ +public class SetDomainIpACLRequest extends AbstractBceRequest { private String domain; + private IpACL ipACL; - private Date endTime; - private Date startTime; - private Integer period; - + /** + * @return domain + */ public String getDomain() { return domain; } + /** + * @param domain the domain name + */ public void setDomain(String domain) { this.domain = domain; } - - public GetStatFlowRequest withDomain(String domain) { + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainIpACLRequest withDomain(String domain) { setDomain(domain); return this; } - public void setEndTime(Date t) { - this.endTime = t; - } - - public Date getEndTime() { - return endTime; - } - - public void setStartTime(Date t) { - this.startTime = t; - } - - public Date getStartTime() { - return startTime; - } - - public GetStatFlowRequest withStartTime(Date startTime) { - this.setStartTime(startTime); - return this; - } - - public GetStatFlowRequest withEndTime(Date endTime) { - this.setEndTime(endTime); - System.out.println(this.endTime); - return this; - } - - public Integer getPeriod() { - return period; + /** + * @return returns this object + */ + public IpACL getIpACL() { + return ipACL; } - - public void setPeriod(int period) { - this.period = period; + + /** + * @param ipACL + */ + public void setIpACL(IpACL ipACL) { + this.ipACL = ipACL; } - public GetStatFlowRequest withPeriod(int period) { - this.setPeriod(period); + /** + * @param ipACL + * @return returns this object + */ + public SetDomainIpACLRequest withIpACL(IpACL ipACL) { + setIpACL(ipACL); return this; } - + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ @Override - public GetStatFlowRequest withRequestCredentials(BceCredentials credentials) { + public SetDomainIpACLRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } + /** + * (non-Javadoc) + * @see Object#toString() + */ @Override public String toString() { try { diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainLimitBandwidthRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainLimitBandwidthRequest.java new file mode 100644 index 00000000..90a4a387 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainLimitBandwidthRequest.java @@ -0,0 +1,46 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +public class SetDomainLimitBandwidthRequest extends CdnRequest { + private String domain; + private LimitBandwidth limitBandwidth; + + public SetDomainLimitBandwidthRequest() { + } + + public SetDomainLimitBandwidthRequest(String domain, LimitBandwidth limitBandwidth) { + this.domain = domain; + this.limitBandwidth = limitBandwidth; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainLimitBandwidthRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public LimitBandwidth getLimitBandwidth() { + return limitBandwidth; + } + + public void setLimitBandwidth(LimitBandwidth limitBandwidth) { + this.limitBandwidth = limitBandwidth; + } + + public SetDomainLimitBandwidthRequest withLimitBandwidth(LimitBandwidth limitBandwidth) { + this.limitBandwidth = limitBandwidth; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainMediaDragRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainMediaDragRequest.java new file mode 100644 index 00000000..aa654d77 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainMediaDragRequest.java @@ -0,0 +1,58 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/28 + */ +public class SetDomainMediaDragRequest extends CdnRequest { + private String domain; + private MediaDragConf mediaDragConf; + + /** + * @return mediaDragConf + */ + public MediaDragConf getMediaDragConf() { + return mediaDragConf; + } + + /** + * @param mediaDragConf Video drag settings + */ + public void setMediaDragConf(MediaDragConf mediaDragConf) { + this.mediaDragConf = mediaDragConf; + } + + /** + * @param mediaDragConf Video drag settings + * @return thi object + */ + public SetDomainMediaDragRequest withMediaDragConf(MediaDragConf mediaDragConf) { + this.mediaDragConf = mediaDragConf; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainMediaDragRequest withDomain(String domain) { + this.domain = domain; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainMobileAccessRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainMobileAccessRequest.java new file mode 100644 index 00000000..d7b47201 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainMobileAccessRequest.java @@ -0,0 +1,58 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/27 + */ +public class SetDomainMobileAccessRequest extends CdnRequest { + private String domain; + private MobileAccess mobileAccess; + + /** + * @return mobileAccess + */ + public MobileAccess getMobileAccess() { + return mobileAccess; + } + + /** + * @param mobileAccess Mobile access control + */ + public void setMobileAccess(MobileAccess mobileAccess) { + this.mobileAccess = mobileAccess; + } + + /** + * @param mobileAccess Mobile access control + * @return this object + */ + public SetDomainMobileAccessRequest withMobileAccess(MobileAccess mobileAccess) { + this.mobileAccess = mobileAccess; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainMobileAccessRequest withDomain(String domain) { + this.domain = domain; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOCSPRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOCSPRequest.java new file mode 100644 index 00000000..df0ee668 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOCSPRequest.java @@ -0,0 +1,48 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * Online Certificate Status Protocol + */ +public class SetDomainOCSPRequest extends CdnRequest { + + private String domain; + private boolean ocsp; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public boolean isOcsp() { + return ocsp; + } + + public void setOcsp(boolean ocsp) { + this.ocsp = ocsp; + } + + /** + * @param ocsp + * @return this object + */ + public SetDomainOCSPRequest withOcsp(boolean ocsp) { + setOcsp(ocsp); + return this; + } + + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainOCSPRequest withDomain(String domain) { + setDomain(domain); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOfflineModeRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOfflineModeRequest.java new file mode 100644 index 00000000..c4b25d01 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOfflineModeRequest.java @@ -0,0 +1,54 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * 离线模式指的是在资源过期回源的时候,如果源站异常,那么CDN会响应之前缓存的资源,响应客户端200,但是回源日志中还是显示5xx + */ +public class SetDomainOfflineModeRequest extends CdnRequest { + + private String domain; + + private boolean OfflineMode; + + public boolean isOfflineMode() { + return OfflineMode; + } + + public void setOfflineMode(boolean offlineMode) { + OfflineMode = offlineMode; + } + + /** + * @param Offline + * @return this object + */ + public SetDomainOfflineModeRequest withOfflineMode(boolean Offline) { + setOfflineMode(Offline); + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainOfflineModeRequest withDomain(String domain) { + this.domain = domain; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOriginFixedIspRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOriginFixedIspRequest.java new file mode 100644 index 00000000..d713f6d9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOriginFixedIspRequest.java @@ -0,0 +1,41 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +public class SetDomainOriginFixedIspRequest extends CdnRequest { + private String domain; + private Boolean originFixedISP; + + public SetDomainOriginFixedIspRequest() { + } + + public SetDomainOriginFixedIspRequest(Boolean originFixedISP) { + this.originFixedISP = originFixedISP; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public SetDomainOriginFixedIspRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public Boolean getOriginFixedISP() { + return originFixedISP; + } + + public void setOriginFixedISP(Boolean originFixedISP) { + this.originFixedISP = originFixedISP; + } + + public SetDomainOriginFixedIspRequest withOriginFixedISP(Boolean originFixedISP) { + this.setOriginFixedISP(originFixedISP); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOriginProtocolRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOriginProtocolRequest.java new file mode 100644 index 00000000..db970b4a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOriginProtocolRequest.java @@ -0,0 +1,53 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class SetDomainOriginProtocolRequest extends AbstractBceRequest { + + private String domain; + /** + * 必选 值为"https", "http" 或者 "*",分别代表https回源,http回源,以及协议跟随回源。设置https需要先开启https加速 + */ + private OriginProtocol originProtocol; + + public SetDomainOriginProtocolRequest() { + } + + public SetDomainOriginProtocolRequest(String domain, OriginProtocol originProtocol) { + this.domain = domain; + this.originProtocol = originProtocol; + } + + public SetDomainOriginProtocolRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public SetDomainOriginProtocolRequest withOriginProtocol(OriginProtocol originProtocol) { + this.originProtocol = originProtocol; + return this; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public OriginProtocol getOriginProtocol() { + return originProtocol; + } + + public void setOriginProtocol(OriginProtocol originProtocol) { + this.originProtocol = originProtocol; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOriginTimeoutRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOriginTimeoutRequest.java new file mode 100644 index 00000000..48bbc27e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainOriginTimeoutRequest.java @@ -0,0 +1,37 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +public class SetDomainOriginTimeoutRequest extends CdnRequest { + private String domain; + private OriginTimeout originTimeout; + + public SetDomainOriginTimeoutRequest() { + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public SetDomainOriginTimeoutRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public OriginTimeout getOriginTimeout() { + return originTimeout; + } + + public void setOriginTimeout(OriginTimeout originTimeout) { + this.originTimeout = originTimeout; + } + + public SetDomainOriginTimeoutRequest withOriginTimeout(OriginTimeout originTimeout) { + this.originTimeout = originTimeout; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainQUICRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainQUICRequest.java new file mode 100644 index 00000000..34990c74 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainQUICRequest.java @@ -0,0 +1,51 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * Quick UDP Internet Connection(QUIC) + */ +public class SetDomainQUICRequest extends CdnRequest { + private String domain; + private boolean quic; + + public boolean isQuic() { + return quic; + } + + public void setQuic(boolean quic) { + this.quic = quic; + } + + /** + * @param quic + * @return this object + */ + public SetDomainQUICRequest withQuic(boolean quic) { + setQuic(quic); + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainQUICRequest withDomain(String domain) { + this.domain = domain; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainRangeSwitchRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainRangeSwitchRequest.java new file mode 100644 index 00000000..2f61d4c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainRangeSwitchRequest.java @@ -0,0 +1,58 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/27 + */ +public class SetDomainRangeSwitchRequest extends CdnRequest { + private String domain; + private boolean rangeSwitch; + + /** + * @return rangeSwitch + */ + public boolean isRangeSwitch() { + return rangeSwitch; + } + + /** + * @param rangeSwitch Whether Range back to source + */ + public void setRangeSwitch(boolean rangeSwitch) { + this.rangeSwitch = rangeSwitch; + } + + /** + * @param rangeSwitch Whether Range back to source + * @return this object + */ + public SetDomainRangeSwitchRequest withRangeSwitch(boolean rangeSwitch) { + this.rangeSwitch = rangeSwitch; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainRangeSwitchRequest withDomain(String domain) { + this.domain = domain; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainRefererACLRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainRefererACLRequest.java new file mode 100644 index 00000000..0faa3cb1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainRefererACLRequest.java @@ -0,0 +1,98 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cdn.model.RefererACL; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * @author yixing + * + */ +public class SetDomainRefererACLRequest extends AbstractBceRequest { + private String domain; + private RefererACL refererACL; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainRefererACLRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return returns this object + */ + public RefererACL getRefererACL() { + return refererACL; + } + + /** + * @param refererACL + */ + public void setRefererACL(RefererACL refererACL) { + this.refererACL = refererACL; + } + + /** + * @param refererACL + * @return returns this object + */ + public SetDomainRefererACLRequest withRefererACL(RefererACL refererACL) { + setRefererACL(refererACL); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public SetDomainRefererACLRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * @see Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainRetryOriginRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainRetryOriginRequest.java new file mode 100644 index 00000000..036b568f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainRetryOriginRequest.java @@ -0,0 +1,41 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * create by songda on 20/12/01 + */ +public class SetDomainRetryOriginRequest extends CdnRequest { + @JsonInclude(JsonInclude.Include.NON_NULL) + private String domain; + @JsonInclude(JsonInclude.Include.ALWAYS) + private RetryOrigin retryOrigin; + + public RetryOrigin getRetryOrigin() { + return retryOrigin; + } + + public void setRetryOrigin(RetryOrigin retryOrigin) { + this.retryOrigin = retryOrigin; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public SetDomainRetryOriginRequest withRetryOrigin(RetryOrigin retryOrigin) { + setRetryOrigin(retryOrigin); + return this; + } + + public SetDomainRetryOriginRequest withDomain(String domain) { + setDomain(domain); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainSeoSwitchRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainSeoSwitchRequest.java new file mode 100644 index 00000000..6bb2d4b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainSeoSwitchRequest.java @@ -0,0 +1,57 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/28 + */ +public class SetDomainSeoSwitchRequest extends CdnRequest { + private String domain; + private SeoSwitch seoSwitch; + + /** + * @return seoSwitch + */ + public SeoSwitch getSeoSwitch() { + return seoSwitch; + } + + /** + * @param seoSwitch Set seo switch properties + */ + public void setSeoSwitch(SeoSwitch seoSwitch) { + this.seoSwitch = seoSwitch; + } + + /** + * @param seoSwitch Set seo switch properties + * @return this object + */ + public SetDomainSeoSwitchRequest withSeoSwitch(SeoSwitch seoSwitch) { + this.seoSwitch = seoSwitch; + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainSeoSwitchRequest withDomain(String domain) { + this.domain = domain; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainTrafficLimitRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainTrafficLimitRequest.java new file mode 100644 index 00000000..07c44119 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainTrafficLimitRequest.java @@ -0,0 +1,35 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class SetDomainTrafficLimitRequest extends AbstractBceRequest { + + private String domain; + + private TrafficLimit trafficLimit; + + public SetDomainTrafficLimitRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public SetDomainTrafficLimitRequest withTrafficLimit(TrafficLimit trafficLimit) { + this.trafficLimit = trafficLimit; + return this; + } + + public String getDomain() { + return domain; + } + + public TrafficLimit getTrafficLimit() { + return trafficLimit; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainUaAclRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainUaAclRequest.java new file mode 100644 index 00000000..5084b99f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainUaAclRequest.java @@ -0,0 +1,50 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class SetDomainUaAclRequest extends AbstractBceRequest { + + private String domain; + private UaAcl uaAcl; + + public SetDomainUaAclRequest() { + } + + public SetDomainUaAclRequest(String domain, UaAcl uaAcl) { + this.domain = domain; + this.uaAcl = uaAcl; + } + + public SetDomainUaAclRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public SetDomainUaAclRequest withUaAcl(UaAcl uaAcl) { + this.uaAcl = uaAcl; + return this; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public UaAcl getUaAcl() { + return uaAcl; + } + + public void setUaAcl(UaAcl uaAcl) { + this.uaAcl = uaAcl; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainUrlRulesRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainUrlRulesRequest.java new file mode 100644 index 00000000..a39a4568 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetDomainUrlRulesRequest.java @@ -0,0 +1,60 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.CdnRequest; + +import java.util.ArrayList; +import java.util.List; + +public class SetDomainUrlRulesRequest extends CdnRequest { + private String domain; + private List urlRules; + + + public SetDomainUrlRulesRequest() { + } + + public List getUrlRules() { + return urlRules; + } + + public void setUrlRules(List urlRules) { + this.urlRules = urlRules; + } + + public SetDomainUrlRulesRequest withUrlRules(List urlRules) { + this.urlRules = urlRules; + return this; + } + + public SetDomainUrlRulesRequest addUrlRule(UrlRule urlRule) { + if (this.urlRules == null) { + this.urlRules = new ArrayList(); + } + this.urlRules.add(urlRule); + return this; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainUrlRulesRequest withDomain(String domain) { + this.domain = domain; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/CreateDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/domain/SetRequestAuthRequest.java similarity index 59% rename from src/main/java/com/baidubce/services/cdn/model/CreateDomainRequest.java rename to src/main/java/com/baidubce/services/cdn/model/domain/SetRequestAuthRequest.java index da31ab63..6b088bdd 100644 --- a/src/main/java/com/baidubce/services/cdn/model/CreateDomainRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/domain/SetRequestAuthRequest.java @@ -11,21 +11,16 @@ * specific language governing permissions and limitations under the License. */ -package com.baidubce.services.cdn.model; +package com.baidubce.services.cdn.model.domain; import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; -import java.util.List; -/** - * Created by sunyixing on 16/1/9. - */ -public class CreateDomainRequest extends AbstractBceRequest { - - private List origin; +public class SetRequestAuthRequest extends AbstractBceRequest { private String domain; + private RequestAuth requestAuth; public String getDomain() { return domain; @@ -35,37 +30,26 @@ public void setDomain(String domain) { this.domain = domain; } - public CreateDomainRequest withDomain(String domain) { - this.domain = domain; - return this; - } - - public List getOrigin() { - return origin; - } - - public void setOrigin(List origin) { - this.origin = origin; + public RequestAuth getRequestAuth() { + return requestAuth; } - public CreateDomainRequest withOrigin(List origin) { - this.origin = origin; - return this; + public void setRequestAuth(RequestAuth requestAuth) { + this.requestAuth = requestAuth; } - public CreateDomainRequest addPeer(OriginPeer peer) { - origin.add(peer); + public SetRequestAuthRequest withDomain(String domain) { + setDomain(domain); return this; } - public CreateDomainRequest addPeer(String peer) { - OriginPeer op = new OriginPeer().withPeer(peer); - origin.add(op); + public SetRequestAuthRequest withRequestAuth(RequestAuth requestAuth) { + setRequestAuth(requestAuth); return this; } @Override - public CreateDomainRequest withRequestCredentials(BceCredentials credentials) { + public SetRequestAuthRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } @@ -78,5 +62,4 @@ public String toString() { return ""; } } - } diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/TrafficLimit.java b/src/main/java/com/baidubce/services/cdn/model/domain/TrafficLimit.java new file mode 100644 index 00000000..aca27581 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/TrafficLimit.java @@ -0,0 +1,113 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +import javax.validation.constraints.DecimalMax; +import javax.validation.constraints.DecimalMin; + +public class TrafficLimit extends JsonObject { + /** + * 必选 是否开启限速 + */ + private Boolean enable; + /** + * 必选 开启限速时必选,单位Byte/s + */ + private Integer limitRate; + /** + * 可选 限速开始时间,请输入0 - 24范围的数字,小于限速结束时间,默认值为 0 + */ + @DecimalMax(value = "24", message = "limitStartHour取值范围应该是[0,24]") + @DecimalMin(value = "0", message = "limitStartHour取值范围应该是[0,24]") + private Integer limitStartHour = 0; + /** + * 可选 限速结束时间,请输入0 - 24范围的数字,大于限速开始时间,默认值为 24 + */ + @DecimalMax(value = "24", message = "limitStartHour取值范围应该是[0,24]") + @DecimalMin(value = "0", message = "limitStartHour取值范围应该是[0,24]") + private Integer limitEndHour = 24; + /** + * 可选 在发送了多少数据之后限速,单位Byte + */ + private Integer limitRateAfter; + /** + * 可选 限速参数名称,根据url中提取的arg进行限速,如rate(优先级高于limitRate + */ + private String trafficLimitArg; + /** + * 可选 限速参数单位,支持m、k、g,默认为Byte + */ + private String trafficLimitUnit; + + public TrafficLimit() { + } + + public TrafficLimit(Boolean enable, Integer limitRate) { + this.enable = enable; + this.limitRate = limitRate; + } + + public TrafficLimit withEnable(Boolean enable) { + this.enable = enable; + return this; + } + + public TrafficLimit withLimitRate(Integer limitRate) { + this.limitRate = limitRate; + return this; + } + + public TrafficLimit withLimitStartHour(Integer limitStartHour) { + this.limitStartHour = limitStartHour; + return this; + } + + public TrafficLimit withLimitEndHour(Integer limitEndHour) { + this.limitEndHour = limitEndHour; + return this; + } + + public TrafficLimit withLimitRateAfter(Integer limitRateAfter) { + this.limitRateAfter = limitRateAfter; + return this; + } + + public TrafficLimit withTrafficLimitArg(String trafficLimitArg) { + this.trafficLimitArg = trafficLimitArg; + return this; + } + + public TrafficLimit withTrafficLimitUnit(String trafficLimitUnit) { + this.trafficLimitUnit = trafficLimitUnit; + return this; + } + + + public Boolean getEnable() { + return enable; + } + + public Integer getLimitRate() { + return limitRate; + } + + public Integer getLimitStartHour() { + return limitStartHour; + } + + public Integer getLimitEndHour() { + return limitEndHour; + } + + public Integer getLimitRateAfter() { + return limitRateAfter; + } + + public String getTrafficLimitArg() { + return trafficLimitArg; + } + + public String getTrafficLimitUnit() { + return trafficLimitUnit; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/UaAcl.java b/src/main/java/com/baidubce/services/cdn/model/domain/UaAcl.java new file mode 100644 index 00000000..78f4876d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/UaAcl.java @@ -0,0 +1,52 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +public class UaAcl extends JsonObject { + /** + * 可选 ua黑名单列表,单个ua长度限制为 1~200 字符 + */ + private List blackList; + /** + * 可选 ua白名单列表,单个ua长度限制为 1~200 字符 + */ + private List whiteList; + + public UaAcl() { + } + + public UaAcl addBlackList(String entry) { + if (blackList == null) { + blackList = new ArrayList(); + } + blackList.add(entry); + return this; + } + + public UaAcl addWhiteList(String entry) { + if (whiteList == null) { + whiteList = new ArrayList(); + } + whiteList.add(entry); + return this; + } + + public List getBlackList() { + return blackList; + } + + public void setBlackList(List blackList) { + this.blackList = blackList; + } + + public List getWhiteList() { + return whiteList; + } + + public void setWhiteList(List whiteList) { + this.whiteList = whiteList; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/UrlRule.java b/src/main/java/com/baidubce/services/cdn/model/domain/UrlRule.java new file mode 100644 index 00000000..cdb7338e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/UrlRule.java @@ -0,0 +1,75 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +public class UrlRule extends JsonObject { + + /** + * 字符串长度小于等于128。 + * 不含http(s)://头和域名。可以匹配参数,比如只改写带有特定参数的URI。支持正则以及捕获,比如(/[^?]+)\?c=1 + * 必选 + */ + private String action; + + /** + * 字符串长度小于等于128。 + * 不含http(s)://头和域名。最终生成的URI必须以/开头。支持捕获,比如${1}/test。 + * 目标URI里面如果没有?,则会带上原始参数。如果有?,则会用?后面的参数替换原始参数。 + * 比如访问URI为/a?c=1 + * • 待重写URI为/a,目标URI为/b,改写后URI为/b?c=1 + * • 待重写URI为/a,目标URI为/b?,改写后URI为/b + * • 待重写URI为/a,目标URI为/b?d=1,改写后URI为/b?d=1 + * 必选 + */ + private String src; + + /** + * 合法值为redirect或者rewrite。 + * redirect:若请求的URI匹配了当前规则,该请求将被302重定向跳转到目标URI。 + * break:若请求的URI匹配了当前规则,执行完当前规则后,将不再匹配剩余规则。 + * 必选 + */ + private String dst; + + public UrlRule() { + } + + public UrlRule withAction(String action) { + this.action = action; + return this; + } + + public UrlRule withSrc(String src) { + this.src = src; + return this; + } + + public UrlRule withDst(String dst) { + this.dst = dst; + return this; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getSrc() { + return src; + } + + public void setSrc(String src) { + this.src = src; + } + + public String getDst() { + return dst; + } + + public void setDst(String dst) { + this.dst = dst; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/domain/UserDomain.java b/src/main/java/com/baidubce/services/cdn/model/domain/UserDomain.java new file mode 100644 index 00000000..bce8b595 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/domain/UserDomain.java @@ -0,0 +1,39 @@ +package com.baidubce.services.cdn.model.domain; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/27 + */ +public class UserDomain extends JsonObject { + private String domain; + private String status; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @return status + */ + public String getStatus() { + return status; + } + + /** + * @param status domain's status + */ + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/dsa/DSA.java b/src/main/java/com/baidubce/services/cdn/model/dsa/DSA.java new file mode 100644 index 00000000..ee4b7c3c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/dsa/DSA.java @@ -0,0 +1,96 @@ +package com.baidubce.services.cdn.model.dsa; + +import com.baidubce.services.cdn.model.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class DSA extends JsonObject { + private List rules; + private boolean enabled; + private String comment; + + /** + * @return enabled + */ + public boolean isEnabled() { + return enabled; + } + + /** + * @param enabled + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + /** + * @param enabled + * @return this object + */ + public DSA withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * @return rules + */ + public List getRules() { + return rules; + } + + /** + * @param rules rule list + */ + public void setRules(List rules) { + this.rules = rules; + } + + /** + * @param rules rule list + * @return this object + */ + public DSA withRules(List rules) { + this.rules = rules; + return this; + } + + /** + * @param rule + * @return this object + */ + public DSA addRules(DSARule rule) { + if (this.rules == null) { + this.rules = new ArrayList(); + } + this.rules.add(rule); + return this; + } + + /** + * @return comment + */ + public String getComment() { + return comment; + } + + /** + * @param comment + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * @param comment + * @return this object + */ + public DSA withComment(String comment) { + this.comment = comment; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/dsa/DSADomain.java b/src/main/java/com/baidubce/services/cdn/model/dsa/DSADomain.java new file mode 100644 index 00000000..a9840dc5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/dsa/DSADomain.java @@ -0,0 +1,121 @@ +package com.baidubce.services.cdn.model.dsa; + +import com.baidubce.services.cdn.model.JsonObject; + +import java.util.ArrayList; +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class DSADomain extends JsonObject { + private String domain; + private List rules; + private String modifyTime; + private String comment; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public DSADomain withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * @return rules + */ + public List getRules() { + return rules; + } + + /** + * @param rules rule list + */ + public void setRules(List rules) { + this.rules = rules; + } + + /** + * @param rules rule list + * @return this object + */ + public DSADomain withRules(List rules) { + this.rules = rules; + return this; + } + + /** + * @param rule + * @return this object + */ + public DSADomain addRules(DSARule rule) { + if (this.rules == null) { + this.rules = new ArrayList(); + } + this.rules.add(rule); + return this; + } + + /** + * @return modifyTime + */ + public String getModifyTime() { + return modifyTime; + } + + /** + * @param modifyTime + */ + public void setModifyTime(String modifyTime) { + this.modifyTime = modifyTime; + } + + /** + * @param modifyTime + * @return this object + */ + public DSADomain withModifyTime(String modifyTime) { + this.modifyTime = modifyTime; + return this; + } + + + /** + * @return comment + */ + public String getComment() { + return comment; + } + + /** + * @param comment + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * @param comment + * @return this object + */ + public DSADomain withComment(String comment) { + this.comment = comment; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/dsa/DSARule.java b/src/main/java/com/baidubce/services/cdn/model/dsa/DSARule.java new file mode 100644 index 00000000..556c4888 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/dsa/DSARule.java @@ -0,0 +1,57 @@ +package com.baidubce.services.cdn.model.dsa; + +import com.baidubce.services.cdn.model.JsonObject; + +/** + * create by changxing01 on 19/8/28 + */ +public class DSARule extends JsonObject { + private String type; + private String value; + + /** + * @return type + */ + public String getType() { + return type; + } + + /** + * @param type rule type + */ + public void setType(String type) { + this.type = type; + } + + /** + * @param type rule type + * @return this object + */ + public DSARule withType(String type) { + this.type = type; + return this; + } + + /** + * @return value + */ + public String getValue() { + return value; + } + + /** + * @param value config rule + */ + public void setValue(String value) { + this.value = value; + } + + /** + * @param value config rule + * @return this object + */ + public DSARule withValue(String value) { + this.value = value; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/dsa/GetDsaDomainListResponse.java b/src/main/java/com/baidubce/services/cdn/model/dsa/GetDsaDomainListResponse.java new file mode 100644 index 00000000..1573f885 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/dsa/GetDsaDomainListResponse.java @@ -0,0 +1,48 @@ +package com.baidubce.services.cdn.model.dsa; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.ArrayList; +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetDsaDomainListResponse extends CdnResponse { + private List domains; + + /** + * @return domains + */ + public List getDomains() { + return domains; + } + + /** + * @param domains domain rule detail + */ + public void setDomains(List domains) { + this.domains = domains; + } + + /** + * @param domains domain rule detail list + * @return this object + */ + public GetDsaDomainListResponse withDomains(List domains) { + this.domains = domains; + return this; + } + + /** + * @param domain domain rule detail + * @return this object + */ + public GetDsaDomainListResponse addDomains(DSADomain domain) { + if (this.domains == null) { + this.domains = new ArrayList(); + } + this.domains.add(domain); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/dsa/SetDomainDsaRequest.java b/src/main/java/com/baidubce/services/cdn/model/dsa/SetDomainDsaRequest.java new file mode 100644 index 00000000..39e2164a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/dsa/SetDomainDsaRequest.java @@ -0,0 +1,57 @@ +package com.baidubce.services.cdn.model.dsa; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/28 + */ +public class SetDomainDsaRequest extends CdnRequest { + private String domain; + private DSA dsa; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainDsaRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * @return dsa + */ + public DSA getDsa() { + return dsa; + } + + /** + * @param dsa Configuration structure + */ + public void setDsa(DSA dsa) { + this.dsa = dsa; + } + + /** + * @param dsa Configuration structure + * @return this object + */ + public SetDomainDsaRequest withDsa(DSA dsa) { + this.dsa = dsa; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/dsa/SetDsaRequest.java b/src/main/java/com/baidubce/services/cdn/model/dsa/SetDsaRequest.java new file mode 100644 index 00000000..bcb5ee6f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/dsa/SetDsaRequest.java @@ -0,0 +1,36 @@ +package com.baidubce.services.cdn.model.dsa; + +import com.baidubce.services.cdn.model.CdnRequest; + +/** + * create by changxing01 on 19/8/28 + */ +public class SetDsaRequest extends CdnRequest { + /** + * "enable"为开通动态加速服务,"disable"为关闭 + */ + private String action; + + /** + * @return action + */ + public String getAction() { + return action; + } + + /** + * @param action + */ + public void setAction(String action) { + this.action = action; + } + + /** + * @param action + * @return this object + */ + public SetDsaRequest withAction(String action) { + this.action = action; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/handler/CdnJsonResponseHandler.java b/src/main/java/com/baidubce/services/cdn/model/handler/CdnJsonResponseHandler.java new file mode 100644 index 00000000..995dbedd --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/handler/CdnJsonResponseHandler.java @@ -0,0 +1,52 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cdn.model.handler; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cdn.model.DescribeIpsResponse; +import com.baidubce.services.cdn.model.util.IpDetail; +import com.baidubce.util.JsonUtils; +import org.apache.http.util.EntityUtils; + +import java.io.InputStream; +import java.util.List; + +/** + * HTTP body json response handler for Baidu BCE responses. + */ +public class CdnJsonResponseHandler implements HttpResponseHandler { + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + InputStream content = httpResponse.getContent(); + + if (content != null) { + if (response.getMetadata().getContentLength() > 0 + || "chunked".equalsIgnoreCase(response.getMetadata().getTransferEncoding())) { + try { + if (response.getClass().equals(DescribeIpsResponse.class)) { + String value = EntityUtils.toString(httpResponse.getHttpResponse().getEntity()); + List list = (List) JsonUtils.fromJsonString(value, List.class); + DescribeIpsResponse response1 = (DescribeIpsResponse) response; + response1.setIpInfo(list); + } + JsonUtils.load(content, response); + } catch (Exception e) {} + } + content.close(); + } + + return true; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/logmodel/GetDomainListLogRequest.java b/src/main/java/com/baidubce/services/cdn/model/logmodel/GetDomainListLogRequest.java new file mode 100644 index 00000000..89e16d6c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/logmodel/GetDomainListLogRequest.java @@ -0,0 +1,143 @@ +package com.baidubce.services.cdn.model.logmodel; + +import com.baidubce.services.cdn.model.CdnRequest; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetDomainListLogRequest extends CdnRequest { + private String startTime; + private String endTime; + private Long type; + private List domains; + private Integer pageNo; + private Integer pageSize; + + /** + * @param startTime + */ + public GetDomainListLogRequest withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + /** + * @param endTime + */ + public GetDomainListLogRequest withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + /** + * @return startTime + */ + public String getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + /** + * @return endTime + */ + public String getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + /** + * @return type + */ + public Long getType() { + return type; + } + + /** + * @param type logmodel type + */ + public void setType(Long type) { + this.type = type; + } + + public GetDomainListLogRequest withType(Long type) { + this.type = type; + return this; + } + + /** + * @return domains + */ + public List getDomains() { + return domains; + } + + /** + * @param domains domain list + */ + public void setDomains(List domains) { + this.domains = domains; + } + + /** + * @param domains domain list + * @return this object + */ + public GetDomainListLogRequest withDomains(List domains) { + this.domains = domains; + return this; + } + + /** + * @param domain domain name + * @return this object + */ + public GetDomainListLogRequest addDomains(String domain) { + if (this.domains == null) { + this.domains = new ArrayList(); + } + this.domains.add(domain); + return this; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public GetDomainListLogRequest withPageNo(Integer pageNo) { + this.pageNo = pageNo; + return this; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public GetDomainListLogRequest withPageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/logmodel/GetDomainListLogResponse.java b/src/main/java/com/baidubce/services/cdn/model/logmodel/GetDomainListLogResponse.java new file mode 100644 index 00000000..d93826dc --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/logmodel/GetDomainListLogResponse.java @@ -0,0 +1,71 @@ +package com.baidubce.services.cdn.model.logmodel; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetDomainListLogResponse extends CdnResponse { + private String startTime; + private String endTime; + private List urls; + private int totalCount; + + /** + * @return startTime + */ + public String getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + /** + * @return endTime + */ + public String getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + /** + * @return urls + */ + public List getUrls() { + return urls; + } + + /** + * @param urls logmodel url list + */ + public void setUrls(List urls) { + this.urls = urls; + } + + /** + * @return totalCount + */ + public int getTotalCount() { + return totalCount; + } + + /** + * @param totalCount url list count + */ + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/logmodel/GetDomainListLogTransRequest.java b/src/main/java/com/baidubce/services/cdn/model/logmodel/GetDomainListLogTransRequest.java new file mode 100644 index 00000000..03e80d8d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/logmodel/GetDomainListLogTransRequest.java @@ -0,0 +1,169 @@ +package com.baidubce.services.cdn.model.logmodel; + +import com.baidubce.services.cdn.model.CdnRequest; + +import java.util.ArrayList; +import java.util.List; + +/** + * create by changxing01 on 19/8/28 + */ +public class GetDomainListLogTransRequest extends CdnRequest { + private String startTime; + private String endTime; + private Long type; + private List domains; + private int pageNo; + private int pageSize; + + /** + * @return startTime + */ + public String getStartTime() { + return startTime; + } + + /** + * @param startTime + * @return this object + */ + public GetDomainListLogTransRequest withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + /** + * @param startTime + */ + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + /** + * @return endTime + */ + public String getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return this object + */ + public GetDomainListLogTransRequest withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + /** + * @return type + */ + public Long getType() { + return type; + } + + /** + * @param type logmodel type + */ + public void setType(Long type) { + this.type = type; + } + + /** + * @param type + * @return this object + */ + public GetDomainListLogTransRequest withType(Long type) { + this.type = type; + return this; + } + + /** + * @return domains + */ + public List getDomains() { + return domains; + } + + /** + * @param domains domain list + */ + public void setDomains(List domains) { + this.domains = domains; + } + + /** + * @param domains domain list + * @return this object + */ + public GetDomainListLogTransRequest withDomains(List domains) { + this.domains = domains; + return this; + } + + /** + * @param domain domain name + * @return this object + */ + public GetDomainListLogTransRequest addDomains(String domain) { + if (this.domains == null) { + this.domains = new ArrayList(); + } + this.domains.add(domain); + return this; + } + + + /** + * @return pageNo + */ + public int getPageNo() { + return pageNo; + } + + /** + * @param pageNo + */ + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + /** + * @param pageNo + * @return this object + */ + public GetDomainListLogTransRequest withPageNo(int pageNo) { + this.pageNo = pageNo; + return this; + } + + /** + * @return pageSize + */ + public int getPageSize() { + return pageSize; + } + + /** + * @param pageSize + */ + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + /** + * @param pageSize + * @return this object + */ + public GetDomainListLogTransRequest withPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/logmodel/LogEntry.java b/src/main/java/com/baidubce/services/cdn/model/logmodel/LogEntry.java new file mode 100644 index 00000000..ca6a40d8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/logmodel/LogEntry.java @@ -0,0 +1,134 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.logmodel; + +import com.baidubce.services.cdn.model.JsonObject; + +import java.util.Date; + +/** + * @author yixing + * + */ +public class LogEntry extends JsonObject { + private String domain; + private String url; + private String name; + private Long size; + private Date startTime; + private Date endTime; + + private Date logTimeBegin; + private Date logTimeEnd; + + /** + * @return url + */ + public String getUrl() { + return url; + } + /** + * @param url + */ + public void setUrl(String url) { + this.url = url; + } + /** + * @return name + */ + public String getName() { + return name; + } + /** + * @param name + */ + public void setName(String name) { + this.name = name; + } + /** + * @return size + */ + public Long getSize() { + return size; + } + /** + * @param size + */ + public void setSize(Long size) { + this.size = size; + } + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public LogEntry withDomain(String domain) { + this.domain = domain; + return this; + } + + public Date getLogTimeBegin() { + return logTimeBegin; + } + + public void setLogTimeBegin(Date logTimeBegin) { + this.logTimeBegin = logTimeBegin; + } + + public Date getLogTimeEnd() { + return logTimeEnd; + } + + public void setLogTimeEnd(Date logTimeEnd) { + this.logTimeEnd = logTimeEnd; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/AvgSpeedDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/AvgSpeedDetail.java new file mode 100644 index 00000000..02926f30 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/AvgSpeedDetail.java @@ -0,0 +1,16 @@ +package com.baidubce.services.cdn.model.stat; + +public class AvgSpeedDetail extends Detail { + private Long avgspeed; + + public AvgSpeedDetail() { + } + + public Long getAvgspeed() { + return avgspeed; + } + + public void setAvgspeed(Long avgspeed) { + this.avgspeed = avgspeed; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/AvgSpeedDistribution.java b/src/main/java/com/baidubce/services/cdn/model/stat/AvgSpeedDistribution.java new file mode 100644 index 00000000..48a0f664 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/AvgSpeedDistribution.java @@ -0,0 +1,17 @@ +package com.baidubce.services.cdn.model.stat; + +public class AvgSpeedDistribution extends DefaultDistribution { + + private Long avgspeed; + + public AvgSpeedDistribution() { + } + + public Long getAvgspeed() { + return avgspeed; + } + + public void setAvgspeed(Long avgspeed) { + this.avgspeed = avgspeed; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/AvgSpeedRegionDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/AvgSpeedRegionDetail.java new file mode 100644 index 00000000..e739b42a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/AvgSpeedRegionDetail.java @@ -0,0 +1,18 @@ +package com.baidubce.services.cdn.model.stat; + +import java.util.List; + +public class AvgSpeedRegionDetail extends Detail { + private List distribution; + + public AvgSpeedRegionDetail() { + } + + public List getDistribution() { + return distribution; + } + + public void setDistribution(List distribution) { + this.distribution = distribution; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/BillingDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/BillingDetail.java new file mode 100644 index 00000000..cc71bc29 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/BillingDetail.java @@ -0,0 +1,37 @@ +package com.baidubce.services.cdn.model.stat; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class BillingDetail { + + /** + * 95带宽值 + */ + @JsonProperty("bill_band") + private Long billBand; + + /** + * 该数据点的时间 + */ + @JsonProperty("bill_time") + private String billTime; + + public BillingDetail() { + } + + public Long getBillBand() { + return billBand; + } + + public void setBillBand(Long billBand) { + this.billBand = billBand; + } + + public String getBillTime() { + return billTime; + } + + public void setBillTime(String billTime) { + this.billTime = billTime; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/CounterDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/CounterDetail.java new file mode 100644 index 00000000..c55c3e37 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/CounterDetail.java @@ -0,0 +1,33 @@ +package com.baidubce.services.cdn.model.stat; + +public class CounterDetail { + + /** + * HTTP状态码 + */ + private Long name; + + /** + * 统计计数 + */ + private Long count; + + public CounterDetail() { + } + + public Long getName() { + return name; + } + + public void setName(Long name) { + this.name = name; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/DayInfo.java b/src/main/java/com/baidubce/services/cdn/model/stat/DayInfo.java new file mode 100644 index 00000000..943604d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/DayInfo.java @@ -0,0 +1,43 @@ +package com.baidubce.services.cdn.model.stat; + +public class DayInfo { + private String date; + private Long totalFlow; + private Long peakBandwidth; + private String peakBandwidthTime; + + public DayInfo() { + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public Long getTotalFlow() { + return totalFlow; + } + + public void setTotalFlow(Long totalFlow) { + this.totalFlow = totalFlow; + } + + public Long getPeakBandwidth() { + return peakBandwidth; + } + + public void setPeakBandwidth(Long peakBandwidth) { + this.peakBandwidth = peakBandwidth; + } + + public String getPeakBandwidthTime() { + return peakBandwidthTime; + } + + public void setPeakBandwidthTime(String peakBandwidthTime) { + this.peakBandwidthTime = peakBandwidthTime; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/DefaultDistribution.java b/src/main/java/com/baidubce/services/cdn/model/stat/DefaultDistribution.java new file mode 100644 index 00000000..75ff86d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/DefaultDistribution.java @@ -0,0 +1,33 @@ +package com.baidubce.services.cdn.model.stat; + +public class DefaultDistribution { + + /** + * 客户端所在省份、地区 + */ + private String location; + + /** + * 客户端所属运营商 + */ + private String isp; + + public DefaultDistribution() { + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/Detail.java b/src/main/java/com/baidubce/services/cdn/model/stat/Detail.java new file mode 100644 index 00000000..6c3ec113 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/Detail.java @@ -0,0 +1,25 @@ +package com.baidubce.services.cdn.model.stat; + +public class Detail { + private String timestamp; + private String key; + + public Detail() { + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/DistributionData.java b/src/main/java/com/baidubce/services/cdn/model/stat/DistributionData.java new file mode 100644 index 00000000..baa49182 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/DistributionData.java @@ -0,0 +1,104 @@ +package com.baidubce.services.cdn.model.stat; + +import java.util.List; + +public class DistributionData { + + /** + * 客户端所在省份、地区 + */ + private String location; + + /** + * 客户端所属运营商 + */ + private String isp; + + private Long avgspeed; + + private Long pv; + + private Long qps; + + /** + * 统计时间段内的传输字节数 + */ + private Long flow; + + /** + * 统计时间段内的平均bps + */ + private Long bps; + + /** + * HTTP状态码计数 + */ + private List counters; + + public DistributionData() { + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } + + public Long getAvgspeed() { + return avgspeed; + } + + public void setAvgspeed(Long avgspeed) { + this.avgspeed = avgspeed; + } + + public Long getPv() { + return pv; + } + + public void setPv(Long pv) { + this.pv = pv; + } + + public Long getQps() { + return qps; + } + + public void setQps(Long qps) { + this.qps = qps; + } + + public Long getFlow() { + return flow; + } + + public void setFlow(Long flow) { + this.flow = flow; + } + + public Long getBps() { + return bps; + } + + public void setBps(Long bps) { + this.bps = bps; + } + + public List getCounters() { + return counters; + } + + public void setCounters(List counters) { + this.counters = counters; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/ErrorCodeCounter.java b/src/main/java/com/baidubce/services/cdn/model/stat/ErrorCodeCounter.java new file mode 100644 index 00000000..776339ff --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/ErrorCodeCounter.java @@ -0,0 +1,30 @@ +package com.baidubce.services.cdn.model.stat; + +import java.util.List; + +public class ErrorCodeCounter { + /** + * 错误码 + */ + private Integer code; + private List counters; + + public ErrorCodeCounter() { + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public List getCounters() { + return counters; + } + + public void setCounters(List counters) { + this.counters = counters; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/ErrorCodeStatDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/ErrorCodeStatDetail.java new file mode 100644 index 00000000..fcb05b4b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/ErrorCodeStatDetail.java @@ -0,0 +1,40 @@ +package com.baidubce.services.cdn.model.stat; + +import java.util.List; + +public class ErrorCodeStatDetail { + + private String timestamp; + private String key; + /** + * 错误状态码类型及对应计数 + */ + private List counters; + + public ErrorCodeStatDetail() { + } + + public List getCounters() { + return counters; + } + + public void setCounters(List counters) { + this.counters = counters; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/ErrorCounterDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/ErrorCounterDetail.java new file mode 100644 index 00000000..14815ef4 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/ErrorCounterDetail.java @@ -0,0 +1,29 @@ +package com.baidubce.services.cdn.model.stat; + +public class ErrorCounterDetail { + /** + * 错误类型 + */ + private String name; + + /** + * 统计计数 + */ + private Long count; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetErrorCodeStatResponse.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetErrorCodeStatResponse.java new file mode 100644 index 00000000..694207ed --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetErrorCodeStatResponse.java @@ -0,0 +1,45 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.ArrayList; +import java.util.List; + +public class GetErrorCodeStatResponse extends CdnResponse { + + /** + * 正常返回的时候为"ok" + */ + private String status; + + private List details = new ArrayList(); + + private Long count; + + public GetErrorCodeStatResponse() { + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getDetails() { + return details; + } + + public void setDetails(List details) { + this.details = details; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetIpv6RegionStatResponse.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetIpv6RegionStatResponse.java new file mode 100644 index 00000000..296907ab --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetIpv6RegionStatResponse.java @@ -0,0 +1,30 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; +import java.util.Map; + +public class GetIpv6RegionStatResponse extends CdnResponse { + private Long count; + private Map>> details; + + public GetIpv6RegionStatResponse() { + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } + + public Map>> getDetails() { + return details; + } + + public void setDetails(Map>> details) { + this.details = details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetIpv6StatRequest.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetIpv6StatRequest.java new file mode 100644 index 00000000..41a54874 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetIpv6StatRequest.java @@ -0,0 +1,173 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnRequest; +import com.baidubce.services.cdn.model.GetStatMetricMapping; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; + +public class GetIpv6StatRequest extends CdnRequest { + + /** + * stat_type 表查询的数据类型, + * 值为为 http 时表查询的 http 数据; + * 值为 https 时表查询的 https 的数据; + * 值为 all 时表查询的包含http,https的总数据; + * 值为region时表示查询分省份-运营商的数据;默认查询all + */ + private String statType; + + /** + * 查询的时间范围结束值,默认为当前时间。时间跨度最长90天 UTC时间 + */ + private String startTime; + + /** + * 查询的时间范围起始值,默认为endTime前推24小时 UTC时间 + */ + private String endTime; + + /** + * 查询结果的粒度,单位秒,可选值为60,300,3600,86400; + * 默认为300,uv 默认3600( + * 选60s的时间粒度时建议startTime和endTime区间跨度建议选择0.5到1h,否则可能会因为数据量太大无法正常返回) + */ + private Integer period = 300; + + /** + * 名或用户Id或Tag + */ + private List keys; + + /** + * 客户端访问分布查询平均速率扩展 + * 查询的省份全拼,默认为空,查询全国数据。 + */ + private String prov; + + /** + * 客户端访问分布查询平均速率扩展 + * + * 查询的运营商代码,默认为空,查询所有运营商数据 + */ + private String isp; + + public GetIpv6StatRequest() { + } + + public GetIpv6StatRequest withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + public GetIpv6StatRequest withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + /** + * + * @param period + * @return + */ + public GetIpv6StatRequest withPeriod(Integer period) { + this.period = period; + return this; + } + + /** + * + * @return + */ + public GetIpv6StatRequest withKeys(List keys) { + this.keys = keys; + return this; + } + + /** + * + * @return + */ + public GetIpv6StatRequest withStatType(String statType) { + this.statType = statType; + return this; + } + + /** + * + * @param prov + * @return + */ + public GetIpv6StatRequest withProv(String prov) { + this.prov = GetStatMetricMapping.PROVINCE_MAP.inverse().get(prov); + this.prov = StringUtils.isEmpty(this.prov) ? prov : this.prov; + return this; + } + + /** + * + * @param isp + * @return + */ + public GetIpv6StatRequest withIsp(String isp) { + this.isp = GetStatMetricMapping.ISP_MAP.inverse().get(isp); + this.isp = StringUtils.isEmpty(this.isp) ? isp : this.isp; + return this; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public Integer getPeriod() { + return period; + } + + public void setPeriod(Integer period) { + this.period = period; + } + + public List getKeys() { + return keys; + } + + public void setKeys(List keys) { + this.keys = keys; + } + + public String getProv() { + return prov; + } + + public void setProv(String prov) { + this.prov = prov; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } + + public String getStatType() { + return statType; + } + + public void setStatType(String statType) { + this.statType = statType; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetIpv6StatResponse.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetIpv6StatResponse.java new file mode 100644 index 00000000..c90d23d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetIpv6StatResponse.java @@ -0,0 +1,29 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.Map; + +public class GetIpv6StatResponse extends CdnResponse { + private Long count; + private Map> details; + + public GetIpv6StatResponse() { + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } + + public Map> getDetails() { + return details; + } + + public void setDetails(Map> details) { + this.details = details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetMetricStatResponse.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetMetricStatResponse.java new file mode 100644 index 00000000..89d4a1f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetMetricStatResponse.java @@ -0,0 +1,45 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.ArrayList; +import java.util.List; + +public class GetMetricStatResponse extends CdnResponse { + + /** + * 正常返回的时候为"ok" + */ + private String status; + + private List details = new ArrayList(); + + private Long count; + + public GetMetricStatResponse() { + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getDetails() { + return details; + } + + public void setDetails(List details) { + this.details = details; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetMonth95Request.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetMonth95Request.java new file mode 100644 index 00000000..2b61d4b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetMonth95Request.java @@ -0,0 +1,141 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnRequest; + +public class GetMonth95Request extends CdnRequest { + + /** + * 为','分隔的域名或标签 + */ + private String domains; + + /** + * 值为peak95,表查询月95带宽数据 + * 必选 + */ + private String type = "peak95"; + + /** + * 表示查询对象为tag还是domain,默认按 domain 查询,当参数值为 true时表按 tag 查询 + * 可选 + */ + private Boolean withTag; + + /** + * 表示是否按整月查询,默认按整月查询,当参数值为true时表按输入时间查询 + * 可选 + */ + private Boolean byTime; + + /** + * 整月查询时的开始查询月份,格式形如"year-month"。默认值为本月 + * 可选 + */ + private String billingMonth; + + /** + * 开始时间,UTC格式。默认值为当前时间前24小时 + * 可选 + */ + private String startTime; + + /** + * 结束时间,UTC格式。默认值为当前时间 + * 可选 + */ + private String endTime; + + public GetMonth95Request() { + } + + public GetMonth95Request withDomains(String domains) { + this.domains = domains; + return this; + } + + public GetMonth95Request withType(String type) { + this.type = type; + return this; + } + + public GetMonth95Request withBillingMonth(String billingMonth) { + this.billingMonth = billingMonth; + return this; + } + + public GetMonth95Request withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + public GetMonth95Request withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + public GetMonth95Request withByTime(Boolean byTime) { + this.byTime = byTime; + return this; + } + + public GetMonth95Request withWithTag(Boolean withTag) { + this.withTag = withTag; + return this; + } + + public String getDomains() { + return domains; + } + + public void setDomains(String domains) { + this.domains = domains; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Boolean getWithTag() { + return withTag; + } + + public void setWithTag(Boolean withTag) { + this.withTag = withTag; + } + + public Boolean getByTime() { + return byTime; + } + + public void setByTime(Boolean byTime) { + this.byTime = byTime; + } + + public String getBillingMonth() { + return billingMonth; + } + + public void setBillingMonth(String billingMonth) { + this.billingMonth = billingMonth; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetMonth95Response.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetMonth95Response.java new file mode 100644 index 00000000..15767d72 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetMonth95Response.java @@ -0,0 +1,21 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class GetMonth95Response extends CdnResponse { + + @JsonProperty("billing_details") + private BillingDetail billingDetails; + + public GetMonth95Response() { + } + + public BillingDetail getBillingDetails() { + return billingDetails; + } + + public void setBillingDetails(BillingDetail billingDetails) { + this.billingDetails = billingDetails; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetPackageUsageListRequest.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetPackageUsageListRequest.java new file mode 100644 index 00000000..9a7f69bf --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetPackageUsageListRequest.java @@ -0,0 +1,70 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnRequest; + +public class GetPackageUsageListRequest extends CdnRequest { + + private int pageNo = 1; + + /** + * 最大支持3000 + */ + private int pageSize = 100; + + /** + * 使用中:RUNNING; 已创建:CREATED; 已过期:EXPIRED; 初始化,待创建:INITIAL; 已用完:USED_UP; 已销毁:DESTROYED; + */ + private String status; + + private String orderBy; + + private String order; + + public GetPackageUsageListRequest() { + } + + public GetPackageUsageListRequest(int pageNo, int pageSize) { + this.pageNo = pageNo; + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetPackageUsageListResponse.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetPackageUsageListResponse.java new file mode 100644 index 00000000..4f86a929 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetPackageUsageListResponse.java @@ -0,0 +1,73 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +public class GetPackageUsageListResponse extends CdnResponse { + private long totalCount; + + private int pageNo = 1; + + /** + * 最大支持3000 + */ + private int pageSize = 100; + + private String orderBy; + + private String order; + + private List result; + + public GetPackageUsageListResponse() { + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public long getTotalCount() { + return totalCount; + } + + public void setTotalCount(long totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetStatDefaultRequest.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetStatDefaultRequest.java new file mode 100644 index 00000000..90f5ae7c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetStatDefaultRequest.java @@ -0,0 +1,167 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.util.DateUtils; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class GetStatDefaultRequest { + /** + * 查询的时间范围结束值,默认为当前时间。时间跨度最长90天 UTC时间 + */ + private String startTime; + + /** + * 查询的时间范围起始值,默认为endTime前推24小时 UTC时间 + */ + private String endTime; + + /** + * 查询结果的粒度,单位秒,可选值为60,300,3600,86400; + * 默认为300,uv 默认3600( + * 选60s的时间粒度时建议startTime和endTime区间跨度建议选择0.5到1h,否则可能会因为数据量太大无法正常返回) + */ + private Integer period = 300; + + /** + * 标识key的内容,0=>域名,1=>用户id,2=>tag,默认0 + */ + @JsonProperty("key_type") + private Integer keyType = 0; + + /** + * 名或用户Id或Tag + */ + private List key; + + /** + * 返回结果聚合粒度,key => 根据key聚合, 空 => 返回整体结果 + */ + private String groupBy = "key"; + + public GetStatDefaultRequest() { + } + + /** + * + * @param startTime + * @return + */ + public GetStatDefaultRequest withStartTime(Date startTime) { + this.startTime = DateUtils.formatAlternateIso8601Date(startTime); + return this; + } + + /** + * + * @param endTime + * @return + */ + public GetStatDefaultRequest withEndTime(Date endTime) { + this.endTime = DateUtils.formatAlternateIso8601Date(endTime); + return this; + } + + /** + * + * @param period + * @return + */ + public GetStatDefaultRequest withPeriod(Integer period) { + this.period = period; + return this; + } + + /** + * + * @param keyType + * @return + */ + public GetStatDefaultRequest withKeyType(Integer keyType) { + this.keyType = keyType; + return this; + } + + /** + * + * @param key + * @return + */ + public GetStatDefaultRequest withKey(List key) { + this.key = key; + return this; + } + + /** + * + * @param key + * @return + */ + public GetStatDefaultRequest withKey(String key) { + if (null == this.key) { + this.key = new ArrayList(); + } + this.key.add(key); + return this; + } + + /** + * + * @param groupBy + * @return + */ + public GetStatDefaultRequest withGroupBy(String groupBy) { + this.groupBy = groupBy; + return this; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public Integer getPeriod() { + return period; + } + + public void setPeriod(Integer period) { + this.period = period; + } + + public Integer getKeyType() { + return keyType; + } + + public void setKeyType(Integer keyType) { + this.keyType = keyType; + } + + public List getKey() { + return key; + } + + public void setKey(List key) { + this.key = key; + } + + public String getGroupBy() { + return groupBy; + } + + public void setGroupBy(String groupBy) { + this.groupBy = groupBy; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetStatMetricRequest.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetStatMetricRequest.java new file mode 100644 index 00000000..223b03f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetStatMetricRequest.java @@ -0,0 +1,490 @@ +/* + * Copyright 2016-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnRequest; +import com.baidubce.services.cdn.model.GetStatMetricMapping; +import com.baidubce.util.DateUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.StringUtils; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * The params of metric query + * + */ +public class GetStatMetricRequest extends CdnRequest { + + /** + * 指定avg_speed,avg_speed_region,pv,pv_region等 + * 必选 + */ + private String metric; + + /** + * 查询的时间范围结束值,默认为当前时间。时间跨度最长90天 UTC时间 + */ + private String startTime; + + /** + * 查询的时间范围起始值,默认为endTime前推24小时 UTC时间 + */ + private String endTime; + + /** + * 查询结果的粒度,单位秒,可选值为60,300,3600,86400; + * 默认为300,uv 默认3600( + * 选60s的时间粒度时建议startTime和endTime区间跨度建议选择0.5到1h,否则可能会因为数据量太大无法正常返回) + */ + private Integer period = 300; + + /** + * 标识key的内容,0=>域名,1=>用户id,2=>tag,默认0 + */ + @JsonProperty("key_type") + private Integer keyType = 0; + + /** + * 名或用户Id或Tag + */ + private List key; + + /** + * 返回结果聚合粒度,key => 根据key聚合, 空 => 返回整体结果 + */ + private String groupBy = "key"; + + /** + * 客户端访问分布查询平均速率扩展 + * 查询的省份全拼,默认为空,查询全国数据。 + */ + private String prov; + + /** + * 客户端访问分布查询平均速率扩展 + * + * 查询的运营商代码,默认为空,查询所有运营商数据 + */ + private String isp; + + /** + * pv/qps查询扩展 + * 查询流量、带宽扩展 + * + * 查询边缘节点或者中心节点pv。可填写"all"或"edge"或者"internal",默认为“all” + */ + private String level; + + /** + * pv/qps https协议查询扩展 + * + * 查询全部pv。可填写"https"或"http"或者"all",默认为“all” + */ + private String protocol; + + /** + * 查询指定http状态码的记录,默认值: "" + */ + private Integer extra; + + /** + * 值为pv或者flow,指定按pv排序还是按flow排序,默认按pv排序 + */ + private String sortKey; + + /** + * + * @param metric + * @return + */ + public GetStatMetricRequest withMetric(String metric) { + this.metric = metric; + return this; + } + + /** + * + * @param sortKey + * @return + */ + public GetStatMetricRequest withSortKey(String sortKey) { + this.sortKey = sortKey; + return this; + } + + /** + * + * @param startTime + * @return + */ + public GetStatMetricRequest withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + /** + * + * @param startTime + * @return + */ + public GetStatMetricRequest withDateStartTime(Date startTime) { + this.startTime = DateUtils.formatAlternateIso8601Date(startTime); + return this; + } + + /** + * + * @param endTime + * @return + */ + public GetStatMetricRequest withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + /** + * + * @param endTime + * @return + */ + public GetStatMetricRequest withDateEndTime(Date endTime) { + this.endTime = DateUtils.formatAlternateIso8601Date(endTime); + return this; + } + + /** + * + * @param period + * @return + */ + public GetStatMetricRequest withPeriod(Integer period) { + this.period = period; + return this; + } + + /** + * + * @param keyType + * @return + */ + public GetStatMetricRequest withKeyType(Integer keyType) { + this.keyType = keyType; + return this; + } + + /** + * + * @param key + * @return + */ + public GetStatMetricRequest withKey(List key) { + this.key = key; + return this; + } + + /** + * + * @param key + * @return + */ + public GetStatMetricRequest withKey(String key) { + if (null == this.key) { + this.key = new ArrayList(); + } + this.key.add(key); + return this; + } + + /** + * + * @param groupBy + * @return + */ + public GetStatMetricRequest withGroupBy(String groupBy) { + this.groupBy = groupBy; + return this; + } + + /** + * + * @param prov + * @return + */ + public GetStatMetricRequest withProv(String prov) { + this.prov = GetStatMetricMapping.PROVINCE_MAP.inverse().get(prov); + this.prov = StringUtils.isEmpty(this.prov) ? prov : this.prov; + return this; + } + + /** + * + * @param isp + * @return + */ + public GetStatMetricRequest withIsp(String isp) { + this.isp = GetStatMetricMapping.ISP_MAP.inverse().get(isp); + this.isp = StringUtils.isEmpty(this.isp) ? isp : this.isp; + return this; + } + + /** + * + * @param level + * @return + */ + public GetStatMetricRequest withLevel(String level) { + this.level = level; + return this; + } + + /** + * + * @param protocol + * @return + */ + public GetStatMetricRequest withProtocol(String protocol) { + this.protocol = protocol; + return this; + } + + /** + * + * @param extra + * @return + */ + public GetStatMetricRequest withExtra(Integer extra) { + this.extra = extra; + return this; + } + + /** + * + * @return + */ + public String getMetric() { + return metric; + } + + /** + * + * @param metric + */ + public void setMetric(String metric) { + this.metric = metric; + } + + /** + * + * @return + */ + public String getStartTime() { + return startTime; + } + + /** + * + * @param startTime + */ + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + /** + * + * @return + */ + public String getEndTime() { + return endTime; + } + + /** + * + * @param endTime + */ + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + /** + * + * @return + */ + public Integer getPeriod() { + return period; + } + + /** + * + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * + * @return + */ + public Integer getKeyType() { + return keyType; + } + + /** + * + * @param keyType + */ + public void setKeyType(Integer keyType) { + this.keyType = keyType; + } + + /** + * + * @return + */ + public List getKey() { + return key; + } + + /** + * + * @param key + */ + public void setKey(List key) { + this.key = key; + } + + /** + * + * @return + */ + public String getGroupBy() { + return groupBy; + } + + /** + * + * @param groupBy + */ + public void setGroupBy(String groupBy) { + this.groupBy = groupBy; + } + + /** + * + * @return + */ + public String getProv() { + return prov; + } + + /** + * + * @param prov + */ + public void setProv(String prov) { + this.prov = prov; + } + + /** + * + * @return + */ + public String getIsp() { + return isp; + } + + /** + * + * @param isp + */ + public void setIsp(String isp) { + this.isp = isp; + } + + /** + * + * @return + */ + public String getLevel() { + return level; + } + + /** + * + * @param level + */ + public void setLevel(String level) { + this.level = level; + } + + /** + * + * @return + */ + public String getProtocol() { + return protocol; + } + + /** + * + * @param protocol + */ + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public Integer getExtra() { + return extra; + } + + public void setExtra(Integer extra) { + this.extra = extra; + } + + public String getSortKey() { + return sortKey; + } + + public void setSortKey(String sortKey) { + this.sortKey = sortKey; + } + + /** + * Parse this instance to map . When additional parameters need to be added + * + * @return + * @throws Exception + */ + public Map toMap() { + Map map = new HashMap(); + try { + Field[] declaredFields = this.getClass().getDeclaredFields(); + for (Field field : declaredFields) { + field.setAccessible(true); + map.put(field.getName(), field.get(this)); + } + return map; + } catch (Exception e) { + e.printStackTrace(); + } + return map; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetStatMetricResponse.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetStatMetricResponse.java new file mode 100644 index 00000000..9909fd3c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetStatMetricResponse.java @@ -0,0 +1,68 @@ +/* + * Copyright 2016-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * The result of metric query + * + */ +public class GetStatMetricResponse extends CdnResponse { + + private static final long serialVersionUID = 1L; + + private String status; + + /** + * + */ + private List> details = new ArrayList>(); + + private Long count; + + /** + * @param details + */ + public void setDetails(List> details) { + this.details = details; + } + + /** + * @return details + */ + public List> getDetails() { + return details; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetStatProvIspRequest.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetStatProvIspRequest.java new file mode 100644 index 00000000..d38bc465 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetStatProvIspRequest.java @@ -0,0 +1,60 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.GetStatMetricMapping; +import org.apache.commons.lang3.StringUtils; + +public class GetStatProvIspRequest extends GetStatDefaultRequest { + /** + * 客户端访问分布查询平均速率扩展 + * 查询的省份全拼,默认为空,查询全国数据。 + */ + private String prov; + + /** + * 客户端访问分布查询平均速率扩展 + * + * 查询的运营商代码,默认为空,查询所有运营商数据 + */ + private String isp; + + public GetStatProvIspRequest() { + } + + public String getProv() { + return prov; + } + + public void setProv(String prov) { + this.prov = prov; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } + + /** + * + * @param prov + * @return + */ + public GetStatProvIspRequest withProv(String prov) { + this.prov = GetStatMetricMapping.PROVINCE_MAP.inverse().get(prov); + this.prov = StringUtils.isEmpty(this.prov) ? prov : this.prov; + return this; + } + + /** + * + * @param isp + * @return + */ + public GetStatProvIspRequest withIsp(String isp) { + this.isp = GetStatMetricMapping.ISP_MAP.inverse().get(isp); + this.isp = StringUtils.isEmpty(this.isp) ? isp : this.isp; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetTopStatResponse.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetTopStatResponse.java new file mode 100644 index 00000000..ade4f5f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetTopStatResponse.java @@ -0,0 +1,44 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.ArrayList; +import java.util.List; + +public class GetTopStatResponse extends CdnResponse { + /** + * 正常返回的时候为"ok" + */ + private String status; + + private List details = new ArrayList(); + + private Long count; + + public GetTopStatResponse() { + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getDetails() { + return details; + } + + public void setDetails(List details) { + this.details = details; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetUploadStatRequest.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetUploadStatRequest.java new file mode 100644 index 00000000..68c738b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetUploadStatRequest.java @@ -0,0 +1,143 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnRequest; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class GetUploadStatRequest extends CdnRequest { + private String type; + + private String startTime; + private String endTime; + + /** + * 查询结果的粒度,单位秒,可选值为60,300,3600,86400; + * 默认为300,uv 默认3600( + * 选60s的时间粒度时建议startTime和endTime区间跨度建议选择0.5到1h,否则可能会因为数据量太大无法正常返回) + */ + private Integer period = 300; + + private List domains; + + private String level; + + /** + * 指定查询流量or带宽数据,true时查询带宽数据,false时查询流量数据,默认值为false + */ + @JsonProperty("isBandwidth") + private Boolean isBandwidth = false; + + /** + * dataType参数指定查询的数据类型, + * "all"表示总数据(dsa+static),"dsa"表示动态数据,"static"表示静态数据。默认值为 "all" + */ + private String dataType = "all"; + + public GetUploadStatRequest() { + } + + public GetUploadStatRequest withType(String type) { + this.type = type; + return this; + } + + public GetUploadStatRequest withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + public GetUploadStatRequest withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + public GetUploadStatRequest withDataType(String dataType) { + this.dataType = dataType; + return this; + } + + public GetUploadStatRequest withLevel(String level) { + this.level = level; + return this; + } + + public GetUploadStatRequest withDomains(List domains) { + this.domains = domains; + return this; + } + + public GetUploadStatRequest withBandwidth(Boolean bandwidth) { + isBandwidth = bandwidth; + return this; + } + + public GetUploadStatRequest withPeriod(Integer period) { + this.period = period; + return this; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public Integer getPeriod() { + return period; + } + + public void setPeriod(Integer period) { + this.period = period; + } + + public List getDomains() { + return domains; + } + + public void setDomains(List domains) { + this.domains = domains; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public Boolean getBandwidth() { + return isBandwidth; + } + + public void setBandwidth(Boolean bandwidth) { + isBandwidth = bandwidth; + } + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetUploadStatResponse.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetUploadStatResponse.java new file mode 100644 index 00000000..767d1e3c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetUploadStatResponse.java @@ -0,0 +1,32 @@ +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.ArrayList; +import java.util.List; + +public class GetUploadStatResponse extends CdnResponse { + + private List details = new ArrayList(); + + private Long count; + + public GetUploadStatResponse() { + } + + public List getDetails() { + return details; + } + + public void setDetails(List details) { + this.details = details; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetXcdnStatMetricRequest.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetXcdnStatMetricRequest.java new file mode 100644 index 00000000..67bc89c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetXcdnStatMetricRequest.java @@ -0,0 +1,292 @@ +/* + * Copyright 2016-2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cdn.model.stat; + +import com.baidubce.services.cdn.model.CdnRequest; +import com.baidubce.util.DateUtils; + +import java.lang.reflect.Field; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.ArrayList; + +/** + * The params of metric query + * + */ +public class GetXcdnStatMetricRequest extends CdnRequest { + + /** + * 指定avg_speed,avg_speed_region,pv,pv_region等 + * 必选 + */ + private String metric; + + /** + * 查询的时间范围结束值,默认为当前时间。时间跨度最长90天 UTC时间 + */ + private String startTime; + + /** + * 查询的时间范围起始值,默认为endTime前推24小时 UTC时间 + */ + private String endTime; + + /** + * 查询结果的粒度,单位秒,可选值为60,300,3600,86400; + * 默认为300,uv 默认3600( + * 选60s的时间粒度时建议startTime和endTime区间跨度建议选择0.5到1h,否则可能会因为数据量太大无法正常返回) + */ + private Integer period = 300; + + /** + * 标识key的内容,0=>域名,1=>用户id,2=>tag,默认0 + */ + private Integer keyType = 0; + + /** + * 名或用户Id或Tag + */ + private List keys; + + private Boolean groupByKey; + + private String productType; + + /** + * + * @param metric + * @return + */ + public GetXcdnStatMetricRequest withMetric(String metric) { + this.metric = metric; + return this; + } + + public GetXcdnStatMetricRequest withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + /** + * + * @param startTime + * @return + */ + public GetXcdnStatMetricRequest withStartTime(Date startTime) { + this.startTime = DateUtils.formatAlternateIso8601Date(startTime); + return this; + } + + /** + * + * @param endTime + * @return + */ + public GetXcdnStatMetricRequest withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + /** + * + * @param endTime + * @return + */ + public GetXcdnStatMetricRequest withEndTime(Date endTime) { + this.endTime = DateUtils.formatAlternateIso8601Date(endTime); + return this; + } + + /** + * + * @param period + * @return + */ + public GetXcdnStatMetricRequest withPeriod(Integer period) { + this.period = period; + return this; + } + + /** + * + * @param keyType + * @return + */ + public GetXcdnStatMetricRequest withKeyType(Integer keyType) { + this.keyType = keyType; + return this; + } + + /** + * + * @param keys + * @return + */ + public GetXcdnStatMetricRequest withKeys(List keys) { + this.keys = keys; + return this; + } + + /** + * + * @param keys + * @return + */ + public GetXcdnStatMetricRequest withKeys(String keys) { + if (null == this.keys) { + this.keys = new ArrayList(); + } + this.keys.add(keys); + return this; + } + + /** + * + * @param groupByKey + * @return + */ + public GetXcdnStatMetricRequest withGroupByKey(Boolean groupByKey) { + this.groupByKey = groupByKey; + return this; + } + + /** + * + * @return + */ + public String getMetric() { + return metric; + } + + /** + * + * @param metric + */ + public void setMetric(String metric) { + this.metric = metric; + } + + /** + * + * @return + */ + public String getStartTime() { + return startTime; + } + + /** + * + * @param startTime + */ + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + /** + * + * @return + */ + public String getEndTime() { + return endTime; + } + + /** + * + * @param endTime + */ + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + /** + * + * @return + */ + public Integer getPeriod() { + return period; + } + + /** + * + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * + * @return + */ + public Integer getKeyType() { + return keyType; + } + + /** + * + * @param keyType + */ + public void setKeyType(Integer keyType) { + this.keyType = keyType; + } + + public List getKeys() { + return keys; + } + + public void setKeys(List keys) { + this.keys = keys; + } + + public Boolean getGroupByKey() { + return groupByKey; + } + + public void setGroupByKey(Boolean groupByKey) { + this.groupByKey = groupByKey; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + this.productType = productType; + } + + /** + * Parse this instance to map . When additional parameters need to be added + * + * @return + * @throws Exception + */ + public Map toMap() { + Map map = new HashMap(); + try { + Field[] declaredFields = this.getClass().getDeclaredFields(); + for (Field field : declaredFields) { + field.setAccessible(true); + map.put(field.getName(), field.get(this)); + } + return map; + } catch (Exception e) { + e.printStackTrace(); + } + return map; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/GetXcdnStatMetricResponse.java b/src/main/java/com/baidubce/services/cdn/model/stat/GetXcdnStatMetricResponse.java new file mode 100644 index 00000000..67fb6681 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/GetXcdnStatMetricResponse.java @@ -0,0 +1,62 @@ +package com.baidubce.services.cdn.model.stat; + + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.ArrayList; +import java.util.List; + +public class GetXcdnStatMetricResponse extends CdnResponse { + private String status; + + private List details = new ArrayList(); + + private Long count; + + private Summary summary; + + private DayInfo days; + + public GetXcdnStatMetricResponse() { + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getDetails() { + return details; + } + + public void setDetails(List details) { + this.details = details; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } + + public Summary getSummary() { + return summary; + } + + public void setSummary(Summary summary) { + this.summary = summary; + } + + public DayInfo getDays() { + return days; + } + + public void setDays(DayInfo days) { + this.days = days; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/Ipv6Data.java b/src/main/java/com/baidubce/services/cdn/model/stat/Ipv6Data.java new file mode 100644 index 00000000..81728c8d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/Ipv6Data.java @@ -0,0 +1,52 @@ +package com.baidubce.services.cdn.model.stat; + +import java.util.Map; + +public class Ipv6Data { + private Long flow; + private Long bps; + private Long pv; + + private Map code; + private Map distribution; + + public Long getFlow() { + return flow; + } + + public void setFlow(Long flow) { + this.flow = flow; + } + + public Long getBps() { + return bps; + } + + public void setBps(Long bps) { + this.bps = bps; + } + + public Long getPv() { + return pv; + } + + public void setPv(Long pv) { + this.pv = pv; + } + + public Map getCode() { + return code; + } + + public void setCode(Map code) { + this.code = code; + } + + public Map getDistribution() { + return distribution; + } + + public void setDistribution(Map distribution) { + this.distribution = distribution; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/PackageDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/PackageDetail.java new file mode 100644 index 00000000..57cbf45b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/PackageDetail.java @@ -0,0 +1,85 @@ +package com.baidubce.services.cdn.model.stat; + +public class PackageDetail { + + /** + * 总容量 + */ + private Long capacity; + + /** + * 已用量 + */ + private Long usedCapacity; + + /** + * 状态 参考入参 + */ + private String status; + + /** + * 包类型 如流量包 + */ + private String packageType; + + /** + * 生效时间,UTC时间 + */ + private String activeTime; + + /** + * 到期时间,UTC时间 + */ + private String expireTime; + + public PackageDetail() { + } + + public Long getCapacity() { + return capacity; + } + + public void setCapacity(Long capacity) { + this.capacity = capacity; + } + + public Long getUsedCapacity() { + return usedCapacity; + } + + public void setUsedCapacity(Long usedCapacity) { + this.usedCapacity = usedCapacity; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPackageType() { + return packageType; + } + + public void setPackageType(String packageType) { + this.packageType = packageType; + } + + public String getActiveTime() { + return activeTime; + } + + public void setActiveTime(String activeTime) { + this.activeTime = activeTime; + } + + public String getExpireTime() { + return expireTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/StatDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/StatDetail.java new file mode 100644 index 00000000..9779905a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/StatDetail.java @@ -0,0 +1,152 @@ +package com.baidubce.services.cdn.model.stat; + +import java.util.List; + +public class StatDetail { + + /** + * 时间点 UTC时间 + */ + private String timestamp; + + /** + * 聚合粒度(groupBy):key => key,其他 => total + */ + private String key; + + /** + * 客户端访问分布数据 + */ + private List distribution; + + /** + * HTTP状态码计数 + */ + private List counters; + + /** + * 统计时间段内的平均速率 + */ + private Long avgspeed; + + /** + * 请求量 + */ + private Long pv; + + /** + * 平均qps + */ + private Long qps; + + /** + * 统计时间段内的请求量 + */ + private Long uv; + + /** + * 统计时间段内的传输字节数 + */ + private Long flow; + + /** + * 统计时间段内的平均bps + */ + private Long bps; + + /** + * 统计时间段内的字节命中率 + */ + private Double hitrate; + + public StatDetail() { + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public List getDistribution() { + return distribution; + } + + public void setDistribution(List distribution) { + this.distribution = distribution; + } + + public Long getAvgspeed() { + return avgspeed; + } + + public void setAvgspeed(Long avgspeed) { + this.avgspeed = avgspeed; + } + + public Long getPv() { + return pv; + } + + public void setPv(Long pv) { + this.pv = pv; + } + + public Long getQps() { + return qps; + } + + public void setQps(Long qps) { + this.qps = qps; + } + + public Long getUv() { + return uv; + } + + public void setUv(Long uv) { + this.uv = uv; + } + + public Long getFlow() { + return flow; + } + + public void setFlow(Long flow) { + this.flow = flow; + } + + public Long getBps() { + return bps; + } + + public void setBps(Long bps) { + this.bps = bps; + } + + public Double getHitrate() { + return hitrate; + } + + public void setHitrate(Double hitrate) { + this.hitrate = hitrate; + } + + public List getCounters() { + return counters; + } + + public void setCounters(List counters) { + this.counters = counters; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/Summary.java b/src/main/java/com/baidubce/services/cdn/model/stat/Summary.java new file mode 100644 index 00000000..e7aa05cd --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/Summary.java @@ -0,0 +1,32 @@ +package com.baidubce.services.cdn.model.stat; + +public class Summary { + /** + * 请求时段的总流量 + */ + private Long totalFlow; + + /** + * 请求时段的峰值带宽 + */ + private Long peakBandwidth; + + public Summary() { + } + + public Long getTotalFlow() { + return totalFlow; + } + + public void setTotalFlow(Long totalFlow) { + this.totalFlow = totalFlow; + } + + public Long getPeakBandwidth() { + return peakBandwidth; + } + + public void setPeakBandwidth(Long peakBandwidth) { + this.peakBandwidth = peakBandwidth; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/TopNDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/TopNDetail.java new file mode 100644 index 00000000..8c3e13b9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/TopNDetail.java @@ -0,0 +1,60 @@ +package com.baidubce.services.cdn.model.stat; + +public class TopNDetail { + private String name; + private Long pv; + private Long flow; + + /** + * 文件大小 单位byte + */ + private Long filesize; + + /** + * 文件类型 url资源后缀 + */ + private String filetype; + + public TopNDetail() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getPv() { + return pv; + } + + public void setPv(Long pv) { + this.pv = pv; + } + + public Long getFlow() { + return flow; + } + + public void setFlow(Long flow) { + this.flow = flow; + } + + public Long getFilesize() { + return filesize; + } + + public void setFilesize(Long filesize) { + this.filesize = filesize; + } + + public String getFiletype() { + return filetype; + } + + public void setFiletype(String filetype) { + this.filetype = filetype; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/TopStatDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/TopStatDetail.java new file mode 100644 index 00000000..d43f132e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/TopStatDetail.java @@ -0,0 +1,71 @@ +package com.baidubce.services.cdn.model.stat; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class TopStatDetail { + /** + * 时间点 UTC时间 + */ + private String timestamp; + + /** + * 聚合粒度(groupBy):key => key,其他 => total + */ + private String key; + + /** + * HTTP状态码计数 + */ + private List counters; + + @JsonProperty("total_pv") + private Long totalPv; + + @JsonProperty("total_flow") + private Long totalFlow; + + public TopStatDetail() { + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public List getCounters() { + return counters; + } + + public void setCounters(List counters) { + this.counters = counters; + } + + public Long getTotalPv() { + return totalPv; + } + + public void setTotalPv(Long totalPv) { + this.totalPv = totalPv; + } + + public Long getTotalFlow() { + return totalFlow; + } + + public void setTotalFlow(Long totalFlow) { + this.totalFlow = totalFlow; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/UploadDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/UploadDetail.java new file mode 100644 index 00000000..7e94d999 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/UploadDetail.java @@ -0,0 +1,43 @@ +package com.baidubce.services.cdn.model.stat; + +public class UploadDetail { + private String time; + private Long flow; + private Long bps; + private Long pv; + + public UploadDetail() { + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public Long getFlow() { + return flow; + } + + public void setFlow(Long flow) { + this.flow = flow; + } + + public Long getBps() { + return bps; + } + + public void setBps(Long bps) { + this.bps = bps; + } + + public Long getPv() { + return pv; + } + + public void setPv(Long pv) { + this.pv = pv; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/stat/XcdnDetail.java b/src/main/java/com/baidubce/services/cdn/model/stat/XcdnDetail.java new file mode 100644 index 00000000..f3c1962c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/stat/XcdnDetail.java @@ -0,0 +1,58 @@ +package com.baidubce.services.cdn.model.stat; + +public class XcdnDetail { + /** + * 时间点 UTC时间 + */ + private String timestamp; + + /** + * 聚合粒度(groupBy):key => key,其他 => total + */ + private String key; + + /** + * 统计时间段内的传输字节数 + */ + private Long flow; + + /** + * 统计时间段内的平均bps + */ + private Long bps; + + public XcdnDetail() { + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Long getFlow() { + return flow; + } + + public void setFlow(Long flow) { + this.flow = flow; + } + + public Long getBps() { + return bps; + } + + public void setBps(Long bps) { + this.bps = bps; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenOperateHistoriesRequest.java b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenOperateHistoriesRequest.java new file mode 100644 index 00000000..1c91eedc --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenOperateHistoriesRequest.java @@ -0,0 +1,46 @@ +package com.baidubce.services.cdn.model.util; + + +public class GetForbiddenOperateHistoriesRequest extends GetForbiddenUrlsRequest { + + /** + * 指定时间范围查询,开始时间,距当前时间点不能超过90天,北京时间 + * 可选 + */ + private String startTime; + + /** + * 指定时间范围查询,截止时间,不能大于当前时间,北京时间 + * 可选 + */ + private String endTime; + + public GetForbiddenOperateHistoriesRequest() { + } + + public GetForbiddenOperateHistoriesRequest withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + public GetForbiddenOperateHistoriesRequest withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenOperateHistoriesResponse.java b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenOperateHistoriesResponse.java new file mode 100644 index 00000000..2060aac1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenOperateHistoriesResponse.java @@ -0,0 +1,29 @@ +package com.baidubce.services.cdn.model.util; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +public class GetForbiddenOperateHistoriesResponse extends CdnResponse { + private long count; + private List urlHistories; + + public GetForbiddenOperateHistoriesResponse() { + } + + public long getCount() { + return count; + } + + public void setCount(long count) { + this.count = count; + } + + public List getUrlHistories() { + return urlHistories; + } + + public void setUrlHistories(List urlHistories) { + this.urlHistories = urlHistories; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenQuota.java b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenQuota.java new file mode 100644 index 00000000..2b1df4c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenQuota.java @@ -0,0 +1,35 @@ +package com.baidubce.services.cdn.model.util; + +import com.baidubce.services.cdn.model.CdnResponse; + +public class GetForbiddenQuota extends CdnResponse { + + /** + * url封禁总容量 + */ + private Long quota; + + /** + * 当前封禁的url数目 + */ + private Long count; + + public GetForbiddenQuota() { + } + + public Long getQuota() { + return quota; + } + + public void setQuota(Long quota) { + this.quota = quota; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenUrlsRequest.java b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenUrlsRequest.java new file mode 100644 index 00000000..34d5073f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenUrlsRequest.java @@ -0,0 +1,82 @@ +package com.baidubce.services.cdn.model.util; + +import com.baidubce.services.cdn.model.CdnRequest; + +public class GetForbiddenUrlsRequest extends CdnRequest { + + /** + * 分页查询页面大小,默认值为10,最大不超过100 + */ + private int pageSize = 10; + private int pageNo = 1; + + /** + * 值为desc或asc,指定时间倒序输出还是时间顺序输出。默认为desc,时序倒序输出。设置为asc时按时序顺序输出 + */ + private String orderBy = "desc"; + + /** + * url path不能超过1024字符 + * 可选 + */ + private String url; + + public GetForbiddenUrlsRequest() { + } + + public GetForbiddenUrlsRequest(String url) { + this.url = url; + } + + public GetForbiddenUrlsRequest withPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + public GetForbiddenUrlsRequest withPageNo(int pageNo) { + this.pageNo = pageNo; + return this; + } + + public GetForbiddenUrlsRequest withUrl(String url) { + this.url = url; + return this; + } + + public GetForbiddenUrlsRequest withOrderBy(String orderBy) { + this.orderBy = orderBy; + return this; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenUrlsResponse.java b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenUrlsResponse.java new file mode 100644 index 00000000..2ff216c8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/GetForbiddenUrlsResponse.java @@ -0,0 +1,29 @@ +package com.baidubce.services.cdn.model.util; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +public class GetForbiddenUrlsResponse extends CdnResponse { + private long count; + private List urlRecords; + + public GetForbiddenUrlsResponse() { + } + + public long getCount() { + return count; + } + + public void setCount(long count) { + this.count = count; + } + + public List getUrlRecords() { + return urlRecords; + } + + public void setUrlRecords(List urlRecords) { + this.urlRecords = urlRecords; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/GetNodeListResponse.java b/src/main/java/com/baidubce/services/cdn/model/util/GetNodeListResponse.java new file mode 100644 index 00000000..99e91abd --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/GetNodeListResponse.java @@ -0,0 +1,29 @@ +package com.baidubce.services.cdn.model.util; + +import com.baidubce.services.cdn.model.CdnResponse; + +import java.util.List; + +public class GetNodeListResponse extends CdnResponse { + private int status; + private List details; + + public GetNodeListResponse() { + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public List getDetails() { + return details; + } + + public void setDetails(List details) { + this.details = details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/IpDetail.java b/src/main/java/com/baidubce/services/cdn/model/util/IpDetail.java new file mode 100644 index 00000000..7194ae94 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/IpDetail.java @@ -0,0 +1,43 @@ +package com.baidubce.services.cdn.model.util; + +public class IpDetail { + private String ip; + private String isp; + private String region; + private Boolean cdnIP; + + public IpDetail() { + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public Boolean getCdnIP() { + return cdnIP; + } + + public void setCdnIP(Boolean cdnIP) { + this.cdnIP = cdnIP; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/NodeDetail.java b/src/main/java/com/baidubce/services/cdn/model/util/NodeDetail.java new file mode 100644 index 00000000..bd6b8a5b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/NodeDetail.java @@ -0,0 +1,61 @@ +package com.baidubce.services.cdn.model.util; + +public class NodeDetail { + private String cnname; + private String ip; + private String level; + private String province; + private String isp; + private String city; + + public NodeDetail() { + } + + public String getCnname() { + return cnname; + } + + public void setCnname(String cnname) { + this.cnname = cnname; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/SetForbiddenUrlsRequest.java b/src/main/java/com/baidubce/services/cdn/model/util/SetForbiddenUrlsRequest.java new file mode 100644 index 00000000..77d33c3c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/SetForbiddenUrlsRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.cdn.model.util; + +import com.baidubce.services.cdn.model.CdnRequest; + +import java.util.List; + +public class SetForbiddenUrlsRequest extends CdnRequest { + private List urls; + + public SetForbiddenUrlsRequest() { + } + + public List getUrls() { + return urls; + } + + public SetForbiddenUrlsRequest withUrls(List urls) { + this.urls = urls; + return this; + } + + public void setUrls(List urls) { + this.urls = urls; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/TestListInterface.java b/src/main/java/com/baidubce/services/cdn/model/util/TestListInterface.java new file mode 100644 index 00000000..5a705bf3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/TestListInterface.java @@ -0,0 +1,6 @@ +package com.baidubce.services.cdn.model.util; + +import java.util.ArrayList; + +public abstract class TestListInterface extends ArrayList { +} diff --git a/src/main/java/com/baidubce/services/cdn/model/util/TimeFormatUtil.java b/src/main/java/com/baidubce/services/cdn/model/util/TimeFormatUtil.java new file mode 100644 index 00000000..f1ca1d61 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/TimeFormatUtil.java @@ -0,0 +1,76 @@ +package com.baidubce.services.cdn.model.util; + +import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TimeFormatUtil { + + private static final Logger LOG = LoggerFactory.getLogger(TimeFormatUtil.class); + private static final String FORMAT = "yyyy-MM-dd'T'HH:mm:SS'Z'"; + + /** + * convert timestamp to time + * @param timestamp + * @param format + * @param isSecond + * @return result + */ + public static String formatToStr(long timestamp, String format, boolean isSecond) { + long ts = 0; + if (isSecond) { + ts = timestamp * 1000; + } else { + ts = timestamp; + } + DateTime dateTime = new DateTime(ts); + String result = null; + try { + format = format == null ? FORMAT : format; + result = dateTime.toString(format); + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + return result; + } + + /** + * convert time to timestamp + * @param timeStr + * @param format + * @param isSecond + * @return result + */ + public static long formatToTs(String timeStr, String format, boolean isSecond) { + long ret = 0; + DateTimeFormatter formatter = DateTimeFormat.forPattern(format); + DateTime dt = DateTime.parse(timeStr, formatter); + long ts = dt.getMillis(); + + if (isSecond) { + ret = ts / 1000; + } else { + ret = ts; + } + + return ret; + } + + public static String formatTimeStr(String timeStr, String inputFormat, + String outputFormat) { + DateTimeFormatter formatter = DateTimeFormat.forPattern(inputFormat); + DateTime dt = DateTime.parse(timeStr, formatter); + long ts = dt.getMillis(); + + DateTime dateTime = new DateTime(ts); + String result = null; + try { + result = dateTime.toString(outputFormat); + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + return result; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cdn/model/util/UrlRecord.java b/src/main/java/com/baidubce/services/cdn/model/util/UrlRecord.java new file mode 100644 index 00000000..c5ae5e9d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/util/UrlRecord.java @@ -0,0 +1,39 @@ +package com.baidubce.services.cdn.model.util; + +public class UrlRecord { + private String url; + private String time; + + /** + * 执行的操作,1表ban操作,0表unban操作 + * 查询url封禁操作记录用到 + */ + private int action; + + public UrlRecord() { + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public int getAction() { + return action; + } + + public void setAction(int action) { + this.action = action; + } +} diff --git a/src/main/java/com/baidubce/services/cert/CertClient.java b/src/main/java/com/baidubce/services/cert/CertClient.java new file mode 100644 index 00000000..b18470dd --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/CertClient.java @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2018 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cert.model.CertCreateRequest; +import com.baidubce.services.cert.model.CertCreateResponse; +import com.baidubce.services.cert.model.CertListResponse; +import com.baidubce.services.cert.model.CertRequest; +import com.baidubce.services.cert.model.CertResponse; +import com.baidubce.services.cert.model.CertUpdateNameRequest; +import com.baidubce.services.cert.model.CertificateMeta; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +/** + * Client for cert public api. + */ +public class CertClient extends AbstractBceClient { + + private static final String CERT_BASE_URL = "/certificate"; + + private static final String VERSION = "/v1"; + + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date", "x-bce-console-rpc-id"}; + + private static final HttpResponseHandler[] handlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + private boolean internal; + + private String accessKey; + + private String secretKey; + + protected CertClient(String accessKey, String secretKey, BceClientConfiguration bceClientConfiguration, + boolean internal) { + super(bceClientConfiguration, handlers); + this.accessKey = accessKey; + this.secretKey = secretKey; + this.internal = internal; + } + + public static CertClient createCertClient(String accessKey, String secretKey, String endpoint) { + BceClientConfiguration bceClientConfiguration = new BceClientConfiguration().withEndpoint(endpoint) + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)); + return new CertClient(accessKey, secretKey, bceClientConfiguration, false); + } + + public CertCreateResponse createCert(CertCreateRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CERT_BASE_URL); + attachRequestToBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, CertCreateResponse.class); + + } + + public CertListResponse listUserCerts() { + CertRequest request = new CertRequest(); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CERT_BASE_URL); + return this.invokeHttpClient(internalRequest, CertListResponse.class); + + } + + public CertificateMeta getCertInfo(String certId) { + CertRequest request = new CertRequest(); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CERT_BASE_URL, certId); + return this.invokeHttpClient(internalRequest, CertificateMeta.class); + } + + public void updateCertName(String certId, String certName) { + CertUpdateNameRequest request = new CertUpdateNameRequest(certName); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + CERT_BASE_URL, certId); + attachRequestToBody(request, internalRequest); + internalRequest.addParameter("certName", ""); + this.invokeHttpClient(internalRequest, CertResponse.class); + } + + public void delete(String certId) { + CertRequest request = new CertRequest(); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, CERT_BASE_URL, certId); + this.invokeHttpClient(internalRequest, CertResponse.class); + } + + public void replaceCertData(String certId, CertCreateRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, CERT_BASE_URL, certId); + attachRequestToBody(request, internalRequest); + internalRequest.addParameter("certData", ""); + this.invokeHttpClient(internalRequest, CertResponse.class); + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest( + AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + + return request; + } + + /** + * put json object into http content for put or post request. + * + * @param request json object of rest request + * @param httpRequest http request object + */ + private void attachRequestToBody(AbstractBceRequest request, InternalRequest httpRequest) { + byte[] content; + try { + content = JsonUtils.toJsonString(request).getBytes("utf-8"); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("utf-8 encoding not supported!", e); + } + httpRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(content.length)); + httpRequest.addHeader(Headers.CONTENT_TYPE, "application/json; charset=utf-8"); + httpRequest.setContent(RestartableInputStream.wrap(content)); + } +} diff --git a/src/main/java/com/baidubce/services/cert/model/CertConstant.java b/src/main/java/com/baidubce/services/cert/model/CertConstant.java new file mode 100644 index 00000000..798db05e --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/model/CertConstant.java @@ -0,0 +1,8 @@ +/* + * Copyright (C) 2018 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert.model; + +public class CertConstant { + public static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; +} diff --git a/src/main/java/com/baidubce/services/cert/model/CertCreateRequest.java b/src/main/java/com/baidubce/services/cert/model/CertCreateRequest.java new file mode 100644 index 00000000..3a42ead0 --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/model/CertCreateRequest.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2018 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert.model; + +import java.util.Date; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + + +/** + * Certificate creation request. + * + */ + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CertCreateRequest extends AbstractBceRequest { + + private String certName; + + private String certServerData; + + private String certPrivateData; + + private String certLinkData; + + private String uploadPublicKey; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = CertConstant.DATETIME_FORMAT, timezone = "UTC") + private Date createTime; + + public String getCertName() { + return certName; + } + + public void setCertName(String certName) { + this.certName = certName; + } + + public String getCertServerData() { + return certServerData; + } + + public void setCertServerData(String certServerData) { + this.certServerData = certServerData; + } + + public String getCertPrivateData() { + return certPrivateData; + } + + public void setCertPrivateData(String certPrivateData) { + this.certPrivateData = certPrivateData; + } + + public String getCertLinkData() { + return certLinkData; + } + + public void setCertLinkData(String certLinkData) { + this.certLinkData = certLinkData; + } + + public String getUploadPublicKey() { + return uploadPublicKey; + } + + public void setUploadPublicKey(String uploadPublicKey) { + this.uploadPublicKey = uploadPublicKey; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cert/model/CertCreateResponse.java b/src/main/java/com/baidubce/services/cert/model/CertCreateResponse.java new file mode 100644 index 00000000..a9b9a222 --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/model/CertCreateResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + + +/** + * Certificate creation response. + * + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CertCreateResponse extends AbstractBceResponse { + + private String certId; + + private String certName; + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } + + public String getCertName() { + return certName; + } + + public void setCertName(String certName) { + this.certName = certName; + } + +} diff --git a/src/main/java/com/baidubce/services/cert/model/CertListRequest.java b/src/main/java/com/baidubce/services/cert/model/CertListRequest.java new file mode 100644 index 00000000..3d5863b4 --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/model/CertListRequest.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2018 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@Deprecated +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CertListRequest extends AbstractBceRequest { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cert/model/CertListResponse.java b/src/main/java/com/baidubce/services/cert/model/CertListResponse.java new file mode 100644 index 00000000..6dd76a23 --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/model/CertListResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * Json response model of listing certs. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CertListResponse extends AbstractBceResponse { + + private List certs; + + public List getCerts() { + return certs; + } + + public void setCerts(List certs) { + this.certs = certs; + } +} diff --git a/src/main/java/com/baidubce/services/cert/model/CertRequest.java b/src/main/java/com/baidubce/services/cert/model/CertRequest.java new file mode 100644 index 00000000..e41d4a23 --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/model/CertRequest.java @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CertRequest extends AbstractBceRequest { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cert/model/CertResponse.java b/src/main/java/com/baidubce/services/cert/model/CertResponse.java new file mode 100644 index 00000000..7c691a60 --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/model/CertResponse.java @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * Cert commmon response + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CertResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/cert/model/CertUpdateNameRequest.java b/src/main/java/com/baidubce/services/cert/model/CertUpdateNameRequest.java new file mode 100644 index 00000000..793868ec --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/model/CertUpdateNameRequest.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * Json request model of updating cert name. + */ + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CertUpdateNameRequest extends AbstractBceRequest { + + private String certName; + + public CertUpdateNameRequest(String certName) { + this.certName = certName; + } + + public String getCertName() { + return certName; + } + + public void setCertName(String certName) { + this.certName = certName; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cert/model/CertificateMeta.java b/src/main/java/com/baidubce/services/cert/model/CertificateMeta.java new file mode 100644 index 00000000..c64942c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/cert/model/CertificateMeta.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2018 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cert.model; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * CertificateMeta json model. + */ +public class CertificateMeta extends AbstractBceResponse { + + private String certId; + + private String certName; + + private String certCommonName; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = CertConstant.DATETIME_FORMAT, timezone = "UTC") + private Date certStartTime; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = CertConstant.DATETIME_FORMAT, timezone = "UTC") + private Date certStopTime; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = CertConstant.DATETIME_FORMAT, timezone = "UTC") + private Date certCreateTime; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = CertConstant.DATETIME_FORMAT, timezone = "UTC") + private Date certUpdateTime; + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } + + public String getCertName() { + return certName; + } + + public void setCertName(String certName) { + this.certName = certName; + } + + public String getCertCommonName() { + return certCommonName; + } + + public void setCertCommonName(String certCommonName) { + this.certCommonName = certCommonName; + } + + public Date getCertStartTime() { + return certStartTime; + } + + public void setCertStartTime(Date certStartTime) { + this.certStartTime = certStartTime; + } + + public Date getCertStopTime() { + return certStopTime; + } + + public void setCertStopTime(Date certStopTime) { + this.certStopTime = certStopTime; + } + + public Date getCertCreateTime() { + return certCreateTime; + } + + public void setCertCreateTime(Date certCreateTime) { + this.certCreateTime = certCreateTime; + } + + public Date getCertUpdateTime() { + return certUpdateTime; + } + + public void setCertUpdateTime(Date certUpdateTime) { + this.certUpdateTime = certUpdateTime; + } +} diff --git a/src/main/java/com/baidubce/services/cfc/CfcClient.java b/src/main/java/com/baidubce/services/cfc/CfcClient.java new file mode 100644 index 00000000..3cf13200 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/CfcClient.java @@ -0,0 +1,848 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.Map; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.HashSet; + +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.Headers; +import com.baidubce.services.cfc.model.CreateFunctionRequest; +import com.baidubce.services.cfc.model.CreateFunctionResponse; +import com.baidubce.services.cfc.model.ListFunctionsRequest; +import com.baidubce.services.cfc.model.ListFunctionsResponse; +import com.baidubce.services.cfc.model.GetFunctionRequest; +import com.baidubce.services.cfc.model.GetFunctionResponse; +import com.baidubce.services.cfc.model.DeleteFunctionRequest; +import com.baidubce.services.cfc.model.DeleteFunctionResponse; +import com.baidubce.services.cfc.model.UpdateFunctionCodeRequest; +import com.baidubce.services.cfc.model.UpdateFunctionCodeResponse; +import com.baidubce.services.cfc.model.GetFunctionConfigurationResponse; +import com.baidubce.services.cfc.model.GetFunctionConfigurationRequest; +import com.baidubce.services.cfc.model.UpdateFunctionConfigurationRequest; +import com.baidubce.services.cfc.model.UpdateFunctionConfigurationResponse; +import com.baidubce.services.cfc.model.ListVersionsByFunctionRequest; +import com.baidubce.services.cfc.model.ListVersionsByFunctionResponse; +import com.baidubce.services.cfc.model.PublishVersionRequest; +import com.baidubce.services.cfc.model.PublishVersionResponse; +import com.baidubce.services.cfc.model.ListAliasesRequest; +import com.baidubce.services.cfc.model.ListAliasesResponse; +import com.baidubce.services.cfc.model.CreateAliasRequest; +import com.baidubce.services.cfc.model.CreateAliasResponse; +import com.baidubce.services.cfc.model.GetAliasResponse; +import com.baidubce.services.cfc.model.GetAliasRequest; +import com.baidubce.services.cfc.model.UpdateAliasResponse; +import com.baidubce.services.cfc.model.UpdateAliasRequest; +import com.baidubce.services.cfc.model.DeleteAliasResponse; +import com.baidubce.services.cfc.model.DeleteAliasRequest; +import com.baidubce.services.cfc.model.CreateTriggerResponse; +import com.baidubce.services.cfc.model.CreateTriggerRequest; +import com.baidubce.services.cfc.model.ListTriggersResponse; +import com.baidubce.services.cfc.model.ListTriggersRequest; +import com.baidubce.services.cfc.model.UpdateTriggerResponse; +import com.baidubce.services.cfc.model.UpdateTriggerRequest; +import com.baidubce.services.cfc.model.DeleteTriggerRequest; +import com.baidubce.services.cfc.model.DeleteTriggerResponse; +import com.baidubce.services.cfc.model.InvokeResponse; +import com.baidubce.services.cfc.model.InvokeRequest; +import com.baidubce.services.cfc.model.GetInvokeResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import static com.baidubce.util.Validate.checkNotNull; + +/** + * Provides the client for accessing the Cloud Function Compute Service. + */ +public class CfcClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(CfcClient.class); + + /** + * The default version for CFC service calls. + */ + private static final String VERSION = "v1"; + + /** + * The path param for CFC service calls. + */ + private static final String FUNCTIONS = "functions"; + + /** + * The path param for CFC service calls. + */ + private static final String CODE = "code"; + + /** + * The path param for CFC service calls. + */ + private static final String CONFIGURATION = "configuration"; + + /** + * The path param for CFC service calls. + */ + private static final String VERSIONS = "versions"; + + /** + * The path param for CFC service calls. + */ + private static final String ALIASES = "aliases"; + + /** + * The path param for CFC service calls. + */ + private static final String RELATION = "relation"; + + /** + * The path param for CFC service calls. + */ + private static final String INVOCATIONS = "invocations"; + + /** + * Error message + */ + private static final String ERRORMSG = "The request should not be null."; + + /** + * encoding type + */ + private static final String ENCODINGTYPE = "utf-8"; + + /** + * encoding type error + */ + private static final String ENCODINGERR = "utf-8 encoding not supported"; + + /** + * content type + */ + private static final String CONTENTTYPE = "application/json; charset=utf-8"; + + /** + * The default host to sign for CFC service calls. + */ + private static final String[] HEADERS_TO_SIGN = {"host"}; + + /** + * The default invoke max timeout for creating new connections. + */ + private static final int INVOKE_CONNECTION_TIMEOUT_IN_MILLIS = 310 * 1000; + + /** + * The default invoke max timeout for reading from a connected socket. + */ + private static final int INVOKE_SOCKET_TIMEOUT_IN_MILLIS = 310 * 1000; + + /** + * Responsible for handling httpResponses from all CFC service calls. + */ + private static HttpResponseHandler[] cfcHandlers = new HttpResponseHandler[]{ + new BceErrorResponseHandler(), + new BceMetadataResponseHandler(), + new CfcResponseHandler(), + new BceJsonResponseHandler(), + }; + + /** + * Constructs a new client to invoke service methods on CFC + */ + public CfcClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new client using the client configuration to access CFC services. + * + * @param clientConfiguration The client configuration options controlling how this client + * connects to Document services (e.g. proxy settings, retry counts, etc). + */ + public CfcClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, cfcHandlers); + } + + /** + * Create a new function + * + * @param request The request containing user-defined function information + * @return Result of the createFunction operation returned by the service + */ + public CreateFunctionResponse createFunction(CreateFunctionRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, FUNCTIONS); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CreateFunctionResponse.class); + } + + /** + * Get user function list + * + * @param functionVersion (Optional) Specify the version of the function. If no function returns the $LATEST + * version of the function, the optional valid value ALL will return all versions, including + * $LATEST + * @param marker (Optional) marker + * @param maxItems (Optional) 1-10000 + * @return + */ + public ListFunctionsResponse listFunctions(String functionVersion, Integer marker, Integer maxItems) { + ListFunctionsRequest request = new ListFunctionsRequest() + .withFunctionVersion(functionVersion) + .withMarker(marker) + .withMaxItems(maxItems); + return this.listFunctions(request); + } + + /** + * Get user function list + * + * @param request + * @return User function list + */ + public ListFunctionsResponse listFunctions(ListFunctionsRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, FUNCTIONS); + if (request.getFunctionVersion() != null) { + internalRequest.addParameter("FunctionVersion", request.getFunctionVersion()); + } + if (request.getMarker() != null) { + internalRequest.addParameter("Marker", String.valueOf(request.getMarker())); + } + if (request.getMaxItems() != null) { + internalRequest.addParameter("MaxItems", String.valueOf(request.getMaxItems())); + } + return invokeHttpClient(internalRequest, ListFunctionsResponse.class); + } + + /** + * Get function information + * + * @param functionName (Required) Function Name You can specify a function name (for example, Thumbnail), or you + * can specify the function's BRN resource name (for example, brn:bce:cfc:bj:account-id: + * function:thumbnail:$LATEST). CFC also allows you to specify a partial BRN (for example, + * account-id:Thumbnail). Note that the BRN length is limited to 1-170. If only the function + * name is specified, the length is limited to 64 characters. + * @param qualifier (optional) Function Alias Use this optional parameter to specify a function version or alias. + * If you specify a function version, the API will use the qualified function BRN to request and + * return information about the specific CFC function version. If you specify an alias, the API + * returns information about the version of the function pointed to by the alias. If you don't + * provide this parameter, the API returns information about the CFC function $LATEST + * @return + */ + public GetFunctionResponse getFunction(String functionName, String qualifier) { + GetFunctionRequest request = new GetFunctionRequest() + .withFunctionName(functionName) + .withQualifier(qualifier); + return this.getFunction(request); + } + + /** + * Get function information + * + * @param request + * @return GetFunctionResponse User function information + */ + public GetFunctionResponse getFunction(GetFunctionRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, FUNCTIONS, + request.getFunctionName()); + if (request.getQualifier() != null) { + internalRequest.addParameter("Qualifier", request.getQualifier()); + } + return invokeHttpClient(internalRequest, GetFunctionResponse.class); + } + + /** + * Delete function + * + * @param functionName (Required) Function name + * @param qualifier (optional) Function alias + * @return + */ + public DeleteFunctionResponse deleteFunction(String functionName, String qualifier) { + DeleteFunctionRequest request = new DeleteFunctionRequest() + .withFunctionName(functionName) + .withQualifier(qualifier); + return this.deleteFunction(request); + } + + /** + * Delete function + * + * @param request + * @return + */ + public DeleteFunctionResponse deleteFunction(DeleteFunctionRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, FUNCTIONS, + request.getFunctionName()); + if (request.getQualifier() != null) { + internalRequest.addParameter("Qualifier", request.getQualifier()); + } + return invokeHttpClient(internalRequest, DeleteFunctionResponse.class); + } + + /** + * Update function code + * + * @param request + * @return Function information + */ + public UpdateFunctionCodeResponse updateFunctionCode(UpdateFunctionCodeRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, FUNCTIONS, + request.getFunctionName(), CODE); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, UpdateFunctionCodeResponse.class); + } + + /** + * Get function configuration + * + * @param functionName (Required) Function name + * @param qualifier (Optional) Function alias + * @return + */ + public GetFunctionConfigurationResponse getFunctionConfiguration(String functionName, String qualifier) { + GetFunctionConfigurationRequest request = new GetFunctionConfigurationRequest() + .withFunctionName(functionName) + .withQualifier(qualifier); + return this.getFunctionConfiguration(request); + } + + /** + * Get function configuration + * + * @param request + * @return function information + */ + public GetFunctionConfigurationResponse getFunctionConfiguration(GetFunctionConfigurationRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, FUNCTIONS, + request.getFunctionName(), CONFIGURATION); + if (request.getQualifier() != null) { + internalRequest.addParameter("Qualifier", request.getQualifier()); + } + return invokeHttpClient(internalRequest, GetFunctionConfigurationResponse.class); + } + + /** + * Update function configuration + * + * @param request + * @return Function information + */ + public UpdateFunctionConfigurationResponse updateFunctionConfiguration(UpdateFunctionConfigurationRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, FUNCTIONS, + request.getFunctionName(), CONFIGURATION); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, UpdateFunctionConfigurationResponse.class); + } + + /** + * Get function version list + * + * @param functionName (Required) Function name + * @param marker (Optional) Function marker + * @param maxItems (Optional) MaxItems 1-10000 + * @return + */ + public ListVersionsByFunctionResponse listVersionsByFunction(String functionName, Integer marker, + Integer maxItems) { + ListVersionsByFunctionRequest request = new ListVersionsByFunctionRequest() + .withFunctionName(functionName) + .withMarker(marker) + .withMaxItems(maxItems); + return this.listVersionsByFunction(request); + } + + /** + * Get function version list + * + * @param request + * @return + */ + public ListVersionsByFunctionResponse listVersionsByFunction(ListVersionsByFunctionRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, FUNCTIONS, + request.getFunctionName(), VERSIONS); + if (request.getMarker() != null) { + internalRequest.addParameter("Marker", String.valueOf(request.getMarker())); + } + if (request.getMaxItems() != null) { + internalRequest.addParameter("MaxItems", String.valueOf(request.getMaxItems())); + } + return invokeHttpClient(internalRequest, ListVersionsByFunctionResponse.class); + } + + public PublishVersionResponse publishVersion(String functionName, String description, String codeSha256) { + PublishVersionRequest request = new PublishVersionRequest() + .withFunctionName(functionName) + .withDescription(description) + .withCodeSha256(codeSha256); + return this.publishVersion(request); + } + + /** + * Publish function + * + * @param request + * @return + */ + public PublishVersionResponse publishVersion(PublishVersionRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, FUNCTIONS, + request.getFunctionName(), VERSIONS); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, PublishVersionResponse.class); + } + + public ListAliasesResponse listAliases(String functionName, String functionVersion, Integer marker, + Integer maxItems) { + ListAliasesRequest request = new ListAliasesRequest() + .withFunctionName(functionName) + .withFunctionVersion(functionVersion) + .withMarker(marker) + .withMaxItems(maxItems); + return this.listAliases(request); + } + + /** + * Get function alias list + * + * @param request + * @return + */ + public ListAliasesResponse listAliases(ListAliasesRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, FUNCTIONS, + request.getFunctionName(), ALIASES); + if (request.getFunctionVersion() != null) { + internalRequest.addParameter("FunctionVersion", request.getFunctionVersion()); + } + if (request.getMarker() != null) { + internalRequest.addParameter("Marker", String.valueOf(request.getMarker())); + } + if (request.getMaxItems() != null) { + internalRequest.addParameter("MaxItems", String.valueOf(request.getMaxItems())); + } + return invokeHttpClient(internalRequest, ListAliasesResponse.class); + } + + /** + * Create function alias + * + * @param functionName Function name + * @param functionVersion Function version + * @param name Alias, uppercase and lowercase letters, numbers, and -_/. special characters, must start + * with a letter and be limited to 64 characters in length + * @param description Alias description + * @return Alias information + */ + public CreateAliasResponse createAlias(String functionName, String functionVersion, String name, + String description) { + CreateAliasRequest request = new CreateAliasRequest(name) + .withName(name) + .withFunctionName(functionName) + .withFunctionVersion(functionVersion) + .withDescription(description); + return createAlias(request); + + } + + /** + * Create function alias + * + * @param request + * @return Alias information + */ + public CreateAliasResponse createAlias(CreateAliasRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, FUNCTIONS, + request.getFunctionName(), ALIASES); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CreateAliasResponse.class); + } + + /** + * Get function alias + * + * @param aliasName Alias name + * @param functionName Function name + * @return + */ + public GetAliasResponse getAlias(String aliasName, String functionName) { + GetAliasRequest request = new GetAliasRequest() + .withAliasName(aliasName) + .withFunctionName(functionName); + return this.getAlias(request); + } + + /** + * Get function alias + * + * @param request + * @return + */ + public GetAliasResponse getAlias(GetAliasRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, FUNCTIONS, + request.getFunctionName(), ALIASES, request.getAliasName()); + return invokeHttpClient(internalRequest, GetAliasResponse.class); + } + + /** + * Update alias + * + * @param functionName Function name + * @param functionVersion Function version + * @param aliasName Alias name + * @param description Alias description + * @return + */ + public UpdateAliasResponse updateAlias(String functionName, String functionVersion, String aliasName, + String description) { + UpdateAliasRequest request = new UpdateAliasRequest() + .withFunctionName(functionName) + .withAliasName(aliasName) + .withFunctionVersion(functionVersion) + .withDescription(description); + return this.updateAlias(request); + } + + /** + * Update function alias + * + * @param request + * @return + */ + public UpdateAliasResponse updateAlias(UpdateAliasRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, FUNCTIONS, + request.getFunctionName(), ALIASES, request.getAliasName()); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, UpdateAliasResponse.class); + } + + /** + * Delete function alias + * + * @param functionName Function name + * @param aliasName Alias name + * @return + */ + public DeleteAliasResponse deleteAlias(String functionName, String aliasName) { + DeleteAliasRequest request = new DeleteAliasRequest() + .withFunctionName(functionName) + .withAliasName(aliasName); + return this.deleteAlias(request); + } + + /** + * Delete function alias + * + * @param request + * @return + */ + public DeleteAliasResponse deleteAlias(DeleteAliasRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, FUNCTIONS, + request.getFunctionName(), ALIASES, request.getAliasName()); + return invokeHttpClient(internalRequest, DeleteAliasResponse.class); + } + + /** + * Get trigger list + * + * @param functionBrn Function BRN + * @return + */ + public ListTriggersResponse listTriggers(String functionBrn) { + ListTriggersRequest request = new ListTriggersRequest() + .withFunctionBrn(functionBrn); + return listTriggers(request); + } + + /** + * Get trigger list + * + * @param request + * @return + */ + public ListTriggersResponse listTriggers(ListTriggersRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, RELATION); + if (request.getFunctionBrn() != null) { + internalRequest.addParameter("FunctionBrn", request.getFunctionBrn()); + } + return invokeHttpClient(internalRequest, ListTriggersResponse.class); + } + + /** + * Create trigger + * + * @param target Function BRN + * @param source Trigger source + * @param data Trigger parameter configuration + * @return + */ + public CreateTriggerResponse createTrigger(String target, String source, Map data) { + CreateTriggerRequest request = new CreateTriggerRequest() + .withTarget(target) + .withSource(source) + .withData(data); + return this.createTrigger(request); + } + + /** + * Create trigger + * + * @param request + * @return + */ + public CreateTriggerResponse createTrigger(CreateTriggerRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, RELATION); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, CreateTriggerResponse.class); + } + + /** + * Update trigger + * + * @param relationId Trigger ID + * @param target Function BRN + * @param source Trigger source + * @param data Trigger parameter configuration + * @return + */ + public UpdateTriggerResponse updateTrigger(String relationId, String target, String source, + Map data) { + UpdateTriggerRequest request = new UpdateTriggerRequest() + .withRelationId(relationId) + .withTarget(target) + .withSource(source) + .withData(data); + UpdateTriggerResponse response = this.updateTrigger(request); + response.getRelation().setSid(null); + return response; + } + + /** + * Update trigger + * + * @param request + * @return + */ + public UpdateTriggerResponse updateTrigger(UpdateTriggerRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, RELATION); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, UpdateTriggerResponse.class); + + } + + /** + * Delete trigger + * + * @param target Function BRN + * @param source Trigger source + * @param relationId Trigger ID + * @return + */ + public DeleteTriggerResponse deleteTrigger(String target, String source, String relationId) { + DeleteTriggerRequest request = new DeleteTriggerRequest() + .withTarget(target) + .withSource(source) + .withRelationId(relationId); + return this.deleteTrigger(request); + } + + /** + * Delete trigger + * + * @param request + * @return + */ + public DeleteTriggerResponse deleteTrigger(DeleteTriggerRequest request) { + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, RELATION); + if (request.getTarget() != null) { + internalRequest.addParameter("Target", request.getTarget()); + } + if (request.getSource() != null) { + internalRequest.addParameter("Source", request.getSource()); + } + if (request.getRelationId() != null) { + internalRequest.addParameter("RelationId", request.getRelationId()); + } + return invokeHttpClient(internalRequest, DeleteTriggerResponse.class); + } + + /** + * Invoke function + * + * @param functionName Function name or function BRN + * @param invocationType Call mode Event (asynchronous call) returns 202/RequestResponse (sync return) / DryRun + * (test function). Default ResauestResponse + * @param logType Log type Tail / None You can set this optional parameter to Tail, provided the + * InvocationType parameter must be RequestResponse + * @param qualifier Function version or function alias + * @param payload + * @return + */ + public InvokeResponse invoke(String functionName, String invocationType, String logType, String qualifier, + byte[] payload) { + InvokeRequest request = new InvokeRequest() + .withFunctionName(functionName) + .withInvocationType(invocationType) + .withLogType(logType) + .withQualifier(qualifier) + .withPayload(payload); + return this.invoke(request); + } + + /** + * Invoke function + * + * @param request + * @return + */ + public InvokeResponse invoke(InvokeRequest request) { + this.config.setConnectionTimeoutInMillis(INVOKE_CONNECTION_TIMEOUT_IN_MILLIS); + this.config.setSocketTimeoutInMillis(INVOKE_SOCKET_TIMEOUT_IN_MILLIS); + checkNotNull(request, ERRORMSG); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, FUNCTIONS, + request.getFunctionName(), INVOCATIONS); + if (request.getInvocationType() != null) { + internalRequest.addParameter("InvocationType", request.getInvocationType()); + } + if (request.getLogType() != null) { + internalRequest.addParameter("LogType", request.getLogType()); + } + if (request.getQualifier() != null) { + internalRequest.addParameter("Qualifier", request.getQualifier()); + } + this.attachInvokeRequestToBody(internalRequest, request.getPayload()); + GetInvokeResponse response = invokeHttpClient(internalRequest, GetInvokeResponse.class); + StringBuilder payload = new StringBuilder(); + try { + if (response.getInvoke().getContent() != null) { + BufferedReader reader = new BufferedReader( + new InputStreamReader(response.getInvoke().getContent(), ENCODINGTYPE)); + String line; + while ((line = reader.readLine()) != null) { + payload.append(line); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + InvokeResponse invokeResponse = new InvokeResponse(); + invokeResponse.setMetadata(response.getMetadata()); + byte[] payloadBytes; + try { + payloadBytes = JsonUtils.toJsonString(payload).getBytes(ENCODINGTYPE); + } catch (UnsupportedEncodingException e) { + throw new BceClientException(ENCODINGERR, e); + } + invokeResponse.setPayload(payloadBytes); + String logResult = response.getInvoke().getObjectMetadata().getBceLogResult(); + if (logResult != "") { + invokeResponse.setBceLogResult(logResult); + } + + return invokeResponse; + + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest( + AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * put json object into http content for put or post request. + * + * @param request json object of rest request + * @param httpRequest http request object + */ + private void attachRequestToBody(AbstractBceRequest request, InternalRequest httpRequest) { + byte[] content; + try { + content = JsonUtils.toJsonString(request).getBytes(ENCODINGTYPE); + } catch (UnsupportedEncodingException e) { + throw new BceClientException(ENCODINGERR, e); + } + + httpRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(content.length)); + httpRequest.addHeader(Headers.CONTENT_TYPE, CONTENTTYPE); + httpRequest.setContent(RestartableInputStream.wrap(content)); + + } + + /** + * put invoke payload into http body for put or post request. + * @param httpRequest json object of rest request + * @param payload http request object + */ + private void attachInvokeRequestToBody(InternalRequest httpRequest, byte[] payload) { + httpRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(payload.length)); + httpRequest.addHeader(Headers.CONTENT_TYPE, CONTENTTYPE); + httpRequest.setContent(RestartableInputStream.wrap(payload)); + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfc/CfcInputStream.java b/src/main/java/com/baidubce/services/cfc/CfcInputStream.java new file mode 100644 index 00000000..9281a91f --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/CfcInputStream.java @@ -0,0 +1,40 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc; + +import org.apache.http.client.methods.CloseableHttpResponse; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.SocketException; + +/** + * The input stream for CFC service calls. + */ +public class CfcInputStream extends FilterInputStream { + private CloseableHttpResponse httpResponse; + + public CfcInputStream(InputStream in, CloseableHttpResponse httpResponse) { + super(in); + this.httpResponse = httpResponse; + } + + public void close() throws IOException { + this.httpResponse.close(); + try { + super.close(); + } catch (SocketException e) { + // expected from some implementations because the stream is closed + } + } +} diff --git a/src/main/java/com/baidubce/services/cfc/CfcResponseHandler.java b/src/main/java/com/baidubce/services/cfc/CfcResponseHandler.java new file mode 100644 index 00000000..638b3b17 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/CfcResponseHandler.java @@ -0,0 +1,62 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.Headers; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cfc.model.CfcInvokeResult; +import com.baidubce.services.cfc.model.CfcMetaData; +import com.baidubce.services.cfc.model.GetInvokeResponse; +import com.baidubce.util.LengthCheckInputStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.InputStream; + +/** + * Responsible for handling httpResponses from all CFC service calls + */ +public class CfcResponseHandler implements HttpResponseHandler { + private static Logger logger = LoggerFactory.getLogger(CfcResponseHandler.class); + private static final String DEFAULT_ENCODING = "UTF-8"; + + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + if (!(response instanceof GetInvokeResponse)) { + return false; + } + CfcInvokeResult object = new CfcInvokeResult(); + CfcMetaData objectMetadata = object.getObjectMetadata(); + objectMetadata.setBceRequestId(httpResponse.getHeader(Headers.BCE_REQUEST_ID)); + objectMetadata.setContentLength(httpResponse.getHeaderAsLong(Headers.CONTENT_LENGTH)); + objectMetadata.setContentType(httpResponse.getHeader(Headers.CONTENT_TYPE)); + objectMetadata.setServer(httpResponse.getHeader(Headers.SERVER)); + objectMetadata.setBceLogResult(httpResponse.getHeader(Headers.BCE_LOG_RESULT)); + + object.setObjectMetadata(objectMetadata); + InputStream content = httpResponse.getContent(); + if (content != null) { + if (objectMetadata.getContentLength() > 0) { + content = new LengthCheckInputStream(content, objectMetadata.getContentLength(), + LengthCheckInputStream.INCLUDE_SKIPPED_BYTES); + } + object.setContent(new CfcInputStream(content, httpResponse.getHttpResponse())); + } + + ((GetInvokeResponse) response).setInvoke(object); + return true; + } + + +} diff --git a/src/main/java/com/baidubce/services/cfc/model/AliasConfiguration.java b/src/main/java/com/baidubce/services/cfc/model/AliasConfiguration.java new file mode 100644 index 00000000..e806652a --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/AliasConfiguration.java @@ -0,0 +1,239 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represent the basic alias information about a CFC function. The information contains the basic information of the + * alias, such as function_name, name, description, etc. + */ +public class AliasConfiguration extends JsonObject { + + /** + * The baidu resource name for alias + */ + @JsonProperty(value = "AliasBrn") + private String AliasBrn; + + /** + * Compatible with AWS Lambda amazon resource name. Same as AliasBrn + */ + @JsonProperty(value = "AliasArn") + private String AliasArn; + + /** + * The name of the function, consisting of a number, a letter, - or _. Length limited to 64 characters + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * The version of the function.$LATEST means the latest, otherwise it consists of numbers and length limited 1-32 + * characters + */ + @JsonProperty(value = "FunctionVersion") + private String FunctionVersion; + + /** + * The name of the alias + */ + @JsonProperty(value = "Name") + private String Name; + + /** + * A short description of the alias. Length limited 0-256 characters. + */ + @JsonProperty(value = "Description") + private String Description; + + /** + * User ID (consists of numbers, letters and _), length limited 128 characters + */ + @JsonProperty(value = "Uid") + private String Uid; + + /** + * The alias latest update time. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + @JsonProperty(value = "UpdatedAt") + private String UpdatedAt; + + /** + * Represent the alias create time. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + @JsonProperty(value = "CreatedAt") + private String CreatedAt; + + /** + * Get the AliasBrn for alias + * @return The AliasBrn for alias + */ + @JsonProperty(value = "AliasBrn") + public String getAliasBrn() { + return this.AliasBrn; + } + + /** + * Set the AliasBrn for alias + * @param aliasBrn The AliasBrn for alias + */ + @JsonProperty(value = "AliasBrn") + public void setAliasBrn(String aliasBrn) { + this.AliasBrn = aliasBrn; + } + + /** + * Get the AliasArn for alias + * @return The AliasArn for alias + */ + @JsonProperty(value = "AliasArn") + public String getAliasArn() { + return this.AliasArn; + } + + /** + * Set the AliasArn for alias + * @param aliasArn The AliasArn for alias + */ + @JsonProperty(value = "AliasArn") + public void setAliasArn(String aliasArn) { + this.AliasArn = aliasArn; + } + + /** + * Get the FunctionName for function + * @return The FunctionName for function + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the FunctionName for function + * @param functionName The FunctionName for function + */ + @JsonProperty(value = "FunctionName") + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the FunctionVersion for function + * @return The FunctionVersion for function + */ + @JsonProperty(value = "FunctionVersion") + public String getFunctionVersion() { + return this.FunctionVersion; + } + + /** + * Set the FunctionVersion for function + * @param functionVersion The FunctionVersion for function + */ + @JsonProperty(value = "FunctionVersion") + public void setFunctionVersion(String functionVersion) { + this.FunctionVersion = functionVersion; + } + + /** + * Get the Name for alias + * @return The Name for alias + */ + @JsonProperty(value = "Name") + public String getName() { + return this.Name; + } + + /** + * Set the Name for alias + * @param name The Name for alias + */ + @JsonProperty(value = "Name") + public void setName(String name) { + this.Name = name; + } + + /** + * Get the Description for alias + * @return The Description for alias + */ + @JsonProperty(value = "Description") + public String getDescription() { + return this.Description; + } + + /** + * Set the Description for alias + * @param description The Description for alias + */ + @JsonProperty(value = "Description") + public void setDescription(String description) { + this.Description = description; + } + + /** + * Get the Uid for the function user + * @return The Uid for the function user + */ + @JsonProperty(value = "Uid") + public String getUid() { + return this.Uid; + } + + /** + * Set the Uid for the function user + * @param uid The Uid for the function user + */ + @JsonProperty(value = "Uid") + public void setUid(String uid) { + this.Uid = uid; + } + + /** + * Get the UpdatedAt for alias + * @return The UpdatedAt for alias + */ + @JsonProperty(value = "UpdatedAt") + public String getUpdatedAt() { + return this.UpdatedAt; + } + + /** + * Set the UpdatedAt for alias + * @param updatedAt The UpdatedAt for alias + */ + @JsonProperty(value = "UpdatedAt") + public void setUpdatedAt(String updatedAt) { + this.UpdatedAt = updatedAt; + } + + /** + * Get the CreatedAt for alias + * @return The CreatedAt for alias + */ + @JsonProperty(value = "CreatedAt") + public String getCreatedAt() { + return this.CreatedAt; + } + + /** + * Set the CreatedAt for alias + * @param createdAt The CreatedAt for alias + */ + @JsonProperty(value = "CreatedAt") + public void setCreatedAt(String createdAt) { + this.CreatedAt = createdAt; + } + +} diff --git a/src/main/java/com/baidubce/services/cfc/model/AliasConfigurationResponse.java b/src/main/java/com/baidubce/services/cfc/model/AliasConfigurationResponse.java new file mode 100644 index 00000000..aa63ba92 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/AliasConfigurationResponse.java @@ -0,0 +1,228 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Contains the data returned by Baidu CFC service calls about aliases + */ +public class AliasConfigurationResponse extends CfcResponse { + /** + * The baidu resource name for alias + */ + @JsonProperty(value = "AliasBrn") + private String AliasBrn; + + /** + * Compatible with AWS Lambda amazon resource name. Same as AliasBrn + */ + @JsonProperty(value = "AliasArn") + private String AliasArn; + + /** + * The name of the function, consisting of a number, a letter, - or _. Length limited to 64 characters + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * The version of the function.$LATEST means the latest, otherwise it consists of numbers and length limited 1-32 + * characters + */ + @JsonProperty(value = "FunctionVersion") + private String FunctionVersion; + + /** + * The name of the alias + */ + @JsonProperty(value = "Name") + private String Name; + + /** + * A short description of the alias. Length limited 0-256 characters. + */ + @JsonProperty(value = "Description") + private String Description; + + /** + * User ID (consists of numbers, letters and _), length limited 128 characters + */ + @JsonProperty(value = "Uid") + private String Uid; + + /** + * The alias latest update time. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + @JsonProperty(value = "UpdatedAt") + private String UpdatedAt; + + /** + * Represent the alias create time. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + @JsonProperty(value = "CreatedAt") + private String CreatedAt; + + /** + * Get the AliasBrn for alias + * @return The AliasBrn for alias + */ + @JsonProperty(value = "AliasBrn") + public String getAliasBrn() { + return this.AliasBrn; + } + + /** + * Set the AliasBrn for alias + * @param aliasBrn The AliasBrn for alias + */ + public void setAliasBrn(String aliasBrn) { + this.AliasBrn = aliasBrn; + } + + /** + * Get the AliasArn for alias + * @return The AliasArn for alias + */ + @JsonProperty(value = "AliasArn") + public String getAliasArn() { + return this.AliasArn; + } + + /** + * Set the AliasArn for alias + * @param aliasArn The AliasArn for alias + */ + public void setAliasArn(String aliasArn) { + this.AliasArn = aliasArn; + } + + /** + * Get the FunctionName for function + * @return The FunctionName for function + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the FunctionName for function + * @param functionName The FunctionName for function + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the FunctionVersion for function + * @return The FunctionVersion for function + */ + @JsonProperty(value = "FunctionVersion") + public String getFunctionVersion() { + return this.FunctionVersion; + } + + /** + * Set the FunctionVersion for function + * @param functionVersion The FunctionVersion for function + */ + public void setFunctionVersion(String functionVersion) { + this.FunctionVersion = functionVersion; + } + + /** + * Get the Name for alias + * @return The Name for alias + */ + @JsonProperty(value = "Name") + public String getName() { + return this.Name; + } + + /** + * Set the Name for alias + * @param name The Name for alias + */ + public void setName(String name) { + this.Name = name; + } + + /** + * Get the Description for alias + * @return The Description for alias + */ + @JsonProperty(value = "Description") + public String getDescription() { + return this.Description; + } + + /** + * Set the Description for alias + * @param description The Description for alias + */ + public void setDescription(String description) { + this.Description = description; + } + + /** + * Get the Uid for the function user + * @return The Uid for the function user + */ + @JsonProperty(value = "Uid") + public String getUid() { + return this.Uid; + } + + /** + * Set the Uid for the function user + * @param uid The Uid for the function user + */ + public void setUid(String uid) { + this.Uid = uid; + } + + /** + * Get the UpdatedAt for alias + * @return The UpdatedAt for alias + */ + @JsonProperty(value = "UpdatedAt") + public String getUpdatedAt() { + return this.UpdatedAt; + } + + /** + * Set the UpdatedAt for alias + * @param updatedAt The UpdatedAt for alias + */ + public void setUpdatedAt(String updatedAt) { + this.UpdatedAt = updatedAt; + } + + /** + * Get the CreatedAt for alias + * @return The CreatedAt for alias + */ + @JsonProperty(value = "CreatedAt") + public String getCreatedAt() { + return this.CreatedAt; + } + + /** + * Set the CreatedAt for alias + * @param createdAt The CreatedAt for alias + */ + public void setCreatedAt(String createdAt) { + this.CreatedAt = createdAt; + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/CfcInvokeResult.java b/src/main/java/com/baidubce/services/cfc/model/CfcInvokeResult.java new file mode 100644 index 00000000..2803987f --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CfcInvokeResult.java @@ -0,0 +1,73 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.services.cfc.CfcInputStream; + +import java.io.Closeable; +import java.io.IOException; + +/** + * Contains the data returned by baidu CFC from the invoke call. + * The result is the return of the user's function performed by baidu CFC. + */ +public class CfcInvokeResult implements Closeable { + + /** + * Represent the HTTP response of CFC service call. + */ + private CfcInputStream Content; + + /** + * represent the meta data of CFC service call. + */ + private CfcMetaData objectMetadata = new CfcMetaData(); + + /** + * Get the meta data of CFC service call. + * @return The objectMetadata of CFC + */ + public CfcMetaData getObjectMetadata() { + return objectMetadata; + } + + /** + * Set the meta data of CFC service call. + * @param objectMetadata The meta data of CFC service call. + */ + public void setObjectMetadata(CfcMetaData objectMetadata) { + this.objectMetadata = objectMetadata; + } + + /** + * Get the Content of CFC service call. + * @return The Content of CFC service call. + */ + public CfcInputStream getContent() { + return Content; + } + + /** + * Set the Content of CFC service call. + * @param content The Content of CFC service call. + */ + public void setContent(CfcInputStream content) { + Content = content; + } + + @Override + public void close() throws IOException { + if (this.getContent() != null) { + this.getContent().close(); + } + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/CfcMetaData.java b/src/main/java/com/baidubce/services/cfc/model/CfcMetaData.java new file mode 100644 index 00000000..4c64d04e --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CfcMetaData.java @@ -0,0 +1,191 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represents the metadata of Baidu CFC. This includes custom + * user-supplied metadata, as well as the standard HTTP headers that Baidu CFC + * sends and receives (ContentLength, ContentType, Server, etc.). + */ +public class CfcMetaData { + + /** + * represent the Bce request id + */ + @JsonProperty(value = "BceRequestId") + private String BceRequestId; + + /** + * The length of the request body. + */ + @JsonProperty(value = "ContentLength") + private long ContentLength = -1; + + /** + * The MIME type of the body of the request. + */ + @JsonProperty(value = "ContentType") + private String ContentType; + + /** + * The date of the Bce request. + */ + @JsonProperty(value = "Date") + private String Date; + + /** + * The server provided by the Bce. + */ + @JsonProperty(value = "Server") + private String Server; + + /** + * The log of the CFC invoke calls. + */ + @JsonProperty(value = "BceLogResult") + private String BceLogResult; + + /** + * Get the Bce request Id + * @return The Bce request Id + */ + public String getBceRequestId() { + return BceRequestId; + } + + /** + * Set the Bce request Id + * @param bceRequestId The Bce request Id + */ + public void setBceRequestId(String bceRequestId) { + BceRequestId = bceRequestId; + } + + /** + * Get the length of the request body. + * @return The length of the request body. + */ + public long getContentLength() { + return ContentLength; + } + + /** + * Set the length of the request body. + * @param contentLength The length of the request body. + */ + public void setContentLength(long contentLength) { + ContentLength = contentLength; + } + + /** + * Get the MIME type of the body of the request. + * @return The MIME type of the body of the request. + */ + public String getContentType() { + return ContentType; + } + + /** + * Set the MIME type of the body of the request. + * @param contentType The MIME type of the body of the request. + */ + public void setContentType(String contentType) { + ContentType = contentType; + } + + /** + * Get the date of the Bce request. + * @return The date of the Bce request. + */ + public String getDate() { + return Date; + } + + /** + * Set the date of the Bce request. + * @param date The date of the Bce request. + */ + public void setDate(String date) { + Date = date; + } + + /** + * Get the server provided by the Bce. + * @return The server provided by the Bce. + */ + public String getServer() { + return Server; + } + + /** + * Set the server provided by the Bce. + * @param server The server provided by the Bce. + */ + public void setServer(String server) { + Server = server; + } + + /** + * Get the log of the CFC invoke calls. + * @return The log of the CFC invoke calls. + */ + public String getBceLogResult() { + return BceLogResult; + } + + /** + * Set the log of the CFC invoke calls. + * @param bceLogResult The log of the CFC invoke calls. + */ + public void setBceLogResult(String bceLogResult) { + BceLogResult = bceLogResult; + } + + public CfcMetaData() { + + } + + public CfcMetaData(CfcMetaData other) { + this.setBceRequestId(other.getBceRequestId()); + this.setContentLength(other.getContentLength()); + this.setContentType(other.getContentType()); + this.setBceLogResult(other.getBceLogResult()); + this.setDate(other.getDate()); + this.setServer(other.getServer()); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder("CfcMetadata ["); + if (this.ContentType != null) { + builder.append("\nContent-Type=").append(this.ContentType); + } + if (this.Date != null) { + builder.append(", \nDate=").append(this.Date); + } + if (this.Server != null) { + builder.append(", \nServer=").append(this.Server); + } + if (this.BceLogResult != null) { + builder.append(", \nX-Bce-Log-Result=").append(this.BceLogResult); + } + if (this.BceRequestId != null) { + builder.append(", \nX-Bce-Request-Id=").append(this.BceRequestId); + } + builder.append(", \nContent-Length=").append(this.ContentLength); + + builder.append(']'); + return builder.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/CfcResponse.java b/src/main/java/com/baidubce/services/cfc/model/CfcResponse.java new file mode 100644 index 00000000..b5730294 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CfcResponse.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.BceResponseMetadata; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Represent the data return by the baidu CFC service calls + */ +public class CfcResponse extends AbstractBceResponse { + /** + * @param metadata + */ + public void setMetadata(BceResponseMetadata metadata) { + this.metadata = metadata; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/Code.java b/src/main/java/com/baidubce/services/cfc/model/Code.java new file mode 100644 index 00000000..635303cc --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/Code.java @@ -0,0 +1,83 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represent the user function code + */ +public class Code { + + /** + * Contains the contents of the compressed directory, not the directory itself + */ + @JsonProperty(value = "ZipFile") + private String ZipFile; + + /** + * Whether to release the version, true or false + */ + @JsonProperty(value = "Publish") + private boolean Publish; + + /** + * true or false + */ + @JsonProperty(value = "DryRun") + private boolean DryRun; + + /** + * Get the Zip package of the function code file to be published. + * When using this interface, you should convert the contents of the zip file to base64-encoded. + * @return ZipFile The Zip package of the function code file to be published. + */ + @JsonProperty(value = "ZipFile") + public String getZipFile() { + return this.ZipFile; + } + + /** + * Set the Zip package of the function code file to be published. + * When using this interface, you should convert the contents of the zip file to base64-encoded. + * @param zipFile The Zip package of the function code file to be published. + */ + public void setZipFile(String zipFile) { + this.ZipFile = zipFile; + } + + /** + * Get the publish + * @return Publish + */ + @JsonProperty(value = "Publish") + public boolean getPublish() { + return this.Publish; + } + + /** + * Set the publish + * @param publish + */ + public void setPublish(boolean publish) { + this.Publish = publish; + } + + @JsonProperty(value = "DryRun") + public boolean getDryRun() { + return this.DryRun; + } + + public void setDryRun(boolean dryrun) { + this.DryRun = dryrun; + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/CodeStorage.java b/src/main/java/com/baidubce/services/cfc/model/CodeStorage.java new file mode 100644 index 00000000..65cb9ed4 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CodeStorage.java @@ -0,0 +1,68 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represent the store information of function code + */ +public class CodeStorage extends JsonObject { + /** + * The stored address of function address + */ + @JsonProperty(value = "Location") + private String Location; + + /** + * Represent the log storage type, currently supports Bos + */ + @JsonProperty(value = "RepositoryType") + private String RepositoryType; + + /** + * Get the code location + * @return The code location + */ + @JsonProperty(value = "Location") + public String getLocation() { + return this.Location; + } + + /** + * Set the code location + * @param location The code location + */ + @JsonProperty(value = "Location") + public void setLocation(String location) { + this.Location = location; + } + + /** + * Get the log storage type + * @return The log storage type + */ + @JsonProperty(value = "RepositoryType") + public String getRepositoryType() { + return this.RepositoryType; + } + + /** + * Set the log storage type + * @param respositoryType The log storage type + */ + @JsonProperty(value = "RepositoryType") + public void setRespositoryType(String respositoryType) { + this.RepositoryType = respositoryType; + } + +} diff --git a/src/main/java/com/baidubce/services/cfc/model/CreateAliasRequest.java b/src/main/java/com/baidubce/services/cfc/model/CreateAliasRequest.java new file mode 100644 index 00000000..a5770f2d --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CreateAliasRequest.java @@ -0,0 +1,136 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for creating a alias for Baidu CFC function. + */ +public class CreateAliasRequest extends GenericAliasRequest { + + /** + * The function name. Note that the length limit only applies to BRN. If only the function name is specified, the + * length is limited to 64 characters. + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + /** + * Alias points to the function version ($LATEST|[0-9]+) + */ + @JsonProperty(value = "FunctionVersion") + private String FunctionVersion; + + /** + * The description of alias + */ + @JsonProperty(value = "Description") + private String Description; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name. Note that the length limit only applies to BRN. If only the function name is specified, + * the length is limited to 64 characters. + * @param functionName + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the function version + * @return The function version + */ + @JsonProperty(value = "FunctionVersion") + public String getFunctionVersion() { + return this.FunctionVersion; + } + + /** + * Set the function version + * @param functionVersion The function version + */ + public void setFunctionVersion(String functionVersion) { + this.FunctionVersion = functionVersion; + } + + /** + * Get the description of the alias + * @return The description of alias + */ + @JsonProperty(value = "Description") + public String getDescription() { + return this.Description; + } + + /** + * Set the description of alias + * @param description The description of alias + */ + public void setDescription(String description) { + this.Description = description; + } + + public CreateAliasRequest(String name) { + super(name); + } + + public CreateAliasRequest withName(String name) { + this.setName(name); + return this; + } + + public CreateAliasRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public CreateAliasRequest withFunctionVersion(String functionVersion) { + this.setFunctionVersion(functionVersion); + return this; + } + + public CreateAliasRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public CreateAliasRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/CreateAliasResponse.java b/src/main/java/com/baidubce/services/cfc/model/CreateAliasResponse.java new file mode 100644 index 00000000..093b4c02 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CreateAliasResponse.java @@ -0,0 +1,19 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for creating alias for Baidu CFC function. + */ +public class CreateAliasResponse extends AliasConfigurationResponse { + +} diff --git a/src/main/java/com/baidubce/services/cfc/model/CreateFunctionRequest.java b/src/main/java/com/baidubce/services/cfc/model/CreateFunctionRequest.java new file mode 100644 index 00000000..bdd7453d --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CreateFunctionRequest.java @@ -0,0 +1,228 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for creating a Baidu CFC function + */ +public class CreateFunctionRequest extends GenericFunctionRequest { + /** + * Function code + */ + @JsonProperty(value = "Code") + private Code Code; + + /** + * Function environment + */ + @JsonProperty(value = "Environment") + private Environment Environment; + + /** + * Entry function of CFC call. For node is module-name.export eg. index.handler maximum length limit is 128. + */ + @JsonProperty(value = "Handler") + private String Handler; + + /** + * Memory size, in megabytes, used by CFC to infer the amount of CPU and memory allocated to user functions. + * Default 128MB,Must be a multiple of 128MB (now CFC provides 128 to 1024M of memory). + */ + @JsonProperty(value = "MemorySize") + private Integer MemorySize; + + /** + * Run time such as nodejs6.11 nodejs8.5 python2 java8 + */ + @JsonProperty(value = "Runtime") + private String Runtime; + + /** + * The timeout for executing a function. 1-300 + */ + @JsonProperty(value = "Timeout") + private Integer Timeout; + + /** + * Get the function code + * @return The function code + */ + @JsonProperty(value = "Code") + public Code getCode() { + return this.Code; + } + + /** + * Set the function code + * @param code The function code + */ + public void setCode(Code code) { + this.Code = code; + } + + /** + * Get the function environment + * @return The function environment + */ + @JsonProperty(value = "Environment") + public Environment getEnvironment() { + return this.Environment; + } + + /** + * Set the function environment + * @param environment The function environment + */ + public void setEnvironment(Environment environment) { + this.Environment = environment; + } + + /** + * Get the entry function of CFC call. + * @return The entry function of CFC call + */ + @JsonProperty(value = "Handler") + public String getHandler() { + return this.Handler; + } + + /** + * Set the entry function of CFC call. For node is module-name.export eg. index.handler maximum length limit is 128 + * @param handler The entry function of CFC call. For node is module-name.export eg. index.handler maximum length + * limit is 128. + */ + public void setHandler(String handler) { + this.Handler = handler; + } + + /** + * Get the memory siz. + * @return The memory size + */ + @JsonProperty(value = "MemorySize") + public Integer getMemorySize() { + return this.MemorySize; + } + + /** + * Set the memory size. in megabytes, used by CFC to infer the amount of CPU and memory allocated to user functions. + * Default 128MB,Must be a multiple of 128MB (now CFC provides 128 to 1024M of memory). + * + * @param memorySize The memory size + */ + public void setMemorySize(Integer memorySize) { + this.MemorySize = memorySize; + } + + /** + * Get the runtime for function. + * @return The runtime for function + */ + @JsonProperty(value = "Runtime") + public String getRuntime() { + return this.Runtime; + } + + /** + * Set the runtime for function. + * @param runtime The runtime for function + */ + public void setRuntime(String runtime) { + this.Runtime = runtime; + } + + /** + * Get the timeout for executing a function + * @return The timeout for executing a function + */ + @JsonProperty(value = "TimeOut") + public Integer getTimeout() { + return this.Timeout; + } + + /** + * Set the timeout for executing a function. The timeout should be 1-300 + * @param timeout The timeout for executing a function + */ + public void setTimeout(Integer timeout) { + this.Timeout = timeout; + } + + public CreateFunctionRequest(String functionName, String description) { + super(functionName, description); + } + + public CreateFunctionRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public CreateFunctionRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public CreateFunctionRequest withCode(Code code) { + this.setCode(code); + return this; + } + + public CreateFunctionRequest withEnvironment(Environment environment) { + this.setEnvironment(environment); + return this; + } + + public CreateFunctionRequest withHandler(String handler) { + this.setHandler(handler); + return this; + } + + public CreateFunctionRequest withMemorySize(Integer memorySize) { + this.setMemorySize(memorySize); + return this; + } + + public CreateFunctionRequest withRuntime(String runtime) { + this.setRuntime(runtime); + return this; + } + + public CreateFunctionRequest withTimeout(Integer timeout) { + this.setTimeout(timeout); + return this; + } + + public CreateFunctionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/CreateFunctionResponse.java b/src/main/java/com/baidubce/services/cfc/model/CreateFunctionResponse.java new file mode 100644 index 00000000..ef27e166 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CreateFunctionResponse.java @@ -0,0 +1,18 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for creating a Baidu CFC function. + */ +public class CreateFunctionResponse extends FunctionConfigurationResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfc/model/CreateTriggerRequest.java b/src/main/java/com/baidubce/services/cfc/model/CreateTriggerRequest.java new file mode 100644 index 00000000..79a62959 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CreateTriggerRequest.java @@ -0,0 +1,130 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.Map; + +/** + * Request object for creating a trigger for Baidu CFC function. + */ +public class CreateTriggerRequest extends AbstractBceRequest { + + /** + * The Baidu resource name of a function + */ + @JsonProperty("Target") + private String Target; + + /** + * The trigger source + */ + @JsonProperty("Source") + private String Source; + + /** + * The parameter configuration of the trigger + */ + @JsonProperty("Data") + private Map Data; + + /** + * Get the target + * @return The target + */ + @JsonProperty(value = "Target") + public String getTarget() { + return this.Target; + } + + /** + * Set the target + * @param target The target + */ + public void setTarget(String target) { + this.Target = target; + } + + /** + * Get the trigger source + * @return The trigger source + */ + @JsonProperty(value = "Source") + public String getSource() { + return this.Source; + } + + /** + * Set the trigger source + * @param source The trigger source + */ + public void setSource(String source) { + this.Source = source; + } + + /** + * Get the parameter configuration of the trigger + * @return The parameter configuration of the trigger + */ + @JsonProperty("Data") + public Map getDate() { + return this.Data; + } + + /** + * Set the parameter configuration of the trigger + * @param data The parameter configuration of the trigger + */ + public void setData(Map data) { + this.Data = data; + } + + public CreateTriggerRequest withTarget(String target) { + this.setTarget(target); + return this; + } + + public CreateTriggerRequest withSource(String source) { + this.setSource(source); + return this; + } + + public CreateTriggerRequest withData(Map data) { + this.setData(data); + return this; + } + + public CreateTriggerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } + +} diff --git a/src/main/java/com/baidubce/services/cfc/model/CreateTriggerResponse.java b/src/main/java/com/baidubce/services/cfc/model/CreateTriggerResponse.java new file mode 100644 index 00000000..31b000a5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/CreateTriggerResponse.java @@ -0,0 +1,45 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Response object for creating a trigger for Baidu CFC function + */ +public class CreateTriggerResponse extends CfcResponse { + + /** + * Trigger relation + */ + @JsonProperty(value = "Relation") + private Relation Relation; + + /** + * Get the trigger relation + * @return The trigger relation + */ + @JsonProperty(value = "Relation") + public Relation getRelation() { + return this.Relation; + } + + /** + * Set the trigger relation + * @param relation The trigger relation + */ + public void setRelation(Relation relation) { + this.Relation = relation; + } + +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/DeleteAliasRequest.java b/src/main/java/com/baidubce/services/cfc/model/DeleteAliasRequest.java new file mode 100644 index 00000000..0a3cc766 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/DeleteAliasRequest.java @@ -0,0 +1,98 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for deleting an alias of Baidu CFC function + */ +public class DeleteAliasRequest extends AbstractBceRequest { + /** + * The name of the function which is the alias belong to + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * The name of the alias + */ + @JsonProperty(value = "AliasName") + private String AliasName; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name + * @param functionName The function name + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the alias name + * @return The alias name + */ + @JsonProperty(value = "AliasName") + public String getAliasName() { + return this.AliasName; + } + + /** + * Set the alias name + * @param aliasName The alias name + */ + public void setAliasName(String aliasName) { + this.AliasName = aliasName; + } + + public DeleteAliasRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public DeleteAliasRequest withAliasName(String aliasName) { + this.setAliasName(aliasName); + return this; + } + + public DeleteAliasRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/DeleteAliasResponse.java b/src/main/java/com/baidubce/services/cfc/model/DeleteAliasResponse.java new file mode 100644 index 00000000..5f83d20c --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/DeleteAliasResponse.java @@ -0,0 +1,19 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for deleting the alias of a Baidu CFC function + */ +public class DeleteAliasResponse extends CfcResponse { + +} diff --git a/src/main/java/com/baidubce/services/cfc/model/DeleteFunctionRequest.java b/src/main/java/com/baidubce/services/cfc/model/DeleteFunctionRequest.java new file mode 100644 index 00000000..7f67696f --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/DeleteFunctionRequest.java @@ -0,0 +1,105 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for deleting a Baidu CFC function + */ +public class DeleteFunctionRequest extends AbstractBceRequest { + /** + * The function name. You can specify a function name (for example, Thumbnail), or you can specify the BRN resource + * name of the function (such as brn:bce:cfc:bj:account-id:function:thumbnail:$LATEST). + * CFC also allows you to specify a partial BRN (for example, account-id:Thumbnail). Note that the BRN length is + * limited to 1-170. If only the function name is specified, the length is limited to 64 characters. + */ + private String FunctionName; + + /** + * Use this optional parameter to specify a function version or alias. If you specify a function version, the API + * will use the qualified function BRN to request and return information about the specific CFC function version. + * If you specify an alias, the API returns information about the version of the function pointed to by the alias. + * If you don't provide this parameter, the API returns information about the CFC function $LATEST. + */ + private String Qualifier; + + /** + * Get the function name + * @return The function name + */ + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name + * @param functionName The function name + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the function qualifier + * @return The function qualifier + */ + public String getQualifier() { + return this.Qualifier; + } + + /** + * Set the function qualifier + * @param qualifier The function qualifier + */ + public void setQualifier(String qualifier) { + this.Qualifier = qualifier; + } + + public DeleteFunctionRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public DeleteFunctionRequest withQualifier(String qualifier) { + this.setQualifier(qualifier); + return this; + } + + /** + * (non-Javadoc) + * + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public DeleteFunctionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/DeleteFunctionResponse.java b/src/main/java/com/baidubce/services/cfc/model/DeleteFunctionResponse.java new file mode 100644 index 00000000..cd3e5e15 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/DeleteFunctionResponse.java @@ -0,0 +1,20 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object foe deleting a Baidu CFC function + */ +public class DeleteFunctionResponse extends CfcResponse { + +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/DeleteTriggerRequest.java b/src/main/java/com/baidubce/services/cfc/model/DeleteTriggerRequest.java new file mode 100644 index 00000000..b4341392 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/DeleteTriggerRequest.java @@ -0,0 +1,126 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for deleting a trigger of the Baidu CFC function + */ +public class DeleteTriggerRequest extends AbstractBceRequest { + /** + * The function BRN + */ + @JsonProperty(value = "Target") + private String Target; + + /** + * The trigger source + */ + @JsonProperty(value = "Source") + private String Source; + + /** + * The trigger ID + */ + @JsonProperty(value = "RelationId") + private String RelationId; + + /** + * Get the function BRN + * @return The function BRN + */ + @JsonProperty(value = "Target") + public String getTarget() { + return this.Target; + } + + /** + * Set the function BRN + * @param target The function BRN + */ + public void setTarget(String target) { + this.Target = target; + } + + /** + * Get the trigger source + * @return The trigger source + */ + @JsonProperty(value = "Source") + public String getSource() { + return this.Source; + } + + /** + * Set the trigger source + * @param source The trigger source + */ + public void setSource(String source) { + this.Source = source; + } + + /** + * Get the trigger ID + * @return The trigger ID + */ + @JsonProperty(value = "RelationId") + public String getRelationId() { + return this.RelationId; + } + + /** + * Set the trigger ID + * @param relationId The trigger ID + */ + public void setRelationId(String relationId) { + this.RelationId = relationId; + } + + public DeleteTriggerRequest withTarget(String target) { + this.setTarget(target); + return this; + } + + public DeleteTriggerRequest withSource(String source) { + this.setSource(source); + return this; + } + + public DeleteTriggerRequest withRelationId(String relationId) { + this.setRelationId(relationId); + return this; + } + + public DeleteTriggerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/DeleteTriggerResponse.java b/src/main/java/com/baidubce/services/cfc/model/DeleteTriggerResponse.java new file mode 100644 index 00000000..177579b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/DeleteTriggerResponse.java @@ -0,0 +1,19 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for deleting a trigger for the Baidu CFC function + */ +public class DeleteTriggerResponse extends CfcResponse { + +} diff --git a/src/main/java/com/baidubce/services/cfc/model/Environment.java b/src/main/java/com/baidubce/services/cfc/model/Environment.java new file mode 100644 index 00000000..7dc28c8e --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/Environment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Map; + +/** + * Represent the function environment + */ +public class Environment extends JsonObject { + + /** + * Environment variable parameter + */ + @JsonProperty(value = "Variables") + private Map Variables; + + /** + * Get the environment variable parameter + * @return The environment variable parameter + */ + @JsonProperty(value = "Variables") + public Map getVariables() { + return this.Variables; + } + + /** + * Set the environment variable parameter + * @param variables The environment variable parameter + */ + public void setVariables(Map variables) { + this.Variables = variables; + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/FunctionConfiguration.java b/src/main/java/com/baidubce/services/cfc/model/FunctionConfiguration.java new file mode 100644 index 00000000..d539fdcc --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/FunctionConfiguration.java @@ -0,0 +1,515 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represent the basic information of the Baidu CFC function + */ +public class FunctionConfiguration extends JsonObject { + + /** + * User ID (consisting of numbers, letters, underscores), length limited to 128 characters + */ + @JsonProperty(value = "Uid") + private String Uid; + + /** + * Function description, short description 0-256 characters + */ + @JsonProperty(value = "Description") + private String Description; + + /** + * The unique resource identifier of the function, 1-170 characters + */ + @JsonProperty(value = "FunctionBrn") + private String FunctionBrn; + + /** + * Regional, currently there are bj (Beijing), su (Suzhou), gz (Guangzhou) + */ + @JsonProperty(value = "Region") + private String Region; + + /** + * Timeout, 1-300, maximum 300 + */ + @JsonProperty(value = "Timeout") + private Integer Timeout; + + /** + * Version description, 0-256 characters + */ + @JsonProperty(value = "VersionDesc") + private String VersionDesc; + + /** + * The latest update time of the function, ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + @JsonProperty("UpdatedAt") + private String UpdatedAt; + + /** + * Compatible with AWS Lambda with UpdatedAt + */ + @JsonProperty(value = "LastModified") + private String LastModified; + + /** + * SHA256 hash of function code package + */ + @JsonProperty(value = "CodeSha256") + private String CodeSha256; + + /** + * The size of the function package, in bytes + */ + @JsonProperty(value = "CodeSize") + private Integer CodeSize; + + /** + * Compatible with AWS Lambda with FunctionBrn + */ + @JsonProperty("FunctionArn") + private String FunctionArn; + + /** + * Function name, consisting of numbers, letters, - or _, limited to 64 characters in length + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * The entry function of the CFC call, for the module is module-name.export eg. index.handler maximum length + * is 128 characters + */ + @JsonProperty(value = "Handler") + private String Handler; + + /** + * Version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + */ + @JsonProperty(value = "Version") + private String Version; + + /** + * Runtime nodejs6.11、nodejs8.5、python2、java8 + */ + @JsonProperty(value = "Runtime") + private String Runtime; + + /** + * Memory size, in megabytes, used by CFC to infer the amount of CPU and memory allocated to user functions. + * Default 128MB,Must be a multiple of 128MB (now CFC provides 128 to 1024M of memory). + */ + @JsonProperty(value = "MemorySize") + private Integer MemorySize; + + /** + * Environment + */ + @JsonProperty(value = "Environment") + private Environment Environment; + + /** + * CommitId + */ + @JsonProperty(value = "CommitId") + private String CommitId; + + /** + * Function execution role + */ + @JsonProperty("Role") + private String Role; + + /** + * Log type bos(baidu object store) / none + */ + @JsonProperty(value = "LogType") + private String LogType; + + /** + * the Bucket location of the log + */ + @JsonProperty(value = "LogBosDir") + private String LogBosDir; + + /** + * Get the user ID + * @return The user ID + */ + @JsonProperty(value = "Uid") + public String getUid() { + return this.Uid; + } + + /** + * Set the user ID (consisting of numbers, letters, underscores), length limited to 128 characters + * @param uid The user ID (consisting of numbers, letters, underscores), length limited to 128 characters + */ + public void setUid(String uid) { + this.Uid = uid; + } + + /** + * Get the function description + * @return The function description + */ + @JsonProperty(value = "Description") + public String getDescription() { + return this.Description; + } + + /** + * Set the function description,0-256 characters + * @param description The function description,0-256 characters + */ + public void setDescription(String description) { + this.Description = description; + } + + /** + * Get the BRN (Baidu resource name) of the function + * @return The BRN (Baidu resource name) of the function + */ + @JsonProperty(value = "FunctionBrn") + public String getFunctionBrn() { + return this.FunctionBrn; + } + + /** + * Set the BRN (Baidu resource name) of the function. 1-170 characters + * @param functionBrn The BRN (Baidu resource name) of the function. 1-170 characters + */ + public void setFunctionBrn(String functionBrn) { + this.FunctionBrn = functionBrn; + } + + /** + * Get the region which function belong to + * @return The region which function belong to + */ + @JsonProperty(value = "Region") + public String getRegion() { + return this.Region; + } + + /** + * Set the region which function belong to. The current regions include bj(beijing)、su(suzhou)、gz + * (guangzhou) + * @param region The region which function belong to + */ + public void setRegion(String region) { + this.Region = region; + } + + /** + * Get the timeout + * @return The timeout + */ + @JsonProperty(value = "Timeout") + public Integer getTimeout() { + return this.Timeout; + } + + /** + * Set the timeout, 1-300 + * @param timeout The timeout + */ + public void setTimeout(Integer timeout) { + this.Timeout = timeout; + } + + /** + * Get the function description + * @return The function description + */ + @JsonProperty(value = "VersionDesc") + public String getVersionDesc() { + return this.VersionDesc; + } + + /** + * Set the function description. 0-256 characters + * @param versionDesc The function description + */ + public void setVersionDesc(String versionDesc) { + this.VersionDesc = versionDesc; + } + + /** + * Get the update time of the function. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + * @return The update time of the function. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + @JsonProperty(value = "UpdatedAt") + public String getUpdatedAt() { + return this.UpdatedAt; + } + + /** + * Set the update time of the function. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + * @param updatedAt The update time of the function. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + public void setUpdatedAt(String updatedAt) { + this.UpdatedAt = updatedAt; + } + + /** + * Get the last modified time which is same as UpdateAt. Compatible with AWS Lambda + * @return The last modified time which is same as UpdateAt. Compatible with AWS Lambda + */ + @JsonProperty(value = "LastModified") + public String getLastModified() { + return this.LastModified; + } + + /** + * Set the last modified time which is same as UpdateAt. Compatible with AWS Lambda + * @param lastModified The last modified time which is same as UpdateAt. Compatible with AWS Lambda + */ + public void setLastModified(String lastModified) { + this.LastModified = lastModified; + } + + /** + * Get the SHA256 hash of function code package + * @returnm The SHA256 hash of function code package + */ + @JsonProperty(value = "CodeSha256") + public String getCodeSha256() { + return this.CodeSha256; + } + + /** + * Set the SHA256 hash of function code package + * @param codeSha256 The SHA256 hash of function code package + */ + public void setCodeSha256(String codeSha256) { + this.CodeSha256 = codeSha256; + } + + /** + * Get the size of the function package, in bytes + * @return The size of the function package, in bytes + */ + @JsonProperty(value = "CodeSize") + public Integer getCodeSize() { + return this.CodeSize; + } + + /** + * Set the size of the function package, in bytes + * @param codeSize The size of the function package, in bytes + */ + public void setCodeSize(Integer codeSize) { + this.CodeSize = codeSize; + } + + /** + * Get the FunctionArn. Compatible with AWS Lambda with FunctionBrn + * @return The FunctionArn. Compatible with AWS Lambda with FunctionBrn + */ + @JsonProperty(value = "FunctionArn") + public String getFunctionArn() { + return this.FunctionArn; + } + + /** + * Set the FunctionArn. Compatible with AWS Lambda with FunctionBrn + * @param functionArn The FunctionArn. Compatible with AWS Lambda with FunctionBrn + */ + public void setFunctionArn(String functionArn) { + this.FunctionArn = functionArn; + } + + /** + * Get the function name, consisting of numbers, letters, - or _, limited to 64 characters in length + * @return The function name, consisting of numbers, letters, - or _, limited to 64 characters in length + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name, consisting of numbers, letters, - or _, limited to 64 characters in length + * @param functionName The function name, consisting of numbers, letters, - or _, limited to 64 characters in + * length + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the entry function of the CFC call, for the module is module-name.export eg. index.handler maximum + * length is 128 characters + * @return The entry function of the CFC call, for the module is module-name.export eg. index.handler maximum + * length is 128 characters + */ + @JsonProperty(value = "Handler") + public String getHandler() { + return this.Handler; + } + + /** + * Set the entry function of the CFC call, for the module is module-name.export eg. index.handler maximum + * length is 128 characters + * @param handler The entry function of the CFC call, for the module is module-name.export eg. index.handler + * maximum length is 128 characters + */ + public void setHandler(String handler) { + this.Handler = handler; + } + + /** + * Get the version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + * @return The version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + */ + @JsonProperty(value = "Version") + public String getVersion() { + return this.Version; + } + + /** + * Set the version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + * @param version The version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + */ + public void setVersion(String version) { + this.Version = version; + } + + /** + * Get the runtime + * @return The runtime + */ + @JsonProperty(value = "Runtime") + public String getRuntime() { + return this.Runtime; + } + + /** + * Set the runtime + * @param runtime The runtime + */ + public void setRuntime(String runtime) { + this.Runtime = runtime; + } + + /** + * Get the memory size + * @return The memory size + */ + @JsonProperty(value = "MemorySize") + public Integer getMemorySize() { + return this.MemorySize; + } + + /** + * Set the memory size, in megabytes, used by CFC to infer the amount of CPU and memory allocated to user + * functions. Default 128MB,Must be a multiple of 128MB (now CFC provides 128 to 1024M of memory). + * @param memorySize The memory size, in megabytes, used by CFC to infer the amount of CPU and memory + * allocated to user functions. Default 128MB,Must be a multiple of 128MB (now CFC provides 128 + * to 1024M of memory). + */ + public void setMemorySize(Integer memorySize) { + this.MemorySize = memorySize; + } + + /** + * Get the environment + * @return The environment + */ + @JsonProperty(value = "Environment") + public Environment getEnvironment() { + return this.Environment; + } + + /** + * Set the environment + * @param environment The environment + */ + public void setEnvironment(Environment environment) { + this.Environment = environment; + } + + /** + * Get the commitId + * @return The commitId + */ + @JsonProperty(value = "CommitId") + public String getCommitId() { + return this.CommitId; + } + + /** + * Set the commitId + * @param commitId The commitId + */ + public void setCommitId(String commitId) { + this.CommitId = commitId; + } + + /** + * Get the function execution role + * @return The function execution role + */ + @JsonProperty(value = "Role") + public String getRole() { + return this.Role; + } + + /** + * Set the function execution role + * @param role The function execution role + */ + public void setRole(String role) { + this.Role = role; + } + + /** + * Get the log type bos /none + * @return The log type + */ + @JsonProperty(value = "LogType") + public String getLogType() { + return this.LogType; + } + + /** + * Set the log type bos /none + * @param logType The log type bos /none + */ + public void setLogType(String logType) { + this.LogType = logType; + } + + /** + * Get the log stored bucket address + * @return The log stored bucket address + */ + @JsonProperty(value = "LogBodDir") + public String getLogBosDir() { + return this.LogBosDir; + } + + /** + * Set the log stored bucket address + * @param logBosDir The log stored bucket address + */ + public void setLogBosDir(String logBosDir) { + this.LogBosDir = logBosDir; + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/FunctionConfigurationResponse.java b/src/main/java/com/baidubce/services/cfc/model/FunctionConfigurationResponse.java new file mode 100644 index 00000000..00b704aa --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/FunctionConfigurationResponse.java @@ -0,0 +1,514 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Response object of the basic information of the Baidu CFC function + */ +public class FunctionConfigurationResponse extends CfcResponse { + /** + * User ID (consisting of numbers, letters, underscores), length limited to 128 characters + */ + @JsonProperty(value = "Uid") + private String Uid; + + /** + * Function description, short description 0-256 characters + */ + @JsonProperty(value = "Description") + private String Description; + + /** + * The unique resource identifier of the function, 1-170 characters + */ + @JsonProperty(value = "FunctionBrn") + private String FunctionBrn; + + /** + * Regional, currently there are bj (Beijing), su (Suzhou), gz (Guangzhou) + */ + @JsonProperty(value = "Region") + private String Region; + + /** + * Timeout, 1-300, maximum 300 + */ + @JsonProperty(value = "Timeout") + private Integer Timeout; + + /** + * Version description, 0-256 characters + */ + @JsonProperty(value = "VersionDesc") + private String VersionDesc; + + /** + * The latest update time of the function, ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + @JsonProperty(value = "UpdatedAt") + private String UpdatedAt; + + /** + * Compatible with AWS Lambda with UpdatedAt + */ + @JsonProperty(value = "LastModified") + private String LastModified; + + /** + * SHA256 hash of function code package + */ + @JsonProperty(value = "CodeSha256") + private String CodeSha256; + + /** + * The size of the function package, in bytes + */ + @JsonProperty(value = "CodeSize") + private Integer CodeSize; + + /** + * Compatible with AWS Lambda with FunctionBrn + */ + @JsonProperty(value = "FunctionArn") + private String FunctionArn; + + /** + * Function name, consisting of numbers, letters, - or _, limited to 64 characters in length + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * The entry function of the CFC call, for the module is module-name.export eg. index.handler maximum length + * is 128 characters + */ + @JsonProperty(value = "Handler") + private String Handler; + + /** + * Version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + */ + @JsonProperty(value = "Version") + private String Version; + + /** + * Runtime nodejs6.11、nodejs8.5、python2、java8 + */ + @JsonProperty(value = "Runtime") + private String Runtime; + + /** + * Memory size, in megabytes, used by CFC to infer the amount of CPU and memory allocated to user functions. + * Default 128MB,Must be a multiple of 128MB (now CFC provides 128 to 1024M of memory). + */ + @JsonProperty(value = "MemorySize") + private Integer MemorySize; + + /** + * Environment + */ + @JsonProperty(value = "Environment") + private Environment Environment; + + /** + * CommitId + */ + @JsonProperty(value = "CommitId") + private String CommitId; + + /** + * Function execution role + */ + @JsonProperty(value = "Role") + private String Role; + + /** + * Log type bos(baidu object store) / none + */ + @JsonProperty(value = "LogType") + private String LogType; + + /** + * the Bucket location of the log + */ + @JsonProperty(value = "LogBosDir") + private String LogBosDir; + + /** + * Get the user ID + * @return The user ID + */ + @JsonProperty(value = "Uid") + public String getUid() { + return this.Uid; + } + + /** + * Set the user ID (consisting of numbers, letters, underscores), length limited to 128 characters + * @param uid The user ID (consisting of numbers, letters, underscores), length limited to 128 characters + */ + public void setUid(String uid) { + this.Uid = uid; + } + + /** + * Get the function description + * @return The function description + */ + @JsonProperty(value = "Description") + public String getDescription() { + return this.Description; + } + + /** + * Set the function description,0-256 characters + * @param description The function description,0-256 characters + */ + public void setDescription(String description) { + this.Description = description; + } + + /** + * Get the BRN (Baidu resource name) of the function + * @return The BRN (Baidu resource name) of the function + */ + @JsonProperty(value = "FunctionBrn") + public String getFunctionBrn() { + return this.FunctionBrn; + } + + /** + * Set the BRN (Baidu resource name) of the function. 1-170 characters + * @param functionBrn The BRN (Baidu resource name) of the function. 1-170 characters + */ + public void setFunctionBrn(String functionBrn) { + this.FunctionBrn = functionBrn; + } + + /** + * Get the region which function belong to + * @return The region which function belong to + */ + @JsonProperty(value = "Region") + public String getRegion() { + return this.Region; + } + + /** + * Set the region which function belong to. The current regions include bj(beijing)、su(suzhou)、gz + * (guangzhou) + * @param region The region which function belong to + */ + public void setRegion(String region) { + this.Region = region; + } + + /** + * Get the timeout + * @return The timeout + */ + @JsonProperty(value = "Timeout") + public Integer getTimeout() { + return this.Timeout; + } + + /** + * Set the timeout, 1-300 + * @param timeout The timeout + */ + public void setTimeout(Integer timeout) { + this.Timeout = timeout; + } + + /** + * Get the function description + * @return The function description + */ + @JsonProperty(value = "VersionDesc") + public String getVersionDesc() { + return this.VersionDesc; + } + + /** + * Set the function description. 0-256 characters + * @param versionDesc The function description + */ + public void setVersionDesc(String versionDesc) { + this.VersionDesc = versionDesc; + } + + /** + * Get the update time of the function. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + * @return The update time of the function. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + @JsonProperty(value = "UpdatedAt") + public String getUpdatedAt() { + return this.UpdatedAt; + } + + /** + * Set the update time of the function. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + * @param updatedAt The update time of the function. ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD) + */ + public void setUpdatedAt(String updatedAt) { + this.UpdatedAt = updatedAt; + } + + /** + * Get the last modified time which is same as UpdateAt. Compatible with AWS Lambda + * @return The last modified time which is same as UpdateAt. Compatible with AWS Lambda + */ + @JsonProperty(value = "LastModified") + public String getLastModified() { + return this.LastModified; + } + + /** + * Set the last modified time which is same as UpdateAt. Compatible with AWS Lambda + * @param lastModified The last modified time which is same as UpdateAt. Compatible with AWS Lambda + */ + public void setLastModified(String lastModified) { + this.LastModified = lastModified; + } + + /** + * Get the SHA256 hash of function code package + * @returnm The SHA256 hash of function code package + */ + @JsonProperty(value = "CodeSha256") + public String getCodeSha256() { + return this.CodeSha256; + } + + /** + * Set the SHA256 hash of function code package + * @param codeSha256 The SHA256 hash of function code package + */ + public void setCodeSha256(String codeSha256) { + this.CodeSha256 = codeSha256; + } + + /** + * Get the size of the function package, in bytes + * @return The size of the function package, in bytes + */ + @JsonProperty(value = "CodeSize") + public Integer getCodeSize() { + return this.CodeSize; + } + + /** + * Set the size of the function package, in bytes + * @param codeSize The size of the function package, in bytes + */ + public void setCodeSize(Integer codeSize) { + this.CodeSize = codeSize; + } + + /** + * Get the FunctionArn. Compatible with AWS Lambda with FunctionBrn + * @return The FunctionArn. Compatible with AWS Lambda with FunctionBrn + */ + @JsonProperty(value = "FunctionArn") + public String getFunctionArn() { + return this.FunctionArn; + } + + /** + * Set the FunctionArn. Compatible with AWS Lambda with FunctionBrn + * @param functionArn The FunctionArn. Compatible with AWS Lambda with FunctionBrn + */ + public void setFunctionArn(String functionArn) { + this.FunctionArn = functionArn; + } + + /** + * Get the function name, consisting of numbers, letters, - or _, limited to 64 characters in length + * @return The function name, consisting of numbers, letters, - or _, limited to 64 characters in length + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name, consisting of numbers, letters, - or _, limited to 64 characters in length + * @param functionName The function name, consisting of numbers, letters, - or _, limited to 64 characters in + * length + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the entry function of the CFC call, for the module is module-name.export eg. index.handler maximum + * length is 128 characters + * @return The entry function of the CFC call, for the module is module-name.export eg. index.handler maximum + * length is 128 characters + */ + @JsonProperty(value = "Handler") + public String getHandler() { + return this.Handler; + } + + /** + * Set the entry function of the CFC call, for the module is module-name.export eg. index.handler maximum + * length is 128 characters + * @param handler The entry function of the CFC call, for the module is module-name.export eg. index.handler + * maximum length is 128 characters + */ + public void setHandler(String handler) { + this.Handler = handler; + } + + /** + * Get the version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + * @return The version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + */ + @JsonProperty(value = "Version") + public String getVersion() { + return this.Version; + } + + /** + * Set the version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + * @param version The version, $LATEST means the latest, otherwise it consists of numbers, 1-32 characters + */ + public void setVersion(String version) { + this.Version = version; + } + + /** + * Get the runtime + * @return The runtime + */ + @JsonProperty(value = "Runtime") + public String getRuntime() { + return this.Runtime; + } + + /** + * Set the runtime + * @param runtime The runtime + */ + public void setRuntime(String runtime) { + this.Runtime = runtime; + } + + /** + * Get the memory size + * @return The memory size + */ + @JsonProperty(value = "MemorySize") + public Integer getMemorySize() { + return this.MemorySize; + } + + /** + * Set the memory size, in megabytes, used by CFC to infer the amount of CPU and memory allocated to user + * functions. Default 128MB,Must be a multiple of 128MB (now CFC provides 128 to 1024M of memory). + * @param memorySize The memory size, in megabytes, used by CFC to infer the amount of CPU and memory + * allocated to user functions. Default 128MB,Must be a multiple of 128MB (now CFC provides 128 + * to 1024M of memory). + */ + public void setMemorySize(Integer memorySize) { + this.MemorySize = memorySize; + } + + /** + * Get the environment + * @return The environment + */ + @JsonProperty(value = "Environment") + public Environment getEnvironment() { + return this.Environment; + } + + /** + * Set the environment + * @param environment The environment + */ + public void setEnvironment(Environment environment) { + this.Environment = environment; + } + + /** + * Get the commitId + * @return The commitId + */ + @JsonProperty(value = "CommitId") + public String getCommitId() { + return this.CommitId; + } + + /** + * Set the commitId + * @param commitId The commitId + */ + public void setCommitId(String commitId) { + this.CommitId = commitId; + } + + /** + * Get the function execution role + * @return The function execution role + */ + @JsonProperty(value = "Role") + public String getRole() { + return this.Role; + } + + /** + * Set the function execution role + * @param role The function execution role + */ + public void setRole(String role) { + this.Role = role; + } + + /** + * Get the log type bos /none + * @return The log type + */ + @JsonProperty(value = "LogType") + public String getLogType() { + return this.LogType; + } + + /** + * Set the log type bos /none + * @param logType The log type bos /none + */ + public void setLogType(String logType) { + this.LogType = logType; + } + + /** + * Get the log stored bucket address + * @return The log stored bucket address + */ + @JsonProperty(value = "LogBosDir") + public String getLogBosDir() { + return this.LogBosDir; + } + + /** + * Set the log stored bucket address + * @param logBosDir The log stored bucket address + */ + public void setLogBosDir(String logBosDir) { + this.LogBosDir = logBosDir; + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/GenericAliasRequest.java b/src/main/java/com/baidubce/services/cfc/model/GenericAliasRequest.java new file mode 100644 index 00000000..beebf79f --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/GenericAliasRequest.java @@ -0,0 +1,86 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request object for generating alias + */ +public abstract class GenericAliasRequest extends AbstractBceRequest { + + /** + * The min length of alias name + */ + private static final int MIN_ALIAS_LENGTH = 1; + + /** + * The max length of alias name + */ + private static final int MAX_ALIAS_LENGTH = 64; + + /** + * Alias name, which can only be uppercase and lowercase letters, numbers, -, _, /, and special characters, and + * must start with a letter. The maximum length is 64 characters. + */ + @JsonProperty(value = "Name") + private String Name; + + public GenericAliasRequest() { + + } + + public GenericAliasRequest(String name) { + this.setName(name); + } + + @JsonProperty(value = "Name") + public String getName() { + return this.Name; + } + + public void setName(String name) { + if (name == null) { + this.Name = name; + return; + } + name = name.trim(); + if (name.length() < MIN_ALIAS_LENGTH) { + throw new IllegalArgumentException("Invalid name: " + name + ". " + + "name should not be less than " + MIN_ALIAS_LENGTH + "."); + } + + if (name.length() > MAX_ALIAS_LENGTH) { + throw new IllegalArgumentException("Invalid name: " + name + ". " + + "name should not be greater than " + MAX_ALIAS_LENGTH + "."); + } + + if (!isLegalAlias(name)) { + throw new IllegalArgumentException("Invalid name: " + name + ". " + + "name should be letters or digit or - or _ or / or . and the first character should be letter."); + } + this.Name = name; + } + + private static boolean isLegalAlias(String alias) { + String regex = "^[a-z0-9A-Z-_/.]+$"; + return alias.matches(regex) && isLetter(alias.charAt(0)); + } + + private static boolean isLetter(char ch) { + return ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z'; + } + + public abstract GenericAliasRequest withName(String name); +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/GenericFunctionRequest.java b/src/main/java/com/baidubce/services/cfc/model/GenericFunctionRequest.java new file mode 100644 index 00000000..812454f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/GenericFunctionRequest.java @@ -0,0 +1,129 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request object for generating the Baidu CFC function + */ +public abstract class GenericFunctionRequest extends AbstractBceRequest { + + /** + * The min length of the CFC function name + */ + private static final int MIN_FUNCTION_NAME_LENGTH = 1; + + /** + * The max length of the CFC function name + */ + private static final int MAX_FUNCTION_NAME_LENGTH = 64; + + /** + * The max length of the CFC function description + */ + private static final int MAX_DESCRIPTION_LENGTH = 256; + + /** + * Function name + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * Function description + */ + @JsonProperty(value = "Description") + private String Description; + + public GenericFunctionRequest() { + + } + + public GenericFunctionRequest(String functionName, String description) { + + if (description == null) { + description = ""; + } + this.setFunctionName(functionName); + this.setDescription(description); + } + + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Function name, consisting of numbers, letters, - or _, limited to 64 characters in length + * @param functionName + */ + public void setFunctionName(String functionName) { + + if (functionName == null) { + throw new IllegalArgumentException("Invalid functionName: functionName should not be empty"); + } + + functionName = functionName.trim(); + if (functionName.length() < MIN_FUNCTION_NAME_LENGTH) { + throw new IllegalArgumentException("Invalid functionName: " + functionName + ". " + + "functionName should not be less than " + MIN_FUNCTION_NAME_LENGTH + + "."); + } + + if (functionName.length() > MAX_FUNCTION_NAME_LENGTH) { + throw new IllegalArgumentException("Invalid functionName: " + functionName + ". " + + "functionName should not be greater than " + MAX_FUNCTION_NAME_LENGTH); + } + + if (!isLegalFunctionName(functionName)) { + throw new IllegalArgumentException("Invalid functionName: " + functionName + ". " + + "functionName should be lowercase letters or digit or - or _"); + } + + this.FunctionName = functionName; + + } + + public abstract GenericFunctionRequest withFunctionName(String functionName); + + private static boolean isLegalFunctionName(String functionName) { + + String regex = "^[a-z0-9A-Z-_]+$"; + return functionName.matches(regex); + } + + @JsonProperty(value = "Description") + public String getDescription() { + return this.Description; + } + + public void setDescription(String description) { + + if (description == null) { + this.Description = description; + } + + description = description.trim(); + if (description.length() > 256) { + throw new IllegalArgumentException("Invalid description: " + description + ". " + + "description should not be greater than " + MAX_DESCRIPTION_LENGTH); + } + + this.Description = description; + } + + public abstract GenericFunctionRequest withDescription(String description); + +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/GetAliasRequest.java b/src/main/java/com/baidubce/services/cfc/model/GetAliasRequest.java new file mode 100644 index 00000000..5f96ec5d --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/GetAliasRequest.java @@ -0,0 +1,95 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for getting alias of the Baidu CFC function + */ +public class GetAliasRequest extends AbstractBceRequest { + + /** + * Alias name + */ + private String AliasName; + + /** + * Function name + */ + private String FunctionName; + + /** + * Get the alias name + * @return The alias name + */ + public String getAliasName() { + return this.AliasName; + } + + /** + * Set the alias name + * @param aliasName The alias name + */ + public void setAliasName(String aliasName) { + this.AliasName = aliasName; + } + + /** + * Get the function name + * @return The function name + */ + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name + * @param functionName The function name + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + public GetAliasRequest withAliasName(String aliasName) { + this.setAliasName(aliasName); + return this; + } + + public GetAliasRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public GetAliasRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/GetAliasResponse.java b/src/main/java/com/baidubce/services/cfc/model/GetAliasResponse.java new file mode 100644 index 00000000..08ef7980 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/GetAliasResponse.java @@ -0,0 +1,19 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for getting an alias of the Baidu CFC function + */ +public class GetAliasResponse extends AliasConfigurationResponse { + +} diff --git a/src/main/java/com/baidubce/services/cfc/model/GetFunctionConfigurationRequest.java b/src/main/java/com/baidubce/services/cfc/model/GetFunctionConfigurationRequest.java new file mode 100644 index 00000000..018e0617 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/GetFunctionConfigurationRequest.java @@ -0,0 +1,111 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for getting Baidu CFC function configuration + */ +public class GetFunctionConfigurationRequest extends AbstractBceRequest { + /** + * Function Name You can specify a function name (for example, Thumbnail), or you can specify the function's BRN + * resource name (for example, brn:bce:cfc:bj:account-id:function:thumbnail:$LATEST). CFC also allows you to + * specify a partial BRN (for example, account-id:Thumbnail). Note that the BRN length is limited to 1-170. If only + * the function name is specified, the length is limited to 64 characters. + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * Use this optional parameter to specify a function version or alias. If you specify a function version, the API + * will use the qualified function BRN to request and return information about the specific CFC function version. + * If you specify an alias, the API returns information about the version of the function pointed to by the alias. + * If you don't provide this parameter, the API returns information about the CFC function $LATEST. + */ + @JsonProperty(value = "Qualifier") + private String Qualifier; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name + * @param functionName The function name + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the function qualifier + * @return The function qualifier + */ + @JsonProperty(value = "Qualifier") + public String getQualifier() { + return this.Qualifier; + } + + /** + * Set the function qualifier + * @param qualifier The function qualifier + */ + public void setQualifier(String qualifier) { + this.Qualifier = qualifier; + } + + public GetFunctionConfigurationRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public GetFunctionConfigurationRequest withQualifier(String qualifier) { + this.setQualifier(qualifier); + return this; + } + + /** + * (non-Javadoc) + * + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetFunctionConfigurationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/GetFunctionConfigurationResponse.java b/src/main/java/com/baidubce/services/cfc/model/GetFunctionConfigurationResponse.java new file mode 100644 index 00000000..644085e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/GetFunctionConfigurationResponse.java @@ -0,0 +1,18 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for getting the Baidu CFC function configuration + */ +public class GetFunctionConfigurationResponse extends FunctionConfigurationResponse { +} diff --git a/src/main/java/com/baidubce/services/cfc/model/GetFunctionRequest.java b/src/main/java/com/baidubce/services/cfc/model/GetFunctionRequest.java new file mode 100644 index 00000000..b1880052 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/GetFunctionRequest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for getting a Baidu CFC function + */ +public class GetFunctionRequest extends AbstractBceRequest { + + /** + * Function Name You can specify a function name (for example, Thumbnail), or you can specify the function's BRN + * resource name (for example, brn:bce:cfc:bj:account-id:function:thumbnail:$LATEST). CFC also allows you to + * specify a partial BRN (for example, account-id:Thumbnail). Note that the BRN length is limited to 1-170. If only + * the function name is specified, the length is limited to 64 characters. + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * Use this optional parameter to specify a function version or alias. If you specify a function version, the API + * will use the qualified function BRN to request and return information about the specific CFC function version. + * If you specify an alias, the API returns information about the version of the function pointed to by the alias. + * If you don't provide this parameter, the API returns information about the CFC function $LATEST. + */ + @JsonProperty(value = "Qualifier") + private String Qualifier; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name + * @param functionName The function name + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the function qualifier + * @return The function qualifier + */ + @JsonProperty(value = "Qualifier") + public String getQualifier() { + return this.Qualifier; + } + + /** + * Set the function qualifier + * @param qualifier The function qualifier + */ + public void setQualifier(String qualifier) { + this.Qualifier = qualifier; + } + + public GetFunctionRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public GetFunctionRequest withQualifier(String qualifier) { + this.setQualifier(qualifier); + return this; + } + + /** + * (non-Javadoc) + * + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetFunctionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/GetFunctionResponse.java b/src/main/java/com/baidubce/services/cfc/model/GetFunctionResponse.java new file mode 100644 index 00000000..1e6f76cc --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/GetFunctionResponse.java @@ -0,0 +1,68 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Response object for getting a Baidu CFC function + */ +public class GetFunctionResponse extends CfcResponse { + /** + * Function code + */ + @JsonProperty(value = "Code") + private CodeStorage Code; + + /** + * Function information + */ + @JsonProperty(value = "Configuration") + private FunctionConfiguration Configuration; + + /** + * Get function code + * @return The function code + */ + @JsonProperty(value = "Code") + public CodeStorage getCode() { + return this.Code; + } + + /** + * Set the function code + * @param code The function code + */ + @JsonProperty(value = "Code") + public void setCode(CodeStorage code) { + this.Code = code; + } + + /** + * Get the function information + * @return The function information + */ + @JsonProperty(value = "Configuration") + public FunctionConfiguration getConfiguration() { + return this.Configuration; + } + + /** + * Set the function information + * @param configuration The function information + */ + @JsonProperty(value = "Configuration") + public void setConfiguration(FunctionConfiguration configuration) { + this.Configuration = configuration; + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/GetInvokeResponse.java b/src/main/java/com/baidubce/services/cfc/model/GetInvokeResponse.java new file mode 100644 index 00000000..5e7d7dcd --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/GetInvokeResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Response object for invoking a Baidu CFC function + */ +public class GetInvokeResponse extends CfcResponse { + + /** + * Represent the invoke result + */ + @JsonProperty(value = "Invoke") + private CfcInvokeResult Invoke; + + /** + * Get the invoke result + * @return The invoke result + */ + public CfcInvokeResult getInvoke() { + return Invoke; + } + + /** + * Set the invoke result + * @param invoke The invoke result + */ + public void setInvoke(CfcInvokeResult invoke) { + Invoke = invoke; + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/InvokeRequest.java b/src/main/java/com/baidubce/services/cfc/model/InvokeRequest.java new file mode 100644 index 00000000..51d4355c --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/InvokeRequest.java @@ -0,0 +1,201 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.Map; + +/** + * request object foe invoking a Baidu CFC function + */ +public class InvokeRequest extends AbstractBceRequest { + /** + * Function Name You can specify a function name (for example, Thumbnail), or you can specify the function's BRN + * resource name (for example, brn:bce:cfc:bj:account-id:function:thumbnail:$LATEST). CFC also allows you to + * specify a partial BRN (for example, account-id:Thumbnail). Note that the BRN length is limited to 1-170. If only + * the function name is specified, the length is limited to 64 characters. + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * Event (asynchronous call) returns 202/RequestResponse/DryRun. Default RequestResponse + */ + @JsonProperty(value = "InvocationType") + private String InvocationType; + + /** + * Log Type Tail / None You can set this optional parameter to Tail, provided the InvocationType parameter must be + * RequestResponse. In this example, the CFC returns the last 4KB of base64 encoded log data in the x-bce-log-result header. + */ + @JsonProperty(value = "LogType") + private String LogType; + + /** + * Use this optional parameter to specify a function version or alias. If you specify a function version, the API + * will use the qualified function BRN to request and return information about the specific CFC function version. + * If you specify an alias, the API returns information about the version of the function pointed to by the alias. + * If you don't provide this parameter, the API returns information about the CFC function $LATEST. + */ + @JsonProperty(value = "Qualifier") + private String Qualifier; + + /** + * The input parameters required by the custom function are passed in the body parameter in the json data format. + * Will call the function as input parameter + */ + @JsonProperty(value = "Payload") + private byte[] Payload; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name + * @param functionName The function name + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the invocation type + * @return The invocation type + */ + @JsonProperty(value = "InvocationType") + public String getInvocationType() { + if (this.InvocationType == null) { + this.InvocationType = "RequestResponse"; + } + return this.InvocationType; + } + + /** + * Set the invocation type + * @param invocationType The invocation type + */ + public void setInvocationType(String invocationType) { + if (invocationType == null) { + invocationType = "RequestResponse"; + } + this.InvocationType = invocationType; + } + + /** + * Get the log type + * @return The log type + */ + @JsonProperty(value = "LogType") + public String getLogType() { + return this.LogType; + } + + /** + * Set the log type + * @param logType The log type + */ + public void setLogType(String logType) { + this.LogType = logType; + } + + /** + * Get the qualifier + * @return The qualifier + */ + @JsonProperty(value = "Qualifier") + public String getQualifier() { + return this.Qualifier; + } + + /** + * Set the qualifier + * @param qualifier The qualifier + */ + public void setQualifier(String qualifier) { + this.Qualifier = qualifier; + } + + /** + * Get the payload + * @return The payload + */ + @JsonProperty(value = "Payload") + public byte[] getPayload() { + return this.Payload; + } + + /** + * Set the payload + * @param payload The payload + */ + public void setPayload(byte[] payload) { + this.Payload = payload; + } + + public InvokeRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + + public InvokeRequest withInvocationType(String invocationType) { + this.setInvocationType(invocationType); + return this; + } + + public InvokeRequest withLogType(String logType) { + this.setLogType(logType); + return this; + } + + public InvokeRequest withQualifier(String qualifier) { + this.setQualifier(qualifier); + return this; + } + + public InvokeRequest withPayload(byte[] payload) { + this.setPayload(payload); + return this; + } + + public InvokeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } + +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/InvokeResponse.java b/src/main/java/com/baidubce/services/cfc/model/InvokeResponse.java new file mode 100644 index 00000000..f4b1f7f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/InvokeResponse.java @@ -0,0 +1,65 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Response object for invoking a CFC function + */ +public class InvokeResponse extends CfcResponse { + /** + * Represent the result of invoking the user function + */ + @JsonProperty(value = "Payload") + private byte[] Payload; + + /** + * The log of invoking the user function + */ + @JsonProperty(value = "BceLogResult") + private String BceLogResult; + + /** + * Get the result of invoking the user function + * @return The result of invoking the user function + */ + @JsonProperty(value = "Payload") + public byte[] getPayload() { + return Payload; + } + + /** + * Set the result of invoking the user function + * @param payload The result of invoking the user function + */ + public void setPayload(byte[] payload) { + Payload = payload; + } + + /** + * Get the log of invoking the user function + * @return The log of invoking the user function + */ + @JsonProperty(value = "BceLogResult") + public String getBceLogResult() { + return BceLogResult; + } + + /** + * Set the log of invoking the user function + * @param bceLogResult The log of invoking the user function + */ + public void setBceLogResult(String bceLogResult) { + BceLogResult = bceLogResult; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfc/model/JsonObject.java b/src/main/java/com/baidubce/services/cfc/model/JsonObject.java new file mode 100644 index 00000000..88b5888b --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/JsonObject.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Json object + */ +public class JsonObject { + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} diff --git a/src/main/java/com/baidubce/services/cfc/model/ListAliasesRequest.java b/src/main/java/com/baidubce/services/cfc/model/ListAliasesRequest.java new file mode 100644 index 00000000..d3194404 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/ListAliasesRequest.java @@ -0,0 +1,162 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for listing aliases for the Baidu CFC function + */ +public class ListAliasesRequest extends AbstractBceRequest { + /** + * Function Name The name of the function that created the alias. Note that the length limit only applies to BRN. + * If only the function name is specified, the length is limited to 64 characters. + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * Function version If you specify this optional parameter, the API only returns an alias pointing to the specific + * CFC function version, otherwise the API will return all aliases created for the CFC function. + */ + @JsonProperty(value = "FunctionVersion") + private String FunctionVersion; + + /** + * Marker + */ + @JsonProperty(value = "Marker") + private Integer Marker; + + /** + * Max items 10000 + */ + @JsonProperty(value = "MaxItems") + private Integer MaxItems; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name + * @param functionName The function name + */ + @JsonProperty(value = "FunctionName") + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the function version + * @return The function version + */ + @JsonProperty(value = "FunctionVersion") + public String getFunctionVersion() { + return this.FunctionVersion; + } + + /** + * Set the function version + * @param functionVersion The function version + */ + @JsonProperty(value = "FunctionVersion") + public void setFunctionVersion(String functionVersion) { + this.FunctionVersion = functionVersion; + } + + /** + * Get the marker + * @return The marker + */ + @JsonProperty(value = "Marker") + public Integer getMarker() { + return this.Marker; + } + + /** + * Set the marker + * @param marker The marker + */ + @JsonProperty(value = "Marker") + public void setMarker(Integer marker) { + this.Marker = marker; + } + + /** + * Get the max items + * @return The max items + */ + @JsonProperty(value = "MaxItems") + public Integer getMaxItems() { + return this.MaxItems; + } + + /** + * Set the max items + * @param maxItems The items + */ + @JsonProperty(value = "MaxItems") + public void setMaxItems(Integer maxItems) { + this.MaxItems = maxItems; + } + + public ListAliasesRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public ListAliasesRequest withFunctionVersion(String functionVersion) { + this.setFunctionVersion(functionVersion); + return this; + } + + public ListAliasesRequest withMarker(Integer marker) { + this.setMarker(marker); + return this; + } + + public ListAliasesRequest withMaxItems(Integer maxItems) { + this.setMaxItems(maxItems); + return this; + } + + public ListAliasesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } + +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/ListAliasesResponse.java b/src/main/java/com/baidubce/services/cfc/model/ListAliasesResponse.java new file mode 100644 index 00000000..e4046a68 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/ListAliasesResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.ArrayList; +import java.util.List; + +/** + * Response object for listing the aliases for the Baidu CFC function + */ +public class ListAliasesResponse extends CfcResponse { + @JsonProperty(value = "Aliases") + private List Aliases = new ArrayList(); + + @JsonProperty(value = "Aliases") + public List getAliases() { + return this.Aliases; + } + + @JsonProperty(value = "Aliases") + public void setAliases(List aliases) { + this.Aliases = aliases; + } + + +} diff --git a/src/main/java/com/baidubce/services/cfc/model/ListFunctionsRequest.java b/src/main/java/com/baidubce/services/cfc/model/ListFunctionsRequest.java new file mode 100644 index 00000000..adc4a695 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/ListFunctionsRequest.java @@ -0,0 +1,156 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for listing the CFC functions + */ +public class ListFunctionsRequest extends AbstractBceRequest { + /** + * Specify the function version. If all functions are not specified to return the $LATEST version, the optional + * valid value ALL will return all versions, including $LATEST + */ + @JsonProperty(value = "FunctionVersion") + private String FunctionVersion; + + /** + * Marker + */ + @JsonProperty(value = "Marker") + private Integer Marker; + + /** + * 1-10000 + */ + @JsonProperty(value = "MaxItems") + private Integer MaxItems; + + /** + * Get function version. If all functions are not specified to return the $LATEST version, the optional + * valid value ALL will return all versions, including $LATEST + * @return + */ + @JsonProperty(value = "FunctionVersion") + public String getFunctionVersion() { + return this.FunctionVersion; + } + + /** + * Set function version. If all functions are not specified to return the $LATEST version, the optional + * valid value ALL will return all versions, including $LATEST + * @param functionVersion + */ + @JsonProperty(value = "FunctionVersion") + public void setFunctionVersion(String functionVersion) { + this.FunctionVersion = functionVersion; + } + + /** + * Get the marker + * @return The marker + */ + @JsonProperty(value = "Marker") + public Integer getMarker() { + return this.Marker; + } + + /** + * Set the marker + * @param marker The marker + */ + @JsonProperty(value = "Marker") + public void setMarker(Integer marker) { + this.Marker = marker; + } + + /** + * get MaxItems 1-10000 + * @return + */ + @JsonProperty(value = "MaxItems") + public Integer getMaxItems() { + return this.MaxItems; + } + + /** + * set maxItems 1-10000 + * @param maxItems 1-10000 + */ + @JsonProperty(value = "MaxItems") + public void setMaxItems(Integer maxItems) { + this.MaxItems = maxItems; + } + + /** + * Specify the function version. If all functions are not specified to return the $LATEST version, the optional + * valid value ALL will return all versions, including $LATEST + * @param functionVersion + * @return this object + */ + public ListFunctionsRequest withFunctionVersion(String functionVersion) { + this.setFunctionVersion(functionVersion); + return this; + } + + /** + * Specify the function marker + * @param marker + * @return this object + */ + public ListFunctionsRequest withMarker(Integer marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the MaxItems for the request + * + * @param maxItems 1-10000 + * @return this object + */ + public ListFunctionsRequest withMaxItems(Integer maxItems) { + this.setMaxItems(maxItems); + return this; + } + + /** + * (non-Javadoc) + * + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public ListFunctionsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/ListFunctionsResponse.java b/src/main/java/com/baidubce/services/cfc/model/ListFunctionsResponse.java new file mode 100644 index 00000000..1001e98f --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/ListFunctionsResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.ArrayList; +import java.util.List; + +/** + * Response object for listing the CFC functions + */ +public class ListFunctionsResponse extends CfcResponse { + /** + * Functions + */ + @JsonProperty(value = "Functions") + private List Functions = new ArrayList(); + + /** + * Get the function list + * @return + */ + @JsonProperty(value = "Functions") + public List getFunctions() { + return this.Functions; + } + + /** + * Set the function list + * @param functions + */ + @JsonProperty(value = "Functions") + public void setFunctions(List functions) { + this.Functions = functions; + } + +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/ListTriggersRequest.java b/src/main/java/com/baidubce/services/cfc/model/ListTriggersRequest.java new file mode 100644 index 00000000..a12e82ce --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/ListTriggersRequest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for listing triggers for the CFC function + */ +public class ListTriggersRequest extends AbstractBceRequest { + /** + * Function BRN + */ + @JsonProperty(value = "FunctionBrn") + private String FunctionBrn; + + /** + * Get the function BRN + * @return The function BRN + */ + @JsonProperty(value = "FunctionBrn") + public String getFunctionBrn() { + return this.FunctionBrn; + } + + /** + * Set the function BRN + * @param functionBrn The function BRN + */ + public void setFunctionBrn(String functionBrn) { + this.FunctionBrn = functionBrn; + } + + public ListTriggersRequest withFunctionBrn(String functionBrn) { + this.setFunctionBrn(functionBrn); + return this; + } + + public ListTriggersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/ListTriggersResponse.java b/src/main/java/com/baidubce/services/cfc/model/ListTriggersResponse.java new file mode 100644 index 00000000..4d8821f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/ListTriggersResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.ArrayList; +import java.util.List; + +/** + * Response object for listing triggers for the CFC function + */ +public class ListTriggersResponse extends CfcResponse { + + /** + * Relation + */ + @JsonProperty(value = "Relation") + private List Relation = new ArrayList(); + + /** + * Get the relation + * @return The relation + */ + @JsonProperty(value = "Relation") + public List getRelation() { + return this.Relation; + } + + /** + * Set the relation + * @param relation The relation + */ + public void setRelation(List relation) { + this.Relation = relation; + } + +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/ListVersionsByFunctionRequest.java b/src/main/java/com/baidubce/services/cfc/model/ListVersionsByFunctionRequest.java new file mode 100644 index 00000000..a8b406bc --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/ListVersionsByFunctionRequest.java @@ -0,0 +1,154 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for listing versions of the CFC function + */ +public class ListVersionsByFunctionRequest extends AbstractBceRequest { + + /** + * Specify the function version. If all functions are not specified to return the $LATEST version, the optional + * valid value ALL will return all versions, including $LATEST + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * Marker + */ + @JsonProperty(value = "Marker") + private Integer Marker; + + /** + * Max items 1-10000 + */ + @JsonProperty(value = "MaxItems") + private Integer MaxItems; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name, you can specify a function name (for example, Thumbnail), Or you can specify the BRN + * resource name of the function (for example: brn:bce:cfc:bj:account-id:function:thumbnail). CFC also allows you + * to specify a partial BRN (for example, account-id:Thumbnail). Note that the BRN length is limited to 1-140. If + * only the function name is specified, the length is limited to 64 characters. + * @param functionName The function name + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the marker + * @return The marker + */ + @JsonProperty(value = "Marker") + public Integer getMarker() { + return this.Marker; + } + + /** + * Set the marker + * @param marker The marker + */ + public void setMarker(Integer marker) { + this.Marker = marker; + } + + /** + * get MaxItems 1-10000 + * @return The MaxItems + */ + @JsonProperty(value = "MaxItems") + public Integer getMaxItems() { + return this.MaxItems; + } + + /** + * set maxItems 1-10000 + * @param maxItems 1-10000 + */ + public void setMaxItems(Integer maxItems) { + this.MaxItems = maxItems; + } + + /** + * Set the function name + * @param functionName + * @return this object + */ + public ListVersionsByFunctionRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + /** + * Set the function marker + * @param marker + * @return this object + */ + public ListVersionsByFunctionRequest withMarker(Integer marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the MaxItems for the request + * + * @param maxItems 1-10000 + * @return this object + */ + public ListVersionsByFunctionRequest withMaxItems(Integer maxItems) { + this.setMaxItems(maxItems); + return this; + } + + /** + * (non-Javadoc) + * + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public ListVersionsByFunctionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/ListVersionsByFunctionResponse.java b/src/main/java/com/baidubce/services/cfc/model/ListVersionsByFunctionResponse.java new file mode 100644 index 00000000..432f4188 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/ListVersionsByFunctionResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.ArrayList; +import java.util.List; + +/** + * Response object for listing versions of the CFC function + */ +public class ListVersionsByFunctionResponse extends CfcResponse { + /** + * Function versions + */ + @JsonProperty(value = "Versions") + private List Versions = new ArrayList(); + + /** + * Get the function version list + * @return The function version list + */ + @JsonProperty(value = "Versions") + public List getVersions() { + return this.Versions; + } + + /** + * Set the function version list + * @param versions The function version list + */ + public void setVersions(List versions) { + this.Versions = versions; + } + +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/PublishVersionRequest.java b/src/main/java/com/baidubce/services/cfc/model/PublishVersionRequest.java new file mode 100644 index 00000000..48aff85c --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/PublishVersionRequest.java @@ -0,0 +1,141 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for publishing the CFC function + */ +public class PublishVersionRequest extends AbstractBceRequest { + /** + * Function Name You can specify a function name (for example, Thumbnail), or you can specify the function's BRN + * resource name (for example: brn:bce:cfc:bj:account-id:function:thumbnail). CFC also allows you to specify a + * partial BRN (for example, account-id:Thumbnail). Note that the BRN length is limited to 1-140. If only the + * function name is specified, the length is limited to 64 characters. + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * The version description 0-256 + */ + @JsonProperty(value = "Description") + private String Description; + + /** + * The SHA256 hash of the deployment package you want to publish. This will provide verification for the code you + * posted. If you supply this parameter, the value must match the SHA256 of the latest version that was successfully + * published. + */ + @JsonProperty(value = "CodeSha256") + private String CodeSha256; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set function Name You can specify a function name (for example, Thumbnail), or you can specify the function's + * BRN resource name (for example: brn:bce:cfc:bj:account-id:function:thumbnail). CFC also allows you to specify a + * partial BRN (for example, account-id:Thumbnail). Note that the BRN length is limited to 1-140. If only the + * function name is specified, the length is limited to 64 characters. + * @param functionName + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the version description + * @return The version description + */ + @JsonProperty(value = "Description") + public String getDescription() { + return this.Description; + } + + /** + * Set the version description + * @param description The version description + */ + public void setDescription(String description) { + this.Description = description; + } + + /** + * Get the function code sha256 + * @return The function code sha256 + */ + @JsonProperty(value = "CodeSha256") + public String getCodeSha256() { + return this.CodeSha256; + } + + /** + * Set the function code sha256 + * @param codeSha256 The function code sha256 + */ + public void setCodeSha256(String codeSha256) { + this.CodeSha256 = codeSha256; + } + + public PublishVersionRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public PublishVersionRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public PublishVersionRequest withCodeSha256(String codeSha256) { + this.setCodeSha256(codeSha256); + return this; + } + + /** + * (non-Javadoc) + * + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public PublishVersionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/PublishVersionResponse.java b/src/main/java/com/baidubce/services/cfc/model/PublishVersionResponse.java new file mode 100644 index 00000000..a5505eaa --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/PublishVersionResponse.java @@ -0,0 +1,18 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for publishing a CFC function + */ +public class PublishVersionResponse extends FunctionConfigurationResponse { +} diff --git a/src/main/java/com/baidubce/services/cfc/model/Relation.java b/src/main/java/com/baidubce/services/cfc/model/Relation.java new file mode 100644 index 00000000..7410e492 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/Relation.java @@ -0,0 +1,136 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +/** + * Relation + */ +public class Relation { + /** + * Trigger ID + */ + @JsonProperty(value = "RelationId") + private String RelationId; + + /** + * policy statement-id + */ + @JsonProperty(value = "Sid") + private String Sid; + + /** + * Trigger source + */ + @JsonProperty(value = "Source") + private String Source; + + /** + * Function BRN + */ + @JsonProperty(value = "Target") + private String Target; + + /** + * Data + */ + @JsonProperty(value = "Data") + private RelationConfiguration Data; + + /** + * Get the relation Id + * @return The relation Id + */ + @JsonProperty(value = "RelationId") + public String getRelationId() { + return this.RelationId; + } + + /** + * Set the relation Id + * @param relationId The relation Id + */ + public void setRelationId(String relationId) { + this.RelationId = relationId; + } + + /** + * Get the Sid + * @return The Sid + */ + @JsonProperty(value = "Sid") + public String getSid() { + return this.Sid; + } + + /** + * Set the Sid + * @param sid The Sid + */ + public void setSid(String sid) { + this.Sid = sid; + } + + /** + * Get the source + * @return The source + */ + @JsonProperty(value = "Source") + public String getSource() { + return this.Source; + } + + /** + * Set the source + * @param source The source + */ + public void setSource(String source) { + this.Source = source; + } + + /** + * Get the target + * @return The target + */ + @JsonProperty(value = "Target") + public String getTarget() { + return this.Target; + } + + /** + * Set the target + * @param target The target + */ + public void setTarget(String target) { + this.Target = target; + } + + /** + * Get the data + * @return The data + */ + @JsonProperty(value = "Data") + public RelationConfiguration getData() { + return this.Data; + } + + /** + * Set the data + * @param data The data + */ + public void setData(RelationConfiguration data) { + this.Data = data; + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/RelationConfiguration.java b/src/main/java/com/baidubce/services/cfc/model/RelationConfiguration.java new file mode 100644 index 00000000..dcf8a7d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/RelationConfiguration.java @@ -0,0 +1,135 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represent the basic information of the trigger relation + */ +public class RelationConfiguration { + /** + * unique identifier resource of the trigger + */ + @JsonProperty(value = "Brn") + private String Brn; + + /** + * Authentication type, optional values are "anonymous" or "iam" + */ + @JsonProperty(value = "AuthType") + private String AuthType; + + /** + * Resource domain name prefix + */ + @JsonProperty(value = "EndpointPrefix") + private String EndpointPrefix; + + /** + * HTTP method, such as "GET,HEAD" + */ + @JsonProperty(value = "Method") + private String Method; + + /** + * URL + */ + @JsonProperty(value = "ResourcePath") + private String ResourcePath; + + /** + * Get the Brn + * @return The Brn + */ + @JsonProperty(value = "Brn") + public String getBrn() { + return this.Brn; + } + + /** + * Set the Brn + * @param brn The Brn + */ + public void setBrn(String brn) { + this.Brn = brn; + } + + /** + * Get the auth type + * @return The auth type + */ + @JsonProperty(value = "AuthType") + public String getAuthType() { + return this.AuthType; + } + + /** + * Set the auth type + * @param authType The auth type + */ + public void setAuthType(String authType) { + this.AuthType = authType; + } + + /** + * Get the end point prefix + * @return The end point prefix + */ + @JsonProperty(value = "EndpointPrefix") + public String getEndpointPrefix() { + return this.EndpointPrefix; + } + + /** + * Set the end point prefix + * @param endpointPrefix The end point prefix + */ + public void setEndpointPrefix(String endpointPrefix) { + this.EndpointPrefix = endpointPrefix; + } + + /** + * Get the HTTP method + * @return The HTTP method + */ + @JsonProperty(value = "Method") + public String getMethod() { + return this.Method; + } + + /** + * Set the HTTP method + * @param method The HTTP method + */ + public void setMethod(String method) { + this.Method = method; + } + + /** + * Get the resource path + * @return The resource path + */ + @JsonProperty(value = "ResourcePath") + public String getResourcePath() { + return this.ResourcePath; + } + + /** + * Set the resource path + * @param resourcePsth The resource path + */ + public void setResourcePath(String resourcePsth) { + this.ResourcePath = resourcePsth; + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/UpdateAliasRequest.java b/src/main/java/com/baidubce/services/cfc/model/UpdateAliasRequest.java new file mode 100644 index 00000000..b698ac88 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/UpdateAliasRequest.java @@ -0,0 +1,154 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for updating the alias of the CFC function + */ +public class UpdateAliasRequest extends AbstractBceRequest { + /** + * Function name + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * Alias name + */ + @JsonProperty(value = "AliasName") + private String AliasName; + /** + * The version which the alias point to (($LATEST|[0-9]+) + */ + @JsonProperty(value = "FunctionVersion") + private String FunctionVersion; + + /** + * Alias description + */ + @JsonProperty(value = "Description") + private String Description; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name + * @param functionName The function name + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the alias name + * @return The alias name + */ + @JsonProperty(value = "AliasName") + public String getAliasName() { + return this.AliasName; + } + + /** + * Set the alias name + * @param aliasName The alias name + */ + public void setAliasName(String aliasName) { + this.AliasName = aliasName; + } + + /** + * Get the function version + * @return The function version + */ + @JsonProperty(value = "FunctionVersion") + public String getFunctionVersion() { + return this.FunctionVersion; + } + + /** + * Set the function version + * @param functionVersion The function version + */ + public void setFunctionVersion(String functionVersion) { + this.FunctionVersion = functionVersion; + } + + /** + * Get the alias description + * @return The alias description + */ + @JsonProperty(value = "Description") + public String getDescription() { + return this.Description; + } + + /** + * Set the alias description + * @param description The alias description + */ + public void setDescription(String description) { + this.Description = description; + } + + public UpdateAliasRequest withAliasName(String aliasName) { + this.setAliasName(aliasName); + return this; + } + + public UpdateAliasRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public UpdateAliasRequest withFunctionVersion(String functionVersion) { + this.setFunctionVersion(functionVersion); + return this; + } + + public UpdateAliasRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public UpdateAliasRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/UpdateAliasResponse.java b/src/main/java/com/baidubce/services/cfc/model/UpdateAliasResponse.java new file mode 100644 index 00000000..26dedcb5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/UpdateAliasResponse.java @@ -0,0 +1,19 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for updating the alias + */ +public class UpdateAliasResponse extends AliasConfigurationResponse { + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionCodeRequest.java b/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionCodeRequest.java new file mode 100644 index 00000000..454da6ae --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionCodeRequest.java @@ -0,0 +1,162 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for updating the CFC function code + */ +public class UpdateFunctionCodeRequest extends AbstractBceRequest { + /** + * Function Name You can specify a function name (for example, Thumbnail), or you can specify the function's BRN + * resource name (for example, brn:bce:cfc:bj:account-id:function:thumbnail). CFC also allows you to specify a + * partial BRN (for example, account-id:Thumbnail). Note that the BRN length is limited to 1-140. If only the + * function name is specified, the length is limited to 64 characters. + */ + @JsonProperty(value = "FunctionName") + private String FunctionName; + + /** + * The base64-encoded of the zip package you want to publish Note that the zip package compresses the contents of + * the directory, not the directory itself. + */ + @JsonProperty(value = "ZipFile") + private String ZipFile; + + /** + * Whether to publish directly + */ + @JsonProperty(value = "Publish") + private boolean Publish; + + /** + * This Boolean parameter can be used to test your request for CFC to update the CFC function and publish a version + * as an atomic operation. It will do all the necessary calculations and validations for your code, but will not + * upload it or release a version. Each time the operation is called, the CodeSha256 hash value of the supplied + * code is also evaluated and returned in the response. Not yet supported + */ + @JsonProperty(value = "DryRun") + private boolean DryRun; + + /** + * Get the function name + * @return The function name + */ + @JsonProperty(value = "FunctionName") + public String getFunctionName() { + return this.FunctionName; + } + + /** + * Set the function name + * @param functionName The function name + */ + public void setFunctionName(String functionName) { + this.FunctionName = functionName; + } + + /** + * Get the function code zip + * @return The function code zip + */ + @JsonProperty(value = "ZipFile") + public String getZipFile() { + return this.ZipFile; + } + + /** + * Set the function code zip + * @param zipFile The function code zip + */ + public void setZipFile(String zipFile) { + this.ZipFile = zipFile; + } + + /** + * Get the publish + * @return The publish + */ + @JsonProperty(value = "Publish") + public boolean getPublish() { + return this.Publish; + } + + /** + * Set the publish + * @param publish The publish + */ + public void setPublish(boolean publish) { + this.Publish = publish; + } + + /** + * Get the dryrun + * @return The dryrun + */ + @JsonProperty(value = "DryRun") + public boolean getDryRun() { + return this.DryRun; + } + + /** + * Set the dryrun + * @param dryRun The dryrun + */ + public void setDryRun(boolean dryRun) { + this.DryRun = dryRun; + } + + public UpdateFunctionCodeRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public UpdateFunctionCodeRequest withZipFile(String zipFile) { + this.setZipFile(zipFile); + return this; + } + + public UpdateFunctionCodeRequest withPublish(boolean publish) { + this.setPublish(publish); + return this; + } + + public UpdateFunctionCodeRequest withDryRun(boolean dryRun) { + this.setDryRun(dryRun); + return this; + } + + public UpdateFunctionCodeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionCodeResponse.java b/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionCodeResponse.java new file mode 100644 index 00000000..01f63dd6 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionCodeResponse.java @@ -0,0 +1,18 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for updating the CFC function code + */ +public class UpdateFunctionCodeResponse extends FunctionConfigurationResponse { +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionConfigurationRequest.java b/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionConfigurationRequest.java new file mode 100644 index 00000000..4930d66c --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionConfigurationRequest.java @@ -0,0 +1,239 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +/** + * Request object for updating the CFC function configuration + */ +public class UpdateFunctionConfigurationRequest extends GenericFunctionRequest { + /** + * Function code + */ + @JsonProperty(value = "Code") + private Code Code; + + /** + * Environment + */ + @JsonProperty(value = "Environment") + private Environment Environment; + + /** + * The entry function of the CFC call, for the module is module-name.export eg. index.handler maximum length limit + * is 128 + */ + @JsonProperty(value = "Handler") + private String Handler; + + /** + * The size of the memory, in megabytes, that CFC uses to estimate the amount of CPU and memory allocated to the + * user function. The default value is 128MB, which must be a multiple of 128MB (now CFC provides 128 to 1024M of + * memory) + */ + @JsonProperty(value = "MemorySize") + private Integer MemorySize; + + /** + * Runtime nodejs6.11 nodejs8.5 python2 java8 + */ + @JsonProperty(value = "Runtime") + private String Runtime; + + /** + * Timeout 1-300,max timeout is 300 + */ + @JsonProperty(value = "Timeout") + private Integer Timeout; + + /** + * Get the function code + * @return The function code + */ + @JsonProperty(value = "Code") + public Code getCode() { + return this.Code; + } + + /** + * Set the function code + * @param code The function code + */ + public void setCode(Code code) { + this.Code = code; + } + + /** + * Get the environment + * @return The environment + */ + @JsonProperty(value = "Environment") + public Environment getEnvironment() { + return this.Environment; + } + + /** + * Set the environment + * @param environment The environment + */ + public void setEnvironment(Environment environment) { + this.Environment = environment; + } + + /** + * Get the entry function of the CFC call, for the module is module-name.export eg. index.handler maximum length + * limit is 128 + * @return + */ + @JsonProperty(value = "Handler") + public String getHandler() { + return this.Handler; + } + + /** + * Set the entry function of the CFC call, for the module is module-name.export eg. index.handler maximum length + * limit is 128 + * + * @param handler The entry function of the CFC call, for the module is module-name.export eg. index.handler + * maximum length limit is 128 + */ + public void setHandler(String handler) { + this.Handler = handler; + } + + /** + * Get the size of the memory, in megabytes, that CFC uses to estimate the amount of CPU and memory allocated to + * the user function. The default value is 128MB, which must be a multiple of 128MB (now CFC provides 128 to 1024M + * of memory) + * @return + */ + @JsonProperty(value = "MemorySize") + public Integer getMemorySize() { + return this.MemorySize; + } + + /** + * Set the size of the memory, in megabytes, that CFC uses to estimate the amount of CPU and memory allocated to + * the user function. The default value is 128MB, which must be a multiple of 128MB (now CFC provides 128 to 1024M + * of memory) + * @param memorySize The size of the memory, in megabytes, that CFC uses to estimate the amount of CPU and memory + * allocated to the user function. The default value is 128MB, which must be a multiple of 128MB + * (now CFC provides 128 to 1024M of memory) + */ + public void setMemorySize(Integer memorySize) { + this.MemorySize = memorySize; + } + + /** + * Get the runtime + * @return The runtime + */ + @JsonProperty(value = "Runtime") + public String getRuntime() { + return this.Runtime; + } + + /** + * Set the runtime + * @param runtime The runtime + */ + public void setRuntime(String runtime) { + this.Runtime = runtime; + } + + /** + * Get the timeout + * @return The timeout + */ + @JsonProperty(value = "Timeout") + public Integer getTimeout() { + return this.Timeout; + } + + /** + * Set the timeout + * @param timeout The timeout + */ + public void setTimeout(Integer timeout) { + this.Timeout = timeout; + } + + public UpdateFunctionConfigurationRequest(String functionName, String description) { + + super(functionName, description); + } + + public UpdateFunctionConfigurationRequest withFunctionName(String functionName) { + this.setFunctionName(functionName); + return this; + } + + public UpdateFunctionConfigurationRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public UpdateFunctionConfigurationRequest withCode(Code code) { + this.setCode(code); + return this; + } + + public UpdateFunctionConfigurationRequest withEnvironment(Environment environment) { + this.setEnvironment(environment); + return this; + } + + public UpdateFunctionConfigurationRequest withHandler(String handler) { + this.setHandler(handler); + return this; + } + + public UpdateFunctionConfigurationRequest withMemorySize(Integer memorySize) { + this.setMemorySize(memorySize); + return this; + } + + public UpdateFunctionConfigurationRequest withRuntime(String runtime) { + this.setRuntime(runtime); + return this; + } + + public UpdateFunctionConfigurationRequest withTimeout(Integer timeout) { + this.setTimeout(timeout); + return this; + } + + public UpdateFunctionConfigurationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } + +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionConfigurationResponse.java b/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionConfigurationResponse.java new file mode 100644 index 00000000..5ae7dcf5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/UpdateFunctionConfigurationResponse.java @@ -0,0 +1,18 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +/** + * Response object for updating the CFC function configuration + */ +public class UpdateFunctionConfigurationResponse extends FunctionConfigurationResponse { +} diff --git a/src/main/java/com/baidubce/services/cfc/model/UpdateTriggerRequest.java b/src/main/java/com/baidubce/services/cfc/model/UpdateTriggerRequest.java new file mode 100644 index 00000000..53843a27 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/UpdateTriggerRequest.java @@ -0,0 +1,157 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.Map; + +/** + * Request object for updating the trigger + */ +public class UpdateTriggerRequest extends AbstractBceRequest { + /** + * Trigger ID + */ + @JsonProperty(value = "RelationId") + private String RelationId; + + /** + * Function BRN + */ + @JsonProperty(value = "Target") + private String Target; + + /** + * Trigger source + */ + @JsonProperty(value = "Source") + private String Source; + + /** + * Trigger parameter configuration + */ + @JsonProperty(value = "Data") + private Map Data; + + /** + * Get the relation Id + * @return The relation Id + */ + @JsonProperty(value = "RelationId") + public String getRelationId() { + return this.RelationId; + } + + /** + * Set the relation Id + * @param relationId The relation Id + */ + public void setRelationId(String relationId) { + this.RelationId = relationId; + } + + /** + * Get the target + * @return The target + */ + @JsonProperty(value = "Target") + public String getTarget() { + return this.Target; + } + + /** + * Set the target + * @param target The target + */ + public void setTarget(String target) { + this.Target = target; + } + + /** + * Get the source + * @return The source + */ + @JsonProperty(value = "Source") + public String getSource() { + return this.Source; + } + + /** + * Set the source + * @param source The source + */ + public void setSource(String source) { + this.Source = source; + } + + /** + * Get the data + * @return The data + */ + @JsonProperty(value = "Data") + public Map getDate() { + return this.Data; + } + + /** + * Set the data + * @param data The data + */ + public void setData(Map data) { + this.Data = data; + } + + public UpdateTriggerRequest withRelationId(String relationId) { + this.setRelationId(relationId); + return this; + } + + public UpdateTriggerRequest withTarget(String target) { + this.setTarget(target); + return this; + } + + public UpdateTriggerRequest withSource(String source) { + this.setSource(source); + return this; + } + + public UpdateTriggerRequest withData(Map data) { + this.setData(data); + return this; + } + + public UpdateTriggerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + try { + return JsonUtils.toJsonPrettyString(this); + } catch (JsonProcessingException e) { + return ""; + } + } +} + diff --git a/src/main/java/com/baidubce/services/cfc/model/UpdateTriggerResponse.java b/src/main/java/com/baidubce/services/cfc/model/UpdateTriggerResponse.java new file mode 100644 index 00000000..c1dc894e --- /dev/null +++ b/src/main/java/com/baidubce/services/cfc/model/UpdateTriggerResponse.java @@ -0,0 +1,45 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfc.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Response for updating the trigger + */ +public class UpdateTriggerResponse extends CfcResponse { + + /** + * Relation + */ + @JsonProperty(value = "Relation") + private Relation Relation; + + /** + * Get the relation + * @return The relation + */ + @JsonProperty(value = "Relation") + public Relation getRelation() { + return this.Relation; + } + + /** + * Set the relation + * @param relation The relation + */ + public void setRelation(Relation relation) { + this.Relation = relation; + } + +} + diff --git a/src/main/java/com/baidubce/services/cfs/v2/CfsClient.java b/src/main/java/com/baidubce/services/cfs/v2/CfsClient.java new file mode 100644 index 00000000..730b6f9c --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/CfsClient.java @@ -0,0 +1,238 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2; + +import java.util.Map; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.common.ApiInfo; +import com.baidubce.common.BaseBceClient; +import com.baidubce.common.BaseBceResponse; +import com.baidubce.common.BceRegion; +import com.baidubce.internal.InternalRequest; +import com.baidubce.services.cfs.v2.api.CfsApi; +import com.baidubce.services.cfs.v2.model.CreateFSRequest; +import com.baidubce.services.cfs.v2.model.CreateFSResponse; +import com.baidubce.services.cfs.v2.model.CreateMountTargetRequest; +import com.baidubce.services.cfs.v2.model.CreateMountTargetResponse; +import com.baidubce.services.cfs.v2.model.DescribeFsRequest; +import com.baidubce.services.cfs.v2.model.DescribeFsResponse; +import com.baidubce.services.cfs.v2.model.DescribeMountTargetRequest; +import com.baidubce.services.cfs.v2.model.DescribeMountTargetResponse; +import com.baidubce.services.cfs.v2.model.DropFsRequest; +import com.baidubce.services.cfs.v2.model.GetFsQuotaResponse; +import com.baidubce.services.cfs.v2.model.UpdateFsRequest; +import com.google.common.collect.ImmutableMap; +import com.baidubce.BceClientException; + + +/** + * Cfs + */ +public class CfsClient extends BaseBceClient { + + private static final Map ENDPOINTS = ImmutableMap.builder() + .put(BceRegion.DEFAULT, "http://cfs.bj.baidubce.com") + .put(BceRegion.BJ, "http://cfs.bj.baidubce.com") + .put(BceRegion.BD, "http://cfs.bd.baidubce.com") + .put(BceRegion.SU, "http://cfs.su.baidubce.com") + .put(BceRegion.GZ, "http://cfs.gz.baidubce.com") + .put(BceRegion.FWH, "http://cfs.fwh.baidubce.com") + .put(BceRegion.HKG, "http://cfs.hkg.baidubce.com") + .build(); + + /** + * Service name for extra config and handler. + */ + private static final String SERVICE_ID = "Cfs"; + + /** + * Constructs a new client to invoke service methods on demo with region. + */ + public CfsClient(String ak, String sk, BceRegion region) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(region)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public CfsClient(String ak, String sk) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(BceRegion.DEFAULT)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public CfsClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Api lists + */ + private static final Map CFS_APIS = CfsApi.getApis(); + + /** + * 创建文件系统 + * + * @param body + * @return CreateFSResponse + */ + public CreateFSResponse createFS(CreateFSRequest body) { + ApiInfo apiInfo = new ApiInfo(CFS_APIS.get("createFS")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreateFSResponse.class); + } + + /** + * * 给创建一个文件系统的挂载点,返回domain。 * 付费方式为后付费。 + * + * @param fsId 待创建MountTarget的FileSystem的ID + * @param body + * @return CreateMountTargetResponse + */ + public CreateMountTargetResponse createMountTarget(String fsId, CreateMountTargetRequest body) { + ApiInfo apiInfo = new ApiInfo(CFS_APIS.get("createMountTarget")); + String apiPath = apiInfo.getPath() + .withPathParameter("fsId", fsId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreateMountTargetResponse.class); + } + + /** + * 释放指定的FileSystem的MountTarget + * + * @param fsId 待释放的target的FileSystem的ID + * @param mountId 待释放的target的ID + */ + public void deleteMountTarget(String fsId, String mountId) { + ApiInfo apiInfo = new ApiInfo(CFS_APIS.get("deleteMountTarget")); + String apiPath = apiInfo.getPath() + .withPathParameter("fsId", fsId) + .withPathParameter("mountId", mountId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 查询用户账户下的所有FileSystem信息。 支持按fsId、userId,匹配规则支持部分包含。 返回结果是多重查询条件的交集 结果支持marker分页,分页大小默认为1000,可通过maxKeys参数指定 + * + * @param userId 要查询文件系统所属的用户ID + * @param fsId 要查询的FileSystem ID + * @param marker 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + * @param maxKeys 每页包含的最大数量,最大数量不超过1000。缺省值为1000 + * @param body + * @return DescribeFsResponse + */ + public DescribeFsResponse describeFs(DescribeFsRequest body, String userId, String fsId, String marker, + Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(CFS_APIS.get("describeFs")); + String apiPath = apiInfo.getPath().get(); + + if (userId.length() == 0 && fsId.length() == 0) { + throw new BceClientException("Invalid request, userId or fsId should not be empty"); + } + if (userId.length() != 0) { + apiInfo.getQueries().put("userId", userId); + } + if (fsId.length() != 0 ) { + apiInfo.getQueries().put("fsId", fsId); + } + if (marker.length() != 0) { + apiInfo.getQueries().put("marker", marker); + } + if (maxKeys > 0) { + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + } + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + + return invokeHttpClient(internalRequest, DescribeFsResponse.class); + } + + /** + * * 查询指定文件系统下的所有MountTarget信息。 * 返回结果是多重查询条件的交集 * 结果支持marker分页,分页大小默认为1000,可通过maxKeys参数指定 + * + * @param fsId + * @param mountId 要查询的MountTarget的ID + * @param marker 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + * @param maxKeys 每页包含的最大数量,最大数量不超过1000。缺省值为1000 + * @param body + * @return DescribeMountTargetResponse + */ + public DescribeMountTargetResponse describeMountTarget(String fsId, DescribeMountTargetRequest body, + String mountId, String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(CFS_APIS.get("describeMountTarget")); + String apiPath = apiInfo.getPath() + .withPathParameter("fsId", fsId).get(); + if (mountId.length() != 0) { + apiInfo.getQueries().put("mountId", mountId); + } + if (marker.length() != 0) { + apiInfo.getQueries().put("marker", marker); + } + if (maxKeys > 0) { + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + } + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, DescribeMountTargetResponse.class); + } + + /** + * 释放指定的FileSystem,被释放的FileSystem超过回收时间后会被永远删除,无法找回 + * + * @param fsId 待释放的FileSystem的ID + * @param body + */ + public void dropFs(String fsId, DropFsRequest body) { + ApiInfo apiInfo = new ApiInfo(CFS_APIS.get("dropFs")); + String apiPath = apiInfo.getPath() + .withPathParameter("fsId", fsId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 获取文件系统quota + * + * @return GetFsQuotaResponse + */ + public GetFsQuotaResponse getFsQuota() { + ApiInfo apiInfo = new ApiInfo(CFS_APIS.get("getFsQuota")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetFsQuotaResponse.class); + } + + /** + * 更新一个filesystem的配置信息。 + * + * @param fsId 待更新的FileSystem的ID + * @param body + */ + public void updateFs(String fsId, UpdateFsRequest body) { + ApiInfo apiInfo = new ApiInfo(CFS_APIS.get("updateFs")); + String apiPath = apiInfo.getPath() + .withPathParameter("fsId", fsId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/cfs/v2/api/CfsApi.java b/src/main/java/com/baidubce/services/cfs/v2/api/CfsApi.java new file mode 100644 index 00000000..941927dd --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/api/CfsApi.java @@ -0,0 +1,85 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.api; + +import java.util.HashMap; +import java.util.Map; + +import com.baidubce.common.ApiInfo; +import com.baidubce.common.ApiPath; +import com.baidubce.http.HttpMethodName; + +public class CfsApi { + /** + * Api list with api name + */ + private static Map apis = new HashMap(); + + public static Map getApis() { + // 创建文件系统 + apis.put("createFS", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/cfs"), + new HashMap(), + new HashMap())); + // * 给创建一个文件系统的挂载点,返回domain。 * 付费方式为后付费。 + apis.put("createMountTarget", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/cfs/[fsId]"), + new HashMap(), + new HashMap())); + // 释放指定的FileSystem的MountTarget + apis.put("deleteMountTarget", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/cfs/[fsId]/[mountId]"), + new HashMap(), + new HashMap())); + // 查询用户账户下的所有FileSystem信息。 支持按fsId、userId,匹配规则支持部分包含。 返回结果是多重查询条件的交集 结果支持marker分页,分页大小默认为1000,可通过maxKeys参数指定 + apis.put("describeFs", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/cfs"), + new HashMap() { + { + } + }, + new HashMap())); + // * 查询指定文件系统下的所有MountTarget信息。 * 返回结果是多重查询条件的交集 * 结果支持marker分页,分页大小默认为1000,可通过maxKeys参数指定 + apis.put("describeMountTarget", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/cfs/[fsId]"), + new HashMap() { + { + } + }, + new HashMap())); + // 释放指定的FileSystem,被释放的FileSystem超过回收时间后会被永远删除,无法找回 + apis.put("dropFs", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/cfs/[fsId]"), + new HashMap(), + new HashMap())); + // 获取文件系统quota + apis.put("getFsQuota", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/cfs/quota"), + new HashMap(), + new HashMap())); + // 更新一个filesystem的配置信息。 + apis.put("updateFs", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/cfs/[fsId]"), + new HashMap(), + new HashMap())); + return apis; + } +} diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/CreateFSRequest.java b/src/main/java/com/baidubce/services/cfs/v2/model/CreateFSRequest.java new file mode 100644 index 00000000..15e5b6a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/CreateFSRequest.java @@ -0,0 +1,96 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateFSRequest extends BaseBceRequest { + /** + * FileSystem的名称,方便记忆。长度1~65个字节,字母开头,可包含字母数字-_/.字符。 + */ + private String fsName; + + /** + * 文件系统类型:1.cap(性能型),默认性能型 + */ + private String type; + + /** + * 协议类型:1.nfs 2.smb,默认nfs协议 + */ + private String protocal; + + /** + * vpcId + */ + private String vpcId; + + /** + * zone + */ + private String zone; + + public void setFsName(String fsName) { + this.fsName = fsName; + } + + public String getFsName() { + return this.fsName; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setProtocal(String protocal) { + this.protocal = protocal; + } + + public String getProtocal() { + return this.protocal; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getVpcId() { + return this.vpcId; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public String getZone() { + return this.zone; + } + + @Override + public String toString() { + return "CreateFSRequest{" + + "fsName=" + fsName + "\n" + + "type=" + type + "\n" + + "protocal=" + protocal + "\n" + + "vpcId=" + vpcId + "\n" + + "zone=" + zone + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/CreateFSResponse.java b/src/main/java/com/baidubce/services/cfs/v2/model/CreateFSResponse.java new file mode 100644 index 00000000..d111a53f --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/CreateFSResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateFSResponse extends BaseBceResponse { + /** + * fsId + */ + private String fsId; + + public void setFsId(String fsId) { + this.fsId = fsId; + } + + public String getFsId() { + return this.fsId; + } + + @Override + public String toString() { + return "CreateFSResponse{" + + "fsId=" + fsId + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/CreateMountTargetRequest.java b/src/main/java/com/baidubce/services/cfs/v2/model/CreateMountTargetRequest.java new file mode 100644 index 00000000..c4acd45d --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/CreateMountTargetRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateMountTargetRequest extends BaseBceRequest { + /** + * MountTarget所属子网,subnet属于fs所在vpc,为短id + */ + private String subnetId; + + /** + * fs实例vip所属VPC的短Id + */ + private String vpcId; + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getSubnetId() { + return this.subnetId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getVpcId() { + return this.vpcId; + } + + @Override + public String toString() { + return "CreateMountTargetRequest{" + + "subnetId=" + subnetId + "\n" + + "vpcId=" + vpcId + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/CreateMountTargetResponse.java b/src/main/java/com/baidubce/services/cfs/v2/model/CreateMountTargetResponse.java new file mode 100644 index 00000000..3a37e633 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/CreateMountTargetResponse.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateMountTargetResponse extends BaseBceResponse { + /** + * mount点的ID + */ + private String mountId; + + /** + * 分配的服务dns,通过此dns执行文件系统挂载,即可访问服务 + */ + private String domain; + + public void setMountId(String mountId) { + this.mountId = mountId; + } + + public String getMountId() { + return this.mountId; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getDomain() { + return this.domain; + } + + @Override + public String toString() { + return "CreateMountTargetResponse{" + + "mountId=" + mountId + "\n" + + "domain=" + domain + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/DescribeFsRequest.java b/src/main/java/com/baidubce/services/cfs/v2/model/DescribeFsRequest.java new file mode 100644 index 00000000..dc1ddceb --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/DescribeFsRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DescribeFsRequest extends BaseBceRequest { + @Override + public String toString() { + return "DescribeFsRequest{" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/DescribeFsResponse.java b/src/main/java/com/baidubce/services/cfs/v2/model/DescribeFsResponse.java new file mode 100644 index 00000000..8624ace9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/DescribeFsResponse.java @@ -0,0 +1,224 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DescribeFsResponse extends BaseBceResponse { + /** + * 包含查询结果的列表 + */ + private List fileSystemList; + + /** + * 标记查询的起始位置,若结果列表为空,此项不存在 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页结果包含的数量 + */ + private Integer maxKeys; + + public void setFileSystemList(List fileSystemList) { + this.fileSystemList = fileSystemList; + } + + public List getFileSystemList() { + return this.fileSystemList; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + @Override + public String toString() { + return "DescribeFsResponse{" + + "fileSystemList=" + fileSystemList + "\n" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "}"; + } + + public static class FileSystemModel { + private String fsId; + + private String fsName; + + private String type; + + private String protocol; + + private String vpcId; + + private List mountTargetList; + + private String status; + + public void setFsId(String fsId) { + this.fsId = fsId; + } + + public String getFsId() { + return this.fsId; + } + + public void setFsName(String fsName) { + this.fsName = fsName; + } + + public String getFsName() { + return this.fsName; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getProtocol() { + return this.protocol; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getVpcId() { + return this.vpcId; + } + + public void setMountTargetList(List mountTargetList) { + this.mountTargetList = mountTargetList; + } + + public List getMountTargetList() { + return this.mountTargetList; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + @Override + public String toString() { + return "FileSystemModel{" + + "fsId=" + fsId + "\n" + + "fsName=" + fsName + "\n" + + "type=" + type + "\n" + + "protocol=" + protocol + "\n" + + "vpcId=" + vpcId + "\n" + + "mountTargetList=" + mountTargetList + "\n" + + "status=" + status + "\n" + + "}"; + } + + public static class MountTargetModel { + private String subnetId; + + private String domain; + + private String mountId; + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getSubnetId() { + return this.subnetId; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getDomain() { + return this.domain; + } + + public void setMountId(String mountId) { + this.mountId = mountId; + } + + public String getMountId() { + return this.mountId; + } + + @Override + public String toString() { + return "MountTargetModel{" + + "subnetId=" + subnetId + "\n" + + "domain=" + domain + "\n" + + "mountId=" + mountId + "\n" + + "}"; + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/DescribeMountTargetRequest.java b/src/main/java/com/baidubce/services/cfs/v2/model/DescribeMountTargetRequest.java new file mode 100644 index 00000000..170abcbb --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/DescribeMountTargetRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DescribeMountTargetRequest extends BaseBceRequest { + @Override + public String toString() { + return "DescribeMountTargetRequest{" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/DescribeMountTargetResponse.java b/src/main/java/com/baidubce/services/cfs/v2/model/DescribeMountTargetResponse.java new file mode 100644 index 00000000..ccd66a11 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/DescribeMountTargetResponse.java @@ -0,0 +1,139 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DescribeMountTargetResponse extends BaseBceResponse { + /** + * 标记查询的起始位置,若结果列表为空,此项不存在 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private Integer maxKeys; + + /** + * mountTargetList + */ + private List mountTargetList; + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + public void setMountTargetList(List mountTargetList) { + this.mountTargetList = mountTargetList; + } + + public List getMountTargetList() { + return this.mountTargetList; + } + + @Override + public String toString() { + return "DescribeMountTargetResponse{" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "mountTargetList=" + mountTargetList + "\n" + + "}"; + } + + public static class MountTargetModel { + private String subnetId; + + private String domain; + + private String mountId; + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getSubnetId() { + return this.subnetId; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getDomain() { + return this.domain; + } + + public void setMountId(String mountId) { + this.mountId = mountId; + } + + public String getMountId() { + return this.mountId; + } + + @Override + public String toString() { + return "MountTargetModel{" + + "subnetId=" + subnetId + "\n" + + "domain=" + domain + "\n" + + "mountId=" + mountId + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/DropFsRequest.java b/src/main/java/com/baidubce/services/cfs/v2/model/DropFsRequest.java new file mode 100644 index 00000000..c8a13c19 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/DropFsRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DropFsRequest extends BaseBceRequest { + @Override + public String toString() { + return "DropFsRequest{" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/GetFsQuotaResponse.java b/src/main/java/com/baidubce/services/cfs/v2/model/GetFsQuotaResponse.java new file mode 100644 index 00000000..36337555 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/GetFsQuotaResponse.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetFsQuotaResponse extends BaseBceResponse { + /** + * total + */ + private Integer total; + + /** + * created + */ + private Integer created; + + public void setTotal(Integer total) { + this.total = total; + } + + public Integer getTotal() { + return this.total; + } + + public void setCreated(Integer created) { + this.created = created; + } + + public Integer getCreated() { + return this.created; + } + + @Override + public String toString() { + return "GetFsQuotaResponse{" + + "total=" + total + "\n" + + "created=" + created + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfs/v2/model/UpdateFsRequest.java b/src/main/java/com/baidubce/services/cfs/v2/model/UpdateFsRequest.java new file mode 100644 index 00000000..acfdc9fb --- /dev/null +++ b/src/main/java/com/baidubce/services/cfs/v2/model/UpdateFsRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cfs.v2.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateFsRequest extends BaseBceRequest { + /** + * FileSystem的名称,方便记忆。长度1~65个字节,字母开头,可包含字母数字-_/.字符。 + */ + private String fsName; + + public void setFsName(String fsName) { + this.fsName = fsName; + } + + public String getFsName() { + return this.fsName; + } + + @Override + public String toString() { + return "UpdateFsRequest{" + + "fsName=" + fsName + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/CfwClient.java b/src/main/java/com/baidubce/services/cfw/CfwClient.java new file mode 100644 index 00000000..434875a5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/CfwClient.java @@ -0,0 +1,312 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw; + +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.common.ApiInfo; +import com.baidubce.common.BaseBceClient; +import com.baidubce.common.BaseBceResponse; +import com.baidubce.common.BceRegion; +import com.baidubce.internal.InternalRequest; +import com.baidubce.services.cfw.api.CfwApi; +import com.baidubce.services.cfw.model.BindCfwRequest; +import com.baidubce.services.cfw.model.CreateCfwRequest; +import com.baidubce.services.cfw.model.CreateCfwResponse; +import com.baidubce.services.cfw.model.CreateCfwRuleRequest; +import com.baidubce.services.cfw.model.DeleteCfwRuleRequest; +import com.baidubce.services.cfw.model.DisableCfwRequest; +import com.baidubce.services.cfw.model.EnableCfwRequest; +import com.baidubce.services.cfw.model.GetCfwResponse; +import com.baidubce.services.cfw.model.ListCfwRequest; +import com.baidubce.services.cfw.model.ListCfwResponse; +import com.baidubce.services.cfw.model.ListInstanceRequest; +import com.baidubce.services.cfw.model.UnbindCfwRequest; +import com.baidubce.services.cfw.model.UpdateCfwRequest; +import com.baidubce.services.cfw.model.ListInstanceResponse; +import com.baidubce.services.cfw.model.UpdateCfwRuleRequest; +import com.google.common.collect.ImmutableMap; + +/** + * Cfw + */ +public class CfwClient extends BaseBceClient { + /** + * endpoint + */ + private static final Map ENDPOINTS = ImmutableMap.builder() + .put(BceRegion.DEFAULT, "cfw.baidubce.com") + .build(); + + /** + * API version + */ + private static final String VERSION = "1"; + + /** + * Service name for extra config and handler. + */ + private static final String SERVICE_ID = "Cfw"; + + /** + * Constructs a new client to invoke service methods on demo with region. + */ + public CfwClient(String ak, String sk, BceRegion region) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(region)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public CfwClient(String ak, String sk) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(BceRegion.DEFAULT)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public CfwClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Api lists + */ + private static final Map CFW_APIS = CfwApi.getApis(); + + /** + * 批量实例绑定CFW策略。 - 没有规则的CFW不能绑定到实例 + * + * @param cfwId CFW的id + * @param body + */ + public void bindCfw(String cfwId, BindCfwRequest body) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("bindCfw")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 创建CFW策略。 + * + * @param body + * @return CreateCfwResponse + */ + public CreateCfwResponse createCfw(CreateCfwRequest body) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("createCfw")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreateCfwResponse.class); + } + + /** + * 批量创建CFW中防护规则。 + * - 五元组(protocol/sourceAddress/destAddress/sourcePort/destPort) + 方向(direction)不能全部相同。 + * - 一次最多创建100条规则。 + * + * @param cfwId CFW的id + * @param body + */ + public void createCfwRule(String cfwId, CreateCfwRuleRequest body) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("createCfwRule")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 删除指定CFW策略。 - CFW存在绑定关系时不允许删除 + * + * @param cfwId CFW的id + */ + public void deleteCfw(String cfwId) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("deleteCfw")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 批量删除指定CFW中某些规则。 - CFW已绑定到实例时,至少保留一条规则。 + * + * @param cfwId CFW的id + * @param body + */ + public void deleteCfwRule(String cfwId, DeleteCfwRuleRequest body) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("deleteCfwRule")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 已绑定CFW的实例,使用该接口临时关闭CFW的防护功能。 + * + * @param cfwId CFW的id + * @param body + */ + public void disableCfw(String cfwId, DisableCfwRequest body) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("disableCfw")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 已绑定CFW并且临时关闭了防护功能的实例,使用该接口恢复CFW的防护功能。 + * + * @param cfwId CFW的id + * @param body + */ + public void enableCfw(String cfwId, EnableCfwRequest body) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("enableCfw")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 查询指定CFW策略的详情信息。 + * + * @param cfwId CFW的id + * @return GetCfwResponse + */ + public GetCfwResponse getCfw(String cfwId) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("getCfw")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetCfwResponse.class); + } + + /** + * 查询CFW策略列表信息。 + * + * @param listCfwRequest + * @return ListCfwResponse + */ + public ListCfwResponse listCfw(ListCfwRequest listCfwRequest) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("listCfw")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION).get(); + if (StringUtils.isNotBlank(listCfwRequest.getMarker())) { + apiInfo.getQueries().put("marker", listCfwRequest.getMarker()); + } + if (listCfwRequest.getMaxKeys() != null) { + apiInfo.getQueries().put("maxKeys", String.valueOf(listCfwRequest.getMaxKeys())); + } + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListCfwResponse.class); + } + + /** + * 查询防护边界实例的列表。 + * + * @param listInstanceRequest + * @return ListInstanceResponse + */ + public ListInstanceResponse listInstance(ListInstanceRequest listInstanceRequest) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("listInstance")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION).get(); + if (StringUtils.isBlank(listInstanceRequest.getInstanceType())) { + throw new BceClientException("InstanceType cannot be empty!"); + } + apiInfo.getQueries().put("instanceType", listInstanceRequest.getInstanceType()); + if (StringUtils.isNotBlank(listInstanceRequest.getMarker())) { + apiInfo.getQueries().put("marker", listInstanceRequest.getMarker()); + } + if (StringUtils.isNotBlank(listInstanceRequest.getStatus())) { + apiInfo.getQueries().put("status", listInstanceRequest.getStatus()); + } + if (StringUtils.isNotBlank(listInstanceRequest.getRegion())) { + apiInfo.getQueries().put("region", listInstanceRequest.getRegion()); + } + if (listInstanceRequest.getMaxKeys() != null) { + apiInfo.getQueries().put("maxKeys", String.valueOf(listInstanceRequest.getMaxKeys())); + } + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListInstanceResponse.class); + } + + /** + * 实例批量解绑CFW。 + * + * @param cfwId CFW的id + * @param body + */ + public void unbindCfw(String cfwId, UnbindCfwRequest body) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("unbindCfw")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 更新CFW策略的基本信息。 + * + * @param cfwId CFW的id + * @param body + */ + public void updateCfw(String cfwId, UpdateCfwRequest body) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("updateCfw")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 修改指定CFW规则。 - 五元组(protocol/sourceAddress/destAddress/sourcePort/destPort) + 方向(direction)不能全部相同。 + * + * @param cfwId CFW策略的id + * @param cfwRuleId CFW规则的id + * @param body + */ + public void updateCfwRule(String cfwId, String cfwRuleId, UpdateCfwRuleRequest body) { + ApiInfo apiInfo = new ApiInfo(CFW_APIS.get("updateCfwRule")); + String apiPath = apiInfo.getPath() + .withPathParameter("version", VERSION) + .withPathParameter("cfwId", cfwId) + .withPathParameter("cfwRuleId", cfwRuleId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/cfw/api/CfwApi.java b/src/main/java/com/baidubce/services/cfw/api/CfwApi.java new file mode 100644 index 00000000..7b093ccf --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/api/CfwApi.java @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.api; + +import java.util.HashMap; +import java.util.Map; + +import com.baidubce.common.ApiInfo; +import com.baidubce.common.ApiPath; +import com.baidubce.http.HttpMethodName; + +public class CfwApi { + /** + * Api list with api name + */ + private static Map apis = new HashMap(); + + public static Map getApis() { + // 批量实例绑定CFW策略。 - 没有规则的CFW不能绑定到实例 + apis.put("bindCfw", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v[version]/cfw/[cfwId]"), + new HashMap(){ + { + put("bind", ""); + } + }, + new HashMap())); + // 创建CFW策略。 + apis.put("createCfw", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v[version]/cfw"), + new HashMap(), + new HashMap())); + // 批量创建CFW中防护规则。 - 五元组(protocol/sourceAddress/destAddress/sourcePort/destPort) + 方向(direction)不能全部相同。 - 一次最多创建100条规则。 + apis.put("createCfwRule", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v[version]/cfw/[cfwId]/rule"), + new HashMap(), + new HashMap())); + // 删除指定CFW策略。 - CFW存在绑定关系时不允许删除 + apis.put("deleteCfw", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v[version]/cfw/[cfwId]"), + new HashMap(), + new HashMap())); + // 批量删除指定CFW中某些规则。 - CFW已绑定到实例时,至少保留一条规则。 + apis.put("deleteCfwRule", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v[version]/cfw/[cfwId]/delete/rule"), + new HashMap(), + new HashMap())); + // 已绑定CFW的实例,使用该接口临时关闭CFW的防护功能。 + apis.put("disableCfw", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v[version]/cfw/[cfwId]"), + new HashMap(){ + { + put("off", ""); + } + }, + new HashMap())); + // 已绑定CFW并且临时关闭了防护功能的实例,使用该接口恢复CFW的防护功能。 + apis.put("enableCfw", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v[version]/cfw/[cfwId]"), + new HashMap(){ + { + put("on", ""); + } + }, + new HashMap())); + // 查询指定CFW策略的详情信息。 + apis.put("getCfw", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v[version]/cfw/[cfwId]"), + new HashMap(), + new HashMap())); + // 查询CFW策略列表信息。 + apis.put("listCfw", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v[version]/cfw"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // 查询防护边界实例的列表。 + apis.put("listInstance", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v[version]/cfw/instance"), + new HashMap() { + { + put("instanceType", null); + put("marker", null); + put("maxKeys", null); + put("status", null); + put("region", null); + } + }, + new HashMap())); + // 实例批量解绑CFW。 + apis.put("unbindCfw", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v[version]/cfw/[cfwId]"), + new HashMap(){ + { + put("unbind", ""); + } + }, + new HashMap())); + // 更新CFW策略的基本信息。 + apis.put("updateCfw", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v[version]/cfw/[cfwId]"), + new HashMap(), + new HashMap())); + // 修改指定CFW规则。 - 五元组(protocol/sourceAddress/destAddress/sourcePort/destPort) + 方向(direction)不能全部相同。 + apis.put("updateCfwRule", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v[version]/cfw/[cfwId]/rule/[cfwRuleId]"), + new HashMap(), + new HashMap())); + return apis; + } +} diff --git a/src/main/java/com/baidubce/services/cfw/model/BindCfwRequest.java b/src/main/java/com/baidubce/services/cfw/model/BindCfwRequest.java new file mode 100644 index 00000000..d85ffe59 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/BindCfwRequest.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class BindCfwRequest extends BaseBceRequest { + /** + * 实例类型,取值 [ eip | nat | etGateway | peerconn | csn | ipv6Gateway ] + */ + private String instanceType; + + /** + * 绑定实例信息 + */ + private List instances; + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public String getInstanceType() { + return this.instanceType; + } + + public void setInstances(List instances) { + this.instances = instances; + } + + public List getInstances() { + return this.instances; + } + + @Override + public String toString() { + return "BindCfwRequest{" + + "instanceType=" + instanceType + "\n" + + "instances=" + instances + "\n" + + "}"; + } + + public static class CfwBind { + private String region; + + private String instanceId; + + private String role; + + private String memberId; + + public void setRegion(String region) { + this.region = region; + } + + public String getRegion() { + return this.region; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceId() { + return this.instanceId; + } + + public void setRole(String role) { + this.role = role; + } + + public String getRole() { + return this.role; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getMemberId() { + return this.memberId; + } + + @Override + public String toString() { + return "CfwBind{" + + "region=" + region + "\n" + + "instanceId=" + instanceId + "\n" + + "role=" + role + "\n" + + "memberId=" + memberId + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/CreateCfwRequest.java b/src/main/java/com/baidubce/services/cfw/model/CreateCfwRequest.java new file mode 100644 index 00000000..89d5513a --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/CreateCfwRequest.java @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateCfwRequest extends BaseBceRequest { + /** + * CFW名称,长度不超过65个字符,可由数字、字符、下划线组成 + */ + private String name; + + /** + * CFW描述,不超过200字符 + */ + private String description; + + /** + * CFW规则 + */ + private List cfwRules; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCfwRules(List cfwRules) { + this.cfwRules = cfwRules; + } + + public List getCfwRules() { + return this.cfwRules; + } + + @Override + public String toString() { + return "CreateCfwRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "cfwRules=" + cfwRules + "\n" + + "}"; + } + + public static class CreateRule { + private Integer ipVersion; + + private Integer priority; + + private String protocol; + + private String direction; + + private String sourceAddress; + + private String destAddress; + + private String sourcePort; + + private String destPort; + + private String action; + + private String description; + + public void setIpVersion(Integer ipVersion) { + this.ipVersion = ipVersion; + } + + public Integer getIpVersion() { + return this.ipVersion; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getProtocol() { + return this.protocol; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getDirection() { + return this.direction; + } + + public void setSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + } + + public String getSourceAddress() { + return this.sourceAddress; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getDestAddress() { + return this.destAddress; + } + + public void setSourcePort(String sourcePort) { + this.sourcePort = sourcePort; + } + + public String getSourcePort() { + return this.sourcePort; + } + + public void setDestPort(String destPort) { + this.destPort = destPort; + } + + public String getDestPort() { + return this.destPort; + } + + public void setAction(String action) { + this.action = action; + } + + public String getAction() { + return this.action; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "CreateRule{" + + "ipVersion=" + ipVersion + "\n" + + "priority=" + priority + "\n" + + "protocol=" + protocol + "\n" + + "direction=" + direction + "\n" + + "sourceAddress=" + sourceAddress + "\n" + + "destAddress=" + destAddress + "\n" + + "sourcePort=" + sourcePort + "\n" + + "destPort=" + destPort + "\n" + + "action=" + action + "\n" + + "description=" + description + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/CreateCfwResponse.java b/src/main/java/com/baidubce/services/cfw/model/CreateCfwResponse.java new file mode 100644 index 00000000..495f1a3e --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/CreateCfwResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateCfwResponse extends BaseBceResponse { + /** + * CFW的id + */ + private String cfwId; + + public void setCfwId(String cfwId) { + this.cfwId = cfwId; + } + + public String getCfwId() { + return this.cfwId; + } + + @Override + public String toString() { + return "CreateCfwResponse{" + + "cfwId=" + cfwId + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/CreateCfwRuleRequest.java b/src/main/java/com/baidubce/services/cfw/model/CreateCfwRuleRequest.java new file mode 100644 index 00000000..5a1fa685 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/CreateCfwRuleRequest.java @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateCfwRuleRequest extends BaseBceRequest { + /** + * CFW规则列表 + */ + private List cfwRules; + + public void setCfwRules(List cfwRules) { + this.cfwRules = cfwRules; + } + + public List getCfwRules() { + return this.cfwRules; + } + + @Override + public String toString() { + return "CreateCfwRuleRequest{" + + "cfwRules=" + cfwRules + "\n" + + "}"; + } + + public static class CreateRule { + private Integer ipVersion; + + private Integer priority; + + private String protocol; + + private String direction; + + private String sourceAddress; + + private String destAddress; + + private String sourcePort; + + private String destPort; + + private String action; + + private String description; + + public void setIpVersion(Integer ipVersion) { + this.ipVersion = ipVersion; + } + + public Integer getIpVersion() { + return this.ipVersion; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getProtocol() { + return this.protocol; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getDirection() { + return this.direction; + } + + public void setSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + } + + public String getSourceAddress() { + return this.sourceAddress; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getDestAddress() { + return this.destAddress; + } + + public void setSourcePort(String sourcePort) { + this.sourcePort = sourcePort; + } + + public String getSourcePort() { + return this.sourcePort; + } + + public void setDestPort(String destPort) { + this.destPort = destPort; + } + + public String getDestPort() { + return this.destPort; + } + + public void setAction(String action) { + this.action = action; + } + + public String getAction() { + return this.action; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "CreateRule{" + + "ipVersion=" + ipVersion + "\n" + + "priority=" + priority + "\n" + + "protocol=" + protocol + "\n" + + "direction=" + direction + "\n" + + "sourceAddress=" + sourceAddress + "\n" + + "destAddress=" + destAddress + "\n" + + "sourcePort=" + sourcePort + "\n" + + "destPort=" + destPort + "\n" + + "action=" + action + "\n" + + "description=" + description + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/DeleteCfwRuleRequest.java b/src/main/java/com/baidubce/services/cfw/model/DeleteCfwRuleRequest.java new file mode 100644 index 00000000..9f4f738f --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/DeleteCfwRuleRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeleteCfwRuleRequest extends BaseBceRequest { + /** + * 批量删除的CFW规则id + */ + private List cfwRuleIds; + + public void setCfwRuleIds(List cfwRuleIds) { + this.cfwRuleIds = cfwRuleIds; + } + + public List getCfwRuleIds() { + return this.cfwRuleIds; + } + + @Override + public String toString() { + return "DeleteCfwRuleRequest{" + + "cfwRuleIds=" + cfwRuleIds + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/DisableCfwRequest.java b/src/main/java/com/baidubce/services/cfw/model/DisableCfwRequest.java new file mode 100644 index 00000000..cad6049a --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/DisableCfwRequest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DisableCfwRequest extends BaseBceRequest { + /** + * 防护实例的id + */ + private String instanceId; + + /** + * PEERCONN实例特有属性,实例角色,取值 [ acceptor | initiatorn ],当实例为PEERCONN时,该值必填 + */ + private String role; + + /** + * CSN实例特有属性,CSN中网络实例id,当实例为CSN时,该值必填 + */ + private String memberId; + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceId() { + return this.instanceId; + } + + public void setRole(String role) { + this.role = role; + } + + public String getRole() { + return this.role; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getMemberId() { + return this.memberId; + } + + @Override + public String toString() { + return "DisableCfwRequest{" + + "instanceId=" + instanceId + "\n" + + "role=" + role + "\n" + + "memberId=" + memberId + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/EnableCfwRequest.java b/src/main/java/com/baidubce/services/cfw/model/EnableCfwRequest.java new file mode 100644 index 00000000..58725a9b --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/EnableCfwRequest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class EnableCfwRequest extends BaseBceRequest { + /** + * 防护实例的id + */ + private String instanceId; + + /** + * PEERCONN实例特有属性,实例角色,取值[ acceptor | initiatorn ],当实例为PEERCONN时,该值必填 + */ + private String role; + + /** + * CSN实例特有属性,CSN中网络实例id,当实例为CSN时,该值必填 + */ + private String memberId; + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceId() { + return this.instanceId; + } + + public void setRole(String role) { + this.role = role; + } + + public String getRole() { + return this.role; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getMemberId() { + return this.memberId; + } + + @Override + public String toString() { + return "EnableCfwRequest{" + + "instanceId=" + instanceId + "\n" + + "role=" + role + "\n" + + "memberId=" + memberId + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/GetCfwResponse.java b/src/main/java/com/baidubce/services/cfw/model/GetCfwResponse.java new file mode 100644 index 00000000..5403839e --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/GetCfwResponse.java @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetCfwResponse extends BaseBceResponse { + /** + * CFW的id + */ + private String cfwId; + + /** + * CFW的名称 + */ + private String name; + + /** + * CFW的描述 + */ + private String description; + + /** + * CFW的创建时间,标准UTC时间 + */ + private String createdTime; + + /** + * CFW绑定实例的数量 + */ + private Integer bindInstanceNum; + + /** + * CFW规则 + */ + private List cfwRules; + + public void setCfwId(String cfwId) { + this.cfwId = cfwId; + } + + public String getCfwId() { + return this.cfwId; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + public String getCreatedTime() { + return this.createdTime; + } + + public void setBindInstanceNum(Integer bindInstanceNum) { + this.bindInstanceNum = bindInstanceNum; + } + + public Integer getBindInstanceNum() { + return this.bindInstanceNum; + } + + public void setCfwRules(List cfwRules) { + this.cfwRules = cfwRules; + } + + public List getCfwRules() { + return this.cfwRules; + } + + @Override + public String toString() { + return "GetCfwResponse{" + + "cfwId=" + cfwId + "\n" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "createdTime=" + createdTime + "\n" + + "bindInstanceNum=" + bindInstanceNum + "\n" + + "cfwRules=" + cfwRules + "\n" + + "}"; + } + + public static class CfwRule { + private Integer ipVersion; + + private Integer priority; + + private String protocol; + + private String direction; + + private String sourceAddress; + + private String destAddress; + + private String sourcePort; + + private String destPort; + + private String action; + + private String description; + + private String cfwId; + + private String cfwRuleId; + + public void setIpVersion(Integer ipVersion) { + this.ipVersion = ipVersion; + } + + public Integer getIpVersion() { + return this.ipVersion; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getProtocol() { + return this.protocol; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getDirection() { + return this.direction; + } + + public void setSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + } + + public String getSourceAddress() { + return this.sourceAddress; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getDestAddress() { + return this.destAddress; + } + + public void setSourcePort(String sourcePort) { + this.sourcePort = sourcePort; + } + + public String getSourcePort() { + return this.sourcePort; + } + + public void setDestPort(String destPort) { + this.destPort = destPort; + } + + public String getDestPort() { + return this.destPort; + } + + public void setAction(String action) { + this.action = action; + } + + public String getAction() { + return this.action; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCfwId(String cfwId) { + this.cfwId = cfwId; + } + + public String getCfwId() { + return this.cfwId; + } + + public void setCfwRuleId(String cfwRuleId) { + this.cfwRuleId = cfwRuleId; + } + + public String getCfwRuleId() { + return this.cfwRuleId; + } + + @Override + public String toString() { + return "CfwRule{" + + "ipVersion=" + ipVersion + "\n" + + "priority=" + priority + "\n" + + "protocol=" + protocol + "\n" + + "direction=" + direction + "\n" + + "sourceAddress=" + sourceAddress + "\n" + + "destAddress=" + destAddress + "\n" + + "sourcePort=" + sourcePort + "\n" + + "destPort=" + destPort + "\n" + + "action=" + action + "\n" + + "description=" + description + "\n" + + "cfwId=" + cfwId + "\n" + + "cfwRuleId=" + cfwRuleId + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/ListCfwRequest.java b/src/main/java/com/baidubce/services/cfw/model/ListCfwRequest.java new file mode 100644 index 00000000..c580dca4 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/ListCfwRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListCfwRequest { + /** + * 批量获取列表查询的起始位置,是一个由系统生成的字符串 + */ + private String marker; + /** + * 每页包含的最大数量,最大数量通常不超过1000,缺省值为1000 + */ + private Integer maxKeys; + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public Integer getMaxKeys() { + return maxKeys; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } +} diff --git a/src/main/java/com/baidubce/services/cfw/model/ListCfwResponse.java b/src/main/java/com/baidubce/services/cfw/model/ListCfwResponse.java new file mode 100644 index 00000000..7f5d47eb --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/ListCfwResponse.java @@ -0,0 +1,303 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListCfwResponse extends BaseBceResponse { + /** + * 标记查询的起始位置 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private Integer maxKeys; + + /** + * CFW列表 + */ + private List cfws; + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + public void setCfws(List cfws) { + this.cfws = cfws; + } + + public List getCfws() { + return this.cfws; + } + + @Override + public String toString() { + return "ListCfwResponse{" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "cfws=" + cfws + "\n" + + "}"; + } + + public static class Cfw { + private String cfwId; + + private String name; + + private String description; + + private String createdTime; + + private Integer bindInstanceNum; + + private List cfwRules; + + public void setCfwId(String cfwId) { + this.cfwId = cfwId; + } + + public String getCfwId() { + return this.cfwId; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + public String getCreatedTime() { + return this.createdTime; + } + + public void setBindInstanceNum(Integer bindInstanceNum) { + this.bindInstanceNum = bindInstanceNum; + } + + public Integer getBindInstanceNum() { + return this.bindInstanceNum; + } + + public void setCfwRules(List cfwRules) { + this.cfwRules = cfwRules; + } + + public List getCfwRules() { + return this.cfwRules; + } + + @Override + public String toString() { + return "Cfw{" + + "cfwId=" + cfwId + "\n" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "createdTime=" + createdTime + "\n" + + "bindInstanceNum=" + bindInstanceNum + "\n" + + "cfwRules=" + cfwRules + "\n" + + "}"; + } + + public static class CfwRule { + private Integer ipVersion; + + private Integer priority; + + private String protocol; + + private String direction; + + private String sourceAddress; + + private String destAddress; + + private String sourcePort; + + private String destPort; + + private String action; + + private String description; + + private String cfwId; + + private String cfwRuleId; + + public void setIpVersion(Integer ipVersion) { + this.ipVersion = ipVersion; + } + + public Integer getIpVersion() { + return this.ipVersion; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getProtocol() { + return this.protocol; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getDirection() { + return this.direction; + } + + public void setSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + } + + public String getSourceAddress() { + return this.sourceAddress; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getDestAddress() { + return this.destAddress; + } + + public void setSourcePort(String sourcePort) { + this.sourcePort = sourcePort; + } + + public String getSourcePort() { + return this.sourcePort; + } + + public void setDestPort(String destPort) { + this.destPort = destPort; + } + + public String getDestPort() { + return this.destPort; + } + + public void setAction(String action) { + this.action = action; + } + + public String getAction() { + return this.action; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCfwId(String cfwId) { + this.cfwId = cfwId; + } + + public String getCfwId() { + return this.cfwId; + } + + public void setCfwRuleId(String cfwRuleId) { + this.cfwRuleId = cfwRuleId; + } + + public String getCfwRuleId() { + return this.cfwRuleId; + } + + @Override + public String toString() { + return "CfwRule{" + + "ipVersion=" + ipVersion + "\n" + + "priority=" + priority + "\n" + + "protocol=" + protocol + "\n" + + "direction=" + direction + "\n" + + "sourceAddress=" + sourceAddress + "\n" + + "destAddress=" + destAddress + "\n" + + "sourcePort=" + sourcePort + "\n" + + "destPort=" + destPort + "\n" + + "action=" + action + "\n" + + "description=" + description + "\n" + + "cfwId=" + cfwId + "\n" + + "cfwRuleId=" + cfwRuleId + "\n" + + "}"; + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/ListInstanceRequest.java b/src/main/java/com/baidubce/services/cfw/model/ListInstanceRequest.java new file mode 100644 index 00000000..775b2505 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/ListInstanceRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListInstanceRequest { + /** + * 实例类型,取值[ eip | nat | etGateway | peerconn | csn | ipv6Gateway ] + */ + private String instanceType; + /** + * 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + */ + private String marker; + /** + * 每页包含的最大数量,最大数量通常不超过1000,缺省值为1000 + */ + private Integer maxKeys; + /** + * 防护状态,取值 [ unbound | protected | unprotected ] + */ + private String status; + /** + * 地域信息,取值 [ bj | gz | su | fsh | hkg | bd | fwh | sin ] + */ + private String region; + + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public Integer getMaxKeys() { + return maxKeys; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } +} diff --git a/src/main/java/com/baidubce/services/cfw/model/ListInstanceResponse.java b/src/main/java/com/baidubce/services/cfw/model/ListInstanceResponse.java new file mode 100644 index 00000000..bba7aef7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/ListInstanceResponse.java @@ -0,0 +1,295 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListInstanceResponse extends BaseBceResponse { + /** + * 标记查询的起始位置 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private Integer maxKeys; + + /** + * 防护实例列表 + */ + private List instances; + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + public void setInstances(List instances) { + this.instances = instances; + } + + public List getInstances() { + return this.instances; + } + + @Override + public String toString() { + return "ListInstanceResponse{" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "instances=" + instances + "\n" + + "}"; + } + + public static class Instance { + private String instanceId; + + private String instanceName; + + private String status; + + private String region; + + private String cfwId; + + private String cfwName; + + private String vpcId; + + private String vpcName; + + private String publicIp; + + private String role; + + private String localIfId; + + private String localIfName; + + private String peerRegion; + + private String peerVpcId; + + private String peerVpcName; + + private String memberId; + + private String memberName; + + private String memberAccountId; + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceId() { + return this.instanceId; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getInstanceName() { + return this.instanceName; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getRegion() { + return this.region; + } + + public void setCfwId(String cfwId) { + this.cfwId = cfwId; + } + + public String getCfwId() { + return this.cfwId; + } + + public void setCfwName(String cfwName) { + this.cfwName = cfwName; + } + + public String getCfwName() { + return this.cfwName; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getVpcId() { + return this.vpcId; + } + + public void setVpcName(String vpcName) { + this.vpcName = vpcName; + } + + public String getVpcName() { + return this.vpcName; + } + + public void setPublicIp(String publicIp) { + this.publicIp = publicIp; + } + + public String getPublicIp() { + return this.publicIp; + } + + public void setRole(String role) { + this.role = role; + } + + public String getRole() { + return this.role; + } + + public void setLocalIfId(String localIfId) { + this.localIfId = localIfId; + } + + public String getLocalIfId() { + return this.localIfId; + } + + public void setLocalIfName(String localIfName) { + this.localIfName = localIfName; + } + + public String getLocalIfName() { + return this.localIfName; + } + + public void setPeerRegion(String peerRegion) { + this.peerRegion = peerRegion; + } + + public String getPeerRegion() { + return this.peerRegion; + } + + public void setPeerVpcId(String peerVpcId) { + this.peerVpcId = peerVpcId; + } + + public String getPeerVpcId() { + return this.peerVpcId; + } + + public void setPeerVpcName(String peerVpcName) { + this.peerVpcName = peerVpcName; + } + + public String getPeerVpcName() { + return this.peerVpcName; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getMemberId() { + return this.memberId; + } + + public void setMemberName(String memberName) { + this.memberName = memberName; + } + + public String getMemberName() { + return this.memberName; + } + + public void setMemberAccountId(String memberAccountId) { + this.memberAccountId = memberAccountId; + } + + public String getMemberAccountId() { + return this.memberAccountId; + } + + @Override + public String toString() { + return "Instance{" + + "instanceId=" + instanceId + "\n" + + "instanceName=" + instanceName + "\n" + + "status=" + status + "\n" + + "region=" + region + "\n" + + "cfwId=" + cfwId + "\n" + + "cfwName=" + cfwName + "\n" + + "vpcId=" + vpcId + "\n" + + "vpcName=" + vpcName + "\n" + + "publicIp=" + publicIp + "\n" + + "role=" + role + "\n" + + "localIfId=" + localIfId + "\n" + + "localIfName=" + localIfName + "\n" + + "peerRegion=" + peerRegion + "\n" + + "peerVpcId=" + peerVpcId + "\n" + + "peerVpcName=" + peerVpcName + "\n" + + "memberId=" + memberId + "\n" + + "memberName=" + memberName + "\n" + + "memberAccountId=" + memberAccountId + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/UnbindCfwRequest.java b/src/main/java/com/baidubce/services/cfw/model/UnbindCfwRequest.java new file mode 100644 index 00000000..1a63b99d --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/UnbindCfwRequest.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UnbindCfwRequest extends BaseBceRequest { + /** + * 实例类型,取值[ eip | nat | etGateway | peerconn | csn | ipv6Gateway ] + */ + private String instanceType; + + /** + * 解绑实例信息 + */ + private List instances; + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public String getInstanceType() { + return this.instanceType; + } + + public void setInstances(List instances) { + this.instances = instances; + } + + public List getInstances() { + return this.instances; + } + + @Override + public String toString() { + return "UnbindCfwRequest{" + + "instanceType=" + instanceType + "\n" + + "instances=" + instances + "\n" + + "}"; + } + + public static class CfwBind { + private String region; + + private String instanceId; + + private String role; + + private String memberId; + + public void setRegion(String region) { + this.region = region; + } + + public String getRegion() { + return this.region; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceId() { + return this.instanceId; + } + + public void setRole(String role) { + this.role = role; + } + + public String getRole() { + return this.role; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getMemberId() { + return this.memberId; + } + + @Override + public String toString() { + return "CfwBind{" + + "region=" + region + "\n" + + "instanceId=" + instanceId + "\n" + + "role=" + role + "\n" + + "memberId=" + memberId + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/UpdateCfwRequest.java b/src/main/java/com/baidubce/services/cfw/model/UpdateCfwRequest.java new file mode 100644 index 00000000..75f6a9c9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/UpdateCfwRequest.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateCfwRequest extends BaseBceRequest { + /** + * CFW名称,长度不超过65个字符,可由数字、字符、下划线组成 + */ + private String name; + + /** + * CFW描述,不超过200字符 + */ + private String description; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "UpdateCfwRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cfw/model/UpdateCfwRuleRequest.java b/src/main/java/com/baidubce/services/cfw/model/UpdateCfwRuleRequest.java new file mode 100644 index 00000000..602d51ff --- /dev/null +++ b/src/main/java/com/baidubce/services/cfw/model/UpdateCfwRuleRequest.java @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2022 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.cfw.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateCfwRuleRequest extends BaseBceRequest { + /** + * IP协议类型,取值 [ 4 | 6 ] + */ + private Integer ipVersion; + + /** + * 规则优先级,取值 [ 1-1000 ] + */ + private Integer priority; + + /** + * 协议类型,取值 [ TCP | UDP | ICMP | ALL ] + */ + private String protocol; + + /** + * 方向,取值 [ in | out ] + */ + private String direction; + + /** + * 源IP,0.0.0.0/0表示所有 + */ + private String sourceAddress; + + /** + * 目的IP,0.0.0.0/0表示所有 + */ + private String destAddress; + + /** + * 源端口,0-65535表示所有 + */ + private String sourcePort; + + /** + * 目的端口,0-65535表示所有 + */ + private String destPort; + + /** + * 策略,取值 [ allow | deny ] + */ + private String action; + + /** + * CFW规则的描述 + */ + private String description; + + public void setIpVersion(Integer ipVersion) { + this.ipVersion = ipVersion; + } + + public Integer getIpVersion() { + return this.ipVersion; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getProtocol() { + return this.protocol; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getDirection() { + return this.direction; + } + + public void setSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + } + + public String getSourceAddress() { + return this.sourceAddress; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getDestAddress() { + return this.destAddress; + } + + public void setSourcePort(String sourcePort) { + this.sourcePort = sourcePort; + } + + public String getSourcePort() { + return this.sourcePort; + } + + public void setDestPort(String destPort) { + this.destPort = destPort; + } + + public String getDestPort() { + return this.destPort; + } + + public void setAction(String action) { + this.action = action; + } + + public String getAction() { + return this.action; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "UpdateCfwRuleRequest{" + + "ipVersion=" + ipVersion + "\n" + + "priority=" + priority + "\n" + + "protocol=" + protocol + "\n" + + "direction=" + direction + "\n" + + "sourceAddress=" + sourceAddress + "\n" + + "destAddress=" + destAddress + "\n" + + "sourcePort=" + sourcePort + "\n" + + "destPort=" + destPort + "\n" + + "action=" + action + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cnap/CnapClient.java b/src/main/java/com/baidubce/services/cnap/CnapClient.java new file mode 100644 index 00000000..8fd744d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/CnapClient.java @@ -0,0 +1,1261 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap; + +import static com.baidubce.services.cnap.model.access.CreateAccessModel.CLUSTER_NETWORK; +import static com.baidubce.services.cnap.model.access.CreateAccessModel.PUBLIC_NETWORK; +import static com.baidubce.services.cnap.model.application.ApplicationModel.DEFAULT_DEPLOY_TYPE; +import static com.baidubce.services.cnap.model.application.WorkloadType.MICROSERVICE_APPLICATION; +import static com.baidubce.services.cnap.model.application.WorkloadType.SIMPLE_APPLICATION; +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.services.cnap.model.workspace.GetWorkspaceNameRequest; +import com.baidubce.services.cnap.model.workspace.GetWorkspaceNameResponse; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cnap.handler.CnapHttpResponseHandler; +import com.baidubce.services.cnap.model.access.CreateAccessModel; +import com.baidubce.services.cnap.model.access.CreateAccessRequest; +import com.baidubce.services.cnap.model.access.CreateAccessResponse; +import com.baidubce.services.cnap.model.access.DeleteAccessRequest; +import com.baidubce.services.cnap.model.access.DeleteAccessResponse; +import com.baidubce.services.cnap.model.access.ListAccessRequest; +import com.baidubce.services.cnap.model.access.ListAccessResponse; +import com.baidubce.services.cnap.model.access.NewAccessModel; +import com.baidubce.services.cnap.model.application.CreateApplicationRequest; +import com.baidubce.services.cnap.model.application.CreateApplicationResponse; +import com.baidubce.services.cnap.model.application.DeleteApplicationRequest; +import com.baidubce.services.cnap.model.application.DeleteApplicationResponse; +import com.baidubce.services.cnap.model.application.ListApplicationRequest; +import com.baidubce.services.cnap.model.application.ListApplicationResponse; +import com.baidubce.services.cnap.model.cluster.BindClusterToWorkspaceRequest; +import com.baidubce.services.cnap.model.cluster.BindClusterToWorkspaceResponse; +import com.baidubce.services.cnap.model.cluster.ImportClusterRequest; +import com.baidubce.services.cnap.model.cluster.ImportClusterResponse; +import com.baidubce.services.cnap.model.cluster.ReleaseClusterRequest; +import com.baidubce.services.cnap.model.cluster.ReleaseClusterResponse; +import com.baidubce.services.cnap.model.cluster.UnbindClusterToWorkspaceRequest; +import com.baidubce.services.cnap.model.cluster.UnbindClusterToWorkspaceResponse; +import com.baidubce.services.cnap.model.deploygroup.ContainerModel; +import com.baidubce.services.cnap.model.deploygroup.CreateDeployGroupRequest; +import com.baidubce.services.cnap.model.deploygroup.CreateDeployGroupResponse; +import com.baidubce.services.cnap.model.deploygroup.DeleteDeployGroupRequest; +import com.baidubce.services.cnap.model.deploygroup.DeleteDeployGroupResponse; +import com.baidubce.services.cnap.model.deploygroup.DeployGroupType; +import com.baidubce.services.cnap.model.deploygroup.GetDeployGroupRequest; +import com.baidubce.services.cnap.model.deploygroup.GetDeployGroupResponse; +import com.baidubce.services.cnap.model.deploygroup.ListDeployGroupByImageRequest; +import com.baidubce.services.cnap.model.deploygroup.ListDeployGroupByImageResponse; +import com.baidubce.services.cnap.model.deploygroup.ListDeployGroupByPageRequest; +import com.baidubce.services.cnap.model.deploygroup.ListDeployGroupByPageResponse; +import com.baidubce.services.cnap.model.deploygroup.NewDeployGroupModel; +import com.baidubce.services.cnap.model.deploygroup.ScaleDeployGroupRequest; +import com.baidubce.services.cnap.model.deploygroup.ScaleDeployGroupResponse; +import com.baidubce.services.cnap.model.deploygroup.UpdateDeployGroupRequest; +import com.baidubce.services.cnap.model.deploygroup.UpdateDeployGroupResponse; +import com.baidubce.services.cnap.model.environment.BindClusterToEnvironmentRequest; +import com.baidubce.services.cnap.model.environment.BindClusterToEnvironmentResponse; +import com.baidubce.services.cnap.model.environment.CreateEnvironmentRequest; +import com.baidubce.services.cnap.model.environment.CreateEnvironmentResponse; +import com.baidubce.services.cnap.model.environment.DeleteEnvironmentReponse; +import com.baidubce.services.cnap.model.environment.DeleteEnvironmentRequest; +import com.baidubce.services.cnap.model.environment.ListEnvironmentRequest; +import com.baidubce.services.cnap.model.environment.ListEnvironmentResponse; +import com.baidubce.services.cnap.model.environment.UnbindClusterToEnvironmentRequest; +import com.baidubce.services.cnap.model.environment.UnbindClusterToEnvironmentResponse; +import com.baidubce.services.cnap.model.environment.UpdateEnvironmentRequest; +import com.baidubce.services.cnap.model.environment.UpdateEnvironmentResponse; +import com.baidubce.services.cnap.model.monitoring.CreateAlertRulesRequest; +import com.baidubce.services.cnap.model.monitoring.CreateAlertRulesResponse; +import com.baidubce.services.cnap.model.monitoring.DeleteAlertRulesRequest; +import com.baidubce.services.cnap.model.monitoring.DeleteAlertRulesResponse; +import com.baidubce.services.cnap.model.monitoring.GetMonitorDataRequest; +import com.baidubce.services.cnap.model.monitoring.GetMonitorDataResponse; +import com.baidubce.services.cnap.model.monitoring.ListAlertRecordResponse; +import com.baidubce.services.cnap.model.monitoring.ListAlertRulesRequest; +import com.baidubce.services.cnap.model.monitoring.ListAlertRulesResponse; +import com.baidubce.services.cnap.model.monitoring.ListAlertRecordRequest; +import com.baidubce.services.cnap.model.monitoring.UpdateAlertRulesRequest; +import com.baidubce.services.cnap.model.monitoring.UpdateAlertRulesResponse; +import com.baidubce.services.cnap.model.releaserecord.CreateReleaseRecordRequest; +import com.baidubce.services.cnap.model.releaserecord.CreateReleaseRecordResponse; +import com.baidubce.services.cnap.model.releaserecord.GetReleaseRecordProgressRequest; +import com.baidubce.services.cnap.model.releaserecord.GetReleaseRecordProgressResponse; +import com.baidubce.services.cnap.model.releaserecord.ListReleaseRecordRequest; +import com.baidubce.services.cnap.model.releaserecord.ListReleaseRecordResponse; +import com.baidubce.services.cnap.model.releaserecord.RollbackReleaseRecordRequest; +import com.baidubce.services.cnap.model.releaserecord.RollbackReleaseRecordResponse; +import com.baidubce.services.cnap.model.releaserecord.TaskReqModel; +import com.baidubce.services.cnap.model.repository.CreateRepositoryRequest; +import com.baidubce.services.cnap.model.repository.CreateRepositoryResponse; +import com.baidubce.services.cnap.model.repository.ListImageRequest; +import com.baidubce.services.cnap.model.repository.ListImageResponse; +import com.baidubce.services.cnap.model.workspace.CreateWorkspaceRequest; +import com.baidubce.services.cnap.model.workspace.CreateWorkspaceResponse; +import com.baidubce.services.cnap.model.workspace.DeleteWorkspaceRequest; +import com.baidubce.services.cnap.model.workspace.DeleteWorkspaceResponse; +import com.baidubce.services.cnap.model.workspace.GetWorkspaceRequest; +import com.baidubce.services.cnap.model.workspace.GetWorkspaceResponse; +import com.baidubce.services.cnap.model.workspace.ListWorkspaceRequest; +import com.baidubce.services.cnap.model.workspace.ListWorkspaceResponse; +import com.baidubce.services.cnap.model.workspace.UpdateWorkspaceRequest; +import com.baidubce.services.cnap.model.workspace.UpdateWorkspaceResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +/** + * Provides the client for accessing the Baidu Cloud-Native Application Platform Service(cnap). + */ +public class CnapClient extends AbstractBceClient { + private static final String VERSION = "v2"; + + private static final String CONSOLE_PREFIX = "console"; + + private static final String WORKSPACE_PREFIX = "workspaces"; + private static final String APPLICATION_PREFIX = "applications"; + private static final String DEPLOY_GROUP_PREFIX = "deployGroups"; + private static final String ENVIRONMENT_PREFIX = "environments"; + private static final String CLUSTER_PREFIX = "clusters"; + private static final String REPOSITORY_PREFIX = "repositories"; + private static final String IMAGE_PREFIX = "images"; + private static final String ACCESS_PREFIX = "accesses"; + private static final String RELEASE_RECORD_PREFIX = "releaseRecords"; + private static final String MONITORING_PREFIX = "monitoring"; + private static final String BILLING_PREFIX = "billing"; + private static final String BILLING_WORKSPACE_PREFIX = "billingWorkspaces"; + + /** + * Exception messages. + */ + private static final String USER_ID_MESSAGE_KEY = "user id"; + + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String REQUEST_WORKSPACE_INFO_NULL_ERROR_MESSAGE + = "request workspace info should not be null."; + private static final String REQUEST_CLUSTER_INFO_NULL_ERROR_MESSAGE = "request cluster info should not be null."; + private static final String WORKSPACE_ID_MESSAGE_KEY = "workspace id"; + private static final String WORKSPACE_NAME_MESSAGE_KEY = "workspace name"; + private static final String WORKSPACE_DESCRIPTION_MESSAGE_KEY = "workspace description"; + + private static final String ENVIRONMENT_ID_MESSAGE_KEY = "environment id"; + private static final String ENVIRONMENT_NAME_MESSAGE_KEY = "environment name"; + + private static final String CLUSTER_ID_MESSAGE_KEY = "cluster id"; + private static final String CLUSTER_IDS_MESSAGE_KEY = "cluster ids"; + private static final String CLUSTER_REGION_MESSAGE_KEY = "cluster region"; + private static final String CLUSTER_TYPE_MESSAGE_KEY = "cluster type"; + private static final String CLUSTER_UNDERLAY_CLUSTER_ID_MESSAGE_KEY = "underlay cluster id"; + + private static final String REPOSITORY_ID_MESSAGE_KEY = "repository id"; + private static final String REPOSITORY_NAME_MESSAGE_KEY = "repository name"; + private static final String REPOSITORY_TYPE_MESSAGE_KEY = "repository type"; + + + private static final String DEPLOY_GROUP_ID_MESSAGE_KEY = "deploy group id"; + private static final String DEPLOY_GROUP_NAME_MESSAGE_KEY = "deploy group name"; + + private static final String APPLICATION_NAME_MESSAGE_KEY = "application name"; + private static final String APPLICATION_ID_MESSAGE_KEY = "application id"; + + private static final String IMAGE_NAME_MESSAGE_KEY = "image name"; + private static final String IMAGE_PATH_MESSAGE_KEY = "image path"; + + private static final String RELEASE_RECORD_ID_MESSAGE_KEY = "release record id"; + + private static final String ACCESS_ID_MESSAGE_KEY = "deploy group id"; + private static final String ACCESS_NAME_MESSAGE_KEY = "access name"; + + private static final int MIN_PORT = 1; + + private static final int MAX_PORT = 65535; + + private static final int MAX_DESCRIPTION_LENGTH = 140; + + private static final int ILLEGAL_INITIAL = -1; + + + /** + * Responsible for handling httpResponses from all cnap service calls. + */ + private static final HttpResponseHandler[] cnap_handlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new CnapHttpResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on bcc. + */ + public CnapClient() { + this(new CnapClientConfiguration()); + } + + /** + * Constructs a new cnap client using the client configuration to access cnap. + * + * @param clientConfiguration The cnap client configuration options controlling how this client + * connects to cnap. + */ + public CnapClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, cnap_handlers); + } + + + /** + * Creates and initializes a new request object for the specified bcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + + /** + * Creates and initializes a new request object for the specified bcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequestWithCustomPath(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * Create workspace. + * + * @param request CreateWorkspaceRequest + * @return CreateWorkspaceResponse + */ + public CreateWorkspaceResponse createWorkspace(CreateWorkspaceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getWorkspace(), REQUEST_WORKSPACE_INFO_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspace().getName(), + checkEmptyExceptionMessageFormat(WORKSPACE_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, WORKSPACE_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateWorkspaceResponse.class); + } + + /** + * Query detail information of workspace. + * + * @param request GetWorkspaceRequest + * @return GetWorkspaceResponse + */ + public GetWorkspaceResponse getWorkspace(GetWorkspaceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, WORKSPACE_PREFIX, + request.getWorkspaceID()); + return invokeHttpClient(internalRequest, GetWorkspaceResponse.class); + } + + + /** + * Query name of billing workspace. + * + * @param request GetWorkspaceNameRequest + * @return GetWorkspaceNameResponse + */ + public GetWorkspaceNameResponse getWorkspaceName(GetWorkspaceNameRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getUserID(), checkEmptyExceptionMessageFormat(USER_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequestWithCustomPath + (request, HttpMethodName.GET, BILLING_PREFIX, "v1", BILLING_WORKSPACE_PREFIX, + request.getWorkspaceID(), "users", request.getUserID(), "workspaceName"); + return invokeHttpClient(internalRequest, GetWorkspaceNameResponse.class); + } + + + /** + * Update information of workspace. + * + * @param request GetWorkspaceRequest + * @return GetWorkspaceResponse + */ + public UpdateWorkspaceResponse updateWorkspace(UpdateWorkspaceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDescription(), + checkEmptyExceptionMessageFormat(WORKSPACE_DESCRIPTION_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, WORKSPACE_PREFIX, + request.getWorkspaceID()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateWorkspaceResponse.class); + } + + /** + * Delete workspace + * + * @param request DeleteWorkspaceRequest + * @return DeleteWorkspaceResponse + */ + public DeleteWorkspaceResponse deleteWorkspace(DeleteWorkspaceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, WORKSPACE_PREFIX, + request.getWorkspaceID()); + internalRequest.addParameter("skipDeleteUnderlay", String.valueOf(request.getSkipDeleteUnderlay())); + internalRequest.addParameter("ignoreUnderlayError", String.valueOf(request.getIgnoreUnderlayError())); + return invokeHttpClient(internalRequest, DeleteWorkspaceResponse.class); + } + + + /** + * List workspace + * + * @param request ListWorkspaceRequest + * @return ListWorkspaceResponse + */ + public ListWorkspaceResponse listWorkspace(ListWorkspaceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, WORKSPACE_PREFIX); + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + if (StringUtils.isNotEmpty(request.getPageSize())) { + internalRequest.addParameter("pageSize", request.getPageSize()); + } + if (StringUtils.isNotEmpty(request.getPageNo())) { + internalRequest.addParameter("pageNo", request.getPageNo()); + } + if (StringUtils.isNotEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (StringUtils.isNotEmpty(request.getResourceID())) { + internalRequest.addParameter("resourceID", request.getResourceID()); + } + return invokeHttpClient(internalRequest, ListWorkspaceResponse.class); + } + + /** + * Create Environment. + * + * @param request CreateEnvironmentRequest + * @return CreateEnvironmentResponse + */ + public CreateEnvironmentResponse createEnvironment(CreateEnvironmentRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(ENVIRONMENT_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, WORKSPACE_PREFIX, + request.getWorkspaceID(), ENVIRONMENT_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEnvironmentResponse.class); + } + + /** + * Update environment. + * + * @param request UpdateEnvironmentRequest + * @return UpdateEnvironmentResponse + */ + public UpdateEnvironmentResponse updateEnvironment(UpdateEnvironmentRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getEnvironmentID(), checkEmptyExceptionMessageFormat(ENVIRONMENT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, WORKSPACE_PREFIX, + request.getWorkspaceID(), ENVIRONMENT_PREFIX, request.getEnvironmentID()); + internalRequest.addParameter("skipDeleteUnderlay", String.valueOf(request.getSkipDeleteUnderlay())); + internalRequest.addParameter("ignoreUnderlayError", String.valueOf(request.getIgnoreUnderlayError())); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateEnvironmentResponse.class); + } + + /** + * List Environment. + * + * @param request ListEnvironmentRequest + * @return ListEnvironmentResponse + */ + public ListEnvironmentResponse listEnvironment(ListEnvironmentRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CONSOLE_PREFIX, + WORKSPACE_PREFIX, request.getWorkspaceID(), ENVIRONMENT_PREFIX); + internalRequest.addParameter("orderBy", request.getOrderBy()); + internalRequest.addParameter("order", request.getOrder()); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + if (!StringUtils.isEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + return invokeHttpClient(internalRequest, ListEnvironmentResponse.class); + } + + /** + * Delete Environment. + * + * @param request DeleteEnvironmentRequest + * @return DeleteEnvironmentReponse + */ + public DeleteEnvironmentReponse deleteEnvironment(DeleteEnvironmentRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getEnvironmentID(), checkEmptyExceptionMessageFormat(ENVIRONMENT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, WORKSPACE_PREFIX, + request.getWorkspaceID(), ENVIRONMENT_PREFIX, request.getEnvironmentID()); + internalRequest.addParameter("skipDeleteUnderlay", String.valueOf(request.getSkipDeleteUnderlay())); + internalRequest.addParameter("ignoreUnderlayError", String.valueOf(request.getIgnoreUnderlayError())); + return invokeHttpClient(internalRequest, DeleteEnvironmentReponse.class); + } + + /** + * Bind cluster to environment. + * + * @param request BindClusterToWorkspaceRequest + * @return BindClusterToEnvironmentResponse + */ + public BindClusterToEnvironmentResponse bindClusterToEnvironment(BindClusterToEnvironmentRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getEnvironmentID(), checkEmptyExceptionMessageFormat(ENVIRONMENT_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getClusterID(), checkEmptyExceptionMessageFormat(CLUSTER_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, WORKSPACE_PREFIX, + request.getWorkspaceID(), ENVIRONMENT_PREFIX, request.getEnvironmentID()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BindClusterToEnvironmentResponse.class); + } + + /** + * Unbind cluster to environment. + * + * @param request BindClusterToWorkspaceRequest + * @return BindClusterToEnvironmentResponse + */ + public UnbindClusterToEnvironmentResponse unBindClusterToEnvironment(UnbindClusterToEnvironmentRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getEnvironmentID(), checkEmptyExceptionMessageFormat(ENVIRONMENT_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, WORKSPACE_PREFIX, + request.getWorkspaceID(), ENVIRONMENT_PREFIX, request.getEnvironmentID()); + internalRequest.addParameter("skipDeleteUnderlay", String.valueOf(request.getSkipDeleteUnderlay())); + internalRequest.addParameter("ignoreUnderlayError", String.valueOf(request.getIgnoreUnderlayError())); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UnbindClusterToEnvironmentResponse.class); + } + + /** + * Import cluster. + * + * @param request ImportClusterRequest + * @return ImportClusterResponse + */ + public ImportClusterResponse importCluster(ImportClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request, REQUEST_CLUSTER_INFO_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getCluster().getRegion(), + checkEmptyExceptionMessageFormat(CLUSTER_REGION_MESSAGE_KEY)); + checkStringNotEmpty(request.getCluster().getUnderlayClusterID(), + checkEmptyExceptionMessageFormat(CLUSTER_UNDERLAY_CLUSTER_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getCluster().getType(), + checkEmptyExceptionMessageFormat(CLUSTER_TYPE_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CLUSTER_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ImportClusterResponse.class); + } + + /** + * Release cluster. + * + * @param request ReleaseClusterRequest + * @return ReleaseClusterResponse + */ + public ReleaseClusterResponse releaseCluster(ReleaseClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterID(), + checkEmptyExceptionMessageFormat(CLUSTER_UNDERLAY_CLUSTER_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, CLUSTER_PREFIX, + request.getClusterID()); + internalRequest.addParameter("skipDeleteUnderlay", String.valueOf(request.getSkipDeleteUnderlay())); + internalRequest.addParameter("ignoreUnderlayError", String.valueOf(request.getIgnoreUnderlayError())); + return invokeHttpClient(internalRequest, ReleaseClusterResponse.class); + } + + /** + * Bind Cluster to workspace. + * + * @param request BindClusterToWorkspaceRequest + * @return BindClusterToWorkspaceResponse + */ + public BindClusterToWorkspaceResponse bindClusterToWorkspace(BindClusterToWorkspaceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkArgument(request.getClusterIDs().size() > 0, + checkEmptyExceptionMessageFormat(CLUSTER_IDS_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, WORKSPACE_PREFIX, + request.getWorkspaceID(), CLUSTER_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BindClusterToWorkspaceResponse.class); + } + + /** + * Unbind Cluster to workspace. + * + * @param request BindClusterRequest + * @return BindClusterResponse + */ + public UnbindClusterToWorkspaceResponse unbindClusterToWorkspace(UnbindClusterToWorkspaceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), + checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getClusterID(), + checkEmptyExceptionMessageFormat(CLUSTER_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, WORKSPACE_PREFIX, + request.getWorkspaceID(), CLUSTER_PREFIX, request.getClusterID()); + internalRequest.addParameter("skipDeleteUnderlay", String.valueOf(request.getSkipDeleteUnderlay())); + internalRequest.addParameter("ignoreUnderlayError", String.valueOf(request.getIgnoreUnderlayError())); + return invokeHttpClient(internalRequest, UnbindClusterToWorkspaceResponse.class); + } + + /** + * Create Repository. + * + * @param request CreateRepositoryRequest + * @return CreateRepositoryResponse + */ + public CreateRepositoryResponse createRepository(CreateRepositoryRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(REPOSITORY_NAME_MESSAGE_KEY)); + checkArgument(request.getType() > 0 && request.getType() < 4, + checkEmptyExceptionMessageFormat(REPOSITORY_TYPE_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, WORKSPACE_PREFIX, + request.getWorkspaceID(), REPOSITORY_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateRepositoryResponse.class); + } + + /** + * List image. + * + * @param request ListImageRequest + * @return ListImageResponse + */ + public ListImageResponse listImage(ListImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getRepositoryID(), checkEmptyExceptionMessageFormat(REPOSITORY_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, WORKSPACE_PREFIX, + request.getWorkspaceID(), REPOSITORY_PREFIX, request.getRepositoryID(), IMAGE_PREFIX); + internalRequest.addParameter("orderBy", request.getOrderBy()); + internalRequest.addParameter("order", request.getOrder()); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + if (!StringUtils.isEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + return invokeHttpClient(internalRequest, ListImageResponse.class); + } + + /** + * Create access. + * + * @param request CreateAccessRequest + * @return CreateAccessResponse + */ + public CreateAccessResponse createAccess(CreateAccessRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getAccessList(), "create access model list should not be null."); + String workspaceID = ""; + String applicationID = ""; + String deployGroupID = ""; + for (CreateAccessModel accessModel : request.getAccessList()) { + checkStringNotEmpty(accessModel.getWorkspaceID(), + checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(accessModel.getApplicationID(), + checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkStringNotEmpty(accessModel.getDeployGroupID(), + checkEmptyExceptionMessageFormat(DEPLOY_GROUP_ID_MESSAGE_KEY)); + checkStringNotEmpty(accessModel.getName(), checkEmptyExceptionMessageFormat(ACCESS_NAME_MESSAGE_KEY)); + checkArgument(accessModel.getType() >= CLUSTER_NETWORK && accessModel.getType() <= PUBLIC_NETWORK, + "type should between 1 and 3."); + checkArgument("TCP".equals(accessModel.getProtocol()) || + "UDP".equals(accessModel.getProtocol()), "protocol should be TCP or UDP."); + checkArgument(accessModel.getPort() >= MIN_PORT && accessModel.getPort() <= MAX_PORT, + "port should between 1 and 65535."); + checkArgument(accessModel.getTargetPort() >= MIN_PORT && accessModel.getPort() <= MAX_PORT, + "target port should between 1 and 65535."); + + checkArgument(StringUtils.isEmpty(workspaceID) || (StringUtils.isNotEmpty(workspaceID) + && !workspaceID.equals(accessModel.getWorkspaceID())), + "workspace id should be equal."); + checkArgument(StringUtils.isEmpty(applicationID) || (StringUtils.isNotEmpty(applicationID) + && !applicationID.equals(accessModel.getApplicationID())), + "application id should be equal."); + checkArgument(StringUtils.isEmpty(deployGroupID) || (StringUtils.isNotEmpty(deployGroupID) + && !deployGroupID.equals(accessModel.getDeployGroupID())), + "id should be equal."); + workspaceID = accessModel.getWorkspaceID(); + applicationID = accessModel.getApplicationID(); + deployGroupID = accessModel.getDeployGroupID(); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, WORKSPACE_PREFIX, + workspaceID, APPLICATION_PREFIX, applicationID, DEPLOY_GROUP_PREFIX, deployGroupID, ACCESS_PREFIX); + String strJson = JsonUtils.toJsonString(request.getAccessList()); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + return invokeHttpClient(internalRequest, CreateAccessResponse.class); + } + + /** + * Delete access. + * + * @param request DeleteAccessRequest + * @return DeleteAccessResponse + */ + public DeleteAccessResponse deleteAccess(DeleteAccessRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDeployGroupID(), checkEmptyExceptionMessageFormat(DEPLOY_GROUP_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getAccessID(), checkEmptyExceptionMessageFormat(ACCESS_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, WORKSPACE_PREFIX, + request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), DEPLOY_GROUP_PREFIX, + request.getDeployGroupID(), ACCESS_PREFIX, request.getAccessID()); + return invokeHttpClient(internalRequest, DeleteAccessResponse.class); + } + + /** + * List access. + * + * @param request ListAccessRequest + * @return ListAccessResponse + */ + public ListAccessResponse listAccess(ListAccessRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDeployGroupID(), checkEmptyExceptionMessageFormat(DEPLOY_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CONSOLE_PREFIX, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), + DEPLOY_GROUP_PREFIX, request.getDeployGroupID(), ACCESS_PREFIX); + internalRequest.addParameter("orderBy", request.getOrderBy()); + internalRequest.addParameter("order", request.getOrder()); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + return invokeHttpClient(internalRequest, ListAccessResponse.class); + } + + /** + * List application. + * + * @param request ListApplicationRequest + * @return ListApplicationResponse + */ + public ListApplicationResponse listApplication(ListApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, WORKSPACE_PREFIX, + request.getWorkspaceID(), APPLICATION_PREFIX); + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + if (StringUtils.isNotEmpty(request.getPageSize())) { + internalRequest.addParameter("pageSize", request.getPageSize()); + } + if (StringUtils.isNotEmpty(request.getPageNo())) { + internalRequest.addParameter("pageNo", request.getPageNo()); + } + if (StringUtils.isNotEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (StringUtils.isNotEmpty(request.getResourceID())) { + internalRequest.addParameter("resourceID", request.getResourceID()); + } + if (StringUtils.isNotEmpty(request.getDeployType())) { + internalRequest.addParameter("deployType", request.getDeployType()); + } + if (request.getWorkloadType() != 0) { + internalRequest.addParameter("workloadType", String.valueOf(request.getWorkloadType())); + } + return invokeHttpClient(internalRequest, ListApplicationResponse.class); + } + + /** + * Delete application. + * + * @param request DeleteApplicationRequest + * @return DeleteApplicationResponse + */ + public DeleteApplicationResponse deleteApplication(DeleteApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID()); + internalRequest.addParameter("ignoreUnderlayError", String.valueOf(request.getIgnoreUnderlayError())); + internalRequest.addParameter("skipDeleteUnderlay", String.valueOf(request.getSkipDeleteUnderlay())); + return invokeHttpClient(internalRequest, DeleteApplicationResponse.class); + + } + + /** + * Create deploy group. + * + * @param request CreateDeployGroupRequest + * @return CreateDeployGroupResponse + */ + public CreateDeployGroupResponse createDeployGroup(CreateDeployGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + // check access info. + if (CollectionUtils.isNotEmpty(request.getAccess())) { + List accessModelList = request.getAccess(); + for (NewAccessModel accessModel : accessModelList) { + checkStringNotEmpty(accessModel.getName(), checkEmptyExceptionMessageFormat(ACCESS_NAME_MESSAGE_KEY)); + checkArgument(accessModel.getType() >= CLUSTER_NETWORK + && accessModel.getType() <= PUBLIC_NETWORK, + "type should between 1 and 3."); + checkArgument("TCP".equals(accessModel.getProtocol()) || + "UDP".equals(accessModel.getProtocol()), "protocol should be TCP or UDP."); + checkArgument(accessModel.getPort() >= MIN_PORT && accessModel.getPort() <= MAX_PORT, + "port should between 1 and 65535."); + checkArgument(accessModel.getTargetPort() >= MIN_PORT && accessModel.getPort() <= MAX_PORT, + "target port should between 1 and 65535."); + } + } + // check deploy group info. + checkNotNull(request.getDeployGroup(), "request deploy group should not be null."); + NewDeployGroupModel deployGroupModel = request.getDeployGroup(); + checkStringNotEmpty(deployGroupModel.getName(), + checkEmptyExceptionMessageFormat(DEPLOY_GROUP_NAME_MESSAGE_KEY)); + checkStringNotEmpty(deployGroupModel.getEnvironmentID(), + checkEmptyExceptionMessageFormat(ENVIRONMENT_ID_MESSAGE_KEY)); + if (deployGroupModel.getType() == DeployGroupType.NORMAL) { + checkArgument(deployGroupModel.getReplicas() > 0, "replicas should greater than 0."); + checkArgument("Recreate".equals(deployGroupModel.getDeployStrategyType()) + || "RollingUpdate".equals(deployGroupModel.getDeployStrategyType()), + "type should be Recreate or RollingUpdate."); + checkNotNull(request.getDeployGroup().getConf() == null + || request.getDeployGroup().getConf().getContainers() == null + || request.getDeployGroup().getConf().getContainers().size() == 0, + "deploy group conf should not be null."); + List containerModelList = request.getDeployGroup().getConf().getContainers(); + for (ContainerModel containerModel : containerModelList) { + checkStringNotEmpty(containerModel.getBapRepositoryID(), + checkEmptyExceptionMessageFormat(REPOSITORY_ID_MESSAGE_KEY)); + checkStringNotEmpty(containerModel.getName(), + checkEmptyExceptionMessageFormat(IMAGE_NAME_MESSAGE_KEY)); + checkStringNotEmpty(containerModel.getName(), + checkEmptyExceptionMessageFormat(IMAGE_PATH_MESSAGE_KEY)); + checkArgument(StringUtils.isNotEmpty(containerModel.getResources().requestsInfo().get("cpu")) + && StringUtils.isNotEmpty(containerModel.getResources().requestsInfo().get("memory")), + "resource requirement should not be empty."); + } + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, WORKSPACE_PREFIX, + request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), DEPLOY_GROUP_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateDeployGroupResponse.class); + } + + /** + * Get deploy group. + * + * @param request GetDeployGroupRequest + * @return GetDeployGroupResponse + */ + public GetDeployGroupResponse getDeployGroup(GetDeployGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDeployGroupID(), checkEmptyExceptionMessageFormat(DEPLOY_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, WORKSPACE_PREFIX, + request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), DEPLOY_GROUP_PREFIX, + request.getDeployGroupID()); + return invokeHttpClient(internalRequest, GetDeployGroupResponse.class); + } + + /** + * List deploy group by page. + * + * @param request ListDeployGroupByPageRequest + * @return ListDeployGroupByPageResponse + */ + public ListDeployGroupByPageResponse listDeployGroupByPage(ListDeployGroupByPageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + CONSOLE_PREFIX, WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, + request.getApplicationID(), DEPLOY_GROUP_PREFIX); + internalRequest.addParameter("pageSize", request.getPageSize()); + internalRequest.addParameter("pageNo", request.getPageNo()); + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (StringUtils.isNotEmpty(request.getEnvironmentID())) { + internalRequest.addParameter("environmentID", request.getEnvironmentID()); + } + return invokeHttpClient(internalRequest, ListDeployGroupByPageResponse.class); + } + + /** + * List deploy group by image. + * + * @param request ListDeployGroupByImageRequest + * @return ListDeployGroupByImageResponse + */ + public ListDeployGroupByImageResponse listDeployGroupByImage(ListDeployGroupByImageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + // checkArgument( + // StringUtils.isNotEmpty(request.getImages()) || StringUtils.isNotEmpty(request.getConfigIDs()), + // "images or configIDs is empty."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + CONSOLE_PREFIX, WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, + request.getApplicationID(), DEPLOY_GROUP_PREFIX); + if (StringUtils.isNotEmpty(request.getImages())) { + internalRequest.addParameter("images", request.getImages()); + } + if (StringUtils.isNotEmpty(request.getConfigIDs())) { + internalRequest.addParameter("configIDs", request.getConfigIDs()); + } + return invokeHttpClient(internalRequest, ListDeployGroupByImageResponse.class); + } + + /** + * Delete deploy group. + * + * @param request DeleteDeployGroupRequest + * @return DeleteDeployGroupResponse + */ + public DeleteDeployGroupResponse deleteDeployGroup(DeleteDeployGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDeployGroupID(), checkEmptyExceptionMessageFormat(DEPLOY_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), + DEPLOY_GROUP_PREFIX, request.getDeployGroupID()); + internalRequest.addParameter("skipDeleteUnderlay", String.valueOf(request.getSkipDeleteUnderlay())); + internalRequest.addParameter("ignoreUnderlayError", String.valueOf(request.getIgnoreUnderlayError())); + return invokeHttpClient(internalRequest, DeleteDeployGroupResponse.class); + } + + /** + * Update deploy group. + * + * @param request UpdateDeployGroupRequest + * @return UpdateDeployGroupResponse + */ + public UpdateDeployGroupResponse updateDeployGroup(UpdateDeployGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDeployGroupID(), checkEmptyExceptionMessageFormat(DEPLOY_GROUP_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), + DEPLOY_GROUP_PREFIX, request.getDeployGroupID()); + return invokeHttpClient(internalRequest, UpdateDeployGroupResponse.class); + } + + /** + * Scale deploy group. + * + * @param request ScaleDeployGroupRequest + * @return ScaleDeployGroupResponse + */ + public ScaleDeployGroupResponse scaleDeployGroup(ScaleDeployGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getDeployGroupID(), checkEmptyExceptionMessageFormat(DEPLOY_GROUP_ID_MESSAGE_KEY)); + checkArgument(request.getReplicas() >= 0, "replicas is illegal"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), + DEPLOY_GROUP_PREFIX, request.getDeployGroupID(), "scale"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ScaleDeployGroupResponse.class); + } + + /** + * Create release record. + * + * @param request CreateReleaseRecordRequest + * @return CreateReleaseRecordResponse + */ + public CreateReleaseRecordResponse createReleaseRecord(CreateReleaseRecordRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkArgument("RdType".equals(request.getType()), "type should be RdType."); + checkArgument(StringUtils.isNotEmpty(request.getDescription()) + && request.getDescription().length() < MAX_DESCRIPTION_LENGTH, + "description should not be empty or greater than 140 character"); + checkArgument(CollectionUtils.isNotEmpty(request.getImages()) + || CollectionUtils.isNotEmpty(request.getConfigs()), + "images info or config info shoud not be empty."); + checkArgument(CollectionUtils.isNotEmpty(request.getTasks()), "task info should not be empty."); + List taskReqModelList = request.getTasks(); + for (TaskReqModel taskReqModel : taskReqModelList) { + checkStringNotEmpty(taskReqModel.getDeployGroupID(), + checkEmptyExceptionMessageFormat(DEPLOY_GROUP_ID_MESSAGE_KEY)); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), + RELEASE_RECORD_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateReleaseRecordResponse.class); + } + + /** + * Rollback release record. + * + * @param request RollbackReleaseRecordRequest + * @return RollbackReleaseRecordResponse + */ + public RollbackReleaseRecordResponse rollbackReleaseRecord(RollbackReleaseRecordRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getReleaseRecordID(), + checkEmptyExceptionMessageFormat(RELEASE_RECORD_ID_MESSAGE_KEY)); + checkArgument(StringUtils.isNotEmpty(request.getDescription()) + && request.getDescription().length() < MAX_DESCRIPTION_LENGTH, + "description should not be empty or greater than 140 character"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), + RELEASE_RECORD_PREFIX, request.getReleaseRecordID(), "rollbackToVersion"); + checkArgument(CollectionUtils.isNotEmpty(request.getTasks()), "task info should not be empty."); + List taskReqModelList = request.getTasks(); + for (TaskReqModel taskReqModel : taskReqModelList) { + checkStringNotEmpty(taskReqModel.getDeployGroupID(), + checkEmptyExceptionMessageFormat(DEPLOY_GROUP_ID_MESSAGE_KEY)); + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, RollbackReleaseRecordResponse.class); + } + + /** + * List release record. + * + * @param request ListReleaseRecordRequest + * @return ListReleaseRecordResponse + */ + public ListReleaseRecordResponse listReleaseRecord(ListReleaseRecordRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CONSOLE_PREFIX, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), + RELEASE_RECORD_PREFIX); + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + if (StringUtils.isNotEmpty(request.getPageSize())) { + internalRequest.addParameter("pageSize", request.getPageSize()); + } + if (StringUtils.isNotEmpty(request.getPageNo())) { + internalRequest.addParameter("pageNo", request.getPageNo()); + } + if (StringUtils.isNotEmpty(request.getExecutor())) { + internalRequest.addParameter("executor", request.getExecutor()); + } + if (StringUtils.isNotEmpty(request.getStatus())) { + internalRequest.addParameter("status", request.getStatus()); + } + if (StringUtils.isNotEmpty(request.getType())) { + internalRequest.addParameter("type", request.getType()); + } + if (request.getStartTime() != null) { + internalRequest.addParameter("startTime", String.valueOf(request.getStartTime().getTime())); + } + if (request.getEndTime() != null) { + internalRequest.addParameter("endTime", String.valueOf(request.getEndTime().getTime())); + } + return invokeHttpClient(internalRequest, ListReleaseRecordResponse.class); + } + + /** + * Get release record progress. + * + * @param request GetReleaseRecordProgressRequest + * @return GetReleaseRecordProgressResponse + */ + public GetReleaseRecordProgressResponse getReleaseRecordProgress(GetReleaseRecordProgressRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getWorkspaceID(), checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplicationID(), checkEmptyExceptionMessageFormat(APPLICATION_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getReleaseRecordID(), + checkEmptyExceptionMessageFormat(RELEASE_RECORD_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX, request.getApplicationID(), + RELEASE_RECORD_PREFIX, request.getReleaseRecordID(), "progress"); + return invokeHttpClient(internalRequest, GetReleaseRecordProgressResponse.class); + } + + /** + * Create application. + * + * @param request CreateApplicationRequest + * @return CreateApplicationResponse + */ + public CreateApplicationResponse createApplication(CreateApplicationRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkNotNull(request.getApplication(), "application info should not be empty."); + checkStringNotEmpty(request.getWorkspaceID(), + checkEmptyExceptionMessageFormat(WORKSPACE_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getApplication().getName(), + checkEmptyExceptionMessageFormat(APPLICATION_NAME_MESSAGE_KEY)); + checkArgument(DEFAULT_DEPLOY_TYPE == request.getApplication().getDeployType(), "deploy type is illegal."); + checkArgument(SIMPLE_APPLICATION == request.getApplication().getWorkloadType() + || MICROSERVICE_APPLICATION == request.getApplication().getWorkloadType(), + "work load type is illegal."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + WORKSPACE_PREFIX, request.getWorkspaceID(), APPLICATION_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateApplicationResponse.class); + } + + /** + * Create alert rule. + * + * @param request CreateAlertRulesRequest + * @return CreateAlertRulesResponse + */ + public CreateAlertRulesResponse createAlertRules(CreateAlertRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat("name")); + checkStringNotEmpty(request.getDuration(), checkEmptyExceptionMessageFormat("duration time")); + checkStringNotEmpty(request.getPromql(), checkEmptyExceptionMessageFormat("promql")); + checkStringNotEmpty(request.getOp(), checkEmptyExceptionMessageFormat("op")); + checkStringNotEmpty(request.getRepeatInterval(), checkEmptyExceptionMessageFormat("repeatInterval")); + checkArgument(ILLEGAL_INITIAL != request.getThreshold(), "threshold is illegal."); + InternalRequest internalRequest = this.createRequestWithCustomPath(request, HttpMethodName.POST, + MONITORING_PREFIX, "v1", "alertRules"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateAlertRulesResponse.class); + } + + /** + * Update alert rule. + * + * @param request UpdateAlertRulesRequest + * @return UpdateAlertRulesResponse + */ + public UpdateAlertRulesResponse updateAlertRules(UpdateAlertRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getAlertRuleID(), checkEmptyExceptionMessageFormat("alert rule id")); + checkStringNotEmpty(request.getDuration(), checkEmptyExceptionMessageFormat("duration time")); + checkStringNotEmpty(request.getPromql(), checkEmptyExceptionMessageFormat("promql")); + checkStringNotEmpty(request.getOp(), checkEmptyExceptionMessageFormat("op")); + checkStringNotEmpty(request.getRepeatInterval(), checkEmptyExceptionMessageFormat("repeatInterval")); + InternalRequest internalRequest = this.createRequestWithCustomPath(request, HttpMethodName.PUT, + MONITORING_PREFIX, "v1", "alertRules", request.getAlertRuleID()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateAlertRulesResponse.class); + } + + /** + * Delete alert rules. + * + * @param request DeleteAlertRulesRequest + * @return DeleteAlertRulesResponse + */ + public DeleteAlertRulesResponse deleteAlertRules(DeleteAlertRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getAlertRuleID(), checkEmptyExceptionMessageFormat("alert rule id")); + InternalRequest internalRequest = this.createRequestWithCustomPath(request, HttpMethodName.DELETE, + MONITORING_PREFIX, "v1", "alertRules", request.getAlertRuleID()); + return invokeHttpClient(internalRequest, DeleteAlertRulesResponse.class); + } + + /** + * List alert rules. + * + * @param request ListAlertRulesRequest + * @return ListAlertRulesResponse + */ + public ListAlertRulesResponse listAlertRules(ListAlertRulesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequestWithCustomPath(request, HttpMethodName.GET, + MONITORING_PREFIX, "v1", "alertRules"); + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + if (StringUtils.isNotEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + return invokeHttpClient(internalRequest, ListAlertRulesResponse.class); + } + + /** + * List alert record. + * + * @param request ListAlertsRequest + * @return ListAlertResponse + */ + public ListAlertRecordResponse listAlertRecord(ListAlertRecordRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequestWithCustomPath(request, HttpMethodName.GET, + MONITORING_PREFIX, "v1", "alerts"); + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + if (StringUtils.isNotEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (-1 != request.getStartsAt()) { + internalRequest.addParameter("startsAt", String.valueOf(request.getStartsAt())); + } + if (-1 != request.getEndsAt()) { + internalRequest.addParameter("endsAt", String.valueOf(request.getEndsAt())); + } + return invokeHttpClient(internalRequest, ListAlertRecordResponse.class); + } + + /** + * Get monitor data. + * + * @param request GetMonitorDataRequest + * @return GetMonitorDataResponse + */ + public GetMonitorDataResponse getMonitorData(GetMonitorDataRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getQuery(), checkEmptyExceptionMessageFormat("query")); + checkArgument(ILLEGAL_INITIAL != request.getStart(), "start is illegal."); + checkArgument(ILLEGAL_INITIAL != request.getEnd(), "end is illegal."); + checkArgument(ILLEGAL_INITIAL != request.getStep(), "step is illegal."); + + InternalRequest internalRequest = this.createRequestWithCustomPath(request, HttpMethodName.GET, + MONITORING_PREFIX, "v1", "query_range"); + internalRequest.addParameter("query", request.getQuery()); + internalRequest.addParameter("start", String.valueOf(request.getStart())); + internalRequest.addParameter("end", String.valueOf(request.getEnd())); + internalRequest.addParameter("step", String.valueOf(request.getStep())); + if (request.getTimeout() != ILLEGAL_INITIAL) { + internalRequest.addParameter("timeout", String.valueOf(request.getTimeout())); + } + return invokeHttpClient(internalRequest, GetMonitorDataResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/CnapClientConfiguration.java b/src/main/java/com/baidubce/services/cnap/CnapClientConfiguration.java new file mode 100644 index 00000000..8f8ceb2b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/CnapClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for cnap service. + */ +public class CnapClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/cnap/handler/CnapHttpResponseHandler.java b/src/main/java/com/baidubce/services/cnap/handler/CnapHttpResponseHandler.java new file mode 100644 index 00000000..7052e4e3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/handler/CnapHttpResponseHandler.java @@ -0,0 +1,50 @@ +package com.baidubce.services.cnap.handler; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import org.apache.http.util.EntityUtils; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.access.AccessModel; +import com.baidubce.services.cnap.model.access.CreateAccessResponse; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * The cnap http response handler. + */ +public class CnapHttpResponseHandler implements HttpResponseHandler { + + public static final ObjectMapper mapper = new ObjectMapper(); + + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + if (!response.getClass().equals(CreateAccessResponse.class)) { + return false; + } + InputStream content = httpResponse.getContent(); + if (content == null) { + return false; + } + if (response.getMetadata().getContentLength() > 0 + || "chunked".equalsIgnoreCase(response.getMetadata().getTransferEncoding())) { + String value = EntityUtils.toString(httpResponse.getHttpResponse().getEntity()); + JavaType javaType = getCollectionType(ArrayList.class, AccessModel.class); + List list = (List) mapper.readValue(value, javaType); + CreateAccessResponse createAccessResponse = (CreateAccessResponse) response; + createAccessResponse.setResult(list); + return true; + } + content.close(); + return false; + } + + + public static JavaType getCollectionType(Class collectionClass, Class... elementClasses) { + return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses); + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/access/AccessModel.java b/src/main/java/com/baidubce/services/cnap/model/access/AccessModel.java new file mode 100644 index 00000000..f624cbe7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/access/AccessModel.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.access; + +import java.util.Date; + +/** + * The model for access. + */ +public class AccessModel { + + /** + * The id of access. + */ + private String resourceID; + + /** + * The name of access. + */ + private String name; + + /** + * The type of access. + * 1 indicate access in cluster network. + * 2 indicate access in vpc network. + * 3 indicate access in public network. + */ + private int type; + + /** + * The protocol of access. + */ + private String protocol; + + + /** + * The port of access. + */ + private int port; + + /** + * The port of listening. + */ + private int targetPort; + + /** + * The inner endpoint. + */ + private String innerEndpoint; + + /** + * The ip of access. + */ + private String ip; + + /** + * The status of access. + */ + private String status; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public int getTargetPort() { + return targetPort; + } + + public void setTargetPort(int targetPort) { + this.targetPort = targetPort; + } + + public String getInnerEndpoint() { + return innerEndpoint; + } + + public void setInnerEndpoint(String innerEndpoint) { + this.innerEndpoint = innerEndpoint; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/access/CreateAccessModel.java b/src/main/java/com/baidubce/services/cnap/model/access/CreateAccessModel.java new file mode 100644 index 00000000..2da9098e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/access/CreateAccessModel.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.access; + +/** + * The model for create access. + */ +public class CreateAccessModel { + + public static final int CLUSTER_NETWORK = 1; + public static final int VPC_NETWORK = 2; + public static final int PUBLIC_NETWORK = 3; + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The id of deploy group. + */ + private String deployGroupID; + + /** + * The name of access. + */ + private String name; + + /** + * The type of access. + * 1 indicate access in cluster network. + * 2 indicate access in vpc network. + * 3 indicate access in public network. + */ + private int type = PUBLIC_NETWORK; + + /** + * The protocol of access. + */ + private String protocol = "TCP"; + + /** + * The port of access. + */ + private int port; + + /** + * The port of listening. + */ + private int targetPort; + + /** + * The access type. + */ + private String accessType = "BLB"; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public int getTargetPort() { + return targetPort; + } + + public void setTargetPort(int targetPort) { + this.targetPort = targetPort; + } + + public String getAccessType() { + return accessType; + } + + public void setAccessType(String accessType) { + this.accessType = accessType; + } + + public CreateAccessModel withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public CreateAccessModel withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public CreateAccessModel withDeployGroupID(String deployGroupID) { + this.setDeployGroupID(deployGroupID); + return this; + } + + public CreateAccessModel withName(String name) { + this.setName(name); + return this; + } + + public CreateAccessModel withType(int type) { + this.setType(type); + return this; + } + + public CreateAccessModel withProtocol(String protocol) { + this.setProtocol(protocol); + return this; + } + + public CreateAccessModel withPort(int port) { + this.setPort(port); + return this; + } + + public CreateAccessModel withTargetPort(int targetPort) { + this.setTargetPort(targetPort); + return this; + } + + public CreateAccessModel withAccessType(String accessType) { + this.setAccessType(accessType); + return this; + } + + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/access/CreateAccessRequest.java b/src/main/java/com/baidubce/services/cnap/model/access/CreateAccessRequest.java new file mode 100644 index 00000000..45d02f91 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/access/CreateAccessRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.access; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for create access. + */ +public class CreateAccessRequest extends AbstractBceRequest { + + /** + * The access list. + */ + private List accessList = new ArrayList(); + + public List getAccessList() { + return accessList; + } + + public CreateAccessRequest addAccess(CreateAccessModel access) { + this.accessList.add(access); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public CreateAccessRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/access/CreateAccessResponse.java b/src/main/java/com/baidubce/services/cnap/model/access/CreateAccessResponse.java new file mode 100644 index 00000000..1676aad9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/access/CreateAccessResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.access; + + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for create access. + */ +public class CreateAccessResponse extends AbstractBceResponse { + /** + * The access model list. + */ + private List result; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/access/DeleteAccessRequest.java b/src/main/java/com/baidubce/services/cnap/model/access/DeleteAccessRequest.java new file mode 100644 index 00000000..40a4d891 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/access/DeleteAccessRequest.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.access; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for delete access. + */ +public class DeleteAccessRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The id of deploy group. + */ + private String deployGroupID; + + /** + * The id of access. + */ + private String accessID; + + /** + * The flag which indicates skip delete underlay. + */ + private boolean skipDeleteUnderlay = false; + + /** + * The flag which indicates ignore underlay error. + */ + private boolean ignoreUnderlayError = false; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public String getAccessID() { + return accessID; + } + + public void setAccessID(String accessID) { + this.accessID = accessID; + } + + public void setIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.ignoreUnderlayError = ignoreUnderlayError; + } + + public boolean getIgnoreUnderlayError() { + return ignoreUnderlayError; + } + + public void setSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.skipDeleteUnderlay = skipDeleteUnderlay; + } + + public boolean getSkipDeleteUnderlay() { + return skipDeleteUnderlay; + } + + public DeleteAccessRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public DeleteAccessRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public DeleteAccessRequest withDeployGroupID(String deployGroupID) { + this.setDeployGroupID(deployGroupID); + return this; + } + + public DeleteAccessRequest withAccessID(String accessID) { + this.setAccessID(accessID); + return this; + } + + public DeleteAccessRequest withSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.setSkipDeleteUnderlay(skipDeleteUnderlay); + return this; + } + + public DeleteAccessRequest withIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.setIgnoreUnderlayError(ignoreUnderlayError); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public DeleteAccessRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/access/DeleteAccessResponse.java b/src/main/java/com/baidubce/services/cnap/model/access/DeleteAccessResponse.java new file mode 100644 index 00000000..fa56f6df --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/access/DeleteAccessResponse.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.access; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for delete access. + */ +public class DeleteAccessResponse extends AbstractBceResponse { + + /** + * The id of access. + */ + private String resourceID; + + /** + * The name of access. + */ + private String name; + + /** + * The type of access. + * 1 indicate access in cluster network. + * 2 indicate access in vpc network. + * 3 indicate access in public network. + */ + private int type; + + /** + * The protocol of access. + */ + private String protocol; + + + /** + * The port of access. + */ + private int port; + + /** + * The port of listening. + */ + private int targetPort; + + /** + * The inner endpoint. + */ + private String innerEndpoint; + + /** + * The ip of access. + */ + private String ip; + + /** + * The status of access. + */ + private String status; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public int getTargetPort() { + return targetPort; + } + + public void setTargetPort(int targetPort) { + this.targetPort = targetPort; + } + + public String getInnerEndpoint() { + return innerEndpoint; + } + + public void setInnerEndpoint(String innerEndpoint) { + this.innerEndpoint = innerEndpoint; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/access/ListAccessRequest.java b/src/main/java/com/baidubce/services/cnap/model/access/ListAccessRequest.java new file mode 100644 index 00000000..d57714d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/access/ListAccessRequest.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.access; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list access. + */ +public class ListAccessRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The id of deploy group. + */ + private String deployGroupID; + + /** + * The order by info. + */ + private String orderBy = ""; + + /** + * The order info, eg asc, desc. + */ + private String order = ""; + + /** + * The page size of list. + */ + private int pageSize = 10; + + /** + * The page no of list. + */ + private int pageNo = 1; + + /** + * The type of access. + */ + private int type; + + /** + * The name of access. + */ + private String name; + + /** + * The protocol of access. + */ + private String protocol; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + + public ListAccessRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public ListAccessRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public ListAccessRequest withDeployGroupID(String deployGroupID) { + this.setDeployGroupID(deployGroupID); + return this; + } + + public ListAccessRequest withOrderBy(String orderBy) { + this.setOrderBy(orderBy); + return this; + } + + public ListAccessRequest withOrder(String order) { + this.setOrder(order); + return this; + } + + public ListAccessRequest withPageSize(int pageSize) { + this.setPageSize(pageSize); + return this; + } + + public ListAccessRequest withPageNo(int pageNo) { + this.setPageNo(pageNo); + return this; + } + + public ListAccessRequest withType(int type) { + this.setType(type); + return this; + } + + public ListAccessRequest withName(String name) { + this.setName(name); + return this; + } + + public ListAccessRequest withProtocol(String protocol) { + this.setProtocol(protocol); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListAccessRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/access/ListAccessResponse.java b/src/main/java/com/baidubce/services/cnap/model/access/ListAccessResponse.java new file mode 100644 index 00000000..8686c833 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/access/ListAccessResponse.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.access; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for list access. + */ +public class ListAccessResponse extends AbstractBceResponse { + /** + * The page no. + */ + private int pageNo; + + /** + * The page size. + */ + private int pageSize; + + /** + * The total count. + */ + private int totalCount; + + /** + * The result. + */ + private List result; + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cnap/model/access/NewAccessModel.java b/src/main/java/com/baidubce/services/cnap/model/access/NewAccessModel.java new file mode 100644 index 00000000..e477c5bb --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/access/NewAccessModel.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.access; + +/** + * The model for access. + */ +public class NewAccessModel { + + /** + * The name of access. + */ + private String name; + + /** + * The type of access. + * 1 indicate access in cluster network. + * 2 indicate access in vpc network. + * 3 indicate access in public network. + */ + private int type = 3; + + /** + * The protocol of access. + * eg TCP or UDP. + */ + private String protocol = "TCP"; + + + /** + * The port of access. + */ + private int port; + + /** + * The port of listening. + */ + private int targetPort; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public int getTargetPort() { + return targetPort; + } + + public void setTargetPort(int targetPort) { + this.targetPort = targetPort; + } + + public NewAccessModel withType(int type) { + this.setType(type); + return this; + } + + public NewAccessModel withProtocol(String protocol) { + this.setProtocol(protocol); + return this; + } + + public NewAccessModel withPort(int port) { + this.setPort(port); + return this; + } + + public NewAccessModel withTargetPort(int targetPort) { + this.setTargetPort(targetPort); + return this; + } + + public NewAccessModel withName(String name) { + this.setName(name); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/ApplicationBaseInfoModel.java b/src/main/java/com/baidubce/services/cnap/model/application/ApplicationBaseInfoModel.java new file mode 100644 index 00000000..7cdab79e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/ApplicationBaseInfoModel.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +import java.util.Date; + +/** + * The base model for application. + */ +public class ApplicationBaseInfoModel { + /** + * The id of application. + */ + private String resourceID; + + /** + * The name of application. + */ + private String name; + + /** + * The description of application. + */ + private String description; + + /** + * The type of application. + */ + private int workloadType; + + /** + * The deploy type of application. + */ + private int deployType; + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The create time of application. + */ + private Date createdAt; + + /** + * The update time of application. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getWorkloadType() { + return workloadType; + } + + public void setWorkloadType(int workloadType) { + this.workloadType = workloadType; + } + + public int getDeployType() { + return deployType; + } + + public void setDeployType(int deployType) { + this.deployType = deployType; + } + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/ApplicationModel.java b/src/main/java/com/baidubce/services/cnap/model/application/ApplicationModel.java new file mode 100644 index 00000000..c860a248 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/ApplicationModel.java @@ -0,0 +1,87 @@ +package com.baidubce.services.cnap.model.application; + + +/** + * The model for application. + */ +public class ApplicationModel { + + public static final int DEFAULT_DEPLOY_TYPE = 1; + + /** + * The name of application. + */ + private String name; + + /** + * The description of application. + */ + private String description = ""; + + /** + * The type of application. eg: 1 or 4. + * 1 indicates simple application. + * 4 indicates micro service application. + */ + private int workloadType = WorkloadType.MICROSERVICE_APPLICATION; + + /** + * The deploy type of application.eg: 1. + * 1 indicates cce deploy. + */ + private int deployType = 1; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getWorkloadType() { + return workloadType; + } + + public void setWorkloadType(int workloadType) { + this.workloadType = workloadType; + } + + public int getDeployType() { + return deployType; + } + + public void setDeployType(int deployType) { + this.deployType = deployType; + } + + + public ApplicationModel withName(String name) { + this.setName(name); + return this; + } + + public ApplicationModel withDescription(String description) { + this.setDescription(description); + return this; + } + + public ApplicationModel withWorkloadType(int workloadType) { + this.setWorkloadType(workloadType); + return this; + } + + public ApplicationModel withDeployType(int deployType) { + this.setDeployType(deployType); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/ClusterModel.java b/src/main/java/com/baidubce/services/cnap/model/application/ClusterModel.java new file mode 100644 index 00000000..4c809292 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/ClusterModel.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +import java.util.Date; + +/** + * The model of cluster. + */ +public class ClusterModel { + /** + * The name of cluster. + */ + private String name; + + /** + * The region of cluster. + */ + private String region; + + /** + * The id of cluster. + */ + private String resourceID; + + /** + * The description of cluster. + */ + private String description; + + /** + * The type of cluster. + */ + private String type; + + /** + * The id of underlay cluster. + */ + private String underlayClusterID; + + /** + * The virtual machine count of cluster. + */ + private int slaveVmCount; + + /** + * The status of cluster. + */ + private String status; + + /** + * The create time of cluster. + */ + private Date createdAt; + + /** + * The update time of cluster. + */ + private Date updatedAt; + + /** + * The resource usage of cluster. + */ + private ResourceUsageModel resourceUsage; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUnderlayClusterID() { + return underlayClusterID; + } + + public void setUnderlayClusterID(String underlayClusterID) { + this.underlayClusterID = underlayClusterID; + } + + public int getSlaveVmCount() { + return slaveVmCount; + } + + public void setSlaveVmCount(int slaveVmCount) { + this.slaveVmCount = slaveVmCount; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public ResourceUsageModel getResourceUsage() { + return resourceUsage; + } + + public void setResourceUsage(ResourceUsageModel resourceUsage) { + this.resourceUsage = resourceUsage; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/CreateApplicationRequest.java b/src/main/java/com/baidubce/services/cnap/model/application/CreateApplicationRequest.java new file mode 100644 index 00000000..f301f04d --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/CreateApplicationRequest.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cnap.model.access.NewAccessModel; +import com.baidubce.services.cnap.model.deploygroup.NewDeployGroupModel; + +/** + * The request for create app. + */ +public class CreateApplicationRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The access info. + */ + private List access; + + /** + * The application info. + */ + private ApplicationModel application; + + /** + * The group info. + */ + private NewDeployGroupModel deployGroup; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public List getAccess() { + return access; + } + + public void setAccess(List access) { + this.access = access; + } + + public ApplicationModel getApplication() { + return application; + } + + public void setApplication(ApplicationModel application) { + this.application = application; + } + + public NewDeployGroupModel getDeployGroup() { + return deployGroup; + } + + public void setDeployGroup(NewDeployGroupModel deployGroup) { + this.deployGroup = deployGroup; + } + + + public CreateApplicationRequest addAccess(NewAccessModel accessModel) { + if (CollectionUtils.isEmpty(access)) { + access = new LinkedList(); + } + access.add(accessModel); + return this; + } + + public CreateApplicationRequest withApplication(ApplicationModel application) { + this.setApplication(application); + return this; + } + + public CreateApplicationRequest withDeployGroup(NewDeployGroupModel deployGroup) { + this.setDeployGroup(deployGroup); + return this; + } + + public CreateApplicationRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public CreateApplicationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/CreateApplicationResponse.java b/src/main/java/com/baidubce/services/cnap/model/application/CreateApplicationResponse.java new file mode 100644 index 00000000..a02bd838 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/CreateApplicationResponse.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.workspace.WorkspaceBaseInfoModel; + +/** + * The response for create application. + */ +public class CreateApplicationResponse extends AbstractBceResponse { + /** + * The id of application. + */ + private String resourceID; + + /** + * The name of application. + */ + private String name; + + /** + * The description of application. + */ + private String description; + + /** + * The deploy type of application. + */ + private int deployType; + + /** + * The type of application. + */ + private int workloadType; + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + /** + * The workspace base info. + */ + private WorkspaceBaseInfoModel workspace; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getDeployType() { + return deployType; + } + + public void setDeployType(int deployType) { + this.deployType = deployType; + } + + public int getWorkloadType() { + return workloadType; + } + + public void setWorkloadType(int workloadType) { + this.workloadType = workloadType; + } + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public WorkspaceBaseInfoModel getWorkspace() { + return workspace; + } + + public void setWorkspace(WorkspaceBaseInfoModel workspace) { + this.workspace = workspace; + } +} + diff --git a/src/main/java/com/baidubce/services/cnap/model/application/DeleteApplicationRequest.java b/src/main/java/com/baidubce/services/cnap/model/application/DeleteApplicationRequest.java new file mode 100644 index 00000000..bd19f6c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/DeleteApplicationRequest.java @@ -0,0 +1,96 @@ +package com.baidubce.services.cnap.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for delete application. + */ +public class DeleteApplicationRequest extends AbstractBceRequest { + + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The flag which indicates ignore under lay error. + */ + private boolean ignoreUnderlayError; + + /** + * The flag which indicates skip delete under lay. + */ + private boolean skipDeleteUnderlay; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public void setIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.ignoreUnderlayError = ignoreUnderlayError; + } + + public boolean getIgnoreUnderlayError() { + return ignoreUnderlayError; + } + + public void setSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.skipDeleteUnderlay = skipDeleteUnderlay; + } + + public boolean getSkipDeleteUnderlay() { + return skipDeleteUnderlay; + } + + public DeleteApplicationRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public DeleteApplicationRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + + } + + public DeleteApplicationRequest withIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.setIgnoreUnderlayError(ignoreUnderlayError); + return this; + } + + public DeleteApplicationRequest withSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.setSkipDeleteUnderlay(skipDeleteUnderlay); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public DeleteApplicationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/DeleteApplicationResponse.java b/src/main/java/com/baidubce/services/cnap/model/application/DeleteApplicationResponse.java new file mode 100644 index 00000000..4c927a3b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/DeleteApplicationResponse.java @@ -0,0 +1,9 @@ +package com.baidubce.services.cnap.model.application; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for delete application. + */ +public class DeleteApplicationResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/DeployGroupModel.java b/src/main/java/com/baidubce/services/cnap/model/application/DeployGroupModel.java new file mode 100644 index 00000000..f8288095 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/DeployGroupModel.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +import java.util.Date; + +/** + * The model of deploy group. + */ +public class DeployGroupModel { + /** + * The id of deploy group. + */ + private String resourceID; + + /** + * The name of deploy group. + */ + private String name; + + /** + * The description of deploy group. + */ + private String description; + + /** + * The deploy strategy type of deploy group. + */ + private String deployStrategyType; + + /** + * The replicas of deploy group; + */ + private int replicas; + + /** + * The type of deploy group. + */ + private int type; + + /** + * The environment id of deploy group. + */ + private String environmentID; + + /** + * Deploy group is locked. + */ + private boolean isLocked; + + /** + * The release record id of deploy group. + */ + private String releaseRecordID; + + /** + * The status of deploy group. + */ + private String status; + + /** + * The create time of deploy group. + */ + private Date createdAt; + + /** + * The update time of deploy group. + */ + private Date updatedAt; + + /** + * The cluster info of deploy group. + */ + private ClusterModel cluster; + + /** + * The environment info of deploy group. + */ + private EnvironmentModel environment; + + /** + * The resources of deploy group. + */ + private ResourcesModel resources; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDeployStrategyType() { + return deployStrategyType; + } + + public void setDeployStrategyType(String deployStrategyType) { + this.deployStrategyType = deployStrategyType; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public void setIsLocked(boolean isLocked) { + this.isLocked = isLocked; + } + + public boolean getIsLocked() { + return isLocked; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public ClusterModel getCluster() { + return cluster; + } + + public void setCluster(ClusterModel cluster) { + this.cluster = cluster; + } + + public EnvironmentModel getEnvironment() { + return environment; + } + + public void setEnvironment(EnvironmentModel environment) { + this.environment = environment; + } + + public ResourcesModel getResources() { + return resources; + } + + public void setResources(ResourcesModel resources) { + this.resources = resources; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/EnvironmentModel.java b/src/main/java/com/baidubce/services/cnap/model/application/EnvironmentModel.java new file mode 100644 index 00000000..6fea879f --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/EnvironmentModel.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +import java.util.Date; + +/** + * The model of Environment. + */ +public class EnvironmentModel { + + /** + * The id of environment. + */ + private String resourceID; + + /** + * The name of environment. + */ + private String name; + + /** + * The description of environment. + */ + private String description; + + /** + * The cluster id of environment. + */ + private String clusterID; + + /** + * The region of environment. + */ + private String region; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/ListApplicationRequest.java b/src/main/java/com/baidubce/services/cnap/model/application/ListApplicationRequest.java new file mode 100644 index 00000000..0621d42c --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/ListApplicationRequest.java @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list application. + */ +public class ListApplicationRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The orderBy info, eg. createdAt(workspace create time) + */ + private String orderBy = ""; + + /** + * The order info, eg. asc, desc. + */ + private String order = ""; + + /** + * The page size of list. + */ + private String pageSize = "10"; + + /** + * The page no of list. + */ + private String pageNo = "1"; + + /** + * The name of application. + */ + private String name; + + /** + * The id of application. + */ + private String resourceID; + + /** + * The type of application deploy. + * 1 indicates k8s deploy. + */ + private String deployType; + + /** + * The type of application. + * 1 indicates common application. + * 4 indicates micro service application. + */ + private int workloadType; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getPageSize() { + return pageSize; + } + + public void setPageSize(String pageSize) { + this.pageSize = pageSize; + } + + public String getPageNo() { + return pageNo; + } + + public void setPageNo(String pageNo) { + this.pageNo = pageNo; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getDeployType() { + return deployType; + } + + public void setDeployType(String deployType) { + this.deployType = deployType; + } + + public int getWorkloadType() { + return workloadType; + } + + public void setWorkloadType(int workloadType) { + this.workloadType = workloadType; + } + + public ListApplicationRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public ListApplicationRequest withOrderBy(String orderBy) { + this.setOrderBy(orderBy); + return this; + } + + public ListApplicationRequest withOrder(String order) { + this.setOrder(order); + return this; + } + + public ListApplicationRequest withPageSize(String pageSize) { + this.setPageSize(pageSize); + return this; + } + + public ListApplicationRequest withPageNo(String pageNo) { + this.setPageNo(pageNo); + return this; + } + + public ListApplicationRequest withName(String name) { + this.setName(name); + return this; + } + + public ListApplicationRequest withResourceID(String resourceID) { + this.setResourceID(resourceID); + return this; + } + + public ListApplicationRequest withDeployType(String deployType) { + this.setDeployType(deployType); + return this; + } + + public ListApplicationRequest withWorkloadType(int workloadType) { + this.setWorkloadType(workloadType); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListApplicationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/ListApplicationResponse.java b/src/main/java/com/baidubce/services/cnap/model/application/ListApplicationResponse.java new file mode 100644 index 00000000..6c53c72e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/ListApplicationResponse.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for list application. + */ +public class ListApplicationResponse extends AbstractBceResponse { + + /** + * The page size of list. + */ + private int pageSize; + + /** + * The page no of list. + */ + private int pageNo; + + /** + * The total count of list. + */ + private int totalCount; + + /** + * The result of list. + */ + private List result; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/PageApplicationModel.java b/src/main/java/com/baidubce/services/cnap/model/application/PageApplicationModel.java new file mode 100644 index 00000000..48711909 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/PageApplicationModel.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +import java.util.Date; +import java.util.List; + +/** + * The model of application. + */ +public class PageApplicationModel { + /** + * The id of application. + */ + private String resourceID; + + /** + * The name of application. + */ + private String name; + + /** + * The description of application. + */ + private String description; + + /** + * The create time of application. + */ + private Date createdAt; + + /** + * The update time of application. + */ + private Date updatedAt; + + /** + * The work load type of application. + */ + private int workloadType; + + /** + * The deploy type of application. + */ + private int deployType; + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The count of deploy group. + */ + private int deployGroupCount; + + /** + * The deploy group list. + */ + private List deployGroupList; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public int getWorkloadType() { + return workloadType; + } + + public void setWorkloadType(int workloadType) { + this.workloadType = workloadType; + } + + public int getDeployType() { + return deployType; + } + + public void setDeployType(int deployType) { + this.deployType = deployType; + } + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public int getDeployGroupCount() { + return deployGroupCount; + } + + public void setDeployGroupCount(int deployGroupCount) { + this.deployGroupCount = deployGroupCount; + } + + public List getDeployGroupList() { + return deployGroupList; + } + + public void setDeployGroupList(List deployGroupList) { + this.deployGroupList = deployGroupList; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/ResourceUsageModel.java b/src/main/java/com/baidubce/services/cnap/model/application/ResourceUsageModel.java new file mode 100644 index 00000000..7a78a14e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/ResourceUsageModel.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +/** + * The model of ResourceUsage. + */ +public class ResourceUsageModel { + /** + * The cpu info. + */ + private UsageModel cpu; + + /** + * The memory info. + */ + private UsageModel memory; + + public UsageModel getCpu() { + return cpu; + } + + public void setCpu(UsageModel cpu) { + this.cpu = cpu; + } + + public UsageModel getMemory() { + return memory; + } + + public void setMemory(UsageModel memory) { + this.memory = memory; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/ResourcesModel.java b/src/main/java/com/baidubce/services/cnap/model/application/ResourcesModel.java new file mode 100644 index 00000000..c61dae9c --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/ResourcesModel.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +/**workloadType + * The model of resources. + */ +public class ResourcesModel { + /** + * The info of cpu. + */ + private String cpuRequest; + + /** + * The info of memory. + */ + private String memRequest; + + public String getCpuRequest() { + return cpuRequest; + } + + public void setCpuRequest(String cpuRequest) { + this.cpuRequest = cpuRequest; + } + + public String getMemRequest() { + return memRequest; + } + + public void setMemRequest(String memRequest) { + this.memRequest = memRequest; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/UsageModel.java b/src/main/java/com/baidubce/services/cnap/model/application/UsageModel.java new file mode 100644 index 00000000..16edc42c --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/UsageModel.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.application; + +/** + * The model of cpu. + */ +public class UsageModel { + /** + * The left info. + */ + private String left; + + /** + * The request info. + */ + private String request; + + /** + * The total info. + */ + private String total; + + /** + * The used info. + */ + private String used; + + public String getLeft() { + return left; + } + + public void setLeft(String left) { + this.left = left; + } + + public String getRequest() { + return request; + } + + public void setRequest(String request) { + this.request = request; + } + + public String getTotal() { + return total; + } + + public void setTotal(String total) { + this.total = total; + } + + public String getUsed() { + return used; + } + + public void setUsed(String used) { + this.used = used; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/application/WorkloadType.java b/src/main/java/com/baidubce/services/cnap/model/application/WorkloadType.java new file mode 100644 index 00000000..f45ccc63 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/application/WorkloadType.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.application; + +public class WorkloadType { + + public static final int SIMPLE_APPLICATION = 1; + public static final int MICROSERVICE_APPLICATION = 4; + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/BindClusterToWorkspaceRequest.java b/src/main/java/com/baidubce/services/cnap/model/cluster/BindClusterToWorkspaceRequest.java new file mode 100644 index 00000000..f9baf3b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/BindClusterToWorkspaceRequest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.cluster; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for bind cluster. + */ +public class BindClusterToWorkspaceRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The cluster id list of imported cluster. + */ + private List clusterIDs = new ArrayList(); + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public List getClusterIDs() { + return clusterIDs; + } + + public void setClusterIDs(List clusterIDs) { + this.clusterIDs = clusterIDs; + } + + public BindClusterToWorkspaceRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public BindClusterToWorkspaceRequest withClusterIDs(List clusterIDs) { + this.setClusterIDs(clusterIDs); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public BindClusterToWorkspaceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/BindClusterToWorkspaceResponse.java b/src/main/java/com/baidubce/services/cnap/model/cluster/BindClusterToWorkspaceResponse.java new file mode 100644 index 00000000..b4fccee0 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/BindClusterToWorkspaceResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.cluster; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for bind cluster to workspace. + */ +public class BindClusterToWorkspaceResponse extends AbstractBceResponse { + /** + * The cluster id list. + */ + private List clusterIDs; + + public List getClusterIDs() { + return clusterIDs; + } + + public void setClusterIDs(List clusterIDs) { + this.clusterIDs = clusterIDs; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/ClusterModel.java b/src/main/java/com/baidubce/services/cnap/model/cluster/ClusterModel.java new file mode 100644 index 00000000..3cdaebac --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/ClusterModel.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.cluster; + +import java.util.Date; + +import com.baidubce.services.cnap.model.application.ResourceUsageModel; + +/** + * The model for cluster. + */ +public class ClusterModel { + /** + * The id of cluster. + */ + private String resourceID; + + /** + * The name of cluster. + */ + private String name; + + /** + * The description of cluster. + */ + private String description; + + /** + * The id of underlay cluster. + */ + private String underlayClusterID; + + /** + * The region of cluster. + */ + private String region; + + /** + * The type of cluster. + */ + private String type = "cce"; + + /** + * The slave vm count of cluster. + */ + private int slaveVmCount; + + /** + * The status of cluster. + */ + private String status; + + /** + * The resource usage. + */ + private ResourceUsageModel resourceUsage; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getUnderlayClusterID() { + return underlayClusterID; + } + + public void setUnderlayClusterID(String underlayClusterID) { + this.underlayClusterID = underlayClusterID; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int getSlaveVmCount() { + return slaveVmCount; + } + + public void setSlaveVmCount(int slaveVmCount) { + this.slaveVmCount = slaveVmCount; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public ResourceUsageModel getResourceUsage() { + return resourceUsage; + } + + public void setResourceUsage(ResourceUsageModel resourceUsage) { + this.resourceUsage = resourceUsage; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/ImportClusterRequest.java b/src/main/java/com/baidubce/services/cnap/model/cluster/ImportClusterRequest.java new file mode 100644 index 00000000..a3e7d70d --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/ImportClusterRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.cluster; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.apache.commons.collections.CollectionUtils; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for import cluster. + */ +public class ImportClusterRequest extends AbstractBceRequest { + + /** + * The workspace id list. + */ + private List> workspaceList; + + /** + * The cluster info. + */ + private NewClusterModel cluster; + + public void setWorkspaceList(List workspaceList) { + if (CollectionUtils.isEmpty(workspaceList)) { + return; + } + this.workspaceList = new LinkedList>(); + for (String workspaceID : workspaceList) { + Map info = new HashMap(); + info.put("workspaceID", workspaceID); + this.workspaceList.add(info); + } + } + + public NewClusterModel getCluster() { + return cluster; + } + + public void setCluster(NewClusterModel cluster) { + this.cluster = cluster; + } + + public ImportClusterRequest withWorkspaceList (List workspaceList) { + this.setWorkspaceList(workspaceList); + return this; + } + + public ImportClusterRequest withNewClusterModel (NewClusterModel model) { + this.setCluster(model); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ImportClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/ImportClusterResponse.java b/src/main/java/com/baidubce/services/cnap/model/cluster/ImportClusterResponse.java new file mode 100644 index 00000000..f9a4825a --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/ImportClusterResponse.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.cluster; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.application.ResourceUsageModel; + +/** + * The response for import cluster. + */ +public class ImportClusterResponse extends AbstractBceResponse { + /** + * The name of cluster. + */ + private String name; + + /** + * The region of cluster. + */ + private String region; + + /** + * The id of cluster. + */ + private String resourceID; + + /** + * The description of cluster. + */ + private String description; + + /** + * The type of cluster. + */ + private String type; + + /** + * The id of underlay cluster. + */ + private String underlayClusterID; + + /** + * The virtual machine count of cluster. + */ + private int slaveVmCount; + + /** + * The status of cluster. + */ + private String status; + + /** + * The create time of cluster. + */ + private Date createdAt; + + /** + * The update time of cluster. + */ + private Date updatedAt; + + /** + * The resource usage of cluster. + */ + private ResourceUsageModel resourceUsageModel; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUnderlayClusterID() { + return underlayClusterID; + } + + public void setUnderlayClusterID(String underlayClusterID) { + this.underlayClusterID = underlayClusterID; + } + + public int getSlaveVmCount() { + return slaveVmCount; + } + + public void setSlaveVmCount(int slaveVmCount) { + this.slaveVmCount = slaveVmCount; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public ResourceUsageModel getResourceUsageModel() { + return resourceUsageModel; + } + + public void setResourceUsageModel(ResourceUsageModel resourceUsageModel) { + this.resourceUsageModel = resourceUsageModel; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/NewClusterModel.java b/src/main/java/com/baidubce/services/cnap/model/cluster/NewClusterModel.java new file mode 100644 index 00000000..f7aab8ed --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/NewClusterModel.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.cluster; + +/** + * The model of cluster. + */ +public class NewClusterModel { + /** + * The region of cluster. + */ + private String region = "bj"; + + /** + * The id of underlay cluster. + */ + private String underlayClusterID; + + /** + * The type of cluster. + */ + private String type = "cce"; + + /** + * The description of cluster. + */ + private String description; + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getUnderlayClusterID() { + return underlayClusterID; + } + + public void setUnderlayClusterID(String underlayClusterID) { + this.underlayClusterID = underlayClusterID; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public NewClusterModel withRegion(String region) { + this.setRegion(region); + return this; + } + + public NewClusterModel withUnderlayClusterID(String underlayClusterID) { + this.setUnderlayClusterID(underlayClusterID); + return this; + } + + public NewClusterModel withType(String type) { + this.setType(type); + return this; + } + + public NewClusterModel withDescription(String description) { + this.setDescription(description); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/ReleaseClusterRequest.java b/src/main/java/com/baidubce/services/cnap/model/cluster/ReleaseClusterRequest.java new file mode 100644 index 00000000..2ba207a5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/ReleaseClusterRequest.java @@ -0,0 +1,75 @@ +package com.baidubce.services.cnap.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for release cluster. + */ +public class ReleaseClusterRequest extends AbstractBceRequest { + /** + * The id of cluster in cnap. + */ + private String clusterID; + + /** + * The flag which indicates skip delete underlay. + */ + private boolean skipDeleteUnderlay; + + /** + * The flag which indicates ignore underlay error. + */ + private boolean ignoreUnderlayError; + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public void setIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.ignoreUnderlayError = ignoreUnderlayError; + } + + public boolean getIgnoreUnderlayError() { + return ignoreUnderlayError; + } + + public void setSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.skipDeleteUnderlay = skipDeleteUnderlay; + } + + public boolean getSkipDeleteUnderlay() { + return skipDeleteUnderlay; + } + + public ReleaseClusterRequest withClusterID(String clusterID) { + this.clusterID = clusterID; + return this; + } + + public ReleaseClusterRequest withSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.setSkipDeleteUnderlay(skipDeleteUnderlay); + return this; + } + + public ReleaseClusterRequest withIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.setIgnoreUnderlayError(ignoreUnderlayError); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ReleaseClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/ReleaseClusterResponse.java b/src/main/java/com/baidubce/services/cnap/model/cluster/ReleaseClusterResponse.java new file mode 100644 index 00000000..e88a36c8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/ReleaseClusterResponse.java @@ -0,0 +1,154 @@ +package com.baidubce.services.cnap.model.cluster; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.application.ResourceUsageModel; + +/** + * The response for release cluster. + */ +public class ReleaseClusterResponse extends AbstractBceResponse { + /** + * The name of cluster. + */ + private String name; + + /** + * The region of cluster. + */ + private String region; + + /** + * The id of cluster. + */ + private String resourceID; + + /** + * The description of cluster. + */ + private String description; + + /** + * The type of cluster. + */ + private String type; + + /** + * The id of underlay cluster. + */ + private String underlayClusterID; + + /** + * The virtual machine count of cluster. + */ + private int slaveVmCount; + + /** + * The status of cluster. + */ + private String status; + + /** + * The create time of cluster. + */ + private Date createdAt; + + /** + * The update time of cluster. + */ + private Date updatedAt; + + /** + * The resource usage of cluster. + */ + private ResourceUsageModel resourceUsageModel; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUnderlayClusterID() { + return underlayClusterID; + } + + public void setUnderlayClusterID(String underlayClusterID) { + this.underlayClusterID = underlayClusterID; + } + + public int getSlaveVmCount() { + return slaveVmCount; + } + + public void setSlaveVmCount(int slaveVmCount) { + this.slaveVmCount = slaveVmCount; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public ResourceUsageModel getResourceUsageModel() { + return resourceUsageModel; + } + + public void setResourceUsageModel(ResourceUsageModel resourceUsageModel) { + this.resourceUsageModel = resourceUsageModel; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/UnbindClusterToWorkspaceRequest.java b/src/main/java/com/baidubce/services/cnap/model/cluster/UnbindClusterToWorkspaceRequest.java new file mode 100644 index 00000000..39f62bef --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/UnbindClusterToWorkspaceRequest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for unbind cluster. + */ +public class UnbindClusterToWorkspaceRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The cluster id. + */ + private String clusterID; + + /** + * The flag indicates whether can ignore underlay error. + */ + private boolean ignoreUnderlayError = false; + + /** + * The flag indicates whether can skip delete underlay. + */ + private boolean skipDeleteUnderlay = false; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public void setIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.ignoreUnderlayError = ignoreUnderlayError; + } + + public boolean getIgnoreUnderlayError() { + return ignoreUnderlayError; + } + + public void setSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.skipDeleteUnderlay = skipDeleteUnderlay; + } + + public boolean getSkipDeleteUnderlay() { + return skipDeleteUnderlay; + } + + public UnbindClusterToWorkspaceRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public UnbindClusterToWorkspaceRequest withClusterID(String clusterID) { + this.setClusterID(clusterID); + return this; + } + + public UnbindClusterToWorkspaceRequest withIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.setIgnoreUnderlayError(ignoreUnderlayError); + return this; + } + + public UnbindClusterToWorkspaceRequest withSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.setSkipDeleteUnderlay(skipDeleteUnderlay); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public UnbindClusterToWorkspaceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/cluster/UnbindClusterToWorkspaceResponse.java b/src/main/java/com/baidubce/services/cnap/model/cluster/UnbindClusterToWorkspaceResponse.java new file mode 100644 index 00000000..20279fd3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/cluster/UnbindClusterToWorkspaceResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.cluster; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for unbind cluster. + */ +public class UnbindClusterToWorkspaceResponse extends AbstractBceResponse { + /** + * The cluster id list. + */ + private List clusterIDs; + + public List getClusterIDs() { + return clusterIDs; + } + + public void setClusterIDs(List clusterIDs) { + this.clusterIDs = clusterIDs; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ComponentMeta.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ComponentMeta.java new file mode 100644 index 00000000..18bc4060 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ComponentMeta.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +public class ComponentMeta { + + /** + * The name of namespace. + */ + private String namespace; + + /** + * The name of workspace. + */ + private String workspaceName; + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The name of application. + */ + private String appName; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The name of deploy group. + */ + private String deployGroupName; + + /** + * The id of deploy group. + */ + private String deployGroupID; + + /** + * The id of cluster. + */ + private String clusterID; + + /** + * The owner info. + */ + private String owner; + + /** + * The env info. + */ + private String env; + + /** + * The name of deploy group. + */ + private String deploymentName; + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + public String getWorkspaceName() { + return workspaceName; + } + + public void setWorkspaceName(String workspaceName) { + this.workspaceName = workspaceName; + } + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getDeployGroupName() { + return deployGroupName; + } + + public void setDeployGroupName(String deployGroupName) { + this.deployGroupName = deployGroupName; + } + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getEnv() { + return env; + } + + public void setEnv(String env) { + this.env = env; + } + + public String getDeploymentName() { + return deploymentName; + } + + public void setDeploymentName(String deploymentName) { + this.deploymentName = deploymentName; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ComponentModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ComponentModel.java new file mode 100644 index 00000000..b1c6d78a --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ComponentModel.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for component. + */ +public class ComponentModel { + /** + * The name of component. eg, lama or config. + * + */ + private String name; + + /** + * The param of component. + */ + private Object params; + + /** + * The meta of component. + */ + private ComponentMeta meta; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Object getParams() { + return params; + } + + public void setParams(Object params) { + this.params = params; + } + + public ComponentMeta getMeta() { + return meta; + } + + public void setMeta(ComponentMeta meta) { + this.meta = meta; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ConfigCompnonetModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ConfigCompnonetModel.java new file mode 100644 index 00000000..6f449ffd --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ConfigCompnonetModel.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +/** + * The model for config component. + */ +public class ConfigCompnonetModel { + /** + * The config of container. + */ + private List containerConfigs; + + public List getContainerConfigs() { + return containerConfigs; + } + + public void setContainerConfigs(List containerConfigs) { + this.containerConfigs = containerConfigs; + } + + public ConfigCompnonetModel addContainerConfigModel(ContainerConfigModel containerConfigModel) { + if (CollectionUtils.isEmpty(containerConfigs)) { + containerConfigs = new LinkedList(); + } + containerConfigs.add(containerConfigModel); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ConfigComponentModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ConfigComponentModel.java new file mode 100644 index 00000000..ef0f6b3e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ConfigComponentModel.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.List; + +/** + * The model for config component. + */ +public class ConfigComponentModel { + + /** + * The container config list. + */ + private List containerConfigs; + + public List getContainerConfigs() { + return containerConfigs; + } + + public void setContainerConfigs( + List containerConfigs) { + this.containerConfigs = containerConfigs; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ConfigToDeployModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ConfigToDeployModel.java new file mode 100644 index 00000000..959cc83a --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ConfigToDeployModel.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for config to deploy. + */ +public class ConfigToDeployModel { + + /** + * The id of config. + */ + private String configID; + + /** + * The id of config version. + */ + private String configVersionID; + + /** + * The absolute path of config file. + */ + private String path; + + public String getConfigID() { + return configID; + } + + public void setConfigID(String configID) { + this.configID = configID; + } + + public String getConfigVersionID() { + return configVersionID; + } + + public void setConfigVersionID(String configVersionID) { + this.configVersionID = configVersionID; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public ConfigToDeployModel withConfigID(String configID) { + this.setConfigID(configID); + return this; + } + + public ConfigToDeployModel withConfigVersionID(String configVersionID) { + this.setConfigID(configVersionID); + return this; + } + + public ConfigToDeployModel withPath(String path) { + this.setPath(path); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ContainerConfigModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ContainerConfigModel.java new file mode 100644 index 00000000..2756e828 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ContainerConfigModel.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.List; + +/** + * The model for container config. + */ +public class ContainerConfigModel { + /** + * The name of container. + */ + private String containerName; + + /** + * The config to deploy list. + */ + private List configToDeploys; + + public String getContainerName() { + return containerName; + } + + public void setContainerName(String containerName) { + this.containerName = containerName; + } + + public List getConfigToDeploys() { + return configToDeploys; + } + + public void setConfigToDeploys( + List configToDeploys) { + this.configToDeploys = configToDeploys; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ContainerModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ContainerModel.java new file mode 100644 index 00000000..04ebda6f --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ContainerModel.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +/** + * The model for container. + */ +public class ContainerModel { + + /** + * The id of bap repository. + */ + private String bapRepositoryID; + + /** + * The name of image. + */ + private String name; + + /** + * The address of image. + */ + private String image; + + /** + * The command info. + */ + private List command; + + /** + * The argument info. + */ + private List argus; + + /** + * The environment info. + */ + private List env; + + /** + * The lifecycle info. + */ + private LifecycleModel lifecycle; + + /** + * The liveness probe info. + */ + private ProbeModel livenessProbe; + + /** + * The readiness probe info. + */ + private ProbeModel readinessProbe; + + /** + * The resource requirement. + */ + private ResourceRequirementsModel resources; + + public String getBapRepositoryID() { + return bapRepositoryID; + } + + public void setBapRepositoryID(String bapRepositoryID) { + this.bapRepositoryID = bapRepositoryID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public List getCommand() { + return command; + } + + public void setCommand(List command) { + this.command = command; + } + + public List getArgus() { + return argus; + } + + public void setArgus(List argus) { + this.argus = argus; + } + + public List getEnv() { + return env; + } + + public void setEnv(List env) { + this.env = env; + } + + public LifecycleModel getLifecycle() { + return lifecycle; + } + + public void setLifecycle(LifecycleModel lifecycle) { + this.lifecycle = lifecycle; + } + + public ProbeModel getLivenessProbe() { + return livenessProbe; + } + + public void setLivenessProbe(ProbeModel livenessProbe) { + this.livenessProbe = livenessProbe; + } + + public ProbeModel getReadinessProbe() { + return readinessProbe; + } + + public void setReadinessProbe(ProbeModel readinessProbe) { + this.readinessProbe = readinessProbe; + } + + public ResourceRequirementsModel getResources() { + return resources; + } + + public void setResources(ResourceRequirementsModel resources) { + this.resources = resources; + } + + public ContainerModel withBapRepositoryID(String bapRepositoryID) { + this.setBapRepositoryID(bapRepositoryID); + return this; + } + + public ContainerModel withName(String name) { + this.setName(name); + return this; + } + + public ContainerModel withImage(String image) { + this.setImage(image); + return this; + } + + public ContainerModel addCommand(String command) { + if (CollectionUtils.isEmpty(this.command)) { + this.command = new LinkedList(); + } + this.command.add(command); + return this; + } + + public ContainerModel addArgu(String argu) { + if (CollectionUtils.isEmpty(this.argus)) { + this.argus = new LinkedList(); + } + this.argus.add(argu); + return this; + } + + public ContainerModel addEnv(EnvVarModel envVarModel) { + if (CollectionUtils.isEmpty(this.env)) { + this.env = new LinkedList(); + } + this.env.add(envVarModel); + return this; + } + + public ContainerModel withLifecycle(LifecycleModel lifecycle) { + this.setLifecycle(lifecycle); + return this; + } + + public ContainerModel withLivenessProbe(ProbeModel livenessProbe) { + this.setLivenessProbe(livenessProbe); + return this; + } + + public ContainerModel withReadinessProbe(ProbeModel readinessProbe) { + this.setReadinessProbe(readinessProbe); + return this; + } + + public ContainerModel withResources(ResourceRequirementsModel resources) { + this.setResources(resources); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/CreateDeployGroupRequest.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/CreateDeployGroupRequest.java new file mode 100644 index 00000000..542934b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/CreateDeployGroupRequest.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cnap.model.access.NewAccessModel; + +/** + * The request for create deploy group. + */ +public class CreateDeployGroupRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The access info of deploy group. + */ + private List access; + + /** + * The deploy group info. + */ + private NewDeployGroupModel deployGroup; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public List getAccess() { + return access; + } + + public void setAccess(List access) { + this.access = access; + } + + public NewDeployGroupModel getDeployGroup() { + return deployGroup; + } + + public void setDeployGroup(NewDeployGroupModel deployGroup) { + this.deployGroup = deployGroup; + } + + public CreateDeployGroupRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public CreateDeployGroupRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public CreateDeployGroupRequest addAccess(NewAccessModel accessModel) { + if (CollectionUtils.isEmpty(access)) { + access = new LinkedList(); + } + this.access.add(accessModel); + return this; + } + + public CreateDeployGroupRequest withDeployGroup(NewDeployGroupModel deployGroup) { + this.setDeployGroup(deployGroup); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public CreateDeployGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/CreateDeployGroupResponse.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/CreateDeployGroupResponse.java new file mode 100644 index 00000000..04ad24bf --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/CreateDeployGroupResponse.java @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.Date; +import java.util.List; + + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.application.ApplicationBaseInfoModel; +import com.baidubce.services.cnap.model.application.EnvironmentModel; +import com.baidubce.services.cnap.model.application.ResourcesModel; +import com.baidubce.services.cnap.model.releaserecord.TaskBaseInfoModel; +import com.baidubce.services.cnap.model.workspace.WorkspaceBaseInfoModel; + +/** + * The response for create deploy group. + */ +public class CreateDeployGroupResponse extends AbstractBceResponse { + /** + * The id of deploy group. + */ + private String resourceID; + + /** + * The name of deploy group. + */ + private String name; + + + /** + * The type of deploy group. + */ + private int type; + + /** + * The description of deploy group. + */ + private String description; + + /** + * The id of environment. + */ + private String environmentID; + + /** + * The count of replicas. + */ + private int replicas; + + /** + * The flag which indicates deploy group is locked. + */ + private boolean isLocked; + + /** + * The id of release record. + */ + private String releaseRecordID; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + /** + * The resource info. + */ + private ResourcesModel resources; + + /** + * The type of deploy strategy. + */ + private String deployStrategyType; + + /** + * The deploy group conf. + */ + private DeploySpecModel conf; + + /** + * The component conf. + */ + private List componentConf; + + /** + * The workspace info. + */ + private WorkspaceBaseInfoModel workspace; + + /** + * The application info. + */ + private ApplicationBaseInfoModel application; + + /** + * The environment info. + */ + private EnvironmentModel environment; + + /** + * The task info. + */ + private TaskBaseInfoModel task; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public boolean getIsLocked() { + return this.isLocked; + } + + public void setIsLocked(boolean isLocked) { + this.isLocked = isLocked; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public ResourcesModel getResources() { + return resources; + } + + public void setResources(ResourcesModel resources) { + this.resources = resources; + } + + public String getDeployStrategyType() { + return deployStrategyType; + } + + public void setDeployStrategyType(String deployStrategyType) { + this.deployStrategyType = deployStrategyType; + } + + public DeploySpecModel getConf() { + return conf; + } + + public void setConf(DeploySpecModel conf) { + this.conf = conf; + } + + public List getComponentConf() { + return componentConf; + } + + public void setComponentConf(List componentConf) { + this.componentConf = componentConf; + } + + public WorkspaceBaseInfoModel getWorkspace() { + return workspace; + } + + public void setWorkspace(WorkspaceBaseInfoModel workspace) { + this.workspace = workspace; + } + + public ApplicationBaseInfoModel getApplication() { + return application; + } + + public void setApplication(ApplicationBaseInfoModel application) { + this.application = application; + } + + public EnvironmentModel getEnvironment() { + return environment; + } + + public void setEnvironment(EnvironmentModel environment) { + this.environment = environment; + } + + public TaskBaseInfoModel getTask() { + return task; + } + + public void setTask(TaskBaseInfoModel task) { + this.task = task; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/DataSourceModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DataSourceModel.java new file mode 100644 index 00000000..47110ac7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DataSourceModel.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for datasource. + */ +public class DataSourceModel { + /** + * The name of container. + */ + private String containerName; + + /** + * The flag which indicates standard output. + */ + private boolean isStdouterr; + + /** + * The path of log file. + */ + private String logFilePath; + + /** + * The flag which indicates has pods log. + */ + private boolean hasPodlogs; + + /** + * The flag which indicates has pod metrics. + */ + private boolean hasPodmetrics; + + /** + * The id info. + */ + private String id; + + /** + * The pid info. + */ + private String pid; + + public String getContainerName() { + return containerName; + } + + public void setContainerName(String containerName) { + this.containerName = containerName; + } + + public boolean getIsStdouterr() { + return isStdouterr; + } + + public void setIsStdouterr(boolean isStdouterr) { + this.isStdouterr = isStdouterr; + } + + public String getLogFilePath() { + return logFilePath; + } + + public void setLogFilePath(String logFilePath) { + this.logFilePath = logFilePath; + } + + public boolean isStdouterr() { + return isStdouterr; + } + + public void setStdouterr(boolean stdouterr) { + isStdouterr = stdouterr; + } + + public boolean isHasPodlogs() { + return hasPodlogs; + } + + public void setHasPodlogs(boolean hasPodlogs) { + this.hasPodlogs = hasPodlogs; + } + + public boolean isHasPodmetrics() { + return hasPodmetrics; + } + + public void setHasPodmetrics(boolean hasPodmetrics) { + this.hasPodmetrics = hasPodmetrics; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public DataSourceModel withContainerName(String containerName) { + this.setContainerName(containerName); + return this; + } + + public DataSourceModel withIsStdouterr(boolean isStdouterr) { + this.setIsStdouterr(isStdouterr); + return this; + } + + public DataSourceModel withLogFilePath(String logFilePath) { + this.setLogFilePath(logFilePath); + return this; + } + + public DataSourceModel withId(String id) { + this.setId(id); + return this; + } + + public DataSourceModel withHasPodlogs(boolean hasPodlogs) { + this.setHasPodlogs(hasPodlogs); + return this; + } + + public DataSourceModel withHasPodmetrics(boolean hasPodmetrics) { + this.setHasPodlogs(hasPodmetrics); + return this; + } + + public DataSourceModel withPid(String pid) { + this.setPid(pid); + return this; + } + + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeleteDeployGroupRequest.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeleteDeployGroupRequest.java new file mode 100644 index 00000000..2560fc57 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeleteDeployGroupRequest.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class DeleteDeployGroupRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The id of deploy group. + */ + private String deployGroupID; + + /** + * The flag which indicates ignore under lay error. + */ + private boolean ignoreUnderlayError = false; + + /** + * The flag which indicates skip delete underlay. + */ + private boolean skipDeleteUnderlay = false; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public void setIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.ignoreUnderlayError = ignoreUnderlayError; + } + + public boolean getIgnoreUnderlayError() { + return ignoreUnderlayError; + } + + public void setSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.skipDeleteUnderlay = skipDeleteUnderlay; + } + + public boolean getSkipDeleteUnderlay() { + return skipDeleteUnderlay; + } + + public DeleteDeployGroupRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public DeleteDeployGroupRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public DeleteDeployGroupRequest withDeployGroupID(String deployGroupID) { + this.setDeployGroupID(deployGroupID); + return this; + } + + public DeleteDeployGroupRequest withIgnoreUnderlayError(boolean ignoreUnderlayError ) { + this.setIgnoreUnderlayError(ignoreUnderlayError); + return this; + } + + public DeleteDeployGroupRequest withSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.setIgnoreUnderlayError(skipDeleteUnderlay); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public DeleteDeployGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeleteDeployGroupResponse.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeleteDeployGroupResponse.java new file mode 100644 index 00000000..244da5ef --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeleteDeployGroupResponse.java @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.Date; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.application.ApplicationBaseInfoModel; +import com.baidubce.services.cnap.model.application.EnvironmentModel; +import com.baidubce.services.cnap.model.application.ResourcesModel; +import com.baidubce.services.cnap.model.workspace.WorkspaceBaseInfoModel; + +/** + * The response for delete deploy group. + */ +public class DeleteDeployGroupResponse extends AbstractBceResponse { + /** + * The id of deploy group. + */ + private String resourceID; + + /** + * The name of deploy group. + */ + private String name; + + /** + * The description of deploy group. + */ + private String description; + + /** + * The environment id of deploy group. + */ + private String environmentID; + + /** + * The replicas of deploy group; + */ + private int replicas; + + /** + * Deploy group is locked. + */ + private boolean isLocked; + + /** + * The release record id of deploy group. + */ + private String releaseRecordID; + + /** + * The status of deploy group. + */ + private String status; + + /** + * The create time of deploy group. + */ + private Date createdAt; + + /** + * The update time of deploy group. + */ + private Date updatedAt; + + /** + * The resources of deploy group. + */ + private ResourcesModel resources; + + /** + * The deploy strategy type of deploy group. + */ + private String deployStrategyType; + + /** + * The conf of deploy group. + */ + private DeploySpecModel conf; + + /** + * The component conf. + */ + private List componentConf; + + /** + * The workspace info. + */ + private WorkspaceBaseInfoModel workspace; + + /** + * The application info. + */ + private ApplicationBaseInfoModel application; + + /** + * The environment info of deploy group. + */ + private EnvironmentModel environment; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public void setIsLocked(boolean isLocked) { + this.isLocked = isLocked; + } + + public boolean getIsLocked() { + return this.isLocked; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public ResourcesModel getResources() { + return resources; + } + + public void setResources(ResourcesModel resources) { + this.resources = resources; + } + + public String getDeployStrategyType() { + return deployStrategyType; + } + + public void setDeployStrategyType(String deployStrategyType) { + this.deployStrategyType = deployStrategyType; + } + + public DeploySpecModel getConf() { + return conf; + } + + public void setConf(DeploySpecModel conf) { + this.conf = conf; + } + + public List getComponentConf() { + return componentConf; + } + + public void setComponentConf(List componentConf) { + this.componentConf = componentConf; + } + + public WorkspaceBaseInfoModel getWorkspace() { + return workspace; + } + + public void setWorkspace(WorkspaceBaseInfoModel workspace) { + this.workspace = workspace; + } + + public ApplicationBaseInfoModel getApplication() { + return application; + } + + public void setApplication(ApplicationBaseInfoModel application) { + this.application = application; + } + + public EnvironmentModel getEnvironment() { + return environment; + } + + public void setEnvironment(EnvironmentModel environment) { + this.environment = environment; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeployGroupType.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeployGroupType.java new file mode 100644 index 00000000..b04afbc2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeployGroupType.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.deploygroup; + +public class DeployGroupType { + + /** + * The type of normal deploy group. + */ + public static final int NORMAL = 1; + + /** + * The type of empty deploy group. + */ + public static final int EMPTY = 2; +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeployGroupWithConfigModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeployGroupWithConfigModel.java new file mode 100644 index 00000000..e8ec94a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeployGroupWithConfigModel.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.Date; +import java.util.List; + +import com.baidubce.services.cnap.model.application.ResourcesModel; + +/** + * The model for deploy group with config. + */ +public class DeployGroupWithConfigModel { + + /** + * The id of deploy group. + */ + private String resourceID; + + /** + * The name of deploy group. + */ + private String name; + + /** + * The description of deploy group. + */ + private String description; + + /** + * The replicas of deploy group. + */ + private int replicas; + + /** + * The id of environment. + */ + private String environmentID; + + /** + * The flag which indicates the deploy group is locked. + */ + private boolean isLocked; + + /** + * The release record id. + */ + private String releaseRecordID; + + /** + * The resource usage of deploy group. + */ + private ResourcesModel resources; + + /** + * The component conf of deploy group. + */ + private List componentConf; + + /** + * The conf of deploy group. + */ + private DeploySpecModel conf; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public void setIsLocked(boolean isLocked) { + this.isLocked = isLocked; + } + + public boolean getIsLocked() { + return this.isLocked; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public ResourcesModel getResources() { + return resources; + } + + public void setResources(ResourcesModel resources) { + this.resources = resources; + } + + public List getComponentConf() { + return componentConf; + } + + public void setComponentConf(List componentConf) { + this.componentConf = componentConf; + } + + public DeploySpecModel getConf() { + return conf; + } + + public void setConf(DeploySpecModel conf) { + this.conf = conf; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeploySpecModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeploySpecModel.java new file mode 100644 index 00000000..9b723091 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeploySpecModel.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.LinkedList; +import java.util.List; + +/** + * The model for deploy specification. + */ +public class DeploySpecModel { + + /** + * The container list. + */ + private List containers = new LinkedList(); + + public List getContainers() { + return containers; + } + + public void setContainers(List containers) { + this.containers = containers; + } + + public DeploySpecModel withContainers(List containers) { + this.setContainers(containers); + return this; + } + + public DeploySpecModel addContainerModel(ContainerModel container) { + this.containers.add(container); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeployTaskModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeployTaskModel.java new file mode 100644 index 00000000..79f68632 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/DeployTaskModel.java @@ -0,0 +1,86 @@ +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.Date; + +/** + * The model for deploy task. + */ +public class DeployTaskModel { + /** + * The id of task. + */ + private String taskID; + + /** + * The type of task. + */ + private String type; + + /** + * The id of deploy group. + */ + private String deployGroupID; + + /** + * The name of deploy group. + */ + private String deployGroupName; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + public String getTaskID() { + return taskID; + } + + public void setTaskID(String taskID) { + this.taskID = taskID; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public String getDeployGroupName() { + return deployGroupName; + } + + public void setDeployGroupName(String deployGroupName) { + this.deployGroupName = deployGroupName; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/EnvVarModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/EnvVarModel.java new file mode 100644 index 00000000..b7a6d8cf --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/EnvVarModel.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for environment var. + */ +public class EnvVarModel { + /** + * The name of environment. + */ + private String name; + + /** + * The value of environment. + */ + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public EnvVarModel withName(String name) { + this.setName(name); + return this; + } + + public EnvVarModel withValue(String value) { + this.setValue(value); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ExecActionModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ExecActionModel.java new file mode 100644 index 00000000..8991bd0b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ExecActionModel.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.List; + +/** + * The model for exec action. + */ +public class ExecActionModel { + private List command; + + public List getCommand() { + return command; + } + + public void setCommand(List command) { + this.command = command; + } + + public ExecActionModel withCommand(List command) { + this.setCommand(command); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/GetDeployGroupRequest.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/GetDeployGroupRequest.java new file mode 100644 index 00000000..5336214e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/GetDeployGroupRequest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get deploy group. + */ +public class GetDeployGroupRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The id of deploy group. + */ + private String deployGroupID; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public GetDeployGroupRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public GetDeployGroupRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public GetDeployGroupRequest withDeployGroupID(String deployGroupID) { + this.setDeployGroupID(deployGroupID); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public GetDeployGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/GetDeployGroupResponse.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/GetDeployGroupResponse.java new file mode 100644 index 00000000..9711529b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/GetDeployGroupResponse.java @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.Date; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.application.ApplicationBaseInfoModel; +import com.baidubce.services.cnap.model.application.EnvironmentModel; +import com.baidubce.services.cnap.model.application.ResourcesModel; +import com.baidubce.services.cnap.model.workspace.WorkspaceBaseInfoModel; + +/** + * The response for get deploy group. + */ +public class GetDeployGroupResponse extends AbstractBceResponse { + /** + * The id of deploy group. + */ + private String resourceID; + + /** + * The name of deploy group. + */ + private String name; + + /** + * The description of deploy group. + */ + private String description; + + /** + * The id of environment. + */ + private String environmentID; + + /** + * The count of replicas. + */ + private int replicas; + + /** + * The flag which indicates deploy group is locked. + */ + private boolean isLocked; + + /** + * The type of deploy group. + */ + private int type; + + /** + * The id of release record. + */ + private String releaseRecordID; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + /** + * The resource info. + */ + private ResourcesModel resources; + + /** + * The type of deploy strategy. + */ + private String deployStrategyType; + + /** + * The deploy group conf. + */ + private DeploySpecModel conf; + + /** + * The component conf. + */ + private List componentConf; + + /** + * The workspace info. + */ + private WorkspaceBaseInfoModel workspace; + + /** + * The application info. + */ + private ApplicationBaseInfoModel application; + + /** + * The environment info. + */ + private EnvironmentModel environment; + + /** + * The status of deploy group. + */ + private String status; + + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public void setIsLocked(boolean isLocked) { + this.isLocked = isLocked; + } + + public boolean getIsLocked() { + return this.isLocked; + + } + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public ResourcesModel getResources() { + return resources; + } + + public void setResources(ResourcesModel resources) { + this.resources = resources; + } + + public String getDeployStrategyType() { + return deployStrategyType; + } + + public void setDeployStrategyType(String deployStrategyType) { + this.deployStrategyType = deployStrategyType; + } + + public DeploySpecModel getConf() { + return conf; + } + + public void setConf(DeploySpecModel conf) { + this.conf = conf; + } + + public List getComponentConf() { + return componentConf; + } + + public void setComponentConf(List componentConf) { + this.componentConf = componentConf; + } + + public WorkspaceBaseInfoModel getWorkspace() { + return workspace; + } + + public void setWorkspace(WorkspaceBaseInfoModel workspace) { + this.workspace = workspace; + } + + public ApplicationBaseInfoModel getApplication() { + return application; + } + + public void setApplication(ApplicationBaseInfoModel application) { + this.application = application; + } + + public EnvironmentModel getEnvironment() { + return environment; + } + + public void setEnvironment(EnvironmentModel environment) { + this.environment = environment; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/GrokConfigModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/GrokConfigModel.java new file mode 100644 index 00000000..30975bcf --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/GrokConfigModel.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +/** + * The model for grok config. + */ +public class GrokConfigModel { + /** + * The list of additional patterns. + */ + private List additionalPatterns; + + public List getAdditionalPatterns() { + return additionalPatterns; + } + + public void setAdditionalPatterns(List additionalPatterns) { + this.additionalPatterns = additionalPatterns; + } + + public GrokConfigModel addAdditionalPatterns(String additionalPattern) { + if (CollectionUtils.isEmpty(additionalPatterns)) { + additionalPatterns = new LinkedList(); + } + additionalPatterns.add(additionalPattern); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/HTTPGetActionModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/HTTPGetActionModel.java new file mode 100644 index 00000000..e5537719 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/HTTPGetActionModel.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for http get action. + */ +public class HTTPGetActionModel { + + /** + * The path of url. + */ + private String path; + + /** + * The port. + */ + private int port; + + /** + * The host info. + */ + private String host; + + /** + * The scheme. + */ + private String scheme; + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getScheme() { + return scheme; + } + + public void setScheme(String scheme) { + this.scheme = scheme; + } + + public HTTPGetActionModel withPath(String path) { + this.setPath(path); + return this; + } + + public HTTPGetActionModel withPort(int port) { + this.setPort(port); + return this; + } + + public HTTPGetActionModel withHost(String host) { + this.setHost(host); + return this; + } + + public HTTPGetActionModel withScheme(String scheme) { + this.setScheme(scheme); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/HandlerModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/HandlerModel.java new file mode 100644 index 00000000..c3a8a8dc --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/HandlerModel.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for hander. + */ +public class HandlerModel { + /** + * The exec action model. + */ + private ExecActionModel exec; + + /** + * The http get action model. + */ + private HTTPGetActionModel httpGet; + + /** + * The tcp socket action model. + */ + private TCPSocketActionModel tcpSocket; + + public ExecActionModel getExec() { + return exec; + } + + public void setExec(ExecActionModel exec) { + this.exec = exec; + } + + public HTTPGetActionModel getHttpGet() { + return httpGet; + } + + public void setHttpGet(HTTPGetActionModel httpGet) { + this.httpGet = httpGet; + } + + public TCPSocketActionModel getTcpSocket() { + return tcpSocket; + } + + public void setTcpSocket(TCPSocketActionModel tcpSocket) { + this.tcpSocket = tcpSocket; + } + + public HandlerModel withExecActionModel(ExecActionModel exec) { + this.setExec(exec); + return this; + } + + public HandlerModel withHTTPGetActionModel(HTTPGetActionModel httpGet) { + this.setHttpGet(httpGet); + return this; + } + + public HandlerModel withTCPSocketAction(TCPSocketActionModel tcpSocket) { + this.setTcpSocket(tcpSocket); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/InputConfigModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/InputConfigModel.java new file mode 100644 index 00000000..6e72b918 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/InputConfigModel.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for input config. + */ +public class InputConfigModel { + /** + * The flag which indicates read all. + */ + private boolean readall; + + /** + * The data source of metric. + */ + private DataSourceModel metricFileFilter; + + public boolean getReadall() { + return readall; + } + + public void setReadall(boolean readall) { + this.readall = readall; + } + + public DataSourceModel getMetricFileFilter() { + return metricFileFilter; + } + + public void setMetricFileFilter(DataSourceModel metricFileFilter) { + this.metricFileFilter = metricFileFilter; + } + + public InputConfigModel withReadall(boolean readall) { + this.setReadall(readall); + return this; + } + + public InputConfigModel withMetricFileFilter(DataSourceModel metricFileFilter) { + this.setMetricFileFilter(metricFileFilter); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/LamaConfigModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/LamaConfigModel.java new file mode 100644 index 00000000..f70b97eb --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/LamaConfigModel.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +/** + * The model for lama config. + */ +public class LamaConfigModel { + + /** + * The list of data source. + */ + private List dataSources; + + /** + * The config of pod log. + */ + private PodLogsConfigModel podLogsConfig; + + /** + * The config of pod metrics. + */ + private PodMetricsConfigModel podMetricsConfig; + + public List getDataSources() { + return dataSources; + } + + public void setDataSources(List dataSources) { + this.dataSources = dataSources; + } + + public PodLogsConfigModel getPodLogsConfig() { + return podLogsConfig; + } + + public void setPodLogsConfig(PodLogsConfigModel podLogsConfig) { + this.podLogsConfig = podLogsConfig; + } + + public PodMetricsConfigModel getPodMetricsConfig() { + return podMetricsConfig; + } + + public void setPodMetricsConfig(PodMetricsConfigModel podMetricsConfig) { + this.podMetricsConfig = podMetricsConfig; + } + + public LamaConfigModel addDatasourceModel(DataSourceModel dataSourceModel) { + if (CollectionUtils.isEmpty(dataSources)) { + dataSources = new LinkedList(); + } + dataSources.add(dataSourceModel); + return this; + } + + public LamaConfigModel withPodLogsConfig(PodLogsConfigModel podLogsConfig) { + this.setPodLogsConfig(podLogsConfig); + return this; + } + + public LamaConfigModel withPodMetricsConfigModel(PodMetricsConfigModel podMetricsConfig) { + this.setPodMetricsConfig(podMetricsConfig); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/LifecycleModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/LifecycleModel.java new file mode 100644 index 00000000..14918f97 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/LifecycleModel.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for container lifecycle. + */ +public class LifecycleModel { + /** + * The post start handler. + */ + private HandlerModel postStart; + + /** + * The pre stop handler. + */ + private HandlerModel preStop; + + public HandlerModel getPostStart() { + return postStart; + } + + public void setPostStart(HandlerModel postStart) { + this.postStart = postStart; + } + + public HandlerModel getPreStop() { + return preStop; + } + + public void setPreStop(HandlerModel preStop) { + this.preStop = preStop; + } + + public LifecycleModel withPostStart(HandlerModel postStart) { + this.setPostStart(postStart); + return this; + } + + public LifecycleModel withPreStop(HandlerModel preStop) { + this.setPreStop(preStop); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByImageRequest.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByImageRequest.java new file mode 100644 index 00000000..1c05b97c --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByImageRequest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list deploy group by image. + */ +public class ListDeployGroupByImageRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The images info, eg: nginx or nginx,mysql. + */ + private String images; + + /** + * The config id, eg: cm-QQSJFPQa or cm-CCSZEPQb + */ + private String configIDs; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getImages() { + return images; + } + + public void setImages(String images) { + this.images = images; + } + + public String getConfigIDs() { + return configIDs; + } + + public void setConfigIDs(String configIDs) { + this.configIDs = configIDs; + } + + public ListDeployGroupByImageRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public ListDeployGroupByImageRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public ListDeployGroupByImageRequest withImages(String images) { + this.setImages(images); + return this; + } + + public ListDeployGroupByImageRequest withConfigIDs(String configIDs) { + this.setConfigIDs(configIDs); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListDeployGroupByImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByImageResponse.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByImageResponse.java new file mode 100644 index 00000000..02c758d9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByImageResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for list deploy group by image. + */ +public class ListDeployGroupByImageResponse extends AbstractBceResponse { + + /** + * The result list. + */ + private List result; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByPageRequest.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByPageRequest.java new file mode 100644 index 00000000..1a1ff2c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByPageRequest.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list deploy group by page. + */ +public class ListDeployGroupByPageRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + + /** + * The orderBy info. + */ + private String orderBy = ""; + + /** + * The order info, eg. asc, desc. + */ + private String order = ""; + + /** + * The page size of list. + */ + private String pageSize = "10"; + + /** + * The page no of list. + */ + private String pageNo = "1"; + + /** + * The image info. + */ + private String images; + + /** + * The config id list. + */ + private String configIDs; + + /** + * The name of deploy group. + */ + private String name; + + /** + * The environment of deploy group. + */ + private String environmentID; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getPageSize() { + return pageSize; + } + + public void setPageSize(String pageSize) { + this.pageSize = pageSize; + } + + public String getPageNo() { + return pageNo; + } + + public void setPageNo(String pageNo) { + this.pageNo = pageNo; + } + + public String getImages() { + return images; + } + + public void setImages(String images) { + this.images = images; + } + + public String getConfigIDs() { + return configIDs; + } + + public void setConfigIDs(String configIDs) { + this.configIDs = configIDs; + } + + public ListDeployGroupByPageRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public ListDeployGroupByPageRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + + public ListDeployGroupByPageRequest withOrderBy(String orderBy) { + this.setOrderBy(orderBy); + return this; + } + + public ListDeployGroupByPageRequest withOrder(String order) { + this.setOrder(order); + return this; + } + + public ListDeployGroupByPageRequest withPageSize(String pageSize) { + this.setPageSize(pageSize); + return this; + } + + public ListDeployGroupByPageRequest withPageNo(String pageNo) { + this.setPageNo(pageNo); + return this; + } + + public ListDeployGroupByPageRequest withImages(String images) { + this.setImages(images); + return this; + } + + public ListDeployGroupByPageRequest withConfigIDs(String configIDs) { + this.setConfigIDs(configIDs); + return this; + } + + public ListDeployGroupByPageRequest withName(String name) { + this.setName(name); + return this; + } + + public ListDeployGroupByPageRequest withEnvironmentID(String environmentID) { + this.setEnvironmentID(environmentID); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListDeployGroupByPageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByPageResponse.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByPageResponse.java new file mode 100644 index 00000000..360c7c50 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ListDeployGroupByPageResponse.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.application.DeployGroupModel; + +/** + * The response for list deploy group by page. + */ +public class ListDeployGroupByPageResponse extends AbstractBceResponse { + + /** + * The page no info. + */ + private int pageNo; + + /** + * The page size info. + */ + private int pageSize; + + /** + * The total count info. + */ + private int totalCount; + + /** + * The result info. + */ + private List result; + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/LogConfigModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/LogConfigModel.java new file mode 100644 index 00000000..60818ea2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/LogConfigModel.java @@ -0,0 +1,358 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.HashMap; +import java.util.Map; + +/** + * The model for log config. + */ +public class LogConfigModel { + + /** + * The tags of log. + */ + private Map logsTags = new HashMap(); + + /** + * The type of log output. eg: "Compnonent" or "ElasticSearch" + * + */ + private String logsOutputType; + + /** + * The exclude path. + */ + private String excludePath; + + /** + * The data source of this log strategy. + */ + private DataSourceModel logFileFilter; + + /** + * The flag which indicates log parser. + */ + private boolean isLogParserEnabled; + + /** + * The type of parser. + */ + private String parserType = "json"; + + /** + * The formate of parser log. + */ + private String parserLogFormat; + + /** + * The time key. + */ + private String timeKey; + + /** + * The time format. + */ + private String timeFormat; + + /** + * The id of plugin. + */ + private String pluginInsID; + + /** + * The host of Elasticsearch. + */ + private String host; + + /** + * The index of Elasticsearch. + */ + private String index; + + /** + * The flag which indicates log stash format. + */ + private boolean logstashFormat; + + /** + * The prefix of log stash. + */ + private String logstashPrefix; + + /** + * The data format of log stash. + */ + private String logstashDateFormat; + + /** + * The auth info. + */ + private String auth; + + /** + * The user name of Elasticsearch. + */ + private String userName; + + /** + * The password of Elasticsearch. + */ + private String password; + + /** + * The pid info. + */ + private String pid; + + + public Map getLogsTags() { + return logsTags; + } + + public void setLogsTags(Map logsTags) { + this.logsTags = logsTags; + } + + public String getLogsOutputType() { + return logsOutputType; + } + + public void setLogsOutputType(String logsOutputType) { + this.logsOutputType = logsOutputType; + } + + public String getExcludePath() { + return excludePath; + } + + public void setExcludePath(String excludePath) { + this.excludePath = excludePath; + } + + public DataSourceModel getLogFileFilter() { + return logFileFilter; + } + + public void setLogFileFilter(DataSourceModel logFileFilter) { + this.logFileFilter = logFileFilter; + } + + public void setIsLogParserEnabled(boolean isLogParserEnabled) { + this.isLogParserEnabled = isLogParserEnabled; + } + + public boolean getIsLogParserEnabled() { + return this.isLogParserEnabled; + } + + public String getParserType() { + return parserType; + } + + public void setParserType(String parserType) { + this.parserType = parserType; + } + + public String getParserLogFormat() { + return parserLogFormat; + } + + public void setParserLogFormat(String parserLogFormat) { + this.parserLogFormat = parserLogFormat; + } + + public String getTimeKey() { + return timeKey; + } + + public void setTimeKey(String timeKey) { + this.timeKey = timeKey; + } + + public String getTimeFormat() { + return timeFormat; + } + + public void setTimeFormat(String timeFormat) { + this.timeFormat = timeFormat; + } + + public String getPluginInsID() { + return pluginInsID; + } + + public void setPluginInsID(String pluginInsID) { + this.pluginInsID = pluginInsID; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + public boolean getLogstashFormat() { + return logstashFormat; + } + + public void setLogstashFormat(boolean logstashFormat) { + this.logstashFormat = logstashFormat; + } + + public String getLogstashPrefix() { + return logstashPrefix; + } + + public void setLogstashPrefix(String logstashPrefix) { + this.logstashPrefix = logstashPrefix; + } + + public String getLogstashDateFormat() { + return logstashDateFormat; + } + + public void setLogstashDateFormat(String logstashDateFormat) { + this.logstashDateFormat = logstashDateFormat; + } + + public String getAuth() { + return auth; + } + + public void setAuth(String auth) { + this.auth = auth; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public LogConfigModel withLogsOutputType(String logsOutputType) { + this.setLogsOutputType(logsOutputType); + return this; + } + + public LogConfigModel withExcludePath(String excludePath) { + this.setExcludePath(excludePath); + return this; + } + + public LogConfigModel withLogFileFilter(DataSourceModel logFileFilter) { + this.setLogFileFilter(logFileFilter); + return this; + } + + public LogConfigModel withIsLogParserEnabled(boolean isLogParserEnabled) { + this.setIsLogParserEnabled(isLogParserEnabled); + return this; + } + + public LogConfigModel withParserLogFormat(String parserLogFormat) { + this.setParserLogFormat(parserLogFormat); + return this; + } + + public LogConfigModel withTimeKey(String timeKey) { + this.setTimeKey(timeKey); + return this; + } + + public LogConfigModel withTimeFormat(String timeFormat) { + this.setTimeFormat(timeFormat); + return this; + } + + public LogConfigModel withPluginInsID(String pluginInsID) { + this.setPluginInsID(pluginInsID); + return this; + } + + public LogConfigModel withHost(String host) { + this.setHost(host); + return this; + } + + public LogConfigModel withIndex(String index) { + this.setIndex(index); + return this; + } + + public LogConfigModel withLogstashFormat(boolean logstashFormat) { + this.setLogstashFormat(logstashFormat); + return this; + } + + public LogConfigModel withLogstashPrefix(String logstashPrefix) { + this.setLogstashPrefix(logstashPrefix); + return this; + } + + public LogConfigModel withLogstashDateFormat(String logstashDateFormat) { + this.setLogstashFormat(logstashFormat); + return this; + } + + public LogConfigModel withAuth(String auth) { + this.setAuth(auth); + return this; + } + + public LogConfigModel withUserName(String userName) { + this.setUserName(userName); + return this; + } + + public LogConfigModel withPassword(String password) { + this.setPassword(password); + return this; + } + + public LogConfigModel withPid(String pid) { + this.setPid(pid); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/MetricConfigModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/MetricConfigModel.java new file mode 100644 index 00000000..657c63bd --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/MetricConfigModel.java @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.mortbay.util.StringUtil; + +/** + * The model for metric config. + */ +public class MetricConfigModel { + + /** + * The type of metric. + * eg counter, gauge, summary, histogram + */ + private String type; + + /** + * The name of metric. + */ + private String name; + + /** + * The help of metric. + */ + private String help; + + /** + * The match pattern. + */ + private String match; + + /** + * The labels info. + */ + private Map labels = new HashMap(); + + /** + * The value of metric. + */ + private String value; + + /** + * The retention info. + */ + private String retention; + + /** + * The flag which indicates cumulative. + */ + private boolean gaugeCumulative; + + /** + * The list histogram Bucket. + */ + private List histogramBuckets; + + /** + * The summary quantiles. + */ + private List summaryQuantiles; + + /** + * The datasource 0f metric. + */ + private DataSourceModel metricFileFilter; + + /** + * The pid info. + */ + private String pid; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getHelp() { + return help; + } + + public void setHelp(String help) { + this.help = help; + } + + public String getMatch() { + return match; + } + + public void setMatch(String match) { + this.match = match; + } + + public Map getLabels() { + return labels; + } + + public void setLabels(Map labels) { + this.labels = labels; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getRetention() { + return retention; + } + + public void setRetention(String retention) { + this.retention = retention; + } + + public void setGaugeCumulative(boolean gaugeCumulative) { + this.gaugeCumulative = gaugeCumulative; + } + + public boolean getGaugeCumulative() { + return this.gaugeCumulative; + } + + public List getHistogramBuckets() { + return histogramBuckets; + } + + public void setHistogramBuckets(List histogramBuckets) { + this.histogramBuckets = histogramBuckets; + } + + public List getSummaryQuantiles() { + return summaryQuantiles; + } + + public void setSummaryQuantiles(List summaryQuantiles) { + this.summaryQuantiles = summaryQuantiles; + } + + public DataSourceModel getMetricFileFilter() { + return metricFileFilter; + } + + public void setMetricFileFilter(DataSourceModel metricFileFilter) { + this.metricFileFilter = metricFileFilter; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public MetricConfigModel withType(String type) { + this.setType(type); + return this; + } + + public MetricConfigModel withName(String name) { + this.setName(name); + return this; + } + + public MetricConfigModel withHelp(String help) { + this.setHelp(help); + return this; + } + + public MetricConfigModel withMatch(String match) { + this.setMatch(match); + return this; + } + + public MetricConfigModel withValue(String value) { + this.setValue(value); + return this; + } + + public MetricConfigModel withRetention(String retention) { + this.setRetention(retention); + return this; + } + + public MetricConfigModel withGaugeCumulative(boolean gaugeCumulative) { + this.setGaugeCumulative(gaugeCumulative); + return this; + } + + public MetricConfigModel addHistogramBuckets(String histogramBucket) { + if (StringUtils.isEmpty(histogramBucket)) { + histogramBuckets = new LinkedList(); + } + histogramBuckets.add(histogramBucket); + return this; + } + + public MetricConfigModel addSummaryQuantiles(String summaryQuantily) { + if (StringUtils.isEmpty(summaryQuantily)) { + summaryQuantiles = new LinkedList(); + } + summaryQuantiles.add(summaryQuantily); + return this; + } + + public MetricConfigModel withMetricFileFilter(DataSourceModel metricFileFilter) { + this.setMetricFileFilter(metricFileFilter); + return this; + } + + public MetricConfigModel withPid(String pid) { + this.setPid(pid); + return this; + } + + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/NewComponentModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/NewComponentModel.java new file mode 100644 index 00000000..96540e1d --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/NewComponentModel.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for component. + */ +public class NewComponentModel { + /** + * The name of component. + * eg. lama or config. + */ + private String name; + + /** + * The params, eg ConfigCompnonetModel or LamaConfigModel. + */ + private Object params; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Object getParams() { + return params; + } + + public void setParams(Object params) { + this.params = params; + } + + public NewComponentModel withName(String name) { + this.setName(name); + return this; + } + + public NewComponentModel withParams(Object params) { + this.setParams(params); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/NewDeployGroupModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/NewDeployGroupModel.java new file mode 100644 index 00000000..f53dad97 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/NewDeployGroupModel.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.LinkedList; +import java.util.List; + +/** + * The model for deploy group. + */ +public class NewDeployGroupModel { + /** + * The name of deploy group. + */ + private String name; + + /** + * The description of deploy group. + */ + private String description = ""; + + /** + * The environment id of deploy group. + */ + private String environmentID; + + /** + * The count of replicas. + */ + private int replicas = 1; + + /** + * The type of deploy group. + */ + private int type = DeployGroupType.NORMAL; + + /** + * The type of deploy strategy. + * RollingUpdate or Recreate. + */ + private String deployStrategyType = "RollingUpdate"; + + /** + * The config of deploy group component. + */ + private List componentConf = new LinkedList(); + + /** + * The config of deploy group. + */ + private DeploySpecModel conf; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public String getDeployStrategyType() { + return deployStrategyType; + } + + public void setDeployStrategyType(String deployStrategyType) { + this.deployStrategyType = deployStrategyType; + } + + public List getComponentConf() { + return componentConf; + } + + public void setComponentConf(List componentConf) { + this.componentConf = componentConf; + } + + public DeploySpecModel getConf() { + return conf; + } + + public void setConf(DeploySpecModel conf) { + this.conf = conf; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public NewDeployGroupModel withName(String name) { + this.setName(name); + return this; + } + + public NewDeployGroupModel withDescription(String description) { + this.setDescription(description); + return this; + } + + public NewDeployGroupModel withEnvironmentID(String environmentID) { + this.setEnvironmentID(environmentID); + return this; + } + + public NewDeployGroupModel withReplicas(int replicas) { + this.setReplicas(replicas); + return this; + } + + public NewDeployGroupModel withDeployStrategyType(String deployStrategyType) { + this.setDeployStrategyType(deployStrategyType); + return this; + } + + public NewDeployGroupModel withType(int type) { + this.setType(type); + return this; + } + + public NewDeployGroupModel addComponmentModel(NewComponentModel componentModel) { + this.componentConf.add(componentModel); + return this; + } + + public NewDeployGroupModel withDeploySpecModel(DeploySpecModel conf) { + this.setConf(conf); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/PodLogsConfigModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/PodLogsConfigModel.java new file mode 100644 index 00000000..5c62f43d --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/PodLogsConfigModel.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +/** + * The model for pod logs config. + */ +public class PodLogsConfigModel { + + /** + * The list of pod log config. + */ + private List logsConfig; + + public List getLogsConfig() { + return logsConfig; + } + + public void setLogsConfig(List logsConfig) { + this.logsConfig = logsConfig; + } + + public PodLogsConfigModel addLogConfigModel(LogConfigModel logConfigModel) { + if (CollectionUtils.isEmpty(logsConfig)) { + logsConfig = new LinkedList(); + } + logsConfig.add(logConfigModel); + return this; + + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/PodMetricsConfigModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/PodMetricsConfigModel.java new file mode 100644 index 00000000..76de1565 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/PodMetricsConfigModel.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +/** + * The model for pod metric config. + */ +public class PodMetricsConfigModel { + /** + * The input config model. + */ + private InputConfigModel input; + + /** + * The grok config model. + */ + private GrokConfigModel grok; + + /** + * The metrics config model. + */ + private List metricsConfig; + + public InputConfigModel getInput() { + return input; + } + + public void setInput(InputConfigModel input) { + this.input = input; + } + + public GrokConfigModel getGrok() { + return grok; + } + + public void setGrok(GrokConfigModel grok) { + this.grok = grok; + } + + public List getMetricsConfig() { + return metricsConfig; + } + + public void setMetricsConfig(List metricsConfig) { + this.metricsConfig = metricsConfig; + } + + public PodMetricsConfigModel withInputConfigModel(InputConfigModel input) { + this.setInput(input); + return this; + } + + public PodMetricsConfigModel withGrokConfigModel(GrokConfigModel grok) { + this.setGrok(grok); + return this; + } + + public PodMetricsConfigModel addMetricConfigModel(MetricConfigModel metricConfigModel) { + if (CollectionUtils.isEmpty(metricsConfig)) { + metricsConfig = new LinkedList(); + } + metricsConfig.add(metricConfigModel); + return this; + + } + + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ProbeModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ProbeModel.java new file mode 100644 index 00000000..8899678f --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ProbeModel.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for probe. + */ +public class ProbeModel { + + /** + * The exec action command. + */ + private ExecActionModel exec; + + /** + * The http action. + */ + private HTTPGetActionModel httpGet; + + /** + * The tcp socket. + */ + private TCPSocketActionModel tcpSocket; + + /** + * The time out. + */ + private int timeoutSeconds = 1; + + /** + * The period time to start probe. + */ + private int periodSeconds; + + public ExecActionModel getExec() { + return exec; + } + + public void setExec(ExecActionModel exec) { + this.exec = exec; + } + + public HTTPGetActionModel getHttpGet() { + return httpGet; + } + + public void setHttpGet(HTTPGetActionModel httpGet) { + this.httpGet = httpGet; + } + + public TCPSocketActionModel getTcpSocket() { + return tcpSocket; + } + + public void setTcpSocket(TCPSocketActionModel tcpSocket) { + this.tcpSocket = tcpSocket; + } + + public int getTimeoutSeconds() { + return timeoutSeconds; + } + + public void setTimeoutSeconds(int timeoutSeconds) { + this.timeoutSeconds = timeoutSeconds; + } + + public int getPeriodSeconds() { + return periodSeconds; + } + + public void setPeriodSeconds(int periodSeconds) { + this.periodSeconds = periodSeconds; + } + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ResourceRequirementsModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ResourceRequirementsModel.java new file mode 100644 index 00000000..8b169a55 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ResourceRequirementsModel.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + + +/** + * The model for resource requirement. + */ +public class ResourceRequirementsModel { + /** + * The resource requirement info. + */ + private Map requests = new HashMap(); + + public Map getRequests() { + return requests; + } + + public ResourceRequirementsModel withCpuRequirement(double cpu) { + BigDecimal bg = BigDecimal.valueOf(cpu); + double d = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + requests.put("cpu", String.valueOf((int)(1000 * d)) + "m"); + return this; + } + + public ResourceRequirementsModel withMemoryRequirement(int memory) { + requests.put("memory", String.valueOf(memory) + "Mi"); + return this; + } + + public Map requestsInfo() { + return this.requests; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ScaleDeployGroupRequest.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ScaleDeployGroupRequest.java new file mode 100644 index 00000000..f26058c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ScaleDeployGroupRequest.java @@ -0,0 +1,94 @@ +package com.baidubce.services.cnap.model.deploygroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for scale deploy group. + */ +public class ScaleDeployGroupRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The id of deploy group. + */ + private String deployGroupID; + + /** + * The count of replicas; + */ + private int replicas; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public ScaleDeployGroupRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public ScaleDeployGroupRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public ScaleDeployGroupRequest withDeployGroupID(String deployGroupID) { + this.setDeployGroupID(deployGroupID); + return this; + } + + public ScaleDeployGroupRequest withReplicas(int replicas) { + this.setReplicas(replicas); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ScaleDeployGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/ScaleDeployGroupResponse.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ScaleDeployGroupResponse.java new file mode 100644 index 00000000..3fed45c8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/ScaleDeployGroupResponse.java @@ -0,0 +1,249 @@ +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.Date; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.application.ApplicationBaseInfoModel; +import com.baidubce.services.cnap.model.application.EnvironmentModel; +import com.baidubce.services.cnap.model.application.ResourcesModel; +import com.baidubce.services.cnap.model.workspace.WorkspaceBaseInfoModel; + +/** + * The response for scale deploy group. + */ +public class ScaleDeployGroupResponse extends AbstractBceResponse { + + /** + * The id of deploy group. + */ + private String resourceID; + + /** + * The name of deploy group. + */ + private String name; + + /** + * The description of deploy group. + */ + private String description; + + /** + * The id of environment. + */ + private String environmentID; + + /** + * The count of replicas. + */ + private int replicas; + + /** + * The type of deploy group. + */ + private int type; + + /** + * The flag which indicates deploy group is locked. + */ + private boolean isLocked; + + /** + * The id of release record. + */ + private String releaseRecordID; + + /** + * The deploy group status. + */ + private String status; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + /** + * The resource info. + */ + private ResourcesModel resources; + + /** + * The type of deploy strategy. + */ + private String deployStrategyType; + + /** + * The deploy group conf. + */ + private DeploySpecModel conf; + + /** + * The component conf. + */ + private List componentConf; + + /** + * The workspace info. + */ + private WorkspaceBaseInfoModel workspace; + + /** + * The application info. + */ + private ApplicationBaseInfoModel application; + + /** + * The environment info. + */ + private EnvironmentModel environment; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public boolean getIsLocked() { + return isLocked; + } + + public void setIsLocked(boolean isLocked) { + this.isLocked = isLocked; + } + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public ResourcesModel getResources() { + return resources; + } + + public void setResources(ResourcesModel resources) { + this.resources = resources; + } + + public String getDeployStrategyType() { + return deployStrategyType; + } + + public void setDeployStrategyType(String deployStrategyType) { + this.deployStrategyType = deployStrategyType; + } + + public DeploySpecModel getConf() { + return conf; + } + + public void setConf(DeploySpecModel conf) { + this.conf = conf; + } + + public List getComponentConf() { + return componentConf; + } + + public void setComponentConf(List componentConf) { + this.componentConf = componentConf; + } + + public WorkspaceBaseInfoModel getWorkspace() { + return workspace; + } + + public void setWorkspace(WorkspaceBaseInfoModel workspace) { + this.workspace = workspace; + } + + public ApplicationBaseInfoModel getApplication() { + return application; + } + + public void setApplication(ApplicationBaseInfoModel application) { + this.application = application; + } + + public EnvironmentModel getEnvironment() { + return environment; + } + + public void setEnvironment(EnvironmentModel environment) { + this.environment = environment; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/TCPSocketActionModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/TCPSocketActionModel.java new file mode 100644 index 00000000..397a361d --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/TCPSocketActionModel.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +/** + * The model for tcp socket. + */ +public class TCPSocketActionModel { + + /** + * The port info. + */ + private int port; + + /** + * The host info. + */ + private String host; + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + + public TCPSocketActionModel withPort(int port) { + this.setPort(port); + return this; + } + + public TCPSocketActionModel withHost(String host) { + this.setHost(host); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/TaskModel.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/TaskModel.java new file mode 100644 index 00000000..5911653c --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/TaskModel.java @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.Date; + +/** + * The model for task. + */ +public class TaskModel { + /** + * The id of task. + */ + private String taskID; + + /** + * The type of task. eg, DeployGroup + */ + private String type; + + /** + * The id of release recode. + */ + private String releaseRecordID; + + /** + * The status. + */ + private String status; + + /** + * The id of pre task. + */ + private String preTaskID; + + /** + * The strategy after task. + */ + private String pendAfterTask; + + /** + * The name of task. + */ + private String name; + + /** + * The progress of task. + */ + private int progress; + + /** + * The start time of task. + */ + private Date startTime; + + /** + * The end time of task. + */ + private Date endTime; + + /** + * The create time of task. + */ + private Date createdAt; + + /** + * The update time of task. + */ + private Date updatedAt; + + /** + * The deploy task info. + */ + private DeployTaskModel deployTask; + + public String getTaskID() { + return taskID; + } + + public void setTaskID(String taskID) { + this.taskID = taskID; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getPendAfterTask() { + return pendAfterTask; + } + + public void setPendAfterTask(String pendAfterTask) { + this.pendAfterTask = pendAfterTask; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPreTaskID() { + return preTaskID; + } + + public void setPreTaskID(String preTaskID) { + this.preTaskID = preTaskID; + } + + public int getProgress() { + return progress; + } + + public void setProgress(int progress) { + this.progress = progress; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public DeployTaskModel getDeployTask() { + return deployTask; + } + + public void setDeployTask(DeployTaskModel deployTask) { + this.deployTask = deployTask; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/UpdateDeployGroupRequest.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/UpdateDeployGroupRequest.java new file mode 100644 index 00000000..555b5c9b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/UpdateDeployGroupRequest.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.deploygroup; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cnap.model.access.NewAccessModel; + +/** + * The request for update deploy group. + */ +public class UpdateDeployGroupRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The id of deploy group. + */ + private String deployGroupID; + + /** + * The description of deploy group. + */ + private String description; + + /** + * The number of replicas. + */ + private int replicas; + + /** + * The deploy spec model conf. + */ + private DeploySpecModel conf; + + /** + * The component conf. + */ + private List compnonentConf; + + /** + * The access of deploy group. + */ + private List access; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public DeploySpecModel getConf() { + return conf; + } + + public void setConf(DeploySpecModel conf) { + this.conf = conf; + } + + public List getCompnonentConf() { + return compnonentConf; + } + + public void setCompnonentConf(List compnonentConf) { + this.compnonentConf = compnonentConf; + } + + public List getAccess() { + return access; + } + + public void setAccess(List access) { + this.access = access; + } + + public UpdateDeployGroupRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public UpdateDeployGroupRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public UpdateDeployGroupRequest withDeployGroupID(String deployGroupID) { + this.setDeployGroupID(deployGroupID); + return this; + } + + public UpdateDeployGroupRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public UpdateDeployGroupRequest withReplicas(int replicas) { + this.setReplicas(replicas); + return this; + } + + public UpdateDeployGroupRequest withConf(DeploySpecModel conf) { + this.setConf(conf); + return this; + } + + public UpdateDeployGroupRequest withCompnonentConf(List compnonentConf) { + this.setCompnonentConf(compnonentConf); + return this; + } + + public UpdateDeployGroupRequest withAccess(List access) { + this.setAccess(access); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public UpdateDeployGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/deploygroup/UpdateDeployGroupResponse.java b/src/main/java/com/baidubce/services/cnap/model/deploygroup/UpdateDeployGroupResponse.java new file mode 100644 index 00000000..274bc91d --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/deploygroup/UpdateDeployGroupResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.deploygroup; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for update deploy group. + */ +public class UpdateDeployGroupResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/BindClusterToEnvironmentRequest.java b/src/main/java/com/baidubce/services/cnap/model/environment/BindClusterToEnvironmentRequest.java new file mode 100644 index 00000000..cadfa38e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/BindClusterToEnvironmentRequest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for bind cluster to environment. + */ +public class BindClusterToEnvironmentRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of environment. + */ + private String environmentID; + + /** + * The id of cluster. + */ + private String clusterID; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public BindClusterToEnvironmentRequest withEnvironmentID(String environmentID) { + this.setEnvironmentID(environmentID); + return this; + } + + public BindClusterToEnvironmentRequest withClusterID(String clusterID) { + this.setClusterID(clusterID); + return this; + } + + public BindClusterToEnvironmentRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public BindClusterToEnvironmentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/BindClusterToEnvironmentResponse.java b/src/main/java/com/baidubce/services/cnap/model/environment/BindClusterToEnvironmentResponse.java new file mode 100644 index 00000000..22b3a6df --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/BindClusterToEnvironmentResponse.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for bind cluster to environment. + */ +public class BindClusterToEnvironmentResponse extends AbstractBceResponse { + /** + * The id of environment. + */ + private String resourceID; + + /** + * The name of environment. + */ + private String name; + + /** + * The description of environment. + */ + private String description; + + /** + * The culster id which environment binds. + */ + private String clusterID; + + + /** + * The create time of environment. + */ + private Date createdAt; + + /** + * The update time of environment. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/CNAPRegion.java b/src/main/java/com/baidubce/services/cnap/model/environment/CNAPRegion.java new file mode 100644 index 00000000..0ea27ab3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/CNAPRegion.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.environment; + +public class CNAPRegion { + public static final String BJ = "bj"; + + public static final String GZ = "gz"; + + public static final String SU = "su"; + + public static final String BD = "bd"; +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/CreateEnvironmentRequest.java b/src/main/java/com/baidubce/services/cnap/model/environment/CreateEnvironmentRequest.java new file mode 100644 index 00000000..13a10545 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/CreateEnvironmentRequest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for create environment. + */ +public class CreateEnvironmentRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The name of environment. + */ + private String name; + + /** + * The description of environment. + */ + private String description; + + /** + * The cluster id of environment. + */ + private String clusterID; + + /** + * The region of env. + */ + private String region; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public CreateEnvironmentRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public CreateEnvironmentRequest withName(String name) { + this.setName(name); + return this; + } + + public CreateEnvironmentRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public CreateEnvironmentRequest withClusterID(String clusterID) { + this.setClusterID(clusterID); + return this; + } + + public CreateEnvironmentRequest withRegion(String region) { + this.setRegion(region); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public CreateEnvironmentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/CreateEnvironmentResponse.java b/src/main/java/com/baidubce/services/cnap/model/environment/CreateEnvironmentResponse.java new file mode 100644 index 00000000..67867f2d --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/CreateEnvironmentResponse.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.workspace.WorkspaceModel; + +/** + * The response for create environment. + */ +public class CreateEnvironmentResponse extends AbstractBceResponse { + + /** + * The id of environment. + */ + private String resourceID; + + /** + * The name of environment. + */ + private String name; + + /** + * The description of environment. + */ + private String description; + + /** + * The culster id which environment binds. + */ + private String clusterID; + + + /** + * The create time of environment. + */ + private Date createdAt; + + /** + * The update time of environment. + */ + private Date updatedAt; + + /** + * The workspace info. + */ + private WorkspaceModel workspace; + + /** + * The region of environment. + */ + private String region; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public WorkspaceModel getWorkspace() { + return workspace; + } + + public void setWorkspace(WorkspaceModel workspace) { + this.workspace = workspace; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/DeleteEnvironmentReponse.java b/src/main/java/com/baidubce/services/cnap/model/environment/DeleteEnvironmentReponse.java new file mode 100644 index 00000000..ad49ae67 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/DeleteEnvironmentReponse.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for delete environment. + */ +public class DeleteEnvironmentReponse extends AbstractBceResponse { + + /** + * The culster id which environment binds. + */ + private String clusterID; + + /** + * The create time of environment. + */ + private Date createdAt; + + /** + * The description of environment. + */ + private String description; + + /** + * The id of environment. + */ + private String resourceID; + + /** + * The name of environment. + */ + private String name; + + /** + * The update time of environment. + */ + private Date updatedAt; + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/DeleteEnvironmentRequest.java b/src/main/java/com/baidubce/services/cnap/model/environment/DeleteEnvironmentRequest.java new file mode 100644 index 00000000..c2a8efbb --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/DeleteEnvironmentRequest.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for delete environment. + */ +public class DeleteEnvironmentRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of environment. + */ + private String environmentID; + + /** + * The flag which indicates ignore underlay error. + */ + private boolean ignoreUnderlayError = false; + + /** + * The flag which indicates skip delete underlay. + */ + private boolean skipDeleteUnderlay = false; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public void setIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.ignoreUnderlayError = ignoreUnderlayError; + } + + public boolean getIgnoreUnderlayError() { + return ignoreUnderlayError; + } + + public void setSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.skipDeleteUnderlay = skipDeleteUnderlay; + } + + public boolean getSkipDeleteUnderlay() { + return skipDeleteUnderlay; + } + + + public DeleteEnvironmentRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public DeleteEnvironmentRequest withEnvironmentId(String environmentID) { + this.setEnvironmentID(environmentID); + return this; + } + + public DeleteEnvironmentRequest withIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.setIgnoreUnderlayError(ignoreUnderlayError); + return this; + } + + public DeleteEnvironmentRequest withSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.setSkipDeleteUnderlay(skipDeleteUnderlay); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public DeleteEnvironmentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/ListEnvironmentRequest.java b/src/main/java/com/baidubce/services/cnap/model/environment/ListEnvironmentRequest.java new file mode 100644 index 00000000..cf2a4d34 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/ListEnvironmentRequest.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list environment. + */ +public class ListEnvironmentRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The order by info. + */ + private String orderBy = "name"; + + /** + * The order info, eg asc, desc. + */ + private String order = "desc"; + + /** + * The page size of list. + */ + private int pageSize = 10; + + /** + * The page no of list. + */ + private int pageNo = 1; + + /** + * The name of environment. + */ + private String name; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + + public ListEnvironmentRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public ListEnvironmentRequest withOrderBy(String orderBy) { + this.setOrderBy(orderBy); + return this; + } + + public ListEnvironmentRequest withOrder(String order) { + this.setOrder(order); + return this; + } + + public ListEnvironmentRequest withPageSize(int pageSize) { + this.setPageSize(pageSize); + return this; + } + + public ListEnvironmentRequest withPageNo(int pageNo) { + this.setPageNo(pageNo); + return this; + } + + public ListEnvironmentRequest withName(String name) { + this.setName(name); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListEnvironmentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/ListEnvironmentResponse.java b/src/main/java/com/baidubce/services/cnap/model/environment/ListEnvironmentResponse.java new file mode 100644 index 00000000..6056b5e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/ListEnvironmentResponse.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for list environment. + */ +public class ListEnvironmentResponse extends AbstractBceResponse { + + /** + * The page size of list. + */ + private int pageSize = 10; + + /** + * The page no of list. + */ + private int pageNo = 1; + + /** + * The total count. + */ + private int totalCount; + + /** + * The result of list environment. + */ + List result; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/PageEnvironmentModel.java b/src/main/java/com/baidubce/services/cnap/model/environment/PageEnvironmentModel.java new file mode 100644 index 00000000..7cf91e1f --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/PageEnvironmentModel.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import java.util.Date; +import java.util.List; + +import com.baidubce.services.cnap.model.application.PageApplicationModel; +import com.baidubce.services.cnap.model.cluster.ClusterModel; + +/** + * The model for page environment. + */ +public class PageEnvironmentModel { + + /** + * The id of environment. + */ + private String resourceID; + + /** + * The name of environment. + */ + private String name; + + /** + * The description of environment. + */ + private String description; + + /** + * The cluster id. + */ + private String clusterID; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + /** + * The application list in environment. + */ + private List applicationList; + + /** + * The cluster info. + */ + private ClusterModel cluster; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public List getApplicationList() { + return applicationList; + } + + public void setApplicationList( + List applicationList) { + this.applicationList = applicationList; + } + + public ClusterModel getCluster() { + return cluster; + } + + public void setCluster(ClusterModel cluster) { + this.cluster = cluster; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/UnbindClusterToEnvironmentRequest.java b/src/main/java/com/baidubce/services/cnap/model/environment/UnbindClusterToEnvironmentRequest.java new file mode 100644 index 00000000..fe4f1b55 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/UnbindClusterToEnvironmentRequest.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for unbind cluster to environment. + */ +public class UnbindClusterToEnvironmentRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of environment. + */ + private String environmentID; + + /** + * The id of cluster. + */ + private String clusterID = ""; + + /** + * The description of cluster. + */ + private String description = ""; + + /** + * The flag indicates whether can ignore underlay error. + */ + private boolean ignoreUnderlayError = false; + + /** + * The flag indicates whether can skip delete underlay. + */ + private boolean skipDeleteUnderlay = false; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public void setIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.ignoreUnderlayError = ignoreUnderlayError; + } + + public boolean getIgnoreUnderlayError() { + return ignoreUnderlayError; + } + + public void setSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.skipDeleteUnderlay = skipDeleteUnderlay; + } + + public boolean getSkipDeleteUnderlay() { + return skipDeleteUnderlay; + } + + + public UnbindClusterToEnvironmentRequest withEnvironmentID(String environmentID) { + this.setEnvironmentID(environmentID); + return this; + } + + public UnbindClusterToEnvironmentRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + + public UnbindClusterToEnvironmentRequest withIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.setIgnoreUnderlayError(ignoreUnderlayError); + return this; + } + + public UnbindClusterToEnvironmentRequest withSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.setSkipDeleteUnderlay(skipDeleteUnderlay); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public UnbindClusterToEnvironmentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/UnbindClusterToEnvironmentResponse.java b/src/main/java/com/baidubce/services/cnap/model/environment/UnbindClusterToEnvironmentResponse.java new file mode 100644 index 00000000..20844786 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/UnbindClusterToEnvironmentResponse.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.environment; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for unbind cluster to environment. + */ +public class UnbindClusterToEnvironmentResponse extends AbstractBceResponse { + /** + * The id of environment. + */ + private String resourceID; + + /** + * The name of environment. + */ + private String name; + + /** + * The description of environment. + */ + private String description; + + /** + * The culster id which environment binds. + */ + private String clusterID; + + + /** + * The create time of environment. + */ + private Date createdAt; + + /** + * The update time of environment. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/UpdateEnvironmentRequest.java b/src/main/java/com/baidubce/services/cnap/model/environment/UpdateEnvironmentRequest.java new file mode 100644 index 00000000..698b1cfe --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/UpdateEnvironmentRequest.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.environment; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for update environment. + */ +public class UpdateEnvironmentRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of environment. + */ + private String environmentID; + + /** + * The description of environment. + */ + private String description; + + /** + * The cluster id of environment. + */ + private String clusterID; + + /** + * The region of env. + */ + private String region; + + /** + * The flag which indicates ignore underlay error. + */ + private boolean ignoreUnderlayError = false; + + /** + * The flag which indicates skip delete underlay. + */ + private boolean skipDeleteUnderlay = false; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public boolean getIgnoreUnderlayError() { + return ignoreUnderlayError; + } + + public void setIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.ignoreUnderlayError = ignoreUnderlayError; + } + + public boolean getSkipDeleteUnderlay() { + return skipDeleteUnderlay; + } + + public void setSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.skipDeleteUnderlay = skipDeleteUnderlay; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public UpdateEnvironmentRequest withIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.setIgnoreUnderlayError(ignoreUnderlayError); + return this; + } + + public UpdateEnvironmentRequest withSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.setSkipDeleteUnderlay(skipDeleteUnderlay); + return this; + } + + public UpdateEnvironmentRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public UpdateEnvironmentRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public UpdateEnvironmentRequest withClusterID(String clusterID) { + this.setClusterID(clusterID); + return this; + } + + public UpdateEnvironmentRequest withRegion(String region) { + this.setRegion(region); + return this; + } + + + public UpdateEnvironmentRequest withEnvironmentID(String environmentID) { + this.setEnvironmentID(environmentID); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public UpdateEnvironmentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/environment/UpdateEnvironmentResponse.java b/src/main/java/com/baidubce/services/cnap/model/environment/UpdateEnvironmentResponse.java new file mode 100644 index 00000000..04d150ae --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/environment/UpdateEnvironmentResponse.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.environment; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for update environment. + */ +public class UpdateEnvironmentResponse extends AbstractBceResponse { + /** + * The id of environment. + */ + private String resourceID; + + /** + * The name of environment. + */ + private String name; + + /** + * The description of environment. + */ + private String description; + + /** + * The culster id which environment binds. + */ + private String clusterID; + + /** + * The region info. + */ + private String region; + + /** + * The create time of environment. + */ + private Date createdAt; + + /** + * The update time of environment. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClusterID() { + return clusterID; + } + + public void setClusterID(String clusterID) { + this.clusterID = clusterID; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/AlertContacts.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/AlertContacts.java new file mode 100644 index 00000000..533d62cf --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/AlertContacts.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import java.util.LinkedList; +import java.util.List; + +public class AlertContacts { + /** + * The list of user id. + */ + private List users; + + + public AlertContacts addUser(String user) { + if (users == null) { + users = new LinkedList(); + } + users.add(user); + return this; + } + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/AlertRecordModel.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/AlertRecordModel.java new file mode 100644 index 00000000..d19c1cc1 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/AlertRecordModel.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import java.util.Date; + +/** + * The model for alert record. + */ +public class AlertRecordModel { + + /** + * The id of alert rule. + */ + private String alertRuleID; + + /** + * The name of alert rule. + */ + private String alertRuleName; + + /** + * The start time. + */ + private Date startsAt; + + /** + * The end time. + */ + private Date endsAt; + + /** + * The notified time. + */ + private Date notifiedAt; + + /** + * The id of alert record. + */ + private String resourceID; + + /** + * The expected threshold. + */ + private int threshold; + + /** + * The status. + */ + private String status; + + /** + * The duration time. + */ + private String duration; + + /** + * The PromQL query statement. + */ + private String promql; + + /** + * The operator. + */ + private String op; + + /** + * The repeat interval time. + */ + private String repeatInterval; + + /** + * The contact user. + */ + private AlertContacts contacts; + + /** + * The k-v label. + */ + private Object labels; + + /** + * The description. + */ + private String description; + + public String getAlertRuleID() { + return alertRuleID; + } + + public void setAlertRuleID(String alertRuleID) { + this.alertRuleID = alertRuleID; + } + + public String getAlertRuleName() { + return alertRuleName; + } + + public void setAlertRuleName(String alertRuleName) { + this.alertRuleName = alertRuleName; + } + + public Date getStartsAt() { + return startsAt; + } + + public void setStartsAt(Date startsAt) { + this.startsAt = startsAt; + } + + public Date getEndsAt() { + return endsAt; + } + + public void setEndsAt(Date endsAt) { + this.endsAt = endsAt; + } + + public Date getNotifiedAt() { + return notifiedAt; + } + + public void setNotifiedAt(Date notifiedAt) { + this.notifiedAt = notifiedAt; + } + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public int getThreshold() { + return threshold; + } + + public void setThreshold(int threshold) { + this.threshold = threshold; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getPromql() { + return promql; + } + + public void setPromql(String promql) { + this.promql = promql; + } + + public String getOp() { + return op; + } + + public void setOp(String op) { + this.op = op; + } + + public String getRepeatInterval() { + return repeatInterval; + } + + public void setRepeatInterval(String repeatInterval) { + this.repeatInterval = repeatInterval; + } + + public AlertContacts getContacts() { + return contacts; + } + + public void setContacts(AlertContacts contacts) { + this.contacts = contacts; + } + + public Object getLabels() { + return labels; + } + + public void setLabels(Object labels) { + this.labels = labels; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/AlertRulesModel.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/AlertRulesModel.java new file mode 100644 index 00000000..3740d9ff --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/AlertRulesModel.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +/** + * The model for alert rules. + */ +public class AlertRulesModel { + /** + * The id of alert rule. + */ + private String resourceID; + + /** + * The name of alert rule. + */ + private String name; + + /** + * The duration time. + */ + private String duration; + + /** + * The promql query. + */ + private String promql; + + /** + * The operator. + */ + private String op; + + /** + * The repeat interval. + */ + private String repeatInterval; + + /** + * The contacts user. + */ + private AlertContacts contacts; + + /** + * The label k-v pair. + */ + private Object labels; + + /** + * The description. + */ + private String description; + + /** + * The expected threshold. + */ + private int threshold; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getPromql() { + return promql; + } + + public void setPromql(String promql) { + this.promql = promql; + } + + public String getOp() { + return op; + } + + public void setOp(String op) { + this.op = op; + } + + public String getRepeatInterval() { + return repeatInterval; + } + + public void setRepeatInterval(String repeatInterval) { + this.repeatInterval = repeatInterval; + } + + public AlertContacts getContacts() { + return contacts; + } + + public void setContacts(AlertContacts contacts) { + this.contacts = contacts; + } + + public Object getLabels() { + return labels; + } + + public void setLabels(Object labels) { + this.labels = labels; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getThreshold() { + return threshold; + } + + public void setThreshold(int threshold) { + this.threshold = threshold; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/CreateAlertRulesRequest.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/CreateAlertRulesRequest.java new file mode 100644 index 00000000..28d3276b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/CreateAlertRulesRequest.java @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for create alert rules. + */ +public class CreateAlertRulesRequest extends AbstractBceRequest { + + /** + * The name of alert rule. + */ + private String name; + + /** + * The duration time. + */ + private String duration; + + /** + * The PromQL query + */ + private String promql; + + /** + * The operator, eg >、 ==、 < + */ + private String op; + + /** + * The interval time of repeat alert. + */ + private String repeatInterval; + + /** + * The expected threshold. + */ + private int threshold = -1; + + /** + * The contacts user. + */ + private AlertContacts contacts = new AlertContacts(); + + /** + * The label info which contains k-v pair. + */ + private Object labels = new Object(); + + /** + * The description info. + */ + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getPromql() { + return promql; + } + + public void setPromql(String promql) { + this.promql = promql; + } + + public String getOp() { + return op; + } + + public void setOp(String op) { + this.op = op; + } + + public String getRepeatInterval() { + return repeatInterval; + } + + public void setRepeatInterval(String repeatInterval) { + this.repeatInterval = repeatInterval; + } + + public int getThreshold() { + return threshold; + } + + public void setThreshold(int threshold) { + this.threshold = threshold; + } + + public AlertContacts getContacts() { + return contacts; + } + + public void setContacts(AlertContacts contacts) { + this.contacts = contacts; + } + + public Object getLabels() { + return labels; + } + + public void setLabels(Object labels) { + this.labels = labels; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public CreateAlertRulesRequest withName(String name) { + this.setName(name); + return this; + } + + public CreateAlertRulesRequest withDuration(String duration) { + this.setDuration(duration); + return this; + } + + public CreateAlertRulesRequest withPromql(String promql) { + this.setPromql(promql); + return this; + } + + public CreateAlertRulesRequest withOp(String op) { + this.setOp(op); + return this; + } + + public CreateAlertRulesRequest withRepeatInterval(String repeatInterval) { + this.setRepeatInterval(repeatInterval); + return this; + } + + public CreateAlertRulesRequest withThreshold(int threshold) { + this.setThreshold(threshold); + return this; + } + + public CreateAlertRulesRequest withContacts(AlertContacts alertContacts) { + this.setContacts(alertContacts); + return this; + } + + public CreateAlertRulesRequest withLabels(Object labels) { + this.setLabels(labels); + return this; + } + + public CreateAlertRulesRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public CreateAlertRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/CreateAlertRulesResponse.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/CreateAlertRulesResponse.java new file mode 100644 index 00000000..be1cab2b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/CreateAlertRulesResponse.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for create alert rules. + */ +public class CreateAlertRulesResponse extends AbstractBceResponse { + + /** + * The id of resource. + */ + private String resourceID; + + /** + * The name of alert rule. + */ + private String name; + + /** + * The duration time. + */ + private String duration; + + /** + * The PromQL query + */ + private String promql; + + /** + * The operator. + */ + private String op; + + /** + * The interval time of repeat alert. + */ + private String repeatInterval; + + /** + * The contacts user. + */ + private AlertContacts contacts; + + /** + * The label info which contains k-v pair. + */ + private Object labels; + + /** + * The description info. + */ + private String description; + + /** + * The expected threshold. + */ + private int threshold; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getPromql() { + return promql; + } + + public void setPromql(String promql) { + this.promql = promql; + } + + public String getOp() { + return op; + } + + public void setOp(String op) { + this.op = op; + } + + public String getRepeatInterval() { + return repeatInterval; + } + + public void setRepeatInterval(String repeatInterval) { + this.repeatInterval = repeatInterval; + } + + public AlertContacts getContacts() { + return contacts; + } + + public void setContacts(AlertContacts contacts) { + this.contacts = contacts; + } + + public Object getLabels() { + return labels; + } + + public void setLabels(Object labels) { + this.labels = labels; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getThreshold() { + return threshold; + } + + public void setThreshold(int threshold) { + this.threshold = threshold; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/DeleteAlertRulesRequest.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/DeleteAlertRulesRequest.java new file mode 100644 index 00000000..33df56a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/DeleteAlertRulesRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for delete alert rules. + */ +public class DeleteAlertRulesRequest extends AbstractBceRequest { + + /** + * The id of alert rule. + */ + private String alertRuleID; + + public String getAlertRuleID() { + return alertRuleID; + } + + public void setAlertRuleID(String alertRuleID) { + this.alertRuleID = alertRuleID; + } + + public DeleteAlertRulesRequest withAlertRuleID(String alertRuleID) { + this.setAlertRuleID(alertRuleID); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public DeleteAlertRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/DeleteAlertRulesResponse.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/DeleteAlertRulesResponse.java new file mode 100644 index 00000000..b9be0c0f --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/DeleteAlertRulesResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for delete alert rules. + */ +public class DeleteAlertRulesResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/GetMonitorDataRequest.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/GetMonitorDataRequest.java new file mode 100644 index 00000000..b4476da7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/GetMonitorDataRequest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get monitor data. + */ +public class GetMonitorDataRequest extends AbstractBceRequest { + + /** + * The PromQL query. + */ + private String query; + + /** + * The start timestamp (second). + */ + private long start = -1; + + /** + * The end timestamp (second). + */ + private long end = -1; + + /** + * The query point time step. + */ + private int step = -1; + + /** + * The timeout info. + */ + private int timeout = -1; + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public long getStart() { + return start; + } + + public void setStart(long start) { + this.start = start; + } + + public long getEnd() { + return end; + } + + public void setEnd(long end) { + this.end = end; + } + + public int getStep() { + return step; + } + + public void setStep(int step) { + this.step = step; + } + + public int getTimeout() { + return timeout; + } + + public void setTimeout(int timeout) { + this.timeout = timeout; + } + + public GetMonitorDataRequest withQuery(String query) { + this.setQuery(query); + return this; + } + + public GetMonitorDataRequest withStart(long start) { + this.setStart(start); + return this; + } + + public GetMonitorDataRequest withEnd(long end) { + this.setEnd(end); + return this; + } + + public GetMonitorDataRequest withStep(int step) { + this.setStep(step); + return this; + } + + public GetMonitorDataRequest withTimeout(int timeout) { + this.setTimeout(timeout); + return this; + } + + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public GetMonitorDataRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/GetMonitorDataResponse.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/GetMonitorDataResponse.java new file mode 100644 index 00000000..c64c5a52 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/GetMonitorDataResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for get monitor data. + */ +public class GetMonitorDataResponse extends AbstractBceResponse { + + /** + * The status. + */ + private String status; + + /** + * The data collection. + */ + private MetricsDataModel data; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public MetricsDataModel getData() { + return data; + } + + public void setData(MetricsDataModel data) { + this.data = data; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRecordRequest.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRecordRequest.java new file mode 100644 index 00000000..7d698479 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRecordRequest.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list alerts record. + */ +public class ListAlertRecordRequest extends AbstractBceRequest { + + /** + * The order by info. + */ + private String orderBy; + + /** + * The order info, eg asc, desc. + */ + private String order; + + /** + * The page size of list. + */ + private int pageSize = 10; + + /** + * The page no of list. + */ + private int pageNo = 1; + + /** + * The name of environment. + */ + private String name; + + /** + * The start time. + */ + private long startsAt = -1; + + /** + * The end time. + */ + private long endsAt = -1; + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public long getStartsAt() { + return startsAt; + } + + public void setStartsAt(long startsAt) { + this.startsAt = startsAt; + } + + public long getEndsAt() { + return endsAt; + } + + public void setEndsAt(long endsAt) { + this.endsAt = endsAt; + } + + public ListAlertRecordRequest withOrderBy(String orderBy) { + this.setOrderBy(orderBy); + return this; + } + + public ListAlertRecordRequest withOrder(String order) { + this.setOrder(order); + return this; + } + + public ListAlertRecordRequest withPageSize(int pageSize) { + this.setPageSize(pageSize); + return this; + } + + public ListAlertRecordRequest withPageNo(int pageNo) { + this.setPageNo(pageNo); + return this; + } + + public ListAlertRecordRequest withName(String name) { + this.setName(name); + return this; + } + + public ListAlertRecordRequest withStartsAt(long startsAt) { + this.setStartsAt(startsAt); + return this; + } + + public ListAlertRecordRequest withEndsAt(long endsAt) { + this.setEndsAt(endsAt); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListAlertRecordRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRecordResponse.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRecordResponse.java new file mode 100644 index 00000000..fe6b6619 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRecordResponse.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for list alert. + */ +public class ListAlertRecordResponse extends AbstractBceResponse { + + /** + * The page size of list. + */ + private int pageSize = 10; + + /** + * The page no of list. + */ + private int pageNo = 1; + + /** + * The total count. + */ + private int totalCount; + + /** + * The result info. + */ + private List result; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRulesRequest.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRulesRequest.java new file mode 100644 index 00000000..19df248e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRulesRequest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list alert rules. + */ +public class ListAlertRulesRequest extends AbstractBceRequest { + + /** + * The order by info. + */ + private String orderBy; + + /** + * The order info, eg asc, desc. + */ + private String order; + + /** + * The page size of list. + */ + private int pageSize = 10; + + /** + * The page no of list. + */ + private int pageNo = 1; + + /** + * The name of alert rule. + */ + private String name; + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ListAlertRulesRequest withOrderBy(String orderBy) { + this.setOrderBy(orderBy); + return this; + } + + public ListAlertRulesRequest withOrder(String order) { + this.setOrder(order); + return this; + } + + public ListAlertRulesRequest withPageSize(int pageSize) { + this.setPageSize(pageSize); + return this; + } + + public ListAlertRulesRequest withPageNo(int pageNo) { + this.setPageNo(pageNo); + return this; + } + + public ListAlertRulesRequest withName(String name) { + this.setName(name); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListAlertRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRulesResponse.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRulesResponse.java new file mode 100644 index 00000000..cc9d3fda --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/ListAlertRulesResponse.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The reponse for list alert rules. + */ +public class ListAlertRulesResponse extends AbstractBceResponse { + + /** + * The page size of list. + */ + private int pageSize = 10; + + /** + * The page no of list. + */ + private int pageNo = 1; + + /** + * The total count. + */ + private int totalCount; + + /** + * The result info. + */ + private List result; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/MetricsDataModel.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/MetricsDataModel.java new file mode 100644 index 00000000..a0e8eecb --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/MetricsDataModel.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import java.util.List; + +/** + * The model for metrics data. + */ +public class MetricsDataModel { + + /** + * The data type. + */ + private String resultType; + + /** + * The result list. + */ + private List result; + + public String getResultType() { + return resultType; + } + + public void setResultType(String resultType) { + this.resultType = resultType; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/MetricsResultModel.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/MetricsResultModel.java new file mode 100644 index 00000000..1a9f7f23 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/MetricsResultModel.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import java.util.List; + +/** + * The model for metrics result. + */ +public class MetricsResultModel { + + /** + * The label k-v pair. + */ + private Object metric; + + /** + * The array of metrics data. + */ + private List> values; + + public Object getMetric() { + return metric; + } + + public void setMetric(Object metric) { + this.metric = metric; + } + + public List> getValues() { + return values; + } + + public void setValues(List> values) { + this.values = values; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/UpdateAlertRulesRequest.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/UpdateAlertRulesRequest.java new file mode 100644 index 00000000..6b69a7d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/UpdateAlertRulesRequest.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class UpdateAlertRulesRequest extends AbstractBceRequest { + + /** + * The id of alert rule. + */ + private String alertRuleID; + + /** + * The duration time. + */ + private String duration; + + /** + * The PromQL query + */ + private String promql; + + /** + * The operator, eg >、 =、 < + */ + private String op; + + /** + * The interval time of repeat alert. + */ + private String repeatInterval; + + /** + * The contacts user. + */ + private AlertContacts contacts; + + /** + * The label info which contains k-v pair. + */ + private Object labels; + + /** + * The description info. + */ + private String description; + + /** + * The expected threshold. + */ + private int threshold = -1; + + public String getAlertRuleID() { + return alertRuleID; + } + + public void setAlertRuleID(String alertRuleID) { + this.alertRuleID = alertRuleID; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getPromql() { + return promql; + } + + public void setPromql(String promql) { + this.promql = promql; + } + + public String getOp() { + return op; + } + + public void setOp(String op) { + this.op = op; + } + + public String getRepeatInterval() { + return repeatInterval; + } + + public void setRepeatInterval(String repeatInterval) { + this.repeatInterval = repeatInterval; + } + + public AlertContacts getContacts() { + return contacts; + } + + public void setContacts(AlertContacts contacts) { + this.contacts = contacts; + } + + public Object getLabels() { + return labels; + } + + public void setLabels(Object labels) { + this.labels = labels; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getThreshold() { + return threshold; + } + + public void setThreshold(int threshold) { + this.threshold = threshold; + } + + public UpdateAlertRulesRequest withAlertRuleID(String alertRuleID) { + this.setAlertRuleID(alertRuleID); + return this; + } + + public UpdateAlertRulesRequest withDuration(String duration) { + this.setDuration(duration); + return this; + } + + public UpdateAlertRulesRequest withPromql(String promql) { + this.setPromql(promql); + return this; + } + + public UpdateAlertRulesRequest withOp(String op) { + this.setOp(op); + return this; + } + + public UpdateAlertRulesRequest withRepeatInterval(String repeatInterval) { + this.setRepeatInterval(repeatInterval); + return this; + } + + public UpdateAlertRulesRequest withContacts(AlertContacts alertContacts) { + this.setContacts(alertContacts); + return this; + } + + public UpdateAlertRulesRequest withLabels(Object labels) { + this.setLabels(labels); + return this; + } + + public UpdateAlertRulesRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public UpdateAlertRulesRequest withThreshold(int threshold) { + this.setThreshold(threshold); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public UpdateAlertRulesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/monitoring/UpdateAlertRulesResponse.java b/src/main/java/com/baidubce/services/cnap/model/monitoring/UpdateAlertRulesResponse.java new file mode 100644 index 00000000..cda16b16 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/monitoring/UpdateAlertRulesResponse.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.cnap.model.monitoring; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for update alert rules. + */ +public class UpdateAlertRulesResponse extends AbstractBceResponse { + + /** + * The id of resource. + */ + private String resourceID; + + /** + * The name of alert rule. + */ + private String name; + + /** + * The duration time. + */ + private String duration; + + /** + * The PromQL query + */ + private String promql; + + /** + * The operator. + */ + private String op; + + /** + * The interval time of repeat alert. + */ + private String repeatInterval; + + /** + * The contacts user. + */ + private AlertContacts contacts = new AlertContacts(); + + /** + * The label info which contains k-v pair. + */ + private Object labels = new Object(); + + /** + * The description info. + */ + private String description; + + /** + * The expected threshold. + */ + private int threshold; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getPromql() { + return promql; + } + + public void setPromql(String promql) { + this.promql = promql; + } + + public String getOp() { + return op; + } + + public void setOp(String op) { + this.op = op; + } + + public String getRepeatInterval() { + return repeatInterval; + } + + public void setRepeatInterval(String repeatInterval) { + this.repeatInterval = repeatInterval; + } + + public AlertContacts getContacts() { + return contacts; + } + + public void setContacts(AlertContacts contacts) { + this.contacts = contacts; + } + + public Object getLabels() { + return labels; + } + + public void setLabels(Object labels) { + this.labels = labels; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getThreshold() { + return threshold; + } + + public void setThreshold(int threshold) { + this.threshold = threshold; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/ConfigAndExpectVersionModel.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ConfigAndExpectVersionModel.java new file mode 100644 index 00000000..42fdf49e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ConfigAndExpectVersionModel.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +/** + * The model for config. + */ +public class ConfigAndExpectVersionModel { + /** + * The id of config. + */ + private String configID; + + /** + * The id of config version. + */ + private String expectConfigVersionID; + + public String getConfigID() { + return configID; + } + + public void setConfigID(String configID) { + this.configID = configID; + } + + public String getExpectConfigVersionID() { + return expectConfigVersionID; + } + + public void setExpectConfigVersionID(String expectConfigVersionID) { + this.expectConfigVersionID = expectConfigVersionID; + } + + public ConfigAndExpectVersionModel withConfigID(String configID) { + this.setConfigID(configID); + return this; + } + + public ConfigAndExpectVersionModel withExpectConfigVersionID(String expectConfigVersionID) { + this.setExpectConfigVersionID(expectConfigVersionID); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/CreateReleaseRecordRequest.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/CreateReleaseRecordRequest.java new file mode 100644 index 00000000..2a36f7d2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/CreateReleaseRecordRequest.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for create release record. + */ +public class CreateReleaseRecordRequest extends AbstractBceRequest { + + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The type of release record. eg: RdType. + */ + private String type = "RdType"; + + /** + * The description of release record. + */ + private String description = ""; + + /** + * The image info. + */ + private List images; + + /** + * The config info. + */ + private List configs = new LinkedList(); + + /** + * The task info. + */ + private List tasks; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getImages() { + return images; + } + + public void setImages(List images) { + this.images = images; + } + + public List getConfigs() { + return configs; + } + + public void setConfigs(List configs) { + this.configs = configs; + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } + + public CreateReleaseRecordRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public CreateReleaseRecordRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public CreateReleaseRecordRequest withType(String type) { + this.setType(type); + return this; + } + + public CreateReleaseRecordRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public CreateReleaseRecordRequest addImageAndExpectVersionModel(ImageAndExpectVersionModel model) { + if (CollectionUtils.isEmpty(images)) { + images = new LinkedList(); + } + images.add(model); + return this; + } + + public CreateReleaseRecordRequest addConfigAndExpectVersionModel(ConfigAndExpectVersionModel model) { + if (CollectionUtils.isEmpty(configs)) { + configs = new LinkedList(); + } + configs.add(model); + return this; + } + + public CreateReleaseRecordRequest addTaskReqModel(TaskReqModel model) { + if (CollectionUtils.isEmpty(tasks)) { + tasks = new LinkedList(); + } + tasks.add(model); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public CreateReleaseRecordRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/CreateReleaseRecordResponse.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/CreateReleaseRecordResponse.java new file mode 100644 index 00000000..dd246171 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/CreateReleaseRecordResponse.java @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.deploygroup.TaskModel; + +/** + * The response for create release record. + */ +public class CreateReleaseRecordResponse extends AbstractBceResponse { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The type of release record. + */ + private String type; + + /** + * The description of release record. + */ + private String description; + + /** + * The custom info. + */ + private String handleReason; + + /** + * The username of operator. + */ + private String executor; + + /** + * The status of release record. + */ + private String status; + + /** + * The id of release record transaction. + */ + private String transactionID; + + /** + * The custom info. + */ + private String planDeployTime; + + /** + * The id of release record. + */ + private String releaseRecordID; + + /** + * The start time. + */ + private Date startTime; + + /** + * The end time. + */ + private Date endTime; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + /** + * The images info. + */ + private Map images; + + /** + * The config info. + */ + private Map configs; + + /** + * The task info. + */ + private List tasks; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getHandleReason() { + return handleReason; + } + + public void setHandleReason(String handleReason) { + this.handleReason = handleReason; + } + + public String getExecutor() { + return executor; + } + + public void setExecutor(String executor) { + this.executor = executor; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTransactionID() { + return transactionID; + } + + public void setTransactionID(String transactionID) { + this.transactionID = transactionID; + } + + public String getPlanDeployTime() { + return planDeployTime; + } + + public void setPlanDeployTime(String planDeployTime) { + this.planDeployTime = planDeployTime; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Map getImages() { + return images; + } + + public void setImages(Map images) { + this.images = images; + } + + public Map getConfigs() { + return configs; + } + + public void setConfigs(Map configs) { + this.configs = configs; + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/DeployGroupBaseInfoModel.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/DeployGroupBaseInfoModel.java new file mode 100644 index 00000000..efecc627 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/DeployGroupBaseInfoModel.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.Date; +import java.util.List; + +import com.baidubce.services.cnap.model.application.ResourcesModel; +import com.baidubce.services.cnap.model.deploygroup.NewComponentModel; + +/** + * The model for deploy group base info. + */ +public class DeployGroupBaseInfoModel { + + /** + * The id of deploy group. + */ + private String resourceID; + + /** + * The name of deploy group. + */ + private String name; + + /** + * The description of deploy group. + */ + private String description; + + /** + * The type of deploy strategy. + */ + private String deployStrategyType; + + /** + * The replicas. + */ + private int replicas; + + /** + * The id of environment. + */ + private String environmentID; + + /** + * The flag which indicates the deploy group is locked. + */ + private boolean isLocked; + + /** + * The id of release record. + */ + private String releaseRecordID; + + /** + * The status of deploy group. + */ + private String status; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + /** + * The resource info. + */ + private ResourcesModel resources; + + /** + * The component conf of deploy group. + */ + private List componentConf; + + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDeployStrategyType() { + return deployStrategyType; + } + + public void setDeployStrategyType(String deployStrategyType) { + this.deployStrategyType = deployStrategyType; + } + + public int getReplicas() { + return replicas; + } + + public void setReplicas(int replicas) { + this.replicas = replicas; + } + + public String getEnvironmentID() { + return environmentID; + } + + public void setEnvironmentID(String environmentID) { + this.environmentID = environmentID; + } + + public boolean isLocked() { + return isLocked; + } + + public void setLocked(boolean locked) { + isLocked = locked; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public ResourcesModel getResources() { + return resources; + } + + public void setResources(ResourcesModel resources) { + this.resources = resources; + } + + public List getComponentConf() { + return componentConf; + } + + public void setComponentConf(List componentConf) { + this.componentConf = componentConf; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/GetReleaseRecordProgressRequest.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/GetReleaseRecordProgressRequest.java new file mode 100644 index 00000000..56002a6b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/GetReleaseRecordProgressRequest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get release record progress request. + */ +public class GetReleaseRecordProgressRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The id of release record. + */ + private String releaseRecordID; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public GetReleaseRecordProgressRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public GetReleaseRecordProgressRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public GetReleaseRecordProgressRequest withReleaseRecordID(String releaseRecordID) { + this.setReleaseRecordID(releaseRecordID); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public GetReleaseRecordProgressRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/GetReleaseRecordProgressResponse.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/GetReleaseRecordProgressResponse.java new file mode 100644 index 00000000..0cfed705 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/GetReleaseRecordProgressResponse.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.Date; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for get release record progress. + */ +public class GetReleaseRecordProgressResponse extends AbstractBceResponse { + /** + * The status. + */ + private String status; + + /** + * The start time. + */ + private Date startTime; + + /** + * The end time. + */ + private Date endTime; + + /** + * The task progress info. + */ + private List tasksProgress; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public List getTasksProgress() { + return tasksProgress; + } + + public void setTasksProgress(List tasksProgress) { + this.tasksProgress = tasksProgress; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/ImageAndExpectVersionModel.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ImageAndExpectVersionModel.java new file mode 100644 index 00000000..ada245c8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ImageAndExpectVersionModel.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +public class ImageAndExpectVersionModel { + + /** + * The address of updated image. + */ + private String image; + + /** + * The version 0f update image. + */ + private String expectImageVersion; + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getExpectImageVersion() { + return expectImageVersion; + } + + public void setExpectImageVersion(String expectImageVersion) { + this.expectImageVersion = expectImageVersion; + } + + public ImageAndExpectVersionModel withImage(String image) { + this.setImage(image); + return this; + } + + public ImageAndExpectVersionModel withExpectImageVersion(String expectImageVersion) { + this.setExpectImageVersion(expectImageVersion); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/ListReleaseRecordRequest.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ListReleaseRecordRequest.java new file mode 100644 index 00000000..196bfa19 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ListReleaseRecordRequest.java @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.Date; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list release record. + */ +public class ListReleaseRecordRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The order by info. eg: startTime + */ + private String orderBy; + + /** + * The order info. eg: desc or asc. + */ + private String order; + + /** + * The page size. + */ + private String pageSize = "10"; + + /** + * The page no. + */ + private String pageNo = "1"; + + /** + * The operator. + */ + private String executor; + + /** + * The status of release record. eg: RUNNING,PENDING,PAUSED,TERMINATED,SUCCESS + */ + private String status; + + /** + * The type of release record. + */ + private String type; + + /** + * The start time. + */ + private Date startTime; + + /** + * The end time. + */ + private Date endTime; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getPageSize() { + return pageSize; + } + + public void setPageSize(String pageSize) { + this.pageSize = pageSize; + } + + public String getPageNo() { + return pageNo; + } + + public void setPageNo(String pageNo) { + this.pageNo = pageNo; + } + + public String getExecutor() { + return executor; + } + + public void setExecutor(String executor) { + this.executor = executor; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public ListReleaseRecordRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public ListReleaseRecordRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public ListReleaseRecordRequest withOrderBy(String orderBy) { + this.setOrder(orderBy); + return this; + } + + public ListReleaseRecordRequest withOrder(String order) { + this.setOrder(order); + return this; + } + + public ListReleaseRecordRequest withPageSize(String pageSize) { + this.setPageSize(pageSize); + return this; + } + + public ListReleaseRecordRequest withPageNo(String pageNo) { + this.setPageNo(pageNo); + return this; + } + + public ListReleaseRecordRequest withExecutor(String executor) { + this.setExecutor(executor); + return this; + } + + public ListReleaseRecordRequest withStatus(String status) { + this.setStatus(status); + return this; + } + + public ListReleaseRecordRequest withType(String type) { + this.setType(type); + return this; + } + + public ListReleaseRecordRequest withStartTime(Date startTime) { + this.setStartTime(startTime); + return this; + } + + public ListReleaseRecordRequest withEndTime(Date endTime) { + this.setEndTime(endTime); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListReleaseRecordRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/ListReleaseRecordResponse.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ListReleaseRecordResponse.java new file mode 100644 index 00000000..292a3ee5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ListReleaseRecordResponse.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for list release record. + */ +public class ListReleaseRecordResponse extends AbstractBceResponse { + /** + * The page no. + */ + private int pageNo; + + /** + * The page size. + */ + private int pageSize; + + /** + * The total count. + */ + private int totalCount; + + /** + * The result list. + */ + private List result; + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult( + List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/ReleaseRecordWithDeployGroupModel.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ReleaseRecordWithDeployGroupModel.java new file mode 100644 index 00000000..9bdbd7fb --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/ReleaseRecordWithDeployGroupModel.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.Date; +import java.util.List; + +/** + * The model for release record with deploy group. + */ +public class ReleaseRecordWithDeployGroupModel { + + /** + * The id of release record. + */ + private String releaseRecordID; + + /** + * The operator of release record. + */ + private String executor; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The status of release record. + */ + private String status; + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The type of release record. + */ + private String type; + + /** + * The description of release record. + */ + private String description; + + /** + * The custom info. + */ + private String handleReason; + + /** + * The id of release record transaction. + */ + private String transactionID; + + /** + * The custom info. + */ + private Date planDeployTime; + + /** + * The start time. + */ + private Date startTime; + + /** + * The end time. + */ + private Date endTime; + + /** + * The deploy group info. + */ + private List deployGroups; + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public String getExecutor() { + return executor; + } + + public void setExecutor(String executor) { + this.executor = executor; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getHandleReason() { + return handleReason; + } + + public void setHandleReason(String handleReason) { + this.handleReason = handleReason; + } + + public String getTransactionID() { + return transactionID; + } + + public void setTransactionID(String transactionID) { + this.transactionID = transactionID; + } + + public Date getPlanDeployTime() { + return planDeployTime; + } + + public void setPlanDeployTime(Date planDeployTime) { + this.planDeployTime = planDeployTime; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public List getDeployGroups() { + return deployGroups; + } + + public void setDeployGroups( + List deployGroups) { + this.deployGroups = deployGroups; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/RollbackReleaseRecordRequest.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/RollbackReleaseRecordRequest.java new file mode 100644 index 00000000..39591992 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/RollbackReleaseRecordRequest.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for rollback release record. + */ +public class RollbackReleaseRecordRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The id of release record. + */ + private String releaseRecordID; + + /** + * The description of rollback. + */ + private String description; + + /** + * The task info of rollback. + */ + private List tasks; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public RollbackReleaseRecordRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public RollbackReleaseRecordRequest withApplicationID(String applicationID) { + this.setApplicationID(applicationID); + return this; + } + + public RollbackReleaseRecordRequest withReleaseRecordID(String releaseRecordID) { + this.setReleaseRecordID(releaseRecordID); + return this; + } + + public RollbackReleaseRecordRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + public RollbackReleaseRecordRequest addTaskReqModel(TaskReqModel model) { + if (CollectionUtils.isEmpty(tasks)) { + tasks = new LinkedList(); + } + tasks.add(model); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public RollbackReleaseRecordRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/RollbackReleaseRecordResponse.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/RollbackReleaseRecordResponse.java new file mode 100644 index 00000000..2aa7ed06 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/RollbackReleaseRecordResponse.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.cnap.model.deploygroup.TaskModel; + +/** + * The response for rollback. + */ +public class RollbackReleaseRecordResponse extends AbstractBceResponse { + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of application. + */ + private String applicationID; + + /** + * The type of release record. + */ + private String type; + + /** + * The description of release record. + */ + private String description; + + /** + * The custom info. + */ + private String handleReason; + + /** + * The username of operator. + */ + private String executor; + + /** + * The status of release record. + */ + private String status; + + /** + * The id of release record transaction. + */ + private String transactionID; + + /** + * The custom info. + */ + private String planDeployTime; + + /** + * The id of release record. + */ + private String releaseRecordID; + + /** + * The start time. + */ + private Date startTime; + + /** + * The end time. + */ + private Date endTime; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + /** + * The images info. + */ + private Map images; + + /** + * The config info. + */ + private Map configs; + + /** + * The task info. + */ + private List tasks; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getApplicationID() { + return applicationID; + } + + public void setApplicationID(String applicationID) { + this.applicationID = applicationID; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getHandleReason() { + return handleReason; + } + + public void setHandleReason(String handleReason) { + this.handleReason = handleReason; + } + + public String getExecutor() { + return executor; + } + + public void setExecutor(String executor) { + this.executor = executor; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTransactionID() { + return transactionID; + } + + public void setTransactionID(String transactionID) { + this.transactionID = transactionID; + } + + public String getPlanDeployTime() { + return planDeployTime; + } + + public void setPlanDeployTime(String planDeployTime) { + this.planDeployTime = planDeployTime; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Map getImages() { + return images; + } + + public void setImages(Map images) { + this.images = images; + } + + public Map getConfigs() { + return configs; + } + + public void setConfigs(Map configs) { + this.configs = configs; + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/TaskBaseInfoModel.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/TaskBaseInfoModel.java new file mode 100644 index 00000000..60e3068b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/TaskBaseInfoModel.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.Date; + +/** + * The model for task base info. + */ +public class TaskBaseInfoModel { + /** + * The id of task. + */ + private String taskID; + + /** + * The type of type. + */ + private String type; + + /** + * The id of release record. + */ + private String releaseRecordID; + + /** + * The status of task. + */ + private String status; + + /** + * The pre id of task. + */ + private String preTaskID; + + /** + * The action after task. + */ + private int pendAfterTask; + + /** + * The name of task. + */ + private String name; + + /** + * The process of task. + */ + private String progress; + + /** + * The start time. + */ + private Date startTime; + + /** + * The end time. + */ + private Date endTime; + + /** + * The create time. + */ + private Date createdAt; + + /** + * The update time. + */ + private Date updatedAt; + + public String getTaskID() { + return taskID; + } + + public void setTaskID(String taskID) { + this.taskID = taskID; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getReleaseRecordID() { + return releaseRecordID; + } + + public void setReleaseRecordID(String releaseRecordID) { + this.releaseRecordID = releaseRecordID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPreTaskID() { + return preTaskID; + } + + public void setPreTaskID(String preTaskID) { + this.preTaskID = preTaskID; + } + + public int getPendAfterTask() { + return pendAfterTask; + } + + public void setPendAfterTask(int pendAfterTask) { + this.pendAfterTask = pendAfterTask; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProgress() { + return progress; + } + + public void setProgress(String progress) { + this.progress = progress; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/TaskProgressModel.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/TaskProgressModel.java new file mode 100644 index 00000000..e37ac0a4 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/TaskProgressModel.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +import java.util.Date; + +/** + * The model for task progress. + */ +public class TaskProgressModel { + + /** + * The id of task. + */ + private String taskID; + + /** + * The progress of task. + */ + private String progress; + + /** + * The flag which indicate the task is current. + */ + private boolean currentTask; + + /** + * The status of task. + */ + private String status; + + /** + * The start time. + */ + private Date startTime; + + /** + * The end time. + */ + private Date endTime; + + public String getTaskID() { + return taskID; + } + + public void setTaskID(String taskID) { + this.taskID = taskID; + } + + public String getProgress() { + return progress; + } + + public void setProgress(String progress) { + this.progress = progress; + } + + + public boolean getCurrentTask() { + return this.currentTask; + } + + public void setCurrentTask(boolean currentTask) { + this.currentTask = currentTask; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/releaserecord/TaskReqModel.java b/src/main/java/com/baidubce/services/cnap/model/releaserecord/TaskReqModel.java new file mode 100644 index 00000000..ac266e33 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/releaserecord/TaskReqModel.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.releaserecord; + +/** + * The model for task. + */ +public class TaskReqModel { + /** + * The id of deploy group. + */ + private String deployGroupID; + + /** + * The operation after task. eg: 0 , 1. + * 0 indicates continue after task. + * 1 indicates pending after task. + */ + private int pendAfterTask = 0; + + + + public String getDeployGroupID() { + return deployGroupID; + } + + public void setDeployGroupID(String deployGroupID) { + this.deployGroupID = deployGroupID; + } + + public int getPendAfterTask() { + return pendAfterTask; + } + + public void setPendAfterTask(int pendAfterTask) { + this.pendAfterTask = pendAfterTask; + } + + public TaskReqModel withDeployGroupID(String deployGroupID) { + this.setDeployGroupID(deployGroupID); + return this; + } + + public TaskReqModel withPendAfterTask(int pendAfterTask) { + this.setPendAfterTask(pendAfterTask); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/repository/CreateRepositoryRequest.java b/src/main/java/com/baidubce/services/cnap/model/repository/CreateRepositoryRequest.java new file mode 100644 index 00000000..20d785da --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/repository/CreateRepositoryRequest.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.repository; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for create repository. + */ +public class CreateRepositoryRequest extends AbstractBceRequest { + + /** + * The endpoint of repository. + * The endpoint of Baidu Yun repository: hub.baidubce.com + */ + private String endpoint = "hub.baidubce.com"; + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The name of repository. + */ + private String name; + + /** + * The type of repository. + * 1 indicates Baidu Yun repository. + * 2 indicates Docker Hub repository. + * 3 indicates Custom repository. + */ + private int type = 1; + + /** + * The flag which indicates repository is secure. + */ + private boolean isSecure = true; + + /** + * The flag which indicates repository is private. + */ + private boolean isPrivate = true; + + /** + * The repository username. + */ + private String username; + + /** + * The repository password. + */ + private String password; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public boolean getIsSecure() { + return isSecure; + } + + public void setIsSecure(boolean isSecure) { + this.isSecure = isSecure; + } + + public boolean getIsPrivate() { + return isPrivate; + } + + public void setIsPrivate(boolean isPrivate) { + this.isPrivate = isPrivate; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public CreateRepositoryRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public CreateRepositoryRequest withName(String name) { + this.setName(name); + return this; + } + + public CreateRepositoryRequest withType(int type) { + this.setType(type); + return this; + } + + public CreateRepositoryRequest withSecure(boolean isSecure) { + this.setIsSecure(isSecure); + return this; + } + + public CreateRepositoryRequest withPriviate(boolean priviate) { + this.setIsPrivate(priviate); + return this; + } + + public CreateRepositoryRequest withUsername(String username) { + this.setUsername(username); + return this; + } + + public CreateRepositoryRequest withPassword(String password) { + this.setPassword(password); + return this; + } + + public CreateRepositoryRequest withEndpoint(String endpoint) { + this.setEndpoint(endpoint); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public CreateRepositoryRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/repository/CreateRepositoryResponse.java b/src/main/java/com/baidubce/services/cnap/model/repository/CreateRepositoryResponse.java new file mode 100644 index 00000000..a72128fe --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/repository/CreateRepositoryResponse.java @@ -0,0 +1,114 @@ + +package com.baidubce.services.cnap.model.repository; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for create repository. + */ +public class CreateRepositoryResponse extends AbstractBceResponse { + + /** + * The endpoint of repository. + */ + private String endpoint; + + /** + * The flag which indicates repository is secure. + */ + private boolean isSecure; + + /** + * The flag which indicates repository is private. + */ + private boolean isPrivate; + + /** + * The name of repository. + */ + private String name; + + /** + * The repository password. + */ + private String password; + + /** + * The type of repository. + */ + private int type; + + /** + * The repository username. + */ + private String username; + + /** + * The id of repository. + */ + private String resourceID; + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public boolean getIsSecure() { + return isSecure; + } + + public void setIsSecure(boolean isSecure) { + this.isSecure = isSecure; + } + + public boolean getIsPrivate() { + return this.isPrivate; + } + + public void setIsPrivate(boolean isPrivate) { + this.isPrivate = isPrivate; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/repository/ImageMetaModel.java b/src/main/java/com/baidubce/services/cnap/model/repository/ImageMetaModel.java new file mode 100644 index 00000000..2bfaa595 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/repository/ImageMetaModel.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.repository; + +import java.util.Date; + +/** + * The image meta model. + */ +public class ImageMetaModel { + /** + * The name of image. + */ + private String name; + + /** + * The namespace of image. + */ + private String namespace; + + /** + * The description of image. + */ + private String description; + + /** + * The address of image. + */ + private String address; + + /** + * The flag which indicate the image is private. + */ + private String isPrivate; + + /** + * The create time. + */ + private Date createAt; + + /** + * The update time. + */ + private Date updateAt; + + /** + * The full description of image. + */ + private String fullDescription; + + /** + * The logo url of image. + */ + private String logoUrl; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getIsPrivate() { + return isPrivate; + } + + public void setIsPrivate(String isPrivate) { + this.isPrivate = isPrivate; + } + + public Date getCreateAt() { + return createAt; + } + + public void setCreateAt(Date createAt) { + this.createAt = createAt; + } + + public Date getUpdateAt() { + return updateAt; + } + + public void setUpdateAt(Date updateAt) { + this.updateAt = updateAt; + } + + public String getFullDescription() { + return fullDescription; + } + + public void setFullDescription(String fullDescription) { + this.fullDescription = fullDescription; + } + + public String getLogoUrl() { + return logoUrl; + } + + public void setLogoUrl(String logoUrl) { + this.logoUrl = logoUrl; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/repository/ListImageRequest.java b/src/main/java/com/baidubce/services/cnap/model/repository/ListImageRequest.java new file mode 100644 index 00000000..d16c7e0b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/repository/ListImageRequest.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.repository; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list images. + */ +public class ListImageRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The id of repository. + */ + private String repositoryID; + + /** + * The order by info. + */ + private String orderBy = "name"; + + /** + * The order info, eg asc, desc. + */ + private String order = "asc"; + + /** + * The page size of list. + */ + private int pageSize = 10; + + /** + * The page no of list. + */ + private int pageNo = 1; + + /** + * The name of image. + */ + private String name; + + public ListImageRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public ListImageRequest withRepositoryID(String repositoryID) { + this.setRepositoryID(repositoryID); + return this; + } + + public ListImageRequest withOrderBy(String orderBy) { + this.setOrderBy(orderBy); + return this; + } + + public ListImageRequest withOrder(String order) { + this.setOrder(order); + return this; + } + + public ListImageRequest withPageSize(int pageSize) { + this.setPageSize(pageSize); + return this; + } + + public ListImageRequest withPageNo(int pageNo) { + this.setPageNo(pageNo); + return this; + } + + public ListImageRequest withName(String name) { + this.setName(name); + return this; + } + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getRepositoryID() { + return repositoryID; + } + + public void setRepositoryID(String repositoryID) { + this.repositoryID = repositoryID; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListImageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/repository/ListImageResponse.java b/src/main/java/com/baidubce/services/cnap/model/repository/ListImageResponse.java new file mode 100644 index 00000000..b4ccd8f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/repository/ListImageResponse.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.repository; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +public class ListImageResponse extends AbstractBceResponse { + + /** + * The page size of list. + */ + private int pageSize = 10; + + /** + * The page no of list. + */ + private int pageNo = 1; + + /** + * The total count. + */ + private int totalCount; + + /** + * The result of list image. + */ + List result; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/CreateWorkspaceRequest.java b/src/main/java/com/baidubce/services/cnap/model/workspace/CreateWorkspaceRequest.java new file mode 100644 index 00000000..344621da --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/CreateWorkspaceRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for create workspace. + */ +public class CreateWorkspaceRequest extends AbstractBceRequest { + + /** + * The workspace info. + */ + private NewWorkspaceModel workspace; + + /** + * The optional ids of cluster. + */ + private List clusterIDs = new ArrayList(); + + public NewWorkspaceModel getWorkspace() { + return workspace; + } + + public void setWorkspace(NewWorkspaceModel workspace) { + this.workspace = workspace; + } + + public List getClusterIDs() { + return clusterIDs; + } + + public void setClusterIDs(List clusterIDs) { + this.clusterIDs = clusterIDs; + } + + public CreateWorkspaceRequest withNewWorkspaceModel(NewWorkspaceModel newWorkspaceModel) { + this.setWorkspace(newWorkspaceModel); + return this; + } + + public CreateWorkspaceRequest addClusterID(String clusterID) { + if (CollectionUtils.isEmpty(clusterIDs)) { + clusterIDs = new LinkedList(); + } + clusterIDs.add(clusterID); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public CreateWorkspaceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/CreateWorkspaceResponse.java b/src/main/java/com/baidubce/services/cnap/model/workspace/CreateWorkspaceResponse.java new file mode 100644 index 00000000..18ec4162 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/CreateWorkspaceResponse.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; + +public class CreateWorkspaceResponse extends AbstractBceResponse { + /** + * The resource id of workspace. + */ + private String resourceID; + + /** + * The name of workspace. + */ + private String name; + + /** + * The description of workspace. + */ + private String description; + + /** + * The create time of workspace. + */ + private Date createdAt; + + /** + * The update time of workspace. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/DeleteWorkspaceRequest.java b/src/main/java/com/baidubce/services/cnap/model/workspace/DeleteWorkspaceRequest.java new file mode 100644 index 00000000..05dcf128 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/DeleteWorkspaceRequest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class DeleteWorkspaceRequest extends AbstractBceRequest { + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The flag indicates whether can ignore underlay error. + */ + private boolean ignoreUnderlayError = true; + + /** + * The flag indicates whether can skip delete underlay. + */ + private boolean skipDeleteUnderlay = true; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public void setIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.ignoreUnderlayError = ignoreUnderlayError; + } + + public boolean getIgnoreUnderlayError() { + return ignoreUnderlayError; + } + + public void setSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.skipDeleteUnderlay = skipDeleteUnderlay; + } + + public boolean getSkipDeleteUnderlay() { + return skipDeleteUnderlay; + } + + public DeleteWorkspaceRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public DeleteWorkspaceRequest withIgnoreUnderlayError(boolean ignoreUnderlayError) { + this.setIgnoreUnderlayError(ignoreUnderlayError); + return this; + } + + public DeleteWorkspaceRequest withSkipDeleteUnderlay(boolean skipDeleteUnderlay) { + this.setSkipDeleteUnderlay(skipDeleteUnderlay); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public DeleteWorkspaceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/DeleteWorkspaceResponse.java b/src/main/java/com/baidubce/services/cnap/model/workspace/DeleteWorkspaceResponse.java new file mode 100644 index 00000000..84c3bc6e --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/DeleteWorkspaceResponse.java @@ -0,0 +1,9 @@ +package com.baidubce.services.cnap.model.workspace; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for delete workspace. + */ +public class DeleteWorkspaceResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceNameRequest.java b/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceNameRequest.java new file mode 100644 index 00000000..044400c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceNameRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get workspace name. + */ +public class GetWorkspaceNameRequest extends AbstractBceRequest { + /** + * The id of workspace. + */ + private String workspaceID; + /** + * The user id of workspace. + */ + private String userID; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getUserID() { + return userID; + } + + public void setUserID(String userID) { + this.userID = userID; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public GetWorkspaceNameRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public GetWorkspaceNameRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public GetWorkspaceNameRequest withUserID(String userID) { + this.setUserID(userID); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceNameResponse.java b/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceNameResponse.java new file mode 100644 index 00000000..1c725b19 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceNameResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for get workspace name. + */ +public class GetWorkspaceNameResponse extends AbstractBceResponse { + + /** + * The name of workspace. + */ + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceRequest.java b/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceRequest.java new file mode 100644 index 00000000..b4486288 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get workspace. + */ +public class GetWorkspaceRequest extends AbstractBceRequest { + /** + * The id of workspace. + */ + private String workspaceID; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public GetWorkspaceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public GetWorkspaceRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceResponse.java b/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceResponse.java new file mode 100644 index 00000000..2e3f25a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/GetWorkspaceResponse.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for get workspace detail. + */ +public class GetWorkspaceResponse extends AbstractBceResponse { + /** + * The resource id of workspace. + */ + private String resourceID; + + /** + * The name of workspace. + */ + private String name; + + /** + * The description of workspace. + */ + private String description; + + /** + * The create time of workspace. + */ + private Date createdAt; + + /** + * The update time of workspace. + */ + private Date updatedAt; + + /** + * The application count of workspace. + */ + private int applicationCount; + + /** + * The cluster count of workspace. + */ + private int clusterCount; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public int getApplicationCount() { + return applicationCount; + } + + public void setApplicationCount(int applicationCount) { + this.applicationCount = applicationCount; + } + + public int getClusterCount() { + return clusterCount; + } + + public void setClusterCount(int clusterCount) { + this.clusterCount = clusterCount; + } + +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/ListWorkspaceRequest.java b/src/main/java/com/baidubce/services/cnap/model/workspace/ListWorkspaceRequest.java new file mode 100644 index 00000000..6028e5f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/ListWorkspaceRequest.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for list workspace. + */ +public class ListWorkspaceRequest extends AbstractBceRequest { + + /** + * The orderBy info, eg. createdAt(workspace create time) + */ + private String orderBy = "createdAt"; + + /** + * The order info, eg. asc, desc. + */ + private String order = "desc"; + + /** + * The page size of list. + */ + private String pageSize = "10"; + + /** + * The page no of list. + */ + private String pageNo = "1"; + + /** + * The name of workspace. + */ + private String name; + + /** + * The id of workspace. + */ + private String resourceID; + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getPageSize() { + return pageSize; + } + + public void setPageSize(String pageSize) { + this.pageSize = pageSize; + } + + public String getPageNo() { + return pageNo; + } + + public void setPageNo(String pageNo) { + this.pageNo = pageNo; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public ListWorkspaceRequest withOrderBy(String orderBy) { + this.setOrderBy(orderBy); + return this; + } + + public ListWorkspaceRequest withOrder(String order) { + this.setOrder(order); + return this; + } + + public ListWorkspaceRequest withPageSize(String pageSize) { + this.setPageSize(pageSize); + return this; + } + + public ListWorkspaceRequest withPageNo(String pageNo) { + this.setPageNo(pageNo); + return this; + } + + public ListWorkspaceRequest withName(String name) { + this.setName(name); + return this; + } + + public ListWorkspaceRequest withResourceID(String resourceID) { + this.setResourceID(resourceID); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return request with credentials. + */ + @Override + public ListWorkspaceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/ListWorkspaceResponse.java b/src/main/java/com/baidubce/services/cnap/model/workspace/ListWorkspaceResponse.java new file mode 100644 index 00000000..96f31784 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/ListWorkspaceResponse.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for list workspace. + */ +public class ListWorkspaceResponse extends AbstractBceResponse { + + /** + * The page size of list. + */ + private int pageSize; + + /** + * The page no of list. + */ + private int pageNo; + + /** + * The total count of list. + */ + private int totalCount; + + /** + * The result of list workspace. + */ + private List result; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/NewWorkspaceModel.java b/src/main/java/com/baidubce/services/cnap/model/workspace/NewWorkspaceModel.java new file mode 100644 index 00000000..3218ef19 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/NewWorkspaceModel.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +/** + * The workspace info modal. + */ +public class NewWorkspaceModel { + + /** + * The name of workspace. + */ + private String name; + + /** + * The optional description of workspace + * + */ + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public NewWorkspaceModel withName(String name) { + this.setName(name); + return this; + } + + public NewWorkspaceModel withDescription(String description) { + this.setDescription(description); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/UpdateWorkspaceRequest.java b/src/main/java/com/baidubce/services/cnap/model/workspace/UpdateWorkspaceRequest.java new file mode 100644 index 00000000..149526a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/UpdateWorkspaceRequest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for update workspace. + */ +public class UpdateWorkspaceRequest extends AbstractBceRequest { + + /** + * The id of workspace. + */ + private String workspaceID; + + /** + * The description of workspace. + */ + private String description; + + public String getWorkspaceID() { + return workspaceID; + } + + public void setWorkspaceID(String workspaceID) { + this.workspaceID = workspaceID; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public UpdateWorkspaceRequest withWorkspaceID(String workspaceID) { + this.setWorkspaceID(workspaceID); + return this; + } + + public UpdateWorkspaceRequest withDescription(String description) { + this.setDescription(description); + return this; + } + + @Override + public UpdateWorkspaceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/UpdateWorkspaceResponse.java b/src/main/java/com/baidubce/services/cnap/model/workspace/UpdateWorkspaceResponse.java new file mode 100644 index 00000000..c53f267b --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/UpdateWorkspaceResponse.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import java.util.Date; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for update workspace. + */ +public class UpdateWorkspaceResponse extends AbstractBceResponse { + /** + * The resource id of workspace. + */ + private String resourceID; + + /** + * The name of workspace. + */ + private String name; + + /** + * The description of workspace. + */ + private String description; + + /** + * The create time of workspace. + */ + private Date createdAt; + + /** + * The update time of workspace. + */ + private Date updatedAt; + + /** + * The application count of workspace. + */ + private int applicationCount; + + /** + * The cluster count of workspace. + */ + private int clusterCount; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public int getApplicationCount() { + return applicationCount; + } + + public void setApplicationCount(int applicationCount) { + this.applicationCount = applicationCount; + } + + public int getClusterCount() { + return clusterCount; + } + + public void setClusterCount(int clusterCount) { + this.clusterCount = clusterCount; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/WorkspaceBaseInfoModel.java b/src/main/java/com/baidubce/services/cnap/model/workspace/WorkspaceBaseInfoModel.java new file mode 100644 index 00000000..37b99419 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/WorkspaceBaseInfoModel.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import java.util.Date; + +/** + * The base model for workspace. + */ +public class WorkspaceBaseInfoModel { + + /** + * The resource id of workspace. + */ + private String resourceID; + + /** + * The name of workspace. + */ + private String name; + + /** + * The description of workspace. + */ + private String description; + + /** + * The create time of workspace. + */ + private Date createdAt; + + /** + * The update time of workspace. + */ + private Date updatedAt; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/src/main/java/com/baidubce/services/cnap/model/workspace/WorkspaceModel.java b/src/main/java/com/baidubce/services/cnap/model/workspace/WorkspaceModel.java new file mode 100644 index 00000000..6195dbb3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cnap/model/workspace/WorkspaceModel.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.cnap.model.workspace; + +import java.util.Date; + +/** + * The workspace of model. + */ +public class WorkspaceModel { + /** + * The resource id of workspace. + */ + private String resourceID; + + /** + * The name of workspace. + */ + private String name; + + /** + * The description of workspace. + */ + private String description; + + /** + * The create time of workspace. + */ + private Date createdAt; + + /** + * The update time of workspace. + */ + private Date updatedAt; + + /** + * The application count of workspace. + */ + private int applicationCount; + + /** + * The cluster count of workspace. + */ + private int clusterCount; + + public String getResourceID() { + return resourceID; + } + + public void setResourceID(String resourceID) { + this.resourceID = resourceID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public int getApplicationCount() { + return applicationCount; + } + + public void setApplicationCount(int applicationCount) { + this.applicationCount = applicationCount; + } + + public int getClusterCount() { + return clusterCount; + } + + public void setClusterCount(int clusterCount) { + this.clusterCount = clusterCount; + } +} diff --git a/src/main/java/com/baidubce/services/csn/CsnClient.java b/src/main/java/com/baidubce/services/csn/CsnClient.java new file mode 100644 index 00000000..aa474f58 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/CsnClient.java @@ -0,0 +1,717 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn; + +import java.util.Map; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.common.ApiInfo; +import com.baidubce.common.BaseBceClient; +import com.baidubce.common.BaseBceResponse; +import com.baidubce.common.BceRegion; +import com.baidubce.internal.InternalRequest; +import com.baidubce.services.csn.api.CsnApi; +import com.baidubce.services.csn.model.AttachInstanceRequest; +import com.baidubce.services.csn.model.BindCsnBpRequest; +import com.baidubce.services.csn.model.CreateAssociationRequest; +import com.baidubce.services.csn.model.CreateCsnBpLimitRequest; +import com.baidubce.services.csn.model.CreateCsnBpRequest; +import com.baidubce.services.csn.model.CreateCsnBpResponse; +import com.baidubce.services.csn.model.CreateCsnRequest; +import com.baidubce.services.csn.model.CreateCsnResponse; +import com.baidubce.services.csn.model.CreatePropagationRequest; +import com.baidubce.services.csn.model.CreateRouteRuleRequest; +import com.baidubce.services.csn.model.CsnBpPriceRequest; +import com.baidubce.services.csn.model.CsnBpPriceResponse; +import com.baidubce.services.csn.model.DeleteCsnBpLimitRequest; +import com.baidubce.services.csn.model.DetachInstanceRequest; +import com.baidubce.services.csn.model.GetCsnBpResponse; +import com.baidubce.services.csn.model.GetCsnResponse; +import com.baidubce.services.csn.model.ListAssociationResponse; +import com.baidubce.services.csn.model.ListCsnBpLimitByCsnIdResponse; +import com.baidubce.services.csn.model.ListCsnBpLimitResponse; +import com.baidubce.services.csn.model.ListCsnBpResponse; +import com.baidubce.services.csn.model.ListCsnResponse; +import com.baidubce.services.csn.model.ListInstanceResponse; +import com.baidubce.services.csn.model.ListPropagationResponse; +import com.baidubce.services.csn.model.ListRouteRuleResponse; +import com.baidubce.services.csn.model.ListRouteTableResponse; +import com.baidubce.services.csn.model.ListTgwResponse; +import com.baidubce.services.csn.model.ListTgwRuleResponse; +import com.baidubce.services.csn.model.ResizeCsnBpRequest; +import com.baidubce.services.csn.model.UnbindCsnBpRequest; +import com.baidubce.services.csn.model.UpdateCsnBpLimitRequest; +import com.baidubce.services.csn.model.UpdateCsnBpRequest; +import com.baidubce.services.csn.model.UpdateCsnRequest; +import com.baidubce.services.csn.model.UpdateTgwRequest; +import com.google.common.collect.ImmutableMap; + +/** + * Csn + */ +public class CsnClient extends BaseBceClient { + + private static final Map ENDPOINTS = ImmutableMap.builder() + .put(BceRegion.DEFAULT, "http://csn.baidubce.com") + .build(); + + /** + * Service name for extra config and handler. + */ + private static final String SERVICE_ID = "Csn"; + + /** + * Constructs a new client to invoke service methods on demo with region. + */ + public CsnClient(String ak, String sk, BceRegion region) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(region)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public CsnClient(String ak, String sk) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(BceRegion.DEFAULT)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public CsnClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Api lists + */ + private static final Map CSN_APIS = CsnApi.getApis(); + + /* -------------------------- 云智能网相关 -------------------------- */ + + /** + * 创建云智能网。 + * + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + * @param body + * @return CreateCsnResponse + */ + public CreateCsnResponse createCsn(CreateCsnRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("createCsn")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreateCsnResponse.class); + } + + /** + * 更新云智能网。 更新云智能网的名称和描述。 + * + * @param csnId 云智能网ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + * @param body + */ + public void updateCsn(String csnId, UpdateCsnRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("updateCsn")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 删除云智能网。 已经加载了网络实例的云智能网不能直接删除,必须先卸载实例。 + * + * @param csnId 云智能网的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + */ + public void deleteCsn(String csnId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("deleteCsn")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 查询云智能网列表。 + * + * @param marker 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + * @param maxKeys 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + * @return ListCsnResponse + */ + public ListCsnResponse listCsn(String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listCsn")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("marker", marker); + if (null == maxKeys) { + maxKeys = 1000; + } + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListCsnResponse.class); + } + + /** + * 查询指定云智能网下加载的网络实例信息。 + * + * @param csnId 云智能网的ID + * @param marker 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + * @param maxKeys 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + * @return ListInstanceResponse 云智能网下加载的网络实例列表 + */ + public ListInstanceResponse listInstance(String csnId, String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listInstance")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId).get(); + apiInfo.getQueries().put("marker", marker); + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListInstanceResponse.class); + } + + /** + * 查询云智能网详情。 + * + * @param csnId csnId 云智能网的ID + * @return GetCsnResponse 云智能网详情 + */ + public GetCsnResponse getCsn(String csnId) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("getCsn")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetCsnResponse.class); + } + + /** + * 从云智能网中移出指定的网络实例。 + * + * @param csnId 云智能网的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + * @param detachInstanceRequest 卸载网络实例的请求参数 + */ + public void detachInstance(String csnId, DetachInstanceRequest detachInstanceRequest, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("detachInstance")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), detachInstanceRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 将网络实例加载进云智能网。 + * + * @param csnId 云智能网的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + * @param attachInstanceRequest 加载网络实例的请求参数 + */ + public void attachInstance(String csnId, AttachInstanceRequest attachInstanceRequest, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("attachInstance")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), attachInstanceRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /* -------------------------- 路由管理相关 -------------------------- */ + + /** + * 添加云智能网路由表的路由条目。 + * + * @param csnRtId 云智能网路由表的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + * @param createRouteRuleRequest + */ + public void createRouteRule(String csnRtId, CreateRouteRuleRequest createRouteRuleRequest, + String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("createRouteRule")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnRtId", csnRtId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), createRouteRuleRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 查询指定云智能网路由表的路由条目。 + * + * @param csnRtId 云智能网路由表的ID + * @param marker 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + * @param maxKeys 每页包含的最大数量,最大数量不超过1000。缺省值为1000 + * @return ListRouteRuleResponse + */ + public ListRouteRuleResponse listRouteRule(String csnRtId, String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listRouteRule")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnRtId", csnRtId).get(); + apiInfo.getQueries().put("marker", marker); + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListRouteRuleResponse.class); + } + + /** + * 删除云智能网路由表的指定路由条目。 + * + * @param csnRtId 路由表的ID + * @param csnRtRuleId 路由条目的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + */ + public void deleteRouteRule(String csnRtId, String csnRtRuleId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("deleteRouteRule")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnRtId", csnRtId) + .withPathParameter("csnRtRuleId", csnRtRuleId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 创建路由表的学习关系。 + * + * @param csnRtId 云智能网路由表的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + * @param createPropagationRequest + */ + public void createPropagation(String csnRtId, CreatePropagationRequest createPropagationRequest, + String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("createPropagation")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnRtId", csnRtId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), createPropagationRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 查询指定云智能网路由表的学习关系。 + * + * @param csnRtId 云智能网路由表的ID + * @return ListPropagationResponse + */ + public ListPropagationResponse listPropagation(String csnRtId) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listPropagation")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnRtId", csnRtId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListPropagationResponse.class); + } + + /** + * 删除云智能网路由表的学习关系。 + * + * @param csnRtId 路由表的ID + * @param attachId 网络实例在云智能网中的身份ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + */ + public void deletePropagation(String csnRtId, String attachId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("deletePropagation")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnRtId", csnRtId) + .withPathParameter("attachId", attachId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 创建路由表的关联关系。 + * + * @param csnRtId 云智能网路由表的ID + * @param createAssociationRequest 创建路由表参数 + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + */ + public void createAssociation(String csnRtId, + CreateAssociationRequest createAssociationRequest, + String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("createAssociation")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnRtId", csnRtId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), createAssociationRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 查询指定云智能网路由表的关联关系。 + * + * @param csnRtId 云智能网路由表的ID + * @return ListAssociationResponse + */ + public ListAssociationResponse listAssociation(String csnRtId) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listAssociation")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnRtId", csnRtId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListAssociationResponse.class); + } + + /** + * 删除云智能网路由表的关联关系。 + * + * @param csnRtId 路由表的ID + * @param attachId 网络实例在云智能网中的身份ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串,详见ClientToken幂等性 + */ + public void deleteAssociation(String csnRtId, String attachId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("deleteAssociation")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnRtId", csnRtId) + .withPathParameter("attachId", attachId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 查询云智能网的路由表列表。 + * + * @param csnId 云智能网的ID + * @param marker 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + * @param maxKeys 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + * @return ListRouteTableResponse 云智能网的路由表列表 + */ + public ListRouteTableResponse listRouteTable(String csnId, String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listRouteTable")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId).get(); + apiInfo.getQueries().put("marker", marker); + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListRouteTableResponse.class); + } + + /* -------------------------- 带宽包相关 -------------------------- */ + + /** + * 查询云智能网带宽包列表。 + * + * @param marker 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + * @param maxKeys 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + * @return 云智能网带宽包列表 + */ + public ListCsnBpResponse listCsnBp(String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listCsnBp")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("marker", marker); + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListCsnBpResponse.class); + } + + /** + * 查询指定云智能网带宽包详情。 + * + * @param csnBpId 带宽包的ID + * @return 云智能网带宽包详情 + */ + public GetCsnBpResponse getCsnBp(String csnBpId) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("getCsnBp")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetCsnBpResponse.class); + } + + /** + * 创建云智能网共享带宽包。 + * + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + * @param createCsnBpRequest 创建云智能网带宽包参数 + * @return CreateCsnBpResponse 云智能网带宽包返回,内含带宽包的ID + */ + public CreateCsnBpResponse createCsnBp(CreateCsnBpRequest createCsnBpRequest, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("createCsnBp")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), createCsnBpRequest); + return invokeHttpClient(internalRequest, CreateCsnBpResponse.class); + } + + /** + * 更新带宽包的名称信息。 + * + * @param csnBpId 带宽包的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + * @param updateCsnBpRequest 更新带宽包传参,内含需要更改后的name + */ + public void updateCsnBp(String csnBpId, UpdateCsnBpRequest updateCsnBpRequest, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("updateCsnBp")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), updateCsnBpRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 删除带宽包。 + * + * @param csnBpId 带宽包的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + */ + public void deleteCsnBp(String csnBpId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("deleteCsnBp")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 带宽包的带宽升降级。 + * + * @param csnBpId 带宽包的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + * @param resizeCsnBpRequest 带宽包升级参数,内含升降级的带宽值 + */ + public void resizeCsnBp(String csnBpId, ResizeCsnBpRequest resizeCsnBpRequest, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("resizeCsnBp")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), resizeCsnBpRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 带宽包解绑云智能网。 + * + * @param csnBpId 带宽包的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + * @param unbindCsnBpRequest 解绑云智能网参数,内含云智能网ID + */ + public void unbindCsnBp(String csnBpId, UnbindCsnBpRequest unbindCsnBpRequest, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("unbindCsnBp")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), unbindCsnBpRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 带宽包绑定云智能网。 + * + * @param csnBpId 带宽包的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + * @param bindCsnBpRequest 绑定参数,内含云智能网ID + */ + public void bindCsnBp(String csnBpId, BindCsnBpRequest bindCsnBpRequest, String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("bindCsnBp")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), bindCsnBpRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 云智能网带宽包询价。 + * + * @param csnBpPriceRequest 云智能网带宽包询价参数 + * @return CsnBpPriceResponse 云智能网带宽包询价返回 + */ + public CsnBpPriceResponse csnBpPrice(CsnBpPriceRequest csnBpPriceRequest) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("csnBpPrice")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), csnBpPriceRequest); + return invokeHttpClient(internalRequest, CsnBpPriceResponse.class); + } + + /* -------------------------- 区域带宽相关 -------------------------- */ + + /** + * 查询带宽包的地域带宽列表。 + * + * @param csnBpId 带宽包的ID + * @return 带宽包的地域带宽列表 + */ + public ListCsnBpLimitResponse listCsnBpLimit(String csnBpId) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listCsnBpLimit")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListCsnBpLimitResponse.class); + } + + /** + * 创建带宽包中两个地域间的地域带宽。 + * + * @param csnBpId 带宽包的ID + * @param createCsnBpLimitRequest 创建地域带宽参数 + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + */ + public void createCsnBpLimit(String csnBpId, + CreateCsnBpLimitRequest createCsnBpLimitRequest, + String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("createCsnBpLimit")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), createCsnBpLimitRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 更新带宽包中两个地域间的地域带宽。 + * + * @param csnBpId 带宽包的ID + * @param updateCsnBpLimitRequest 更新地域带宽参数 + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + */ + public void updateCsnBpLimit(String csnBpId, + UpdateCsnBpLimitRequest updateCsnBpLimitRequest, + String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("updateCsnBpLimit")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), updateCsnBpLimitRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 删除带宽包中两个地域间的地域带宽。 + * + * @param csnBpId 带宽包的ID + * @param deleteCsnBpLimitRequest 删除地域带宽参数 + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + */ + public void deleteCsnBpLimit(String csnBpId, + DeleteCsnBpLimitRequest deleteCsnBpLimitRequest, + String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("deleteCsnBpLimit")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnBpId", csnBpId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), deleteCsnBpLimitRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 查询云智能网的地域带宽列表。 + * + * @param csnId 云智能网的ID + * @return 云智能网的地域带宽列表 + */ + public ListCsnBpLimitByCsnIdResponse listCsnBpLimitByCsnId(String csnId) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listCsnBpLimitByCsnId")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListCsnBpLimitByCsnIdResponse.class); + } + + /* -------------------------- TGW相关 -------------------------- */ + + /** + * 查询云智能网TGW列表。 + * + * @param csnId 云智能网的ID + * @param marker 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + * @param maxKeys 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + * @return ListTgwResponse + */ + public ListTgwResponse listTgw(String csnId, String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listTgw")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId).get(); + apiInfo.getQueries().put("marker", marker); + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListTgwResponse.class); + } + + /** + * 更新TGW的名称、描述。 + * + * @param csnId 云智能网的ID + * @param tgwId TGW实例的ID + * @param clientToken 幂等性Token,是一个长度不超过64位的ASCII字符串 + * @param updateTgwRequest + */ + public void updateTgw(String csnId, String tgwId, UpdateTgwRequest updateTgwRequest, + String clientToken) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("updateTgw")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId) + .withPathParameter("tgwId", tgwId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), updateTgwRequest); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * 查询指定TGW的路由条目。 + * + * @param csnId 云智能网的ID + * @param tgwId TGW的ID + * @param marker 批量获取列表的查询的起始位置,是一个由系统生成的字符串 + * @param maxKeys 每页包含的最大数量,最大数量不超过1000,缺省值为1000 + * @return ListTgwRuleResponse + */ + public ListTgwRuleResponse listTgwRule(String csnId, String tgwId, String marker, + Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(CSN_APIS.get("listTgwRule")); + String apiPath = apiInfo.getPath() + .withPathParameter("csnId", csnId) + .withPathParameter("tgwId", tgwId).get(); + apiInfo.getQueries().put("marker", marker); + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListTgwRuleResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/csn/api/CsnApi.java b/src/main/java/com/baidubce/services/csn/api/CsnApi.java new file mode 100644 index 00000000..051ce238 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/api/CsnApi.java @@ -0,0 +1,377 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.api; + +import java.util.HashMap; +import java.util.Map; + +import com.baidubce.common.ApiInfo; +import com.baidubce.common.ApiPath; +import com.baidubce.http.HttpMethodName; + +public class CsnApi { + /** + * Api list with api name + */ + private static Map apis = new HashMap(); + + public static Map getApis() { + + /* + ---------------------- 云智能网相关 --------------------- + */ + // 创建云智能网。 + apis.put("createCsn", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/csn"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 更新云智能网。 更新云智能网的名称和描述。 + apis.put("updateCsn", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/csn/[csnId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 删除云智能网。 已经加载了网络实例的云智能网不能直接删除,必须先卸载实例。 + apis.put("deleteCsn", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/csn/[csnId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 查询云智能网列表。 + apis.put("listCsn", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // 查询指定云智能网下加载的网络实例信息。 + apis.put("listInstance", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/[csnId]/instance"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // 查询云智能网详情。 + apis.put("getCsn", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/[csnId]"), + new HashMap(), + new HashMap())); + // 从云智能网中移出指定的网络实例。 + apis.put("detachInstance", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/csn/[csnId]"), + new HashMap() { + { + put("detach", ""); + put("clientToken", null); + } + }, + new HashMap())); + // 将网络实例加载进云智能网。 + apis.put("attachInstance", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/csn/[csnId]"), + new HashMap() { + { + put("attach", ""); + put("clientToken", null); + } + }, + new HashMap())); + + /* + ---------------------- 路由管理相关 --------------------- + */ + // 添加云智能网路由表的路由条目。 + apis.put("createRouteRule", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/csn/routeTable/[csnRtId]/rule"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 查询指定云智能网路由表的路由条目。 + apis.put("listRouteRule", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/routeTable/[csnRtId]/rule"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // 删除云智能网路由表的指定路由条目。 + apis.put("deleteRouteRule", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/csn/routeTable/[csnRtId]/rule/[csnRtRuleId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 创建路由表的学习关系。 + apis.put("createPropagation", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/csn/routeTable/[csnRtId]/propagation"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 查询指定云智能网路由表的学习关系。 + apis.put("listPropagation", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/routeTable/[csnRtId]/propagation"), + new HashMap(), + new HashMap())); + // 删除云智能网路由表的学习关系。 + apis.put("deletePropagation", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/csn/routeTable/[csnRtId]/propagation/[attachId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 创建路由表的关联关系。 + apis.put("createAssociation", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/csn/routeTable/[csnRtId]/association"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 查询指定云智能网路由表的关联关系。 + apis.put("listAssociation", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/routeTable/[csnRtId]/association"), + new HashMap(), + new HashMap())); + // 删除云智能网路由表的关联关系。 + apis.put("deleteAssociation", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/csn/routeTable/[csnRtId]/association/[attachId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 查询云智能网的路由表列表。 + apis.put("listRouteTable", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/[csnId]/routeTable"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + + /* + ---------------------- 带宽包相关 --------------------- + */ + // 查询云智能网带宽包列表。 + apis.put("listCsnBp", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/bp"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // 查询指定云智能网带宽包详情。 + apis.put("getCsnBp", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/bp/[csnBpId]"), + new HashMap(), + new HashMap())); + // 创建云智能网共享带宽包。 + apis.put("createCsnBp", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/csn/bp"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 更新带宽包的名称信息。 + apis.put("updateCsnBp", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/csn/bp/[csnBpId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 删除带宽包。 + apis.put("deleteCsnBp", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/csn/bp/[csnBpId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 带宽包的带宽升降级。 + apis.put("resizeCsnBp", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/csn/bp/[csnBpId]"), + new HashMap() { + { + put("resize", ""); + put("clientToken", null); + } + }, + new HashMap())); + // 带宽包解绑云智能网。 + apis.put("unbindCsnBp", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/csn/bp/[csnBpId]"), + new HashMap() { + { + put("unbind", ""); + put("clientToken", null); + } + }, + new HashMap())); + // 带宽包绑定云智能网。 + apis.put("bindCsnBp", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/csn/bp/[csnBpId]"), + new HashMap() { + { + put("bind", ""); + put("clientToken", null); + } + }, + new HashMap())); + // 带宽包询价。 + apis.put("csnBpPrice", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/csn/bp/price"), + new HashMap(), + new HashMap())); + + /* + ---------------------- 区域带宽相关 --------------------- + */ + // 查询带宽包的地域带宽列表。 + apis.put("listCsnBpLimit", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/bp/[csnBpId]/limit"), + new HashMap(), + new HashMap())); + // 创建带宽包中两个地域间的地域带宽。 + apis.put("createCsnBpLimit", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/csn/bp/[csnBpId]/limit"), + new HashMap(), + new HashMap())); + // 更新带宽包中两个地域间的地域带宽。 + apis.put("updateCsnBpLimit", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/csn/bp/[csnBpId]/limit"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 删除带宽包中两个地域间的地域带宽。 + apis.put("deleteCsnBpLimit", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/csn/bp/[csnBpId]/limit/delete"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // 查询云智能网的地域带宽列表。 + apis.put("listCsnBpLimitByCsnId", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/[csnId]/bp/limit"), + new HashMap(), + new HashMap())); + + /* + ---------------------- TGW相关 --------------------- + */ + // 查询云智能网TGW列表。 + apis.put("listTgw", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/[csnId]/tgw"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // 更新TGW的名称、描述。 + apis.put("updateTgw", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/csn/[csnId]/tgw/[tgwId]"), + new HashMap(), + new HashMap())); + // 查询指定TGW的路由条目。 + apis.put("listTgwRule", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/csn/[csnId]/tgw/[tgwId]/rule"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + return apis; + } +} diff --git a/src/main/java/com/baidubce/services/csn/model/AttachInstanceRequest.java b/src/main/java/com/baidubce/services/csn/model/AttachInstanceRequest.java new file mode 100644 index 00000000..9e7418f2 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/AttachInstanceRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class AttachInstanceRequest extends BaseBceRequest { + /** + * 加载的实例类型,取值 [ vpc | channel | bec_vpc ],分别表示私有网络、专线通道、边缘网络 + */ + private String instanceType; + + /** + * 加载的实例ID + */ + private String instanceId; + + /** + * 加载的实例所属的region + */ + private String instanceRegion; + + /** + * 跨账号加载网络实例场景下,网络实例所属账号的ID + */ + private String instanceAccountId; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/BindCsnBpRequest.java b/src/main/java/com/baidubce/services/csn/model/BindCsnBpRequest.java new file mode 100644 index 00000000..6d1bbf62 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/BindCsnBpRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class BindCsnBpRequest extends BaseBceRequest { + /** + * 云智能网的ID + */ + private String csnId; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/CreateAssociationRequest.java b/src/main/java/com/baidubce/services/csn/model/CreateAssociationRequest.java new file mode 100644 index 00000000..fbc4baa0 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CreateAssociationRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateAssociationRequest extends BaseBceRequest { + /** + * 网络实例在云智能网中的身份ID + */ + private String attachId; + + /** + * 描述 + */ + private String description; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/CreateCsnBpLimitRequest.java b/src/main/java/com/baidubce/services/csn/model/CreateCsnBpLimitRequest.java new file mode 100644 index 00000000..cd6fb0a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CreateCsnBpLimitRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateCsnBpLimitRequest extends BaseBceRequest { + /** + * 地域带宽的本端region,云边互通场景中表示云端region + */ + private String localRegion; + + /** + * 地域带宽的对端region,云边互通场景中表示边缘region + */ + private String peerRegion; + + /** + * 地域带宽的带宽值 + */ + private Integer bandwidth; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/CreateCsnBpRequest.java b/src/main/java/com/baidubce/services/csn/model/CreateCsnBpRequest.java new file mode 100644 index 00000000..395283a4 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CreateCsnBpRequest.java @@ -0,0 +1,106 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateCsnBpRequest extends BaseBceRequest { + /** + * 带宽包的名称,不能为空 + */ + private String name; + + /** + * 带宽包的互通类型,取值 [ center | center-edge | edge-edge ],分别表示云间互通、云边互通、边边互通,默认为云间互通 + */ + private String interworkType; + + /** + * 带宽包的带宽值,最大值为10000 + */ + private Integer bandwidth; + + /** + * 网络实例所属的区域。取值 [ China | Asia-Pacific ],分别表示中国大陆、亚太区域 + */ + private String geographicA; + + /** + * 另一个网络实例所属的区域。取值 [ China | Asia-Pacific ],分别表示中国大陆、亚太区域 + */ + private String geographicB; + + /** + * billing + */ + private Billing billing; + + + /** + * 带宽包的标签列表 + */ + private List tags; + + @Getter + @Setter + @ToString + @Builder + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Billing { + /** + * 付款方式,预支付(Prepaid)和后支付(Postpaid) + */ + private String paymentTiming; + + /** + * 付费需要传该参数。ByTraffic按量计费,ByBandwidth按带宽计费,PeakBandwidth_Percent_95 95计费,Enhanced_Percent_95增强型95计费 + */ + private String billingMethod; + + /** + * 保留信息,支付方式为后支付时不需要设置,预支付时必须设置 + */ + private Reservation reservation; + + @Getter + @Setter + @ToString + @Builder + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Reservation { + /** + * 时长,[1,2,3,4,5,6,7,8,9,12,24,36] + */ + private Integer reservationLength; + + /** + * 时间单位,当前仅支持按月,取值month + */ + private String reservationTimeUnit; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/CreateCsnBpResponse.java b/src/main/java/com/baidubce/services/csn/model/CreateCsnBpResponse.java new file mode 100644 index 00000000..8d11384c --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CreateCsnBpResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateCsnBpResponse extends BaseBceResponse { + /** + * 带宽包的ID + */ + private String csnBpId; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/CreateCsnRequest.java b/src/main/java/com/baidubce/services/csn/model/CreateCsnRequest.java new file mode 100644 index 00000000..3dca07dd --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CreateCsnRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateCsnRequest extends BaseBceRequest { + /** + * 云智能网的名称 + */ + private String name; + + /** + * 云智能网的描述 + */ + private String description; + + /** + * 云智能网的标签列表 + */ + private List tags; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + @Override + public String toString() { + return "CreateCsnRequest{" + + "name='" + name + '\'' + + ", description='" + description + '\'' + + ", tags=" + tags + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/CreateCsnResponse.java b/src/main/java/com/baidubce/services/csn/model/CreateCsnResponse.java new file mode 100644 index 00000000..91e8f3af --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CreateCsnResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateCsnResponse extends BaseBceResponse { + /** + * 云智能网的ID + */ + private String csnId; + + public void setCsnId(String csnId) { + this.csnId = csnId; + } + + public String getCsnId() { + return this.csnId; + } + + @Override + public String toString() { + return "CreateCsnResponse{" + + "csnId=" + csnId + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/CreatePropagationRequest.java b/src/main/java/com/baidubce/services/csn/model/CreatePropagationRequest.java new file mode 100644 index 00000000..d38861ad --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CreatePropagationRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreatePropagationRequest extends BaseBceRequest { + /** + * 网络实例在云智能网中的身份的ID + */ + private String attachId; + + /** + * 描述 + */ + private String description; + + public void setAttachId(String attachId) { + this.attachId = attachId; + } + + public String getAttachId() { + return this.attachId; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "CreatePropagationRequest{" + + "attachId=" + attachId + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/CreateRouteRuleRequest.java b/src/main/java/com/baidubce/services/csn/model/CreateRouteRuleRequest.java new file mode 100644 index 00000000..c83a8632 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CreateRouteRuleRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateRouteRuleRequest extends BaseBceRequest { + /** + * 网络实例在云智能网中的身份的ID + */ + private String attachId; + + /** + * 路由的目的地址,当前只支持0.0.0.0/0 + */ + private String destAddress; + + /** + * 路由类型,当前只支持custom + */ + private String routeType; + + public void setAttachId(String attachId) { + this.attachId = attachId; + } + + public String getAttachId() { + return this.attachId; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getDestAddress() { + return this.destAddress; + } + + public void setRouteType(String routeType) { + this.routeType = routeType; + } + + public String getRouteType() { + return this.routeType; + } + + @Override + public String toString() { + return "CreateRouteRuleRequest{" + + "attachId=" + attachId + "\n" + + "destAddress=" + destAddress + "\n" + + "routeType=" + routeType + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/CsnBpPriceRequest.java b/src/main/java/com/baidubce/services/csn/model/CsnBpPriceRequest.java new file mode 100644 index 00000000..3cbf519f --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CsnBpPriceRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class CsnBpPriceRequest extends BaseBceRequest{ + /** + * 带宽包的名称 + */ + private String name; + /** + * 带宽包的带宽值,后付费按流量不需要该值 + */ + private Integer bandwidth; + /** + * 网络实例所属的区域。取值 [ China | Asia-Pacific ],分别表示中国大陆、亚太区域 + */ + private String geographicA; + /** + * 另一个网络实例所属的区域。取值 [ China | Asia-Pacific ],分别表示中国大陆、亚太区域 + */ + private String geographicB; + /** + * 计费信息 + */ + private CreateCsnBpRequest.Billing billing; +} diff --git a/src/main/java/com/baidubce/services/csn/model/CsnBpPriceResponse.java b/src/main/java/com/baidubce/services/csn/model/CsnBpPriceResponse.java new file mode 100644 index 00000000..9a5028f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/CsnBpPriceResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceResponse; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class CsnBpPriceResponse extends BaseBceResponse { + /** + * 价格 1.预付费为对应带宽和购买时长所需的价格 2.后付费按流量为1G流量的价格 3.后付费日峰值带宽和95计费为对应请求中带宽的价格 + */ + private String price; +} diff --git a/src/main/java/com/baidubce/services/csn/model/DeleteCsnBpLimitRequest.java b/src/main/java/com/baidubce/services/csn/model/DeleteCsnBpLimitRequest.java new file mode 100644 index 00000000..adbbba87 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/DeleteCsnBpLimitRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeleteCsnBpLimitRequest extends BaseBceRequest { + /** + * 地域带宽的本端region + */ + private String localRegion; + + /** + * 地域带宽的对端region + */ + private String peerRegion; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/DetachInstanceRequest.java b/src/main/java/com/baidubce/services/csn/model/DetachInstanceRequest.java new file mode 100644 index 00000000..8b46ff8e --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/DetachInstanceRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class DetachInstanceRequest extends BaseBceRequest { + /** + * 加载的实例类型,取值 [ vpc | channel | bec_vpc ],分别表示私有网络、专线通道、边缘网络 + */ + private String instanceType; + + /** + * 加载的实例ID + */ + private String instanceId; + + /** + * 加载的实例所属的region + */ + private String instanceRegion; + + /** + * 跨账号加载网络实例场景下,网络实例所属账号的ID + */ + private String instanceAccountId; + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/GetCsnBpResponse.java b/src/main/java/com/baidubce/services/csn/model/GetCsnBpResponse.java new file mode 100644 index 00000000..a1c8b82f --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/GetCsnBpResponse.java @@ -0,0 +1,87 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.baidubce.services.tag.model.Tag; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class GetCsnBpResponse extends BaseBceResponse { + /** + * 带宽包的ID + */ + private String csnBpId; + + /** + * 带宽包的名称 + */ + private String name; + + /** + * 带宽包的总带宽 + */ + private String bandwidth; + + /** + * 带宽包的已分配带宽 + */ + private String usedBandwidth; + + /** + * 绑定云智能网实例 + */ + private String csnId; + + /** + * 带宽包互通类型,取值 [ center | center-edge | edge-edge ],分别表示云间互通、云边互通、边边互通 + */ + private String interworkType; + + /** + * 带宽包互通地域,取值 [ chinesemainland | asiapacific | crossregional ],分别表示中国大陆、亚太区域、跨区域互通 + */ + private String interworkRegion; + + /** + * 带宽包的状态 + */ + private String status; + + /** + * 带宽包的付费方式,取值 [ PrePaid | PostPaid ],分别表示预付费、后付费 + */ + private String paymentTiming; + + /** + * 带宽包预付费的到期时间 + */ + private String expiredTime; + + /** + * 带宽包的创建时间 + */ + private String createTime; + + /** + * 带宽包的标签列表 + */ + private List tags; +} diff --git a/src/main/java/com/baidubce/services/csn/model/GetCsnResponse.java b/src/main/java/com/baidubce/services/csn/model/GetCsnResponse.java new file mode 100644 index 00000000..75590cae --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/GetCsnResponse.java @@ -0,0 +1,63 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetCsnResponse extends BaseBceResponse { + /** + * 云智能网的名称 + */ + private String name; + + /** + * 云智能网的描述 + */ + private String description; + + /** + * 云智能网的ID + */ + private String csnId; + + /** + * 云智能网的状态 + */ + private String status; + + /** + * 云智能网加载的网络实例数量 + */ + private Integer instanceNum; + + /** + * 云智能网绑定的带宽包数量 + */ + private Integer csnBpNum; + + /** + * 云智能网的标签列表 + */ + private List tags; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ListAssociationResponse.java b/src/main/java/com/baidubce/services/csn/model/ListAssociationResponse.java new file mode 100644 index 00000000..ecdb9ddf --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListAssociationResponse.java @@ -0,0 +1,127 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListAssociationResponse extends BaseBceResponse { + /** + * 包含查询结果的列表 + */ + private List associations; + + public void setAssociations(List associations) { + this.associations = associations; + } + + public List getAssociations() { + return this.associations; + } + + @Override + public String toString() { + return "ListAssociationResponse{" + + "associations=" + associations + "\n" + + "}"; + } + + public static class CsnRtAssociation { + private String attachId; + + private String description; + + private String instanceId; + + private String instanceName; + + private String instanceRegion; + + private String instanceType; + + private String status; + + public void setAttachId(String attachId) { + this.attachId = attachId; + } + + public String getAttachId() { + return this.attachId; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceId() { + return this.instanceId; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getInstanceName() { + return this.instanceName; + } + + public void setInstanceRegion(String instanceRegion) { + this.instanceRegion = instanceRegion; + } + + public String getInstanceRegion() { + return this.instanceRegion; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public String getInstanceType() { + return this.instanceType; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + @Override + public String toString() { + return "CsnRtAssociation{" + + "attachId=" + attachId + "\n" + + "description=" + description + "\n" + + "instanceId=" + instanceId + "\n" + + "instanceName=" + instanceName + "\n" + + "instanceRegion=" + instanceRegion + "\n" + + "instanceType=" + instanceType + "\n" + + "status=" + status + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ListCsnBpLimitByCsnIdResponse.java b/src/main/java/com/baidubce/services/csn/model/ListCsnBpLimitByCsnIdResponse.java new file mode 100644 index 00000000..eadb55df --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListCsnBpLimitByCsnIdResponse.java @@ -0,0 +1,45 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class ListCsnBpLimitByCsnIdResponse extends BaseBceResponse { + /** + * 地域带宽列表 + */ + private List bpLimits; + + @Getter + @Setter + @ToString + public static class CsnBpLimit { + private String csnBpId; + + private String csnId; + + private String localRegion; + + private String peerRegion; + + private Integer bandwidth; + } +} diff --git a/src/main/java/com/baidubce/services/csn/model/ListCsnBpLimitResponse.java b/src/main/java/com/baidubce/services/csn/model/ListCsnBpLimitResponse.java new file mode 100644 index 00000000..0db7b177 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListCsnBpLimitResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListCsnBpLimitResponse extends BaseBceResponse { + /** + * 地域带宽列表 + */ + private List bpLimits; + + @Getter + @Setter + @ToString + public static class CsnBpLimit { + private String csnBpId; + + private String csnId; + + private String localRegion; + + private String peerRegion; + + private Integer bandwidth; + } +} diff --git a/src/main/java/com/baidubce/services/csn/model/ListCsnBpResponse.java b/src/main/java/com/baidubce/services/csn/model/ListCsnBpResponse.java new file mode 100644 index 00000000..7838e05c --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListCsnBpResponse.java @@ -0,0 +1,82 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.baidubce.services.tag.model.Tag; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class ListCsnBpResponse extends BaseBceResponse { + /** + * 包含查询结果的列表 + */ + private List csnBps; + + /** + * 标记查询的起始位置,若结果列表为空,此项不存在 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private Integer maxKeys; + + @Getter + @Setter + @ToString + public static class CsnBp { + private String csnBpId; + + private String name; + + private String bandwidth; + + private String usedBandwidth; + + private String csnId; + + private String interworkType; + + private String interworkRegion; + + private String status; + + private String paymentTiming; + + private String expiredTime; + + private String createTime; + + private List tags; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ListCsnResponse.java b/src/main/java/com/baidubce/services/csn/model/ListCsnResponse.java new file mode 100644 index 00000000..b4a7c1df --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListCsnResponse.java @@ -0,0 +1,185 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.math.BigDecimal; +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.baidubce.services.tag.model.Tag; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListCsnResponse extends BaseBceResponse { + /** + * 云智能网列表 + */ + private List csns; + + /** + * 标记查询的起始位置 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private BigDecimal maxKeys; + + public void setCsns(List csns) { + this.csns = csns; + } + + public List getCsns() { + return this.csns; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(BigDecimal maxKeys) { + this.maxKeys = maxKeys; + } + + public BigDecimal getMaxKeys() { + return this.maxKeys; + } + + @Override + public String toString() { + return "ListCsnResponse{" + + "csns=" + csns + "\n" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "}"; + } + + public static class Csn { + private String csnId; + + private String name; + + private String description; + + private String status; + + private BigDecimal instanceNum; + + private BigDecimal csnBpNum; + + private List tags; + + public void setCsnId(String csnId) { + this.csnId = csnId; + } + + public String getCsnId() { + return this.csnId; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + public void setInstanceNum(BigDecimal instanceNum) { + this.instanceNum = instanceNum; + } + + public BigDecimal getInstanceNum() { + return this.instanceNum; + } + + public void setCsnBpNum(BigDecimal csnBpNum) { + this.csnBpNum = csnBpNum; + } + + public BigDecimal getCsnBpNum() { + return this.csnBpNum; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + @Override + public String toString() { + return "Csn{" + + "csnId='" + csnId + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", status='" + status + '\'' + + ", instanceNum=" + instanceNum + + ", csnBpNum=" + csnBpNum + + ", tags=" + tags + + '}'; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ListInstanceResponse.java b/src/main/java/com/baidubce/services/csn/model/ListInstanceResponse.java new file mode 100644 index 00000000..491dcd6d --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListInstanceResponse.java @@ -0,0 +1,72 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListInstanceResponse extends BaseBceResponse { + /** + * 网络实例列表 + */ + private List instances; + + /** + * 标记查询的起始位置,若结果列表为空,此项不存在 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private Integer maxKeys; + + @Getter + @Setter + @ToString + public static class Instance { + private String attachId; + + private String instanceType; + + private String instanceId; + + private String instanceName; + + private String instanceRegion; + + private String instanceAccountId; + + private String status; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ListPropagationResponse.java b/src/main/java/com/baidubce/services/csn/model/ListPropagationResponse.java new file mode 100644 index 00000000..20725c84 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListPropagationResponse.java @@ -0,0 +1,127 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListPropagationResponse extends BaseBceResponse { + /** + * 包含查询结果的列表 + */ + private List propagations; + + public void setPropagations(List propagations) { + this.propagations = propagations; + } + + public List getPropagations() { + return this.propagations; + } + + @Override + public String toString() { + return "ListPropagationResponse{" + + "propagations=" + propagations + "\n" + + "}"; + } + + public static class CsnRtPropagation { + private String attachId; + + private String description; + + private String instanceId; + + private String instanceName; + + private String instanceRegion; + + private String instanceType; + + private String status; + + public void setAttachId(String attachId) { + this.attachId = attachId; + } + + public String getAttachId() { + return this.attachId; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceId() { + return this.instanceId; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getInstanceName() { + return this.instanceName; + } + + public void setInstanceRegion(String instanceRegion) { + this.instanceRegion = instanceRegion; + } + + public String getInstanceRegion() { + return this.instanceRegion; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public String getInstanceType() { + return this.instanceType; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + @Override + public String toString() { + return "CsnRtPropagation{" + + "attachId=" + attachId + "\n" + + "description=" + description + "\n" + + "instanceId=" + instanceId + "\n" + + "instanceName=" + instanceName + "\n" + + "instanceRegion=" + instanceRegion + "\n" + + "instanceType=" + instanceType + "\n" + + "status=" + status + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ListRouteRuleResponse.java b/src/main/java/com/baidubce/services/csn/model/ListRouteRuleResponse.java new file mode 100644 index 00000000..d6b87338 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListRouteRuleResponse.java @@ -0,0 +1,283 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.math.BigDecimal; +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListRouteRuleResponse extends BaseBceResponse { + /** + * 路由条目列表 + */ + private List csnRtRules; + + /** + * 标记查询的起始位置,若结果列表为空,此项不存在 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private BigDecimal maxKeys; + + public void setCsnRtRules(List csnRtRules) { + this.csnRtRules = csnRtRules; + } + + public List getCsnRtRules() { + return this.csnRtRules; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(BigDecimal maxKeys) { + this.maxKeys = maxKeys; + } + + public BigDecimal getMaxKeys() { + return this.maxKeys; + } + + @Override + public String toString() { + return "ListRouteRuleResponse{" + + "csnRtRules=" + csnRtRules + "\n" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "}"; + } + + public static class CsnRtRule { + private String ruleId; + + private String routeType; + + private String csnId; + + private String csnRtId; + + private String description; + + private String fromAttachId; + + private String status; + + private String sourceAddress; + + private String destAddress; + + private String nextHopId; + + private String nextHopName; + + private String nextHopRegion; + + private String nextHopType; + + private String asPath; + + private String community; + + private Boolean blackHole; + + public void setRuleId(String ruleId) { + this.ruleId = ruleId; + } + + public String getRuleId() { + return this.ruleId; + } + + public void setRouteType(String routeType) { + this.routeType = routeType; + } + + public String getRouteType() { + return this.routeType; + } + + public void setCsnId(String csnId) { + this.csnId = csnId; + } + + public String getCsnId() { + return this.csnId; + } + + public void setCsnRtId(String csnRtId) { + this.csnRtId = csnRtId; + } + + public String getCsnRtId() { + return this.csnRtId; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setFromAttachId(String fromAttachId) { + this.fromAttachId = fromAttachId; + } + + public String getFromAttachId() { + return this.fromAttachId; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + public void setSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + } + + public String getSourceAddress() { + return this.sourceAddress; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getDestAddress() { + return this.destAddress; + } + + public void setNextHopId(String nextHopId) { + this.nextHopId = nextHopId; + } + + public String getNextHopId() { + return this.nextHopId; + } + + public void setNextHopName(String nextHopName) { + this.nextHopName = nextHopName; + } + + public String getNextHopName() { + return this.nextHopName; + } + + public void setNextHopRegion(String nextHopRegion) { + this.nextHopRegion = nextHopRegion; + } + + public String getNextHopRegion() { + return this.nextHopRegion; + } + + public void setNextHopType(String nextHopType) { + this.nextHopType = nextHopType; + } + + public String getNextHopType() { + return this.nextHopType; + } + + public void setAsPath(String asPath) { + this.asPath = asPath; + } + + public String getAsPath() { + return this.asPath; + } + + public void setCommunity(String community) { + this.community = community; + } + + public String getCommunity() { + return this.community; + } + + public void setBlackHole(Boolean blackHole) { + this.blackHole = blackHole; + } + + public Boolean isBlackHole() { + return this.blackHole; + } + + @Override + public String toString() { + return "CsnRtRule{" + + "ruleId=" + ruleId + "\n" + + "routeType=" + routeType + "\n" + + "csnId=" + csnId + "\n" + + "csnRtId=" + csnRtId + "\n" + + "description=" + description + "\n" + + "fromAttachId=" + fromAttachId + "\n" + + "status=" + status + "\n" + + "sourceAddress=" + sourceAddress + "\n" + + "destAddress=" + destAddress + "\n" + + "nextHopId=" + nextHopId + "\n" + + "nextHopName=" + nextHopName + "\n" + + "nextHopRegion=" + nextHopRegion + "\n" + + "nextHopType=" + nextHopType + "\n" + + "asPath=" + asPath + "\n" + + "community=" + community + "\n" + + "blackHole=" + blackHole + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ListRouteTableResponse.java b/src/main/java/com/baidubce/services/csn/model/ListRouteTableResponse.java new file mode 100644 index 00000000..eff5de7e --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListRouteTableResponse.java @@ -0,0 +1,151 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.math.BigDecimal; +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListRouteTableResponse extends BaseBceResponse { + /** + * 路由表列表 + */ + private List csnRts; + + /** + * 标记查询的起始位置,若结果列表为空,此项不存在 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private BigDecimal maxKeys; + + public void setCsnRts(List csnRts) { + this.csnRts = csnRts; + } + + public List getCsnRts() { + return this.csnRts; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(BigDecimal maxKeys) { + this.maxKeys = maxKeys; + } + + public BigDecimal getMaxKeys() { + return this.maxKeys; + } + + @Override + public String toString() { + return "ListRouteTableResponse{" + + "csnRts=" + csnRts + "\n" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "}"; + } + + public static class CsnRouteTable { + private String csnRtId; + + private String name; + + private String description; + + private String type; + + public void setCsnRtId(String csnRtId) { + this.csnRtId = csnRtId; + } + + public String getCsnRtId() { + return this.csnRtId; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + @Override + public String toString() { + return "CsnRouteTable{" + + "csnRtId=" + csnRtId + "\n" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "type=" + type + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ListTgwResponse.java b/src/main/java/com/baidubce/services/csn/model/ListTgwResponse.java new file mode 100644 index 00000000..53784ebe --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListTgwResponse.java @@ -0,0 +1,161 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.math.BigDecimal; +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListTgwResponse extends BaseBceResponse { + /** + * TGW列表 + */ + private List tgws; + + /** + * 标记查询的起始位置,若结果列表为空,此项不存在 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private BigDecimal maxKeys; + + public void setTgws(List tgws) { + this.tgws = tgws; + } + + public List getTgws() { + return this.tgws; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(BigDecimal maxKeys) { + this.maxKeys = maxKeys; + } + + public BigDecimal getMaxKeys() { + return this.maxKeys; + } + + @Override + public String toString() { + return "ListTgwResponse{" + + "tgws=" + tgws + "\n" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "}"; + } + + public static class Tgw { + private String tgwId; + + private String csnId; + + private String name; + + private String region; + + private String description; + + public void setTgwId(String tgwId) { + this.tgwId = tgwId; + } + + public String getTgwId() { + return this.tgwId; + } + + public void setCsnId(String csnId) { + this.csnId = csnId; + } + + public String getCsnId() { + return this.csnId; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getRegion() { + return this.region; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "Tgw{" + + "tgwId=" + tgwId + "\n" + + "csnId=" + csnId + "\n" + + "name=" + name + "\n" + + "region=" + region + "\n" + + "description=" + description + "\n" + + "}"; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ListTgwRuleResponse.java b/src/main/java/com/baidubce/services/csn/model/ListTgwRuleResponse.java new file mode 100644 index 00000000..fa65b1a5 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ListTgwRuleResponse.java @@ -0,0 +1,260 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import java.math.BigDecimal; +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListTgwRuleResponse extends BaseBceResponse { + /** + * TGW路由条目列表 + */ + private List tgwRtRules; + + /** + * 标记查询的起始位置,若结果列表为空,此项不存在 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private BigDecimal maxKeys; + + public void setTgwRtRules(List tgwRtRules) { + this.tgwRtRules = tgwRtRules; + } + + public List getTgwRtRules() { + return this.tgwRtRules; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(BigDecimal maxKeys) { + this.maxKeys = maxKeys; + } + + public BigDecimal getMaxKeys() { + return this.maxKeys; + } + + @Override + public String toString() { + return "ListTgwRuleResponse{" + + "tgwRtRules=" + tgwRtRules + "\n" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "}"; + } + + public static class TgwRtRule { + private String ruleId; + + private String routeType; + + private String csnId; + + private String csnRtId; + + private String fromAttachId; + + private String status; + + private String destAddress; + + private String nextHopId; + + private String nextHopName; + + private String nextHopRegion; + + private String nextHopType; + + private String asPath; + + private String community; + + private Boolean blackHole; + + public void setRuleId(String ruleId) { + this.ruleId = ruleId; + } + + public String getRuleId() { + return this.ruleId; + } + + public void setRouteType(String routeType) { + this.routeType = routeType; + } + + public String getRouteType() { + return this.routeType; + } + + public void setCsnId(String csnId) { + this.csnId = csnId; + } + + public String getCsnId() { + return this.csnId; + } + + public void setCsnRtId(String csnRtId) { + this.csnRtId = csnRtId; + } + + public String getCsnRtId() { + return this.csnRtId; + } + + public void setFromAttachId(String fromAttachId) { + this.fromAttachId = fromAttachId; + } + + public String getFromAttachId() { + return this.fromAttachId; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getDestAddress() { + return this.destAddress; + } + + public void setNextHopId(String nextHopId) { + this.nextHopId = nextHopId; + } + + public String getNextHopId() { + return this.nextHopId; + } + + public void setNextHopName(String nextHopName) { + this.nextHopName = nextHopName; + } + + public String getNextHopName() { + return this.nextHopName; + } + + public void setNextHopRegion(String nextHopRegion) { + this.nextHopRegion = nextHopRegion; + } + + public String getNextHopRegion() { + return this.nextHopRegion; + } + + public void setNextHopType(String nextHopType) { + this.nextHopType = nextHopType; + } + + public String getNextHopType() { + return this.nextHopType; + } + + public void setAsPath(String asPath) { + this.asPath = asPath; + } + + public String getAsPath() { + return this.asPath; + } + + public void setCommunity(String community) { + this.community = community; + } + + public String getCommunity() { + return this.community; + } + + public void setBlackHole(Boolean blackHole) { + this.blackHole = blackHole; + } + + public Boolean isBlackHole() { + return this.blackHole; + } + + @Override + public String toString() { + return "TgwRtRule{" + + "ruleId=" + ruleId + "\n" + + "routeType=" + routeType + "\n" + + "csnId=" + csnId + "\n" + + "csnRtId=" + csnRtId + "\n" + + "fromAttachId=" + fromAttachId + "\n" + + "status=" + status + "\n" + + "destAddress=" + destAddress + "\n" + + "nextHopId=" + nextHopId + "\n" + + "nextHopName=" + nextHopName + "\n" + + "nextHopRegion=" + nextHopRegion + "\n" + + "nextHopType=" + nextHopType + "\n" + + "asPath=" + asPath + "\n" + + "community=" + community + "\n" + + "blackHole=" + blackHole + "\n" + + "}"; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/ResizeCsnBpRequest.java b/src/main/java/com/baidubce/services/csn/model/ResizeCsnBpRequest.java new file mode 100644 index 00000000..1c2b737e --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/ResizeCsnBpRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResizeCsnBpRequest extends BaseBceRequest { + /** + * 升降级的带宽值,最大值为10000 + */ + private Integer bandwidth; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/UnbindCsnBpRequest.java b/src/main/java/com/baidubce/services/csn/model/UnbindCsnBpRequest.java new file mode 100644 index 00000000..a1008989 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/UnbindCsnBpRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class UnbindCsnBpRequest extends BaseBceRequest { + /** + * 云智能网的ID + */ + private String csnId; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/UpdateCsnBpLimitRequest.java b/src/main/java/com/baidubce/services/csn/model/UpdateCsnBpLimitRequest.java new file mode 100644 index 00000000..aee17fa5 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/UpdateCsnBpLimitRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateCsnBpLimitRequest extends BaseBceRequest { + /** + * 地域带宽的本端region,该值不能改变 + */ + private String localRegion; + + /** + * 地域带宽的对端region,该值不能改变 + */ + private String peerRegion; + + /** + * 更新的地域带宽的带宽值 + */ + private Integer bandwidth; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/UpdateCsnBpRequest.java b/src/main/java/com/baidubce/services/csn/model/UpdateCsnBpRequest.java new file mode 100644 index 00000000..50735eca --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/UpdateCsnBpRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Builder +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateCsnBpRequest extends BaseBceRequest { + /** + * 带宽包名称 + */ + private String name; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/UpdateCsnRequest.java b/src/main/java/com/baidubce/services/csn/model/UpdateCsnRequest.java new file mode 100644 index 00000000..1157b44f --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/UpdateCsnRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateCsnRequest extends BaseBceRequest { + /** + * 云智能网的名称 + */ + private String name; + + /** + * 云智能网的描述 + */ + private String description; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "UpdateCsnRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/csn/model/UpdateTgwRequest.java b/src/main/java/com/baidubce/services/csn/model/UpdateTgwRequest.java new file mode 100644 index 00000000..01e384a4 --- /dev/null +++ b/src/main/java/com/baidubce/services/csn/model/UpdateTgwRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.csn.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateTgwRequest extends BaseBceRequest { + /** + * TGW的名称 + */ + private String name; + + /** + * TGW的描述信息 + */ + private String description; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "UpdateTgwRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cvca/CvcaClient.java b/src/main/java/com/baidubce/services/cvca/CvcaClient.java new file mode 100644 index 00000000..54a4c9d8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cvca/CvcaClient.java @@ -0,0 +1,129 @@ +package com.baidubce.services.cvca; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; +import java.util.List; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.cvca.model.ChatRequest; +import com.baidubce.services.cvca.model.ChatResponse; +import com.baidubce.util.DateUtils; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.baidubce.util.Validate; + +/** + * 云秘智能客服client + * + * @author wujinlin + */ +public class CvcaClient extends AbstractBceClient { + public static final int DEFAULT_SOCKET_TIMEOUT = 10 * 1000; + + private static final String ENDPOINT = "apicvca.baidubce.com"; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + private static final String VERSION = "v1"; + private static final String CHAT = "chat"; + private static final String HEADER_APP_ID = "x-cvca-app-id"; + private static final String VALIDATE_MESSAGE_APP_ID = "appId不能为空"; + private static final String VALIDATE_MESSAGE_QUERY = "query不能为空"; + + private static final String[] HEADERS_TO_SIGN = { Headers.HOST, Headers.BCE_DATE }; + + private static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; + + public CvcaClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, HANDLERS); + } + + public CvcaClient(String accessKey, String secretKey) { + this(new BceClientConfiguration() + .withSocketTimeoutInMillis(DEFAULT_SOCKET_TIMEOUT) + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)) + .withEndpoint(ENDPOINT)); + } + + public ChatResponse chat(String appId, String query, String sessionId) { + return chat(appId, query, sessionId, null); + } + + public ChatResponse chat(String appId, String query, String sessionId, String customerId) { + Validate.checkStringNotEmpty(appId, VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(query, VALIDATE_MESSAGE_QUERY); + ChatRequest request = new ChatRequest(); + request.setQuery(query); + if (!isStringEmpty(sessionId)) { + request.setSessionId(sessionId); + } + if (!isStringEmpty(customerId)) { + request.setCustomerId(customerId); + } + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, CHAT); + internalRequest.addHeader(HEADER_APP_ID, appId); + return this.invokeHttpClient(internalRequest, ChatResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.addHeader(Headers.BCE_DATE, DateUtils.formatAlternateIso8601Date(new Date())); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, request); + } + + return request; + } + + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } + + private boolean isStringEmpty(String value) { + return value == null || value.trim().isEmpty(); + } +} diff --git a/src/main/java/com/baidubce/services/cvca/model/ChatRequest.java b/src/main/java/com/baidubce/services/cvca/model/ChatRequest.java new file mode 100644 index 00000000..3cd677ae --- /dev/null +++ b/src/main/java/com/baidubce/services/cvca/model/ChatRequest.java @@ -0,0 +1,38 @@ +package com.baidubce.services.cvca.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * chat request + * + * @author wujinlin + */ +public class ChatRequest extends GenericAccountRequest { + private String query; + private String sessionId; + private String customerId; + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } +} diff --git a/src/main/java/com/baidubce/services/cvca/model/ChatResponse.java b/src/main/java/com/baidubce/services/cvca/model/ChatResponse.java new file mode 100644 index 00000000..65225c75 --- /dev/null +++ b/src/main/java/com/baidubce/services/cvca/model/ChatResponse.java @@ -0,0 +1,101 @@ +package com.baidubce.services.cvca.model; + +import java.util.List; +import java.util.Map; + +import com.baidubce.model.AbstractBceResponse; + +/** + * chat response + * + * @author wujinlin + */ +public class ChatResponse extends AbstractBceResponse { + private String answer; + private String sessionId; + private String endType; + private String answerType; + private NLU nlu; + private KB kb; + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + public String getEndType() { + return endType; + } + + public void setEndType(String endType) { + this.endType = endType; + } + + public String getAnswerType() { + return answerType; + } + + public void setAnswerType(String answerType) { + this.answerType = answerType; + } + + public NLU getNlu() { + return nlu; + } + + public void setNlu(NLU nlu) { + this.nlu = nlu; + } + + public KB getKb() { + return kb; + } + + public void setKb(KB kb) { + this.kb = kb; + } + + public static class NLU { + private String intent; + private Map entities; + + public String getIntent() { + return intent; + } + + public void setIntent(String intent) { + this.intent = intent; + } + + public Map getEntities() { + return entities; + } + + public void setEntities(Map entities) { + this.entities = entities; + } + } + + public static class KB { + private List similarQuery; + + public List getSimilarQuery() { + return similarQuery; + } + + public void setSimilarQuery(List similarQuery) { + this.similarQuery = similarQuery; + } + } +} diff --git a/src/main/java/com/baidubce/services/dcc/DccClient.java b/src/main/java/com/baidubce/services/dcc/DccClient.java new file mode 100644 index 00000000..e8bb162d --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/DccClient.java @@ -0,0 +1,386 @@ +/* + * Copyright (c) 2019-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.Reservation; +import com.baidubce.services.dcc.model.CreateDccInstanceRequest; +import com.baidubce.services.dcc.model.CreateDccInstanceResponse; +import com.baidubce.services.dcc.model.CreateDccRequest; +import com.baidubce.services.dcc.model.CreateDccResponse; +import com.baidubce.services.dcc.model.DccAction; +import com.baidubce.services.dcc.model.DccBindTagsRequest; +import com.baidubce.services.dcc.model.DccDetailRequest; +import com.baidubce.services.dcc.model.DccDetailResponse; +import com.baidubce.services.dcc.model.DccModel; +import com.baidubce.services.dcc.model.DccRenameRequest; +import com.baidubce.services.dcc.model.DccUnbindTagsRequest; +import com.baidubce.services.dcc.model.ListDccRequest; +import com.baidubce.services.dcc.model.ListDccResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; +import org.apache.commons.codec.binary.Hex; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Baidu Dedicated Cloud Compute Service(dcc). + */ +public class DccClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(DccClient.class); + + private static final String VERSION = "v1"; + private static final String DCC_PREFIX = "dedicatedHost"; + private static final String INSTANCE_PREFIX = "instance"; + private static final String TAG = "tag"; + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String FLAVOR_NULL_MESSAGE_KEY = "flavor"; + private static final String DCC_ID_MESSAGE_KEY = "dcc id"; + private static final String INSTANCEID_MESSAGE_KEY = "instanceId"; + private static final String NAME_MESSAGE_KEY = "name"; + + /** + * Responsible for handling httpResponses from all dcc service calls. + */ + private static final HttpResponseHandler[] dcc_handlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on dcc. + */ + public DccClient() { + this(new DccClientConfiguration()); + } + + /** + * Constructs a new dcc client using the client configuration to access dcc. + * + * @param clientConfiguration The dcc client configuration options controlling how this client + * connects to dcc (e.g. proxy settings, retry counts, etc). + */ + public DccClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, dcc_handlers); + } + + + /** + * Creates and initializes a new request object for the specified dcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * The encryption implement for AES-128 algorithm for BCE password encryption. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + *

+ * See more detail on + * + * BCE API doc + * + * @param content The content String to encrypt. + * @param privateKey The security key to encrypt. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + * @return The encrypted string of the original content with AES-128 algorithm. + * @throws GeneralSecurityException + */ + private String aes128WithFirst16Char(String content, String privateKey) throws GeneralSecurityException { + byte[] crypted = null; + SecretKeySpec skey = new SecretKeySpec(privateKey.substring(0, 16).getBytes(), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, skey); + crypted = cipher.doFinal(content.getBytes()); + return new String(Hex.encodeHex(crypted)); + } + + /** + * The method to generate a default Billing which is Postpaid. + * + * @return The Billing object with Postpaid PaymentTiming. + */ + private Billing generateDefaultBilling() { + Billing billing = new Billing(); + billing.setPaymentTiming("Postpaid"); + Reservation reservation = new Reservation(); + reservation.setReservationLength(1); + billing.setReservation(reservation); + return billing; + } + + /** + * The method to generate a default Billing with default Reservation which default ReservationLength is 1. + * + * @return The Billing object with default Reservation which default ReservationLength is 1 + */ + private Billing generateDefaultBillingWithReservation() { + Billing billing = new Billing(); + billing.withReservation(new Reservation().withReservationLength(1)); + return billing; + } + + /** + * Create a dcc host with specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param request CreateDccRequest + * @return CreateDccResponse + */ + public CreateDccResponse createDcc(CreateDccRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + + request.checkAutoRenewTime(); + request.checkCloudDiskType(); + checkStringNotEmpty(request.getFlavor(), checkEmptyExceptionMessageFormat(FLAVOR_NULL_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + DCC_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateDccResponse.class); + } + + /** + * Create a dcc instance with specified options. + * + * @param request CreateDccInstanceRequest + * @return CreateDccInstanceResponse + */ + public CreateDccInstanceResponse createDccInstance(CreateDccInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + DCC_PREFIX, INSTANCE_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateDccInstanceResponse.class); + } + + /** + * Create a dcc instance with specified options. + * This interface will encrypt the password + * + * @param request CreateDccInstanceRequest + * @return CreateDccInstanceResponse + */ + public CreateDccInstanceResponse createDccInstanceWithEncryption(CreateDccInstanceRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + DCC_PREFIX, INSTANCE_PREFIX); + if (!Strings.isNullOrEmpty(request.getAdminPass())) { + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setAdminPass(this.aes128WithFirst16Char(request.getAdminPass(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateDccInstanceResponse.class); + } + + /** + * Bind tags to dcc. Tags will also be bound to instances created on the dcc. + * + * @param request DccBindTagsRequest + */ + public void dccBindTags(DccBindTagsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDccId(), checkEmptyExceptionMessageFormat(DCC_ID_MESSAGE_KEY)); + if (request.getChangeTags() == null + || request.getChangeTags().size() == 0) { + throw new IllegalArgumentException("dcc bind tags: tags is empty"); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, DCC_PREFIX, + request.getDccId(), TAG); + internalRequest.addParameter(DccAction.bind.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Unbind tags from dcc. + * + * @param request DccUnbindTagsRequest + */ + public void dccUnbindTags(DccUnbindTagsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDccId(), checkEmptyExceptionMessageFormat(DCC_ID_MESSAGE_KEY)); + if (request.getChangeTags() == null + || request.getChangeTags().size() == 0) { + throw new IllegalArgumentException("dcc unbind tags: tags is empty"); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, DCC_PREFIX, + request.getDccId(), TAG); + internalRequest.addParameter(DccAction.unbind.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Renaming dcc instance. + * + * @param request + */ + public void dccRename(DccRenameRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCEID_MESSAGE_KEY)); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + DCC_PREFIX, request.getInstanceId()); + internalRequest.addParameter(DccAction.modifyAttribute.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query detail information of a dedicated host. + * + * @param request DccDetailRequest + * @return DccModel + */ + public DccModel dccDetail(DccDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getDccId(), checkEmptyExceptionMessageFormat(DCC_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + DCC_PREFIX, request.getDccId()); + DccDetailResponse response = invokeHttpClient(internalRequest, DccDetailResponse.class); + return response.getDedicatedHost(); + } + + /** + * Listing dcc hosts owned by the user. + * zoneName can be specified in the request to list dcc in the target zone. + * + * @param request ListDccRequest + * @return ListDccResponse + */ + public ListDccResponse dccList(ListDccRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, + DCC_PREFIX); + return invokeHttpClient(internalRequest, ListDccResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/dcc/DccClientConfiguration.java b/src/main/java/com/baidubce/services/dcc/DccClientConfiguration.java new file mode 100644 index 00000000..7b0fa160 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/DccClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for dcc service. + */ +public class DccClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/dcc/model/CreateDccInstanceRequest.java b/src/main/java/com/baidubce/services/dcc/model/CreateDccInstanceRequest.java new file mode 100644 index 00000000..8fbc85ac --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/CreateDccInstanceRequest.java @@ -0,0 +1,376 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.CreateCdsModel; +import com.baidubce.services.bcc.model.volume.EphemeralDisk; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request of creating dcc instance + */ +public class CreateDccInstanceRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Specified image id for creating dcc + */ + private String imageId; + + /** + * The billing information + */ + private Billing billing; + + /** + * Specified the instance type for creating dcc + */ + private String instanceType; + + /** + * Specified the virtual cpu count for dcc + */ + private int cpuCount; + + /** + * Specified the memory capacity for dcc + */ + private int memoryCapacityInGB; + + /** + * Specified the size of root disk + */ + private int rootDiskSizeInGb; + + /** + * Specified the type of root disk + */ + private String rootDiskStorageType; + + /** + * Specified the size of local disk + */ + private int localDiskSizeInGB; + + /** + * The optional parameter to specify the ephemeral disk list + * + * When creating the storage optimized instance, one ephemeral disk must be created together. + * + * When creating the gpu instance, one ephemeral disk must be created together, the optional ephemeral disk size + * see + * The optional ephemeral disk size for gpu instance + * + * When creating the fpga instance, one ephemeral disk must be created together, the optional ephemeral disk size + * see + * The optional ephemeral disk size for gpu instance + * + */ + private List ephemeralDisks; + + /** + * The optional list of volume detail info to create. + */ + private List createCdsList; + + /** + * Specified the capacity of network + */ + private int networkCapacityInMbps; + + /** + * Specified the internet charge type + */ + private String internetChargeType; + + /** + * Specified the dedicated host id + */ + private String dedicatedHostId; + + /** + * Specified the purchase count + */ + private int purchaseCount; + + /** + * Specified the name of dcc + */ + private String name; + + /** + * The optional parameter to desc the hostname of instance that will be created. + */ + private String hostname; + + /** + * Indicates whether automatic generation of ordered suffixes + */ + private boolean autoSeqSuffix; + + /** + * Specified the password of dcc + */ + private String adminPass; + + /** + * Specified the zone name + */ + private String zoneName; + + /** + * Specified the subnet id + */ + private String subnetId; + + /** + * Specified the security group id + */ + private String securityGroupId; + + /** + * Specified the gpu card type + */ + private String gpuCard; + + /** + * Specified the fgpa card type + */ + private String fpgaCard; + + /** + * Specified the card count + */ + private String cardCount; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + public int getRootDiskSizeInGb() { + return rootDiskSizeInGb; + } + + public void setRootDiskSizeInGb(int rootDiskSizeInGb) { + this.rootDiskSizeInGb = rootDiskSizeInGb; + } + + public String getRootDiskStorageType() { + return rootDiskStorageType; + } + + public void setRootDiskStorageType(String rootDiskStorageType) { + this.rootDiskStorageType = rootDiskStorageType; + } + + public int getLocalDiskSizeInGB() { + return localDiskSizeInGB; + } + + public void setLocalDiskSizeInGB(int localDiskSizeInGB) { + this.localDiskSizeInGB = localDiskSizeInGB; + } + + public List getEphemeralDisks() { + return ephemeralDisks; + } + + public void setEphemeralDisks(List ephemeralDisks) { + this.ephemeralDisks = ephemeralDisks; + } + + public List getCreateCdsList() { + return createCdsList; + } + + public void setCreateCdsList(List createCdsList) { + this.createCdsList = createCdsList; + } + + public int getNetworkCapacityInMbps() { + return networkCapacityInMbps; + } + + public void setNetworkCapacityInMbps(int networkCapacityInMbps) { + this.networkCapacityInMbps = networkCapacityInMbps; + } + + public String getInternetChargeType() { + return internetChargeType; + } + + public void setInternetChargeType(String internetChargeType) { + this.internetChargeType = internetChargeType; + } + + public String getDedicatedHostId() { + return dedicatedHostId; + } + + public void setDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + } + + public int getPurchaseCount() { + return purchaseCount; + } + + public void setPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public boolean isAutoSeqSuffix() { + return autoSeqSuffix; + } + + public void setAutoSeqSuffix(boolean autoSeqSuffix) { + this.autoSeqSuffix = autoSeqSuffix; + } + + public String getAdminPass() { + return adminPass; + } + + public void setAdminPass(String adminPass) { + this.adminPass = adminPass; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + public String getGpuCard() { + return gpuCard; + } + + public void setGpuCard(String gpuCard) { + this.gpuCard = gpuCard; + } + + public String getFpgaCard() { + return fpgaCard; + } + + public void setFpgaCard(String fpgaCard) { + this.fpgaCard = fpgaCard; + } + + public String getCardCount() { + return cardCount; + } + + public void setCardCount(String cardCount) { + this.cardCount = cardCount; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/CreateDccInstanceResponse.java b/src/main/java/com/baidubce/services/dcc/model/CreateDccInstanceResponse.java new file mode 100644 index 00000000..a5e92d4e --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/CreateDccInstanceResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response of creating dcc instance + */ +public class CreateDccInstanceResponse extends AbstractBceResponse { + /** + * The id list of instances which had been created + */ + private List instanceIds; + + public List getInstanceIds() { + return instanceIds; + } + + public void setInstanceIds(List instanceIds) { + this.instanceIds = instanceIds; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/CreateDccRequest.java b/src/main/java/com/baidubce/services/dcc/model/CreateDccRequest.java new file mode 100644 index 00000000..094fab2e --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/CreateDccRequest.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request class used for creating dcc. + */ +public class CreateDccRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Dcc supports the following two types of cloud disk. + */ + public static final String CLOUD_DISK_TYPE_HP1 = "hp1"; + public static final String CLOUD_DISK_TYPE_CLOUD_HP1 = "cloud_hp1"; + + /** + * Dcc supports the following two types of auto renew time unit. + */ + public static final String AUTO_RENEW_TIME_UNIT_MONTH = "month"; + public static final String AUTO_RENEW_TIME_UNIT_YEAR = "year"; + + /** + * dcc flavor used to create dcc. + */ + private String flavor; + + /** + * specifying the virtual cpu count of the dcc + */ + private int cpuCount; + + /** + * The number of dcc to be created. + */ + private int purchaseCount; + + /** + * The type of the dcc: calculation or storage. + */ + private String type; + + /** + * specifying which zone the dcc should be created in. + */ + private String zoneName; + + /** + * specifying auto renew time length. + */ + private int autoRenewTime; + + /** + * specifying auto renew time unit: month or year + */ + private String autoRenewTimeUnit; + + /** + * specifying the size of the system cloud disk in Gb. + */ + private int cloudDiskSize; + + /** + * specifying the type of the system cloud disk. + */ + private String cloudDiskStorageType = "hp1"; + + /** + * The detail model to specify the billing info. + */ + private Billing billing; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * check whether cloud disk storage type is correct. + */ + public void checkCloudDiskType() { + if (cloudDiskSize > 0) { + if (cloudDiskStorageType == null + || (!cloudDiskStorageType.equals(CLOUD_DISK_TYPE_HP1) + && !cloudDiskStorageType.equals(CLOUD_DISK_TYPE_CLOUD_HP1))) { + throw new IllegalArgumentException("cloud disk storage type is wrong."); + } + } + } + + /** + * check whether auto renew time unit is correct. + */ + public void checkAutoRenewTime() { + if (autoRenewTime > 0) { + if (autoRenewTimeUnit == null + || (!autoRenewTimeUnit.equals(AUTO_RENEW_TIME_UNIT_MONTH) + && !autoRenewTimeUnit.equals(AUTO_RENEW_TIME_UNIT_YEAR))) { + throw new IllegalArgumentException("auto renew time unit is wrong"); + } + } + } + + public String getFlavor() { + return flavor; + } + + public void setFlavor(String flavor) { + this.flavor = flavor; + } + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getPurchaseCount() { + return purchaseCount; + } + + public void setPurchaseCount(int purchaseCount) { + this.purchaseCount = purchaseCount; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public int getAutoRenewTime() { + return autoRenewTime; + } + + public void setAutoRenewTime(int autoRenewTime) { + this.autoRenewTime = autoRenewTime; + } + + public String getAutoRenewTimeUnit() { + return autoRenewTimeUnit; + } + + public void setAutoRenewTimeUnit(String autoRenewTimeUnit) { + this.autoRenewTimeUnit = autoRenewTimeUnit; + } + + public int getCloudDiskSize() { + return cloudDiskSize; + } + + public void setCloudDiskSize(int cloudDiskSize) { + this.cloudDiskSize = cloudDiskSize; + } + + public String getCloudDiskStorageType() { + return cloudDiskStorageType; + } + + public void setCloudDiskStorageType(String cloudDiskStorageType) { + this.cloudDiskStorageType = cloudDiskStorageType; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + @Override + public CreateDccRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/CreateDccResponse.java b/src/main/java/com/baidubce/services/dcc/model/CreateDccResponse.java new file mode 100644 index 00000000..0ae946f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/CreateDccResponse.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.Arrays; +import java.util.List; + +/** + * The response class of creating dcc. + */ +public class CreateDccResponse extends AbstractBceResponse { + + /** + * The ids of the dedicated hosts which had been created. + */ + private List hostIds; + + public List getHostIds() { + return hostIds; + } + + public void setHostIds(List hostIds) { + this.hostIds = hostIds; + } + + @Override + public String toString() { + return "CreateDccResponse{ hostIds=" + Arrays.toString(hostIds.toArray()) + "}"; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/DccAction.java b/src/main/java/com/baidubce/services/dcc/model/DccAction.java new file mode 100644 index 00000000..8c2f7f1a --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/DccAction.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +/** + * The action for operating dedicated host. + */ +public enum DccAction { + + /** + * The action for binding tags. + */ + bind, + + /** + * The action for unbinding tags. + */ + unbind, + + /** + * The action for modifying attribute. + */ + modifyAttribute +} diff --git a/src/main/java/com/baidubce/services/dcc/model/DccBindTagsRequest.java b/src/main/java/com/baidubce/services/dcc/model/DccBindTagsRequest.java new file mode 100644 index 00000000..5a64325a --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/DccBindTagsRequest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * The request class for binding tags to dcc + */ +public class DccBindTagsRequest extends AbstractBceRequest { + + /** + * Dcc id, specify which dedicated host to bind tags. + */ + @JsonIgnore + private String dccId; + + /** + * List of tags to bind. + */ + private List changeTags; + + public String getDccId() { + return dccId; + } + + public void setDccId(String dccId) { + this.dccId = dccId; + } + + public List getChangeTags() { + return changeTags; + } + + public void setChangeTags(List changeTags) { + this.changeTags = changeTags; + } + + @Override + public DccBindTagsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/DccDetailRequest.java b/src/main/java/com/baidubce/services/dcc/model/DccDetailRequest.java new file mode 100644 index 00000000..12c85c15 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/DccDetailRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request class of querying detail information of dcc. + */ +public class DccDetailRequest extends AbstractBceRequest { + + /** + * The short id of the dcc. + */ + private String dccId; + + public String getDccId() { + return dccId; + } + + public void setDccId(String dccId) { + this.dccId = dccId; + } + + public DccDetailRequest withDccId(String dccId) { + this.dccId = dccId; + return this; + } + + @Override + public String toString() { + return "DccDetailRequest{ dccId='" + dccId + "'}"; + } + + @Override + public DccDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/DccDetailResponse.java b/src/main/java/com/baidubce/services/dcc/model/DccDetailResponse.java new file mode 100644 index 00000000..c31910c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/DccDetailResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Response class of querying dcc detail information. + */ +public class DccDetailResponse extends AbstractBceResponse { + + private DccModel dedicatedHost; + + public DccModel getDedicatedHost() { + return dedicatedHost; + } + + public void setDedicatedHost(DccModel dedicatedHost) { + this.dedicatedHost = dedicatedHost; + } + + @Override + public String toString() { + return "DccDetailResponse{dedicatedHost=" + dedicatedHost + "}"; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/DccModel.java b/src/main/java/com/baidubce/services/dcc/model/DccModel.java new file mode 100644 index 00000000..7ecaeabb --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/DccModel.java @@ -0,0 +1,295 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.services.bcc.model.TagModel; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +/** + * DccModel contains information of a dedicated host. + */ +public class DccModel { + + /** + * The short id of the dcc host. + */ + private String id; + + /** + * The name of the dcc + */ + private String name; + + /** + * flavor name of the dcc + */ + private String flavorName; + + /** + * Resource usage information. + */ + private ResourceUsage resourceUsage; + + /** + * billing method of the dcc. + */ + private String paymentTiming; + + /** + * Create time of the dcc. + */ + private Date createTime; + + /** + * Expire time of the dcc. + */ + private Date expireTime; + + /** + * Description string of the dcc. + */ + private String desc; + + /** + * Zone name of the dcc. + */ + private String zoneName; + + /** + * Current status of the dcc. + */ + private String status; + + /** + * Tags bound to the dcc. + */ + private List tags; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFlavorName() { + return flavorName; + } + + public void setFlavorName(String flavorName) { + this.flavorName = flavorName; + } + + public ResourceUsage getResourceUsage() { + return resourceUsage; + } + + public void setResourceUsage(ResourceUsage resourceUsage) { + this.resourceUsage = resourceUsage; + } + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getExpireTime() { + return expireTime; + } + + public void setExpireTime(Date expireTime) { + this.expireTime = expireTime; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + @Override + public String toString() { + return "DccModel{id='" + id + + "', name='" + name + + "', flavorName='" + flavorName + + "', resourceUsage='" + resourceUsage + + "', paymentTiming='" + paymentTiming + + "', createTime=" + createTime + + ", expireTime=" + expireTime + + ", desc='" + desc + + "' zoneName='" + zoneName + + "', status='" + status + + "', tags=" + Arrays.toString(tags.toArray()) + "}"; + } + + /** + * Resource usage information of dcc host. + */ + public static class ResourceUsage { + + private int cpuCount; + private int freeCpuCount; + private int memoryCapacityInGB; + private int freeMemoryCapacityInGB; + private List ephemeralDisks; + + public int getCpuCount() { + return cpuCount; + } + + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + public int getFreeCpuCount() { + return freeCpuCount; + } + + public void setFreeCpuCount(int freeCpuCount) { + this.freeCpuCount = freeCpuCount; + } + + public int getMemoryCapacityInGB() { + return memoryCapacityInGB; + } + + public void setMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + } + + public int getFreeMemoryCapacityInGB() { + return freeMemoryCapacityInGB; + } + + public void setFreeMemoryCapacityInGB(int freeMemoryCapacityInGB) { + this.freeMemoryCapacityInGB = freeMemoryCapacityInGB; + } + + public List getEphemeralDisks() { + return ephemeralDisks; + } + + public void setEphemeralDisks(List ephemeralDisks) { + this.ephemeralDisks = ephemeralDisks; + } + + @Override + public String toString() { + return "ResourceUsage{cpuCount=" + cpuCount + + ", freeCpuCount=" + freeCpuCount + + ", memoryCapacityInGB=" + memoryCapacityInGB + + ", freeMemoryCapacityInGB=" + freeMemoryCapacityInGB + + ", ephemeralDisks=" + Arrays.toString(ephemeralDisks.toArray()) + "}"; + } + } + + /** + * ephemeral disk information. + */ + public static class EphemeralDisk { + /** + * disk size in GB. + */ + private int sizeInGB; + + /** + * free disk size in GB. + */ + private int freeSizeInGB; + + /** + * storage type of the disk. + */ + private String storageType; + + public int getSizeInGB() { + return sizeInGB; + } + + public void setSizeInGB(int sizeInGB) { + this.sizeInGB = sizeInGB; + } + + public int getFreeSizeInGB() { + return freeSizeInGB; + } + + public void setFreeSizeInGB(int freeSizeInGB) { + this.freeSizeInGB = freeSizeInGB; + } + + public String getStorageType() { + return storageType; + } + + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + @Override + public String toString() { + return "EphemeralDisk{sizeInGB=" + sizeInGB + + ", freeSizeInGB=" + freeSizeInGB + + ", storageType='" + storageType + "'}"; + } + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/DccRenameRequest.java b/src/main/java/com/baidubce/services/dcc/model/DccRenameRequest.java new file mode 100644 index 00000000..8657133a --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/DccRenameRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request class for renaming dcc instance. + */ +public class DccRenameRequest extends AbstractBceRequest { + + /** + * The short id of the dcc instance. + */ + @JsonIgnore + private String instanceId; + + /** + * The new name of the dcc instance. + */ + private String name; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DccRenameRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public DccRenameRequest withName(String name) { + this.name = name; + return this; + } + + @Override + public String toString() { + return "DccRenameRequest{name='" + name + + "', instanceId='" + instanceId + "}"; + } + + @Override + public DccRenameRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/DccUnbindTagsRequest.java b/src/main/java/com/baidubce/services/dcc/model/DccUnbindTagsRequest.java new file mode 100644 index 00000000..646134bf --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/DccUnbindTagsRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.Arrays; +import java.util.List; + +/** + * The request class for unbinding tags + */ +public class DccUnbindTagsRequest extends AbstractBceRequest { + + /** + * dcc id, specify which dcc to unbind tags. + */ + @JsonIgnore + private String dccId; + + /** + * List of tags to bind. + */ + private List changeTags; + + public String getDccId() { + return dccId; + } + + public void setDccId(String dccId) { + this.dccId = dccId; + } + + public List getChangeTags() { + return changeTags; + } + + public void setChangeTags(List changeTags) { + this.changeTags = changeTags; + } + + @Override + public String toString() { + return "DccUnbindTagsRequest{ dccId='" + dccId + + "', changeTags=" + Arrays.toString(changeTags.toArray()) + "}"; + } + + @Override + public DccUnbindTagsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/ListDccRequest.java b/src/main/java/com/baidubce/services/dcc/model/ListDccRequest.java new file mode 100644 index 00000000..0c186baa --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/ListDccRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request class used for listing dcc hosts. + */ +public class ListDccRequest extends ListRequest { + + /** + * The name of available zone. + */ + private String zoneName; + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + @Override + public ListDccRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/ListDccResponse.java b/src/main/java/com/baidubce/services/dcc/model/ListDccResponse.java new file mode 100644 index 00000000..965a1344 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/ListDccResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dcc.model; + +import com.baidubce.model.ListResponse; + +import java.util.Arrays; +import java.util.List; + +public class ListDccResponse extends ListResponse { + + private List dedicatedHosts; + + public List getDedicatedHosts() { + return dedicatedHosts; + } + + public void setDedicatedHosts(List dedicatedHosts) { + this.dedicatedHosts = dedicatedHosts; + } + + @Override + public String toString() { + return "ListDccResponse{ dedicatedHosts=" + Arrays.toString(dedicatedHosts.toArray()) + "}"; + } +} diff --git a/src/main/java/com/baidubce/services/dns/DnsClient.java b/src/main/java/com/baidubce/services/dns/DnsClient.java new file mode 100644 index 00000000..6d8191e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/DnsClient.java @@ -0,0 +1,249 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.common.ApiInfo; +import com.baidubce.common.BaseBceClient; +import com.baidubce.common.BaseBceResponse; +import com.baidubce.common.BceRegion; +import com.baidubce.internal.InternalRequest; +import com.baidubce.services.dns.api.DnsApi; +import com.baidubce.services.dns.model.AddLineGroupRequest; +import com.baidubce.services.dns.model.CreatePaidZoneRequest; +import com.baidubce.services.dns.model.CreateRecordRequest; +import com.baidubce.services.dns.model.CreateZoneRequest; +import com.baidubce.services.dns.model.ListLineGroupResponse; +import com.baidubce.services.dns.model.ListRecordResponse; +import com.baidubce.services.dns.model.ListZoneResponse; +import com.baidubce.services.dns.model.RenewZoneRequest; +import com.baidubce.services.dns.model.UpdateLineGroupRequest; +import com.baidubce.services.dns.model.UpdateRecordRequest; +import com.baidubce.services.dns.model.UpgradeZoneRequest; +import com.google.common.collect.ImmutableMap; + +import java.util.Map; + +/** + * Dns + */ +public class DnsClient extends BaseBceClient { + + private static final Map ENDPOINTS = ImmutableMap.builder() + .put(BceRegion.DEFAULT, "http://dns.baidubce.com") + .build(); + /** + * Service name for extra config and handler. + */ + private static final String SERVICE_ID = "Dns"; + + /** + * Constructs a new client to invoke service methods on demo with region. + */ + public DnsClient(String ak, String sk, BceRegion region) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(region)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public DnsClient(String ak, String sk) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(BceRegion.DEFAULT)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public DnsClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Api lists + */ + private static final Map DNS_APIS = DnsApi.getApis(); + + public void addLineGroup(AddLineGroupRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("addLineGroup")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void createPaidZone(CreatePaidZoneRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("createPaidZone")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void createRecord(String zoneName, CreateRecordRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("createRecord")); + String apiPath = apiInfo.getPath() + .withPathParameter("zoneName", zoneName).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void createZone(CreateZoneRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("createZone")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void deleteLineGroup(String lineId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("deleteLineGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("lineId", lineId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void deleteRecord(String zoneName, String recordId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("deleteRecord")); + String apiPath = apiInfo.getPath() + .withPathParameter("zoneName", zoneName) + .withPathParameter("recordId", recordId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void deleteZone(String zoneName, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("deleteZone")); + String apiPath = apiInfo.getPath() + .withPathParameter("zoneName", zoneName).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public ListLineGroupResponse listLineGroup(String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("listLineGroup")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("marker", marker); + if (maxKeys == null) { + maxKeys = 1000; + } + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListLineGroupResponse.class); + } + + public ListRecordResponse listRecord(String zoneName, String rr, String id, String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("listRecord")); + String apiPath = apiInfo.getPath() + .withPathParameter("zoneName", zoneName).get(); + apiInfo.getQueries().put("rr", rr); + apiInfo.getQueries().put("id", id); + apiInfo.getQueries().put("marker", marker); + if (maxKeys == null) { + maxKeys = 1000; + } + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListRecordResponse.class); + } + + public ListZoneResponse listZone(String name, String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("listZone")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("name", name); + apiInfo.getQueries().put("marker", marker); + if (maxKeys == null) { + maxKeys = 1000; + } + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListZoneResponse.class); + } + + public void renewZone(String name, RenewZoneRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("renewZone")); + String apiPath = apiInfo.getPath() + .withPathParameter("name", name).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void updateLineGroup(String lineId, UpdateLineGroupRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("updateLineGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("lineId", lineId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void updateRecord(String zoneName, String recordId, UpdateRecordRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("updateRecord")); + String apiPath = apiInfo.getPath() + .withPathParameter("zoneName", zoneName) + .withPathParameter("recordId", recordId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void updateRecordDisable(String zoneName, String recordId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("updateRecordDisable")); + String apiPath = apiInfo.getPath() + .withPathParameter("zoneName", zoneName) + .withPathParameter("recordId", recordId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void updateRecordEnable(String zoneName, String recordId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("updateRecordEnable")); + String apiPath = apiInfo.getPath() + .withPathParameter("zoneName", zoneName) + .withPathParameter("recordId", recordId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void upgradeZone(UpgradeZoneRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(DNS_APIS.get("upgradeZone")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/dns/api/DnsApi.java b/src/main/java/com/baidubce/services/dns/api/DnsApi.java new file mode 100644 index 00000000..8918a6e7 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/api/DnsApi.java @@ -0,0 +1,201 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.api; + +import java.util.HashMap; +import java.util.Map; + +import com.baidubce.common.ApiInfo; +import com.baidubce.common.ApiPath; +import com.baidubce.http.HttpMethodName; + +public class DnsApi { + /** + * Api list with api name + */ + public static Map apis = new HashMap(); + + public static Map getApis() { + // + apis.put("addLineGroup", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/dns/customline"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("createPaidZone", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/dns/zone/order"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("createRecord", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/dns/zone/[zoneName]/record"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("createZone", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/dns/zone"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("deleteLineGroup", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/dns/customline/[lineId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("deleteRecord", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/dns/zone/[zoneName]/record/[recordId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("deleteZone", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/dns/zone/[zoneName]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("listLineGroup", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/dns/customline"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // + apis.put("listRecord", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/dns/zone/[zoneName]/record"), + new HashMap() { + { + put("rr", null); + put("id", null); + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // + apis.put("listZone", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/dns/zone"), + new HashMap() { + { + put("name", null); + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // + apis.put("renewZone", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/dns/zone/order/[name]"), + new HashMap() { + { + put("purchaseReserved", ""); + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("updateLineGroup", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/dns/customline/[lineId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("updateRecord", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/dns/zone/[zoneName]/record/[recordId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("updateRecordDisable", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/dns/zone/[zoneName]/record/[recordId]"), + new HashMap() { + { + put("disable", ""); + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("updateRecordEnable", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/dns/zone/[zoneName]/record/[recordId]"), + new HashMap() { + { + put("enable", ""); + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("upgradeZone", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/dns/zone/order"), + new HashMap() { + { + put("upgradeToDiscount", ""); + put("clientToken", null); + } + }, + new HashMap())); + return apis; + } +} diff --git a/src/main/java/com/baidubce/services/dns/model/AddLineGroupRequest.java b/src/main/java/com/baidubce/services/dns/model/AddLineGroupRequest.java new file mode 100644 index 00000000..fe3ffc86 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/AddLineGroupRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class AddLineGroupRequest extends BaseBceRequest { + /** + * 线路组名称,长度不超过12个字符。 + */ + private String name; + + /** + * 解析线路。 + */ + private List lines; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setLines(List lines) { + this.lines = lines; + } + + public List getLines() { + return this.lines; + } + + @Override + public String toString() { + return "AddLineGroupRequest{" + + "name=" + name + "\n" + + "lines=" + lines + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/CreatePaidZoneRequest.java b/src/main/java/com/baidubce/services/dns/model/CreatePaidZoneRequest.java new file mode 100644 index 00000000..786742d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/CreatePaidZoneRequest.java @@ -0,0 +1,119 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreatePaidZoneRequest extends BaseBceRequest { + /** + * billing + */ + private Billing billing; + + /** + * 域名的名称 + */ + private List names; + + /** + * 购买的产品版本,包含:普惠版(“discount”)、企业版(“flagship”)。 + */ + private String productVersion; + + public void setBilling(Billing billing) { + this.billing = billing; + } + + public Billing getBilling() { + return this.billing; + } + + public void setNames(List names) { + this.names = names; + } + + public List getNames() { + return this.names; + } + + public void setProductVersion(String productVersion) { + this.productVersion = productVersion; + } + + public String getProductVersion() { + return this.productVersion; + } + + @Override + public String toString() { + return "CreatePaidZoneRequest{" + + "billing=" + billing + "\n" + + "names=" + names + "\n" + + "productVersion=" + productVersion + "\n" + + "}"; + } + + public static class Billing { + private String paymentTiming; + + private Reservation reservation; + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getPaymentTiming() { + return this.paymentTiming; + } + + public void setReservation(Reservation reservation) { + this.reservation = reservation; + } + + public Reservation getReservation() { + return this.reservation; + } + + @Override + public String toString() { + return "Billing{" + + "paymentTiming=" + paymentTiming + "\n" + + "reservation=" + reservation + "\n" + + "}"; + } + + public static class Reservation { + private Integer reservationLength; + + public void setReservationLength(Integer reservationLength) { + this.reservationLength = reservationLength; + } + + public Integer getReservationLength() { + return this.reservationLength; + } + + @Override + public String toString() { + return "Reservation{" + + "reservationLength=" + reservationLength + "\n" + + "}"; + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/CreateRecordRequest.java b/src/main/java/com/baidubce/services/dns/model/CreateRecordRequest.java new file mode 100644 index 00000000..17bfd663 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/CreateRecordRequest.java @@ -0,0 +1,126 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateRecordRequest extends BaseBceRequest { + /** + * 主机记录,例如“www”。记录值和zone的name长度加在一起不能超过255字符。 + */ + private String rr; + + /** + * 解析记录类型,包含:“A”, “CNAME”, “MX”, “TXT”, “NS”, “AAAA”, “SRV”。 + */ + private String type; + + /** + * 记录值,例如 IP:“192.168.1.1”,CNAME:“cname.baidu.com”,MX:“mail.baidu.com”,SRV:优先级 权重 端口 目标地址, + * 每项中间需以空格分隔。例:“0 6 8080 vipserver.test.com”。 + */ + private String value; + + /** + * 解析记录在本地DNS服务器的缓存时间(单位:秒),基础版默认300秒,普惠版默认120秒,企业版默认1秒。取值为正整数。 + */ + private Integer ttl; + + /** + * 解析线路或线路组名称,默认为default,基础版和普惠版包含:默认(default)、电信(ct)、移动(cmnet)、联通(cnc)、 + * 教育网(edu)、搜索引擎(百度)(search);企业版线路取值见LineName,企业版还可以传线路组名称。 + */ + private String line; + + /** + * 描述,长度不超过255个字符。 + */ + private String description; + + /** + * MX记录的优先级,取值范围:[0,50]。记录类型为MX记录时,此参数必选。 + */ + private Integer priority; + + public void setRr(String rr) { + this.rr = rr; + } + + public String getRr() { + return this.rr; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setValue(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public Integer getTtl() { + return this.ttl; + } + + public void setLine(String line) { + this.line = line; + } + + public String getLine() { + return this.line; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + @Override + public String toString() { + return "CreateRecordRequest{" + + "rr=" + rr + "\n" + + "type=" + type + "\n" + + "value=" + value + "\n" + + "ttl=" + ttl + "\n" + + "line=" + line + "\n" + + "description=" + description + "\n" + + "priority=" + priority + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/CreateZoneRequest.java b/src/main/java/com/baidubce/services/dns/model/CreateZoneRequest.java new file mode 100644 index 00000000..5a756e82 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/CreateZoneRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateZoneRequest extends BaseBceRequest { + /** + * 域名的名称,比如baidu.com。 + */ + private String name; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + @Override + public String toString() { + return "CreateZoneRequest{" + + "name=" + name + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/DeleteZoneRequest.java b/src/main/java/com/baidubce/services/dns/model/DeleteZoneRequest.java new file mode 100644 index 00000000..426c5241 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/DeleteZoneRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeleteZoneRequest extends BaseBceRequest { + @Override + public String toString() { + return "DeleteZoneRequest{" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/ListLineGroupRequest.java b/src/main/java/com/baidubce/services/dns/model/ListLineGroupRequest.java new file mode 100644 index 00000000..de76764b --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/ListLineGroupRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListLineGroupRequest extends BaseBceRequest { + /** + * 线路组名称,长度不超过12个字符。 + */ + private String name; + + /** + * 解析线路。 + */ + private List lines; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setLines(List lines) { + this.lines = lines; + } + + public List getLines() { + return this.lines; + } + + @Override + public String toString() { + return "ListLineGroupRequest{" + + "name=" + name + "\n" + + "lines=" + lines + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/ListLineGroupResponse.java b/src/main/java/com/baidubce/services/dns/model/ListLineGroupResponse.java new file mode 100644 index 00000000..9b498c20 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/ListLineGroupResponse.java @@ -0,0 +1,161 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListLineGroupResponse extends BaseBceResponse { + /** + * 标记查询的起始位置。 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页。 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值,当isTruncated为false时,该域不出现。 + */ + private String nextMarker; + + /** + * 每页包含的最大数量。 + */ + private Integer maxKeys; + + /** + * 包含查询结果的线路组列表。 + */ + private List lineList; + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + public void setLineList(List lineList) { + this.lineList = lineList; + } + + public List getLineList() { + return this.lineList; + } + + @Override + public String toString() { + return "ListLineGroupResponse{" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "lineList=" + lineList + "\n" + + "}"; + } + + public static class Line { + private String id; + + private String name; + + private List lines; + + private Integer relatedZoneCount; + + private Integer relatedRecordCount; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setLines(List lines) { + this.lines = lines; + } + + public List getLines() { + return this.lines; + } + + public void setRelatedZoneCount(Integer relatedZoneCount) { + this.relatedZoneCount = relatedZoneCount; + } + + public Integer getRelatedZoneCount() { + return this.relatedZoneCount; + } + + public void setRelatedRecordCount(Integer relatedRecordCount) { + this.relatedRecordCount = relatedRecordCount; + } + + public Integer getRelatedRecordCount() { + return this.relatedRecordCount; + } + + @Override + public String toString() { + return "Line{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "lines=" + lines + "\n" + + "relatedZoneCount=" + relatedZoneCount + "\n" + + "relatedRecordCount=" + relatedRecordCount + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/ListRecordRequest.java b/src/main/java/com/baidubce/services/dns/model/ListRecordRequest.java new file mode 100644 index 00000000..48f9af7f --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/ListRecordRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListRecordRequest extends BaseBceRequest { + @Override + public String toString() { + return "ListRecordRequest{" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/ListRecordResponse.java b/src/main/java/com/baidubce/services/dns/model/ListRecordResponse.java new file mode 100644 index 00000000..023bd37e --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/ListRecordResponse.java @@ -0,0 +1,205 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListRecordResponse extends BaseBceResponse { + /** + * 标记查询的起始位置。 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页。 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现。 + */ + private String nextMarker; + + /** + * 每页包含的最大数量。 + */ + private Integer maxKeys; + + /** + * 包含查询结果的解析记录列表。 + */ + private List records; + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + public void setRecords(List records) { + this.records = records; + } + + public List getRecords() { + return this.records; + } + + @Override + public String toString() { + return "ListRecordResponse{" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "records=" + records + "\n" + + "}"; + } + + public static class Record { + private String id; + + private String rr; + + private String status; + + private String type; + + private String value; + + private Integer ttl; + + private String line; + + private String description; + + private Integer priority; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setRr(String rr) { + this.rr = rr; + } + + public String getRr() { + return this.rr; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setValue(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public Integer getTtl() { + return this.ttl; + } + + public void setLine(String line) { + this.line = line; + } + + public String getLine() { + return this.line; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + @Override + public String toString() { + return "Record{" + + "id=" + id + "\n" + + "rr=" + rr + "\n" + + "status=" + status + "\n" + + "type=" + type + "\n" + + "value=" + value + "\n" + + "ttl=" + ttl + "\n" + + "line=" + line + "\n" + + "description=" + description + "\n" + + "priority=" + priority + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/ListZoneRequest.java b/src/main/java/com/baidubce/services/dns/model/ListZoneRequest.java new file mode 100644 index 00000000..a4a50159 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/ListZoneRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListZoneRequest extends BaseBceRequest { + @Override + public String toString() { + return "ListZoneRequest{" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/ListZoneResponse.java b/src/main/java/com/baidubce/services/dns/model/ListZoneResponse.java new file mode 100644 index 00000000..7b65e361 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/ListZoneResponse.java @@ -0,0 +1,213 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListZoneResponse extends BaseBceResponse { + /** + * 标记查询的起始位置 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private Integer maxKeys; + + /** + * 包含查询结果的域名列表。 + */ + private List zones; + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + public void setZones(List zones) { + this.zones = zones; + } + + public List getZones() { + return this.zones; + } + + @Override + public String toString() { + return "ListZoneResponse{" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "zones=" + zones + "\n" + + "}"; + } + + public static class Zone { + private String id; + + private String name; + + private String status; + + private String productVersion; + + private String createTime; + + private String expireTime; + + private List tags; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + public void setProductVersion(String productVersion) { + this.productVersion = productVersion; + } + + public String getProductVersion() { + return this.productVersion; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateTime() { + return this.createTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + public String getExpireTime() { + return this.expireTime; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public List getTags() { + return this.tags; + } + + @Override + public String toString() { + return "Zone{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "status=" + status + "\n" + + "productVersion=" + productVersion + "\n" + + "createTime=" + createTime + "\n" + + "expireTime=" + expireTime + "\n" + + "tags=" + tags + "\n" + + "}"; + } + + public static class TagModel { + private String tagKey; + + private String tagValue; + + public void setTagKey(String tagKey) { + this.tagKey = tagKey; + } + + public String getTagKey() { + return this.tagKey; + } + + public void setTagValue(String tagValue) { + this.tagValue = tagValue; + } + + public String getTagValue() { + return this.tagValue; + } + + @Override + public String toString() { + return "TagModel{" + + "tagKey=" + tagKey + "\n" + + "tagValue=" + tagValue + "\n" + + "}"; + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/RenewZoneRequest.java b/src/main/java/com/baidubce/services/dns/model/RenewZoneRequest.java new file mode 100644 index 00000000..5b7e737b --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/RenewZoneRequest.java @@ -0,0 +1,89 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class RenewZoneRequest extends BaseBceRequest { + /** + * billing + */ + private Billing billing; + + public void setBilling(Billing billing) { + this.billing = billing; + } + + public Billing getBilling() { + return this.billing; + } + + @Override + public String toString() { + return "RenewZoneRequest{" + + "billing=" + billing + "\n" + + "}"; + } + + public static class Billing { + private String paymentTiming; + + private Reservation reservation; + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getPaymentTiming() { + return this.paymentTiming; + } + + public void setReservation(Reservation reservation) { + this.reservation = reservation; + } + + public Reservation getReservation() { + return this.reservation; + } + + @Override + public String toString() { + return "Billing{" + + "paymentTiming=" + paymentTiming + "\n" + + "reservation=" + reservation + "\n" + + "}"; + } + + public static class Reservation { + private Integer reservationLength; + + public void setReservationLength(Integer reservationLength) { + this.reservationLength = reservationLength; + } + + public Integer getReservationLength() { + return this.reservationLength; + } + + @Override + public String toString() { + return "Reservation{" + + "reservationLength=" + reservationLength + "\n" + + "}"; + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/UpdateLineGroupRequest.java b/src/main/java/com/baidubce/services/dns/model/UpdateLineGroupRequest.java new file mode 100644 index 00000000..0c404697 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/UpdateLineGroupRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateLineGroupRequest extends BaseBceRequest { + /** + * 线路组名称,长度不超过12个字符。 + */ + private String name; + + /** + * 解析线路。 + */ + private List lines; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setLines(List lines) { + this.lines = lines; + } + + public List getLines() { + return this.lines; + } + + @Override + public String toString() { + return "UpdateLineGroupRequest{" + + "name=" + name + "\n" + + "lines=" + lines + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/UpdateRecordRequest.java b/src/main/java/com/baidubce/services/dns/model/UpdateRecordRequest.java new file mode 100644 index 00000000..a738c394 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/UpdateRecordRequest.java @@ -0,0 +1,110 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateRecordRequest extends BaseBceRequest { + /** + * 主机记录,例如“www”,记录值和zone的name长度加在一起不能超过255字符。 + */ + private String rr; + + /** + * 解析记录类型,包含:“A”, “CNAME”, “MX”, “TXT”, “NS”, “AAAA”, “SRV”。 + */ + private String type; + + /** + * 记录值,例如 IP:“192.168.1.1”,CNAME:“cname.baidu.com”,MX:“mail.baidu.com”。 + */ + private String value; + + /** + * 解析记录在本地DNS服务器的缓存时间(单位:秒),基础版默认300秒,普惠版默认120秒,企业版默认1秒,取值为正整数。 + */ + private Integer ttl; + + /** + * 描述,长度不超过255个字符。 + */ + private String description; + + /** + * MX记录的优先级,取值范围:[0,50]。记录类型为MX记录时,此参数必选。 + */ + private Integer priority; + + public void setRr(String rr) { + this.rr = rr; + } + + public String getRr() { + return this.rr; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setValue(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public Integer getTtl() { + return this.ttl; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + @Override + public String toString() { + return "UpdateRecordRequest{" + + "rr=" + rr + "\n" + + "type=" + type + "\n" + + "value=" + value + "\n" + + "ttl=" + ttl + "\n" + + "description=" + description + "\n" + + "priority=" + priority + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dns/model/UpgradeZoneRequest.java b/src/main/java/com/baidubce/services/dns/model/UpgradeZoneRequest.java new file mode 100644 index 00000000..7ed79b71 --- /dev/null +++ b/src/main/java/com/baidubce/services/dns/model/UpgradeZoneRequest.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpgradeZoneRequest extends BaseBceRequest { + /** + * 域名的名称。 + */ + private List names; + + /** + * billing + */ + private Billing billing; + + public void setNames(List names) { + this.names = names; + } + + public List getNames() { + return this.names; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + public Billing getBilling() { + return this.billing; + } + + @Override + public String toString() { + return "UpgradeZoneRequest{" + + "names=" + names + "\n" + + "billing=" + billing + "\n" + + "}"; + } + + public static class Billing { + private String paymentTiming; + + private Reservation reservation; + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getPaymentTiming() { + return this.paymentTiming; + } + + public void setReservation(Reservation reservation) { + this.reservation = reservation; + } + + public Reservation getReservation() { + return this.reservation; + } + + @Override + public String toString() { + return "Billing{" + + "paymentTiming=" + paymentTiming + "\n" + + "reservation=" + reservation + "\n" + + "}"; + } + + public static class Reservation { + private Integer reservationLength; + + public void setReservationLength(Integer reservationLength) { + this.reservationLength = reservationLength; + } + + public Integer getReservationLength() { + return this.reservationLength; + } + + @Override + public String toString() { + return "Reservation{" + + "reservationLength=" + reservationLength + "\n" + + "}"; + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/doc/DocClient.java b/src/main/java/com/baidubce/services/doc/DocClient.java old mode 100644 new mode 100755 index ae805306..397af164 --- a/src/main/java/com/baidubce/services/doc/DocClient.java +++ b/src/main/java/com/baidubce/services/doc/DocClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Baidu, Inc. + * Copyright 2019 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -56,6 +56,8 @@ import com.baidubce.services.doc.model.PublishDocumentRequest; import com.baidubce.services.doc.model.DisableReadTokenResponse; import com.baidubce.services.doc.model.DisableReadTokenRequest; +import com.baidubce.services.doc.model.GetDocumentImagesRequest; +import com.baidubce.services.doc.model.GetDocumentImagesResponse; import com.baidubce.util.HttpUtils; @@ -251,6 +253,7 @@ public CreateDocumentResponse createDocument(CreateDocumentRequest request) { regRequest.setTitle(request.getTitle()); regRequest.setNotification(request.getNotification()); regRequest.setAccess(request.getAccess()); + regRequest.setTargetType(request.getTargetType()); RegisterDocumentResponse regResponse = registerDocument(regRequest); @@ -503,6 +506,34 @@ public GetDocumentResponse getDocument(GetDocumentRequest request) { return response; } + /** + * get a Document Image list if Converted to image. + * Make Sure the Document convert type is image, otherwise will throw BceServiceException + * + * @param documentId the documentId need to get. + * + * @return A GetDocumentImageResponse object containing the information returned by Document. + */ + public GetDocumentImagesResponse getDocumentImages(String documentId) { + checkNotNull(documentId, "documentId should not be null."); + GetDocumentImagesRequest request = new GetDocumentImagesRequest(); + request.setDocumentId(documentId); + InternalRequest internalRequest = this.createRequest(HttpMethodName.GET, request, DOC, request.getDocumentId()); + internalRequest.addParameter("getImages", null); + GetDocumentImagesResponse response; + try { + response = this.invokeHttpClient(internalRequest, GetDocumentImagesResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + // ignore exception + } + } + + return response; + } + /** * list all Document. @@ -530,7 +561,7 @@ public ListDocumentsResponse listDocuments() { /** * list all Document by status. * - * + * @param status the status * @return A ListDocumentsResponse object containing the information returned by Document. */ public ListDocumentsResponse listDocuments(String status) { @@ -720,6 +751,7 @@ public ReadDocumentResponse readDocument(ReadDocumentRequest request) { InternalRequest internalRequest = this.createRequest( HttpMethodName.GET, request, DOC, request.getDocumentId()); internalRequest.addParameter("read", null); + internalRequest.addParameter("expireInSeconds", String.valueOf(request.getExpireInSeconds())); ReadDocumentResponse response; try { response = this.invokeHttpClient(internalRequest, ReadDocumentResponse.class); @@ -793,7 +825,7 @@ public ListNotificationsResponse listNotifications() { * Delete your doc notification by doc notification name. * * @param name doc notification name. - * + * @return the response */ public DeleteNotificationResponse deleteNotification(String name) { DeleteNotificationRequest request = new DeleteNotificationRequest(); @@ -805,7 +837,7 @@ public DeleteNotificationResponse deleteNotification(String name) { * Delete your doc notification by doc notification name. * * @param request The request object containing all parameters for deleting dco notification. - * + * @return the response */ public DeleteNotificationResponse deleteNotification(DeleteNotificationRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -848,7 +880,7 @@ public GetNotificationResponse getNotification(GetNotificationRequest request) { * * @param name The name of notification. * @param endpoint The address to receive notification message. - * + * @return the response */ public CreateNotificationResponse createNotification(String name, String endpoint) { CreateNotificationRequest request = new CreateNotificationRequest(); @@ -860,6 +892,7 @@ public CreateNotificationResponse createNotification(String name, String endpoin * Create a doc notification in the doc stream service. * * @param request The request object containing all options for creating doc notification. + * @return the response */ public CreateNotificationResponse createNotification(CreateNotificationRequest request) { checkNotNull(request, "The parameter request should NOT be null."); diff --git a/src/main/java/com/baidubce/services/doc/model/DocumentImage.java b/src/main/java/com/baidubce/services/doc/model/DocumentImage.java new file mode 100644 index 00000000..e1d53639 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/DocumentImage.java @@ -0,0 +1,77 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.doc.model; + +/** + * DocumentImage class used to store image result. + * + * Created by guofan on 2017/3/20. + */ +public class DocumentImage { + /** + * pageIndex indicate which page + */ + private int pageIndex = -1; + /** + * url indicate page's image url address + */ + private String url = null; + + /** + * get pageIndex + */ + public int getPageIndex() { + return pageIndex; + } + + /** + * set pageIndex + * + * @param pageIndex The document page index. + */ + public void setPageIndex(int pageIndex) { + this.pageIndex = pageIndex; + } + + /** + * get url + * + * @return the image url + */ + public String getUrl() { + return url; + } + + /** + * set url + * + * @param url set the image url + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * to string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocumentImage {\n"); + sb.append(" pageIndex: ").append(pageIndex).append("\n"); + sb.append(" url: ").append(url).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentImagesRequest.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentImagesRequest.java new file mode 100644 index 00000000..40a07899 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/GetDocumentImagesRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * GetDocumentImagesRequest class used to construct GetDocumentImage request, + * and send to API server. + * Created by guofan on 2017/3/20. + */ +public class GetDocumentImagesRequest extends AbstractBceRequest { + /** + * documentId indicate the document + */ + private String documentId = null; + + /** + * set request credentials + * + * @param credentials request credential. + */ + public GetDocumentImagesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * get documentId + * + * @return the document id + */ + public String getDocumentId() { return this.documentId; } + + /** + * set document id + * + * @param documentId the document id. + */ + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentImagesResponse.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentImagesResponse.java new file mode 100644 index 00000000..f177a832 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/GetDocumentImagesResponse.java @@ -0,0 +1,61 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + + +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * GetDocumentImagesResponse class used to receive GetDocumentImage response + * from API server. + * Created by guofan on 2017/3/20. + */ +public class GetDocumentImagesResponse extends AbstractBceResponse { + /** + * images is a list to store the document's images + */ + private List images = null; + + /** + * get document images list + * + * @return the document image list + */ + public List getImages() { + return images; + } + + /** + * set document image list + * + * @param images the document image list + */ + public void setImages(List images) { + this.images = images; + } + + /** + * to string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocuementImages {\n"); + sb.append(" images: ").append(images).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/RegisterDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/RegisterDocumentRequest.java index 6a46d18f..6c7f593e 100644 --- a/src/main/java/com/baidubce/services/doc/model/RegisterDocumentRequest.java +++ b/src/main/java/com/baidubce/services/doc/model/RegisterDocumentRequest.java @@ -1,45 +1,139 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + package com.baidubce.services.doc.model; import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; /** - * Created by baidu on 15/12/30. + * RegisterDocumentRequest class used to register document request + * send to API server. */ + public class RegisterDocumentRequest extends AbstractBceRequest { + /** + * document title + */ private String title = null; + /** + * document format + */ private String format = null; + /** + * document notification when doc status changed + */ private String notification = null; + /** + * document access + */ private String access = null; + /** + * document convert type + */ + private String targetType = null; + /** + * set request credentials + * + * @param credentials request credential. + */ public RegisterDocumentRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } + /** + * get document format + * + * @return the document format + */ public String getFormat() { return this.format; } + /** + * get document format + * + * @param format the document format + */ public void setFormat(String format) { this.format = format; } + /** + * get document notification + * + * @return the document notification + */ public String getNotification() { return this.notification; } + /** + * get document notification + * + * @param notification the document notification + */ public void setNotification(String notification) { this.notification = notification; } + /** + * get document title + * + * @return the document title + */ public String getTitle() { return this.title; } + /** + * get document title + * + * @param title the document title + */ public void setTitle(String title) { this.title = title; } + /** + * get document access + * + * @return the document access + */ public String getAccess() { return access; } + /** + * get document access + * + * @param access the document access + */ public void setAccess(String access) { this.access = access; } + + /** + * get document target type + * + * @return the document target type + */ + public String getTargetType() { + return targetType; + } + + /** + * get document target type + * + * @param targetType the document target type + */ + public void setTargetType(String targetType) { + this.targetType = targetType; + } } diff --git a/src/main/java/com/baidubce/services/dugo/AbstractDuGoRequest.java b/src/main/java/com/baidubce/services/dugo/AbstractDuGoRequest.java new file mode 100644 index 00000000..d3ff47c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/AbstractDuGoRequest.java @@ -0,0 +1,17 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo; + +/** + * DuGo abstract request + */ +public class AbstractDuGoRequest { +} diff --git a/src/main/java/com/baidubce/services/dugo/DuGoClient.java b/src/main/java/com/baidubce/services/dugo/DuGoClient.java new file mode 100644 index 00000000..c01bb1a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/DuGoClient.java @@ -0,0 +1,1724 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo; + +import static com.baidubce.util.Validate.checkIsTrue; +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkPattern; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.baidubce.util.Validate.checkValidValue; + +import com.baidubce.services.dugo.map.DeviceStatusInfoResponse; +import com.baidubce.services.dugo.map.GetDeviceInfoRequest; +import com.baidubce.services.dugo.map.QueryDeviceLogResponse; +import com.baidubce.services.dugo.project.GetBatchListResponse; +import com.baidubce.services.dugo.project.GetProjectByIdResponse; +import com.baidubce.services.dugo.project.GetProjectListResponse; +import com.baidubce.services.dugo.project.QueryInstancesByBatchResponse; +import com.baidubce.services.dugo.project.UpdateBatchDescRequest; +import com.baidubce.services.dugo.project.BatchBindVehicleRequest; +import com.baidubce.services.dugo.project.RandomBindVehiclesRequest; +import com.baidubce.services.dugo.project.BatchUnbindVehiclesRequest; +import com.baidubce.services.dugo.project.QueryMqttBindResultResponse; +import com.baidubce.services.dugo.project.DownloadAuthInfoResponse; +import com.baidubce.services.dugo.project.BatchAddDeviceRequest; +import com.baidubce.services.dugo.project.BatchRemoveDeviceRequest; +import com.baidubce.services.dugo.project.UpdateAliasNameRequest; +import com.baidubce.services.dugo.project.ActivateDeviceRequest; +import com.baidubce.services.dugo.project.QueryDeviceResponse; +import com.baidubce.services.dugo.project.DeviceShadowResponse; +import com.baidubce.services.dugo.project.GroupDeviceShadowResponse; +import com.baidubce.services.dugo.project.QueryDeviceHistoryRequest; +import com.baidubce.services.dugo.project.QueryDeviceHistoryResponse; +import com.baidubce.services.dugo.vehicle.QueryVehicleStatusRequest; +import com.baidubce.services.dugo.vehicle.QueryVehicleStatusResponse; +import com.baidubce.services.dugo.vehicle.UploadDynamicDataRequest; +import com.baidubce.services.dugo.vehicle.UploadStaticDataRequest; +import com.baidubce.services.dugo.vehicle.QuerySingleShadowRequest; +import com.baidubce.services.dugo.vehicle.QuerySingleShadowResponse; +import com.baidubce.services.dugo.vehicle.QueryMultipleShadowRequest; +import com.baidubce.services.dugo.vehicle.QueryMultipleShadowResponse; +import com.baidubce.services.dugo.vehicle.ShadowFilterRequest; +import com.baidubce.services.dugo.vehicle.ShadowFilterResponse; +import com.baidubce.services.dugo.vehicle.HistoryInfoQueryRequest; +import com.baidubce.services.dugo.vehicle.HistoryInfoQueryResponse; +import com.baidubce.services.dugo.vehicle.SchemaDisplayNameResponse; +import com.baidubce.services.dugo.vehicle.SchemaAttributeNameResponse; +import com.baidubce.services.dugo.vehicle.GB32960ParamQueryRequest; +import com.baidubce.services.dugo.vehicle.GB32960ParamQueryResponse; +import com.baidubce.services.dugo.vehicle.GB32960ParamSettingRequest; +import com.baidubce.services.dugo.vehicle.GB32960VehicleControlRequest; +import com.baidubce.services.dugo.alarm.AlarmCreateRequest; +import com.baidubce.services.dugo.alarm.AlarmUpdateRequest; +import com.baidubce.services.dugo.alarm.AlarmBatchRequest; +import com.baidubce.services.dugo.alarm.AlarmDetailsResponse; +import com.baidubce.services.dugo.alarm.AlarmRuleListResponse; +import com.baidubce.services.dugo.map.GeoCodingRequest; +import com.baidubce.services.dugo.map.GeoCodingResponse; +import com.baidubce.services.dugo.map.GeoDecodingRequest; +import com.baidubce.services.dugo.map.GeoDecodingResponse; +import com.baidubce.services.dugo.map.GetLatestPointRequest; +import com.baidubce.services.dugo.map.GetLatestPointResponse; +import com.baidubce.services.dugo.map.GetTrackRequest; +import com.baidubce.services.dugo.map.GetTrackResponse; +import com.baidubce.services.dugo.map.GetDistanceRequest; +import com.baidubce.services.dugo.map.GetDistanceResponse; +import com.baidubce.services.dugo.map.StayPointRequest; +import com.baidubce.services.dugo.map.StayPointResponse; +import com.baidubce.services.dugo.map.DrivingBehaviorRequest; +import com.baidubce.services.dugo.map.DrivingBehaviorResponse; +import com.baidubce.services.dugo.map.CreateFenceRequest; +import com.baidubce.services.dugo.map.CreateFenceResponse; +import com.baidubce.services.dugo.map.UpdateFenceRequest; +import com.baidubce.services.dugo.map.FenceDetailResponse; +import com.baidubce.services.dugo.map.FenceListResponse; +import com.baidubce.services.dugo.map.UpdateFenceAlarmRequest; +import com.baidubce.services.dugo.map.GetFenceAlarmsResponse; +import com.baidubce.services.dugo.map.FenceMonitoredVehicleRequest; +import com.baidubce.services.dugo.map.DeleteMonitoredVehicleRequest; +import com.baidubce.services.dugo.map.MonitoredVehicleListResponse; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.dugo.core.protocol.http.BceIotHttpClient; +import com.baidubce.services.dugo.video.AlarmInfoByTimeRequest; +import com.baidubce.services.dugo.video.AlarmInfoByVehicleIdListRequest; +import com.baidubce.services.dugo.video.AlarmInfoListResponse; +import com.baidubce.services.dugo.video.AlarmVideoInfoByVehicleIdListRequest; +import com.baidubce.services.dugo.video.AlarmVideoInfoByVehicleIdRequest; +import com.baidubce.services.dugo.video.AlarmVideoInfoListResponse; +import com.baidubce.services.dugo.video.FileNameRequest; +import com.baidubce.services.dugo.video.FileUploadResponse; +import com.baidubce.services.dugo.video.GetDownloadUrlResponse; +import com.baidubce.services.dugo.video.GetMediaInfoListResponse; +import com.baidubce.services.dugo.video.GetMediaInfoResponse; +import com.baidubce.services.dugo.video.GetPlayUrlResponse; +import com.baidubce.services.dugo.video.GetTaskStatusResponse; +import com.baidubce.services.dugo.video.MediaInfoByTimeRequest; +import com.baidubce.services.dugo.video.ParameterSettingRequest; +import com.baidubce.services.dugo.video.PlaybackRequest; +import com.baidubce.services.dugo.video.RealTimeRequest; +import com.baidubce.services.dugo.video.TrackAlarmMediaInfoRequest; +import com.baidubce.services.dugo.video.TrackAlarmVideoInfoResponse; +import com.baidubce.services.dugo.video.UploadTaskListRequest; +import com.baidubce.services.dugo.video.UploadTaskListResponse; +import com.baidubce.services.dugo.video.model.RealDataType; +import com.baidubce.services.dugo.video.model.RealStreamType; +import com.baidubce.services.dugo.video.model.VideoType; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import org.apache.commons.lang3.StringUtils; + +/** + * DuGo client + */ +public class DuGoClient extends AbstractBceClient { + private static final String ENDPOINT = "https://ivc.gz.baidubce.com"; + private static final String PREFIX_VERSION1 = "/v1/ivc/data"; + private static final String PREFIX_VIDEO_VERSION1 = "/v1/video"; + private static final String PREFIX_REMOTE_DIAGNOSIS_VERSION1 = "/v1/ivc/remote-diagnosis/api"; + private static final String REQUEST = "request"; + private static final String PROJECT_ID = "projectId"; + private static final String BATCH_ID = "batchId"; + private static final String VEHICLE_IDS = "vehicleIds"; + private static final String VEHICLE_ID = "vehicleId"; + private static final String VIN = "vin"; + private static final String ICCID = "iccid"; + private static final String GROUP_ID = "groupId"; + private static final String DEVICE_ID = "deviceId"; + private static final String ALARM_IDS = "alarmIds"; + private static final String ALARM_ID = "alarmId"; + private static final String FENCE_ID = "fenceId"; + private static final String PAGE_NUM = "pageNum"; + private static final String PAGE_NO = "pageNo"; + private static final String PAGE_SIZE = "pageSize"; + private static final String START_TIME = "startTime"; + private static final String END_TIME = "endTime"; + private static final String FILE_NAME = "fileName"; + + private static HttpResponseHandler[] handlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public DuGoClient(BceClientConfiguration config) { + super(StringUtils.isEmpty(config.getEndpoint()) ? config.withEndpoint(ENDPOINT) : config, handlers); + } + + private InternalRequest buildInternalRequest(String path, HttpMethodName methodName, AbstractDuGoRequest request, + Map param) { + BceIotHttpClient client = new BceIotHttpClient(); + client.withAuth(config.getCredentials().getAccessKeyId(), config.getCredentials().getSecretKey()); + URI uri = HttpUtils.appendUri(this.getEndpoint(), path); + client.withMethod(methodName, uri); + if (methodName == HttpMethodName.POST || methodName == HttpMethodName.PUT) { + client.withPayload(JsonUtils.toJsonString(request).getBytes()); + } + + if (param != null) { + for (Map.Entry entry : param.entrySet()) { + client.addParams(entry.getKey(), entry.getValue()); + } + } + return client.getInternalRequest(); + } + + private InternalRequest buildInternalRequest(String path, HttpMethodName methodName, AbstractDuGoRequest request) { + return buildInternalRequest(path, methodName, request, null); + } + + /** + * Query project list + * + * @return + */ + public GetProjectListResponse getProjects() { + InternalRequest internalRequest = buildInternalRequest(PREFIX_VERSION1 + "/project", + HttpMethodName.GET, null); + return this.invokeHttpClient(internalRequest, GetProjectListResponse.class); + } + + /** + * Query project by projectId + * + * @param projectId + * @return + */ + public GetProjectByIdResponse getProjectById(String projectId) { + isEmptyCheck(projectId, PROJECT_ID); + + InternalRequest internalRequest = buildInternalRequest(PREFIX_VERSION1 + "/project/" + projectId, + HttpMethodName.GET, null); + return this.invokeHttpClient(internalRequest, GetProjectByIdResponse.class); + } + + /** + * Query batch list by projectId + * + * @param projectId + * @return + */ + public GetBatchListResponse getBatchList(String projectId) { + isEmptyCheck(projectId, PROJECT_ID); + + InternalRequest internalRequest = buildInternalRequest(PREFIX_VERSION1 + "/project/" + projectId + "/batches", + HttpMethodName.GET, null); + return this.invokeHttpClient(internalRequest, GetBatchListResponse.class); + } + + /** + * Query instance by batchId + * + * @param batchId + * @param pageNum + * @param pageSize + * @return + */ + public QueryInstancesByBatchResponse queryInstanceByBatch(String batchId, Integer pageNum, Integer pageSize) { + isEmptyCheck(batchId, BATCH_ID); + isNullCheck(pageNum, PAGE_NUM); + isNullCheck(pageSize, PAGE_SIZE); + + Map param = new HashMap(); + param.put(BATCH_ID, batchId); + param.put(PAGE_NUM, String.valueOf(pageNum)); + param.put(PAGE_SIZE, String.valueOf(pageSize)); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/vehicle/batch", HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, QueryInstancesByBatchResponse.class); + } + + /** + * Update description for a batch + * + * @param request + * @param projectId + * @param batchId + * @return + */ + public void updateBatchDesc(UpdateBatchDescRequest request, String projectId, String batchId) { + isNullCheck(request, REQUEST); + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(batchId, BATCH_ID); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/project/" + projectId + "/batch/" + batchId, + HttpMethodName.PUT, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Bind vehicles in batch + * + * @param request + * @return + */ + public void bindVehiclesInBatch(BatchBindVehicleRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getBatchId(), BATCH_ID); + isEmptyCheck(request.getVehicleIds(), VEHICLE_IDS); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/vehicle/bind/batch", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Random bind vehicles in batch + * + * @param request + * @return + */ + public void bindVehiclesInRandom(RandomBindVehiclesRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getProjectId(), PROJECT_ID); + isEmptyCheck(request.getVehicleIds(), VEHICLE_IDS); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/vehicle/bind", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Unbind vehicles in batch + * + * @param request + */ + public void unbindVehiclesInBatch(BatchUnbindVehiclesRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getProjectId(), PROJECT_ID); + isEmptyCheck(request.getVehicleIds(), VEHICLE_IDS); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/vehicle/unbind", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query bind result for mqtt protocol vehicles + * + * @param projectId + * @return + */ + public QueryMqttBindResultResponse queryBindResult(String projectId) { + isEmptyCheck(projectId, PROJECT_ID); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/mqtt/results", HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, QueryMqttBindResultResponse.class); + } + + /** + * Download auth info for mqtt protocol vehicles + * + * @param downloadUrl + * @return + */ + public DownloadAuthInfoResponse downloadAuthInfo(String downloadUrl) { + isEmptyCheck(downloadUrl, "downloadUrl"); + + Map param = new HashMap(); + param.put("downloadUrl", downloadUrl); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/mqtt/download", HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, DownloadAuthInfoResponse.class); + } + + /** + * Batch add devices to user account + * + * @param request + */ + public void batchAddDevice(BatchAddDeviceRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getDeviceBindInfoList(), "device info"); + for (BatchAddDeviceRequest.DeviceBindInfo deviceInfo : request.getDeviceBindInfoList()) { + isEmptyCheck(deviceInfo.getPk(), "pk"); + isEmptyCheck(deviceInfo.getDn(), "dn"); + isEmptyCheck(deviceInfo.getSign(), "sign"); + } + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/device/batchbind", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Batch remove devices from user account + * + * @param request + */ + public void batchRemoveDevice(BatchRemoveDeviceRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getDeviceIds(), "deviceIds"); + for (String deviceId : request.getDeviceIds()) { + isEmptyCheck(deviceId, DEVICE_ID); + } + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/device/batchunbind", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update alias for a device + * + * @param request + */ + public void updateDeviceAlias(String deviceId, UpdateAliasNameRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(deviceId, DEVICE_ID); + isEmptyCheck(request.getAliasName(), "aliasName"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/device/" + deviceId, HttpMethodName.PUT, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Batch active devices + * + * @param request + */ + public void activateDevices(ActivateDeviceRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getDeviceIds(), "deviceIds"); + for (String deviceId : request.getDeviceIds()) { + isEmptyCheck(deviceId, DEVICE_ID); + } + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/device/activate", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query device info + * + * @param groupId + * @param deviceId + * @param aliasName + * @param pk + * @param dn + * @param pageNo + * @param pageSize + * @return + */ + public QueryDeviceResponse queryDeviceInfo(String groupId, String deviceId, String aliasName, String pk, + String dn, Integer pageNo, Integer pageSize) { + isNullCheck(pageNo, PAGE_NO); + isNullCheck(pageSize, PAGE_SIZE); + + Map params = new HashMap(); + params.put(GROUP_ID, groupId); + params.put(DEVICE_ID, deviceId); + params.put("aliasName", aliasName); + params.put("pk", pk); + params.put("dn", dn); + params.put(PAGE_NO, String.valueOf(pageNo)); + params.put(PAGE_SIZE, String.valueOf(pageSize)); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/device", HttpMethodName.GET, null, params); + return this.invokeHttpClient(internalRequest, QueryDeviceResponse.class); + } + + /** + * Query device shadow + * + * @param deviceId + * @param needUpdateTime + * @return + */ + public DeviceShadowResponse queryDeviceShadow(String deviceId, Boolean needUpdateTime) { + isEmptyCheck(deviceId, DEVICE_ID); + + Map params = new HashMap(); + params.put(DEVICE_ID, deviceId); + params.put("needUpdateTime", String.valueOf(needUpdateTime)); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/device/shadow", HttpMethodName.GET, null, params); + return this.invokeHttpClient(internalRequest, DeviceShadowResponse.class); + } + + /** + * Query shadow for a group of devices + * + * @param groupId + * @param needUpdateTime + * @param pageNo + * @param pageSize + * @return + */ + public GroupDeviceShadowResponse queryGroupDeviceShadow(String groupId, Boolean needUpdateTime, + Integer pageNo, Integer pageSize) { + isEmptyCheck(groupId, GROUP_ID); + isNullCheck(pageNo, PAGE_NO); + isNullCheck(pageSize, PAGE_SIZE); + + Map params = new HashMap(); + params.put(GROUP_ID, groupId); + params.put("needUpdateTime", String.valueOf(needUpdateTime)); + params.put(PAGE_NO, String.valueOf(pageNo)); + params.put(PAGE_SIZE, String.valueOf(pageSize)); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/device/shadow/group", HttpMethodName.GET, null, params); + return this.invokeHttpClient(internalRequest, GroupDeviceShadowResponse.class); + } + + /** + * Query device history + * + * @param request + * @return + */ + public QueryDeviceHistoryResponse queryDeviceHistory(QueryDeviceHistoryRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getDeviceId(), DEVICE_ID); + isEmptyCheck(request.getFields(), "fields"); + for (String field : request.getFields()) { + isEmptyCheck(field, "field"); + } + isNullCheck(request.getStart(), "start"); + isNullCheck(request.getEnd(), "end"); + + InternalRequest internalRequest = + buildInternalRequest("/v1/device/history", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, QueryDeviceHistoryResponse.class); + } + + /** + * Query device log + * + * @param deviceId + * @param startHour + * @param endHour + * @return + */ + public QueryDeviceLogResponse queryDeviceLog(String deviceId, String startHour, String endHour) { + isEmptyCheck(deviceId, DEVICE_ID); + isEmptyCheck(startHour, "startHour"); + isEmptyCheck(endHour, "endHour"); + Map params = new HashMap(); + params.put(DEVICE_ID, deviceId); + params.put("startHour", startHour); + params.put("endHour", endHour); + InternalRequest internalRequest = buildInternalRequest(PREFIX_REMOTE_DIAGNOSIS_VERSION1 + "/log/release", + HttpMethodName.GET, null, params); + return this.invokeHttpClient(internalRequest, QueryDeviceLogResponse.class); + } + + /** + * Query device status info + * + * @param deviceId + * @param request + * @return + */ + public DeviceStatusInfoResponse queryDeviceStatusInfo(String deviceId, GetDeviceInfoRequest request) { + isEmptyCheck(deviceId, DEVICE_ID); + isNullCheck(request.getFields(), "fields"); + Map params = new HashMap(); + params.put(DEVICE_ID, deviceId); + InternalRequest internalRequest = buildInternalRequest(PREFIX_REMOTE_DIAGNOSIS_VERSION1 + "/info/query", + HttpMethodName.POST, request, params); + return this.invokeHttpClient(internalRequest, DeviceStatusInfoResponse.class); + + } + + /** + * Upload vehicle static data + * + * @param request + * @return + */ + public void uploadStaticData(UploadStaticDataRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + isEmptyCheck(request.getData(), "data"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/static/upload", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Upload vehicle dynamic data + * + * @param request + * @return + */ + public void uploadDynamicData(UploadDynamicDataRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getPoints(), "points"); + + InternalRequest internalRequest = buildInternalRequest("/v1/data", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query vehicle online status + * + * @param request + * @return + */ + public QueryVehicleStatusResponse queryVehicleOnlineStatus(QueryVehicleStatusRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleIds(), VEHICLE_IDS); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/shadow/onlinequery", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, QueryVehicleStatusResponse.class); + } + + /** + * Query single vehicle shadow + * + * @param request + * @return + */ + public QuerySingleShadowResponse querySingleShadow(QuerySingleShadowRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/shadow/query", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, QuerySingleShadowResponse.class); + } + + /** + * Query multiple vehicle shadows + * + * @param request + * @return + */ + public QueryMultipleShadowResponse queryMultipleShadow(QueryMultipleShadowRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleIds(), VEHICLE_IDS); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/shadow/batchquery", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, QueryMultipleShadowResponse.class); + } + + /** + * Query vehicle shadow by tag + * + * @param request + * @return + */ + public ShadowFilterResponse queryShadowByTag(ShadowFilterRequest request) { + isNullCheck(request, REQUEST); + isNullCheck(request.getPageNo(), PAGE_NUM); + isNullCheck(request.getPageSize(), PAGE_SIZE); + isEmptyCheck(request.getProjectId(), PROJECT_ID); + isEmptyCheck(request.getTags(), "tags"); + isEmptyCheck(request.getFields(), "fields"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/shadow/filterquery", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, ShadowFilterResponse.class); + } + + /** + * Query vehicle history data + * + * @param request + * @return + */ + public HistoryInfoQueryResponse queryVehicleHistoryData(HistoryInfoQueryRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleIds(), VEHICLE_IDS); + isNullCheck(request.getStart(), "start"); + isNullCheck(request.getEnd(), "end"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/historyinfo/query", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, HistoryInfoQueryResponse.class); + } + + /** + * Query display name of given attribute name + * + * @param projectId + * @param attributeName + * @return + */ + public SchemaDisplayNameResponse queryDisplayName(String projectId, String attributeName) { + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(attributeName, "attributeName"); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + param.put("attributeName", attributeName); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/schema/displayName", HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, SchemaDisplayNameResponse.class); + } + + /** + * Query attribute names of given display name + * + * @param projectId + * @param displayName + * @return + */ + public SchemaAttributeNameResponse queryAttributeName(String projectId, String displayName) { + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(displayName, "displayName"); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + param.put("displayName", displayName); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/schema/attributeNames", HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, SchemaAttributeNameResponse.class); + } + + /** + * Query vehicle terminal params (GB/T 32960 protocol) + * + * @param request + * @return + */ + public GB32960ParamQueryResponse queryTerminalParams(GB32960ParamQueryRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVin(), VIN); + isEmptyCheck(request.getIccid(), ICCID); + isEmptyCheck(request.getParamIds(), "paramIds"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/32960/param/query", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, GB32960ParamQueryResponse.class); + } + + /** + * Set vehicle terminal params (GB/T 32960 protocol) + * + * @param request + */ + public void settingTerminalParams(GB32960ParamSettingRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVin(), VIN); + isEmptyCheck(request.getIccid(), ICCID); + isEmptyCheck(request.getParams(), "params"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/32960/param/setting", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Control vehicle terminal (GB/T 32960 protocol) + * + * @param request + */ + public void controlVehicleTerminal(GB32960VehicleControlRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVin(), VIN); + isEmptyCheck(request.getIccid(), ICCID); + isNullCheck(request.getCommandId(), "commandId"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/32960/vehicle/control", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create an alarm rule + * + * @param request + * @param projectId + * @return + */ + public void createAlarmRule(String projectId, AlarmCreateRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(request.getName(), "name"); + isNullCheck(request.getAlarmRule(), "alarmRule"); + isNullCheck(request.getAlarmPolicy(), "alarmPolicy"); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/alarm", HttpMethodName.POST, request, param); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update an alarm rule + * + * @param request + * @param projectId + */ + public void updateAlarmRule(String projectId, AlarmUpdateRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(request.getName(), "name"); + isNullCheck(request.getAlarmRule(), "alarmRule"); + isNullCheck(request.getAlarmPolicy(), "alarmPolicy"); + isEmptyCheck(request.getAlarmId(), ALARM_ID); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/alarm", HttpMethodName.PUT, request, param); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query details of a alarm rule + * + * @param projectId + * @param alarmId + * @return + */ + public AlarmDetailsResponse getAlarmRuleDetails(String projectId, String alarmId) { + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(alarmId, ALARM_ID); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + param.put(ALARM_ID, alarmId); + + InternalRequest internalRequest = buildInternalRequest(PREFIX_VERSION1 + "/alarm", + HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, AlarmDetailsResponse.class); + } + + /** + * Get alarm rule list + * + * @param projectId + * @param pageNum + * @param pageSize + * @return + */ + public AlarmRuleListResponse getAlarmRuleList(String projectId, Integer pageNum, Integer pageSize) { + isEmptyCheck(projectId, PROJECT_ID); + isNullCheck(pageNum, PAGE_NUM); + isNullCheck(pageSize, PAGE_SIZE); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + param.put(PAGE_NUM, String.valueOf(pageNum)); + param.put(PAGE_SIZE, String.valueOf(pageSize)); + param.put("list", ""); + + InternalRequest internalRequest = buildInternalRequest(PREFIX_VERSION1 + "/alarm", + HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, AlarmRuleListResponse.class); + } + + /** + * Batch delete alarm rules + * + * @param request + * @param projectId + */ + public void batchDeleteAlarmRules(String projectId, AlarmBatchRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(request.getAlarmIds(), ALARM_IDS); + + Map param = new HashMap(); + param.put("delete", ""); + param.put(PROJECT_ID, projectId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/alarm", HttpMethodName.POST, request, param); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Batch shield alarm rules + * + * @param request + * @param projectId + */ + public void batchShieldAlarms(AlarmBatchRequest request, String projectId) { + isNullCheck(request, REQUEST); + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(request.getAlarmIds(), ALARM_IDS); + + Map param = new HashMap(); + param.put("shield", ""); + param.put(PROJECT_ID, projectId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/alarm", HttpMethodName.POST, request, param); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Batch recover shield alarm rules + * + * @param request + * @param projectId + */ + public void batchRecoverAlarms(AlarmBatchRequest request, String projectId) { + isNullCheck(request, REQUEST); + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(request.getAlarmIds(), ALARM_IDS); + + Map param = new HashMap(); + param.put("recover", ""); + param.put(PROJECT_ID, projectId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/alarm", HttpMethodName.POST, request, param); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Geo coding (transform an address to latitude/longitude pair) + * + * @param request + * @return + */ + public GeoCodingResponse geoCoding(GeoCodingRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getAddress(), "address"); + + InternalRequest internalRequest = buildInternalRequest(PREFIX_VERSION1 + "/geocoder", + HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, GeoCodingResponse.class); + } + + /** + * Geo decode (transform a latitude/longitude pair to an address) + * + * @param request + * @return + */ + public GeoDecodingResponse geoDecoding(GeoDecodingRequest request) { + isNullCheck(request, REQUEST); + isNullCheck(request.getLatitude(), "latitude"); + isNullCheck(request.getLongitude(), "longitude"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/reversegeocoder", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, GeoDecodingResponse.class); + } + + /** + * Query the latest point of a vehicle + * + * @param request + * @return + */ + public GetLatestPointResponse getLatestPoint(GetLatestPointRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/track/getlatestpoint", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, GetLatestPointResponse.class); + } + + /** + * Query track of a vehicle + * + * @param request + * @return + */ + public GetTrackResponse getTrack(GetTrackRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/track/gettrack", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, GetTrackResponse.class); + } + + /** + * Get distance of a vehicle track + * + * @param request + * @return + */ + public GetDistanceResponse getDistance(GetDistanceRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/track/getdistance", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, GetDistanceResponse.class); + } + + /** + * Query vehicle stay points during a period + * + * @param request + * @return + */ + public StayPointResponse getStayPoint(StayPointRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/analysis/staypoint", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, StayPointResponse.class); + } + + /** + * Query driving behavior of a vehicle + * + * @param request + * @return + */ + public DrivingBehaviorResponse getDrivingBehavior(DrivingBehaviorRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/analysis/drivingbehavior", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, DrivingBehaviorResponse.class); + } + + /** + * Create a fence + * + * @param request + * @return + */ + public CreateFenceResponse createFence(CreateFenceRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getProjectId(), PROJECT_ID); + isEmptyCheck(request.getFenceName(), "fenceName"); + isEmptyCheck(request.getFenceType(), "fenceType"); + isNullCheck(request.getFenceParamsOption(), "fenceParamsOption"); + isEmptyCheck(request.getCoordType(), "coordType"); + isEmptyCheck(request.getMonitoredObjectList(), "monitoredObjectList"); + isEmptyCheck(request.getAlertType(), "alertType"); + isEmptyCheck(request.getAlertSinkList(), "alertSinkList"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence", HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, CreateFenceResponse.class); + } + + /** + * Update a fence + * + * @param request + */ + public void updateFence(UpdateFenceRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getProjectId(), PROJECT_ID); + isEmptyCheck(request.getFenceId(), FENCE_ID); + isEmptyCheck(request.getFenceName(), "fenceName"); + isNullCheck(request.getFenceParamsOption(), "fenceParamsOption"); + isEmptyCheck(request.getCoordType(), "coordType"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence", HttpMethodName.PUT, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Get details of a fence + * + * @param projectId + * @param fenceId + * @return + */ + public FenceDetailResponse getFenceDetail(String projectId, String fenceId) { + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(fenceId, FENCE_ID); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence/" + fenceId, HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, FenceDetailResponse.class); + } + + /** + * Delete a fence + * + * @param projectId + * @param fenceId + */ + public void deleteFence(String projectId, String fenceId) { + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(fenceId, FENCE_ID); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence/" + fenceId, HttpMethodName.DELETE, null, param); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Get fence list in a project + * + * @param projectId + * @param fenceName + * @param vehicleId + * @param pageNum + * @param pageSize + * @return + */ + public FenceListResponse getFenceList(String projectId, String fenceName, String vehicleId, + Integer pageNum, Integer pageSize) { + isEmptyCheck(projectId, PROJECT_ID); + isNullCheck(pageNum, PAGE_NUM); + isNullCheck(pageSize, PAGE_SIZE); + checkIsTrue(pageSize <= 1000, "分页参数不得超过1000"); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + param.put("fenceName", fenceName); + param.put(VEHICLE_ID, vehicleId); + param.put(PAGE_NUM, String.valueOf(pageNum)); + param.put(PAGE_SIZE, String.valueOf(pageSize)); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence", HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, FenceListResponse.class); + } + + /** + * Update alarm config for a fence + * + * @param request + */ + public void updateFenceAlarmConfig(UpdateFenceAlarmRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getProjectId(), PROJECT_ID); + isEmptyCheck(request.getFenceId(), FENCE_ID); + isEmptyCheck(request.getAlertType(), "alertType"); + isEmptyCheck(request.getAlertSinkList(), "alertSinkList"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence/alert", HttpMethodName.PUT, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query alarm list in a fence + * + * @param projectId + * @param fenceId + * @param pageNum + * @param pageSize + * @param startTime + * @param endTime + * @param vehicleId + * @return + */ + public GetFenceAlarmsResponse getFenceAlarms(String projectId, String fenceId, Integer pageNum, Integer pageSize, + String startTime, String endTime, String vehicleId) { + isEmptyCheck(projectId, PROJECT_ID); + isNullCheck(pageNum, PAGE_NUM); + isNullCheck(pageSize, PAGE_SIZE); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + param.put(PAGE_NUM, String.valueOf(pageNum)); + param.put(PAGE_SIZE, String.valueOf(pageSize)); + param.put(START_TIME, startTime); + param.put(END_TIME, endTime); + param.put(VEHICLE_ID, vehicleId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence/" + fenceId + "/alarm", HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, GetFenceAlarmsResponse.class); + } + + /** + * Add monitored vehicles to a given fence + * + * @param fenceId + * @param request + */ + public void addMonitoredVehiclesToFence(String fenceId, FenceMonitoredVehicleRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(fenceId, FENCE_ID); + isEmptyCheck(request.getProjectId(), PROJECT_ID); + isEmptyCheck(request.getVehicleDigestList(), "vehicleDigestList"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence/" + fenceId + "/vehicle", HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update monitored vehicles in a given fence + * + * @param fenceId + * @param request + */ + public void updateMonitoredVehiclesForFence(String fenceId, FenceMonitoredVehicleRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(fenceId, FENCE_ID); + isEmptyCheck(request.getProjectId(), PROJECT_ID); + isEmptyCheck(request.getVehicleDigestList(), "vehicleDigestList"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence/" + fenceId + "/vehicle", HttpMethodName.PUT, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Remove monitored vehicles from a given fence + * + * @param fenceId + * @param request + */ + public void removeVehiclesFromFence(String fenceId, DeleteMonitoredVehicleRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(fenceId, FENCE_ID); + isEmptyCheck(request.getProjectId(), PROJECT_ID); + isEmptyCheck(request.getVehicleIdList(), "vehicleIdList"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence/" + fenceId + "/vehicle/delete", + HttpMethodName.POST, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Query monitored vehicles in a given fence + * + * @param projectId + * @param fenceId + * @param pageNum + * @param pageSize + * @param vehicleId + * @return + */ + public MonitoredVehicleListResponse getVehiclesInFence(String projectId, String fenceId, + Integer pageNum, Integer pageSize, String vehicleId) { + isEmptyCheck(projectId, PROJECT_ID); + isEmptyCheck(fenceId, FENCE_ID); + isNullCheck(pageNum, PAGE_NUM); + isNullCheck(pageSize, PAGE_SIZE); + + Map param = new HashMap(); + param.put(PROJECT_ID, projectId); + param.put(PAGE_NUM, String.valueOf(pageNum)); + param.put(PAGE_SIZE, String.valueOf(pageSize)); + param.put(VEHICLE_ID, vehicleId); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VERSION1 + "/fence/" + fenceId + "/vehicle", + HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, MonitoredVehicleListResponse.class); + } + + /** + * start real-time play + * + * @param vehicleId + * @param channel + * @param request + * @return + */ + public GetPlayUrlResponse realTimePlay(String vehicleId, Integer channel, RealTimeRequest request) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isNullCheck(channel, "channel"); + isNullCheck(request, REQUEST); + isEnumValue(request.getDataType(), "dataType", RealDataType.class); + isEnumValue(request.getStreamType(), "streamType", RealStreamType.class); + isEnumValue(request.getVideoType(), "videoType", VideoType.class); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/real-time/" + vehicleId + "/" + channel, + HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, GetPlayUrlResponse.class); + } + + /** + * end real-time play + * + * @param vehicleId + * @param channel + */ + public void endRealTimePlay(String vehicleId, Integer channel) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isNullCheck(channel, "channel"); + + Map param = new HashMap(); + param.put("close", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/real-time/" + vehicleId + "/" + channel, + HttpMethodName.PUT, null, param); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * start history playback + * + * @param vehicleId + * @param request + * @return + */ + public GetPlayUrlResponse historyPlayback(String vehicleId, PlaybackRequest request) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isNullCheck(request, REQUEST); + isEmptyCheck(request.getFileName(), "fileName"); + isEnumValue(request.getVideoType(), "videoType", VideoType.class); + + Map param = new HashMap(); + param.put("open", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/playback/" + vehicleId, + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, GetPlayUrlResponse.class); + } + + /** + * end history playback + * + * @param vehicleId + * @param fileName + */ + public void endHistoryPlayback(String vehicleId, String fileName) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isEmptyCheck(fileName, FILE_NAME); + + Map param = new HashMap(); + param.put(FILE_NAME, fileName); + param.put("close", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/playback/" + vehicleId, + HttpMethodName.PUT, null, param); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * upload video by name + * + * @param vehicleId + * @param request + * @return + */ + public FileUploadResponse videoUploadByName(String vehicleId, FileNameRequest request) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isNullCheck(request, REQUEST); + isEmptyCheck(request.getFileName(), "fileName"); + + Map param = new HashMap(); + param.put("name", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/upload/" + vehicleId, + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, FileUploadResponse.class); + } + + /** + * cancel upload task + * + * @param taskUuid + */ + public void videoUploadCancel(String taskUuid) { + isEmptyCheck(taskUuid, "taskUuid"); + + Map param = new HashMap(); + param.put("cancel", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/upload/tasks/" + taskUuid, + HttpMethodName.PUT, null, param); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * get status of upload task + * + * @param taskUuid + * @return + */ + public GetTaskStatusResponse getTaskStatus(String taskUuid) { + isEmptyCheck(taskUuid, "taskUuid"); + + Map param = new HashMap(); + param.put("status", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/playback/tasks/" + taskUuid, + HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, GetTaskStatusResponse.class); + } + + /** + * get upload task list + * + * @param pageNum + * @param pageSize + * @param request + * @return + */ + public UploadTaskListResponse getUploadTaskList(Integer pageNum, Integer pageSize, UploadTaskListRequest request) { + isNullCheck(pageNum, PAGE_NUM); + isNullCheck(pageSize, PAGE_SIZE); + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + Map param = new HashMap(); + param.put(PAGE_NUM, String.valueOf(pageNum)); + param.put(PAGE_SIZE, String.valueOf(pageSize)); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/upload/tasks", + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, UploadTaskListResponse.class); + } + + /** + * get play url by upload task + * + * @param taskUuid + * @return + */ + public GetPlayUrlResponse getPlayUrlByTask(String taskUuid) { + isEmptyCheck(taskUuid, "taskUuid"); + + Map param = new HashMap(); + param.put("url", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/playback/tasks/" + taskUuid, + HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, GetPlayUrlResponse.class); + } + + /** + * get play url by video name + * + * @param vehicleId + * @param request + * @return + */ + public GetPlayUrlResponse getPlayUrlByName(String vehicleId, FileNameRequest request) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isNullCheck(request, REQUEST); + isEmptyCheck(request.getFileName(), "fileName"); + + Map param = new HashMap(); + param.put("name", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/playback/" + vehicleId, + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, GetPlayUrlResponse.class); + } + + /** + * get video download url + * + * @param vehicleId + * @param request + * @return + */ + public GetDownloadUrlResponse getVideoDownloadUrl(String vehicleId, FileNameRequest request) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isNullCheck(request, REQUEST); + isEmptyCheck(request.getFileName(), "fileName"); + + Map param = new HashMap(); + param.put("video", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/download/" + vehicleId, + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, GetDownloadUrlResponse.class); + } + + /** + * get image download url + * + * @param vehicleId + * @param request + * @return + */ + public GetDownloadUrlResponse getImageDownloadUrl(String vehicleId, FileNameRequest request) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isNullCheck(request, REQUEST); + isEmptyCheck(request.getFileName(), "fileName"); + + Map param = new HashMap(); + param.put("image", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/download/" + vehicleId, + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, GetDownloadUrlResponse.class); + } + + /** + * set param of principle + * + * @param vehicleId + * @param request + */ + public void setParam(String vehicleId, ParameterSettingRequest request) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isNullCheck(request, REQUEST); + isMatchPattern(request.getParamHex(), "paramHex", "^[A-Fa-f0-9]{1,210}$"); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/param-setting/" + vehicleId, + HttpMethodName.PUT, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * get media list by time + * + * @param vehicleId + * @param request + * @return + */ + public GetMediaInfoListResponse getVideoInfoByTime(String vehicleId, MediaInfoByTimeRequest request) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isNullCheck(request, REQUEST); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/media/" + vehicleId, + HttpMethodName.POST, request); + return this.invokeHttpClient(internalRequest, GetMediaInfoListResponse.class); + } + + /** + * get media by file name + * + * @param vehicleId + * @param fileName + * @return + */ + public GetMediaInfoResponse getMediaInfoByFileName(String vehicleId, String fileName) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isEmptyCheck(fileName, "fileName"); + + Map param = new HashMap(); + param.put("fileName", fileName); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/media/" + vehicleId + "/filename", + HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, GetMediaInfoResponse.class); + } + + /** + * get media list by alarm + * + * @param alarmUuid + * @return + */ + public GetMediaInfoListResponse getMediaInfoByAlarmUuid(String alarmUuid) { + isEmptyCheck(alarmUuid, "alarmUuid"); + + Map param = new HashMap(); + param.put("alarmUuid", alarmUuid); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/media/alarm-uuid", + HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, GetMediaInfoListResponse.class); + } + + /** + * get media list by alarmRefKey + * + * @param vehicleId + * @param alarmRefKey + * @return + */ + public GetMediaInfoListResponse getMediaInfoByAlarmRefKey(String vehicleId, String alarmRefKey) { + isEmptyCheck(vehicleId, VEHICLE_ID); + isEmptyCheck(alarmRefKey, "alarmRefKey"); + + Map param = new HashMap(); + param.put("alarmRefKey", alarmRefKey); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/media/" + vehicleId + "/alarm-ref-key", + HttpMethodName.GET, null, param); + return this.invokeHttpClient(internalRequest, GetMediaInfoListResponse.class); + } + + /** + * get alarm list by vehicle list + * + * @param request + * @return + */ + public AlarmInfoListResponse getAlarmInfoByVehicleIdList(AlarmInfoByVehicleIdListRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleIdList(), "vehicleIdList"); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + Map param = new HashMap(); + param.put("id", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/alarm", + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, AlarmInfoListResponse.class); + } + + /** + * get alarm list by time + * + * @param request + * @return + */ + public AlarmInfoListResponse getAlarmInfoByTime(AlarmInfoByTimeRequest request) { + isNullCheck(request, REQUEST); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + Map param = new HashMap(); + param.put("time", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/alarm", + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, AlarmInfoListResponse.class); + } + + /** + * get alarm & media list by vehicle + * + * @param request + * @return + */ + public AlarmVideoInfoListResponse getAlarmVideoInfoByVehicleId(AlarmVideoInfoByVehicleIdRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + Map param = new HashMap(); + param.put("id", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/alarm/video", + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, AlarmVideoInfoListResponse.class); + } + + /** + * get alarm & media list by vehicle + * + * @param request + * @return + */ + public AlarmVideoInfoListResponse getAlarmVideoInfoByVehicleIdList(AlarmVideoInfoByVehicleIdListRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleIdList(), "vehicleIdList"); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + Map param = new HashMap(); + param.put("ids", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/alarm/video", + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, AlarmVideoInfoListResponse.class); + } + + /** + * get track point & alarm & media list by vehicle + * + * @param request + * @return + */ + public TrackAlarmVideoInfoResponse getTrackAlarmMediaInfoListByVehicleId(TrackAlarmMediaInfoRequest request) { + isNullCheck(request, REQUEST); + isEmptyCheck(request.getVehicleId(), VEHICLE_ID); + isNullCheck(request.getStartTime(), START_TIME); + isNullCheck(request.getEndTime(), END_TIME); + + Map param = new HashMap(); + param.put("id", ""); + + InternalRequest internalRequest = + buildInternalRequest(PREFIX_VIDEO_VERSION1 + "/query" + "/track", + HttpMethodName.POST, request, param); + return this.invokeHttpClient(internalRequest, TrackAlarmVideoInfoResponse.class); + } + + private void isEmptyCheck(String keyValue, String keyName) { + checkStringNotEmpty(keyValue, keyName + " should not be empty"); + } + + private void isEmptyCheck(List keyValues, String keyName) { + isNullCheck(keyValues, keyName); + checkIsTrue(!keyValues.isEmpty(), keyName + " should not be empty"); + } + + private void isEmptyCheck(Map keyValues, String keyName) { + isNullCheck(keyValues, keyName); + checkIsTrue(!keyValues.isEmpty(), keyName + " should not be empty"); + } + + private void isNullCheck(Object keyValue, String keyName) { + checkNotNull(keyValue, keyName + " should not be null"); + } + + private void isMatchPattern(String keyValue, String keyName, String pattern) { + checkPattern(keyValue, pattern, keyName + " format should be " + pattern); + } + + private void isEnumValue(String keyValue, String keyName, Class enumCls) { + checkValidValue(keyValue, enumCls, "the value of " + keyName + " is not valid"); + } +} diff --git a/src/main/java/com/baidubce/services/dugo/alarm/AlarmBatchRequest.java b/src/main/java/com/baidubce/services/dugo/alarm/AlarmBatchRequest.java new file mode 100644 index 00000000..ad6b150b --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/alarm/AlarmBatchRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.alarm; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * Request for batch operating alarms + */ +public class AlarmBatchRequest extends AbstractDuGoRequest { + private List alarmIds; + + public List getAlarmIds() { + return alarmIds; + } + + public void setAlarmIds(List alarmIds) { + this.alarmIds = alarmIds; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dugo/alarm/AlarmCreateRequest.java b/src/main/java/com/baidubce/services/dugo/alarm/AlarmCreateRequest.java new file mode 100644 index 00000000..e2fcd396 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/alarm/AlarmCreateRequest.java @@ -0,0 +1,239 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.alarm; + +import java.util.List; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * Request for creating an alarm + */ +public class AlarmCreateRequest extends AbstractDuGoRequest { + protected String name; + protected String des; + protected List batchIds; + protected List vehicleIds; + protected AlarmRule alarmRule; + protected AlarmPolicy alarmPolicy; + + public AlarmCreateRequest() { + } + + public AlarmCreateRequest(String name, String des, List batchIds, List vehicleIds, + AlarmRule alarmRule, AlarmPolicy alarmPolicy) { + this.name = name; + this.des = des; + this.batchIds = batchIds; + this.vehicleIds = vehicleIds; + this.alarmRule = alarmRule; + this.alarmPolicy = alarmPolicy; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDes() { + return des; + } + + public void setDes(String des) { + this.des = des; + } + + public List getBatchIds() { + return batchIds; + } + + public void setBatchIds(List batchIds) { + this.batchIds = batchIds; + } + + public List getVehicleIds() { + return vehicleIds; + } + + public void setVehicleIds(List vehicleIds) { + this.vehicleIds = vehicleIds; + } + + public AlarmRule getAlarmRule() { + return alarmRule; + } + + public void setAlarmRule(AlarmRule alarmRule) { + this.alarmRule = alarmRule; + } + + public AlarmPolicy getAlarmPolicy() { + return alarmPolicy; + } + + public void setAlarmPolicy(AlarmPolicy alarmPolicy) { + this.alarmPolicy = alarmPolicy; + } + + public static class AlarmRule { + private String alarmField; + private String rule; + private Double alarmFieldValue; + + public AlarmRule() { + } + + public AlarmRule(String alarmField, String rule, Double alarmFieldValue) { + this.alarmField = alarmField; + this.rule = rule; + this.alarmFieldValue = alarmFieldValue; + } + + public String getRule() { + return rule; + } + + public void setRule(String rule) { + this.rule = rule; + } + + public String getAlarmField() { + return alarmField; + } + + public void setAlarmField(String alarmField) { + this.alarmField = alarmField; + } + + public Double getAlarmFieldValue() { + return alarmFieldValue; + } + + public void setAlarmFieldValue(Double alarmFieldValue) { + this.alarmFieldValue = alarmFieldValue; + } + } + + public static class AlarmPolicy { + private List sinkTypes; + private String alarmType; + private AlarmTypeInfo alarmTypeInfo; + + public AlarmPolicy() { + } + + public AlarmPolicy(List sinkTypes, String alarmType, AlarmTypeInfo alarmTypeInfo) { + this.sinkTypes = sinkTypes; + this.alarmType = alarmType; + this.alarmTypeInfo = alarmTypeInfo; + } + + public List getSinkTypes() { + return sinkTypes; + } + + public void setSinkTypes(List sinkTypes) { + this.sinkTypes = sinkTypes; + } + + public String getAlarmType() { + return alarmType; + } + + public void setAlarmType(String alarmType) { + this.alarmType = alarmType; + } + + public AlarmTypeInfo getAlarmTypeInfo() { + return alarmTypeInfo; + } + + public void setAlarmTypeInfo(AlarmTypeInfo alarmTypeInfo) { + this.alarmTypeInfo = alarmTypeInfo; + } + } + + public static class SinkType { + private String sinkType; + private String sinkAddress; + + public SinkType() { + } + + public SinkType(String sinkType, String sinkAddress) { + this.sinkType = sinkType; + this.sinkAddress = sinkAddress; + } + + public String getSinkType() { + return sinkType; + } + + public void setSinkType(String sinkType) { + this.sinkType = sinkType; + } + + public String getSinkAddress() { + return sinkAddress; + } + + public void setSinkAddress(String sinkAddress) { + this.sinkAddress = sinkAddress; + } + } + + public static class AlarmTypeInfo { + private Integer frequency; + private Integer window; + private String unit; + + public Integer getFrequency() { + return frequency; + } + + public void setFrequency(Integer frequency) { + this.frequency = frequency; + } + + public Integer getWindow() { + return window; + } + + public void setWindow(Integer window) { + this.window = window; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public enum UnitType { + SECOND("SECOND"); + + String type; + + UnitType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/alarm/AlarmDetailsResponse.java b/src/main/java/com/baidubce/services/dugo/alarm/AlarmDetailsResponse.java new file mode 100644 index 00000000..4211ec1e --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/alarm/AlarmDetailsResponse.java @@ -0,0 +1,244 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.alarm; + +import java.util.List; +import com.baidubce.model.AbstractBceResponse; + +/** + * Response of querying alarm details + */ +public class AlarmDetailsResponse extends AbstractBceResponse { + private String alarmId; + private String name; + private String des; + private List batchIds; + private List vehicleIds; + private String status; + private AlarmRule alarmRule; + private AlarmPolicy alarmPolicy; + + public String getAlarmId() { + return alarmId; + } + + public void setAlarmId(String alarmId) { + this.alarmId = alarmId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDes() { + return des; + } + + public void setDes(String des) { + this.des = des; + } + + public List getBatchIds() { + return batchIds; + } + + public void setBatchIds(List batchIds) { + this.batchIds = batchIds; + } + + public List getVehicleIds() { + return vehicleIds; + } + + public void setVehicleIds(List vehicleIds) { + this.vehicleIds = vehicleIds; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public AlarmRule getAlarmRule() { + return alarmRule; + } + + public void setAlarmRule(AlarmRule alarmRule) { + this.alarmRule = alarmRule; + } + + public AlarmPolicy getAlarmPolicy() { + return alarmPolicy; + } + + public void setAlarmPolicy(AlarmPolicy alarmPolicy) { + this.alarmPolicy = alarmPolicy; + } + + public static class AlarmRule { + private String alarmField; + private String rule; + private Double alarmFieldValue; + + public AlarmRule() { + } + + public AlarmRule(String alarmField, String rule, Double alarmFieldValue) { + this.alarmField = alarmField; + this.rule = rule; + this.alarmFieldValue = alarmFieldValue; + } + + public String getRule() { + return rule; + } + + public void setRule(String rule) { + this.rule = rule; + } + + public String getAlarmField() { + return alarmField; + } + + public void setAlarmField(String alarmField) { + this.alarmField = alarmField; + } + + public Double getAlarmFieldValue() { + return alarmFieldValue; + } + + public void setAlarmFieldValue(Double alarmFieldValue) { + this.alarmFieldValue = alarmFieldValue; + } + } + + public static class AlarmPolicy { + private List sinkTypes; + private String alarmType; + private AlarmTypeInfo alarmTypeInfo; + + public AlarmPolicy() { + } + + public AlarmPolicy(List sinkTypes, String alarmType, AlarmTypeInfo alarmTypeInfo) { + this.sinkTypes = sinkTypes; + this.alarmType = alarmType; + this.alarmTypeInfo = alarmTypeInfo; + } + + public List getSinkTypes() { + return sinkTypes; + } + + public void setSinkTypes(List sinkTypes) { + this.sinkTypes = sinkTypes; + } + + public String getAlarmType() { + return alarmType; + } + + public void setAlarmType(String alarmType) { + this.alarmType = alarmType; + } + + public AlarmTypeInfo getAlarmTypeInfo() { + return alarmTypeInfo; + } + + public void setAlarmTypeInfo(AlarmTypeInfo alarmTypeInfo) { + this.alarmTypeInfo = alarmTypeInfo; + } + } + + public static class SinkType { + private String sinkType; + private String sinkAddress; + + public SinkType() { + } + + public SinkType(String sinkType, String sinkAddress) { + this.sinkType = sinkType; + this.sinkAddress = sinkAddress; + } + + public String getSinkType() { + return sinkType; + } + + public void setSinkType(String sinkType) { + this.sinkType = sinkType; + } + + public String getSinkAddress() { + return sinkAddress; + } + + public void setSinkAddress(String sinkAddress) { + this.sinkAddress = sinkAddress; + } + } + + public static class AlarmTypeInfo { + + private Integer frequency; + private Double window; + private String unit; + + public Integer getFrequency() { + return frequency; + } + + public void setFrequency(Integer frequency) { + this.frequency = frequency; + } + + public Double getWindow() { + return window; + } + + public void setWindow(Double window) { + this.window = window; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public enum UnitType { + SECOND("SECOND"); + + String type; + + UnitType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/alarm/AlarmRuleListResponse.java b/src/main/java/com/baidubce/services/dugo/alarm/AlarmRuleListResponse.java new file mode 100644 index 00000000..43d3c654 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/alarm/AlarmRuleListResponse.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.alarm; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Query alarm list response + */ +public class AlarmRuleListResponse extends AbstractBceResponse { + private Meta meta; + private List data; + + public Meta getMeta() { + return meta; + } + + public void setMeta(Meta meta) { + this.meta = meta; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class Meta { + private long total; + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + } + + public static class AlarmDigest { + private String alarmId; + private String name; + private String des; + private String status; + + public String getAlarmId() { + return alarmId; + } + + public void setAlarmId(String alarmId) { + this.alarmId = alarmId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDes() { + return des; + } + + public void setDes(String des) { + this.des = des; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/alarm/AlarmUpdateRequest.java b/src/main/java/com/baidubce/services/dugo/alarm/AlarmUpdateRequest.java new file mode 100644 index 00000000..646d0a43 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/alarm/AlarmUpdateRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.alarm; + +import java.util.List; + +/** + * Alarm update request + */ +public class AlarmUpdateRequest extends AlarmCreateRequest { + private String alarmId; + + public AlarmUpdateRequest() { + } + + public AlarmUpdateRequest(String alarmId, String name, String desc, List batchIds, List vehicleIds, + AlarmRule alarmRule, AlarmPolicy alarmPolicy) { + super(name, desc, batchIds, vehicleIds, alarmRule, alarmPolicy); + this.alarmId = alarmId; + } + + public String getAlarmId() { + return this.alarmId; + } + + public void setAlarmId(String alarmId) { + this.alarmId = alarmId; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dugo/core/BceIotClient.java b/src/main/java/com/baidubce/services/dugo/core/BceIotClient.java new file mode 100644 index 00000000..62c3b320 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/core/BceIotClient.java @@ -0,0 +1,70 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.core; + +import com.baidubce.http.HttpMethodName; + +/** + * + * the dugo bce client and build the request + * Created by liuzhenxing01 on 2018/10/18. + */ +public class BceIotClient { + + private String uri; + + private String ak; + + private String sk; + private HttpMethodName methodName; + + public BceIotClient(String uri, String ak, String sk, HttpMethodName methodName) { + if (uri == null || ak == null || sk == null || methodName == null) { + throw new IllegalArgumentException("uri, ak, sk, methodName should not be null"); + } + this.uri = uri; + this.methodName = methodName; + this.ak = ak; + this.sk = sk; + } + + public String getAk() { + return ak; + } + + public void setAk(String ak) { + this.ak = ak; + } + + public String getSk() { + return sk; + } + + public void setSk(String sk) { + this.sk = sk; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public HttpMethodName getMethodName() { + return methodName; + } + + public void setMethodName(HttpMethodName methodName) { + this.methodName = methodName; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/core/protocol/http/BceIotHttpClient.java b/src/main/java/com/baidubce/services/dugo/core/protocol/http/BceIotHttpClient.java new file mode 100644 index 00000000..2fbf5482 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/core/protocol/http/BceIotHttpClient.java @@ -0,0 +1,153 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.core.protocol.http; + +import java.net.URI; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.auth.BceCredentials; +import com.baidubce.auth.BceV1Signer; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.auth.SignOptions; +import com.baidubce.auth.Signer; +import com.baidubce.http.BceHttpClient; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.util.DateUtils; + +/** + * the http client for dugo and build the internalRequest + * Created by liuzhenxing01 on 2018/10/12. + */ +public class BceIotHttpClient { + + private static final String CONTENT_TYPE = "application/json;charset=utf-8"; + + private InternalRequest internalRequest; + private BceCredentials bceCredentials; + private URI uri; + + public BceIotHttpClient() { + } + + public URI getUri() { + return this.uri; + } + + public BceIotHttpClient withAuth(String ak, String sk) { + this.initBceCredentials(ak, sk); + return this; + } + + public String getHost() { + return this.uri.getHost(); + } + + public BceIotHttpClient withMethod(HttpMethodName methodName, URI uri) { + this.uri = uri; + this.initInternalRequest(methodName, uri); + return this; + } + + public InternalRequest getInternalRequest() { + return this.internalRequest; + } + + private void initBceCredentials(String ak, String sk) { + this.bceCredentials = new DefaultBceCredentials(ak, sk); + } + + private void initInternalRequest(HttpMethodName methodName, URI uri) { + internalRequest = new InternalRequest(methodName, uri); + internalRequest.setCredentials(this.bceCredentials); + internalRequest.setSignOptions(this.initSignOptions()); + internalRequest.setHeaders(initHeaders(uri)); + internalRequest.addHeader("Content-Type", CONTENT_TYPE); + } + + public void addParams(String key, String value) { + this.internalRequest.addParameter(key, value); + } + + private Map initHeaders(URI uri) { + Map headers = new HashMap(); + headers.put("x-bce-date", DateUtils.formatAlternateIso8601Date(new Date())); + headers.put("Host", uri.getHost()); + return headers; + } + + public void addHeader(String key, String value) { + this.internalRequest.addHeader(key, value); + } + + private SignOptions initSignOptions() { + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(getHeadersToSign()); + signOptions.setExpirationInSeconds(3600); + return signOptions; + } + + /** + * default header sign is Host and x-bce-date + * @return + */ + private Set getHeadersToSign() { + Set signHeaders = new HashSet(); + signHeaders.add("Host"); + signHeaders.add("x-bce-date"); + return signHeaders; + } + + public BceIotHttpClient withPayload(byte[] payload) { + if (payload == null) { + return this; + } + this.internalRequest.setContent(RestartableInputStream.wrap(payload)); + this.internalRequest.addHeader("Content-Length", "" + payload.length); + + this.internalRequest.addHeader(Headers.CONTENT_LENGTH, Integer.toString(payload.length)); + this.internalRequest.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + return this; + } + + public T exec(Class responseClass, HttpResponseHandler[] hadlers) { + checkClient(); + BceClientConfiguration config = new BceClientConfiguration(); + Signer signer = new BceV1Signer(); + BceHttpClient httpClient = new BceHttpClient(config, signer); + return (T) httpClient.execute(this.internalRequest, responseClass, hadlers); + } + + public T exec(Class responseClass) { + HttpResponseHandler[] responseHandlers = { new BceMetadataResponseHandler(), new + BceJsonResponseHandler(), new BceErrorResponseHandler()}; + return exec(responseClass, responseHandlers); + } + + private void checkClient() { + if (bceCredentials == null || bceCredentials.getAccessKeyId() == null + || bceCredentials.getSecretKey() == null) { + throw new IllegalArgumentException("accessKey and secretKey should not be null"); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dugo/core/protocol/mqtt/BceIotMessage.java b/src/main/java/com/baidubce/services/dugo/core/protocol/mqtt/BceIotMessage.java new file mode 100644 index 00000000..de518f1c --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/core/protocol/mqtt/BceIotMessage.java @@ -0,0 +1,49 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.core.protocol.mqtt; + +/** + * + * the bce MQTT message + * Created by liuzhenxing01 on 2018/10/9. + */ +public class BceIotMessage { + + private String topic; + + private int qos; + + private byte[] payload; + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public int getQos() { + return qos; + } + + public void setQos(int qos) { + this.qos = qos; + } + + public byte[] getPayload() { + return payload; + } + + public void setPayload(byte[] payload) { + this.payload = payload; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/core/protocol/mqtt/MqttConnection.java b/src/main/java/com/baidubce/services/dugo/core/protocol/mqtt/MqttConnection.java new file mode 100644 index 00000000..99b4cf10 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/core/protocol/mqtt/MqttConnection.java @@ -0,0 +1,194 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.core.protocol.mqtt; + +import java.io.IOException; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; + +import javax.net.SocketFactory; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManagerFactory; + +import org.eclipse.paho.client.mqttv3.IMqttActionListener; +import org.eclipse.paho.client.mqttv3.IMqttToken; +import org.eclipse.paho.client.mqttv3.MqttAsyncClient; +import org.eclipse.paho.client.mqttv3.MqttCallback; +import org.eclipse.paho.client.mqttv3.MqttConnectOptions; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; + +/** + * MQTT connect base + * Created by liuzhenxing01 on 2018/10/9. + */ +public class MqttConnection { + + private MqttAsyncClient mqttAsyncClient; + private MqttConnectOptions connectionOptions; + private IMqttActionListener mqttMessageListener; + private static final String TLS_V_1_2 = "TLSv1.2"; + + public MqttConnection(String serverURI, String clientId, String userName, String + password, SocketFactory socketFactory, MqttCallback mqttCallbackListener, + IMqttActionListener mqttMessageListener) throws MqttException { + + if (serverURI == null || mqttCallbackListener == null || mqttMessageListener == null) { + throw new IllegalArgumentException("serverURI, mqttCallbackListener, mqttMessageListener can't be null!"); + } + this.mqttAsyncClient = new MqttAsyncClient(serverURI, clientId, new MemoryPersistence()); + this.mqttAsyncClient.setManualAcks(true); + this.connectionOptions = new MqttConnectOptions(); + this.initOptions(userName, password, socketFactory); + this.mqttMessageListener = mqttMessageListener; + this.mqttAsyncClient.setCallback(mqttCallbackListener); + } + + private void initOptions(String userName, String password, SocketFactory socketFactory) { + this.connectionOptions.setKeepAliveInterval(180); + this.connectionOptions.setCleanSession(true); + this.connectionOptions.setUserName(userName); + this.connectionOptions.setSocketFactory(socketFactory); + if (password != null && !password.isEmpty()) { + this.connectionOptions.setPassword(password.toCharArray()); + } + } + + public MqttAsyncClient getMqttAsyncClient() { + return this.mqttAsyncClient; + } + + /** + * is connect success + * @return false + */ + public boolean isConnected() { + if (null != this.mqttAsyncClient) { + return this.mqttAsyncClient.isConnected(); + } + return false; + } + + public IMqttToken disconnect() throws MqttException { + if (this.mqttAsyncClient != null) { + return this.mqttAsyncClient.disconnect(); + } + return null; + } + + public void close() throws MqttException { + if (this.mqttAsyncClient != null) { + this.mqttAsyncClient.close(); + } + } + + public void openConnection() { + try { + this.mqttAsyncClient.connect(connectionOptions); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * + * publish message + * @param message + */ + public void publishMessage(BceIotMessage message) { + String topic = message.getTopic(); + MqttMessage mqttMessage = new MqttMessage(message.getPayload()); + mqttMessage.setQos(message.getQos()); + + try { + this.mqttAsyncClient.publish(topic, mqttMessage, message, mqttMessageListener); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * subscribe Topic + * @param message + */ + public void subscribeTopic(BceIotMessage message) { + try { + this.mqttAsyncClient.subscribe(message.getTopic(), message.getQos(), message, mqttMessageListener); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void unsubscribeTopic(BceIotMessage message) { + try { + this.mqttAsyncClient.unsubscribe(message.getTopic(), message, mqttMessageListener); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * @param keystore + * @return + * @throws NoSuchAlgorithmException + * @throws KeyStoreException + * @throws KeyManagementException + * @throws IOException + * @throws CertificateException + */ + public static SSLSocketFactory getFactory(KeyStore keystore) { + try { + TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + if (null == keystore) { + tmf.init((KeyStore) null); + } else { + tmf.init(keystore); + } + SSLContext context = SSLContext.getInstance(TLS_V_1_2); + context.init(null, tmf.getTrustManagers(), null); + return context.getSocketFactory(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * get SSLSocketFactory + * @param caKeystore + * @param clientKeystore + * @param keystorePassword + * + * @return + */ + public static SSLSocketFactory getFactory(KeyStore caKeystore, KeyStore clientKeystore, String keystorePassword) { + try { + TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + tmf.init(caKeystore); + KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); + kmf.init(clientKeystore, keystorePassword.toCharArray()); + SSLContext context = SSLContext.getInstance(TLS_V_1_2); + KeyManager[] kms = kmf.getKeyManagers(); + context.init(kms, tmf.getTrustManagers(), null); + return context.getSocketFactory(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dugo/map/CreateFenceRequest.java b/src/main/java/com/baidubce/services/dugo/map/CreateFenceRequest.java new file mode 100644 index 00000000..22b6bef3 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/CreateFenceRequest.java @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * Create fence request + */ +public class CreateFenceRequest extends AbstractDuGoRequest { + private String projectId; + private String fenceName; + private String fenceType; + private Object fenceParamsOption; + private String coordType; + private List monitoredObjectList; + private String alertType; + private List alertSinkList; + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public String getFenceName() { + return fenceName; + } + + public void setFenceName(String fenceName) { + this.fenceName = fenceName; + } + + public String getFenceType() { + return fenceType; + } + + public void setFenceType(String fenceType) { + this.fenceType = fenceType; + } + + public Object getFenceParamsOption() { + return fenceParamsOption; + } + + public void setFenceParamsOption(Object fenceParamsOption) { + this.fenceParamsOption = fenceParamsOption; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } + + public List getMonitoredObjectList() { + return monitoredObjectList; + } + + public void setMonitoredObjectList(List monitoredObjectList) { + this.monitoredObjectList = monitoredObjectList; + } + + public String getAlertType() { + return alertType; + } + + public void setAlertType(String alertType) { + this.alertType = alertType; + } + + public List getAlertSinkList() { + return alertSinkList; + } + + public void setAlertSinkList(List alertSinkList) { + this.alertSinkList = alertSinkList; + } + + public static class MonitoredObject { + private String objectType; + private String objectId; + private String alertCondition; + + public MonitoredObject(String objectType, String objectId, String alertCondition) { + this.objectType = objectType; + this.objectId = objectId; + this.alertCondition = alertCondition; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getAlertCondition() { + return alertCondition; + } + + public void setAlertCondition(String alertCondition) { + this.alertCondition = alertCondition; + } + } + + public static class AlertSink { + private String sinkType; + private String sinkValue; + + public AlertSink() { + } + + public AlertSink(String sinkType, String sinkValue) { + this.sinkType = sinkType; + this.sinkValue = sinkValue; + } + + public String getSinkType() { + return sinkType; + } + + public void setSinkType(String sinkType) { + this.sinkType = sinkType; + } + + public String getSinkValue() { + return sinkValue; + } + + public void setSinkValue(String sinkValue) { + this.sinkValue = sinkValue; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/CreateFenceResponse.java b/src/main/java/com/baidubce/services/dugo/map/CreateFenceResponse.java new file mode 100644 index 00000000..58582002 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/CreateFenceResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Response for creating fence + */ +public class CreateFenceResponse extends AbstractBceResponse { + private String fenceId; + + public String getFenceId() { + return fenceId; + } + + public void setFenceId(String fenceId) { + this.fenceId = fenceId; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/DeleteMonitoredVehicleRequest.java b/src/main/java/com/baidubce/services/dugo/map/DeleteMonitoredVehicleRequest.java new file mode 100644 index 00000000..2585dd7c --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/DeleteMonitoredVehicleRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * Request for deleting monitored vehicles + */ +public class DeleteMonitoredVehicleRequest extends AbstractDuGoRequest { + private String projectId; + private List vehicleIdList; + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public List getVehicleIdList() { + return vehicleIdList; + } + + public void setVehicleIdList(List vehicleIdList) { + this.vehicleIdList = vehicleIdList; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/DeviceStatusInfoResponse.java b/src/main/java/com/baidubce/services/dugo/map/DeviceStatusInfoResponse.java new file mode 100644 index 00000000..3fce9386 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/DeviceStatusInfoResponse.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Get response for query device status info + */ +public class DeviceStatusInfoResponse extends AbstractBceResponse { + private String deviceId; + private Info info; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public Info getInfo() { + return info; + } + + public void setInfo(Info info) { + this.info = info; + } + + public static class Info { + private Device device; + private OTA ota; + private Version version; + private SIM sim; + + public Device getDevice() { + return device; + } + + public void setDevice(Device device) { + this.device = device; + } + + public OTA getOta() { + return ota; + } + + public void setOta(OTA ota) { + this.ota = ota; + } + + public Version getVersion() { + return version; + } + + public void setVersion(Version version) { + this.version = version; + } + + public SIM getSim() { + return sim; + } + + public void setSim(SIM sim) { + this.sim = sim; + } + + public static class Device { + private String pk; + private String dn; + private String sign; + + public String getPk() { + return pk; + } + + public void setPk(String pk) { + this.pk = pk; + } + + public String getDn() { + return dn; + } + + public void setDn(String dn) { + this.dn = dn; + } + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + } + + public static class OTA { + private String otaId; + private String otaSecret; + + public String getOtaId() { + return otaId; + } + + public void setOtaId(String otaId) { + this.otaId = otaId; + } + + public String getOtaSecret() { + return otaSecret; + } + + public void setOtaSecret(String otaSecret) { + this.otaSecret = otaSecret; + } + } + + public static class Version { + private String main; + private String mcu; + + public String getMain() { + return main; + } + + public void setMain(String main) { + this.main = main; + } + + public String getMcu() { + return mcu; + } + + public void setMcu(String mcu) { + this.mcu = mcu; + } + } + + public static class SIM { + private List type; + private String iccid; + + public List getType() { + return type; + } + + public void setType(List type) { + this.type = type; + } + + public String getIccid() { + return iccid; + } + + public void setIccid(String iccid) { + this.iccid = iccid; + } + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/DrivingBehaviorRequest.java b/src/main/java/com/baidubce/services/dugo/map/DrivingBehaviorRequest.java new file mode 100644 index 00000000..f4ad5616 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/DrivingBehaviorRequest.java @@ -0,0 +1,102 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * + * get the vehicle driving behavior + * Created by liuzhenxing01 on 2018/10/22. + */ +public class DrivingBehaviorRequest extends AbstractDuGoRequest { + private String vehicleId; + private Long startTime; + private Long endTime; + private Double speedingThreshold; + private Double harshAccelerationThreshold; + private Double harshBreakingThreshold; + private Double harshSteeringThreshold; + private String processOption; + private String coordTypeOutput; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public Double getSpeedingThreshold() { + return speedingThreshold; + } + + public void setSpeedingThreshold(Double speedingThreshold) { + this.speedingThreshold = speedingThreshold; + } + + public Double getHarshAccelerationThreshold() { + return harshAccelerationThreshold; + } + + public void setHarshAccelerationThreshold(Double harshAccelerationThreshold) { + this.harshAccelerationThreshold = harshAccelerationThreshold; + } + + public Double getHarshBreakingThreshold() { + return harshBreakingThreshold; + } + + public void setHarshBreakingThreshold(Double harshBreakingThreshold) { + this.harshBreakingThreshold = harshBreakingThreshold; + } + + public Double getHarshSteeringThreshold() { + return harshSteeringThreshold; + } + + public void setHarshSteeringThreshold(Double harshSteeringThreshold) { + this.harshSteeringThreshold = harshSteeringThreshold; + } + + public String getProcessOption() { + return processOption; + } + + public void setProcessOption(String processOption) { + this.processOption = processOption; + } + + public String getCoordTypeOutput() { + return coordTypeOutput; + } + + public void setCoordTypeOutput(String coordTypeOutput) { + this.coordTypeOutput = coordTypeOutput; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/DrivingBehaviorResponse.java b/src/main/java/com/baidubce/services/dugo/map/DrivingBehaviorResponse.java new file mode 100644 index 00000000..138c2c63 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/DrivingBehaviorResponse.java @@ -0,0 +1,470 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response for driving behavior + */ +public class DrivingBehaviorResponse extends AbstractBceResponse { + private Double distance; + private Integer duration; + private Double averageSpeed; + private Double maxSpeed; + private Integer speedingNum; + private Integer harshAccelerationNum; + private Integer harshBreakingNum; + private Integer harshSteeringNum; + private Point startPoint; + private Point endPoint; + private List speeding; + private List harshAcceleration; + private List harshBreaking; + private List harshSteering; + + public Double getDistance() { + return distance; + } + + public void setDistance(Double distance) { + this.distance = distance; + } + + public Integer getDuration() { + return duration; + } + + public void setDuration(Integer duration) { + this.duration = duration; + } + + public Double getAverageSpeed() { + return averageSpeed; + } + + public void setAverageSpeed(Double averageSpeed) { + this.averageSpeed = averageSpeed; + } + + public Double getMaxSpeed() { + return maxSpeed; + } + + public void setMaxSpeed(Double maxSpeed) { + this.maxSpeed = maxSpeed; + } + + public Integer getSpeedingNum() { + return speedingNum; + } + + public void setSpeedingNum(Integer speedingNum) { + this.speedingNum = speedingNum; + } + + public Integer getHarshAccelerationNum() { + return harshAccelerationNum; + } + + public void setHarshAccelerationNum(Integer harshAccelerationNum) { + this.harshAccelerationNum = harshAccelerationNum; + } + + public Integer getHarshBreakingNum() { + return harshBreakingNum; + } + + public void setHarshBreakingNum(Integer harshBreakingNum) { + this.harshBreakingNum = harshBreakingNum; + } + + public Integer getHarshSteeringNum() { + return harshSteeringNum; + } + + public void setHarshSteeringNum(Integer harshSteeringNum) { + this.harshSteeringNum = harshSteeringNum; + } + + public Point getStartPoint() { + return startPoint; + } + + public void setStartPoint(Point startPoint) { + this.startPoint = startPoint; + } + + public Point getEndPoint() { + return endPoint; + } + + public void setEndPoint(Point endPoint) { + this.endPoint = endPoint; + } + + public List getSpeeding() { + return speeding; + } + + public void setSpeeding( + List speeding) { + this.speeding = speeding; + } + + public List getHarshAcceleration() { + return harshAcceleration; + } + + public void setHarshAcceleration( + List harshAcceleration) { + this.harshAcceleration = harshAcceleration; + } + + public List getHarshBreaking() { + return harshBreaking; + } + + public void setHarshBreaking( + List harshBreaking) { + this.harshBreaking = harshBreaking; + } + + public List getHarshSteering() { + return harshSteering; + } + + public void setHarshSteering( + List harshSteering) { + this.harshSteering = harshSteering; + } + + public static class HarshAcceleration { + private Double latitude; + private Double longitude; + private String coordType; + private Long locTime; + private Double acceleration; + private Double initialSpeed; + private Double endSpeed; + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + + public Double getAcceleration() { + return acceleration; + } + + public void setAcceleration(Double acceleration) { + this.acceleration = acceleration; + } + + public Double getInitialSpeed() { + return initialSpeed; + } + + public void setInitialSpeed(Double initialSpeed) { + this.initialSpeed = initialSpeed; + } + + public Double getEndSpeed() { + return endSpeed; + } + + public void setEndSpeed(Double endSpeed) { + this.endSpeed = endSpeed; + } + } + + public static class Point { + private Double latitude; + private Double longitude; + private String coordType; + private Long locTime; + private String address; + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + } + + + public static class Speeding { + private Double speedingDistance; + private List speedingPoints; + + public Double getSpeedingDistance() { + return speedingDistance; + } + + public void setSpeedingDistance(Double speedingDistance) { + this.speedingDistance = speedingDistance; + } + + public List getSpeedingPoints() { + return speedingPoints; + } + + public void setSpeedingPoints( + List speedingPoints) { + this.speedingPoints = speedingPoints; + } + } + + public static class SpeedingPoint { + private Double latitude; + private Double longitude; + private String coordType; + private Long locTime; + private Double actualSpeed; + private Double limitSpeed; + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + + public Double getActualSpeed() { + return actualSpeed; + } + + public void setActualSpeed(Double actualSpeed) { + this.actualSpeed = actualSpeed; + } + + public Double getLimitSpeed() { + return limitSpeed; + } + + public void setLimitSpeed(Double limitSpeed) { + this.limitSpeed = limitSpeed; + } + } + + public static class HarshBreaking { + private Double latitude; + private Double longitude; + private String coordType; + private Long locTime; + private Double acceleration; + private Double initialSpeed; + private Double endSpeed; + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + + public Double getAcceleration() { + return acceleration; + } + + public void setAcceleration(Double acceleration) { + this.acceleration = acceleration; + } + + public Double getInitialSpeed() { + return initialSpeed; + } + + public void setInitialSpeed(Double initialSpeed) { + this.initialSpeed = initialSpeed; + } + + public Double getEndSpeed() { + return endSpeed; + } + + public void setEndSpeed(Double endSpeed) { + this.endSpeed = endSpeed; + } + } + + public static class HarshSteering { + private Double latitude; + private Double longitude; + private String coordType; + private Long locTime; + private Double centripetalAcceleration; + private String turnType; + private Double speed; + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + + public Double getCentripetalAcceleration() { + return centripetalAcceleration; + } + + public void setCentripetalAcceleration(Double centripetalAcceleration) { + this.centripetalAcceleration = centripetalAcceleration; + } + + public String getTurnType() { + return turnType; + } + + public void setTurnType(String turnType) { + this.turnType = turnType; + } + + public Double getSpeed() { + return speed; + } + + public void setSpeed(Double speed) { + this.speed = speed; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/FenceDetailResponse.java b/src/main/java/com/baidubce/services/dugo/map/FenceDetailResponse.java new file mode 100644 index 00000000..ee531444 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/FenceDetailResponse.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response for querying fence details + */ +public class FenceDetailResponse extends AbstractBceResponse { + private String fenceId; + private String fenceName; + private String fenceType; + private Object fenceParamsOption; + private String coordType; + private String alertType; + private List alertSinkList; + + public FenceDetailResponse() { + } + + public FenceDetailResponse(String fenceId, String fenceName, String fenceType, Object fenceParamsOption, + String coordType, String alertType, List alertSinkList) { + this.fenceId = fenceId; + this.fenceName = fenceName; + this.fenceType = fenceType; + this.fenceParamsOption = fenceParamsOption; + this.coordType = coordType; + this.alertType = alertType; + this.alertSinkList = alertSinkList; + } + + public String getFenceId() { + return fenceId; + } + + public void setFenceId(String fenceId) { + this.fenceId = fenceId; + } + + public String getFenceName() { + return fenceName; + } + + public void setFenceName(String fenceName) { + this.fenceName = fenceName; + } + + public String getFenceType() { + return fenceType; + } + + public void setFenceType(String fenceType) { + this.fenceType = fenceType; + } + + public Object getFenceParamsOption() { + return fenceParamsOption; + } + + public void setFenceParamsOption(Object fenceParamsOption) { + this.fenceParamsOption = fenceParamsOption; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } + + public String getAlertType() { + return alertType; + } + + public void setAlertType(String alertType) { + this.alertType = alertType; + } + + public List getAlertSinkList() { + return alertSinkList; + } + + public void setAlertSinkList(List alertSinkList) { + this.alertSinkList = alertSinkList; + } + + public static class AlertSink { + private String sinkType; + private String sinkValue; + + public AlertSink() { + } + + public AlertSink(String sinkType, String sinkValue) { + this.sinkType = sinkType; + this.sinkValue = sinkValue; + } + + public String getSinkType() { + return sinkType; + } + + public void setSinkType(String sinkType) { + this.sinkType = sinkType; + } + + public String getSinkValue() { + return sinkValue; + } + + public void setSinkValue(String sinkValue) { + this.sinkValue = sinkValue; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/FenceListResponse.java b/src/main/java/com/baidubce/services/dugo/map/FenceListResponse.java new file mode 100644 index 00000000..4dea6db0 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/FenceListResponse.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +import java.sql.Timestamp; +import java.util.List; + +/** + * Response for listing fence + */ +public class FenceListResponse extends AbstractBceResponse { + private long total; + private List fenceInfoDigestList; + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public List getFenceInfoDigestList() { + return fenceInfoDigestList; + } + + public void setFenceInfoDigestList(List fenceInfoDigestList) { + this.fenceInfoDigestList = fenceInfoDigestList; + } + + public static class FenceInfoDigest { + private String fenceId; + private String fenceName; + private String fenceType; + private Integer vehicleCount; + private Timestamp createTime; + + public String getFenceId() { + return fenceId; + } + + public void setFenceId(String fenceId) { + this.fenceId = fenceId; + } + + public String getFenceName() { + return fenceName; + } + + public void setFenceName(String fenceName) { + this.fenceName = fenceName; + } + + public String getFenceType() { + return fenceType; + } + + public void setFenceType(String fenceType) { + this.fenceType = fenceType; + } + + public Integer getVehicleCount() { + return vehicleCount; + } + + public void setVehicleCount(Integer vehicleCount) { + this.vehicleCount = vehicleCount; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/FenceMonitoredVehicleRequest.java b/src/main/java/com/baidubce/services/dugo/map/FenceMonitoredVehicleRequest.java new file mode 100644 index 00000000..eb50c75a --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/FenceMonitoredVehicleRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * Request for querying monitored vehicles + */ +public class FenceMonitoredVehicleRequest extends AbstractDuGoRequest { + private String projectId; + private List vehicleDigestList; + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public List getVehicleDigestList() { + return vehicleDigestList; + } + + public void setVehicleDigestList(List vehicleDigestList) { + this.vehicleDigestList = vehicleDigestList; + } + + public static class VehicleDigest { + private String vehicleId; + private String alertCondition; + + public VehicleDigest() { + } + + public VehicleDigest(String vehicleId, String alertCondition) { + this.vehicleId = vehicleId; + this.alertCondition = alertCondition; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getAlertCondition() { + return alertCondition; + } + + public void setAlertCondition(String alertCondition) { + this.alertCondition = alertCondition; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GeoCodingRequest.java b/src/main/java/com/baidubce/services/dugo/map/GeoCodingRequest.java new file mode 100644 index 00000000..141a6ea1 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GeoCodingRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * + * geo coding request for address + * Created by liuzhenxing01 on 2018/10/22. + */ +public class GeoCodingRequest extends AbstractDuGoRequest { + private String address; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GeoCodingResponse.java b/src/main/java/com/baidubce/services/dugo/map/GeoCodingResponse.java new file mode 100644 index 00000000..6dfdc7be --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GeoCodingResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Response for geo coding + */ +public class GeoCodingResponse extends AbstractBceResponse { + private String latitude; + private String longitude; + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GeoDecodingRequest.java b/src/main/java/com/baidubce/services/dugo/map/GeoDecodingRequest.java new file mode 100644 index 00000000..87b06b9c --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GeoDecodingRequest.java @@ -0,0 +1,39 @@ +/* +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * Reverse GeoCoding Request model + * Created by liuzhenxing01 on 2018/10/22. + */ +public class GeoDecodingRequest extends AbstractDuGoRequest { + private Double longitude; + private Double latitude; + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dugo/map/GeoDecodingResponse.java b/src/main/java/com/baidubce/services/dugo/map/GeoDecodingResponse.java new file mode 100644 index 00000000..fab325ad --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GeoDecodingResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Response for geo decoding + */ +public class GeoDecodingResponse extends AbstractBceResponse { + private String address; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GetDeviceInfoRequest.java b/src/main/java/com/baidubce/services/dugo/map/GetDeviceInfoRequest.java new file mode 100644 index 00000000..b1f80acb --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GetDeviceInfoRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * Make a request for getting device info + */ +public class GetDeviceInfoRequest extends AbstractDuGoRequest { + private List fields; + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GetDistanceRequest.java b/src/main/java/com/baidubce/services/dugo/map/GetDistanceRequest.java new file mode 100644 index 00000000..3640cdad --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GetDistanceRequest.java @@ -0,0 +1,74 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * get the distance request model + * Created by liuzhenxing01 on 2018/10/22. + */ +public class GetDistanceRequest extends AbstractDuGoRequest { + private String vehicleId; + private Long startTime; + private Long endTime; + private Integer isProcessed; + private String processOption; + private String supplementMode; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public Integer getIsProcessed() { + return isProcessed; + } + + public void setIsProcessed(Integer isProcessed) { + this.isProcessed = isProcessed; + } + + public String getProcessOption() { + return processOption; + } + + public void setProcessOption(String processOption) { + this.processOption = processOption; + } + + public String getSupplementMode() { + return supplementMode; + } + + public void setSupplementMode(String supplementMode) { + this.supplementMode = supplementMode; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GetDistanceResponse.java b/src/main/java/com/baidubce/services/dugo/map/GetDistanceResponse.java new file mode 100644 index 00000000..58fae3ac --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GetDistanceResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Response for getting distance + */ +public class GetDistanceResponse extends AbstractBceResponse { + private String distance; + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GetFenceAlarmsResponse.java b/src/main/java/com/baidubce/services/dugo/map/GetFenceAlarmsResponse.java new file mode 100644 index 00000000..17fa38cd --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GetFenceAlarmsResponse.java @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.Date; +import java.util.List; + +/** + * Response for getting fence alarms + */ +public class GetFenceAlarmsResponse extends AbstractBceResponse { + private Meta meta; + private List alarmPointList; + + public Meta getMeta() { + return meta; + } + + public void setMeta(Meta meta) { + this.meta = meta; + } + + public List getAlarmPointList() { + return alarmPointList; + } + + public void setAlarmPointList(List alarmPointList) { + this.alarmPointList = alarmPointList; + } + + public static class Meta { + private long total; + private String fenceName; + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public String getFenceName() { + return fenceName; + } + + public void setFenceName(String fenceName) { + this.fenceName = fenceName; + } + } + + public static class AlarmPoint { + private String vehicleId; + private Point point; + private Date alarmTime; + private String alertCondition; + + public AlarmPoint() { + } + + public AlarmPoint(String vehicleId, Point point, Date alarmTime, String alertCondition) { + this.vehicleId = vehicleId; + this.point = point; + this.alarmTime = alarmTime; + this.alertCondition = alertCondition; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public Date getAlarmTime() { + return alarmTime; + } + + public void setAlarmTime(Date alarmTime) { + this.alarmTime = alarmTime; + } + + public String getAlertCondition() { + return alertCondition; + } + + public void setAlertCondition(String alertCondition) { + this.alertCondition = alertCondition; + } + } + + public static class Point { + private Double longitude; + private Double latitude; + + public Point() { + } + + public Point(Double longitude, Double latitude) { + this.longitude = longitude; + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GetLatestPointRequest.java b/src/main/java/com/baidubce/services/dugo/map/GetLatestPointRequest.java new file mode 100644 index 00000000..3cd3026b --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GetLatestPointRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * get latest point request model + * Created by liuzhenxing01 on 2018/10/22. + */ +public class GetLatestPointRequest extends AbstractDuGoRequest { + private String vehicleId; + private String processOption; + private String coordTypeOutput; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getProcessOption() { + return processOption; + } + + public void setProcessOption(String processOption) { + this.processOption = processOption; + } + + public String getCoordTypeOutput() { + return coordTypeOutput; + } + + public void setCoordTypeOutput(String coordTypeOutput) { + this.coordTypeOutput = coordTypeOutput; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GetLatestPointResponse.java b/src/main/java/com/baidubce/services/dugo/map/GetLatestPointResponse.java new file mode 100644 index 00000000..671dd488 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GetLatestPointResponse.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Response for getting latest point + */ +public class GetLatestPointResponse extends AbstractBceResponse { + private GeoInfo geoInfo; + private Double limitSpeed; + + public GeoInfo getGeoInfo() { + return geoInfo; + } + + public void setGeoInfo(GeoInfo geoInfo) { + this.geoInfo = geoInfo; + } + + public Double getLimitSpeed() { + return limitSpeed; + } + + public void setLimitSpeed(Double limitSpeed) { + this.limitSpeed = limitSpeed; + } + + public static class GeoInfo { + private Double latitude; + private Double longitude; + private Double radius; + private Double speed; + private Integer direction; + private Double height; + private Long locTime; + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getRadius() { + return radius; + } + + public void setRadius(Double radius) { + this.radius = radius; + } + + public Double getSpeed() { + return speed; + } + + public void setSpeed(Double speed) { + this.speed = speed; + } + + public Integer getDirection() { + return direction; + } + + public void setDirection(Integer direction) { + this.direction = direction; + } + + public Double getHeight() { + return height; + } + + public void setHeight(Double height) { + this.height = height; + } + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/GetTrackRequest.java b/src/main/java/com/baidubce/services/dugo/map/GetTrackRequest.java new file mode 100644 index 00000000..38043e61 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GetTrackRequest.java @@ -0,0 +1,110 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * get the vehicle track request model + * Created by liuzhenxing01 on 2018/10/22. + */ +public class GetTrackRequest extends AbstractDuGoRequest { + private String vehicleId; + private Long startTime; + private Long endTime; + private Integer isProcessed; + private String processOption; + private String supplementMode; + private String coordTypeOutput; + private String sortType; + private Integer pageIndex; + private Integer pageSize; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public Integer getIsProcessed() { + return isProcessed; + } + + public void setIsProcessed(Integer isProcessed) { + this.isProcessed = isProcessed; + } + + public String getProcessOption() { + return processOption; + } + + public void setProcessOption(String processOption) { + this.processOption = processOption; + } + + public String getSupplementMode() { + return supplementMode; + } + + public void setSupplementMode(String supplementMode) { + this.supplementMode = supplementMode; + } + + public String getCoordTypeOutput() { + return coordTypeOutput; + } + + public void setCoordTypeOutput(String coordTypeOutput) { + this.coordTypeOutput = coordTypeOutput; + } + + public String getSortType() { + return sortType; + } + + public void setSortType(String sortType) { + this.sortType = sortType; + } + + public Integer getPageIndex() { + return pageIndex; + } + + public void setPageIndex(Integer pageIndex) { + this.pageIndex = pageIndex; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dugo/map/GetTrackResponse.java b/src/main/java/com/baidubce/services/dugo/map/GetTrackResponse.java new file mode 100644 index 00000000..1c21a3ba --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/GetTrackResponse.java @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response for getting track + */ +public class GetTrackResponse extends AbstractBceResponse { + private Integer total; + private Integer size; + private Double distance; + private Double tollDistance; + private LocationPoint startPoint; + private LocationPoint endPoint; + private List points; + + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + + public Double getDistance() { + return distance; + } + + public void setDistance(Double distance) { + this.distance = distance; + } + + public Double getTollDistance() { + return tollDistance; + } + + public void setTollDistance(Double tollDistance) { + this.tollDistance = tollDistance; + } + + public LocationPoint getStartPoint() { + return startPoint; + } + + public void setStartPoint(LocationPoint startPoint) { + this.startPoint = startPoint; + } + + public LocationPoint getEndPoint() { + return endPoint; + } + + public void setEndPoint(LocationPoint endPoint) { + this.endPoint = endPoint; + } + + public List getPoints() { + return points; + } + + public void setPoints(List points) { + this.points = points; + } + + public static class LocationPoint { + private Double latitude; + private Double longitude; + private String coordType; + private Long locTime; + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + } + + public static class GeoInfo { + private Double latitude; + private Double longitude; + private Double radius; + private Double speed; + private Integer direction; + private Double height; + private Long locTime; + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getRadius() { + return radius; + } + + public void setRadius(Double radius) { + this.radius = radius; + } + + public Double getSpeed() { + return speed; + } + + public void setSpeed(Double speed) { + this.speed = speed; + } + + public Integer getDirection() { + return direction; + } + + public void setDirection(Integer direction) { + this.direction = direction; + } + + public Double getHeight() { + return height; + } + + public void setHeight(Double height) { + this.height = height; + } + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/MonitoredVehicleListResponse.java b/src/main/java/com/baidubce/services/dugo/map/MonitoredVehicleListResponse.java new file mode 100644 index 00000000..03487a84 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/MonitoredVehicleListResponse.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response for querying monitored vehicles + */ +public class MonitoredVehicleListResponse extends AbstractBceResponse { + private long total; + private List vehicleDigestList; + + public MonitoredVehicleListResponse() { + } + + public MonitoredVehicleListResponse(long total, List vehicleDigestList) { + this.total = total; + this.vehicleDigestList = vehicleDigestList; + } + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public List getVehicleDigestList() { + return vehicleDigestList; + } + + public void setVehicleDigestList(List vehicleDigestList) { + this.vehicleDigestList = vehicleDigestList; + } + + public static class VehicleDigest { + private String vehicleId; + private String alertCondition; + + public VehicleDigest() { + } + + public VehicleDigest(String vehicleId, String alertCondition) { + this.vehicleId = vehicleId; + this.alertCondition = alertCondition; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getAlertCondition() { + return alertCondition; + } + + public void setAlertCondition(String alertCondition) { + this.alertCondition = alertCondition; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/QueryDeviceLogResponse.java b/src/main/java/com/baidubce/services/dugo/map/QueryDeviceLogResponse.java new file mode 100644 index 00000000..441e6ecc --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/QueryDeviceLogResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Get response for query device log + */ +public class QueryDeviceLogResponse extends AbstractBceResponse { + private List logFileUrlList; + + public List getLogFileUrlList() { + return logFileUrlList; + } + + public void setLogFileUrlList(List logFileUrlList) { + this.logFileUrlList = logFileUrlList; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/StayPointRequest.java b/src/main/java/com/baidubce/services/dugo/map/StayPointRequest.java new file mode 100644 index 00000000..e8ef1050 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/StayPointRequest.java @@ -0,0 +1,84 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * query the vehicle stay point request model + * Created by liuzhenxing01 on 2018/10/22. + */ +public class StayPointRequest extends AbstractDuGoRequest { + + private String vehicleId; + private Long startTime; + private Long endTime; + private Integer stayTime; + private Integer stayRadius; + private String processOption; + private String coordTypeOutput; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public Integer getStayTime() { + return stayTime; + } + + public void setStayTime(Integer stayTime) { + this.stayTime = stayTime; + } + + public Integer getStayRadius() { + return stayRadius; + } + + public void setStayRadius(Integer stayRadius) { + this.stayRadius = stayRadius; + } + + public String getProcessOption() { + return processOption; + } + + public void setProcessOption(String processOption) { + this.processOption = processOption; + } + + public String getCoordTypeOutput() { + return coordTypeOutput; + } + + public void setCoordTypeOutput(String coordTypeOutput) { + this.coordTypeOutput = coordTypeOutput; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/StayPointResponse.java b/src/main/java/com/baidubce/services/dugo/map/StayPointResponse.java new file mode 100644 index 00000000..4c732134 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/StayPointResponse.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response for querying stay points + */ +public class StayPointResponse extends AbstractBceResponse { + private Integer staypointNum; + private List staypoints; + + public Integer getStaypointNum() { + return staypointNum; + } + + public void setStaypointNum(Integer staypointNum) { + this.staypointNum = staypointNum; + } + + public List getStaypoints() { + return staypoints; + } + + public void setStaypoints(List staypoints) { + this.staypoints = staypoints; + } + + public static class Staypoint { + private Long startTime; + private Long endTime; + private Integer duration; + private Point point; + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public Integer getDuration() { + return duration; + } + + public void setDuration(Integer duration) { + this.duration = duration; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + } + + public static class Point { + private Double latitude; + private Double longitude; + private Double radius; + private String coordType; + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getRadius() { + return radius; + } + + public void setRadius(Double radius) { + this.radius = radius; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/map/UpdateFenceAlarmRequest.java b/src/main/java/com/baidubce/services/dugo/map/UpdateFenceAlarmRequest.java new file mode 100644 index 00000000..df5750f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/UpdateFenceAlarmRequest.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * Request for updating fence alarms + */ +public class UpdateFenceAlarmRequest extends AbstractDuGoRequest { + private String projectId; + private String fenceId; + private String alertType; + private List alertSinkList; + + public UpdateFenceAlarmRequest() { + } + + public UpdateFenceAlarmRequest(String projectId, String fenceId, String alertType, + List alertSinkList) { + this.projectId = projectId; + this.fenceId = fenceId; + this.alertType = alertType; + this.alertSinkList = alertSinkList; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public String getFenceId() { + return fenceId; + } + + public void setFenceId(String fenceId) { + this.fenceId = fenceId; + } + + public String getAlertType() { + return alertType; + } + + public void setAlertType(String alertType) { + this.alertType = alertType; + } + + public List getAlertSinkList() { + return alertSinkList; + } + + public void setAlertSinkList(List alertSinkList) { + this.alertSinkList = alertSinkList; + } + + public static class AlertSink { + private String sinkType; + private String sinkValue; + + public AlertSink() { + } + + public AlertSink(String sinkType, String sinkValue) { + this.sinkType = sinkType; + this.sinkValue = sinkValue; + } + + public String getSinkType() { + return sinkType; + } + + public void setSinkType(String sinkType) { + this.sinkType = sinkType; + } + + public String getSinkValue() { + return sinkValue; + } + + public void setSinkValue(String sinkValue) { + this.sinkValue = sinkValue; + } + } + +} diff --git a/src/main/java/com/baidubce/services/dugo/map/UpdateFenceRequest.java b/src/main/java/com/baidubce/services/dugo/map/UpdateFenceRequest.java new file mode 100644 index 00000000..c2400444 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/map/UpdateFenceRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.map; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * Request for updating a fence + */ +public class UpdateFenceRequest extends AbstractDuGoRequest { + private String projectId; + + private String fenceId; + + private String fenceName; + + private Object fenceParamsOption; + + private String coordType; + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public String getFenceId() { + return fenceId; + } + + public void setFenceId(String fenceId) { + this.fenceId = fenceId; + } + + public String getFenceName() { + return fenceName; + } + + public void setFenceName(String fenceName) { + this.fenceName = fenceName; + } + + public Object getFenceParamsOption() { + return fenceParamsOption; + } + + public void setFenceParamsOption(Object fenceParamsOption) { + this.fenceParamsOption = fenceParamsOption; + } + + public String getCoordType() { + return coordType; + } + + public void setCoordType(String coordType) { + this.coordType = coordType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/AlarmRuleType.java b/src/main/java/com/baidubce/services/dugo/model/AlarmRuleType.java new file mode 100644 index 00000000..7a82db81 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/AlarmRuleType.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Alarm rule type + */ +public enum AlarmRuleType { + R1(">"), R2("="), R4("<"), R5(">="), R6("<="), R7("<>"); + + String rule; + + AlarmRuleType(String rule) { + this.rule = rule; + } + + public String getValue() { + return rule; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/AlarmSinkType.java b/src/main/java/com/baidubce/services/dugo/model/AlarmSinkType.java new file mode 100644 index 00000000..d8daa02b --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/AlarmSinkType.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Alarm sink type + */ +public enum AlarmSinkType { + KAFKA("KAFKA"); + + String sinkType; + + AlarmSinkType(String sinkType) { + this.sinkType = sinkType; + } + + public String getValue() { + return this.sinkType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/AlarmType.java b/src/main/java/com/baidubce/services/dugo/model/AlarmType.java new file mode 100644 index 00000000..52f947a9 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/AlarmType.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Alarm type + */ +public enum AlarmType { + AT_ONCE("AT_ONCE"), + AT_ONCE_WITH_NORMAL("AT_ONCE_WITH_NORMAL"), + MULTI_NOTICE_WITH_NORMAL("MULTI_NOTICE_WITH_NORMAL"); + + String alarmType; + + AlarmType(String alarmType) { + this.alarmType = alarmType; + } + + public String getAlarmType() { + return this.alarmType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/AlertType.java b/src/main/java/com/baidubce/services/dugo/model/AlertType.java new file mode 100644 index 00000000..7e598a0b --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/AlertType.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Alert type + */ +public enum AlertType { + EVERY_TIME("EVERY_TIME"); + + private String alertType; + + AlertType(String alertType) { + this.alertType = alertType; + } + + public String getValue() { + return alertType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/CircleFenceOption.java b/src/main/java/com/baidubce/services/dugo/model/CircleFenceOption.java new file mode 100644 index 00000000..43b9abe5 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/CircleFenceOption.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Option for circle fence + */ +public class CircleFenceOption { + private Double longitude; + private Double latitude; + private Double radius; + private Integer denoise; + + public CircleFenceOption(Double longitude, Double latitude, Double radius) { + this.longitude = longitude; + this.latitude = latitude; + this.radius = radius; + } + + public CircleFenceOption(Double longitude, Double latitude, Double radius, Integer denoise) { + this.longitude = longitude; + this.latitude = latitude; + this.radius = radius; + this.denoise = denoise; + } + + public Double getLongitude() { + return longitude; + } + + public void setLongitude(Double longitude) { + this.longitude = longitude; + } + + public Double getLatitude() { + return latitude; + } + + public void setLatitude(Double latitude) { + this.latitude = latitude; + } + + public Double getRadius() { + return radius; + } + + public void setRadius(Double radius) { + this.radius = radius; + } + + public Integer getDenoise() { + return denoise; + } + + public void setDenoise(Integer denoise) { + this.denoise = denoise; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/CoordType.java b/src/main/java/com/baidubce/services/dugo/model/CoordType.java new file mode 100644 index 00000000..c9ba99ec --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/CoordType.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Coord type + */ +public enum CoordType { + bd09ll("bd09ll"), wgs84("wgs84"), gcj02("gcj02"); + + private String coordType; + + CoordType(String coordType) { + this.coordType = coordType; + } + + public String getValue() { + return coordType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/DistrictFenceOption.java b/src/main/java/com/baidubce/services/dugo/model/DistrictFenceOption.java new file mode 100644 index 00000000..bac3a4fd --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/DistrictFenceOption.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Option for district fence + */ +public class DistrictFenceOption { + private String district; + private Integer denoise; + + public DistrictFenceOption(String district) { + this.district = district; + } + + public DistrictFenceOption(String district, Integer denoise) { + this.district = district; + this.denoise = denoise; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public Integer getDenoise() { + return denoise; + } + + public void setDenoise(Integer denoise) { + this.denoise = denoise; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/FenceAlertCondition.java b/src/main/java/com/baidubce/services/dugo/model/FenceAlertCondition.java new file mode 100644 index 00000000..9cd0997d --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/FenceAlertCondition.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Condition for fence alert + */ +public enum FenceAlertCondition { + IN("IN"), OUT("OUT"), IN_OUT("IN_OUT"); + + private String alertCondition; + + FenceAlertCondition(String alertCondition) { + this.alertCondition = alertCondition; + } + + public String getAlertCondition() { + return alertCondition; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/FenceType.java b/src/main/java/com/baidubce/services/dugo/model/FenceType.java new file mode 100644 index 00000000..f4ee6803 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/FenceType.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Fence type + */ +public enum FenceType { + CIRCLE("CIRCLE"), POLYGON("POLYGON"), POLYLINE("POLYLINE"), DISTRICT("DISTRICT"); + + private String fenceType; + + FenceType(String fenceType) { + this.fenceType = fenceType; + } + + public String getFenceType() { + return fenceType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/MonitoredObjectType.java b/src/main/java/com/baidubce/services/dugo/model/MonitoredObjectType.java new file mode 100644 index 00000000..1de3cb20 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/MonitoredObjectType.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +/** + * Monitored object type + */ +public enum MonitoredObjectType { + VEHICLE("VEHICLE"), BATCH("BATCH"); + + private String objectType; + + MonitoredObjectType(String objectType) { + this.objectType = objectType; + } + + public String getValue() { + return objectType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/PolygonFenceOption.java b/src/main/java/com/baidubce/services/dugo/model/PolygonFenceOption.java new file mode 100644 index 00000000..5cf4378d --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/PolygonFenceOption.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +import java.util.List; + +/** + * Option for polygon fence + */ +public class PolygonFenceOption { + private List points; + private Integer denoise; + + public PolygonFenceOption(List points) { + this.points = points; + } + + public List getPoints() { + return points; + } + + public void setPoints(List points) { + this.points = points; + } + + public Integer getDenoise() { + return denoise; + } + + public void setDenoise(Integer denoise) { + this.denoise = denoise; + } + + public static class Point { + private double longitude; + private double latitude; + + public Point(double longitude, double latitude) { + this.longitude = longitude; + this.latitude = latitude; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/model/PolylineFenceOption.java b/src/main/java/com/baidubce/services/dugo/model/PolylineFenceOption.java new file mode 100644 index 00000000..8ae7dc84 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/model/PolylineFenceOption.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.model; + +import java.util.List; + +/** + * Option for polyline fence + */ +public class PolylineFenceOption { + private List points; + private Integer offset; + private Integer denoise; + + public PolylineFenceOption(List points, Integer offset, Integer denoise) { + this.points = points; + this.offset = offset; + this.denoise = denoise; + } + + public List getPoints() { + return points; + } + + public void setPoints(List points) { + this.points = points; + } + + public Integer getOffset() { + return offset; + } + + public void setOffset(Integer offset) { + this.offset = offset; + } + + public Integer getDenoise() { + return denoise; + } + + public void setDenoise(Integer denoise) { + this.denoise = denoise; + } + + public static class Point { + private double longitude; + private double latitude; + + public Point(double longitude, double latitude) { + this.longitude = longitude; + this.latitude = latitude; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/ActivateDeviceRequest.java b/src/main/java/com/baidubce/services/dugo/project/ActivateDeviceRequest.java new file mode 100644 index 00000000..840bfc8d --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/ActivateDeviceRequest.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * 批量激活设备请求 + */ +public class ActivateDeviceRequest extends AbstractDuGoRequest { + private List deviceIds; + + public ActivateDeviceRequest(List deviceIds) { + this.deviceIds = deviceIds; + } + + public List getDeviceIds() { + return deviceIds; + } + + public void setDeviceIds(List deviceIds) { + this.deviceIds = deviceIds; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/BatchAddDeviceRequest.java b/src/main/java/com/baidubce/services/dugo/project/BatchAddDeviceRequest.java new file mode 100644 index 00000000..90f7c9dd --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/BatchAddDeviceRequest.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * 批量将设备添加到用户账号下的请求 + */ +public class BatchAddDeviceRequest extends AbstractDuGoRequest { + private List deviceBindInfoList; + + public BatchAddDeviceRequest(List deviceBindInfoList) { + this.deviceBindInfoList = deviceBindInfoList; + } + + public List getDeviceBindInfoList() { + return deviceBindInfoList; + } + + public void setDeviceBindInfoList(List deviceBindInfoList) { + this.deviceBindInfoList = deviceBindInfoList; + } + + public static class DeviceBindInfo { + private String pk; + private String dn; + private String sign; + + public DeviceBindInfo(String pk, String dn, String sign) { + this.pk = pk; + this.dn = dn; + this.sign = sign; + } + + public String getPk() { + return pk; + } + + public void setPk(String pk) { + this.pk = pk; + } + + public String getDn() { + return dn; + } + + public void setDn(String dn) { + this.dn = dn; + } + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/BatchBindVehicleRequest.java b/src/main/java/com/baidubce/services/dugo/project/BatchBindVehicleRequest.java new file mode 100644 index 00000000..f946d654 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/BatchBindVehicleRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; +import java.util.Map; + +/** + * Batch bind vehicles request + */ +public class BatchBindVehicleRequest extends AbstractDuGoRequest { + private String batchId; + private List vehicleIds; + // needed only for GB/T 32960 protocol vehicles + private Map iccids; + + public String getBatchId() { + return batchId; + } + + public void setBatchId(String batchId) { + this.batchId = batchId; + } + + public List getVehicleIds() { + return vehicleIds; + } + + public void setVehicleIds(List vehicleIds) { + this.vehicleIds = vehicleIds; + } + + public Map getIccids() { + return iccids; + } + + public void setIccids(Map iccids) { + this.iccids = iccids; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/BatchRemoveDeviceRequest.java b/src/main/java/com/baidubce/services/dugo/project/BatchRemoveDeviceRequest.java new file mode 100644 index 00000000..b64c84a4 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/BatchRemoveDeviceRequest.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * 批量将设备从用户账号下移除的请求 + */ +public class BatchRemoveDeviceRequest extends AbstractDuGoRequest { + private List deviceIds; + + public BatchRemoveDeviceRequest(List deviceIds) { + this.deviceIds = deviceIds; + } + + public List getDeviceIds() { + return deviceIds; + } + + public void setDeviceIds(List deviceIds) { + this.deviceIds = deviceIds; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/BatchUnbindVehiclesRequest.java b/src/main/java/com/baidubce/services/dugo/project/BatchUnbindVehiclesRequest.java new file mode 100644 index 00000000..cf60e937 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/BatchUnbindVehiclesRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * Batch unbind vehicles request + */ +public class BatchUnbindVehiclesRequest extends AbstractDuGoRequest { + private String projectId; + private List vehicleIds; + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public List getVehicleIds() { + return vehicleIds; + } + + public void setVehicleIds(List vehicleIds) { + this.vehicleIds = vehicleIds; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/DeviceShadowResponse.java b/src/main/java/com/baidubce/services/dugo/project/DeviceShadowResponse.java new file mode 100644 index 00000000..4fa0310b --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/DeviceShadowResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Response for query device shadow + */ +public class DeviceShadowResponse extends AbstractBceResponse { + private JsonNode data; + private JsonNode lastUpdatedTime; + + public JsonNode getData() { + return data; + } + + public void setData(JsonNode data) { + this.data = data; + } + + public JsonNode getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(JsonNode lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/DownloadAuthInfoResponse.java b/src/main/java/com/baidubce/services/dugo/project/DownloadAuthInfoResponse.java new file mode 100644 index 00000000..b88296ef --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/DownloadAuthInfoResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Download mqtt auth info response + */ +public class DownloadAuthInfoResponse extends AbstractBceResponse { + private String downloadUrl; + + public String getDownloadUrl() { + return downloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/GetBatchListResponse.java b/src/main/java/com/baidubce/services/dugo/project/GetBatchListResponse.java new file mode 100644 index 00000000..87d9c6a3 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/GetBatchListResponse.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.Date; +import java.util.List; + +/** + * Query batch list response + */ +public class GetBatchListResponse extends AbstractBceResponse { + private Meta meta; + private List data; + + public Meta getMeta() { + return meta; + } + + public void setMeta(Meta meta) { + this.meta = meta; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class Meta { + private long total; + private List address; + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public List getAddress() { + return address; + } + + public void setAddress(List address) { + this.address = address; + } + } + + public static class BatchInfoVo { + private String id; + private Integer totalQuota; + private Date createTime; + private Date expireTime; + private String status; + private String description; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getTotalQuota() { + return totalQuota; + } + + public void setTotalQuota(Integer totalQuota) { + this.totalQuota = totalQuota; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getExpireTime() { + return expireTime; + } + + public void setExpireTime(Date expireTime) { + this.expireTime = expireTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/GetProjectByIdResponse.java b/src/main/java/com/baidubce/services/dugo/project/GetProjectByIdResponse.java new file mode 100644 index 00000000..57e66d93 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/GetProjectByIdResponse.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response for project query + */ +public class GetProjectByIdResponse extends AbstractBceResponse { + private ProjectInfoVo data; + + public ProjectInfoVo getData() { + return data; + } + + public void setData(ProjectInfoVo data) { + this.data = data; + } + + public static class ProjectInfoVo { + private String id; + private String name; + private Integer type; + private String region; + private String protocol; + private Integer totalQuota; + private Integer usedQuota; + private List address; + private Boolean otaEnabled; + private String otaId; + private String otaSecret; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public Integer getTotalQuota() { + return totalQuota; + } + + public void setTotalQuota(Integer totalQuota) { + this.totalQuota = totalQuota; + } + + public Integer getUsedQuota() { + return usedQuota; + } + + public void setUsedQuota(Integer usedQuota) { + this.usedQuota = usedQuota; + } + + public List getAddress() { + return address; + } + + public void setAddress(List address) { + this.address = address; + } + + public Boolean getOtaEnabled() { + return otaEnabled; + } + + public void setOtaEnabled(Boolean otaEnabled) { + this.otaEnabled = otaEnabled; + } + + public String getOtaId() { + return otaId; + } + + public void setOtaId(String otaId) { + this.otaId = otaId; + } + + public String getOtaSecret() { + return otaSecret; + } + + public void setOtaSecret(String otaSecret) { + this.otaSecret = otaSecret; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/GetProjectListResponse.java b/src/main/java/com/baidubce/services/dugo/project/GetProjectListResponse.java new file mode 100644 index 00000000..ca9d981f --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/GetProjectListResponse.java @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response for project list query + */ +public class GetProjectListResponse extends AbstractBceResponse { + private Meta meta; + private List data; + + public Meta getMeta() { + return meta; + } + + public void setMeta(Meta meta) { + this.meta = meta; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class Meta { + private long total; + private long totalQuota; + private long usedQuota; + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public long getTotalQuota() { + return totalQuota; + } + + public void setTotalQuota(long totalQuota) { + this.totalQuota = totalQuota; + } + + public long getUsedQuota() { + return usedQuota; + } + + public void setUsedQuota(long usedQuota) { + this.usedQuota = usedQuota; + } + } + + public static class ProjectInfoVo { + private String id; + private String name; + private Integer type; + private String region; + private String protocol; + private Integer totalQuota; + private Integer usedQuota; + private List address; + private Boolean otaEnabled; + private String otaId; + private String otaSecret; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public Integer getTotalQuota() { + return totalQuota; + } + + public void setTotalQuota(Integer totalQuota) { + this.totalQuota = totalQuota; + } + + public Integer getUsedQuota() { + return usedQuota; + } + + public void setUsedQuota(Integer usedQuota) { + this.usedQuota = usedQuota; + } + + public List getAddress() { + return address; + } + + public void setAddress(List address) { + this.address = address; + } + + public Boolean getOtaEnabled() { + return otaEnabled; + } + + public void setOtaEnabled(Boolean otaEnabled) { + this.otaEnabled = otaEnabled; + } + + public String getOtaId() { + return otaId; + } + + public void setOtaId(String otaId) { + this.otaId = otaId; + } + + public String getOtaSecret() { + return otaSecret; + } + + public void setOtaSecret(String otaSecret) { + this.otaSecret = otaSecret; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/GroupDeviceShadowResponse.java b/src/main/java/com/baidubce/services/dugo/project/GroupDeviceShadowResponse.java new file mode 100644 index 00000000..bd966086 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/GroupDeviceShadowResponse.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.List; + +/** + * Response for querying a group of devices + */ +public class GroupDeviceShadowResponse extends AbstractBceResponse { + private long amount; + private int pageNo; + private int pageSize; + private List list; + + public long getAmount() { + return amount; + } + + public void setAmount(long amount) { + this.amount = amount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public static class DeviceShadow { + private JsonNode data; + private JsonNode lastUpdatedTime; + + public JsonNode getData() { + return data; + } + + public void setData(JsonNode data) { + this.data = data; + } + + public JsonNode getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(JsonNode lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/QueryDeviceHistoryRequest.java b/src/main/java/com/baidubce/services/dugo/project/QueryDeviceHistoryRequest.java new file mode 100644 index 00000000..d4188794 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/QueryDeviceHistoryRequest.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.ArrayList; +import java.util.List; + +/** + * Response for querying device history + */ +public class QueryDeviceHistoryRequest extends AbstractDuGoRequest { + private String deviceId; + private List fields = new ArrayList(); + private String groupId; + private Long start; + private Long end; + private String order = "Asc"; + private Integer limit = 0; + private String marker = null; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public Long getStart() { + return start; + } + + public void setStart(Long start) { + this.start = start; + } + + public Long getEnd() { + return end; + } + + public void setEnd(Long end) { + this.end = end; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/QueryDeviceHistoryResponse.java b/src/main/java/com/baidubce/services/dugo/project/QueryDeviceHistoryResponse.java new file mode 100644 index 00000000..0682d090 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/QueryDeviceHistoryResponse.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.List; + +/** + * Response for querying device history + */ +public class QueryDeviceHistoryResponse extends AbstractBceResponse { + private boolean truncated; + private String marker; + private List dataList; + + public boolean isTruncated() { + return truncated; + } + + public void setTruncated(boolean truncated) { + this.truncated = truncated; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public List getDataList() { + return dataList; + } + + public void setDataList(List dataList) { + this.dataList = dataList; + } + + public static class IvcTsdbDataNode { + private long timestamp; + private String vehicleId; + private JsonNode data; + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public JsonNode getData() { + return data; + } + + public void setData(JsonNode data) { + this.data = data; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/QueryDeviceResponse.java b/src/main/java/com/baidubce/services/dugo/project/QueryDeviceResponse.java new file mode 100644 index 00000000..a41f86e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/QueryDeviceResponse.java @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.Date; +import java.util.List; + +/** + * Response for querying device info + */ +public class QueryDeviceResponse extends AbstractBceResponse { + private List data; + private int totalCount; + private int pageNo; + private int pageSize; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public static class Device { + private String deviceId; + private String pk; + private String dn; + private String endpoint; + private String aliasName; + private String schemaId; + private String groupId; + private String activateStatus; + private Date createTime; + private Date updateTime; + + public Device() { + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getPk() { + return pk; + } + + public void setPk(String pk) { + this.pk = pk; + } + + public String getDn() { + return dn; + } + + public void setDn(String dn) { + this.dn = dn; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getAliasName() { + return aliasName; + } + + public void setAliasName(String aliasName) { + this.aliasName = aliasName; + } + + public String getSchemaId() { + return schemaId; + } + + public void setSchemaId(String schemaId) { + this.schemaId = schemaId; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getActivateStatus() { + return activateStatus; + } + + public void setActivateStatus(String activateStatus) { + this.activateStatus = activateStatus; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/QueryInstancesByBatchResponse.java b/src/main/java/com/baidubce/services/dugo/project/QueryInstancesByBatchResponse.java new file mode 100644 index 00000000..cb84351a --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/QueryInstancesByBatchResponse.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; + +import java.sql.Timestamp; +import java.util.List; + +/** + * Response for querying instances by batch + */ +public class QueryInstancesByBatchResponse extends AbstractBceResponse { + private Meta meta; + private List instanceInfos; + + public Meta getMeta() { + return meta; + } + + public void setMeta(Meta meta) { + this.meta = meta; + } + + public List getInstanceInfos() { + return instanceInfos; + } + + public void setInstanceInfos(List instanceInfos) { + this.instanceInfos = instanceInfos; + } + + public static class Meta { + private long total; + private int pageNum; + private int pageSize; + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public int getPageNum() { + return pageNum; + } + + public void setPageNum(int pageNum) { + this.pageNum = pageNum; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + } + + public static class InstanceInfo { + private String userId; + private String projectId; + private String batchId; + private String instanceId; + private String vehicleId; + private String status; + private Timestamp bindTime; + private Timestamp createTime; + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public String getBatchId() { + return batchId; + } + + public void setBatchId(String batchId) { + this.batchId = batchId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Timestamp getBindTime() { + return bindTime; + } + + public void setBindTime(Timestamp bindTime) { + this.bindTime = bindTime; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/QueryMqttBindResultResponse.java b/src/main/java/com/baidubce/services/dugo/project/QueryMqttBindResultResponse.java new file mode 100644 index 00000000..74e2d8a9 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/QueryMqttBindResultResponse.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +public class QueryMqttBindResultResponse extends AbstractBceResponse { + private List data; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class BindResult { + private String id; + private String startTime; + private String endTime; + private String status; + private String download; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDownload() { + return download; + } + + public void setDownload(String download) { + this.download = download; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/RandomBindVehiclesRequest.java b/src/main/java/com/baidubce/services/dugo/project/RandomBindVehiclesRequest.java new file mode 100644 index 00000000..cb69d233 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/RandomBindVehiclesRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; +import java.util.Map; + +/** + * Random bind vehicles request + */ +public class RandomBindVehiclesRequest extends AbstractDuGoRequest { + private String projectId; + private List vehicleIds; + // needed only for GB/T 32960 protocol vehicles + private Map iccids; + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public List getVehicleIds() { + return vehicleIds; + } + + public void setVehicleIds(List vehicleIds) { + this.vehicleIds = vehicleIds; + } + + public Map getIccids() { + return iccids; + } + + public void setIccids(Map iccids) { + this.iccids = iccids; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/UpdateAliasNameRequest.java b/src/main/java/com/baidubce/services/dugo/project/UpdateAliasNameRequest.java new file mode 100644 index 00000000..af170443 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/UpdateAliasNameRequest.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * Request for updating alias of a device + */ +public class UpdateAliasNameRequest extends AbstractDuGoRequest { + private String aliasName; + + public UpdateAliasNameRequest(String aliasName) { + this.aliasName = aliasName; + } + + public String getAliasName() { + return aliasName; + } + + public void setAliasName(String aliasName) { + this.aliasName = aliasName; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/project/UpdateBatchDescRequest.java b/src/main/java/com/baidubce/services/dugo/project/UpdateBatchDescRequest.java new file mode 100644 index 00000000..d1f1100e --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/project/UpdateBatchDescRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.project; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * Update batch description request + */ +public class UpdateBatchDescRequest extends AbstractDuGoRequest { + private String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/GB32960ParamQueryRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/GB32960ParamQueryRequest.java new file mode 100644 index 00000000..df948466 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/GB32960ParamQueryRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.ArrayList; +import java.util.List; + +/** + * Request for querying GB/T 32960 vehicle parameters + */ +public class GB32960ParamQueryRequest extends AbstractDuGoRequest { + public String vin; + public String iccid; + private List paramIds = new ArrayList(); + + public String getVin() { + return vin; + } + + public void setVin(String vin) { + this.vin = vin; + } + + public String getIccid() { + return iccid; + } + + public void setIccid(String iccid) { + this.iccid = iccid; + } + + public List getParamIds() { + return paramIds; + } + + public void setParamIds(List paramIds) { + this.paramIds = paramIds; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/GB32960ParamQueryResponse.java b/src/main/java/com/baidubce/services/dugo/vehicle/GB32960ParamQueryResponse.java new file mode 100644 index 00000000..9981ca59 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/GB32960ParamQueryResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.HashMap; +import java.util.Map; + +/** + * Response for param querying + */ +public class GB32960ParamQueryResponse extends AbstractBceResponse { + private Map params = new HashMap(); + + public Map getParams() { + return params; + } + + public void setParams(Map params) { + this.params = params; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/GB32960ParamSettingRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/GB32960ParamSettingRequest.java new file mode 100644 index 00000000..19d2d1f4 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/GB32960ParamSettingRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.HashMap; +import java.util.Map; + +/** + * Request for setting params + */ +public class GB32960ParamSettingRequest extends AbstractDuGoRequest { + public String vin; + public String iccid; + private Map params = new HashMap(); + + public String getVin() { + return vin; + } + + public void setVin(String vin) { + this.vin = vin; + } + + public String getIccid() { + return iccid; + } + + public void setIccid(String iccid) { + this.iccid = iccid; + } + + public Map getParams() { + return params; + } + + public void setParams(Map params) { + this.params = params; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/GB32960VehicleControlRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/GB32960VehicleControlRequest.java new file mode 100644 index 00000000..c0fedfa0 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/GB32960VehicleControlRequest.java @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * Request for control vehicles + */ +public class GB32960VehicleControlRequest extends AbstractDuGoRequest { + public String vin; + public String iccid; + private Integer commandId; + private Object commandParam; + + public String getVin() { + return vin; + } + + public void setVin(String vin) { + this.vin = vin; + } + + public String getIccid() { + return iccid; + } + + public void setIccid(String iccid) { + this.iccid = iccid; + } + + public Integer getCommandId() { + return commandId; + } + + public void setCommandId(Integer commandId) { + this.commandId = commandId; + } + + public Object getCommandParam() { + return commandParam; + } + + public void setCommandParam(Object commandParam) { + this.commandParam = commandParam; + } + + public static class RemoteUpgradeCommand { + private String dialPointName; + private String dialUsername; + private String dialPassword; + private String serverAddress; + private long serverPort; + private String terminalManufacturer; + private String hardwareVersion; + private String firmwareVersion; + private String upgradeUrl; + private long connectionTimeout; + + public String getDialPointName() { + return dialPointName; + } + + public void setDialPointName(String dialPointName) { + this.dialPointName = dialPointName; + } + + public String getDialUsername() { + return dialUsername; + } + + public void setDialUsername(String dialUsername) { + this.dialUsername = dialUsername; + } + + public String getDialPassword() { + return dialPassword; + } + + public void setDialPassword(String dialPassword) { + this.dialPassword = dialPassword; + } + + public String getServerAddress() { + return serverAddress; + } + + public void setServerAddress(String serverAddress) { + this.serverAddress = serverAddress; + } + + public long getServerPort() { + return serverPort; + } + + public void setServerPort(long serverPort) { + this.serverPort = serverPort; + } + + public String getTerminalManufacturer() { + return terminalManufacturer; + } + + public void setTerminalManufacturer(String terminalManufacturer) { + this.terminalManufacturer = terminalManufacturer; + } + + public String getHardwareVersion() { + return hardwareVersion; + } + + public void setHardwareVersion(String hardwareVersion) { + this.hardwareVersion = hardwareVersion; + } + + public String getFirmwareVersion() { + return firmwareVersion; + } + + public void setFirmwareVersion(String firmwareVersion) { + this.firmwareVersion = firmwareVersion; + } + + public String getUpgradeUrl() { + return upgradeUrl; + } + + public void setUpgradeUrl(String upgradeUrl) { + this.upgradeUrl = upgradeUrl; + } + + public long getConnectionTimeout() { + return connectionTimeout; + } + + public void setConnectionTimeout(long connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + } + + public static class AlarmCommand { + private int alarmLevel; + private Object alarmInfo; + + public int getAlarmLevel() { + return alarmLevel; + } + + public void setAlarmLevel(int alarmLevel) { + this.alarmLevel = alarmLevel; + } + + public Object getAlarmInfo() { + return alarmInfo; + } + + public void setAlarmInfo(Object alarmInfo) { + this.alarmInfo = alarmInfo; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/HistoryInfoQueryRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/HistoryInfoQueryRequest.java new file mode 100644 index 00000000..0c0091d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/HistoryInfoQueryRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.ArrayList; +import java.util.List; + +/** + * Request for querying vehicle history + */ +public class HistoryInfoQueryRequest extends AbstractDuGoRequest { + private List vehicleIds; + private Long start; + private Long end; + private List fields = new ArrayList(); + private String order = "Asc"; + private Integer limit = 0; + private String marker = null; + + public List getVehicleIds() { + return vehicleIds; + } + + public void setVehicleIds(List vehicleIds) { + this.vehicleIds = vehicleIds; + } + + public long getStart() { + return start; + } + + public void setStart(long start) { + this.start = start; + } + + public long getEnd() { + return end; + } + + public void setEnd(long end) { + this.end = end; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public int getLimit() { + return limit; + } + + public void setLimit(int limit) { + this.limit = limit; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/HistoryInfoQueryResponse.java b/src/main/java/com/baidubce/services/dugo/vehicle/HistoryInfoQueryResponse.java new file mode 100644 index 00000000..31c6960f --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/HistoryInfoQueryResponse.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.List; + +/** + * Response for query vehicle history + */ +public class HistoryInfoQueryResponse extends AbstractBceResponse { + private boolean truncated; + private String marker; + private List dataList; + + public boolean isTruncated() { + return truncated; + } + + public void setTruncated(boolean truncated) { + this.truncated = truncated; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public List getDataList() { + return dataList; + } + + public void setDataList(List dataList) { + this.dataList = dataList; + } + + public static class IvcTsdbDataNode { + private long timestamp; + private String vehicleId; + private JsonNode data; + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public JsonNode getData() { + return data; + } + + public void setData(JsonNode data) { + this.data = data; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/QueryMultipleShadowRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/QueryMultipleShadowRequest.java new file mode 100644 index 00000000..8573c545 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/QueryMultipleShadowRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * multiple shadow request model + * Created by liuzhenxing01 on 2018/10/18. + */ +public class QueryMultipleShadowRequest extends AbstractDuGoRequest { + private List vehicleIds; + private List fields; + + public List getVehicleIds() { + return vehicleIds; + } + + public void setVehicleIds(List vehicleIds) { + this.vehicleIds = vehicleIds; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/QueryMultipleShadowResponse.java b/src/main/java/com/baidubce/services/dugo/vehicle/QueryMultipleShadowResponse.java new file mode 100644 index 00000000..4116a54f --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/QueryMultipleShadowResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.List; + +/** + * Response for query multiple shadow + */ +public class QueryMultipleShadowResponse extends AbstractBceResponse { + private List data; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/QuerySingleShadowRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/QuerySingleShadowRequest.java new file mode 100644 index 00000000..438327bc --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/QuerySingleShadowRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * single shadow request and response + * Created by liuzhenxing01 on 2018/10/18. + */ +public class QuerySingleShadowRequest extends AbstractDuGoRequest { + private String vehicleId; + private List fields; + private boolean needUpdateTime; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public boolean isNeedUpdateTime() { + return needUpdateTime; + } + + public void setNeedUpdateTime(boolean needUpdateTime) { + this.needUpdateTime = needUpdateTime; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/QuerySingleShadowResponse.java b/src/main/java/com/baidubce/services/dugo/vehicle/QuerySingleShadowResponse.java new file mode 100644 index 00000000..c656f6f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/QuerySingleShadowResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Response for querying single shadow + */ +public class QuerySingleShadowResponse extends AbstractBceResponse { + private String vehicleId; + private JsonNode data; + private JsonNode lastUpdatedTime; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public JsonNode getData() { + return data; + } + + public void setData(JsonNode data) { + this.data = data; + } + + public JsonNode getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(JsonNode lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/QueryVehicleStatusRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/QueryVehicleStatusRequest.java new file mode 100644 index 00000000..0ae86f53 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/QueryVehicleStatusRequest.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; + +/** + * query the vehicle status online + * Created by liuzhenxing01 on 2018/10/31. + */ +public class QueryVehicleStatusRequest extends AbstractDuGoRequest { + private List vehicleIds; + + public List getVehicleIds() { + return vehicleIds; + } + + public void setVehicleIds(List vehicleIds) { + this.vehicleIds = vehicleIds; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/QueryVehicleStatusResponse.java b/src/main/java/com/baidubce/services/dugo/vehicle/QueryVehicleStatusResponse.java new file mode 100644 index 00000000..0fc59200 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/QueryVehicleStatusResponse.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response for query vehicle status + */ +public class QueryVehicleStatusResponse extends AbstractBceResponse { + private List data; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class Vehicle { + private String vehicleId; + private String status; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/SchemaAttributeNameResponse.java b/src/main/java/com/baidubce/services/dugo/vehicle/SchemaAttributeNameResponse.java new file mode 100644 index 00000000..ba96b271 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/SchemaAttributeNameResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Response for query attribute name by display name + */ +public class SchemaAttributeNameResponse extends AbstractBceResponse { + private String displayName; + private List attributeNames; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public List getAttributeNames() { + return attributeNames; + } + + public void setAttributeNames(List attributeNames) { + this.attributeNames = attributeNames; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/SchemaDisplayNameResponse.java b/src/main/java/com/baidubce/services/dugo/vehicle/SchemaDisplayNameResponse.java new file mode 100644 index 00000000..29436db0 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/SchemaDisplayNameResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Response for querying display name by attribute name + */ +public class SchemaDisplayNameResponse extends AbstractBceResponse { + private String attributeName; + private String displayName; + + public String getAttributeName() { + return attributeName; + } + + public void setAttributeName(String attributeName) { + this.attributeName = attributeName; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/ShadowFilterRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/ShadowFilterRequest.java new file mode 100644 index 00000000..fcc55062 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/ShadowFilterRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.List; +import java.util.Map; + +/** + * filter shadow reqeust + * Created by liuzhenxing01 on 2018/10/22. + */ +public class ShadowFilterRequest extends AbstractDuGoRequest { + private Integer pageNo; + private Integer pageSize; + private String projectId; + private Map tags; + private List fields; + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public Map getTags() { + return tags; + } + + public void setTags(Map tags) { + this.tags = tags; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/ShadowFilterResponse.java b/src/main/java/com/baidubce/services/dugo/vehicle/ShadowFilterResponse.java new file mode 100644 index 00000000..6544763c --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/ShadowFilterResponse.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.List; + +/** + * Response for shadow filter + */ +public class ShadowFilterResponse extends AbstractBceResponse { + private long amount; + private int pageNo; + private int pageSize; + private List data; + + public long getAmount() { + return amount; + } + + public void setAmount(long amount) { + this.amount = amount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/UploadDynamicDataRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/UploadDynamicDataRequest.java new file mode 100644 index 00000000..213643f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/UploadDynamicDataRequest.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Vehicle dynamic attribute upload request + * Created by liuzhenxing01 on 2018/10/19. + */ +public class UploadDynamicDataRequest extends AbstractDuGoRequest { + public static final String LATITUDE = "latitude"; + public static final String LONGITUDE = "longitude"; + public static final String SPEED = "speed"; + public static final String DIRECTION = "direction"; + public static final String HEIGHT = "height"; + public static final String RADIUS = "radius"; + public static final String COORD_TYPE_INPUT = "coordTypeInput"; + + private List points; + + public List getPoints() { + return points; + } + + public void setPoints(List points) { + this.points = points; + } + + public static class PointData { + private Long locTime; + private String vehicleId; + private Map data = new HashMap(); + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Map getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } + + public void setLatitude(Double latitude) { + data.put(LATITUDE, latitude); + } + + public void setLongitude(Double longitude) { + data.put(LONGITUDE, longitude); + } + + public void setCoordTypeInput(String coordTypeInput) { + data.put(COORD_TYPE_INPUT, coordTypeInput); + } + + public void setSpeed(Double speed) { + data.put(SPEED, speed); + } + + public void setDirection(Integer direction) { + data.put(DIRECTION, direction); + } + + public void setHeight(Double height) { + data.put(HEIGHT, height); + } + + public void setRadius(Double radius) { + data.put(RADIUS, radius); + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/vehicle/UploadStaticDataRequest.java b/src/main/java/com/baidubce/services/dugo/vehicle/UploadStaticDataRequest.java new file mode 100644 index 00000000..da90094d --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/vehicle/UploadStaticDataRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dugo.vehicle; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +import java.util.Map; + +/** + * Static Data Request + * Created by liuzhenxing01 on 2018/10/18. + */ +public class UploadStaticDataRequest extends AbstractDuGoRequest { + private String vehicleId; + private Map data; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Map getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/AlarmInfoByTimeRequest.java b/src/main/java/com/baidubce/services/dugo/video/AlarmInfoByTimeRequest.java new file mode 100644 index 00000000..4a84ee9b --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/AlarmInfoByTimeRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * alarm info by time request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:42 + */ +public class AlarmInfoByTimeRequest extends AbstractDuGoRequest { + private Long startTime; + private Long endTime; + private List alarmTypeList = new ArrayList(); + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public List getAlarmTypeList() { + return alarmTypeList; + } + + public void setAlarmTypeList(List alarmTypeList) { + this.alarmTypeList = alarmTypeList; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/AlarmInfoByVehicleIdListRequest.java b/src/main/java/com/baidubce/services/dugo/video/AlarmInfoByVehicleIdListRequest.java new file mode 100644 index 00000000..c86c53b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/AlarmInfoByVehicleIdListRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * alarm info by vehicleId list request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:44 + */ +public class AlarmInfoByVehicleIdListRequest extends AbstractDuGoRequest { + private List vehicleIdList; + private Long startTime; + private Long endTime; + private List alarmTypeList = new ArrayList(); + + public List getVehicleIdList() { + return vehicleIdList; + } + + public void setVehicleIdList(List vehicleIdList) { + this.vehicleIdList = vehicleIdList; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public List getAlarmTypeList() { + return alarmTypeList; + } + + public void setAlarmTypeList(List alarmTypeList) { + this.alarmTypeList = alarmTypeList; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/AlarmInfoListResponse.java b/src/main/java/com/baidubce/services/dugo/video/AlarmInfoListResponse.java new file mode 100644 index 00000000..e9445b78 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/AlarmInfoListResponse.java @@ -0,0 +1,104 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * alarm info list response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:57 + */ +public class AlarmInfoListResponse extends AbstractBceResponse { + private List alarmInfoList; + + public List getAlarmInfoList() { + return alarmInfoList; + } + + public void setAlarmInfoList(List alarmInfoList) { + this.alarmInfoList = alarmInfoList; + } + + public static class AlarmInfo { + private Long alarmTime; + private String alarmType; + private String vehicleId; + private String vehicleName; + private String groupName; + private double longitude; + private double latitude; + private String alarmRefKey; + + public Long getAlarmTime() { return alarmTime; } + + private void setAlarmTime(Long alarmTime) { this.alarmTime = alarmTime; } + + public String getAlarmType() { + return alarmType; + } + + public void setAlarmType(String alarmType) { + this.alarmType = alarmType; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getVehicleName() { + return vehicleName; + } + + public void setVehicleName(String vehicleName) { + this.vehicleName = vehicleName; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getAlarmRefKey() { + return alarmRefKey; + } + + public void setAlarmRefKey(String alarmRefKey) { + this.alarmRefKey = alarmRefKey; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/AlarmTrackInfo.java b/src/main/java/com/baidubce/services/dugo/video/AlarmTrackInfo.java new file mode 100644 index 00000000..5e18681c --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/AlarmTrackInfo.java @@ -0,0 +1,110 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.sql.Timestamp; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * alarm track info + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:02 + */ +public class AlarmTrackInfo extends AbstractBceResponse { + private double longitude; // 报警经度为主 + private double latitude; // 报警纬度为主 + private double speed; + private Long alarmTime; // 以报警时间为主 + private String alarmUuid; + private String alarmType; + private List trackMediaInfoList; + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed = speed; + } + + public Long getAlarmTime() { + return alarmTime; + } + + public void setAlarmTime(Long alarmTime) { + this.alarmTime = alarmTime; + } + + public String getAlarmUuid() { + return alarmUuid; + } + + public void setAlarmUuid(String alarmUuid) { + this.alarmUuid = alarmUuid; + } + + public String getAlarmType() { + return alarmType; + } + + public void setAlarmType(String alarmType) { + this.alarmType = alarmType; + } + + public List getTrackMediaInfoList() { + return trackMediaInfoList; + } + + public void setTrackMediaInfoList( + List trackMediaInfoList) { + this.trackMediaInfoList = trackMediaInfoList; + } + + public static class TrackMediaInfo { + private String mediaUuid; + private String mediaType; + + public String getMediaUuid() { + return mediaUuid; + } + + public void setMediaUuid(String mediaUuid) { + this.mediaUuid = mediaUuid; + } + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfo.java b/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfo.java new file mode 100644 index 00000000..495fd03d --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfo.java @@ -0,0 +1,199 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.sql.Timestamp; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * alarm video info + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:03 + */ +public class AlarmVideoInfo extends AbstractBceResponse { + private double longitude; // 纬度 + private double latitude; // 经度 + private String alarmType; // 报警类型 + private String alarmUuid; // 报警id + private Long alarmTime; // 报警时间 + private String vehicleId; // 车辆id + private String vehicleName; // 车辆别名 + private String groupName; // 设备组名称 + private List mediaInfoList; // 根据报警 获取 视频信息 + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getAlarmType() { + return alarmType; + } + + public void setAlarmType(String alarmType) { + this.alarmType = alarmType; + } + + public String getAlarmUuid() { + return alarmUuid; + } + + public void setAlarmUuid(String alarmUuid) { + this.alarmUuid = alarmUuid; + } + + public Long getAlarmTime() { + return alarmTime; + } + + public void setAlarmTime(Long alarmTime) { + this.alarmTime = alarmTime; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getVehicleName() { + return vehicleName; + } + + public void setVehicleName(String vehicleName) { + this.vehicleName = vehicleName; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public List getMediaInfoList() { + return mediaInfoList; + } + + public void setMediaInfoList(List mediaInfoList) { + this.mediaInfoList = mediaInfoList; + } + + public static class VideoInfo { + private String mediaUuid; // 视频id + private int channelNum; // 通道号 + private Long startTime; // 视频开始时间 + private Long endTime; // 视频结束时间 + private String fileName; // 视频文件名 + private int fileSize; // 文件大小 + private String status; // 存储位置 + private String mediaType; // 视频类型 + private String streamType; // 码流 + private long duration; // 时长 + + public String getMediaUuid() { + return mediaUuid; + } + + public void setMediaUuid(String mediaUuid) { + this.mediaUuid = mediaUuid; + } + + public int getChannelNum() { + return channelNum; + } + + public void setChannelNum(int channelNum) { + this.channelNum = channelNum; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public int getFileSize() { + return fileSize; + } + + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getStreamType() { + return streamType; + } + + public void setStreamType(String streamType) { + this.streamType = streamType; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfoByVehicleIdListRequest.java b/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfoByVehicleIdListRequest.java new file mode 100644 index 00000000..40d230c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfoByVehicleIdListRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * alarm video info by vehicleId list request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:45 + */ +public class AlarmVideoInfoByVehicleIdListRequest extends AbstractDuGoRequest { + private List vehicleIdList; + private Long startTime; + private Long endTime; + private List alarmTypeList = new ArrayList(); + + public List getVehicleIdList() { + return vehicleIdList; + } + + public void setVehicleIdList(List vehicleIdList) { + this.vehicleIdList = vehicleIdList; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public List getAlarmTypeList() { + return alarmTypeList; + } + + public void setAlarmTypeList(List alarmTypeList) { + this.alarmTypeList = alarmTypeList; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfoByVehicleIdRequest.java b/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfoByVehicleIdRequest.java new file mode 100644 index 00000000..d13fd7b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfoByVehicleIdRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * alarm video info by vehicleId request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:50 + */ +public class AlarmVideoInfoByVehicleIdRequest extends AbstractDuGoRequest { + private String vehicleId; + private Long startTime; + private Long endTime; + private List alarmTypeList = new ArrayList(); + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public List getAlarmTypeList() { + return alarmTypeList; + } + + public void setAlarmTypeList(List alarmTypeList) { + this.alarmTypeList = alarmTypeList; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfoListResponse.java b/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfoListResponse.java new file mode 100644 index 00000000..3e1c3406 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/AlarmVideoInfoListResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * alarm video info list response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:05 + */ +public class AlarmVideoInfoListResponse extends AbstractBceResponse { + List alarmVideoInfoList; + + public List getAlarmVideoInfoList() { + return alarmVideoInfoList; + } + + public void setAlarmVideoInfoList(List alarmVideoInfoList) { + this.alarmVideoInfoList = alarmVideoInfoList; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/FileNameRequest.java b/src/main/java/com/baidubce/services/dugo/video/FileNameRequest.java new file mode 100644 index 00000000..e1abc3c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/FileNameRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * file name request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:37 + */ +public class FileNameRequest extends AbstractDuGoRequest { + private String fileName; // 需要上传的文件名 + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/FileUploadResponse.java b/src/main/java/com/baidubce/services/dugo/video/FileUploadResponse.java new file mode 100644 index 00000000..4369ed2c --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/FileUploadResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import com.baidubce.model.AbstractBceResponse; + +/** + * file upload response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:06 + */ +public class FileUploadResponse extends AbstractBceResponse { + private String taskId; + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/GetDownloadUrlResponse.java b/src/main/java/com/baidubce/services/dugo/video/GetDownloadUrlResponse.java new file mode 100644 index 00000000..ebea2b3a --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/GetDownloadUrlResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import com.baidubce.model.AbstractBceResponse; + +/** + * get download url response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:07 + */ +public class GetDownloadUrlResponse extends AbstractBceResponse { + private String address; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/GetMediaInfoListResponse.java b/src/main/java/com/baidubce/services/dugo/video/GetMediaInfoListResponse.java new file mode 100644 index 00000000..eaf385b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/GetMediaInfoListResponse.java @@ -0,0 +1,160 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.sql.Timestamp; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * get media info list response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:08 + */ +public class GetMediaInfoListResponse extends AbstractBceResponse { + private String vehicleId; // 车辆id + private String vehicleName; // 车辆名称 + private String groupName; // 设备组名称 + private List videoInfoList; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getVehicleName() { return vehicleName; } + + public void setVehicleName(String vehicleName) { this.vehicleName = vehicleName; } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public List getVideoInfoList() { + return videoInfoList; + } + + public void setVideoInfoList( + List videoInfoList) { + this.videoInfoList = videoInfoList; + } + + public static class MediaInfo { + private String mediaUuid; // 视频id + private int channelNum; // 通道号 + private Long startTime; // 视频开始时间 + private Long endTime; // 视频结束时间 + private String fileName; // 视频文件名 + private int fileSize; // 文件大小 + private String alarmType; // 报警类型 + private String status; // 存储位置 + private String mediaType; // 视频类型 + private String streamType; // 码流 + private long duration; // 时长 + + public String getMediaUuid() { + return mediaUuid; + } + + public void setMediaUuid(String mediaUuid) { + this.mediaUuid = mediaUuid; + } + + public int getChannelNum() { + return channelNum; + } + + public void setChannelNum(int channelNum) { + this.channelNum = channelNum; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public int getFileSize() { + return fileSize; + } + + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + public String getAlarmType() { + return alarmType; + } + + public void setAlarmType(String alarmType) { + this.alarmType = alarmType; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getStreamType() { + return streamType; + } + + public void setStreamType(String streamType) { + this.streamType = streamType; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/GetMediaInfoResponse.java b/src/main/java/com/baidubce/services/dugo/video/GetMediaInfoResponse.java new file mode 100644 index 00000000..11cafab8 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/GetMediaInfoResponse.java @@ -0,0 +1,142 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.sql.Timestamp; + +import com.baidubce.model.AbstractBceResponse; + +/** + * get media info response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:09 + */ +public class GetMediaInfoResponse extends AbstractBceResponse { + private String mediaUuid; // 视频id + private String vehicleId; // 车辆id + private String vehicleName; // 车辆名称 + private int channelNum; // 通道号 + private Long startTime; // 视频开始时间 + private Long endTime; // 视频结束时间 + private String fileName; // 视频文件名 + private int fileSize; // 文件大小 + private String alarmType; // 报警类型 + private String status; // 存储位置 + private String mediaType; // 视频类型 + private String streamType; // 码流 + private String groupName; // 设备组名称 + private long duration; // 时长 + + public String getMediaUuid() { + return mediaUuid; + } + + public void setMediaUuid(String mediaUuid) { + this.mediaUuid = mediaUuid; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public int getChannelNum() { + return channelNum; + } + + public void setChannelNum(int channelNum) { + this.channelNum = channelNum; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public int getFileSize() { + return fileSize; + } + + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + public String getAlarmType() { + return alarmType; + } + + public void setAlarmType(String alarmType) { + this.alarmType = alarmType; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getStreamType() { + return streamType; + } + + public void setStreamType(String streamType) { + this.streamType = streamType; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/GetPlayUrlResponse.java b/src/main/java/com/baidubce/services/dugo/video/GetPlayUrlResponse.java new file mode 100644 index 00000000..ab363227 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/GetPlayUrlResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import com.baidubce.model.AbstractBceResponse; + +/** + * get play url response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:09 + */ +public class GetPlayUrlResponse extends AbstractBceResponse { + private String address; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/GetTaskStatusResponse.java b/src/main/java/com/baidubce/services/dugo/video/GetTaskStatusResponse.java new file mode 100644 index 00000000..ec89fbce --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/GetTaskStatusResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import com.baidubce.model.AbstractBceResponse; + +/** + * get task status response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:09 + */ +public class GetTaskStatusResponse extends AbstractBceResponse { + /** + * UPLOADING:上传中, PROCESSING:处理中, UPLOAD_FAILED:上传失败, + * PROCESS_FAILED:处理失败, PUBLISHED:已发布 + */ + private String status; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/MediaInfoByTimeNullAlarmRequest.java b/src/main/java/com/baidubce/services/dugo/video/MediaInfoByTimeNullAlarmRequest.java new file mode 100644 index 00000000..aaec0e47 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/MediaInfoByTimeNullAlarmRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.baidubce.services.dugo.AbstractDuGoRequest; +import com.baidubce.services.dugo.video.model.StreamType; + +/** + * media info by time null alarm request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:51 + */ +public class MediaInfoByTimeNullAlarmRequest extends AbstractDuGoRequest { + private Long startTime; // 开始时间戳 + private Long endTime; // 结束时间戳 + private List statusList = new ArrayList(); // 存储位置 + private List channelList = new ArrayList(); // 通道号(默认全不选) + private String streamType = StreamType.ALL.name(); // 码流(默认全选) + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public List getStatusList() { + return statusList; + } + + public void setStatusList(List statusList) { + this.statusList = statusList; + } + + public List getChannelList() { + return channelList; + } + + public void setChannelList(List channelList) { + this.channelList = channelList; + } + + public String getStreamType() { + return streamType; + } + + public void setStreamType(String streamType) { + this.streamType = streamType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/MediaInfoByTimeRequest.java b/src/main/java/com/baidubce/services/dugo/video/MediaInfoByTimeRequest.java new file mode 100644 index 00000000..4936584f --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/MediaInfoByTimeRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.baidubce.services.dugo.AbstractDuGoRequest; +import com.baidubce.services.dugo.video.model.StreamType; + +/** + * media info by time request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:53 + */ +public class MediaInfoByTimeRequest extends AbstractDuGoRequest { + private Long startTime; // 开始时间戳 + private Long endTime; // 结束时间戳 + private List statusList = new ArrayList(); // 存储位置 + private List alarmTypeList = new ArrayList(); // 报警类型(默认全不选) + private List channelList = new ArrayList(); // 通道号(默认全不选) + private String streamType = StreamType.ALL.name(); // 码流(默认全选) + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public List getStatusList() { + return statusList; + } + + public void setStatusList(List statusList) { + this.statusList = statusList; + } + + public List getAlarmTypeList() { + return alarmTypeList; + } + + public void setAlarmTypeList(List alarmTypeList) { + this.alarmTypeList = alarmTypeList; + } + + public List getChannelList() { + return channelList; + } + + public void setChannelList(List channelList) { + this.channelList = channelList; + } + + public String getStreamType() { + return streamType; + } + + public void setStreamType(String streamType) { + this.streamType = streamType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/Meta.java b/src/main/java/com/baidubce/services/dugo/video/Meta.java new file mode 100644 index 00000000..5a4e9ad6 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/Meta.java @@ -0,0 +1,47 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +/** + * meta + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:11 + */ +public class Meta { + private int total; + private int pageNum; + private int pageSize; + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public int getPageNum() { + return pageNum; + } + + public void setPageNum(int pageNum) { + this.pageNum = pageNum; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/ParameterSettingRequest.java b/src/main/java/com/baidubce/services/dugo/video/ParameterSettingRequest.java new file mode 100644 index 00000000..39346cd6 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/ParameterSettingRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * parameter setting request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:35 + */ +public class ParameterSettingRequest extends AbstractDuGoRequest { + private String paramHex; + + public String getParamHex() { + return paramHex; + } + + public void setParamHex(String paramHex) { + this.paramHex = paramHex; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/PlaybackRequest.java b/src/main/java/com/baidubce/services/dugo/video/PlaybackRequest.java new file mode 100644 index 00000000..4d9a73fa --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/PlaybackRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.Date; + +import com.baidubce.services.dugo.AbstractDuGoRequest; +import com.baidubce.services.dugo.video.model.DataType; +import com.baidubce.services.dugo.video.model.StorageType; +import com.baidubce.services.dugo.video.model.StreamType; +import com.baidubce.services.dugo.video.model.VideoType; + +/** + * playback request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:12 + */ +public class PlaybackRequest extends AbstractDuGoRequest { + private String videoType = VideoType.FLV.name(); // 音视频实时流传输格式 + private String fileName; + + public String getVideoType() { + return videoType; + } + + public void setVideoType(String videoType) { + this.videoType = videoType; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/QueryParamResponse.java b/src/main/java/com/baidubce/services/dugo/video/QueryParamResponse.java new file mode 100644 index 00000000..6576505e --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/QueryParamResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import com.baidubce.model.AbstractBceResponse; + +/** + * query param response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:12 + */ +public class QueryParamResponse extends AbstractBceResponse { + private String paramHex; + + public String getParamHex() { + return paramHex; + } + + public void setParamHex(String paramHex) { + this.paramHex = paramHex; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/RealTimeRequest.java b/src/main/java/com/baidubce/services/dugo/video/RealTimeRequest.java new file mode 100644 index 00000000..cc102077 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/RealTimeRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import com.baidubce.services.dugo.AbstractDuGoRequest; +import com.baidubce.services.dugo.video.model.RealDataType; +import com.baidubce.services.dugo.video.model.RealStreamType; +import com.baidubce.services.dugo.video.model.VideoType; + +/** + * real time request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:07 + */ +public class RealTimeRequest extends AbstractDuGoRequest { + private String dataType = RealDataType.BOTH.name(); // 实时监控数据类型 + private String streamType = RealStreamType.MAIN_STREAM.name(); // 实时监控码流类型 + private String videoType = VideoType.FLV.name(); // 实时监控音视频格式 + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public String getStreamType() { + return streamType; + } + + public void setStreamType(String streamType) { + this.streamType = streamType; + } + + public String getVideoType() { + return videoType; + } + + public void setVideoType(String videoType) { + this.videoType = videoType; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/TrackAlarmMediaInfoRequest.java b/src/main/java/com/baidubce/services/dugo/video/TrackAlarmMediaInfoRequest.java new file mode 100644 index 00000000..1bb049a3 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/TrackAlarmMediaInfoRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * track alarm media info request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:55 + */ +public class TrackAlarmMediaInfoRequest extends AbstractDuGoRequest { + private String vehicleId; + private Long startTime; + private Long endTime; + private List AlarmTypeList = new ArrayList(); + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Long getStartTime() { + return startTime; + } + + public void setStartTime(Long startTime) { + this.startTime = startTime; + } + + public Long getEndTime() { + return endTime; + } + + public void setEndTime(Long endTime) { + this.endTime = endTime; + } + + public List getAlarmTypeList() { + return AlarmTypeList; + } + + public void setAlarmTypeList(List alarmTypeList) { + AlarmTypeList = alarmTypeList; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/TrackAlarmVideoInfoResponse.java b/src/main/java/com/baidubce/services/dugo/video/TrackAlarmVideoInfoResponse.java new file mode 100644 index 00000000..2ab1187e --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/TrackAlarmVideoInfoResponse.java @@ -0,0 +1,99 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.sql.Timestamp; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * track alarm video info response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:12 + */ +public class TrackAlarmVideoInfoResponse extends AbstractBceResponse { + private String vehicleId; + private String vehicleName; + private List trackPointInfoList; + private List alarmTrackInfoList; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getVehicleName() { return vehicleName; } + + public void setVehicleName(String vehicleName) { + this.vehicleName = vehicleName; + } + + public List getTrackPointInfoList() { + return trackPointInfoList; + } + + public void setTrackPointInfoList( + List trackPointInfoList) { + this.trackPointInfoList = trackPointInfoList; + } + + public List getAlarmTrackInfoList() { + return alarmTrackInfoList; + } + + public void setAlarmTrackInfoList(List alarmTrackInfoList) { + this.alarmTrackInfoList = alarmTrackInfoList; + } + + public static class TrackPointInfo { + private double longitude; // 报警经度为主 + private double latitude; // 报警纬度为主 + private double speed; + private Long locTime; // 以报警时间为主 + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed = speed; + } + + public Long getLocTime() { + return locTime; + } + + public void setLocTime(Long locTime) { + this.locTime = locTime; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/UploadTaskListRequest.java b/src/main/java/com/baidubce/services/dugo/video/UploadTaskListRequest.java new file mode 100644 index 00000000..92997961 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/UploadTaskListRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.Date; + +import com.baidubce.services.dugo.AbstractDuGoRequest; + +/** + * upload task list request + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:39 + */ +public class UploadTaskListRequest extends AbstractDuGoRequest { + private String vehicleId; + private Date startTime; // 开始时间戳 + private Date endTime; // 结束时间戳 + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/UploadTaskListResponse.java b/src/main/java/com/baidubce/services/dugo/video/UploadTaskListResponse.java new file mode 100644 index 00000000..50a22eef --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/UploadTaskListResponse.java @@ -0,0 +1,98 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video; + +import java.util.Date; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * upload task list response + * + * @Author: shihuike + * @Date: Created in 2019-08-01 17:14 + */ +public class UploadTaskListResponse extends AbstractBceResponse { + private Meta meta; + private List data; + + public Meta getMeta() { + return meta; + } + + public void setMeta(Meta meta) { + this.meta = meta; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class UploadTaskData { + private String vehicleId; + private String vehicleName; + private String groupName; + private String status; + private String taskUuid; + private Date createTime; + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getVehicleName() { return vehicleName; } + + public void setVehicleName(String vehicleName) { + this.vehicleName = vehicleName; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTaskUuid() { + return taskUuid; + } + + public void setTaskUuid(String taskUuid) { + this.taskUuid = taskUuid; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/model/DataType.java b/src/main/java/com/baidubce/services/dugo/video/model/DataType.java new file mode 100644 index 00000000..07ab2ebe --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/model/DataType.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video.model; + +/** + * data type + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:14 + */ +public enum DataType { + VIDEO(0), // 视频 + IMAGE(1); // 图片 + + private int value; + + DataType(int value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/model/RealDataType.java b/src/main/java/com/baidubce/services/dugo/video/model/RealDataType.java new file mode 100644 index 00000000..8df960db --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/model/RealDataType.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video.model; + +/** + * real data type + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:08 + */ +public enum RealDataType { + BOTH(0), + VIDEO(1), + AUDIO(3), + CENTRAL_BROADCAST(4), + PENETRATE(5); + + private int value; + + RealDataType(int value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/model/RealStreamType.java b/src/main/java/com/baidubce/services/dugo/video/model/RealStreamType.java new file mode 100644 index 00000000..dee1fbcd --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/model/RealStreamType.java @@ -0,0 +1,28 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video.model; + +/** + * real stream type + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:10 + */ +public enum RealStreamType { + MAIN_STREAM(0), + SUB_STREAM(1); + + private int value; + + RealStreamType(int value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/model/StorageType.java b/src/main/java/com/baidubce/services/dugo/video/model/StorageType.java new file mode 100644 index 00000000..fc8dd726 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/model/StorageType.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video.model; + +/** + * storage type + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:16 + */ +public enum StorageType { + ALL(0), + MAIN_MEM(1), + BACKUP_MEM(2); + + private int value; + + StorageType(int value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/model/StreamType.java b/src/main/java/com/baidubce/services/dugo/video/model/StreamType.java new file mode 100644 index 00000000..e569f4f2 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/model/StreamType.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video.model; + +/** + * stream type + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:15 + */ +public enum StreamType { + ALL(0), + MAIN_STREAM(1), + SUB_STREAM(2); + + private int value; + + StreamType(int value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/dugo/video/model/VideoType.java b/src/main/java/com/baidubce/services/dugo/video/model/VideoType.java new file mode 100644 index 00000000..d0564302 --- /dev/null +++ b/src/main/java/com/baidubce/services/dugo/video/model/VideoType.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dugo.video.model; + +/** + * video type + * + * @Author: shihuike + * @Date: Created in 2019-08-01 16:11 + */ +public enum VideoType { + RTMP, + FLV, + HLS +} diff --git a/src/main/java/com/baidubce/services/dumap/BaseDuMapClient.java b/src/main/java/com/baidubce/services/dumap/BaseDuMapClient.java new file mode 100644 index 00000000..534ed4c4 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/BaseDuMapClient.java @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2018-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap; + +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.commons.lang3.StringUtils; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.dumap.handler.DuMapResponseHandler; +import com.baidubce.services.dumap.model.BaseDuMapResponse; +import com.baidubce.util.DateUtils; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import lombok.extern.slf4j.Slf4j; + +/** + * Base DuMap client which does the operations to call dumap server. + * + * @author weizhijun + * @date 2018/10/16 + */ +@Slf4j +public class BaseDuMapClient extends AbstractBceClient { + + private static final int DEFAULT_SOCKET_TIMEOUT = 10 * 1000; + + private static final String ENDPOINT = "http://lbs.baidubce.com"; + private static final String CONTENT_TYPE = "application/json;charset=utf-8"; + private static final String ACCEPT_TYPE = "application/json"; + private static final String APP_ID = "x-app-id"; + private static final String ACCEPT = "Accept"; + + private static final String[] HEADERS_TO_SIGN = {Headers.HOST, Headers.BCE_DATE}; + + private static HttpResponseHandler[] dumapHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new DuMapResponseHandler() + }; + + /** + * Construct a new base dumap client with the defaul configurations and handlers. + */ + public BaseDuMapClient() { + this(new BceClientConfiguration()); + } + + /** + * Construct a new base dumap client with the specified configurations and default handlers. + * + * @param config the client configuration. + */ + public BaseDuMapClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, dumapHandlers); + } + + /** + * Construct a new base dumap client with the specified access key ID and secret key. + * + * @param accessKey Access key ID. + * @param secretKey Secret key. + */ + public BaseDuMapClient(String accessKey, String secretKey) { + this(new BceClientConfiguration() + .withSocketTimeoutInMillis(DEFAULT_SOCKET_TIMEOUT) + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)) + .withEndpoint(ENDPOINT)); + } + + protected BaseDuMapResponse callDuMap(String uri, String appId, AbstractBceRequest request, Object requestParams, + HttpMethodName httpMethodName) { + return callDuMap(uri, appId, request, requestParams, httpMethodName, BodyType.FORM); + } + + protected BaseDuMapResponse callDuMap(String uri, String appId, AbstractBceRequest request, Object requestParams, + HttpMethodName httpMethodName, BodyType bodyType) { + InternalRequest internalRequest = createRequest(request, httpMethodName, bodyType, uri); + internalRequest.addHeader(APP_ID, appId); + internalRequest.addHeader(ACCEPT, ACCEPT_TYPE); + internalRequest.addHeader(Headers.BCE_DATE, DateUtils.formatAlternateIso8601Date(new Date())); + + if (requestParams != null) { + fillParams(internalRequest, requestParams); + } + return this.invokeHttpClient(internalRequest, BaseDuMapResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, BodyType bodyType, + String... pathVariables) { + List path = new ArrayList(); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest internalRequest = new InternalRequest(httpMethod, uri); + // Add sign options. + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + internalRequest.setSignOptions(signOptions); + internalRequest.setCredentials(this.config.getCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, internalRequest, bodyType); + } + return internalRequest; + } + + protected void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request, BodyType bodyType) { + byte[] content = bodyType.equals(BodyType.JSON) ? toJson(bceRequest) : toForm(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + protected byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + return getBytes(jsonStr); + } + + protected byte[] toForm(AbstractBceRequest bceRequest) { + ConcurrentHashMap map = new ConcurrentHashMap(); + Field[] fields = bceRequest.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + try { + if (field.get(bceRequest) != null && !"".equals(field.get(bceRequest).toString())) { + map.put(underscoreName(field.getName()), field.get(bceRequest)); + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + } + String formStr = toFormString(map); + return getBytes(formStr); + } + + private String toFormString(ConcurrentHashMap map) { + Iterator> i = map.entrySet().iterator(); + if (!i.hasNext()) { + return ""; + } + + StringBuffer sb = new StringBuffer(); + for (; ; ) { + Map.Entry e = i.next(); + String key = (String) e.getKey(); + Object value = e.getValue(); + sb.append(key); + sb.append('='); + sb.append(value); + if (!i.hasNext()) { + return sb.toString(); + } + sb.append("&"); + } + } + + private byte[] getBytes(String string) { + try { + return string.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } + + protected void fillParams(InternalRequest request, Object obj) { + Field[] fields = obj.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + try { + if (field.get(obj) != null && !"".equals(field.get(obj).toString())) { + safeAddQueryParam(request, underscoreName(field.getName()), field.get(obj).toString()); + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + } + } + + protected void safeAddQueryParam(InternalRequest request, String key, String value) { + if (StringUtils.isNotBlank(value)) { + request.addParameter(key, value); + } + } + + private String underscoreName(String name) { + StringBuilder result = new StringBuilder(); + if (StringUtils.isBlank(name)) { + return ""; + } + result.append(name.substring(0, 1).toLowerCase()); + for (int i = 1; i < name.length(); i++) { + String s = name.substring(i, i + 1); + if (s.equals(s.toUpperCase()) && !Character.isDigit(s.charAt(0))) { + result.append("_"); + } + result.append(s.toLowerCase()); + } + return result.toString(); + } + + public enum BodyType { + JSON, + FORM + } +} diff --git a/src/main/java/com/baidubce/services/dumap/DuMapClient.java b/src/main/java/com/baidubce/services/dumap/DuMapClient.java new file mode 100644 index 00000000..3a99b5b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/DuMapClient.java @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2018-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap; + +import org.apache.commons.lang3.StringUtils; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.http.HttpMethodName; +import com.baidubce.services.dumap.model.DirectionDrivingParam; +import com.baidubce.services.dumap.model.DirectionRidingParam; +import com.baidubce.services.dumap.model.DirectionTransitParam; +import com.baidubce.services.dumap.model.GeocoderParam; +import com.baidubce.services.dumap.model.GeoconvParam; +import com.baidubce.services.dumap.model.HardwareLocationRequest; +import com.baidubce.services.dumap.model.IPLocationParam; +import com.baidubce.services.dumap.model.PlaceDetailParam; +import com.baidubce.services.dumap.model.PlaceSearchByBoundsParam; +import com.baidubce.services.dumap.model.PlaceSearchByLocationParam; +import com.baidubce.services.dumap.model.PlaceSearchByRegionParam; +import com.baidubce.services.dumap.model.ReverseGeocoderParam; +import com.baidubce.util.Validate; + +/** + * DuMap client which provides the common service and api. + * + * @author weizhijun + * @date 2018/10/18 + */ +public class DuMapClient extends BaseDuMapClient { + + private static final String DEFAULT_OUTPUT = "json"; + private static final int DEFAULT_RADIUS = 1000; + private static final int DEFAULT_PAGE_INDEX = 1; + private static final int DEFAULT_PAGE_SIZE = 10; + private static final int DEFAULT_CONV_FROM = 1; + private static final int DEFAULT_CONV_TO = 5; + + /** + * Construct a DuMap client with default settings. + */ + public DuMapClient() { + super(); + } + + /** + * Construct a DuMap client with BceClientConfiguration. + * + * @param configuration BceClientConfiguration + */ + public DuMapClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Search some place by rectangular area. + * + * @param appId app id + * @param param PlaceSearchByBoundsParam + * + * @return Json string / Xml string + * + * @See https + * ://cloud.baidu.com/doc/DUMAP/Place-API.html + */ + public String placeQuery(String appId, PlaceSearchByBoundsParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getQuery(), DuMapValidateMsg.VALIDATE_MESSAGE_SEARCH_KEYWORD); + Validate.checkStringNotEmpty(param.getBounds(), DuMapValidateMsg.VALIDATE_MESSAGE_SEARCH_AREA); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + return callDuMap("/place/v2/search", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Search some place by administrative area. + * + * @param appId app id + * @param param PlaceSearchByRegionParam + * + * @return Json string / Xml string + * + * @See https + * ://cloud.baidu.com/doc/DUMAP/Place-API.html + */ + public String placeQuery(String appId, PlaceSearchByRegionParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getQuery(), DuMapValidateMsg.VALIDATE_MESSAGE_SEARCH_KEYWORD); + Validate.checkStringNotEmpty(param.getRegion(), DuMapValidateMsg.VALIDATE_MESSAGE_SEARCH_AREA); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + return callDuMap("/place/v2/search", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Search some place by circular area. + * + * @param appId app id + * @param param PlaceSearchByLocationParam + * + * @return Json string / Xml string + * + * @See https + * ://cloud.baidu.com/doc/DUMAP/Place-API.html + */ + public String placeQuery(String appId, PlaceSearchByLocationParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getQuery(), DuMapValidateMsg.VALIDATE_MESSAGE_SEARCH_KEYWORD); + Validate.checkStringNotEmpty(param.getLocation(), DuMapValidateMsg.VALIDATE_MESSAGE_SEARCH_AREA); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + return callDuMap("/place/v2/search", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Get some place detail. + * + * @param appId app id + * @param param PlaceDetailParam + * + * @return Json string / Xml string + * + * @See https + * ://cloud.baidu.com/doc/DUMAP/Place-API.html + */ + public String placeDetail(String appId, PlaceDetailParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getUid(), DuMapValidateMsg.VALIDATE_MESSAGE_POI_UID); + Validate.checkNotNull(param.getScope(), DuMapValidateMsg.VALIDATE_MESSAGE_POI_SCOPE); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + return callDuMap("/place/v2/detail", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Geocode some place. + * + * @param appId app id + * @param param GeocoderParam + * + * @return Json string / Xml string + * + * @See https + * ://cloud.baidu.com/doc/DUMAP/Geocoder-API.html + */ + public String geocoder(String appId, GeocoderParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getAddress(), DuMapValidateMsg.VALIDATE_MESSAGE_ADDRESS); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + return callDuMap("/geocoder/v2/", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Reverser geocode some place. + * + * @param appId app id + * @param param ReverseGeocoderParam + * + * @return Json string / Xml string + * + * @See https + * ://cloud.baidu.com/doc/DUMAP/Geocoder-API.html + */ + public String reverseGeocoder(String appId, ReverseGeocoderParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getLocation(), DuMapValidateMsg.VALIDATE_MESSAGE_ADDRESS); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + if (param.getRadius() == 0) { + param.setRadius(DEFAULT_RADIUS); + } + return callDuMap("/geocoder/v2/", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Direct the bus route. + * + * @param appId app id + * @param param DirectionTransitParam + * + * @return Json string / Xml string + * + * @See https + * ://cloud.baidu.com/doc/DUMAP/Direction-API.html + */ + public String direction(String appId, DirectionTransitParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getOrigin(), DuMapValidateMsg.VALIDATE_MESSAGE_ORIGIN); + Validate.checkStringNotEmpty(param.getDestination(), DuMapValidateMsg.VALIDATE_MESSAGE_DESTINATION); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + if (param.getPageSize() == 0) { + param.setPageSize(DEFAULT_PAGE_SIZE); + } + if (param.getPageIndex() == 0) { + param.setPageIndex(DEFAULT_PAGE_INDEX); + } + return callDuMap("/direction/v2/transit", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Direct the riding route. + * + * @param appId app id + * @param param DirectionRidingParam + * + * @return Json string / Xml string + * + * @See https + * ://cloud.baidu.com/doc/DUMAP/Direction-API.html + */ + public String direction(String appId, DirectionRidingParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getOrigin(), DuMapValidateMsg.VALIDATE_MESSAGE_ORIGIN); + Validate.checkStringNotEmpty(param.getDestination(), DuMapValidateMsg.VALIDATE_MESSAGE_DESTINATION); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + return callDuMap("/direction/v2/riding", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Direct the driving route. + * + * @param appId app id + * @param param DirectionDrivingParam + * + * @return Json string / Xml string + * + * @See https + * ://cloud.baidu.com/doc/DUMAP/Direction-API.html + */ + public String direction(String appId, DirectionDrivingParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getOrigin(), DuMapValidateMsg.VALIDATE_MESSAGE_ORIGIN); + Validate.checkStringNotEmpty(param.getDestination(), DuMapValidateMsg.VALIDATE_MESSAGE_DESTINATION); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + return callDuMap("/direction/v2/driving", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Transform the coordinate. + * + * @param appId app id + * @param param GeoconvParam + * + * @return Json string / Xml string + * + * @See https://cloud.baidu.com/doc/DUMAP/CoordinatesTransform-API.html + */ + public String geoconv(String appId, GeoconvParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkStringNotEmpty(param.getCoords(), DuMapValidateMsg.VALIDATE_MESSAGE_COORDS); + if (StringUtils.isBlank(param.getOutput())) { + param.setOutput(DEFAULT_OUTPUT); + } + if (param.getFrom() == 0) { + param.setFrom(DEFAULT_CONV_FROM); + } + if (param.getTo() == 0) { + param.setTo(DEFAULT_CONV_TO); + } + return callDuMap("/geoconv/v1/", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Locate IP. + * + * @param appId app id + * @param param IpLocationParam + * + * @return Json string + */ + public String locate(String appId, IPLocationParam param) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + return callDuMap("/location/ip", appId, null, param, HttpMethodName.GET).getPayload(); + } + + /** + * Locate intelligent hardware. + * + * @param appId app id + * @param request HardwareLocationRequest + * + * @return Json string + */ + public String locate(String appId, HardwareLocationRequest request) { + Validate.checkStringNotEmpty(appId, DuMapValidateMsg.VALIDATE_MESSAGE_APP_ID); + Validate.checkNotNull(request.getSrc(), DuMapValidateMsg.VALIDATE_MESSAGE_SRC); + Validate.checkNotNull(request.getProd(), DuMapValidateMsg.VALIDATE_MESSAGE_PROD); + Validate.checkNotNull(request.getVer(), DuMapValidateMsg.VALIDATE_MESSAGE_VER); + return callDuMap("/locapi/v2", appId, request, null, HttpMethodName.POST, BodyType.JSON).getPayload(); + } +} diff --git a/src/main/java/com/baidubce/services/dumap/DuMapValidateMsg.java b/src/main/java/com/baidubce/services/dumap/DuMapValidateMsg.java new file mode 100644 index 00000000..1065718e --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/DuMapValidateMsg.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap; + +/** + * DuMap validate message. + * + * @author weizhijun + * @date 2018/10/16 + */ +public interface DuMapValidateMsg { + public static final String VALIDATE_MESSAGE_APP_ID = "appId不能为空"; + public static final String VALIDATE_MESSAGE_SEARCH_KEYWORD = "检索关键字不能为空"; + public static final String VALIDATE_MESSAGE_SEARCH_AREA = "检索区域不能为空"; + public static final String VALIDATE_MESSAGE_POI_UID = "poi的uid不能为空"; + public static final String VALIDATE_MESSAGE_POI_SCOPE = "检索结果详细程度不能为空,可取值1、2"; + public static final String VALIDATE_MESSAGE_ADDRESS = "解析地址不能为空"; + public static final String VALIDATE_MESSAGE_ORIGIN = "起点坐标不能为空"; + public static final String VALIDATE_MESSAGE_DESTINATION = "终点坐标不能为空"; + public static final String VALIDATE_MESSAGE_COORDS = "源坐标不能为空"; + public static final String VALIDATE_MESSAGE_SRC = "厂商标识不能为空"; + public static final String VALIDATE_MESSAGE_PROD = "产品线名称不能为空"; + public static final String VALIDATE_MESSAGE_VER = "服务版本号不能为空"; +} diff --git a/src/main/java/com/baidubce/services/dumap/handler/DuMapResponseHandler.java b/src/main/java/com/baidubce/services/dumap/handler/DuMapResponseHandler.java new file mode 100644 index 00000000..eaca1766 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/handler/DuMapResponseHandler.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018-2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.handler; + +import java.io.InputStream; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.dumap.model.BaseDuMapResponse; +import com.google.common.io.ByteStreams; + +import lombok.extern.slf4j.Slf4j; + +/** + * DuMap response json handler. + */ +@Slf4j +public class DuMapResponseHandler implements HttpResponseHandler { + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + InputStream content = httpResponse.getContent(); + BaseDuMapResponse duMapResponse = (BaseDuMapResponse) response; + if (content != null) { + duMapResponse.setPayload(new String(ByteStreams.toByteArray(content))); + content.close(); + } + return true; + } +} diff --git a/src/main/java/com/baidubce/services/dumap/model/BaseDuMapResponse.java b/src/main/java/com/baidubce/services/dumap/model/BaseDuMapResponse.java new file mode 100644 index 00000000..bc8d1c33 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/BaseDuMapResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Base dumap response. + */ +public class BaseDuMapResponse extends AbstractBceResponse { + + private String payload; + + public String getPayload() { + return payload; + } + + public void setPayload(String payload) { + this.payload = payload; + } +} diff --git a/src/main/java/com/baidubce/services/dumap/model/DirectionDrivingParam.java b/src/main/java/com/baidubce/services/dumap/model/DirectionDrivingParam.java new file mode 100644 index 00000000..cfe5daf6 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/DirectionDrivingParam.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters for driving route direction query. + */ +@Data +@Builder +public class DirectionDrivingParam { + + /** + * Origin coordinate + */ + private String origin; + + /** + * Destination coordinate + */ + private String destination; + + /** + * Uid of origin POI + */ + private String originUid; + + /** + * Uid of destination POI + */ + private String destinationUid; + + /** + * Point coordinates on the way + */ + private String waypoints; + + /** + * Coordinate type origin and destination + */ + private String coordType; + + /** + * Coordinate type of result + */ + private String retCoordtype; + + /** + * Driving strategy type. + */ + private int tactics; + + /** + * Whether return alternatives or not + */ + private String alternatives; + + /** + * Plate number + */ + private String plateNumber; + + /** + * More departure time + */ + private String extDepartureTime; + + /** + * Head direction of the starting point + */ + private String gpsDirection; + + /** + * Starting accuracy + */ + private float radius; + + /** + * Speed + */ + private float speed; + + /** + * Response type + */ + private String output; + + /** + * Call back function + */ + private String callback; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/DirectionRidingParam.java b/src/main/java/com/baidubce/services/dumap/model/DirectionRidingParam.java new file mode 100644 index 00000000..3031b359 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/DirectionRidingParam.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of riding route direction query. + */ +@Data +@Builder +public class DirectionRidingParam { + + /** + * Origin coordinate + */ + private String origin; + + /** + * Destination coordinate + */ + private String destination; + + /** + * Type of origin and destination coordinates. + */ + private String coordType; + + /** + * Riding type + */ + private String ridingType; + + /** + * Coordinate type of result + */ + private String retCoordtype; + + /** + * Response type + */ + private String output; + + /** + * Call back function + */ + private String callback; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/DirectionTransitParam.java b/src/main/java/com/baidubce/services/dumap/model/DirectionTransitParam.java new file mode 100644 index 00000000..d250d512 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/DirectionTransitParam.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the parameters of bus route direction query. + */ +@Data +@Builder +public class DirectionTransitParam { + + /** + * Origin coordinate + */ + private String origin; + + /** + * Destination coordinate + */ + private String destination; + + /** + * Coordinate type of origin and destination + */ + private String coordType; + + /** + * Bus exchange strategy in city + */ + private int tacticsIncity; + + /** + * Cross-city exchange strategy + */ + private int tacticsIntercity; + + /** + * Cross-city transportation strategy + */ + private int transTypeIntercity; + + /** + * Coordinate type of result + */ + private String retCoordtype; + + /** + * Response type + */ + private String output; + + /** + * Number of routes returned in each page + */ + private int pageSize; + + /** + * Index of returned page + */ + private int pageIndex; + + /** + * Call back function + */ + private String callback; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/GeocoderParam.java b/src/main/java/com/baidubce/services/dumap/model/GeocoderParam.java new file mode 100644 index 00000000..33d6ff69 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/GeocoderParam.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of geocoding query. + */ +@Data +@Builder +public class GeocoderParam { + + /** + * Address to be coded + */ + private String address; + + /** + * City name + */ + private String city; + + /** + * Coordinate type of result + */ + private String retCoordtype; + + /** + * Response type + */ + private String output; + + /** + * Callback function + */ + private String callback; + +} diff --git a/src/main/java/com/baidubce/services/dumap/model/GeoconvParam.java b/src/main/java/com/baidubce/services/dumap/model/GeoconvParam.java new file mode 100644 index 00000000..7374c4b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/GeoconvParam.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of coordinate transformation query. + */ +@Data +@Builder +public class GeoconvParam { + + /** + * Coordinate to be transformed + */ + private String coords; + + /** + * Origin coordinate type + */ + private int from; + + /** + * Target coordinate type + */ + private int to; + + /** + * Response type + */ + private String output; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/HardwareLocationRequest.java b/src/main/java/com/baidubce/services/dumap/model/HardwareLocationRequest.java new file mode 100644 index 00000000..7836cb0e --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/HardwareLocationRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import java.util.List; +import java.util.Map; + +import com.baidubce.model.GenericAccountRequest; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of locating intelligent hardware query. + */ +@Data +@Builder +public class HardwareLocationRequest extends GenericAccountRequest { + + /** + * Manufacturer identification (eg. baidu). + */ + private String src; + + /** + * Product line name (eg. baiduwatch). + */ + private String prod; + + /** + * Service version (eg. 1.0). + */ + private String ver; + + /** + * Whether to enable trace or not. (default value is false) + */ + private boolean trace; + + /** + * The request info body which contains the hardware details. + */ + private List> body; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/IPLocationParam.java b/src/main/java/com/baidubce/services/dumap/model/IPLocationParam.java new file mode 100644 index 00000000..7b14acfd --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/IPLocationParam.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of locating ip query. + */ +@Data +@Builder +public class IPLocationParam { + /** + * IP address which needs to be located. + */ + private String ip; + + /** + * Coordinate type of returned location information. + */ + private String coor; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/PlaceDetailParam.java b/src/main/java/com/baidubce/services/dumap/model/PlaceDetailParam.java new file mode 100644 index 00000000..0712ad7e --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/PlaceDetailParam.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of place detail query. + */ +@Data +@Builder +public class PlaceDetailParam { + + /** + * Uid of POI to be queried + */ + private String uid; + + /** + * set of uids (in form of string) + */ + private String uids; + + /** + * Response type + */ + private String output; + + /** + * Detail level of Search result + */ + private int scope; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/PlaceSearchByBoundsParam.java b/src/main/java/com/baidubce/services/dumap/model/PlaceSearchByBoundsParam.java new file mode 100644 index 00000000..fd8a1a99 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/PlaceSearchByBoundsParam.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of rectangular area search query. + */ +@Data +@Builder +public class PlaceSearchByBoundsParam { + + /** + * Keyword to be searched + */ + private String query; + + /** + * Retrieve classification preferences + */ + private String tag; + + /** + * Datail level of search result + */ + private String scope; + + /** + * Search filter + */ + private String filter; + + /** + * Coordinate type + */ + private int coordType; + + /** + * Coordinate type of result + */ + private String retCoordtype; + + /** + * Number of POIs recalled in a single operation + */ + private int pageSize; + + /** + * Returned page number + */ + private int pageNum; + + /** + * Rectangular area to be searched + */ + private String bounds; + + /** + * Response type + */ + private String output; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/PlaceSearchByLocationParam.java b/src/main/java/com/baidubce/services/dumap/model/PlaceSearchByLocationParam.java new file mode 100644 index 00000000..ec69c55d --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/PlaceSearchByLocationParam.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of circular area search query. + */ +@Data +@Builder +public class PlaceSearchByLocationParam { + + /** + * Keyword to be searched + */ + private String query; + + /** + * Retrieve classification preferences + */ + private String tag; + + /** + * Response type + */ + private String output; + + /** + * Datail level of search result + */ + private String scope; + + /** + * Search filter + */ + private String filter; + + /** + * Coordinate type + */ + private int coordType; + + /** + * Coordinate type of type + */ + private String retCoordtype; + + /** + * Number of POIs recalled in a single operation + */ + private int pageSize; + + /** + * Returned page number + */ + private int pageNum; + + /** + * Central point of the circular area to be searched + */ + private String location; + + /** + * Radius of circular area to be searched + */ + private String radius; + + /** + * Whether strictly limit the recall result within the searched radius or not + */ + private String radiusLimit; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/PlaceSearchByRegionParam.java b/src/main/java/com/baidubce/services/dumap/model/PlaceSearchByRegionParam.java new file mode 100644 index 00000000..b05be40c --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/PlaceSearchByRegionParam.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of administrative area search query. + */ +@Data +@Builder +public class PlaceSearchByRegionParam { + + /** + * Keyword to be searched + */ + private String query; + + /** + * Retrieve classification preferences + */ + private String tag; + + /** + * Response type + */ + private String output; + + /** + * Datail level of search result + */ + private String scope; + + /** + * Search filter + */ + private String filter; + + /** + * Coordinate type + */ + private int coordType; + + /** + * Coordinate type of result + */ + private String retCoordtype; + + /** + * Number of POIs recalled in a single operation + */ + private int pageSize; + + /** + * Returned page number + */ + private int pageNum; + + /** + * Administrative region to be searched + */ + private String region; + + /** + * Whether strictly limit the recall result in the searched region or not + */ + private String cityLimit; +} diff --git a/src/main/java/com/baidubce/services/dumap/model/ReverseGeocoderParam.java b/src/main/java/com/baidubce/services/dumap/model/ReverseGeocoderParam.java new file mode 100644 index 00000000..9e1f2573 --- /dev/null +++ b/src/main/java/com/baidubce/services/dumap/model/ReverseGeocoderParam.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2018 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.dumap.model; + +import lombok.Builder; +import lombok.Data; + +/** + * Represent the request parameters of reverse geocoding query. + */ +@Data +@Builder +public class ReverseGeocoderParam { + + /** + * Coordinate + */ + private String location; + + /** + * Coordinate type + */ + private String coordtype; + + /** + * Coordinate type of result + */ + private String retCoordtype; + + /** + * Whether to recall the POI around the incoming coordinates or not + */ + private int pois; + + /** + * POI recall radius + */ + private int radius; + + /** + * Response type + */ + private String output; + + /** + * Call back function + */ + private String callback; + + /** + * Whether calls POI related services or not + */ + private String extensionsPoi; + + /** + * Whether to recall surrounding road data or not + */ + private String extensionsRoad; + + /** + * Whether to recall town data or not + */ + private String extensionsTown; + + /** + * Language type of recalled administrative region + */ + private String language; + + /** + * Whether to automatically fill administrative region + */ + private int languageAuto; + + /** + * Whether to access the latest version of administrative division data + */ + private int latestAdmin; + +} diff --git a/src/main/java/com/baidubce/services/eip/EipClient.java b/src/main/java/com/baidubce/services/eip/EipClient.java new file mode 100644 index 00000000..8c2394f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/EipClient.java @@ -0,0 +1,587 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eip; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.eip.model.AutoRenewEipRequest; +import com.baidubce.services.eip.model.Billing; +import com.baidubce.services.eip.model.BindEipRequest; +import com.baidubce.services.eip.model.CreateEipRequest; +import com.baidubce.services.eip.model.CreateEipResponse; +import com.baidubce.services.eip.model.DirectEipRequest; +import com.baidubce.services.eip.model.ListEipsRequest; +import com.baidubce.services.eip.model.ListEipsResponse; +import com.baidubce.services.eip.model.ListRecycleEipsRequest; +import com.baidubce.services.eip.model.ListRecycleEipsResponse; +import com.baidubce.services.eip.model.OptionalReleaseEipRequest; +import com.baidubce.services.eip.model.PurchaseReservedEipRequest; +import com.baidubce.services.eip.model.RecycleOperateEipRequest; +import com.baidubce.services.eip.model.ReleaseEipRequest; +import com.baidubce.services.eip.model.ResizeEipRequest; +import com.baidubce.services.eip.model.StopAutoRenewEipRequest; +import com.baidubce.services.eip.model.UnbindEipRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; + +/** + * Provides the client for accessing the Elastic Ip Service (EIP). + */ +public class EipClient extends AbstractBceClient { + /** + * EIP API pathVersion + */ + private static final String VERSION = "v1"; + + private static final String PREFIX = "eip"; + + private static final String CLIENT_TOKEN_IDENTIFY = "clientToken"; + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static HttpResponseHandler[] eipHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public EipClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new InstanceClient to invoke service methods on eip instance. + * + * @param clientConfiguration The BCE client configuration options. + */ + public EipClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, eipHandlers); + } + + /** + * Create an eip with the specified options. + * @param bandwidthInMbps specify the bandwidth in Mbps + * @return + */ + public CreateEipResponse createEip(int bandwidthInMbps) { + return createEip(new CreateEipRequest().withBandwidthInMbps(bandwidthInMbps)); + } + + /** + * Create an eip with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for creating an eip. + * @return created eip address + */ + public CreateEipResponse createEip(CreateEipRequest request) { + checkNotNull(request.getBandwidthInMbps(), "bandwidthInMbps should not be null"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + checkNotNull(request.getBandwidthInMbps(), "bandwidthInMbps should not be null"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, null); + + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEipResponse.class); + } + + /** + * Resizing eip + * + * @param eip eip address to be resized + * @param newBandwidthInMbps specify new bandwidth in Mbps for eip + */ + public void resizeEip(String eip, int newBandwidthInMbps) { + this.resizeEip(new ResizeEipRequest().withEip(eip).withNewBandwidthInMbps(newBandwidthInMbps)); + } + + /** + * Resizing eip + * The Prepaid eip can not be downgrade. + * This is an asynchronous interface. + * + * @param request eip & newBandwidthInMbps must be provided + */ + public void resizeEip(ResizeEipRequest request) { + checkNotNull(request.getNewBandwidthInMbps(), "newBandwidthInMbps should not be null"); + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getEip()); + internalRequest.addParameter("resize", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * PurchaseReserved eip with specified duration in month + * @param eip + * @param reservationLength + */ + public void purchaseReservedEipInMonth(String eip, int reservationLength) { + Billing billing = new Billing(); + billing.setReservation(new Billing.Reservation().withReservationLength(reservationLength)); + this.purchaseReservedEip(new PurchaseReservedEipRequest().withEip(eip).withBilling(billing)); + } + + /** + * PurchaseReserved eip with fixed duration + * only Prepaid eip can do this + * @param eip eip address to be renewed + * @param reservationLength purchase length + * @param reservationTimeUnit time unit of purchasing, optional parameter default value 'Month' + */ + public void purchaseReservedEip(String eip, int reservationLength, String reservationTimeUnit) { + Billing billing = new Billing(); + billing.setReservation(new Billing.Reservation().withReservationLength(reservationLength) + .withReservationTimeUnit(reservationTimeUnit)); + + this.purchaseReservedEip(new PurchaseReservedEipRequest().withEip(eip).withBilling(billing)); + } + + /** + * PurchaseReserved eip with fixed duration + * only Prepaid eip can do this + * + * This is an asynchronous interface + * @param request The request containing all options for renewing eip with fixed duration. + */ + public void purchaseReservedEip(PurchaseReservedEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultReservation()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getEip()); + internalRequest.addParameter("purchaseReserved", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * AutoRenew eip with fixed duration + * only Prepaid eip can do this + *

+ * This is an asynchronous interface + * + * @param request The request containing all options for starting autorenew eip. + */ + public void startAutoRenew(AutoRenewEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getEip()); + internalRequest.addParameter("startAutoRenew", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Stop autoRenew eip. + * only Prepaid eip can do this + * + * This is an asynchronous interface + * + * @param request The request containing all options for stopping autorenew eip. + */ + public void stopAutoRenew(StopAutoRenewEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getEip()); + internalRequest.addParameter("stopAutoRenew", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Direct eip. + * + * This is an asynchronous interface + * + * @param request The request containing all options for directing on eip. + */ + public void directEip(DirectEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getEip()); + internalRequest.addParameter("direct", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + internalRequest.addHeader(Headers.CONTENT_LENGTH, "0"); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * UnDirect eip. + * + * This is an asynchronous interface + * + * @param request The request containing all options for undirecting on eip. + */ + public void unDirectEip(DirectEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getEip()); + internalRequest.addParameter("unDirect", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + internalRequest.addHeader(Headers.CONTENT_LENGTH, "0"); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * bind the eip to a specified instanceId and instanceType(BCC|BLB). + * + * @param eip eip address to be bound + * @param instanceId id of instance to be bound + * @param instanceType type of instance to be bound + */ + public void bindEip(String eip, String instanceId, String instanceType) { + this.bindEip(new BindEipRequest().withEip(eip).withInstanceId(instanceId).withInstanceType(instanceType)); + } + + /** + * bind the eip to a specified instanceId and instanceType(BCC|BLB). + * + * @param eip eip address to be bound + * @param instanceId id of instance to be bound + * @param instanceIp ip of instance to be bound + * @param instanceType type of instance to be bound + */ + public void bindEip(String eip, String instanceId, String instanceIp, String instanceType) { + this.bindEip(new BindEipRequest() + .withEip(eip) + .withInstanceId(instanceId) + .withInstanceIp(instanceIp) + .withInstanceType(instanceType)); + } + + /** + * bind the eip to a specified instanceId and instanceType(BCC|BLB). + * the status of eip must be available and thd instance not be expired or boundByEip + * @param request The request containing all options for binding eip + */ + public void bindEip(BindEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getEip()); + internalRequest.addParameter("bind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * unbind the eip from a specified instance + * @param eip eip address to be unbound + */ + public void unbindEip(String eip) { + this.unbindEip(new UnbindEipRequest().withEip(eip)); + } + + /** + * unbind the eip from a specified instance + * @param request The request containing all options for unbinding eip + */ + public void unbindEip(UnbindEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getEip()); + internalRequest.addParameter("unbind", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + internalRequest.addHeader(Headers.CONTENT_LENGTH, "0"); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * release the eip(delete operation) + * @param eip eip address to be released + */ + public void releaseEip(String eip) { + this.releaseEip(new ReleaseEipRequest().withEip(eip)); + } + + /** + * release the eip(delete operation) + * Only the Postpaid instance or Prepaid which is expired can be released. + * if the eip has been bound, must unbind before releasing + * + * @param request The request containing all options for releasing eip + */ + public void releaseEip(ReleaseEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, request.getEip()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * get a list of eips owned by the authenticated user and default conditions + * @return + */ + public ListEipsResponse listEips() { + ListEipsRequest request = new ListEipsRequest(); + return listEips(request); + } + + /** + * get a list of eips owned by the authenticated user and specified conditions + * + * we can Also get a single eip function through this interface by eip condition + * + * if query by the instanceId or instanceType condition, must provides both of them at the same time + * @param request The request containing all options for query + * @return + */ + public ListEipsResponse listEips(ListEipsRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, null); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() >= 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getEip())) { + internalRequest.addParameter("eip", request.getEip()); + } + if (!Strings.isNullOrEmpty(request.getInstanceId())) { + internalRequest.addParameter("instanceId", request.getInstanceId()); + if (Strings.isNullOrEmpty(request.getInstanceType())) { + throw new IllegalArgumentException("there is not instanceType"); + } + } + if (!Strings.isNullOrEmpty(request.getInstanceType())) { + internalRequest.addParameter("instanceType", request.getInstanceType()); + } + return invokeHttpClient(internalRequest, ListEipsResponse.class); + } + + /** + * get a list of eips from recycle owned by the authenticated user and specified conditions + * + * @param request The request containing all options for query + * @return + */ + public ListRecycleEipsResponse listRecycleEips(ListRecycleEipsRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, "recycle"); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() >= 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getEip())) { + internalRequest.addParameter("eip", request.getEip()); + } + if (!Strings.isNullOrEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + return invokeHttpClient(internalRequest, ListRecycleEipsResponse.class); + } + + + /** + * optional release the eip(Including directly deleting the eip or putting the eip into the recycle bin) + * Only the Postpaid instance or Prepaid which is expired can be released. + * if the eip has been bound, must unbind before releasing + * + * @param request The request containing all options for optional releasing eip + */ + public void optionalReleaseEip(OptionalReleaseEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, request.getEip()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + internalRequest.addParameter("releaseToRecycle", String.valueOf(request.isReleaseToRecycle())); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + + /** + * release the eip from recycle. + * + * @param request The request containing all options for releasing eip from recycle. + * @return + */ + public void releaseEipFromRecycle(RecycleOperateEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, + "recycle/" + request.getEip()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * restore the eip from recycle. + * + * @param request The request containing all options for restoring eip from recycle. + * @return + */ + public void restoreEipFromRecycle(RecycleOperateEipRequest request) { + checkStringNotEmpty(request.getEip(), "eip should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, + "recycle/" + request.getEip()); + internalRequest.addParameter("restore", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + internalRequest.addHeader(Headers.CONTENT_LENGTH, "0"); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest( + AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + path.add(PREFIX); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + * + * The default algorithm is using {@link UUID} to generate a random UUID, + * @return An random String generated by {@link UUID}. + */ + private String generateDefaultClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * The method to generate a default Billing which is Postpaid. + * + * @return The Billing object with Postpaid PaymentTiming. + */ + private Billing generateDefaultBilling() { + Billing billing = new Billing(); + billing.setPaymentTiming("Postpaid"); + billing.setBillingMethod("ByBandwidth"); + return billing; + } + + /** + * The method to generate a default Billing with default Reservation which default ReservationLength is 1. + * + * @return The Billing object with default Reservation which default ReservationLength is 1 + */ + private Billing generateDefaultReservation() { + Billing billing = new Billing(); + Billing.Reservation reservation = new Billing.Reservation(); + billing.setReservation(reservation); + reservation.setReservationLength(1); + return billing; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/AutoRenewEipRequest.java b/src/main/java/com/baidubce/services/eip/model/AutoRenewEipRequest.java new file mode 100644 index 00000000..9f60fa3b --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/AutoRenewEipRequest.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for autorenew eip. + */ +@Getter +@Setter +public class AutoRenewEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * eip address to be started autoRenew + */ + private String eip; + /** + * autoRenew TimeUnit. + */ + private String autoRenewTimeUnit; + /** + * autoRenewTime. + */ + private Integer autoRenewTime; + + public AutoRenewEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public AutoRenewEipRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public AutoRenewEipRequest withAutoRenewTimeUnit(String autoRenewTimeUnit) { + this.autoRenewTimeUnit = autoRenewTimeUnit; + return this; + } + + public AutoRenewEipRequest withAutoRenewTime(Integer autoRenewTime) { + this.autoRenewTime = autoRenewTime; + return this; + } + + public AutoRenewEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/Billing.java b/src/main/java/com/baidubce/services/eip/model/Billing.java new file mode 100644 index 00000000..416491fb --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/Billing.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +/** + * The model for billing information. + */ +public class Billing { + /** + * The pay time of the payment, + * see more detail at BCE API doc + * default value 'Postpaid' + */ + private String paymentTiming; + + /** + * The way of eip charging + * see more detail at BCE API doc + */ + private String billingMethod; + + /** + * The reservation model to specify the detail to buy. + * be used when Prepaid + */ + private Reservation reservation; + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getBillingMethod() { + return billingMethod; + } + + public void setBillingMethod(String billingMethod) { + this.billingMethod = billingMethod; + } + + public Reservation getReservation() { + return reservation; + } + + public void setReservation(Reservation reservation) { + this.reservation = reservation; + } + + public Billing withPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + return this; + } + + public Billing withBillingMethod(String billingMethod) { + this.billingMethod = billingMethod; + return this; + } + + public Billing withReservation(Reservation reservation) { + this.reservation = reservation; + return this; + } + + /** + * The reservation model to specify the detail to buy. + */ + public static class Reservation { + /** + * purchase length + */ + private int reservationLength; + + /** + * time unit of purchasing,default 'Month' + */ + private String reservationTimeUnit = "Month"; + + public int getReservationLength() { + return reservationLength; + } + + public void setReservationLength(int reservationLength) { + this.reservationLength = reservationLength; + } + + public String getReservationTimeUnit() { + return reservationTimeUnit; + } + + public void setReservationTimeUnit(String reservationTimeUnit) { + this.reservationTimeUnit = reservationTimeUnit; + } + + public Reservation withReservationLength(int reservationLength) { + this.reservationLength = reservationLength; + return this; + } + + public Reservation withReservationTimeUnit(String reservationTimeUnit) { + this.reservationTimeUnit = reservationTimeUnit; + return this; + } + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/BindEipRequest.java b/src/main/java/com/baidubce/services/eip/model/BindEipRequest.java new file mode 100644 index 00000000..fd4a7c5e --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/BindEipRequest.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for binding eip. + */ +@Getter +@Setter +public class BindEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * eip address to be bound + */ + @JsonIgnore + private String eip; + /** + * type of instance to be bound + */ + private String instanceType; + /** + * id of instance to be bound + */ + private String instanceId; + + /** + * ip of instance to be bound,it is usually used to bind secondary ips and it is optional. + */ + private String instanceIp; + + public BindEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public BindEipRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public BindEipRequest withInstanceType(String instanceType) { + this.instanceType = instanceType; + return this; + } + + public BindEipRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + public BindEipRequest withInstanceIp(String instanceIp) { + this.instanceIp = instanceIp; + return this; + } + + public BindEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/CreateEipRequest.java b/src/main/java/com/baidubce/services/eip/model/CreateEipRequest.java new file mode 100644 index 00000000..574d6059 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/CreateEipRequest.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for creating a newly eip. + */ +@Getter +@Setter +public class CreateEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * name of eip. The optional parameter + */ + private String name; + /** + * specify the bandwidth in Mbps + */ + private Integer bandwidthInMbps; + /** + * billing information. The optional parameter, default paymentTiming is Postpaid + */ + private Billing billing; + + /** + * The tags which will be bound to eip. + */ + private List tags; + + /** + * The ID of resourceGroup which will be bound to eip. + */ + private String resourceGroupId; + + public CreateEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public CreateEipRequest withName(String name) { + this.name = name; + return this; + } + + public CreateEipRequest withBandwidthInMbps(Integer bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + return this; + } + + public CreateEipRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + public CreateEipRequest withTags(List tags) { + this.tags = tags; + return this; + } + + public CreateEipRequest withResourceGroupId(String resourceGroupId) { + this.resourceGroupId = resourceGroupId; + return this; + } + + public CreateEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/CreateEipResponse.java b/src/main/java/com/baidubce/services/eip/model/CreateEipResponse.java new file mode 100644 index 00000000..4174aee4 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/CreateEipResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.ToString; + +/** + * Created by caidahai on 2016/6/23. + */ +@ToString +public class CreateEipResponse extends AbstractBceResponse { + private String eip; + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/DirectEipRequest.java b/src/main/java/com/baidubce/services/eip/model/DirectEipRequest.java new file mode 100644 index 00000000..d5c10751 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/DirectEipRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for stop autoRenew + */ +@Getter +@Setter + +public class DirectEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * eip address to be stopped autoRenew + */ + @JsonIgnore + private String eip; + + public DirectEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public DirectEipRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public DirectEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/ListEipsRequest.java b/src/main/java/com/baidubce/services/eip/model/ListEipsRequest.java new file mode 100644 index 00000000..a72d5207 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/ListEipsRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +/** + * The request for listing eip. + */ +public class ListEipsRequest extends ListRequest { + /** + * eip address condition + */ + private String eip; + /** + * bound instance type condition + */ + private String instanceType; + /** + * bound instance id condition + */ + private String instanceId; + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public ListEipsRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public ListEipsRequest withInstanceType(String instanceType) { + this.instanceType = instanceType; + return this; + } + + public ListEipsRequest withInstanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/ListEipsResponse.java b/src/main/java/com/baidubce/services/eip/model/ListEipsResponse.java new file mode 100644 index 00000000..12a0eb26 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/ListEipsResponse.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.services.bcc.model.TagModel; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Date; +import java.util.List; + +/** + * list of eip model + */ +@Getter +@Setter +public class ListEipsResponse extends ListResponse { + private List eipList; + + @Getter + @Setter + @ToString + public static class EipModel { + /** + * name of eip + */ + private String name; + /** + * eip address + */ + private String eip; + /** + * eip id + */ + private String eipId; + /** + * eip status + * see more detail at BCE API doc + */ + private String status; + /** + * bound instance type + */ + private String instanceType; + /** + * bound instance id + */ + private String instanceId; + /** + * the bandwidth of eip in Mbps + */ + private int bandwidthInMbps; + /** + * The pay time of the payment, + * see more detail at BCE API doc + */ + private String paymentTiming; + /** + * The way of eip charging + * see more detail at BCE API doc + */ + private String billingMethod; + /** + * create time + */ + private Date createTime; + /** + * expire time, only assigned when Prepaid + */ + private Date expireTime; + + /** + * The tags bound to eip. + */ + private List tags; + } + + @Override + public String toString() { + return "ListEipsResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "eipList=" + eipList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/ListRecycleEipsRequest.java b/src/main/java/com/baidubce/services/eip/model/ListRecycleEipsRequest.java new file mode 100644 index 00000000..284f0317 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/ListRecycleEipsRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import lombok.Getter; +import lombok.Setter; + +/** + * The request for listing recycle eip. + */ +@Getter +@Setter +public class ListRecycleEipsRequest extends ListRequest { + /** + * eip address condition + */ + private String eip; + /** + * eip name condition + */ + private String name; + + public ListRecycleEipsRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public ListRecycleEipsRequest withName(String name) { + this.name = name; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/ListRecycleEipsResponse.java b/src/main/java/com/baidubce/services/eip/model/ListRecycleEipsResponse.java new file mode 100644 index 00000000..d1b47e1d --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/ListRecycleEipsResponse.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * list of recycle eip model + */ +@Getter +@Setter +public class ListRecycleEipsResponse extends ListResponse { + private List eipList; + + @Getter + @Setter + @ToString + public static class RecycleEipModel { + /** + * name of eip + */ + private String name; + /** + * eip address + */ + private String eip; + /** + * eip id + */ + private String eipId; + /** + * eip status + * see more detail at BCE API doc + */ + private String status; + /** + * eip route type + */ + private String routeType; + /** + * the bandwidth of eip in Mbps + */ + private int bandwidthInMbps; + /** + * The pay time of the payment, + * see more detail at BCE API doc + */ + private String paymentTiming; + /** + * The way of eip charging + * see more detail at BCE API doc + */ + private String billingMethod; + /** + * offer in recycle time. + */ + private String recycleTime; + /** + * scheduled delete time. + */ + private String scheduledDeleteTime; + } + + @Override + public String toString() { + return "ListRecycleEipsResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "eipList=" + eipList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/ListRequest.java b/src/main/java/com/baidubce/services/eip/model/ListRequest.java new file mode 100644 index 00000000..a2f22379 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/ListRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * list base class + */ +public abstract class ListRequest extends AbstractBceRequest { + /** + * The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + *

+ * Together with the marker, specifies the list result which listing should begin. + *

+ * If the marker is not specified, the list result will listing from the first one. + * + */ + private String marker; + + /** + * The optional parameter to specifies the max number of list result to return. + * The default value is -1. + */ + private int maxKeys = -1; + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public int getMaxKeys() { + return maxKeys; + } + + public void setMaxKeys(int maxKeys) { + this.maxKeys = maxKeys; + } + + public ListRequest withMarker(String marker) { + this.marker = marker; + return this; + } + + public ListRequest withMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + return this; + } + + public ListRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/ListResponse.java b/src/main/java/com/baidubce/services/eip/model/ListResponse.java new file mode 100644 index 00000000..81d754ee --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/ListResponse.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The base response contains the base information about list operation. + */ +public abstract class ListResponse extends AbstractBceResponse { + /** + * The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + */ + private String marker; + + /** + * Iftrue it means there are more result in the next list page, + * otherwise it means the list result is last list page. + */ + private boolean isTruncated; + + /** + * The next marker to list next page result to list begin,if there is no more result in the next page, + * this field it will not appear. + */ + private String nextMarker; + + /** + * The optional parameter in the original request to specifies the max number of list result to return . + */ + private Integer maxKeys; + + /** + * Returning the optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * + * @return The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + */ + public String getMarker() { + return marker; + } + + /** + * Setting the optional parameter marker specified in the original request to specify + * where in the results to begin listing. + * + * @param marker The optional parameter marker specified in the original request to specify + * where in the results to begin listing. + */ + public void setMarker(String marker) { + this.marker = marker; + } + + /** + * Returning false to indicate that there is not more result in the next page, + * otherwise returning true meaning there is more result in next page. + * + * @return Returning false to indicate that there is not more result in the next page, + * otherwise returning true meaning there is more result in next page. + */ + public boolean getIsTruncated() { + return isTruncated; + } + + /** + * Setting the boolean value to indicate that there is not more result in the next page. + * + * Setting false to indicate that there is not more result in the next page, + * Setting true meaning there is more result in next page. + * + * @param isTruncated The boolean value to indicate that there is not more result in the next page. + */ + public void setIsTruncated(boolean isTruncated) { + this.isTruncated = isTruncated; + } + + /** + * Returning the next marker to list next page result to list begin,if there is no more result in the next page, + * this field it will not appear. + * @return The next marker to list next page result to list begin. + */ + public String getNextMarker() { + return nextMarker; + } + + /** + * Setting the next marker to list next page result to list begin. + * @param nextMarker The next marker to list next page result to list begin. + */ + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + /** + * Returning the optional parameter in the original request to specifies the max number of list result to return . + * @return The optional parameter in the original request to specifies the max number of list result to return . + */ + public Integer getMaxKeys() { + return maxKeys; + } + + /** + * Setting the optional parameter in the original request to specifies the max number of list result to return . + * @param maxKeys The optional parameter in the original request to specifies the max number of list result to return . + */ + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/OptionalReleaseEipRequest.java b/src/main/java/com/baidubce/services/eip/model/OptionalReleaseEipRequest.java new file mode 100644 index 00000000..fe7242b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/OptionalReleaseEipRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import lombok.Getter; +import lombok.Setter; + +/** + * The request for optional releasing eip. + */ +@Getter +@Setter +public class OptionalReleaseEipRequest extends ReleaseEipRequest { + /** + * whether to put the specific EIP in the recycle bin (true) or directly delete it (false). + * The default value is false。 + */ + private boolean releaseToRecycle = false; + + public OptionalReleaseEipRequest withReleaseToRecycle(boolean releaseToRecycle) { + this.releaseToRecycle = releaseToRecycle; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/eip/model/PurchaseReservedEipRequest.java b/src/main/java/com/baidubce/services/eip/model/PurchaseReservedEipRequest.java new file mode 100644 index 00000000..8b0daa9d --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/PurchaseReservedEipRequest.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for renewing eip. + */ +public class PurchaseReservedEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * eip address to be renewed + */ + @JsonIgnore + private String eip; + /** + * billing information. + * just providing Reservation is enough + */ + private Billing billing; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + public PurchaseReservedEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public PurchaseReservedEipRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public PurchaseReservedEipRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + public PurchaseReservedEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/RecycleOperateEipRequest.java b/src/main/java/com/baidubce/services/eip/model/RecycleOperateEipRequest.java new file mode 100644 index 00000000..3176c084 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/RecycleOperateEipRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for operating recycle eip. + */ +public class RecycleOperateEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + private String clientToken; + /** + * eip address. + */ + private String eip; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + public RecycleOperateEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public RecycleOperateEipRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public RecycleOperateEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/ReleaseEipRequest.java b/src/main/java/com/baidubce/services/eip/model/ReleaseEipRequest.java new file mode 100644 index 00000000..0d0dc95e --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/ReleaseEipRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for releasing eip. + */ +public class ReleaseEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + private String clientToken; + /** + * eip address to be released + */ + private String eip; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + public ReleaseEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public ReleaseEipRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public ReleaseEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/ResizeEipRequest.java b/src/main/java/com/baidubce/services/eip/model/ResizeEipRequest.java new file mode 100644 index 00000000..6d65805d --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/ResizeEipRequest.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for resizing eip. + */ +public class ResizeEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * eip address to be resized + */ + @JsonIgnore + private String eip; + /** + * specify new bandwidth in Mbps for eip + */ + private Integer newBandwidthInMbps; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + public Integer getNewBandwidthInMbps() { + return newBandwidthInMbps; + } + + public void setNewBandwidthInMbps(Integer newBandwidthInMbps) { + this.newBandwidthInMbps = newBandwidthInMbps; + } + + public ResizeEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public ResizeEipRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public ResizeEipRequest withNewBandwidthInMbps(Integer newBandwidthInMbps) { + this.newBandwidthInMbps = newBandwidthInMbps; + return this; + } + + public ResizeEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/StopAutoRenewEipRequest.java b/src/main/java/com/baidubce/services/eip/model/StopAutoRenewEipRequest.java new file mode 100644 index 00000000..85ece6db --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/StopAutoRenewEipRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for stop autoRenew + */ +@Getter +@Setter + +public class StopAutoRenewEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * eip address to be stopped autoRenew + */ + @JsonIgnore + private String eip; + + public StopAutoRenewEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public StopAutoRenewEipRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public StopAutoRenewEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eip/model/UnbindEipRequest.java b/src/main/java/com/baidubce/services/eip/model/UnbindEipRequest.java new file mode 100644 index 00000000..5bd11c39 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/UnbindEipRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for unbinding eip. + */ +public class UnbindEipRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + private String clientToken; + /** + * eip address to be unbound + */ + private String eip; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + public UnbindEipRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public UnbindEipRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public UnbindEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/EipBpClient.java b/src/main/java/com/baidubce/services/eipbp/EipBpClient.java new file mode 100644 index 00000000..f71330ef --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/EipBpClient.java @@ -0,0 +1,395 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipbp; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.eipbp.model.CreateEipBpRequest; +import com.baidubce.services.eipbp.model.CreateEipBpResponse; +import com.baidubce.services.eipbp.model.EipBpDetailResponse; +import com.baidubce.services.eipbp.model.GetEipBpRequest; +import com.baidubce.services.eipbp.model.ListEipBpsRequest; +import com.baidubce.services.eipbp.model.ListEipBpsResponse; +import com.baidubce.services.eipbp.model.ReleaseEipBpRequest; +import com.baidubce.services.eipbp.model.ResizeEipBpRequest; +import com.baidubce.services.eipbp.model.UpdateEipBpAutoReleaseTimeRequest; +import com.baidubce.services.eipbp.model.UpdateEipBpNameRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.DateUtils.validateUtcDate; +import static com.baidubce.util.Validate.checkMultyParamsNotBothEmpty; +import static com.baidubce.util.Validate.checkNotNull; + + +/** + * Provides the client for accessing the Elastic Ip Service (EIPBP). + */ +public class EipBpClient extends AbstractBceClient { + /** + * EIPBP API pathVersion. + */ + private static final String VERSION = "v1"; + + private static final String PREFIX = "eipbp"; + + private static final String CLIENT_TOKEN_IDENTIFY = "clientToken"; + + private static final String RESIZE_ACTION = "resize"; + + private static final String RENAME_ACTION = "rename"; + + private static final String RETIME_ACTION = "retime"; + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static HttpResponseHandler[] eipHandlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public EipBpClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new InstanceClient to invoke service methods on eipbp instance. + * + * @param clientConfiguration The BCE client configuration options. + */ + public EipBpClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, eipHandlers); + } + + /** + * Create an eipbp with the specified options. + * This is an asynchronous interface. + * + * @param request The request containing all options for creating an eipbp. + * @return created eipbp ip. + */ + public CreateEipBpResponse createEipBp(CreateEipBpRequest request) { + checkNotNull(request.getBandwidthInMbps(), "bandwidthInMbps should not be blank!"); + checkMultyParamsNotBothEmpty(Arrays.asList(request.getEip(), request.getEipGroupId()), + "eip and eipGroupId should not be both blank!"); + validateUtcDate(request.getAutoReleaseTime()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEipBpResponse.class); + } + + /** + * Resizing eipbp. + * This is an asynchronous interface. + * + * @param request eipbp id & newBandwidthInMbps must be provided. + */ + public void resizeEipBp(ResizeEipBpRequest request) { + checkNotNull(request.getId(), "id should not be blank!"); + checkNotNull(request.getBandwidthInMbps(), "bandwidthInMbps should not be blank!"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getId()); + internalRequest.addParameter(RESIZE_ACTION, null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, CreateEipBpResponse.class); + } + + /** + * Resizing eipbp. + * + * @param id eipbp id to be resized. + * @param bandwidthInMbps specify new bandwidth in Mbps for eipbp. + */ + public void resizeEipBp(String id, Integer bandwidthInMbps) { + ResizeEipBpRequest resizeEipBpRequest = new ResizeEipBpRequest(); + resizeEipBpRequest.setId(id); + resizeEipBpRequest.setBandwidthInMbps(bandwidthInMbps); + resizeEipBp(resizeEipBpRequest); + } + + + /** + * Get detail of the eipbp givened id. + * + * @param request The request containing eipbp id to query. + * @return the eipbp detail. + */ + public EipBpDetailResponse getEipBpDetail(GetEipBpRequest request) { + checkNotNull(request.getId(), "id should not be blank!"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, request.getId()); + return invokeHttpClient(internalRequest, EipBpDetailResponse.class); + } + + /** + * Get detail of the eipbp givened id. + * + * @param id The eipbp id to query. + * @return the eipbp detail. + */ + public EipBpDetailResponse getEipBpDetail(String id) { + GetEipBpRequest getEipBpRequest = new GetEipBpRequest(); + getEipBpRequest.setId(id); + return getEipBpDetail(getEipBpRequest); + + } + + /** + * Get a list of eipbps owned by the authenticated user and specified conditions. + * + * @param request The request containing all options for query. + * @return the eipbp's list. + */ + public ListEipBpsResponse listEipBps(ListEipBpsRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, null); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() >= 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getId())) { + internalRequest.addParameter("id", request.getId()); + } + if (!Strings.isNullOrEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (!Strings.isNullOrEmpty(request.getBindType())) { + internalRequest.addParameter("bindType", request.getBindType()); + } + if (!Strings.isNullOrEmpty(request.getType())) { + internalRequest.addParameter("type", request.getType()); + } + return invokeHttpClient(internalRequest, ListEipBpsResponse.class); + } + + /** + * Get a list of eipbps owned by the authenticated user. + * + * @return the eipbp's list. + */ + public ListEipBpsResponse listEipBps() { + ListEipBpsRequest request = new ListEipBpsRequest(); + return listEipBps(request); + } + + /** + * Get a list of eipbps owned by the authenticated user and specified conditions. + * + * @param id eipbp's id. + * @param name eipbp's name. + * @param bindType eipbp's bindType, eip or eipgroup. + * @return the eipbp's list. + */ + public ListEipBpsResponse listEipBps(String id, String name, String bindType) { + ListEipBpsRequest request = new ListEipBpsRequest(); + request.withId(id).withName(name).withBindType(bindType); + return listEipBps(request); + } + + /** + * Get a list of eipbps owned by the authenticated user and specified conditions. + * + * @param id eipbp's id. + * @param name eipbp's name. + * @param bindType eipbp's bindType, eip or eipgroup. + * @param type eipbp's type, BandwidthPackage or AccelerationPackage. + * @return the eipbp's list. + */ + public ListEipBpsResponse listEipBps(String id, String name, String bindType, String type) { + ListEipBpsRequest request = new ListEipBpsRequest(); + request.withId(id).withName(name).withBindType(bindType).withType(type); + return listEipBps(request); + } + + /** + * Rename eipbp. + * + * @param request Eipbp id & name must be provided. + */ + public void renameEipBp(UpdateEipBpNameRequest request) { + checkNotNull(request.getId(), "id should not be blank!"); + checkNotNull(request.getName(), "bandwidthInMbps should not be blank!"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getId()); + internalRequest.addParameter(RENAME_ACTION, null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, CreateEipBpResponse.class); + } + + + /** + * Rename eipbp. + * + * @param id eipbp's id. + * @param name eipbp's new name. + */ + public void renameEipBp(String id, String name) { + UpdateEipBpNameRequest updateEipBpNameRequest = new UpdateEipBpNameRequest(); + updateEipBpNameRequest.withId(id).withName(name); + renameEipBp(updateEipBpNameRequest); + } + + /** + * Update eipbp's autoReleaseTime. + * + * @param request Eipbp id & autoReleaseTime must be provided, the autoReleaseTime must be in UTC format. + */ + public void updateAutoReleaseTime(UpdateEipBpAutoReleaseTimeRequest request) { + checkNotNull(request.getId(), "id should not be blank!"); + checkNotNull(request.getAutoReleaseTime(), "autoReleaseTime should not be blank!"); + validateUtcDate(request.getAutoReleaseTime()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getId()); + internalRequest.addParameter(RETIME_ACTION, null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, CreateEipBpResponse.class); + } + + + /** + * Update eipbp's autoReleaseTime. + * + * @param id eipbp's id. + * @param autoReleaseTime eipbp's autoReleaseTime, must be in UTC format. + */ + public void updateAutoReleaseTime(String id, String autoReleaseTime) { + UpdateEipBpAutoReleaseTimeRequest updateEipBpNameRequest = new UpdateEipBpAutoReleaseTimeRequest(); + updateEipBpNameRequest.withId(id).withAutoReleaseTime(autoReleaseTime); + updateAutoReleaseTime(updateEipBpNameRequest); + } + + + /** + * release the eipbp(delete operation). + * + * @param request The request containing all options for releasing eipbp. + */ + public void releaseEipBp(ReleaseEipBpRequest request) { + checkNotNull(request.getId(), "id should not be blank!"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, request.getId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + invokeHttpClient(internalRequest, CreateEipBpResponse.class); + } + + /** + * release the eipbp(delete operation). + * + * @param id The id eipbp to be released. + */ + public void releaseEipBp(String id) { + ReleaseEipBpRequest releaseEipBpRequest = new ReleaseEipBpRequest(); + releaseEipBp(releaseEipBpRequest.withId(id)); + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest( + AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + path.add(PREFIX); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateDefaultClientToken() { + return UUID.randomUUID().toString(); + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/CreateEipBpRequest.java b/src/main/java/com/baidubce/services/eipbp/model/CreateEipBpRequest.java new file mode 100644 index 00000000..37fce8af --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/CreateEipBpRequest.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for creating a newly eipBp. + */ +@Getter +@Setter +public class CreateEipBpRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * The name of eipBp. The optional parameter. + */ + private String name; + /** + * The eip address that the eipBp attach. Param "eip" and "eipGroupId" will have only one param take effect. + */ + private String eip; + /** + * The eipGroupId that the eipBp attach. Param "eip" and "eipGroupId" will have only one param take effect. + */ + private String eipGroupId; + /** + * The bandwidth of eipBp in Mbps. + */ + private Integer bandwidthInMbps; + /** + * The eipBp autoReleaseTime. Format is "yyyy-MM-ddTHH:mm:ssZ". The optional parameter. + */ + private String autoReleaseTime; + + /** + * The tags which will be bound to eipBp. + */ + private List tags; + + /** + * The ID of resourceGroup which will be bound to eipBp. + */ + private String resourceGroupId; + + public CreateEipBpRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public CreateEipBpRequest withName(String name) { + this.name = name; + return this; + } + + public CreateEipBpRequest withEip(String eip) { + this.eip = eip; + return this; + } + + public CreateEipBpRequest withEipGroupId(String eipGroupId) { + this.eipGroupId = eipGroupId; + return this; + } + + public CreateEipBpRequest withBandwidthInMbps(Integer bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + return this; + } + + + public CreateEipBpRequest withAutoReleaseTime(String autoReleaseTime) { + this.autoReleaseTime = autoReleaseTime; + return this; + } + + public CreateEipBpRequest withTags(List tags) { + this.tags = tags; + return this; + } + + public CreateEipBpRequest withResourceGroupId(String resourceGroupId) { + this.resourceGroupId = resourceGroupId; + return this; + } + + public CreateEipBpRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/CreateEipBpResponse.java b/src/main/java/com/baidubce/services/eipbp/model/CreateEipBpResponse.java new file mode 100644 index 00000000..8d8d9e71 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/CreateEipBpResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.ToString; + +/** + * The response for create eipBp. + */ +@ToString +public class CreateEipBpResponse extends AbstractBceResponse { + + /** + * The created eipBp's id. + * */ + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/EipBpDetailResponse.java b/src/main/java/com/baidubce/services/eipbp/model/EipBpDetailResponse.java new file mode 100644 index 00000000..234fd7fe --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/EipBpDetailResponse.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.TagModel; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * The response for get eipBp detail. + */ +@Getter +@Setter +@ToString +public class EipBpDetailResponse extends AbstractBceResponse { + /** + * The name of eipBp. + */ + private String name; + + /** + * The id of eipBp. + */ + private String id; + + /** + * The type of eipBp binding.'eip' or 'eipGroup'. + */ + private String bindType; + + /** + * The bandwidthInMbps of eipBp. + */ + private Integer bandwidthInMbps; + + /** + * The instanceId of eipBp binding. + */ + private String instanceId; + + /** + * The ips of eipBp binding. If bindType is eip,this param contains only one ip address, + * else contains all ip address in eipGroup. + */ + private List eips; + + /** + * The instance's bandwidthInMbps of eipBp binding. + */ + private Integer instanceBandwidthInMbps; + + /** + * The eipBp createTime. UTC format. + */ + private String createTime; + + /** + * The eipBp autoReleaseTime. UTC format. If not set, it is the same as the expiration time of the bound resource. + */ + private String autoReleaseTime; + + /** + * The tags bound to eipBp. + */ + private List tags; +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/GetEipBpRequest.java b/src/main/java/com/baidubce/services/eipbp/model/GetEipBpRequest.java new file mode 100644 index 00000000..ac9bec57 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/GetEipBpRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get eipBp detail. + */ +public class GetEipBpRequest extends AbstractBceRequest { + + /** + * EipBp id. + * */ + private String id; + + /** + * Configure id for the request. + * + * @param id The id of GetEipBpRequest + * @return GetEipBpRequest with specific id + */ + public GetEipBpRequest withId(String id) { + this.id = id; + return this; + } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public GetEipBpRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/ListEipBpsRequest.java b/src/main/java/com/baidubce/services/eipbp/model/ListEipBpsRequest.java new file mode 100644 index 00000000..f7346218 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/ListEipBpsRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.services.eip.model.ListRequest; + +/** + * The request for listing eipBp. + */ +public class ListEipBpsRequest extends ListRequest { + /** + * eipbp id condition. + */ + private String id; + /** + * eipbp name condition. + */ + private String name; + /** + * eipbp binding instance type condition. + */ + private String bindType; + + /** + * eipbp type condition. + */ + private String type; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getBindType() { + return bindType; + } + + public void setBindType(String bindType) { + this.bindType = bindType; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ListEipBpsRequest withId(String id) { + this.id = id; + return this; + } + + public ListEipBpsRequest withName(String name) { + this.name = name; + return this; + } + + public ListEipBpsRequest withBindType(String bindType) { + this.bindType = bindType; + return this; + } + + public ListEipBpsRequest withType(String type) { + this.type = type; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/ListEipBpsResponse.java b/src/main/java/com/baidubce/services/eipbp/model/ListEipBpsResponse.java new file mode 100644 index 00000000..e0d5cf42 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/ListEipBpsResponse.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.services.eip.model.ListResponse; +import lombok.ToString; + +import java.util.List; + +/** + * the response of listing eipBps. + */ +public class ListEipBpsResponse extends ListResponse { + private List bpList; + + public List getBpList() { + return bpList; + } + + public void setBpList(List bpList) { + this.bpList = bpList; + } + + @ToString + public static class BandwidthPackage { + /** + * The name of eipBp. + */ + private String name; + /** + * The id of eipBp. + */ + private String id; + /** + * The type of eipBp binding.'eip' or 'eipgroup'. + */ + private String bindType; + /** + * The bandwidthInMbps of eipBp. + */ + private Integer bandwidthInMbps; + /** + * The instanceId of eipBp binding. + */ + private String instanceId; + /** + * The ips of eipBp binding. If bindType is eip,this param contains only one ip address, + * else contains all ip address in eipgroup. + */ + private List eips; + /** + * The eipBp createTime. UTC format. + */ + private String createTime; + /** + * The eipBp autoReleaseTime. UTC format. If not set, it is the same as the expiration time of the bound resource. + */ + private String autoReleaseTime; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getBindType() { + return bindType; + } + + public void setBindType(String bindType) { + this.bindType = bindType; + } + + public Integer getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(Integer bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public List getEips() { + return eips; + } + + public void setEips(List eips) { + this.eips = eips; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getAutoReleaseTime() { + return autoReleaseTime; + } + + public void setAutoReleaseTime(String autoReleaseTime) { + this.autoReleaseTime = autoReleaseTime; + } + } + + @Override + public String toString() { + return "ListEipBpsResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "bpList=" + bpList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/ReleaseEipBpRequest.java b/src/main/java/com/baidubce/services/eipbp/model/ReleaseEipBpRequest.java new file mode 100644 index 00000000..a86e35f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/ReleaseEipBpRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for releasing eipbp. + */ +public class ReleaseEipBpRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + private String clientToken; + /** + * eipbp's id to be released + */ + private String id; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ReleaseEipBpRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + public ReleaseEipBpRequest withId(String id) { + this.id = id; + return this; + } + + public ReleaseEipBpRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/ResizeEipBpRequest.java b/src/main/java/com/baidubce/services/eipbp/model/ResizeEipBpRequest.java new file mode 100644 index 00000000..229702fc --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/ResizeEipBpRequest.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for resize eipBp. + */ +public class ResizeEipBpRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * eipBp id. + */ + private String id; + + /** + * new bandwidthInMbps of the eipBp. + */ + private Integer bandwidthInMbps; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(Integer bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public ResizeEipBpRequest withId(String id) { + this.id = id; + return this; + } + + public ResizeEipBpRequest withBandwidthInMbps(Integer bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + return this; + } + + public ResizeEipBpRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/UpdateEipBpAutoReleaseTimeRequest.java b/src/main/java/com/baidubce/services/eipbp/model/UpdateEipBpAutoReleaseTimeRequest.java new file mode 100644 index 00000000..09055f50 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/UpdateEipBpAutoReleaseTimeRequest.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for update eipBp's autoReleaseTime. + */ +public class UpdateEipBpAutoReleaseTimeRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * EipBp's id. + */ + private String id; + + /** + * The autoReleaseTime of the eipBp. + */ + private String autoReleaseTime; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAutoReleaseTime() { + return autoReleaseTime; + } + + public void setAutoReleaseTime(String autoReleaseTime) { + this.autoReleaseTime = autoReleaseTime; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public UpdateEipBpAutoReleaseTimeRequest withId(String id) { + this.id = id; + return this; + } + + public UpdateEipBpAutoReleaseTimeRequest withAutoReleaseTime(String autoReleaseTime) { + this.autoReleaseTime = autoReleaseTime; + return this; + } + + public UpdateEipBpAutoReleaseTimeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipbp/model/UpdateEipBpNameRequest.java b/src/main/java/com/baidubce/services/eipbp/model/UpdateEipBpNameRequest.java new file mode 100644 index 00000000..fc96e151 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipbp/model/UpdateEipBpNameRequest.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipbp.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for update eipBp's name. + */ +public class UpdateEipBpNameRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * eipBp id. + */ + private String id; + + /** + * new name of the eipBp. + */ + private String name; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public UpdateEipBpNameRequest withId(String id) { + this.id = id; + return this; + } + + public UpdateEipBpNameRequest withName(String name) { + this.name = name; + return this; + } + + public UpdateEipBpNameRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/EipGroupClient.java b/src/main/java/com/baidubce/services/eipgroup/EipGroupClient.java new file mode 100644 index 00000000..500bd150 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/EipGroupClient.java @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup; + +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import com.baidubce.services.eipgroup.model.EipGroupOperateRequest; +import com.baidubce.services.eipgroup.model.MoveInRequest; +import com.baidubce.services.eipgroup.model.MoveOutRequest; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.eipgroup.model.BandwidthInMbpsRequest; +import com.baidubce.services.eipgroup.model.CreateEipGroupRequest; +import com.baidubce.services.eipgroup.model.EipCountRequest; +import com.baidubce.services.eipgroup.model.EipNameRequest; +import com.baidubce.services.eipgroup.model.GetEipGroupRequest; +import com.baidubce.services.eipgroup.model.GetEipGroupResponse; +import com.baidubce.services.eipgroup.model.IdResponse; +import com.baidubce.services.eipgroup.model.ListEipGroupRequest; +import com.baidubce.services.eipgroup.model.ListEipGroupResponse; +import com.baidubce.services.eipgroup.model.PurchaseReservedEipGroupRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; + +/** + * Provides the client for accessing the Baidu Cloud network Service nat part. + */ +public class EipGroupClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(EipGroupClient.class); + + private static final String VERSION = "v1"; + private static final String PREFIX = "eipgroup"; + + /** + * Responsible for handling httpResponses from all network service calls. + */ + private static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on network. + */ + public EipGroupClient() { + this(new EipGroupClientConfiguration()); + } + + /** + * Constructs a new network client using the client configuration to access network. + * + * @param clientConfiguration The network client configuration options controlling how this client + * connects to network (e.g. proxy settings, retry counts, etc). + */ + public EipGroupClient(EipGroupClientConfiguration clientConfiguration) { + super(clientConfiguration, HANDLERS); + } + + /** + * Creates and initializes a new request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * Create a eip group with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + *

+ * + * @param request The request containing all options for creating a eip group. + * @return eip group's id newly created + * @throws BceClientException + */ + public IdResponse createEipGroup(CreateEipGroupRequest request) { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + checkNotNull(request.getBilling(), "billing should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, PREFIX); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, IdResponse.class); + } + + /** + * Resize the bandwidth. + * + * @param request The request containing all options for binding the eips to specified eip group. + */ + public void resizeBandwidth(BandwidthInMbpsRequest request) { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, PREFIX, request.getId()); + internalRequest.addParameter("resize", null); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Resize the name. + * + * @param request The request containing all options for binding the eips to specified eip group. + */ + public void update(EipNameRequest request) { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, PREFIX, request.getId()); + internalRequest.addParameter("update", null); + fillPayload(internalRequest, request); + internalRequest.addParameter("clientToken", request.getClientToken()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Resize the count. + * + * @param request The request containing all options for binding the eips to specified eip group. + */ + public void addCount(EipCountRequest request) { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, PREFIX, request.getId()); + internalRequest.addParameter("resize", null); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of eip groups owned by the authenticated user. + * + * @param request The request containing all options for listing own's eip groups. + * @return The response containing a list of eip groups owned by the authenticated user. + */ + public ListEipGroupResponse listEipGroup(ListEipGroupRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, PREFIX); + if (StringUtils.isNotBlank(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (StringUtils.isNotBlank(request.getId())) { + internalRequest.addParameter("id", request.getId()); + } + if (StringUtils.isNotBlank(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (StringUtils.isNotBlank(request.getStatus())) { + internalRequest.addParameter("status", request.getStatus()); + } + + return invokeHttpClient(internalRequest, ListEipGroupResponse.class); + } + + /** + * Get the detail information of specified eip group. + * + * @param request The request of the eip group. + * @return A eip group detail model for the request. + */ + public GetEipGroupResponse getEipGroup(GetEipGroupRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getId(), "id should not be empty."); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, PREFIX, request.getId()); + return this.invokeHttpClient(internalRequest, GetEipGroupResponse.class); + } + + /** + * PurchaseReserving specified eip group. + * + * @param request The request containing all options for purchaseReserving the eips to specified eip group. + */ + public void purchaseReservedEipGroup(PurchaseReservedEipGroupRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getId(), "id should not be empty."); + checkNotNull(request.getBilling(), "billing should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, PREFIX, request.getId()); + internalRequest.addParameter("purchaseReserved", null); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * release eip group. + * + * @param request The request containing all options for release the specified eip group. + */ + public void releaseEipGroup(EipGroupOperateRequest request) { + checkStringNotEmpty(request.getId(), "id should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, PREFIX, request.getId()); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * move eip form group. + * + * @param request The request containing all options for move the specified eips from group. + */ + public void moveOutEips(MoveOutRequest request) { + checkStringNotEmpty(request.getId(), "id should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, PREFIX, request.getId()); + internalRequest.addParameter("move_out", null); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * move eip into eipgroup. + * + * @param request The request containing all options for move the specified eips into group. + */ + public void moveInEips(MoveInRequest request) { + checkStringNotEmpty(request.getId(), "id should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, PREFIX, request.getId()); + internalRequest.addParameter("move_in", null); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/eipgroup/EipGroupClientConfiguration.java b/src/main/java/com/baidubce/services/eipgroup/EipGroupClientConfiguration.java new file mode 100644 index 00000000..be4b30ef --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/EipGroupClientConfiguration.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for nat service. + */ +public class EipGroupClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/BandwidthInMbpsRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/BandwidthInMbpsRequest.java new file mode 100644 index 00000000..aacae153 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/BandwidthInMbpsRequest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for updating bandwidth. + */ +public class BandwidthInMbpsRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of eip group. + */ + @JsonIgnore + private String id; + + /** + * The bandwidthInMbps of eip group. + */ + private int bandwidthInMbps; + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure id for the request. + * + * @param id The id of BandwidthInMbpsRequest + * @return BandwidthInMbpsRequest with specific id + */ + public BandwidthInMbpsRequest withId(String id) { + this.id = id; + return this; + } + + /** + * Configure bandwidthInMbps for the request. + * + * @param bandwidthInMbps The bandwidthInMbps of BandwidthInMbpsRequest + * @return BandwidthInMbpsRequest with specific bandwidthInMbps + */ + public BandwidthInMbpsRequest withBandwidthInMbpst(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/CreateEipGroupRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/CreateEipGroupRequest.java new file mode 100644 index 00000000..e7fe1c1e --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/CreateEipGroupRequest.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.baidubce.services.eip.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for creating a nat. + */ +@Getter +@Setter +public class CreateEipGroupRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The name of eip group. + */ + private String name; + + /** + * The eipCount of eip group. + */ + private int eipCount; + + /** + * The bandwidthInMbps of eip group. + */ + private int bandwidthInMbps; + + /** + * The billing of eip group + */ + private Billing billing; + + /** + * The tags which will be bound to eipGroup. + */ + private List tags; + + /** + * The ID of resourceGroup which will be bound to eipGroup. + */ + private String resourceGroupId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure name for the request. + * + * @param name The name of CreateNatRequest + * @return CreateNatRequest with specific name + */ + public CreateEipGroupRequest withName(String name) { + this.name = name; + return this; + } + + /** + * Configure eipCount for the request. + * + * @param eipCount The eipCount of CreateEipGroupRequest + * @return CreateEipGroupRequest with specific eipCount + */ + public CreateEipGroupRequest withEipCount(int eipCount) { + this.eipCount = eipCount; + return this; + } + + /** + * Configure bandwidthInMbps for the request. + * + * @param bandwidthInMbps The bandwidthInMbps of CreateEipGroupRequest + * @return CreateEipGroupRequest with specific bandwidthInMbps + */ + public CreateEipGroupRequest withBandwidthInMbpst(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + return this; + } + + /** + * Configure billing for the request. + * + * @param billing The spec of CreateNatRequest + * @return CreateNatRequest with specific billing + */ + public CreateEipGroupRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + /** + * Configure tags for the request. + * + * @param tags The tags which will be bound to eipGroup. + * @return CreateEipGroupRequest with specific tags. + */ + public CreateEipGroupRequest withTags(List tags) { + this.tags = tags; + return this; + } + + /** + * Configure resourceGroupId for the request. + * + * @param resourceGroupId The ID of resourceGroup which will be bound to eipGroup. + * @return CreateEipGroupRequest with specific resourceGroupId. + */ + public CreateEipGroupRequest withResourceGroupId(String resourceGroupId) { + this.resourceGroupId = resourceGroupId; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/Eip.java b/src/main/java/com/baidubce/services/eipgroup/model/Eip.java new file mode 100644 index 00000000..9eca2a5e --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/Eip.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class Eip { + + /** + * The name of eip. + */ + private String name; + + /** + * The ip of eip. + */ + private String eip; + + /** + * The status of eip. + */ + private String status; + + /** + * The eipInstanceType of eip. + */ + private String eipInstanceType; + + /** + * The instanceType of eip. + */ + private String instanceType; + + /** + * The instanceId of eip. + */ + private String instanceId; + + /** + * The shareGroupId of eip. + */ + private String shareGroupId; + + /** + * The paymentTiming of eip. + */ + private String paymentTiming; + + /** + * The bandwidthInMbps of eip. + */ + private int bandwidthInMbps; + + /** + * The billingMethod of eip. + */ + private String billingMethod; + + /** + * The createTime of eip. + */ + private String createTime; + + /** + * The expireTime of eip. + */ + private String expireTime; +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/EipCountRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/EipCountRequest.java new file mode 100644 index 00000000..426e27a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/EipCountRequest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for adding eip group count. + */ +public class EipCountRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of eip group. + */ + @JsonIgnore + private String id; + + /** + * The eipAddCount of eip group. + */ + private int eipAddCount; + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure id for the request. + * + * @param id The id of BandwidthInMbpsRequest + * @return BandwidthInMbpsRequest with specific id + */ + public EipCountRequest withId(String id) { + this.id = id; + return this; + } + + /** + * Configure eipAddCount for the request. + * + * @param eipAddCount The bandwidthInMbps of EipCountRequest + * @return EipCountRequest with specific eipAddCount + */ + public EipCountRequest withEipAddCount(int eipAddCount) { + this.eipAddCount = eipAddCount; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getEipAddCount() { + return eipAddCount; + } + + public void setEipAddCount(int eipAddCount) { + this.eipAddCount = eipAddCount; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/EipGroup.java b/src/main/java/com/baidubce/services/eipgroup/model/EipGroup.java new file mode 100644 index 00000000..83e1dce0 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/EipGroup.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.services.bcc.model.TagModel; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * Eip group model. + */ +@Getter +@Setter +@ToString +public class EipGroup { + + /** + * The id of EipGroup. + */ + private String id; + + /** + * The name of EipGroup. + */ + private String name; + + /** + * The eips of EipGroup. + */ + private List eips; + + /** + * The status of EipGroup. + */ + private String status; + + /** + * The bandwidthInMbps of EipGroup. + */ + private int bandwidthInMbps; + + /** + * The paymentTiming of EipGroup. + */ + private String paymentTiming; + + /** + * The createTime of EipGroup. + */ + private String createTime; + + /** + * The expireTime of EipGroup. + */ + private String expireTime; + + /** + * The tags bound to eipGroup. + */ + private List tags; +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/EipGroupOperateRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/EipGroupOperateRequest.java new file mode 100644 index 00000000..be55d557 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/EipGroupOperateRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for operate eipgroup. + */ +@Getter +@Setter +public class EipGroupOperateRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of eip group. + */ + private String id; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure id for the request. + * + * @param id The id of EipNameRequest + * @return EipNameRequest with specific id + */ + public EipGroupOperateRequest withId(String id) { + this.id = id; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/EipNameRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/EipNameRequest.java new file mode 100644 index 00000000..6e3e3adf --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/EipNameRequest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for updating eip group name. + */ +public class EipNameRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of eip group. + */ + @JsonIgnore + private String id; + + /** + * The name of eip group. + */ + private String name; + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure id for the request. + * + * @param id The id of EipNameRequest + * @return EipNameRequest with specific id + */ + public EipNameRequest withId(String id) { + this.id = id; + return this; + } + + /** + * Configure name for the request. + * + * @param name The name of EipNameRequest + * @return EipNameRequest with specific name + */ + public EipNameRequest withName(String name) { + this.name = name; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/GetEipGroupRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/GetEipGroupRequest.java new file mode 100644 index 00000000..cf18c9b4 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/GetEipGroupRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for get a eip group. + */ +public class GetEipGroupRequest extends AbstractBceRequest { + + /** + * The id of eip group. + */ + private String id; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure id for the request. + * + * @param id The id of GetEipGroupRequest + * @return GetEipGroupRequest with specific id + */ + public GetEipGroupRequest withId(String id) { + this.id = id; + return this; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/GetEipGroupResponse.java b/src/main/java/com/baidubce/services/eipgroup/model/GetEipGroupResponse.java new file mode 100644 index 00000000..600592af --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/GetEipGroupResponse.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.TagModel; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * Eip group model. + */ +@Getter +@Setter +@ToString +public class GetEipGroupResponse extends AbstractBceResponse { + + /** + * The id of EipGroup. + */ + private String id; + + /** + * The name of EipGroup. + */ + private String name; + + /** + * The eips of EipGroup. + */ + private List eips; + + /** + * The status of EipGroup. + */ + private String status; + + /** + * The bandwidthInMbps of EipGroup. + */ + private int bandwidthInMbps; + + /** + * The paymentTiming of EipGroup. + */ + private String paymentTiming; + + /** + * The createTime of EipGroup. + */ + private String createTime; + + /** + * The expireTime of EipGroup. + */ + private String expireTime; + + /** + * The tags bound to eipGroup. + */ + private List tags; +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/IdResponse.java b/src/main/java/com/baidubce/services/eipgroup/model/IdResponse.java new file mode 100644 index 00000000..084c1bbc --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/IdResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class IdResponse extends AbstractBceResponse { + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/ListEipGroupRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/ListEipGroupRequest.java new file mode 100644 index 00000000..9d325319 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/ListEipGroupRequest.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; + +/** + * The request for list eip group. + */ +public class ListEipGroupRequest extends ListRequest { + + /** + * The id of eip group. + */ + private String id; + + /** + * The name of eip group. + */ + private String name; + + /** + * The status of eip group. + */ + private String status; + + /** + * Configure id for the request. + * + * @param id The id of ListEipGroupRequest + * @return ListEipGroupRequest with specific id + */ + public ListEipGroupRequest withId(String id) { + this.id = id; + return this; + } + + /** + * Configure name for the request. + * + * @param name The name of ListEipGroupRequest + * @return ListEipGroupRequest with specific name + */ + public ListEipGroupRequest withNatId(String name) { + this.name = name; + return this; + } + + /** + * Configure status for the request. + * + * @param status The status of ListEipGroupRequest + * @return ListEipGroupRequest with specific status + */ + public ListEipGroupRequest withStatus(String status) { + this.status = status; + return this; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/ListEipGroupResponse.java b/src/main/java/com/baidubce/services/eipgroup/model/ListEipGroupResponse.java new file mode 100644 index 00000000..ea24b212 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/ListEipGroupResponse.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.model.ListResponse; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The response for list eip group request. + */ +@Getter +@Setter +public class ListEipGroupResponse extends ListResponse { + + /** + * List of eip group info + */ + private List eipgroups; + + @Override + public String toString() { + return "ListEipGroupResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "eipgroups=" + eipgroups + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/MoveInRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/MoveInRequest.java new file mode 100644 index 00000000..7639da22 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/MoveInRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipgroup.model; + +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for move out eip from eipgroup. + */ +@Getter +@Setter +public class MoveInRequest extends EipGroupOperateRequest { + + /** + * move in eip params + */ + private List eips; + + /** + * Configure moveInEips for the request. + * + * @param eips The list of moveInEipsRequest + * @return EipNameRequest with specific moveOutEipsRequest + */ + public MoveInRequest withEips(List eips) { + this.eips = eips; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/MoveOutRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/MoveOutRequest.java new file mode 100644 index 00000000..1d570d8d --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/MoveOutRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.services.eip.model.Billing; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for move out eip from eipgroup. + */ +@Getter +@Setter +public class MoveOutRequest extends EipGroupOperateRequest { + + /** + * move out eip params + */ + private List moveOutEips; + + @Getter + @Setter + public static class EipMoveOutModel { + /** + * the ip of move out eip + */ + private String eip; + /** + * the bandwidthInMbps of move out eip. + * only native eip of group need this parameter. + */ + private Integer bandwidthInMbps; + /** + * the billing of move out eip. + * only native eip of group need this parameter. + */ + private Billing billing; + } + + /** + * Configure moveOutEips for the request. + * + * @param moveOutEips The list of moveOutEipsRequest + * @return EipNameRequest with specific moveOutEipsRequest + */ + public MoveOutRequest withMoveOutEips(List moveOutEips) { + this.moveOutEips = moveOutEips; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eipgroup/model/PurchaseReservedEipGroupRequest.java b/src/main/java/com/baidubce/services/eipgroup/model/PurchaseReservedEipGroupRequest.java new file mode 100644 index 00000000..93a31756 --- /dev/null +++ b/src/main/java/com/baidubce/services/eipgroup/model/PurchaseReservedEipGroupRequest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eipgroup.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.eip.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for purchaseReserving eip group. + */ +public class PurchaseReservedEipGroupRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of eip group. + */ + @JsonIgnore + private String id; + + /** + * The billing of eip group that will be purchaseReserved. + */ + private Billing billing; + + /** + * Configure billing for the request. + * + * @param billing The spec of PurchaseReservedEipGroupRequest + * @return PurchaseReservedEipGroupRequest with specific billing + */ + public PurchaseReservedEipGroupRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + /** + * Configure id for the request. + * + * @param id The id of the eip group. + * @return PurchaseReservedNatRequest with specific id + */ + public PurchaseReservedEipGroupRequest withId(String id) { + this.id = id; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eiptp/EipTpClient.java b/src/main/java/com/baidubce/services/eiptp/EipTpClient.java new file mode 100644 index 00000000..83b68cb2 --- /dev/null +++ b/src/main/java/com/baidubce/services/eiptp/EipTpClient.java @@ -0,0 +1,213 @@ +package com.baidubce.services.eiptp; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.eiptp.model.CreateEipTpRequest; +import com.baidubce.services.eiptp.model.CreateEipTpResponse; +import com.baidubce.services.eiptp.model.EipTpDetailResponse; +import com.baidubce.services.eiptp.model.GetEipTpRequest; +import com.baidubce.services.eiptp.model.ListEipTpsRequest; +import com.baidubce.services.eiptp.model.ListEipTpsResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; + +/** + * Provides the client for accessing the Elastic Ip Service (EIP TP). + */ +public class EipTpClient extends AbstractBceClient { + + /** + * EIP TP API pathVersion. + */ + private static final String VERSION = "v1"; + + /** + * EIP TP url prefix + */ + private static final String PREFIX = "eiptp"; + + private static final String CLIENT_TOKEN_IDENTIFY = "clientToken"; + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static HttpResponseHandler[] eipHandlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public EipTpClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new InstanceClient to invoke service methods on eiptp instance. + * + * @param clientConfiguration The BCE client configuration options. + */ + public EipTpClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, eipHandlers); + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest( + AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + path.add(PREFIX); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateDefaultClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * Create an eiptp with the specified options. + * + * @param request The request containing all options for creating an eiptp. + * @return created eiptp id. + */ + public CreateEipTpResponse createEipTp(CreateEipTpRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getReservationLength(), "reservationLength should not be null."); + checkStringNotEmpty(request.getCapacity(), "capacity should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEipTpResponse.class); + } + + /** + * Get detail of the eiptp by the request. + * + * @param request The request containing eiptp id for query. + * @return the eiptp detail. + */ + public EipTpDetailResponse getEipTpDetail(GetEipTpRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getId(), "id should not be blank!"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, request.getId()); + return invokeHttpClient(internalRequest, EipTpDetailResponse.class); + } + + /** + * Get detail of the eiptp by the passed id. + * + * @param id The eiptp id for query. + * @return the eiptp detail. + */ + public EipTpDetailResponse getEipTpDetail(String id) { + GetEipTpRequest getEipTpRequest = new GetEipTpRequest(); + getEipTpRequest.setId(id); + return getEipTpDetail(getEipTpRequest); + } + + /** + * Get a list of eiptps owned by the authenticated user filtered by specific conditions. + * + * @param request The request containing all options for query. + * @return the list of eiptps. + */ + public ListEipTpsResponse listEipTps(ListEipTpsRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, null); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0 && request.getMaxKeys() <= 1000) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getId())) { + internalRequest.addParameter("id", request.getId()); + } + if (!Strings.isNullOrEmpty(request.getDeductPolicy())) { + internalRequest.addParameter("deductPolicy", request.getDeductPolicy()); + } + if (!Strings.isNullOrEmpty(request.getStatus())) { + internalRequest.addParameter("status", request.getStatus()); + } + return invokeHttpClient(internalRequest, ListEipTpsResponse.class); + } + + /** + * Get a list of eiptps owned by the authenticated user. + * + * @return the list of eiptps. + */ + public ListEipTpsResponse listEipTps() { + ListEipTpsRequest request = new ListEipTpsRequest(); + return listEipTps(request); + } +} diff --git a/src/main/java/com/baidubce/services/eiptp/model/CreateEipTpRequest.java b/src/main/java/com/baidubce/services/eiptp/model/CreateEipTpRequest.java new file mode 100644 index 00000000..bd8597f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/eiptp/model/CreateEipTpRequest.java @@ -0,0 +1,53 @@ +package com.baidubce.services.eiptp.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for creating a new eipTp. + */ +@Setter +@Getter +public class CreateEipTpRequest extends AbstractBceRequest { + /** + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * The reservation length of the eiptp including 1, 6 and 12 months. + */ + private Integer reservationLength; + + /** + * The capacity of the eiptp. + * When reservationLength = 1 => capacity: {"10G"/"50G"/"100G"/"500G"/"1T"/"5T"/"10T"/"50T"} + * When reservationLength = 6 => capacity: {"60G"/"300G"/"600G"/"3T"/"6T"/"30T"/"60T"/"300T"} + * When reservationLength = 12 => capacity: {"1T"/"10T"/"50T"/"100T"/"500T"/"1P"} + */ + private String capacity; + + /** + * The deduct policy of the eiptp including "FullTimeDurationPackage" and "TimeDurationPackage". + * The default deduct policy is "FullTimeDurationPackage", the optional parameter. + */ + private String deductPolicy; + + /** + * The eiptp package type. + * The default package type is "WebOutBytes", the optional parameter. + */ + private String packageType; + + @Override + public CreateEipTpRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eiptp/model/CreateEipTpResponse.java b/src/main/java/com/baidubce/services/eiptp/model/CreateEipTpResponse.java new file mode 100644 index 00000000..e2c0820f --- /dev/null +++ b/src/main/java/com/baidubce/services/eiptp/model/CreateEipTpResponse.java @@ -0,0 +1,19 @@ +package com.baidubce.services.eiptp.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * The response for creating an eipTp. + */ +@Getter +@Setter +@ToString +public class CreateEipTpResponse extends AbstractBceResponse { + /** + * The created eiptp's id. + * */ + private String id; +} diff --git a/src/main/java/com/baidubce/services/eiptp/model/EipTpDetailResponse.java b/src/main/java/com/baidubce/services/eiptp/model/EipTpDetailResponse.java new file mode 100644 index 00000000..e1626820 --- /dev/null +++ b/src/main/java/com/baidubce/services/eiptp/model/EipTpDetailResponse.java @@ -0,0 +1,60 @@ +package com.baidubce.services.eiptp.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * The response for getting eiptp detail. + */ +@Getter +@Setter +@ToString +public class EipTpDetailResponse extends AbstractBceResponse { + + /** + * The id of the eiptp. + */ + private String id; + + /** + * The deduct policy of the eiptp including "FullTimeDurationPackage" and "TimeDurationPackage". + */ + private String deductPolicy; + + /** + * The capacity of the eiptp. + */ + private String capacity; + + /** + * The capacity of the eiptp already used by the user. + */ + private String usedCapacity; + + /** + * The status of the eiptp including "RUNNING", "EXPIRED" and "USED_UP". + */ + private String status; + + /** + * The package type of the eiptp. + */ + private String packageType; + + /** + * The active time of the eiptp (GMT+8 format). + */ + private String activeTime; + + /** + * The expire time of the eiptp (GMT+8 format). + */ + private String expireTime; + + /** + * The eiptp createTime (GMT+8 format). + */ + private String createTime; +} diff --git a/src/main/java/com/baidubce/services/eiptp/model/GetEipTpRequest.java b/src/main/java/com/baidubce/services/eiptp/model/GetEipTpRequest.java new file mode 100644 index 00000000..890baea0 --- /dev/null +++ b/src/main/java/com/baidubce/services/eiptp/model/GetEipTpRequest.java @@ -0,0 +1,36 @@ +package com.baidubce.services.eiptp.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for getting eiptp detail. + */ +@Getter +@Setter +public class GetEipTpRequest extends AbstractBceRequest { + + /** + * The eiptp id. + */ + private String id; + + /** + * Configure id for the request. + * + * @param id The id of GetEipTpRequest + * @return GetEipTpRequest with the specific id + */ + public GetEipTpRequest withId(String id) { + this.id = id; + return this; + } + + @Override + public GetEipTpRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eiptp/model/ListEipTpsRequest.java b/src/main/java/com/baidubce/services/eiptp/model/ListEipTpsRequest.java new file mode 100644 index 00000000..7da622ed --- /dev/null +++ b/src/main/java/com/baidubce/services/eiptp/model/ListEipTpsRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.eiptp.model; + +import com.baidubce.services.eip.model.ListRequest; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +/** + * The request for listing eiptp. + */ +public class ListEipTpsRequest extends ListRequest { + + /** + * The eiptp id. + * The optional parameter. + */ + private String id; + + /** + * The deduct policy of the eiptp including "FullTimeDurationPackage" and "TimeDurationPackage". + * The optional parameter. + */ + private String deductPolicy; + + /** + * The status of the eiptp including "RUNNING", "EXPIRED" and "USED_UP". + * The optional parameter. + */ + private String status; +} diff --git a/src/main/java/com/baidubce/services/eiptp/model/ListEipTpsResponse.java b/src/main/java/com/baidubce/services/eiptp/model/ListEipTpsResponse.java new file mode 100644 index 00000000..3c780efe --- /dev/null +++ b/src/main/java/com/baidubce/services/eiptp/model/ListEipTpsResponse.java @@ -0,0 +1,93 @@ +package com.baidubce.services.eiptp.model; + +import java.util.List; + +import com.baidubce.services.eip.model.ListResponse; + +import lombok.Getter; +import lombok.Setter; + +/** + * The request for listing eiptp. + */ +@Setter +@Getter +public class ListEipTpsResponse extends ListResponse { + + private List packageList; + + @Override + public String toString() { + return "ListEipTpsResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "packageList=" + packageList + + '}'; + } + + @Setter + @Getter + public static class Package { + /** + * The id of the eiptp. + */ + private String id; + + /** + * The deduct policy of the eiptp including "FullTimeDurationPackage" and "TimeDurationPackage". + */ + private String deductPolicy; + + /** + * The package type of the eiptp. + */ + private String packageType; + + /** + * The status of the eiptp including "RUNNING", "EXPIRED" and "USED_UP". + */ + private String status; + + /** + * The capacity of the eiptp. + */ + private String capacity; + + /** + * The capacity of the eiptp already used by the user. + */ + private String usedCapacity; + + /** + * The eipTp createTime (GMT+8 format). + */ + private String createTime; + + /** + * The active time of the eipTp (GMT+8 format). + */ + private String activeTime; + + /** + * The expire time of the eipTp (GMT+8 format). + */ + private String expireTime; + + @Override + public String toString() { + return "Package{" + + "id='" + id + '\'' + + ", deductPolicy='" + deductPolicy + '\'' + + ", packageType='" + packageType + '\'' + + ", status='" + status + '\'' + + ", capacity='" + capacity + '\'' + + ", usedCapacity='" + usedCapacity + '\'' + + ", createTime='" + createTime + '\'' + + ", activeTime='" + activeTime + '\'' + + ", expireTime='" + expireTime + '\'' + + '}'; + } + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/EndpointClient.java b/src/main/java/com/baidubce/services/endpoint/EndpointClient.java new file mode 100644 index 00000000..cc699443 --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/EndpointClient.java @@ -0,0 +1,314 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint; + +import static com.baidubce.util.Validate.checkMultyParamsNotBothEmpty; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.endpoint.model.CreateEndpointRequest; +import com.baidubce.services.endpoint.model.CreateEndpointResponse; +import com.baidubce.services.endpoint.model.Endpoint; +import com.baidubce.services.endpoint.model.GetEndpointRequest; +import com.baidubce.services.endpoint.model.ListEndpointRequest; +import com.baidubce.services.endpoint.model.ListEndpointResponse; +import com.baidubce.services.endpoint.model.ModifyEndpointRequest; +import com.baidubce.services.endpoint.model.ReleaseEndpointRequest; +import com.baidubce.services.endpoint.model.ServiceRequest; +import com.baidubce.services.endpoint.model.ServiceResponse; +import com.baidubce.services.endpoint.model.UpdateEnterpriseSecurityGroups; +import com.baidubce.services.endpoint.model.UpdateSecurityGroups; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +/** + * Provides the client for accessing the Baidu Cloud network Service ENDPOINT. + */ +public class EndpointClient extends AbstractBceClient { + private static final Logger LOGGER = LoggerFactory.getLogger(EndpointClient.class); + + private static final String VERSION = "v1"; + private static final String ENDPOINT_PREFIX = "endpoint"; + + /** + * Responsible for handling httpResponses from all network service calls. + */ + private static final HttpResponseHandler[] endpointHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public EndpointClient() { + this(new EndpointClientConfiguration()); + } + + /** + * Constructs a new InstanceClient to invoke service methods on endpoint instance. + * + * @param clientConfiguration The BCE client configuration options. + */ + public EndpointClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, endpointHandlers); + } + + /** + * Creates and initializes a new request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * @return Return a list of service owned by the authenticated user. + */ + public ServiceResponse listService() { + InternalRequest internalRequest = + this.createRequest(new ServiceRequest(), HttpMethodName.GET, ENDPOINT_PREFIX, "publicService"); + return this.invokeHttpClient(internalRequest, ServiceResponse.class); + } + + + /** + * Create an endpoint with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param request he request containing all options for creating a endpoint. + * + * @return + */ + public CreateEndpointResponse createEndpoint(CreateEndpointRequest request) { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateClientToken()); + } + checkNotNull(request.getBilling(), "billing should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ENDPOINT_PREFIX); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEndpointResponse.class); + } + + /** + * Return a list of endpoints owned by the authenticated user. + * + * @param request The request containing all options for listing own's endpoint. + * + * @return The response containing a list of endpoints owned by the authenticated user. + */ + public ListEndpointResponse listEndpoint(ListEndpointRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getVpcId(), "vpcId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ENDPOINT_PREFIX); + if (StringUtils.isNotBlank(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + internalRequest.addParameter("vpcId", request.getVpcId()); + if (StringUtils.isNotBlank(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (StringUtils.isNotBlank(request.getIpAddress())) { + internalRequest.addParameter("ipAddress", request.getIpAddress()); + } + if (StringUtils.isNotBlank(request.getStatus())) { + internalRequest.addParameter("status", request.getStatus()); + } + if (StringUtils.isNotBlank(request.getSubnetId())) { + internalRequest.addParameter("subnetId", request.getSubnetId()); + } + if (StringUtils.isNotBlank(request.getService())) { + internalRequest.addParameter("service", request.getService()); + } + return invokeHttpClient(internalRequest, ListEndpointResponse.class); + } + + /** + * Get the detail information of specified endpoint. + * + * @param endpointId The id of the endpoint. + * + * @return A Endpoint detail model for the endpointId. + */ + public Endpoint getEndpoint(String endpointId) { + checkStringNotEmpty(endpointId, "endpointId should not be empty."); + GetEndpointRequest request = new GetEndpointRequest().withEndpointId(endpointId); + return getEndpoint(request); + } + + /** + * Get the detail information of specified Endpoint. + * + * @param request The request of the network. + * + * @return A Endpoint detail model for the request. + */ + public Endpoint getEndpoint(GetEndpointRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getEndpointId(), "endpointId should not be empty."); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, ENDPOINT_PREFIX, request.getEndpointId()); + return this.invokeHttpClient(internalRequest, Endpoint.class); + } + + /** + * Modifying the name of the specified endpoint. + * + * @param request The request containing all options for modifying the endpoint name/description; + */ + public void modifyEndpoint(ModifyEndpointRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getEndpointId(), "endpointId should not be null."); + checkMultyParamsNotBothEmpty(Arrays.asList(request.getName(), request.getDescription()), + "name and description should not be all null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, ENDPOINT_PREFIX, request.getEndpointId()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Releasing specified endpoint. + * + * @param request The request containing all options for releasing the specified endpoint. + */ + public void releaseEndpoint(ReleaseEndpointRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getEndpointId(), "endpointId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, ENDPOINT_PREFIX, request.getEndpointId()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * update endpoint's securitygroups + * + * @param updateSecurityGroups + */ + public void updateSecurityGroups(UpdateSecurityGroups updateSecurityGroups) { + checkNotNull(updateSecurityGroups, "request should not be null."); + checkStringNotEmpty(updateSecurityGroups.getEndpointId(), "endpointId should not be empty."); + if (Strings.isNullOrEmpty(updateSecurityGroups.getClientToken())) { + updateSecurityGroups.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + updateSecurityGroups, HttpMethodName.PUT, ENDPOINT_PREFIX, updateSecurityGroups.getEndpointId()); + internalRequest.addParameter("bindSg", null); + fillPayload(internalRequest, updateSecurityGroups); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * update endpoint's enterpriseSecurityGroups + * + * @param updateSecurityGroups + */ + public void updateEnterpriseSecurityGroups(UpdateEnterpriseSecurityGroups updateSecurityGroups) { + checkNotNull(updateSecurityGroups, "request should not be null."); + checkStringNotEmpty(updateSecurityGroups.getEndpointId(), "endpointId should not be empty."); + if (Strings.isNullOrEmpty(updateSecurityGroups.getClientToken())) { + updateSecurityGroups.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + updateSecurityGroups, HttpMethodName.PUT, ENDPOINT_PREFIX, updateSecurityGroups.getEndpointId()); + internalRequest.addParameter("bindEsg", null); + fillPayload(internalRequest, updateSecurityGroups); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/EndpointClientConfiguration.java b/src/main/java/com/baidubce/services/endpoint/EndpointClientConfiguration.java new file mode 100644 index 00000000..29497d80 --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/EndpointClientConfiguration.java @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint; + +import com.baidubce.BceClientConfiguration; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +public class EndpointClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/CreateEndpointRequest.java b/src/main/java/com/baidubce/services/endpoint/model/CreateEndpointRequest.java new file mode 100644 index 00000000..69368bf1 --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/CreateEndpointRequest.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +public class CreateEndpointRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + /** + * The name of endpoint that will be created. + */ + private String name; + /** + * The vpcId of endpoint. + */ + private String vpcId; + /** + * The subnetId of endpoint. + */ + private String subnetId; + /** + * The service of endpoint that will be created. + */ + private String service; + /** + * The description of endpoint that will be created. + */ + private String description; + /** + * The ipAddress of endpoint that will be created. + */ + private String ipAddress; + /** + * The billing of endpoint that will be created. + */ + private Billing billing; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getService() { + return service; + } + + public void setService(String service) { + this.service = service; + } + + public String endpointId; // 用于更新使用 + + public String getEndpointId() { + return endpointId; + } + + public void setEndpointId(String endpointId) { + this.endpointId = endpointId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/CreateEndpointResponse.java b/src/main/java/com/baidubce/services/endpoint/model/CreateEndpointResponse.java new file mode 100644 index 00000000..a2b51b1a --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/CreateEndpointResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.ToString; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +@ToString +public class CreateEndpointResponse extends AbstractBceResponse { + /** + * endpointId + */ + private String id; + /** + * endpoint's ip + */ + private String ipAddress; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/Endpoint.java b/src/main/java/com/baidubce/services/endpoint/model/Endpoint.java new file mode 100644 index 00000000..02794c5d --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/Endpoint.java @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.ToString; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +@ToString +public class Endpoint extends AbstractBceResponse { + + /** + * The endpointId of endpoint. + */ + private String endpointId; + + /** + * The name of endpoint. + */ + private String name; + + /** + * The ipAddress of endpoint. + */ + private String ipAddress; + + /** + * The status of endpoint. + */ + private String status; + + /** + * The service of endpoint. + */ + private String service; + + /** + * The subnetId of endpoint. + */ + private String subnetId; + + /** + * The description of endpoint. + */ + private String description; + + /** + * The createTime of endpoint. + */ + private String createTime; + + /** + * The productType of endpoint. + */ + private String productType; + + /** + * The vpcId of endpoint. + */ + private String vpcId; + + public String getEndpointId() { + return endpointId; + } + + public void setEndpointId(String endpointId) { + this.endpointId = endpointId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getService() { + return service; + } + + public void setService(String service) { + this.service = service; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getProductType() { + return productType; + } + + public void setProductType(String productType) { + this.productType = productType; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/GetEndpointRequest.java b/src/main/java/com/baidubce/services/endpoint/model/GetEndpointRequest.java new file mode 100644 index 00000000..5f11e84d --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/GetEndpointRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +public class GetEndpointRequest extends AbstractBceRequest { + /** + * The endpointId of endpoint. + */ + private String endpointId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure id for the request. + * + * @param endpointId The endpointId of GetEndpointRequest + * @return GetEndpointRequest with specific name + */ + public GetEndpointRequest withEndpointId(String endpointId) { + this.endpointId = endpointId; + return this; + } + + public String getEndpointId() { + return endpointId; + } + + public void setEndpointId(String endpointId) { + this.endpointId = endpointId; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/ListEndpointRequest.java b/src/main/java/com/baidubce/services/endpoint/model/ListEndpointRequest.java new file mode 100644 index 00000000..fa1dad5e --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/ListEndpointRequest.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +public class ListEndpointRequest extends ListRequest { + /** + * The vpcId of Endpoint. + */ + private String vpcId; + + + /** + * The name of Endpoint. + */ + private String name; + + + /** + * The ipAddress of Endpoint. + */ + private String ipAddress; + + + /** + * The status of Endpoint. + */ + private String status; + + /** + * The subnetId of Endpoint. + */ + private String subnetId; + + /** + * The service of Endpoint. + */ + private String service; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getService() { + return service; + } + + public void setService(String service) { + this.service = service; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/ListEndpointResponse.java b/src/main/java/com/baidubce/services/endpoint/model/ListEndpointResponse.java new file mode 100644 index 00000000..327a90cc --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/ListEndpointResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +public class ListEndpointResponse extends ListResponse { + + /** + * The endpoint list + */ + List endpoints; + + public List getEndpoints() { + return endpoints; + } + + public void setEndpoints(List endpoints) { + this.endpoints = endpoints; + } + + @Override + public String toString() { + return "ListEndpointResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "endpoints=" + endpoints + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/ModifyEndpointRequest.java b/src/main/java/com/baidubce/services/endpoint/model/ModifyEndpointRequest.java new file mode 100644 index 00000000..bfc7673e --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/ModifyEndpointRequest.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +public class ModifyEndpointRequest extends AbstractBceRequest { + /** + * The id of endpoint to be updated. + */ + private String endpointId; + + /** + * The new value for endpoint's name. + */ + private String name; + + /** + * The new value for endpoint's description. + */ + private String description; + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getEndpointId() { + return endpointId; + } + + public void setEndpointId(String endpointId) { + this.endpointId = endpointId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/ReleaseEndpointRequest.java b/src/main/java/com/baidubce/services/endpoint/model/ReleaseEndpointRequest.java new file mode 100644 index 00000000..bdd5c619 --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/ReleaseEndpointRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +public class ReleaseEndpointRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of endpoint to be release. + */ + @JsonIgnore + private String endpointId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getEndpointId() { + return endpointId; + } + + public void setEndpointId(String endpointId) { + this.endpointId = endpointId; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/ServiceRequest.java b/src/main/java/com/baidubce/services/endpoint/model/ServiceRequest.java new file mode 100644 index 00000000..720925f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/ServiceRequest.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +public class ServiceRequest extends AbstractBceRequest { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/ServiceResponse.java b/src/main/java/com/baidubce/services/endpoint/model/ServiceResponse.java new file mode 100644 index 00000000..8a466310 --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/ServiceResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2021 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import lombok.ToString; + +/** + * Created by XingChunyang + * Date: 2021/01/21. + */ + +@ToString +public class ServiceResponse extends AbstractBceResponse { + /** + * The service list + */ + private List services = new ArrayList(); + + public List getServices() { + return services; + } + + public void setServices(List services) { + this.services = services; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/UpdateEnterpriseSecurityGroups.java b/src/main/java/com/baidubce/services/endpoint/model/UpdateEnterpriseSecurityGroups.java new file mode 100644 index 00000000..f4eb8138 --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/UpdateEnterpriseSecurityGroups.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class UpdateEnterpriseSecurityGroups extends AbstractBceRequest { + @JsonIgnore + private String clientToken; + + private String endpointId; + + private List enterpriseSecurityGroupIds; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/endpoint/model/UpdateSecurityGroups.java b/src/main/java/com/baidubce/services/endpoint/model/UpdateSecurityGroups.java new file mode 100644 index 00000000..537cd98f --- /dev/null +++ b/src/main/java/com/baidubce/services/endpoint/model/UpdateSecurityGroups.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.endpoint.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class UpdateSecurityGroups extends AbstractBceRequest { + @JsonIgnore + private String clientToken; + + private String endpointId; + + private List securityGroupIds; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eni/EniClient.java b/src/main/java/com/baidubce/services/eni/EniClient.java new file mode 100644 index 00000000..6c9a79e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/EniClient.java @@ -0,0 +1,585 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.CollectionUtils; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.eni.model.CreateEniRequest; +import com.baidubce.services.eni.model.CreateEniResponse; +import com.baidubce.services.eni.model.DeleteEniRequest; +import com.baidubce.services.eni.model.EniAction; +import com.baidubce.services.eni.model.EniBindEipRequest; +import com.baidubce.services.eni.model.EniDetail; +import com.baidubce.services.eni.model.EniInstanceOperateRequest; +import com.baidubce.services.eni.model.EniPrivateIpBatchAddRequest; +import com.baidubce.services.eni.model.EniPrivateIpBatchOperateRequest; +import com.baidubce.services.eni.model.EniPrivateIpOperateRequest; +import com.baidubce.services.eni.model.EniStatusResponse; +import com.baidubce.services.eni.model.EniUnBindEipRequest; +import com.baidubce.services.eni.model.EniUpdateEnterpriseSecurityGroupRequest; +import com.baidubce.services.eni.model.EniUpdateRequest; +import com.baidubce.services.eni.model.EniUpdateSecurityGroupRequest; +import com.baidubce.services.eni.model.GetEniDetailRequest; +import com.baidubce.services.eni.model.ListEniRequest; +import com.baidubce.services.eni.model.ListEniResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.baidubce.util.Validate; +import com.google.common.base.Strings; + +/** + * Provides the client for accessing the Baidu Cloud network Service Elastic Network Interface Card. + */ +public class EniClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(EniClient.class); + + private static final String VERSION = "v1"; + private static final String ENI_PREFIX = "eni"; + private static final String CLIENT_TOKEN = "clientToken"; + private static final String MARKER = "marker"; + private static final String MAX_KEYS = "maxKeys"; + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String NAME_MESSAGE_KEY = "name"; + private static final String SUBNET_ID_MESSAGE_KEY = "subnetId"; + private static final String ENI_ID_MESSAGE_KEY = "eniId"; + private static final String SG_AND_ESG_IDS_EMPTY_MESSAGE = + "securityGroupIds and enterpriseSecurityGroupIds cannot be empty at the same time"; + private static final String SG_AND_ESG_IDS_BOTH_HAVE_VALUES_MESSAGE = + "securityGroupIds and enterpriseSecurityGroupIds cannot have values at the same time"; + private static final String SECURITY_GROUP_IDS_MESSAGE = "request securityGroupIds should not be null or empty."; + private static final String ENTERPRISE_SECURITY_GROUP_IDS_MESSAGE = + "request enterpriseSecurityGroupIds should not be null or empty."; + private static final String PRIVATE_IP_SET_MESSAGE = "request privateIpSet should not be null or empty."; + private static final String PRIVATE_IP_ADDRESSES_AND_COUNT_MESSAGE = + "request privateIpAddresses and privateIpAddressCount should not be neither null or empty."; + private static final String PRIVATE_IP_ADDRESSES_MESSAGE = + "request privateIpAddresses should not be null or empty."; + private static final String VPC_ID_MESSAGE_KEY = "vpcId"; + private static final String INSTANCE_ID_MESSAGE_KEY = "instanceId"; + private static final String PRIVATE_IP_ADDRESS_MESSAGE_KEY = "privateIpAddress"; + private static final String PUBLIC_IP_ADDRESS_MESSAGE_KEY = "publicIpAddress"; + + /** + * Responsible for handling httpResponses from all eni network service calls. + */ + private static final HttpResponseHandler[] ENI_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on eni. + */ + public EniClient() { + this(new EniClientConfiguration()); + } + + /** + * Constructs a new eni client using the client configuration to access eni. + */ + public EniClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, ENI_HANDLERS); + } + + /** + * Creates and initializes a new request object for the specified bcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * Create an ENI with the specified options. + * You could fill field of clientToken,which is especially for keeping idempotent. + * securityGroupIds and enterpriseSecurityGroupIds cannot be empty or have values at the same time + * + * @param request The request containing all options for creating an ENI. + * @return id of the newly created ENI. + */ + public CreateEniResponse createEni(CreateEniRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getSubnetId(), checkEmptyExceptionMessageFormat(SUBNET_ID_MESSAGE_KEY)); + if (CollectionUtils.isEmpty(request.getSecurityGroupIds()) + && CollectionUtils.isEmpty(request.getEnterpriseSecurityGroupIds())){ + throw new IllegalArgumentException(SG_AND_ESG_IDS_EMPTY_MESSAGE); + } + if (!CollectionUtils.isEmpty(request.getSecurityGroupIds()) + && !CollectionUtils.isEmpty(request.getEnterpriseSecurityGroupIds())){ + throw new IllegalArgumentException(SG_AND_ESG_IDS_BOTH_HAVE_VALUES_MESSAGE); + } + if (CollectionUtils.isEmpty(request.getPrivateIpSet())) { + throw new IllegalArgumentException(PRIVATE_IP_SET_MESSAGE); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ENI_PREFIX); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEniResponse.class); + } + + /** + * Update the name or description of a specified ENI. + * + * @param request operate model of updating ENI + */ + public void updateEni(EniUpdateRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (Strings.isNullOrEmpty(request.getAction())) { + request.setAction("modifyAttribute"); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ENI_PREFIX, + request.getEniId()); + internalRequest.addParameter(EniAction.modifyAttribute.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified ENI. + * + * @param request The request containing all options for deleting the specified ENI owned by user. + */ + public void deleteEni(DeleteEniRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, ENI_PREFIX, request.getEniId()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified ENI by ID. + * + * @param eniId The id of ENI that will be deleted. + */ + public void deleteEni(String eniId) { + deleteEni(DeleteEniRequest.builder().eniId(eniId).build()); + } + + /** + * List ENIs owned by the authenticated user. + * + * @param request The request containing all options for listing ENI owned by user. + * @return The response with list of ENIs owned by user. + */ + public ListEniResponse listEni(ListEniRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getVpcId(), checkEmptyExceptionMessageFormat(VPC_ID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ENI_PREFIX); + internalRequest.addParameter(VPC_ID_MESSAGE_KEY, request.getVpcId()); + if (!Strings.isNullOrEmpty(request.getInstanceId())) { + internalRequest.addParameter(INSTANCE_ID_MESSAGE_KEY, request.getInstanceId()); + } + if (!Strings.isNullOrEmpty(request.getName())) { + internalRequest.addParameter(NAME_MESSAGE_KEY, request.getName()); + } + if (!CollectionUtils.isEmpty(request.getPrivateIpAddress())) { + List privateIpAddress = request.getPrivateIpAddress(); + StringBuilder sb = new StringBuilder(); + sb.append(privateIpAddress.get(0)); + for (int i = 1; i < privateIpAddress.size(); i++) { + sb.append(","); + sb.append(privateIpAddress.get(i)); + } + internalRequest.addParameter(PRIVATE_IP_ADDRESS_MESSAGE_KEY, sb.toString()); + } + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } else if (request.getMaxKeys() <= 0) { + internalRequest.addParameter(MAX_KEYS, "1000"); + } + return invokeHttpClient(internalRequest, ListEniResponse.class); + } + + /** + * Get single ENI detail owned by the authenticated user. + * + * @param request The request containing all options for get ENI detail owned by user. + * @return the ENI detail + */ + public EniDetail getEniDetail(GetEniDetailRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, ENI_PREFIX, request.getEniId()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, EniDetail.class); + } + + /** + * Add the private ip of the specified ENI + * The newly added private IPs are all secondary IPs + * + * @param request The request containing all options for adding the secondary ip of the specified ENI. + */ + public void addPrivateIp(EniPrivateIpOperateRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkNotNull(request.getPrivateIpAddress(), checkEmptyExceptionMessageFormat(PRIVATE_IP_ADDRESS_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + ENI_PREFIX, request.getEniId(), "privateIp"); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the private ip of the specified ENI + * The primary IP cannot be deleted, only the secondary IP can be deleted + * + * @param request The request containing all options for deleting the secondary ip of the specified ENI. + */ + public void deletePrivateIp(EniPrivateIpOperateRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getPrivateIpAddress(), + checkEmptyExceptionMessageFormat(PRIVATE_IP_ADDRESS_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, + ENI_PREFIX, request.getEniId(), "privateIp", request.getPrivateIpAddress()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Batch add the private ips of the specified ENI + * The newly added private IPs are secondary IPs + * + * @param request The request containing all options for batch adding the secondary ip of the specified ENI. + */ + public void batchAddPrivateIp(EniPrivateIpBatchAddRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (request.getPrivateIpAddressCount() == null + && CollectionUtils.isEmpty(request.getPrivateIpAddresses())) { + throw new IllegalArgumentException(PRIVATE_IP_ADDRESSES_AND_COUNT_MESSAGE); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, + ENI_PREFIX, request.getEniId(), "privateIp/batchAdd"); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Batch delete the private ips of the specified ENI + * The primary IP cannot be deleted, only the secondary IP can be deleted + * + * @param request The request containing all options for batch deleting the secondary ip of the specified ENI. + */ + public void batchDeletePrivateIp(EniPrivateIpBatchOperateRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (CollectionUtils.isEmpty(request.getPrivateIpAddresses())) { + throw new IllegalArgumentException(PRIVATE_IP_ADDRESSES_MESSAGE); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, + ENI_PREFIX, request.getEniId(), "privateIp/batchDel"); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Mount the ENI to the specified cloud host. + * + * @param request The request containing all options for mounting the ENI to the specified cloud host. + */ + public void attachEniInstance(EniInstanceOperateRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCE_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (Strings.isNullOrEmpty(request.getAction())) { + request.setAction(EniAction.attach.name()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ENI_PREFIX, + request.getEniId()); + internalRequest.addParameter(request.getAction(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * The ENI offloads the cloud host. + * + * @param request The request containing all options for offloading the cloud host. + */ + public void detachEniInstance(EniInstanceOperateRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getInstanceId(), checkEmptyExceptionMessageFormat(INSTANCE_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (Strings.isNullOrEmpty(request.getAction())) { + request.setAction(EniAction.detach.name()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ENI_PREFIX, + request.getEniId()); + internalRequest.addParameter(request.getAction(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * ENI bind public IP + * + * @param request The request containing all options for binding public IP + */ + public void bindEniPublicIp(EniBindEipRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getPrivateIpAddress(), + checkEmptyExceptionMessageFormat(PRIVATE_IP_ADDRESS_MESSAGE_KEY)); + checkStringNotEmpty(request.getPublicIpAddress(), + checkEmptyExceptionMessageFormat(PUBLIC_IP_ADDRESS_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (Strings.isNullOrEmpty(request.getAction())) { + request.setAction(EniAction.bind.name()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ENI_PREFIX, + request.getEniId()); + internalRequest.addParameter(request.getAction(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * ENI unbind public IP + * + * @param request The request containing all options for unbinding public IP + */ + public void unBindEniPublicIp(EniUnBindEipRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getPublicIpAddress(), + checkEmptyExceptionMessageFormat(PUBLIC_IP_ADDRESS_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (Strings.isNullOrEmpty(request.getAction())) { + request.setAction(EniAction.unBind.name()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ENI_PREFIX, + request.getEniId()); + internalRequest.addParameter(request.getAction(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update the normal security group bound to the ENI. + * An ENI must have at least one security group (normal security group or enterprise security group) + * This operation is the normal security group that the ENI will eventually join, + * and will be removed from the existing normal security group or enterprise security group. + * + * @param request The request containing all options for updating the common security group bound to the ENI. + */ + public void updateEniSecurityGroup(EniUpdateSecurityGroupRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + if (CollectionUtils.isEmpty(request.getSecurityGroupIds())) { + throw new IllegalArgumentException(SECURITY_GROUP_IDS_MESSAGE); + } + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (Strings.isNullOrEmpty(request.getAction())) { + request.setAction(EniAction.bindSg.name()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ENI_PREFIX, + request.getEniId()); + internalRequest.addParameter(request.getAction(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update the enterprise security group bound to the ENI. + * An ENI must have at least one security group (normal security group or enterprise security group) + * This operation is the enterprise security group that the ENI will eventually join, + * and will be removed from the existing normal security group or enterprise security group. + * + * @param request The request containing all options for updating the common security group bound to the ENI. + */ + public void updateEniEnterpriseSecurityGroup(EniUpdateEnterpriseSecurityGroupRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEniId(), checkEmptyExceptionMessageFormat(ENI_ID_MESSAGE_KEY)); + if (CollectionUtils.isEmpty(request.getEnterpriseSecurityGroupIds())) { + throw new IllegalArgumentException(ENTERPRISE_SECURITY_GROUP_IDS_MESSAGE); + } + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (Strings.isNullOrEmpty(request.getAction())) { + request.setAction(EniAction.bindEsg.name()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ENI_PREFIX, + request.getEniId()); + internalRequest.addParameter(request.getAction(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public EniStatusResponse getEniStatus(String eniId) { + GetEniDetailRequest request = new GetEniDetailRequest(); + request.setEniId(eniId); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ENI_PREFIX, + request.getEniId(), "status"); + return invokeHttpClient(internalRequest, EniStatusResponse.class); + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + +} diff --git a/src/main/java/com/baidubce/services/eni/EniClientConfiguration.java b/src/main/java/com/baidubce/services/eni/EniClientConfiguration.java new file mode 100644 index 00000000..49f3c249 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/EniClientConfiguration.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for Elastic Network Interface Card service. + */ +public class EniClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/eni/model/CreateEniRequest.java b/src/main/java/com/baidubce/services/eni/model/CreateEniRequest.java new file mode 100644 index 00000000..a9018766 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/CreateEniRequest.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * The request for creating new Elastic Network Interface Card. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class CreateEniRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Name of the ENI which will be created + */ + private String name; + + /** + * id of the subnet to which the ENI belongs. + */ + private String subnetId; + + /** + * A set of security groups bound to the ENI + */ + private List securityGroupIds; + + /** + * A set of enterprise security groups bound to the ENI + */ + private List enterpriseSecurityGroupIds; + + /** + * Intranet IP information + * Only one of the specified IPs can be the primary IP, and the others must be secondary IPs. + */ + private List privateIpSet; + + /** + * Description of ENI. + */ + private String description; + + /** + * The communication mode of the ENI. Valid values: + * + * standard: uses the TCP communication mode. + * highPerformance: uses the remote direct memory access (RDMA) communication mode with Elastic RDMA Interface + * (ERI) enabled. + */ + private String networkInterfaceTrafficMode; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateEniRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/CreateEniResponse.java b/src/main/java/com/baidubce/services/eni/model/CreateEniResponse.java new file mode 100644 index 00000000..292eef50 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/CreateEniResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Getter; +import lombok.Setter; + +/** + * The response for creating an Elastic Network Interface Card. + */ +@Getter +@Setter +public class CreateEniResponse extends AbstractBceResponse { + + /** + * id of the newly created ENI + */ + private String eniId; + + @Override + public String toString() { + return "CreateEniResponse{" + + "eniId='" + eniId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/DeleteEniRequest.java b/src/main/java/com/baidubce/services/eni/model/DeleteEniRequest.java new file mode 100644 index 00000000..367bd228 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/DeleteEniRequest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for deleting the specified Elastic Network Interface Card. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class DeleteEniRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of ENI. + */ + private String eniId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteEniRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/Eni.java b/src/main/java/com/baidubce/services/eni/model/Eni.java new file mode 100644 index 00000000..a0b86009 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/Eni.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * The model for describing Elastic Network Interface Card. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class Eni extends AbstractBceResponse { + /** + * The id of ENI + */ + private String eniId; + + /** + * The name of ENI + */ + private String name; + + /** + * Availability zone to which the ENI belongs + */ + private String zoneName; + + /** + * The description of ENI + */ + private String description; + + /** + * The id of the cloud host mounted on the ENI + */ + private String instanceId; + + /** + * The mac address of the ENI + */ + private String macAddress; + + /** + * The vpc ID of the ENI + */ + private String vpcId; + + /** + * The subnet ID of the ENI + */ + private String subnetId; + + /** + * The status of ENI + * available:not mounted + * attaching:is being mounted + * inuse:has been mounted + * detaching:is being detached + */ + private String status; + + /** + * Intranet IP information + * Only one of the specified IPs can be the primary IP, and the others must be secondary IPs. + */ + private List privateIpSet; +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniAction.java b/src/main/java/com/baidubce/services/eni/model/EniAction.java new file mode 100644 index 00000000..02673724 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniAction.java @@ -0,0 +1,17 @@ +package com.baidubce.services.eni.model; + +/** + * The action for operating the Elastic Network Interface Card. + */ +public enum EniAction { + /** + * update specified ENI name or description + */ + modifyAttribute, + attach, + detach, + bind, + unBind, + bindSg, + bindEsg, +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniBindEipRequest.java b/src/main/java/com/baidubce/services/eni/model/EniBindEipRequest.java new file mode 100644 index 00000000..305be91e --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniBindEipRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for bind Elastic Network Interface Card to Elastic IP. + */ +@Getter +@Setter +@ToString +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniBindEipRequest extends EniOperateRequest { + + /** + * Intranet IP address of the ENI + */ + private String privateIpAddress; + + /** + * Elastic IP address + */ + private String publicIpAddress; + + @Builder(builderMethodName = "EniBindEipRequestBuilder") + public EniBindEipRequest(String clientToken, String action, String eniId, + String privateIpAddress, String publicIpAddress) { + super(clientToken, action, eniId); + this.privateIpAddress = privateIpAddress; + this.publicIpAddress = publicIpAddress; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniDetail.java b/src/main/java/com/baidubce/services/eni/model/EniDetail.java new file mode 100644 index 00000000..73b16abd --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniDetail.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The detail model for describing Elastic Network Interface Card. + */ +@Getter +@Setter +@ToString(callSuper = true) +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniDetail extends Eni { + + /** + * List of security group IDs bound to the ENI + */ + private List securityGroupIds; + + private List enterpriseSecurityGroupIds; + /** + * createTime of ENI + */ + private String createdTime; + + @Builder(builderMethodName = "EniDetailBuilder") + public EniDetail(String eniId, String name, String zoneName, String description, String instanceId, + String macAddress, String vpcId, String subnetId, String status, List privateIpSet, + List securityGroupIds) { + super(eniId, name, zoneName, description, instanceId, macAddress, vpcId, subnetId, status, privateIpSet); + this.securityGroupIds = securityGroupIds; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniInstanceOperateRequest.java b/src/main/java/com/baidubce/services/eni/model/EniInstanceOperateRequest.java new file mode 100644 index 00000000..041ce152 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniInstanceOperateRequest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for attach/detach Elastic Network Interface Card instance. + */ +@Getter +@Setter +@ToString +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniInstanceOperateRequest extends EniOperateRequest { + + /** + * The cloud host ID to be operated + */ + private String instanceId; + + @Builder(builderMethodName = "EniInstanceOperateRequestBuilder") + public EniInstanceOperateRequest(String clientToken, String action, String eniId, String instanceId) { + super(clientToken, action, eniId); + this.instanceId = instanceId; + } + +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniOperateRequest.java b/src/main/java/com/baidubce/services/eni/model/EniOperateRequest.java new file mode 100644 index 00000000..9cf902f2 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniOperateRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * Request model to operate ENI + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniOperateRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Actions to take on an ENI + */ + private String action; + + /** + * The id of ENI + */ + private String eniId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return EniOperateRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniPrivateIpBatchAddRequest.java b/src/main/java/com/baidubce/services/eni/model/EniPrivateIpBatchAddRequest.java new file mode 100644 index 00000000..ff555e0f --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniPrivateIpBatchAddRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * The request for add Elastic Network Interface Card privateIp. + */ +@Getter +@Setter +@ToString +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniPrivateIpBatchAddRequest extends EniPrivateIpBatchOperateRequest { + + /** + * The number of newly applied secondary IP addresses + */ + private Integer privateIpAddressCount; + + @Builder(builderMethodName = "EniPrivateIpBatchAddRequestBuilder") + public EniPrivateIpBatchAddRequest(String clientToken, String eniId, + List privateIpAddresses, Integer privateIpAddressCount) { + super(clientToken, eniId, privateIpAddresses); + this.privateIpAddressCount = privateIpAddressCount; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniPrivateIpBatchOperateRequest.java b/src/main/java/com/baidubce/services/eni/model/EniPrivateIpBatchOperateRequest.java new file mode 100644 index 00000000..01a6c7b4 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniPrivateIpBatchOperateRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * The request for batch add/delete Elastic Network Interface Card private Ips. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniPrivateIpBatchOperateRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of ENI + */ + private String eniId; + + /** + * secondary ip Addresses which will be added or deleted + */ + private List privateIpAddresses; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return EniPrivateIpOperateRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniPrivateIpOperateRequest.java b/src/main/java/com/baidubce/services/eni/model/EniPrivateIpOperateRequest.java new file mode 100644 index 00000000..af043e1d --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniPrivateIpOperateRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for add/delete Elastic Network Interface Card privateIp. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniPrivateIpOperateRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of ENI + */ + private String eniId; + + /** + * secondary ip address which will be added or deleted + */ + private String privateIpAddress; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return EniPrivateIpOperateRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniStatusResponse.java b/src/main/java/com/baidubce/services/eni/model/EniStatusResponse.java new file mode 100644 index 00000000..60823af2 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniStatusResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class EniStatusResponse extends AbstractBceResponse { + private String eniStatus; + + @Override + public String toString() { + return "EniStatusResponse{" + + "eniStatus='" + eniStatus + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniUnBindEipRequest.java b/src/main/java/com/baidubce/services/eni/model/EniUnBindEipRequest.java new file mode 100644 index 00000000..d74c6d89 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniUnBindEipRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for unbind Elastic IP of The Elastic Network Interface Card. + */ +@Getter +@Setter +@ToString +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniUnBindEipRequest extends EniOperateRequest { + + /** + * Elastic IP address + */ + private String publicIpAddress; + + @Builder(builderMethodName = "EniUnBindEipRequestBuilder") + public EniUnBindEipRequest(String clientToken, String action, String eniId, String publicIpAddress) { + super(clientToken, action, eniId); + this.publicIpAddress = publicIpAddress; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniUpdateEnterpriseSecurityGroupRequest.java b/src/main/java/com/baidubce/services/eni/model/EniUpdateEnterpriseSecurityGroupRequest.java new file mode 100644 index 00000000..ab5f9d98 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniUpdateEnterpriseSecurityGroupRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * The request for update the enterprise security group bound to the Elastic Network Interface Card. + */ +@Getter +@Setter +@ToString +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniUpdateEnterpriseSecurityGroupRequest extends EniOperateRequest { + + /** + * A list of enterprise security group ids + */ + private List enterpriseSecurityGroupIds; + + @Builder(builderMethodName = "EniUpdateEnterpriseSecurityGroupRequestBuilder") + public EniUpdateEnterpriseSecurityGroupRequest(String clientToken, String action, String eniId, + List enterpriseSecurityGroupIds) { + super(clientToken, action, eniId); + this.enterpriseSecurityGroupIds = enterpriseSecurityGroupIds; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniUpdateRequest.java b/src/main/java/com/baidubce/services/eni/model/EniUpdateRequest.java new file mode 100644 index 00000000..c13dd024 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniUpdateRequest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for update Elastic Network Interface Card name and description. + */ +@Getter +@Setter +@ToString +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniUpdateRequest extends EniOperateRequest { + + /** + * The name of ENI + */ + private String name; + + /** + * The description of ENI + */ + private String description; + + @Builder(builderMethodName = "EniUpdateRequestBuilder") + public EniUpdateRequest(String clientToken, String action, String eniId, String name, String description) { + super(clientToken, action, eniId); + this.name = name; + this.description = description; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/EniUpdateSecurityGroupRequest.java b/src/main/java/com/baidubce/services/eni/model/EniUpdateSecurityGroupRequest.java new file mode 100644 index 00000000..ad5bc72a --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/EniUpdateSecurityGroupRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * The request for update the common security group bound to the Elastic Network Interface Card. + */ +@Getter +@Setter +@ToString +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EniUpdateSecurityGroupRequest extends EniOperateRequest { + + /** + * A list of common security group ids + */ + private List securityGroupIds; + + @Builder(builderMethodName = "EniUpdateSecurityGroupRequestBuilder") + public EniUpdateSecurityGroupRequest(String clientToken, String action, String eniId, + List securityGroupIds) { + super(clientToken, action, eniId); + this.securityGroupIds = securityGroupIds; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/GetEniDetailRequest.java b/src/main/java/com/baidubce/services/eni/model/GetEniDetailRequest.java new file mode 100644 index 00000000..7b049c0f --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/GetEniDetailRequest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for get the specified Elastic Network Interface Card detail. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class GetEniDetailRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of ENI. + */ + private String eniId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteEniRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/ListEniRequest.java b/src/main/java/com/baidubce/services/eni/model/ListEniRequest.java new file mode 100644 index 00000000..ad3502b4 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/ListEniRequest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * The request for listing Elastic Network Interface Cards owned by the user. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class ListEniRequest extends ListRequest { + + /** + * The ID of vpc to which the ENI belongs + * The required parameter to list ENIs. + */ + private String vpcId; + + /** + * The ID of the cloud host mounted on the ENI + * The optional parameter to list ENIs. + * If it's specified,only the ENI related to the specified instance will be listed. + */ + private String instanceId; + + /** + * The name of ENI + */ + private String name; + + /** + * The internal network ip address of the ENI + * support single IP or multiple IP queries (multiple IPs are separated by English commas) + * single IP suffix fuzzy matching, multiple IP precise matching + */ + private List privateIpAddress; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListEniRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/ListEniResponse.java b/src/main/java/com/baidubce/services/eni/model/ListEniResponse.java new file mode 100644 index 00000000..9d5c04ff --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/ListEniResponse.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import com.baidubce.model.ListResponse; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The response for listing Elastic Network Interface Card. + */ +@Getter +@Setter +public class ListEniResponse extends ListResponse { + + /** + * The list of ENI detail models. + */ + private List enis; + + @Override + public String toString() { + return "ListEniResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "enis=" + enis + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/eni/model/PrivateIp.java b/src/main/java/com/baidubce/services/eni/model/PrivateIp.java new file mode 100644 index 00000000..9efaa4d2 --- /dev/null +++ b/src/main/java/com/baidubce/services/eni/model/PrivateIp.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.eni.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The detail model for describing Intranet IP. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class PrivateIp { + + /** + * Public network IP address, ie eip address. + */ + private String publicIpAddress; + + /** + * Whether it is the primary IP. + */ + private Boolean primary; + + /** + * Intranet IP address. + * If privateIpAddress is empty, it means that the Ip address is automatically assigned + */ + private String privateIpAddress; +} diff --git a/src/main/java/com/baidubce/services/esg/EsgClient.java b/src/main/java/com/baidubce/services/esg/EsgClient.java new file mode 100644 index 00000000..79f723dc --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/EsgClient.java @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.esg.model.CreateEsgRequest; +import com.baidubce.services.esg.model.CreateEsgResponse; +import com.baidubce.services.esg.model.DeleteEsgRequest; +import com.baidubce.services.esg.model.DeleteEsgRuleRequest; +import com.baidubce.services.esg.model.EsgAction; +import com.baidubce.services.esg.model.EsgRuleOperateRequest; +import com.baidubce.services.esg.model.ListEsgRequest; +import com.baidubce.services.esg.model.ListEsgResponse; +import com.baidubce.services.esg.model.UpdateEsgRuleRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.baidubce.util.Validate; +import com.google.common.base.Strings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Baidu Cloud network Service enterprise security group. + */ +public class EsgClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(EsgClient.class); + + private static final String VERSION = "v1"; + private static final String ESG_PREFIX = "enterprise/security"; + private static final String ESG_RULE_PREFIX = ESG_PREFIX + "/rule"; + private static final String CLIENT_TOKEN = "clientToken"; + private static final String MARKER = "marker"; + private static final String MAX_KEYS = "maxKeys"; + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String REQUEST_RULE_NULL_ERROR_MESSAGE = "request rule should not be null."; + private static final String NAME_MESSAGE_KEY = "name"; + private static final String ESGID_MESSAGE_KEY = "enterpriseSecurityGroupId"; + private static final String INSTANCEID_MESSAGE_KEY = "instanceId"; + + /** + * Responsible for handling httpResponses from all esg network service calls. + */ + private static final HttpResponseHandler[] ESG_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on esg. + */ + public EsgClient() { + this(new EsgClientConfiguration()); + } + + /** + * Constructs a new esg client using the client configuration to access esg. + */ + public EsgClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, ESG_HANDLERS); + } + + /** + * Creates and initializes a new request object for the specified bcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * Create an enterprise security group with the specified options. + * You must fill field of clientToken,which is especially for keeping idempotent. + * + * @param request The request containing all options for creating a enterprise security group. + * @return enterprise security group id newly created + */ + public CreateEsgResponse createEsg(CreateEsgRequest request){ + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ESG_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEsgResponse.class); + } + + /** + * List enterprise security group owned by the authenticated user. + * + * @param request The request containing all options for listing enterprise security group owned by user. + * @return The response with list of enterprise security group + * which contains enterprise security group rules owned by user. + */ + public ListEsgResponse listEsg(ListEsgRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ESG_PREFIX); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + }else if (request.getMaxKeys() <= 0){ + internalRequest.addParameter(MAX_KEYS, "1000"); + } + if (!Strings.isNullOrEmpty(request.getInstanceId())) { + internalRequest.addParameter(INSTANCEID_MESSAGE_KEY, request.getInstanceId()); + } + return invokeHttpClient(internalRequest, ListEsgResponse.class); + } + + /** + * Delete the specified enterprise security group. + * + * @param request The request containing all options for deleting the specified + * enterprise security group owned by user. + */ + public void deleteEsg(DeleteEsgRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEnterpriseSecurityGroupId(), + checkEmptyExceptionMessageFormat(ESGID_MESSAGE_KEY)); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, ESG_PREFIX, request.getEnterpriseSecurityGroupId()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified enterprise security group. + * + * @param esgId The id of enterprise security group that will be deleted. + */ + public void deleteEsg(String esgId) { + deleteEsg(DeleteEsgRequest.builder().enterpriseSecurityGroupId(esgId).build()); + } + + /** + * Authorize enterprise security group rules to a specified enterprise security group + * + * @param request The request containing all options for authorizing enterprise security group rule + */ + public void authorizeEsgRule(EsgRuleOperateRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEnterpriseSecurityGroupId(), + checkEmptyExceptionMessageFormat(ESGID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (Strings.isNullOrEmpty(request.getAction())) { + request.setAction("authorizeRule"); + } + if (null == request.getRules()) { + throw new IllegalArgumentException(REQUEST_RULE_NULL_ERROR_MESSAGE); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ESG_PREFIX, + request.getEnterpriseSecurityGroupId()); + internalRequest.addParameter(EsgAction.authorizeRule.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete an enterprise security group rule from the specified enterprise security group + * + * @param request The request containing all options for deleting enterprise security group rule + */ + public void deleteEsgRule(DeleteEsgRuleRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEnterpriseSecurityGroupRuleId(), + checkEmptyExceptionMessageFormat(ESGID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, ESG_RULE_PREFIX, + request.getEnterpriseSecurityGroupRuleId()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the specified enterprise security group rule. + * + * @param esgRuleId The id of enterprise security group that will be deleted. + */ + public void deleteEsgRule(String esgRuleId) { + deleteEsgRule(DeleteEsgRuleRequest.builder().enterpriseSecurityGroupRuleId(esgRuleId).build()); + } + + /** + * Update the specified enterprise security group rule. + * + * @param request The request containing all options for updating enterprise security group rule. + */ + public void updateEsgRule(UpdateEsgRuleRequest request){ + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getEnterpriseSecurityGroupRuleId(), + checkEmptyExceptionMessageFormat(ESGID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ESG_RULE_PREFIX, + request.getEnterpriseSecurityGroupRuleId()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + +} diff --git a/src/main/java/com/baidubce/services/esg/EsgClientConfiguration.java b/src/main/java/com/baidubce/services/esg/EsgClientConfiguration.java new file mode 100644 index 00000000..468c7f5b --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/EsgClientConfiguration.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for enterprise security group service. + */ +public class EsgClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/esg/model/CreateEsgRequest.java b/src/main/java/com/baidubce/services/esg/model/CreateEsgRequest.java new file mode 100644 index 00000000..e4af2027 --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/CreateEsgRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * The request for creating new enterprise security group. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class CreateEsgRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The name of enterprise security group which will be created. + */ + private String name; + + /** + * The optional parameter to describe the enterprise Security group that will be created. + */ + private String desc; + + /** + * The list of rules which define how the enterprise security group works. + */ + private List rules; + + /** + * The list of tags defined by users themselves. + * they can summarize or classify the main content of the enterprise security group. + */ + private List tags; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/esg/model/CreateEsgResponse.java b/src/main/java/com/baidubce/services/esg/model/CreateEsgResponse.java new file mode 100644 index 00000000..8cddb4c8 --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/CreateEsgResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Getter; +import lombok.Setter; + +/** + * The response for creating an enterprise security group. + */ +@Getter +@Setter +public class CreateEsgResponse extends AbstractBceResponse { + + /** + * The id of newly created enterprise security group + */ + private String enterpriseSecurityGroupId; + + @Override + public String toString() { + return "CreateEsgResponse{" + + "enterpriseSecurityGroupId='" + enterpriseSecurityGroupId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/esg/model/DeleteEsgRequest.java b/src/main/java/com/baidubce/services/esg/model/DeleteEsgRequest.java new file mode 100644 index 00000000..238e373a --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/DeleteEsgRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for deleting the specified enterprise security group + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class DeleteEsgRequest extends AbstractBceRequest { + + /** + * The id of enterprise security group. + */ + private String enterpriseSecurityGroupId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteEsgRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/esg/model/DeleteEsgRuleRequest.java b/src/main/java/com/baidubce/services/esg/model/DeleteEsgRuleRequest.java new file mode 100644 index 00000000..e239b62a --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/DeleteEsgRuleRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for deleting an enterprise security group rule from the specified enterprise security group + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class DeleteEsgRuleRequest extends AbstractBceRequest { + + /** + * The id of an enterprise security group rule. + */ + private String enterpriseSecurityGroupRuleId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteEsgRuleRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/esg/model/EnterpriseSecurityGroup.java b/src/main/java/com/baidubce/services/esg/model/EnterpriseSecurityGroup.java new file mode 100644 index 00000000..3bb7d4dd --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/EnterpriseSecurityGroup.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import com.baidubce.services.bcc.model.TagModel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * The detail model for describing enterprise security group. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EnterpriseSecurityGroup { + + /** + * The id of the enterprise security group. + */ + private String id; + + /** + * The name of the enterprise security group. + */ + private String name; + + /** + * The description of the enterprise security group. + */ + private String desc; + + /** + * The created time of the enterprise security group. + */ + private String createdTime; + + /** + * The list of rules which describe how the enterprise security group works. + */ + private List rules; + + /** + * The list of tags defined by users themselves. + * they can summarize or classify the main content of the enterprise security group. + */ + private List tags; +} diff --git a/src/main/java/com/baidubce/services/esg/model/EnterpriseSecurityGroupRule.java b/src/main/java/com/baidubce/services/esg/model/EnterpriseSecurityGroupRule.java new file mode 100644 index 00000000..65b5e583 --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/EnterpriseSecurityGroupRule.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The model about the rule of the enterprise security group. + * The tuple of (remark, protocol, direction, portRange, sourceIp|destIp, sourceGroupId|destGroupId) + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EnterpriseSecurityGroupRule { + + /** + * The remark for the rule + */ + private String remark; + + /** + * The parameter to define the rule direction,available value are "ingress/egress" + */ + private String direction; + + /** + * The ethernet protocol + */ + private String ethertype; + + /** + * The port range to specify the port which the rule will work on. + * Available range is rang [0, 65535],"" for all port. + */ + private String portRange; + + /** + * The parameter specify which protocol will the rule work on, the fault value is "" for all protocol. + * Available protocol are tcp,udp and icmp. + */ + private String protocol = ""; + + /** + * The source ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "ingress" + */ + private String sourceIp; + + /** + * The destination ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "egress" + */ + private String destIp; + + /** + * Allow or deny strategy, Available value are allow,deny + */ + private String action; + + /** + * Priority of enterprise security group,the smaller value is,the higher priority is + * if allow strategy and deny strategy have the same priority,deny strategy takes precedence + * Available range is rang [1, 1000] + */ + private Integer priority; + + /** + * The id of enterprise security group rule. + */ + private String enterpriseSecurityGroupRuleId; + + /** + * created time of enterprise security group rule + */ + private String createdTime; + + /** + * update time of enterprise security group rule + */ + private String updatedTime; +} diff --git a/src/main/java/com/baidubce/services/esg/model/EsgAction.java b/src/main/java/com/baidubce/services/esg/model/EsgAction.java new file mode 100644 index 00000000..32817328 --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/EsgAction.java @@ -0,0 +1,22 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +/** + * The action for operating the enterprise security group. + */ +public enum EsgAction { + + /** + * Authorizing enterprise security group rules to an enterprise security group + */ + authorizeRule, +} diff --git a/src/main/java/com/baidubce/services/esg/model/EsgRuleOperateRequest.java b/src/main/java/com/baidubce/services/esg/model/EsgRuleOperateRequest.java new file mode 100644 index 00000000..d6f601c9 --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/EsgRuleOperateRequest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * Request model to authorize enterprise security group rule + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class EsgRuleOperateRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Actions to take on an enterprise security group + */ + private String action; + + /** + * The id of enterprise security group which will be authorized/revoked to + */ + private String enterpriseSecurityGroupId; + + /** + * Enterprise Security groups which will be operated + */ + private List rules; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/esg/model/ListEsgRequest.java b/src/main/java/com/baidubce/services/esg/model/ListEsgRequest.java new file mode 100644 index 00000000..dd846824 --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/ListEsgRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for listing the enterprise security group owned by the user. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class ListEsgRequest extends ListRequest { + + /** + * The id of instance. + * The optional parameter to list the enterprise security group. + * If it's specified,only the enterprise security group related to the specified instance will be listed. + */ + private String instanceId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListEsgRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/esg/model/ListEsgResponse.java b/src/main/java/com/baidubce/services/esg/model/ListEsgResponse.java new file mode 100644 index 00000000..ae995195 --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/ListEsgResponse.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +import lombok.Getter; +import lombok.Setter; + +/** + * The response for listing enterprise security group request. + */ +@Getter +@Setter +public class ListEsgResponse extends ListResponse { + + /** + * The list of enterprise security group detail model. + */ + private List enterpriseSecurityGroups; + + @Override + public String toString() { + return "ListEsgResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "enterpriseSecurityGroups=" + enterpriseSecurityGroups + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/esg/model/UpdateEsgRuleRequest.java b/src/main/java/com/baidubce/services/esg/model/UpdateEsgRuleRequest.java new file mode 100644 index 00000000..f061c6d6 --- /dev/null +++ b/src/main/java/com/baidubce/services/esg/model/UpdateEsgRuleRequest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2014-2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.esg.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * The request for updating an existed enterprise security group. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class UpdateEsgRuleRequest extends AbstractBceRequest { + + /** + * The id of enterprise security group rule. + */ + private String enterpriseSecurityGroupRuleId; + + /** + * The remark for the rule + */ + private String remark; + + /** + * The port range to specify the port which the rule will work on. + * Available range is rang [0, 65535],"" for all port. + */ + private String portRange; + + /** + * The source ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "ingress" + */ + private String sourceIp; + + /** + * The parameter to define the rule direction,available value are "ingress/egress" + */ + private String direction; + + /** + * The destination ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address), + * other supported formats such as 10.159.6.18/12 or 10.159.6.186. Only supports IPV4. + * Only works for direction = "egress" + */ + private String destIp; + + /** + * Allow or deny strategy, Available value are allow,deny + */ + private String action; + + + /** + * The ethernet protocol + */ + private String ethertype; + + /** + * Priority of enterprise security group,the smaller value is,the higher priority is + * if allow strategy and deny strategy have the same priority,deny strategy takes precedence + * Available range is rang [1, 1000] + */ + private Integer priority; + + /** + * The parameter specify which protocol will the rule work on, the fault value is "" for all protocol. + * Available protocol are tcp,udp and icmp. + */ + private String protocol; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateEsgRuleRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/et/EtClient.java b/src/main/java/com/baidubce/services/et/EtClient.java new file mode 100644 index 00000000..3ee3bda4 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/EtClient.java @@ -0,0 +1,548 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.et; + +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import com.baidubce.services.et.model.AssociateEtChannelRequest; +import com.baidubce.services.et.model.DisassociateEtChannelRequest; +import com.google.common.base.Strings; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.et.model.ApplyForEtRequest; +import com.baidubce.services.et.model.ApplyForEtResponse; +import com.baidubce.services.et.model.CreateEtChannelRequest; +import com.baidubce.services.et.model.CreateEtChannelResponse; +import com.baidubce.services.et.model.CreateEtChannelRouteResponse; +import com.baidubce.services.et.model.CreateEtChannelRouteRuleRequest; +import com.baidubce.services.et.model.EnableEtChannelIpv6Request; +import com.baidubce.services.et.model.Et; +import com.baidubce.services.et.model.EtChannelIdRequest; +import com.baidubce.services.et.model.EtChannelRouteRuleIdRequest; +import com.baidubce.services.et.model.ListEtChannelRouteRulesRequest; +import com.baidubce.services.et.model.ListEtChannelRouteRulesResponse; +import com.baidubce.services.et.model.ListEtChannelsResponse; +import com.baidubce.services.et.model.ListEtRequest; +import com.baidubce.services.et.model.ListEtResponse; +import com.baidubce.services.et.model.ResubmitEtChannelRequest; +import com.baidubce.services.et.model.UpdateEtChannelRequest; +import com.baidubce.services.et.model.UpdateEtChannelRouteRuleRequest; +import com.baidubce.services.et.model.UpdateEtRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +/** + * Provides the client for accessing the Baidu Cloud network Service Express Tunnel(ET). + */ +public class EtClient extends AbstractBceClient { + private static final Logger LOGGER = LoggerFactory.getLogger(EtClient.class); + + private static final String VERSION = "v1"; + private static final String ET_PREFIX = "et"; + private static final String ET_CHANNEL_PREFIX = "channel"; + private static final String ET_CHANNEL_ROUTE_PREFIX = "route/rule"; + private static final String ET_CHANNEL_ASSOCIATE_PREFIX = "associate"; + private static final String ET_CHANNEL_DISASSOCIATE_PREFIX = "disassociate"; + private static final String CLIENT_TOKEN = "clientToken"; + + /** + * Responsible for handling httpResponses from all ET network service calls. + */ + private static final HttpResponseHandler[] ET_HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on ET. + */ + public EtClient() { + this(new EtClientConfiguration()); + } + + /** + * Constructs a new ET client using the client configuration to access ET. + * + * @param clientConfiguration The network client configuration options controlling how this client + * connects to network (e.g. proxy settings, retry counts, etc). + */ + public EtClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, ET_HANDLERS); + } + + /** + * Creates and initializes a new request object for the specified ET resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * Apply for an ET with the specified options. + * + * @param request The request containing all options for creating an ET. + * @return ET id newly created + */ + public ApplyForEtResponse applyForEt(ApplyForEtRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getName(), "name should not be empty"); + checkStringNotEmpty(request.getIsp(), "isp should not be empty"); + checkStringNotEmpty(request.getIntfType(), "intfType should not be empty"); + checkStringNotEmpty(request.getApType(), "apType should not be empty"); + checkStringNotEmpty(request.getApAddr(), "apAddr should not be empty"); + checkStringNotEmpty(request.getUserIdc(), "userIdc should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ET_PREFIX + "/init"); + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ApplyForEtResponse.class); + } + + /** + * Modifying the special attribute to new value of the ET owned by the user. + * + * @param request The request containing all options for modifying own's ET. + */ + public void updateEt(UpdateEtRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "request etId should not be empty."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ET_PREFIX, request.getEtId()); + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Return a list of ETs owned by the authenticated user. + * + * @return The response containing a list of Ets owned by the authenticated user. + */ + public ListEtResponse listEts(ListEtRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ET_PREFIX); + if (StringUtils.isNotBlank(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (StringUtils.isNotBlank(request.getStatus())) { + internalRequest.addParameter("status", request.getStatus()); + } + + return invokeHttpClient(internalRequest, ListEtResponse.class); + } + + /** + * Get single ET detail owned by the authenticated user. + * + * @param etId ET(ID) + * @return ET detail for the etId + */ + public Et getEtDetail(String etId) { + checkStringNotEmpty(etId, "etId should not be empty"); + InternalRequest internalRequest = this.createRequest(new AbstractBceRequest() { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + }, HttpMethodName.GET, ET_PREFIX, etId); + return this.invokeHttpClient(internalRequest, Et.class); + } + + /** + * Create an ET channel with the specified options. Only when the ET status is “Available”, this ET channel + * can be created. + * + * @param request The request containing all options for creating an ET channel. + * @return ET channel id newly created + */ + public CreateEtChannelResponse createEtChannel(CreateEtChannelRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getBaiduAddress(), "baiduAddress should not be empty"); + checkStringNotEmpty(request.getName(), "name should not be empty"); + checkStringNotEmpty(request.getCustomerAddress(), "customerAddress should not be empty"); + checkStringNotEmpty(request.getRouteType(), "routeType should not be empty"); + checkNotNull(request.getVlanId(), "vlanId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ET_PREFIX, + request.getEtId(), ET_CHANNEL_PREFIX); + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEtChannelResponse.class); + } + + /** + * Return a list of ET channels. + * + * @param etId the specified ET id + * @return The response containing a list of Et channels owned by the specified ET. + */ + public ListEtChannelsResponse listEtChannels(String etId) { + checkStringNotEmpty(etId, "etId should not be empty"); + InternalRequest internalRequest = this.createRequest(new AbstractBceRequest() { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + }, HttpMethodName.GET, ET_PREFIX, etId, ET_CHANNEL_PREFIX); + return this.invokeHttpClient(internalRequest, ListEtChannelsResponse.class); + } + + /** + * Resubmit an ET channel with the specified options. Only when the ET status “Applying” or “Application + * rejected”, this interface is available. + * + * @param request The request containing all options for resubmitting an ET channel. + */ + public void resubmitEtChannel(ResubmitEtChannelRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + checkStringNotEmpty(request.getBaiduAddress(), "baiduAddress should not be empty"); + checkStringNotEmpty(request.getName(), "name should not be empty"); + checkStringNotEmpty(request.getCustomerAddress(), "customerAddress should not be empty"); + checkStringNotEmpty(request.getRouteType(), "routeType should not be empty"); + checkNotNull(request.getVlanId(), "vlanId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ET_PREFIX, + request.getEtId(), ET_CHANNEL_PREFIX, request.getEtChannelId()); + internalRequest.addParameter("reCreate", null); + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update an ET channel with the specified options.When the tunnel status is neither “Applying” nor “Application + * rejected”, this interface is available. + * + * @param request The request containing all options for updating an ET channel. + */ + public void updateEtChannel(UpdateEtChannelRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ET_PREFIX, + request.getEtId(), ET_CHANNEL_PREFIX, request.getEtChannelId()); + internalRequest.addParameter("modifyAttribute", null); + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the ET channel. When the channel status is “Available”, “Pending payment”, or + * “Application rejected”, this interface is available. + * + * @param request – The request containing all options for deleting an ET channel. + */ + public void deleteEtChannel(EtChannelIdRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, ET_PREFIX, + request.getEtId(), ET_CHANNEL_PREFIX, request.getEtChannelId()); + + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Turn on ET channel ipv6 function, which is a white list function. + * + * @param request - The request containing all options for turn on ET channel ipv6 function. + */ + public void enableEtChannelIpv6(EnableEtChannelIpv6Request request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + checkStringNotEmpty(request.getBaiduIpv6Address(), "baiduIpv6Address should not be empty"); + checkStringNotEmpty(request.getCustomerIpv6Address(), "customerIpv6Address should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ET_PREFIX, + request.getEtId(), ET_CHANNEL_PREFIX, request.getEtChannelId()); + internalRequest.addParameter("enableIpv6", null); + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Turn off ET channel ipv6 function. + * + * @param request - The request containing all options for turn off ET channel ipv6 function. + */ + public void disableEtChannelIpv6(EtChannelIdRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ET_PREFIX, + request.getEtId(), ET_CHANNEL_PREFIX, request.getEtChannelId()); + internalRequest.addParameter("disableIpv6", null); + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create an ET channel route rule with the specified options. + * + * @param request The request containing all options for creating an ET channel route rule. + * @return ET channel route rule id newly created. + */ + public CreateEtChannelRouteResponse createEtChannelRouteRule(CreateEtChannelRouteRuleRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + checkStringNotEmpty(request.getDestAddress(), "destAddress should not be empty"); + checkStringNotEmpty(request.getNexthopType(), "nexthopType should not be empty"); + checkStringNotEmpty(request.getNexthopId(), "nexthopId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ET_PREFIX, + request.getEtId(), ET_CHANNEL_PREFIX, request.getEtChannelId(), ET_CHANNEL_ROUTE_PREFIX); + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEtChannelRouteResponse.class); + } + + /** + * Return a list of ET route rules. + * + * @return The response containing a list of ET route rules. + */ + public ListEtChannelRouteRulesResponse listEtChannelRouteRules(ListEtChannelRouteRulesRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ET_PREFIX, + request.getEtId(), ET_CHANNEL_PREFIX, request.getEtChannelId(), ET_CHANNEL_ROUTE_PREFIX); + if (StringUtils.isNotBlank(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (StringUtils.isNotBlank(request.getDestAddress())) { + internalRequest.addParameter("destAddress", request.getDestAddress()); + } + + return invokeHttpClient(internalRequest, ListEtChannelRouteRulesResponse.class); + } + + /** + * Update an ET channel route rule's description. + * + * @param request The request containing all options for updating an ET channel route rule. + */ + public void updateEtChannelRouteRule(UpdateEtChannelRouteRuleRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + checkStringNotEmpty(request.getRouteRuleId(), "routeRuleId should not be empty"); + checkNotNull(request.getDescription(), "description should not be null"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ET_PREFIX, request.getEtId(), + ET_CHANNEL_PREFIX, request.getEtChannelId(), ET_CHANNEL_ROUTE_PREFIX, request.getRouteRuleId()); + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Delete the ET channel route rule. + * + * @param request – The request containing all options for deleting an ET channel route rule. + */ + public void deleteEtRouteRule(EtChannelRouteRuleIdRequest request) { + checkNotNull(request, "request should not be null."); + + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + checkStringNotEmpty(request.getRouteRuleId(), "routeRuleId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, ET_PREFIX, + request.getEtId(), ET_CHANNEL_PREFIX, request.getEtChannelId(), ET_CHANNEL_ROUTE_PREFIX, + request.getRouteRuleId()); + + if (StringUtils.isNotBlank(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Associate an extra channel to the ET channel. + * + * @param request The request containing all options for associating an extra channel to the ET channel. + */ + public void associateEtChannel(AssociateEtChannelRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + checkStringNotEmpty(request.getExtraChannelId(), "extraChannelId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ET_PREFIX, request.getEtId(), + ET_CHANNEL_PREFIX, request.getEtChannelId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(ET_CHANNEL_ASSOCIATE_PREFIX, null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Disassociate an extra channel from the ET channel. + * + * @param request The request containing all options for disassociating an extra channel from the ET channel. + */ + public void disassociateEtChannel(DisassociateEtChannelRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getEtId(), "etId should not be empty"); + checkStringNotEmpty(request.getEtChannelId(), "etChannelId should not be empty"); + checkStringNotEmpty(request.getExtraChannelId(), "extraChannelId should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ET_PREFIX, request.getEtId(), + ET_CHANNEL_PREFIX, request.getEtChannelId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(ET_CHANNEL_DISASSOCIATE_PREFIX, null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } +} diff --git a/src/main/java/com/baidubce/services/et/EtClientConfiguration.java b/src/main/java/com/baidubce/services/et/EtClientConfiguration.java new file mode 100644 index 00000000..4097789c --- /dev/null +++ b/src/main/java/com/baidubce/services/et/EtClientConfiguration.java @@ -0,0 +1,9 @@ +package com.baidubce.services.et; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for Express Tunnel(ET). + */ +public class EtClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/et/model/ApplyForEtRequest.java b/src/main/java/com/baidubce/services/et/model/ApplyForEtRequest.java new file mode 100644 index 00000000..e5e9e12c --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/ApplyForEtRequest.java @@ -0,0 +1,135 @@ +package com.baidubce.services.et.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.ToString; + +/** + * The request for applying for a newly ET. + */ +@ToString +public class ApplyForEtRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The name of ET that will be created. + */ + private String name; + + /** + * The option param to describe the ET + */ + private String description; + + /** + * Operator. Its value range is ISP_CMCC/ISP_CUCC/ISP_CYC/ISP_OTHER, which respectively correspond to China + * Mobile/China Unicom/China Telecom/Others in China + */ + private String isp; + + /** + * The physical port specification, of which the value range is 1G/10G/100G + */ + private String intfType; + + /** + * The line type for the Baidu AI Cloud internal users is BAIDU, and the line type for the Baidu AI Cloud + * external users is SINGLE + */ + private String apType; + + /** + * Access point. Its value range is BB/BJYZ/M3A/M3B/M2A/M2B/HKG03/WHGG/SHWGQ/BDBL, which respectively correspond + * to Beijing Haidian access point/Beijing Yizhuang access point/Guangzhou Nansha access point/Shenzhen access + * point/Nanjing access point/Suzhou access point/Hong Kong access point/Wuhan Optics Valley access + * point/Shanghai access point/Baoding access point + */ + private String apAddr; + + /** + * End-to-end address. + */ + private String userIdc; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } + + public String getIntfType() { + return intfType; + } + + public void setIntfType(String intfType) { + this.intfType = intfType; + } + + public String getApType() { + return apType; + } + + public void setApType(String apType) { + this.apType = apType; + } + + public String getApAddr() { + return apAddr; + } + + public void setApAddr(String apAddr) { + this.apAddr = apAddr; + } + + public String getUserIdc() { + return userIdc; + } + + public void setUserIdc(String userIdc) { + this.userIdc = userIdc; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/ApplyForEtResponse.java b/src/main/java/com/baidubce/services/et/model/ApplyForEtResponse.java new file mode 100644 index 00000000..640fa785 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/ApplyForEtResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.et.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.ToString; + +/** + * The response for applying for a newly ET. + */ +@ToString +public class ApplyForEtResponse extends AbstractBceResponse { + /** + * ET id newly created + */ + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/AssociateEtChannelRequest.java b/src/main/java/com/baidubce/services/et/model/AssociateEtChannelRequest.java new file mode 100644 index 00000000..001f8f7e --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/AssociateEtChannelRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.et.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class AssociateEtChannelRequest extends AbstractBceRequest { + + @JsonIgnore + private String clientToken; + + private String etId; + + private String etChannelId; + + private String extraChannelId; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/CreateEtChannelRequest.java b/src/main/java/com/baidubce/services/et/model/CreateEtChannelRequest.java new file mode 100644 index 00000000..232e45ed --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/CreateEtChannelRequest.java @@ -0,0 +1,238 @@ +package com.baidubce.services.et.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.ToString; + +/** + * The request for creating a newly ET channel. + */ +@ToString +public class CreateEtChannelRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * ET id + */ + private String etId; + + /** + * Allocation Object + */ + private List authorizedUsers; + + /** + * Description + */ + private String description; + + /** + * Cloud network interconnection IP + */ + private String baiduAddress; + + /** + * Channel Name + */ + private String name; + + /** + * Routing parameter. Only when “routeType” is "static-route", the routing parameter is required + */ + private List networks; + + /** + * IDC Interconnection IP + */ + private String customerAddress; + + /** + * Routing protocol. Currently, only “static-route” (static) and "bgp” (dynamic) are available + */ + private String routeType; + + /** + * VLAN ID, Value range: 1- 4094 + */ + private Integer vlanId; + + /** + * BGP ASN. Its valid range is 1-4294967295, and Baidu AI Cloud ASN is 45085. Only when the “routeType” is “bgp”, + * it is required + */ + private String bgpAsn; + + /** + * BGP key. Only when the “routeType” is “bgp”, it is required + */ + private String bgpKey; + + /** + * enable ipv6 or not, 1 means enable and 0 means disable + */ + private Integer enableIpv6; + + /** + * Cloud network interconnection IPv6 IP, required when enableIpv6=1 + */ + private String baiduIpv6Address; + + /** + * IDC Interconnection IPv6 IP, required when enableIpv6=1 + */ + private String customerIpv6Address; + + /** + * IPv6 routing parameter. Only when “routeType” is "static-route" and enableIpv6=1, the IPv6 routing parameter + * is required + */ + private List ipv6Networks; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getEtId() { + return etId; + } + + public void setEtId(String etId) { + this.etId = etId; + } + + public List getAuthorizedUsers() { + return authorizedUsers; + } + + public void setAuthorizedUsers(List authorizedUsers) { + this.authorizedUsers = authorizedUsers; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getBaiduAddress() { + return baiduAddress; + } + + public void setBaiduAddress(String baiduAddress) { + this.baiduAddress = baiduAddress; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getNetworks() { + return networks; + } + + public void setNetworks(List networks) { + this.networks = networks; + } + + public String getCustomerAddress() { + return customerAddress; + } + + public void setCustomerAddress(String customerAddress) { + this.customerAddress = customerAddress; + } + + public String getRouteType() { + return routeType; + } + + public void setRouteType(String routeType) { + this.routeType = routeType; + } + + public Integer getVlanId() { + return vlanId; + } + + public void setVlanId(Integer vlanId) { + this.vlanId = vlanId; + } + + public String getBgpAsn() { + return bgpAsn; + } + + public void setBgpAsn(String bgpAsn) { + this.bgpAsn = bgpAsn; + } + + public String getBgpKey() { + return bgpKey; + } + + public void setBgpKey(String bgpKey) { + this.bgpKey = bgpKey; + } + + public Integer getEnableIpv6() { + return enableIpv6; + } + + public void setEnableIpv6(Integer enableIpv6) { + this.enableIpv6 = enableIpv6; + } + + public String getBaiduIpv6Address() { + return baiduIpv6Address; + } + + public void setBaiduIpv6Address(String baiduIpv6Address) { + this.baiduIpv6Address = baiduIpv6Address; + } + + public String getCustomerIpv6Address() { + return customerIpv6Address; + } + + public void setCustomerIpv6Address(String customerIpv6Address) { + this.customerIpv6Address = customerIpv6Address; + } + + public List getIpv6Networks() { + return ipv6Networks; + } + + public void setIpv6Networks(List ipv6Networks) { + this.ipv6Networks = ipv6Networks; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/CreateEtChannelResponse.java b/src/main/java/com/baidubce/services/et/model/CreateEtChannelResponse.java new file mode 100644 index 00000000..b7a6c9a0 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/CreateEtChannelResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.et.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.ToString; + +/** + * The response for creating a newly ET tunnel + */ +@ToString +public class CreateEtChannelResponse extends AbstractBceResponse { + /** + * ET tunnel id newly created + */ + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/CreateEtChannelRouteResponse.java b/src/main/java/com/baidubce/services/et/model/CreateEtChannelRouteResponse.java new file mode 100644 index 00000000..bdf8f0f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/CreateEtChannelRouteResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.et.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.ToString; + +/** + * The response for creating a newly ET channel route. + */ +@ToString +public class CreateEtChannelRouteResponse extends AbstractBceResponse { + private String routeRuleId; + + public String getRouteRuleId() { + return routeRuleId; + } + + public void setRouteRuleId(String routeRuleId) { + this.routeRuleId = routeRuleId; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/CreateEtChannelRouteRuleRequest.java b/src/main/java/com/baidubce/services/et/model/CreateEtChannelRouteRuleRequest.java new file mode 100644 index 00000000..60912d9a --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/CreateEtChannelRouteRuleRequest.java @@ -0,0 +1,74 @@ +package com.baidubce.services.et.model; + +import lombok.ToString; + +/** + * The request for creating a newly ET channel route rule. + */ +@ToString +public class CreateEtChannelRouteRuleRequest extends EtChannelIdRequest { + /** + * IP version. IPv4's version is 4; IPv6's version is 6. Deafault value is 4. + */ + private int ipVersion = 4; + + /** + * The target network segment + */ + private String destAddress; + + /** + * Route type. The ET gateway type is "etGateway"; the ET channel type is "etChannel". + */ + private String nexthopType; + + /** + * Next hop id + */ + private String nexthopId; + + /** + * Description + */ + private String description; + + public int getIpVersion() { + return ipVersion; + } + + public void setIpVersion(int ipVersion) { + this.ipVersion = ipVersion; + } + + public String getDestAddress() { + return destAddress; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getNexthopType() { + return nexthopType; + } + + public void setNexthopType(String nexthopType) { + this.nexthopType = nexthopType; + } + + public String getNexthopId() { + return nexthopId; + } + + public void setNexthopId(String nexthopId) { + this.nexthopId = nexthopId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/DisassociateEtChannelRequest.java b/src/main/java/com/baidubce/services/et/model/DisassociateEtChannelRequest.java new file mode 100644 index 00000000..a81e41c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/DisassociateEtChannelRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.et.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class DisassociateEtChannelRequest extends AbstractBceRequest { + + @JsonIgnore + private String clientToken; + + private String etId; + + private String etChannelId; + + private String extraChannelId; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/EnableEtChannelIpv6Request.java b/src/main/java/com/baidubce/services/et/model/EnableEtChannelIpv6Request.java new file mode 100644 index 00000000..d98d11f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/EnableEtChannelIpv6Request.java @@ -0,0 +1,50 @@ +package com.baidubce.services.et.model; + +import java.util.List; + +import lombok.ToString; + +/** + * The request for enabling ET channel . + */ +@ToString +public class EnableEtChannelIpv6Request extends EtChannelIdRequest{ + /** + * Cloud network interconnection IPv6 IP + */ + private String baiduIpv6Address; + + /** + * IDC Interconnection IPv6 IP + */ + private String customerIpv6Address; + + /** + * IPv6 routing parameter. + */ + private List ipv6Networks; + + public String getBaiduIpv6Address() { + return baiduIpv6Address; + } + + public void setBaiduIpv6Address(String baiduIpv6Address) { + this.baiduIpv6Address = baiduIpv6Address; + } + + public String getCustomerIpv6Address() { + return customerIpv6Address; + } + + public void setCustomerIpv6Address(String customerIpv6Address) { + this.customerIpv6Address = customerIpv6Address; + } + + public List getIpv6Networks() { + return ipv6Networks; + } + + public void setIpv6Networks(List ipv6Networks) { + this.ipv6Networks = ipv6Networks; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/Et.java b/src/main/java/com/baidubce/services/et/model/Et.java new file mode 100644 index 00000000..7d651f43 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/Et.java @@ -0,0 +1,144 @@ +package com.baidubce.services.et.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.ToString; + +/** + * The model for describing ET. + */ +@ToString +public class Et extends AbstractBceResponse { + /** + * ET(ID) + */ + private String id; + + /** + * Name + */ + private String name; + + /** + * Description + */ + private String description; + + /** + * Express status. Its value range is ack-wait/accept/reject/building/pay-wait/established/stopped/deleted, which + * respectively correspond to Applying/Application accepted/Application rejected/Constructing/Unpaid (the unpaid + * port duration fee for the completed construction)/Available/Expired/Deleting after the expiry + */ + private String status; + + /** + * Expiration time + */ + private String expireTime; + + /** + * Operator. Its value range is ISP_CMCC/ISP_CUCC/ISP_CTC/ISP_CHH/ISP_OTHER, which respectively correspond to + * China Mobile/China Unicom/China Telecom/Hosted Express/Others in China + */ + private String isp; + + /** + * The interface specification, of which the value range is 1G/10G/100G + */ + private String intfType; + + /** + * Access Type + */ + private String apType; + + /** + * Access Point + */ + private String apAddr; + + /** + * Peer address + */ + private String userIdc; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getExpireTime() { + return expireTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } + + public String getIntfType() { + return intfType; + } + + public void setIntfType(String intfType) { + this.intfType = intfType; + } + + public String getApType() { + return apType; + } + + public void setApType(String apType) { + this.apType = apType; + } + + public String getApAddr() { + return apAddr; + } + + public void setApAddr(String apAddr) { + this.apAddr = apAddr; + } + + public String getUserIdc() { + return userIdc; + } + + public void setUserIdc(String userIdc) { + this.userIdc = userIdc; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/EtChannel.java b/src/main/java/com/baidubce/services/et/model/EtChannel.java new file mode 100644 index 00000000..06737f9f --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/EtChannel.java @@ -0,0 +1,222 @@ +package com.baidubce.services.et.model; + +import java.util.List; + +import lombok.ToString; + +/** + * The model for describing ET channel. + */ +@ToString +public class EtChannel { + /** + * ET channel id + */ + private String id; + + /** + * Name + */ + private String name; + + /** + * Description + */ + private String description; + + /** + * Channel status. Its value range is ack-wait/accept/closed/pay-wait/reject/building/established, which + * respectively correspond to Applying/Application accepted/Expired/Pending payment/Application + * rejected/Constructing/Available + */ + private String status; + + /** + * Cloud network interconnection IP + */ + private String baiduAddress; + + /** + * Allocation Object + */ + private List authorizedUsers; + + + /** + * Routing parameter. Only when “routeType” is "static-route", the routing parameter is available + */ + private List networks; + + /** + * IDC Interconnection IP + */ + private String customerAddress; + + /** + * Routing protocol. Currently, only “static-route” (static) and "bgp” (dynamic) are available + */ + private String routeType; + + /** + * VLAN ID, Value range: 1- 4094 + */ + private Integer vlanId; + + /** + * BGP ASN. Its valid range is 1-4294967295, and Baidu AI Cloud ASN is 45085 + */ + private String bgpAsn; + + /** + * BGP key. Only when the “routeType” is “bgp” + */ + private String bgpKey; + + /** + * enable ipv6 or not, 1 means enable and 0 means disable + */ + private Integer enableIpv6; + + /** + * Cloud network interconnection IPv6 IP + */ + private String baiduIpv6Address; + + /** + * IDC Interconnection IPv6 IP + */ + private String customerIpv6Address; + + /** + * IPv6 routing parameter + */ + private List ipv6Networks; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getBaiduAddress() { + return baiduAddress; + } + + public void setBaiduAddress(String baiduAddress) { + this.baiduAddress = baiduAddress; + } + + public List getAuthorizedUsers() { + return authorizedUsers; + } + + public void setAuthorizedUsers(List authorizedUsers) { + this.authorizedUsers = authorizedUsers; + } + + public List getNetworks() { + return networks; + } + + public void setNetworks(List networks) { + this.networks = networks; + } + + public String getCustomerAddress() { + return customerAddress; + } + + public void setCustomerAddress(String customerAddress) { + this.customerAddress = customerAddress; + } + + public String getRouteType() { + return routeType; + } + + public void setRouteType(String routeType) { + this.routeType = routeType; + } + + public Integer getVlanId() { + return vlanId; + } + + public void setVlanId(Integer vlanId) { + this.vlanId = vlanId; + } + + public String getBgpAsn() { + return bgpAsn; + } + + public void setBgpAsn(String bgpAsn) { + this.bgpAsn = bgpAsn; + } + + public String getBgpKey() { + return bgpKey; + } + + public void setBgpKey(String bgpKey) { + this.bgpKey = bgpKey; + } + + public Integer getEnableIpv6() { + return enableIpv6; + } + + public void setEnableIpv6(Integer enableIpv6) { + this.enableIpv6 = enableIpv6; + } + + public String getBaiduIpv6Address() { + return baiduIpv6Address; + } + + public void setBaiduIpv6Address(String baiduIpv6Address) { + this.baiduIpv6Address = baiduIpv6Address; + } + + public String getCustomerIpv6Address() { + return customerIpv6Address; + } + + public void setCustomerIpv6Address(String customerIpv6Address) { + this.customerIpv6Address = customerIpv6Address; + } + + public List getIpv6Networks() { + return ipv6Networks; + } + + public void setIpv6Networks(List ipv6Networks) { + this.ipv6Networks = ipv6Networks; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/EtChannelIdRequest.java b/src/main/java/com/baidubce/services/et/model/EtChannelIdRequest.java new file mode 100644 index 00000000..07d43148 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/EtChannelIdRequest.java @@ -0,0 +1,65 @@ +package com.baidubce.services.et.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.ToString; + +/** + * The request for containing ET channel ID. + */ +@ToString +public class EtChannelIdRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * ET id + */ + private String etId; + + /** + * ET channel id + */ + private String etChannelId; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getEtId() { + return etId; + } + + public void setEtId(String etId) { + this.etId = etId; + } + + public String getEtChannelId() { + return etChannelId; + } + + public void setEtChannelId(String etChannelId) { + this.etChannelId = etChannelId; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/EtChannelRouteRule.java b/src/main/java/com/baidubce/services/et/model/EtChannelRouteRule.java new file mode 100644 index 00000000..c04215e6 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/EtChannelRouteRule.java @@ -0,0 +1,152 @@ +package com.baidubce.services.et.model; + +import lombok.ToString; + +/** + * The model for describing ET channel route rule. + */ +@ToString +public class EtChannelRouteRule { + /** + * ET channel route rule ID + */ + private String routeRuleId; + + /** + * IP version. IPv4's version is 4; IPv6's version is 6. Deafault value is 4. + */ + private int ipVersion = 4; + + /** + * The target network segment + */ + private String destAddress; + + /** + * Route type. Its value range is etGateway/etChannel/csn. + */ + private String nexthopType; + + /** + * Next hop id + */ + private String nexthopId; + + /** + * Description + */ + private String description; + + /** + * Route protocal. Its value range is static-route/bgp. + */ + private String routeProto; + + /** + * As-Path. Only when “routeType” is "bgp", the as-path is available. + */ + private String asPaths; + + /** + * LocalPreference. Only when “routeType” is "bgp", the as-path is available. + */ + private Integer localPreference; + + /** + * Med. Only when “routeType” is "bgp", the as-path is available. + */ + private Integer med; + + /** + * Origin. Only when “routeType” is "bgp", the as-path is available. + */ + private String origin; + + public String getRouteRuleId() { + return routeRuleId; + } + + public void setRouteRuleId(String routeRuleId) { + this.routeRuleId = routeRuleId; + } + + public int getIpVersion() { + return ipVersion; + } + + public void setIpVersion(int ipVersion) { + this.ipVersion = ipVersion; + } + + public String getDestAddress() { + return destAddress; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + public String getNexthopType() { + return nexthopType; + } + + public void setNexthopType(String nexthopType) { + this.nexthopType = nexthopType; + } + + public String getNexthopId() { + return nexthopId; + } + + public void setNexthopId(String nexthopId) { + this.nexthopId = nexthopId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getRouteProto() { + return routeProto; + } + + public void setRouteProto(String routeProto) { + this.routeProto = routeProto; + } + + public String getAsPaths() { + return asPaths; + } + + public void setAsPaths(String asPaths) { + this.asPaths = asPaths; + } + + public Integer getLocalPreference() { + return localPreference; + } + + public void setLocalPreference(Integer localPreference) { + this.localPreference = localPreference; + } + + public Integer getMed() { + return med; + } + + public void setMed(Integer med) { + this.med = med; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String origin) { + this.origin = origin; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/EtChannelRouteRuleIdRequest.java b/src/main/java/com/baidubce/services/et/model/EtChannelRouteRuleIdRequest.java new file mode 100644 index 00000000..76c9d971 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/EtChannelRouteRuleIdRequest.java @@ -0,0 +1,19 @@ +package com.baidubce.services.et.model; + +import lombok.ToString; + +/** + * The request for containing ET channel route ID. + */ +@ToString +public class EtChannelRouteRuleIdRequest extends EtChannelIdRequest { + private String routeRuleId; + + public String getRouteRuleId() { + return routeRuleId; + } + + public void setRouteRuleId(String routeRuleId) { + this.routeRuleId = routeRuleId; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/ListEtChannelRouteRulesRequest.java b/src/main/java/com/baidubce/services/et/model/ListEtChannelRouteRulesRequest.java new file mode 100644 index 00000000..effc7053 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/ListEtChannelRouteRulesRequest.java @@ -0,0 +1,58 @@ +package com.baidubce.services.et.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; + +import lombok.ToString; + +/** + * The request for listing ET channel route rules. + */ +@ToString +public class ListEtChannelRouteRulesRequest extends ListRequest { + /** + * ET id + */ + private String etId; + + /** + * ET channel id + */ + private String etChannelId; + + /** + * The target network segment + */ + private String destAddress; + + public String getEtId() { + return etId; + } + + public void setEtId(String etId) { + this.etId = etId; + } + + public String getEtChannelId() { + return etChannelId; + } + + public void setEtChannelId(String etChannelId) { + this.etChannelId = etChannelId; + } + + public String getDestAddress() { + return destAddress; + } + + public void setDestAddress(String destAddress) { + this.destAddress = destAddress; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/ListEtChannelRouteRulesResponse.java b/src/main/java/com/baidubce/services/et/model/ListEtChannelRouteRulesResponse.java new file mode 100644 index 00000000..75f9beb1 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/ListEtChannelRouteRulesResponse.java @@ -0,0 +1,31 @@ +package com.baidubce.services.et.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +/** + * The response for listing ET channel route rules. + */ +public class ListEtChannelRouteRulesResponse extends ListResponse { + private List routeRules; + + public List getRouteRules() { + return routeRules; + } + + public void setRouteRules(List routeRules) { + this.routeRules = routeRules; + } + + @Override + public String toString() { + return "ListEtChannelRouteRulesResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "routeRules=" + routeRules + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/ListEtChannelsResponse.java b/src/main/java/com/baidubce/services/et/model/ListEtChannelsResponse.java new file mode 100644 index 00000000..7ebd6b78 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/ListEtChannelsResponse.java @@ -0,0 +1,23 @@ +package com.baidubce.services.et.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.ToString; + +/** + * The response for listing ET channels. + */ +@ToString +public class ListEtChannelsResponse extends AbstractBceResponse { + private List etChannels; + + public List getEtChannels() { + return etChannels; + } + + public void setEtChannels(List etChannels) { + this.etChannels = etChannels; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/ListEtRequest.java b/src/main/java/com/baidubce/services/et/model/ListEtRequest.java new file mode 100644 index 00000000..ffbdabe3 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/ListEtRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.et.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; + +import lombok.ToString; + +/** + * The request for listing ET. + */ +@ToString +public class ListEtRequest extends ListRequest { + /** + * Express status. Its value range is ack-wait/accept/reject/building/pay-wait/established/stopped/deleted, which + * respectively correspond to Applying/Application accepted/Application rejected/Constructing/Unpaid (the unpaid + * port duration fee for the completed construction)/Available/Expired/Deleting after the expiry + */ + private String status; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/ListEtResponse.java b/src/main/java/com/baidubce/services/et/model/ListEtResponse.java new file mode 100644 index 00000000..fcd8e0e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/ListEtResponse.java @@ -0,0 +1,34 @@ +package com.baidubce.services.et.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +/** + * The response for listing ET. + */ +public class ListEtResponse extends ListResponse { + /** + * ET List + */ + private List ets; + + public List getEts() { + return ets; + } + + public void setEts(List ets) { + this.ets = ets; + } + + @Override + public String toString() { + return "ListEtResponse{" + + "marker=" + getMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "ets=" + ets + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/ResubmitEtChannelRequest.java b/src/main/java/com/baidubce/services/et/model/ResubmitEtChannelRequest.java new file mode 100644 index 00000000..ce2d5bf0 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/ResubmitEtChannelRequest.java @@ -0,0 +1,168 @@ +package com.baidubce.services.et.model; + +import java.util.List; + +import lombok.ToString; + +/** + * The request for resubmitting an ET channel. + */ +@ToString +public class ResubmitEtChannelRequest extends EtChannelIdRequest { + /** + * Allocation Object + */ + private List authorizedUsers; + + /** + * Description + */ + private String description; + + /** + * Cloud network interconnection IP + */ + private String baiduAddress; + + /** + * Channel Name + */ + private String name; + + /** + * Routing parameter. Only when “routeType” is "static-route", the routing parameter is required + */ + private List networks; + + /** + * IDC Interconnection IP + */ + private String customerAddress; + + /** + * Routing protocol. Currently, only “static-route” (static) and "bgp” (dynamic) are available + */ + private String routeType; + + /** + * VLAN ID, Value range: 1- 4094 + */ + private Integer vlanId; + + /** + * enable ipv6 or not, 1 means enable and 0 means disable + */ + private Integer enableIpv6; + + /** + * Cloud network interconnection IPv6 IP, required when enableIpv6=1 + */ + private String baiduIpv6Address; + + /** + * IDC Interconnection IPv6 IP, required when enableIpv6=1 + */ + private String customerIpv6Address; + + /** + * IPv6 routing parameter. Only when “routeType” is "static-route" and enableIpv6=1, the IPv6 routing parameter + * is required + */ + private List ipv6Networks; + + public List getAuthorizedUsers() { + return authorizedUsers; + } + + public void setAuthorizedUsers(List authorizedUsers) { + this.authorizedUsers = authorizedUsers; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getBaiduAddress() { + return baiduAddress; + } + + public void setBaiduAddress(String baiduAddress) { + this.baiduAddress = baiduAddress; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getNetworks() { + return networks; + } + + public void setNetworks(List networks) { + this.networks = networks; + } + + public String getCustomerAddress() { + return customerAddress; + } + + public void setCustomerAddress(String customerAddress) { + this.customerAddress = customerAddress; + } + + public String getRouteType() { + return routeType; + } + + public void setRouteType(String routeType) { + this.routeType = routeType; + } + + public Integer getVlanId() { + return vlanId; + } + + public void setVlanId(Integer vlanId) { + this.vlanId = vlanId; + } + + public Integer getEnableIpv6() { + return enableIpv6; + } + + public void setEnableIpv6(Integer enableIpv6) { + this.enableIpv6 = enableIpv6; + } + + public String getBaiduIpv6Address() { + return baiduIpv6Address; + } + + public void setBaiduIpv6Address(String baiduIpv6Address) { + this.baiduIpv6Address = baiduIpv6Address; + } + + public String getCustomerIpv6Address() { + return customerIpv6Address; + } + + public void setCustomerIpv6Address(String customerIpv6Address) { + this.customerIpv6Address = customerIpv6Address; + } + + public List getIpv6Networks() { + return ipv6Networks; + } + + public void setIpv6Networks(List ipv6Networks) { + this.ipv6Networks = ipv6Networks; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/UpdateEtChannelRequest.java b/src/main/java/com/baidubce/services/et/model/UpdateEtChannelRequest.java new file mode 100644 index 00000000..84667b65 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/UpdateEtChannelRequest.java @@ -0,0 +1,35 @@ +package com.baidubce.services.et.model; + +import lombok.ToString; + +/** + * The request for updating an ET channel. + */ +@ToString +public class UpdateEtChannelRequest extends EtChannelIdRequest { + /** + * Channel Name + */ + private String name; + + /** + * Description + */ + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/UpdateEtChannelRouteRuleRequest.java b/src/main/java/com/baidubce/services/et/model/UpdateEtChannelRouteRuleRequest.java new file mode 100644 index 00000000..661d226d --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/UpdateEtChannelRouteRuleRequest.java @@ -0,0 +1,19 @@ +package com.baidubce.services.et.model; + +import lombok.ToString; + +/** + * The request for updating an ET channel route rule. + */ +@ToString +public class UpdateEtChannelRouteRuleRequest extends EtChannelRouteRuleIdRequest { + private String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/baidubce/services/et/model/UpdateEtRequest.java b/src/main/java/com/baidubce/services/et/model/UpdateEtRequest.java new file mode 100644 index 00000000..171b5c59 --- /dev/null +++ b/src/main/java/com/baidubce/services/et/model/UpdateEtRequest.java @@ -0,0 +1,78 @@ +package com.baidubce.services.et.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.ToString; + +/** + * The request for updating an ET resource. + */ +@ToString +public class UpdateEtRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * ET id for modifying + */ + private String etId; + + /** + * The name of ET that will be created. + */ + private String name; + + /** + * The option param to describe the ET + */ + private String description; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getEtId() { + return etId; + } + + public void setEtId(String etId) { + this.etId = etId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/EtGatewayClient.java b/src/main/java/com/baidubce/services/etgateway/EtGatewayClient.java new file mode 100644 index 00000000..a39221d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/EtGatewayClient.java @@ -0,0 +1,329 @@ +package com.baidubce.services.etgateway; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.etgateway.model.BindEtChannelRequest; +import com.baidubce.services.etgateway.model.CreateEtGatewayHealthCheckRequest; +import com.baidubce.services.etgateway.model.CreateEtGatewayRequest; +import com.baidubce.services.etgateway.model.CreateEtGatewayResponse; +import com.baidubce.services.etgateway.model.DeleteEtGatewayRequest; +import com.baidubce.services.etgateway.model.GetEtGatewayRequest; +import com.baidubce.services.etgateway.model.GetEtGatewayResponse; +import com.baidubce.services.etgateway.model.ListEtGatewayRequest; +import com.baidubce.services.etgateway.model.ListEtGatewayResponse; +import com.baidubce.services.etgateway.model.UnbindEtChannelRequest; +import com.baidubce.services.etgateway.model.UpdateEtGatewayRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import static com.google.common.base.Preconditions.checkNotNull; + +public class EtGatewayClient extends AbstractBceClient { + private static final Logger LOGGER = LoggerFactory.getLogger(EtGatewayClient.class); + + private static final String VERSION = "v1"; + private static final String ETGATEWAY_PREFIX = "etGateway"; + private static final String ETGATEWAY_HEALTH_CHECK_PREFIX = "healthCheck"; + + /** + * Responsible for handling httpResponses from all network service calls. + */ + private static final HttpResponseHandler[] ETGATEWAY_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on EtGateway. + */ + public EtGatewayClient() { + this(new EtGatewayClientConfiguration()); + } + + /** + * Constructs a new EtGatewayClient client using the client configuration to access EtGateway. + * + * @param clientConfiguration The EtGatewayClient client configuration options controlling how this client + * connects to EtGateway (e.g. proxy settings, retry counts, etc). + */ + public EtGatewayClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, ETGATEWAY_HANDLERS); + } + + + /** + * Creates and initializes a new request object for the specified EtGateway resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + + /** + * Create a EtGateway with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + *

+ * + * @param request The request containing all options for creating an EtGateway. + * @return etGatewayId newly created + * @throws BceClientException + */ + public CreateEtGatewayResponse createEtGateway(CreateEtGatewayRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getVpcId(), "request vpcId should not be null."); + checkNotNull(request.getName(), "request name should not be null."); + checkNotNull(request.getSpeed(), "request speed should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ETGATEWAY_PREFIX); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateEtGatewayResponse.class); + } + + + /** + * In accordance with the query info, return a list of dedicated line gateways. + * + * @param request The request containing all options for list EtGateway. + * @return + */ + public ListEtGatewayResponse listEtGateways(ListEtGatewayRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getVpcId(), "request vpcId should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ETGATEWAY_PREFIX); + internalRequest.addParameter("vpcId", request.getVpcId()); + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (StringUtils.isNotEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (StringUtils.isNotEmpty(request.getStatus())) { + internalRequest.addParameter("status", request.getStatus()); + } + if (StringUtils.isNotEmpty(request.getEtGatewayId())) { + internalRequest.addParameter("etGatewayId", request.getEtGatewayId()); + } + + return invokeHttpClient(internalRequest, ListEtGatewayResponse.class); + + } + + /** + * Query details of the dedicated line gateway + * + * @param etGatewayId + * @return + */ + public GetEtGatewayResponse getEtGateway(String etGatewayId) { + return getEtGateway(new GetEtGatewayRequest().setEtGatewayId(etGatewayId)); + } + + private GetEtGatewayResponse getEtGateway(GetEtGatewayRequest request) { + checkNotNull(request.getEtGatewayId(), "etGatewayId should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, ETGATEWAY_PREFIX, + request.getEtGatewayId()); + return this.invokeHttpClient(internalRequest, GetEtGatewayResponse.class); + } + + /** + * Update the dedicated line gateway. + * + * @param request The request containing all options for update EtGateway. + */ + public void updateEtGateway(UpdateEtGatewayRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getEtGatewayId(), "etGatewayId should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ETGATEWAY_PREFIX, + request.getEtGatewayId()); + fillPayload(internalRequest, request); + internalRequest.addParameter("clientToken", request.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Release the dedicated line gateway + * + * @param etGatewayId + */ + public void deleteEtGateway(String etGatewayId) { + deleteEtGateway(new DeleteEtGatewayRequest().setEtGatewayId(etGatewayId)); + } + + /** + * Release the dedicated line gateway + * + * @param etGatewayId + * @param clientToken The request will be idempotent if clientToken is provided. + */ + public void deleteEtGateway(String etGatewayId, String clientToken) { + deleteEtGateway(new DeleteEtGatewayRequest().setEtGatewayId(etGatewayId).setClientToken(clientToken)); + } + + private void deleteEtGateway(DeleteEtGatewayRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getEtGatewayId(), "etGatewayId should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, ETGATEWAY_PREFIX, + request.getEtGatewayId()); + internalRequest.addParameter("clientToken", request.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Binding a dedicated line gateway to a physical dedicated line channel, + * you can choose to simultaneously set the cloud-side network parameters. + * + * @param request + */ + public void bindEtChannel(BindEtChannelRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getEtGatewayId(), "etGatewayId should not be null."); + checkNotNull(request.getEtId(), "etGatewayId should not be null."); + checkNotNull(request.getChannelId(), "etGatewayId should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ETGATEWAY_PREFIX, + request.getEtGatewayId()); + internalRequest.addParameter("clientToken", request.getClientToken()); + internalRequest.addParameter("bind", ""); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + + } + + /** + * Unbinding a dedicated line gateway from a physical dedicated line channel + * + * @param request + */ + public void unbindEtChannel(UnbindEtChannelRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getEtGatewayId(), "etGatewayId should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, ETGATEWAY_PREFIX, + request.getEtGatewayId()); + internalRequest.addParameter("clientToken", request.getClientToken()); + internalRequest.addParameter("unbind", ""); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create health check for the dedicated line gateway. + * + * @param request + */ + public void createEtGatewayHealthCheck(CreateEtGatewayHealthCheckRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getEtGatewayId(), "etGatewayId should not be null."); + checkNotNull(request.getHealthCheckInterval(), "healthCheckInterval should not be null."); + checkNotNull(request.getHealthThreshold(), "healthThreshold should not be null."); + checkNotNull(request.getUnhealthThreshold(), "unhealthThreshold should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ETGATEWAY_PREFIX, + request.getEtGatewayId(), ETGATEWAY_HEALTH_CHECK_PREFIX); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/EtGatewayClientConfiguration.java b/src/main/java/com/baidubce/services/etgateway/EtGatewayClientConfiguration.java new file mode 100644 index 00000000..0759a8b0 --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/EtGatewayClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.etgateway; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for EtGateway service. + */ +public class EtGatewayClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/BindEtChannelRequest.java b/src/main/java/com/baidubce/services/etgateway/model/BindEtChannelRequest.java new file mode 100644 index 00000000..1a967218 --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/BindEtChannelRequest.java @@ -0,0 +1,53 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +import java.util.List; + +@Setter +@Getter +@Accessors(chain = true) +public class BindEtChannelRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + private String etGatewayId; + /** + * The ID of the bound physical dedicated line. Both etId and channelId must exist simultaneously. + */ + private String etId; + + /** + * The ID of the bound dedicated line channel. Both etId and channelId must exist simultaneously. + */ + private String channelId; + + /** + * The cloud-side network of the dedicated line gateway. + * Users can choose the local VPC subnet or define one or more custom subnets. + * This setting is only applicable when parameters etId and channelId exist + */ + private List localCidrs; + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/CreateEtGatewayHealthCheckRequest.java b/src/main/java/com/baidubce/services/etgateway/model/CreateEtGatewayHealthCheckRequest.java new file mode 100644 index 00000000..5bf34fa2 --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/CreateEtGatewayHealthCheckRequest.java @@ -0,0 +1,69 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Getter +@Setter +@Accessors(chain = true) +public class CreateEtGatewayHealthCheckRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + private String etGatewayId; + + /** + * The source IP for health check. + */ + private String healthCheckSourceIp; + + /** + * The method of health check. + */ + private String healthCheckType; + + /** + * The port for health check. + */ + private Integer healthCheckPort; + + /** + * The interval for health check + */ + private Integer healthCheckInterval; + + /** + * The threshold for health check + */ + private Integer healthThreshold; + + /** + * The threshold for unhealthy status in health check + */ + private Integer unhealthThreshold; + + /** + * Whether to automatically generate probing routes. Enabled by default. If you want to disable, choose false. + */ + private Boolean autoGenerateRouteRule; + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/CreateEtGatewayRequest.java b/src/main/java/com/baidubce/services/etgateway/model/CreateEtGatewayRequest.java new file mode 100644 index 00000000..4133b6fd --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/CreateEtGatewayRequest.java @@ -0,0 +1,78 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +import java.util.List; + +@Getter +@Setter +@Accessors(chain = true) +public class CreateEtGatewayRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The name of the dedicated line gateway, composed of uppercase and lowercase letters, numbers, + * and special characters -_ /. Must start with a letter and have a length of 1-65 characters + */ + private String name; + + /** + * vpcId + */ + private String vpcId; + + /** + * The speed limit value of the dedicated line gateway bandwidth, measured in Mbps. + * The limit is an integer between 2 and 10000. + */ + private Integer speed; + + /** + * The description of the dedicated line gateway, not exceeding 200 characters + */ + private String description; + + /** + * The ID of the bound physical dedicated line. Both etId and channelId must exist simultaneously. + */ + private String etId; + + /** + * The ID of the bound dedicated line channel. Both etId and channelId must exist simultaneously. + */ + private String channelId; + + /** + * The cloud-side network of the dedicated line gateway. + * Users can choose the local VPC subnet or define one or more custom subnets. + * This setting is only applicable when parameters etId and channelId exist + */ + private List localCidrs; + + /** + * The tag of the dedicated line gateway. + */ + private List tags; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/CreateEtGatewayResponse.java b/src/main/java/com/baidubce/services/etgateway/model/CreateEtGatewayResponse.java new file mode 100644 index 00000000..27e77508 --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/CreateEtGatewayResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class CreateEtGatewayResponse extends AbstractBceResponse { + + /** + * The ID of the created dedicated line gateway. + */ + private String etGatewayId; + +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/DeleteEtGatewayRequest.java b/src/main/java/com/baidubce/services/etgateway/model/DeleteEtGatewayRequest.java new file mode 100644 index 00000000..15bf0023 --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/DeleteEtGatewayRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Setter +@Getter +@Accessors(chain = true) +public class DeleteEtGatewayRequest extends AbstractBceRequest{ + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + private String etGatewayId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/EtGateway.java b/src/main/java/com/baidubce/services/etgateway/model/EtGateway.java new file mode 100644 index 00000000..cdb5231f --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/EtGateway.java @@ -0,0 +1,77 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.services.bcc.model.TagModel; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +@Getter +@Setter +@ToString +@Accessors(chain = true) +public class EtGateway { + /** + * dedicated line gateway ID + */ + private String etGatewayId; + + /** + * The name of the dedicated line gateway + */ + private String name; + + /** + * dedicated line gateway status + */ + private String status; + + /** + * dedicated line gateway egress bandwidt + */ + private String speed; + + private String createTime; + + /** + * The description of the dedicated line gateway + */ + private String description; + + /** + * vpcId + */ + private String vpcId; + + /** + * The ID of the bound physical dedicated line. + */ + private String etId; + + /** + * The ID of the bound dedicated line channel. + */ + private String channelId; + + /** + * IPv4 cloud-side network + */ + private List localCidrs; + + /** + * Whether IPv6 functionality is enabled, 1 for yes, 0 for no. + */ + private Integer enableIpv6; + + /** + * IPv6 cloud-side network + */ + private List ipv6LocalCidrs; + + /** + * Tag list + */ + private List tags; +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/GetEtGatewayRequest.java b/src/main/java/com/baidubce/services/etgateway/model/GetEtGatewayRequest.java new file mode 100644 index 00000000..04869e4b --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/GetEtGatewayRequest.java @@ -0,0 +1,20 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Getter +@Setter +@Accessors(chain = true) +public class GetEtGatewayRequest extends AbstractBceRequest { + private String etGatewayId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/GetEtGatewayResponse.java b/src/main/java/com/baidubce/services/etgateway/model/GetEtGatewayResponse.java new file mode 100644 index 00000000..3fd92d9f --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/GetEtGatewayResponse.java @@ -0,0 +1,113 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +@Getter +@Setter +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class GetEtGatewayResponse extends AbstractBceResponse { + /** + * dedicated line gateway ID + */ + private String etGatewayId; + + /** + * The name of the dedicated line gateway + */ + private String name; + + /** + * dedicated line gateway status + */ + private String status; + + /** + * dedicated line gateway egress bandwidt + */ + private String speed; + + private String createTime; + + /** + * The description of the dedicated line gateway + */ + private String description; + + /** + * vpcId + */ + private String vpcId; + + /** + * The ID of the bound physical dedicated line. + */ + private String etId; + + /** + * The ID of the bound dedicated line channel. + */ + private String channelId; + + /** + * IPv4 cloud-side network + */ + private List localCidrs; + + /** + * Whether IPv6 functionality is enabled, 1 for yes, 0 for no. + */ + private Integer enableIpv6; + + /** + * IPv6 cloud-side network + */ + private List ipv6LocalCidrs; + + /** + * The source IP for health check. + */ + private String healthcheckourceIp; + + /** + * The destination IP for health check + */ + private String healthCheckDestIp; + + /** + * The interval for health check + */ + private Integer healthCheckInterval; + + /** + * The threshold for health check + */ + private Integer healthThreshold; + + /** + * The threshold for unhealthy status in health check + */ + private Integer unhealthThreshold; + + /** + * The method of health check. + */ + private String healthCheckType; + + /** + * The port for health check. + */ + private Integer healthCheckPort; + + /** + * Tag list + */ + private List tags; +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/ListEtGatewayRequest.java b/src/main/java/com/baidubce/services/etgateway/model/ListEtGatewayRequest.java new file mode 100644 index 00000000..4c4624dc --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/ListEtGatewayRequest.java @@ -0,0 +1,41 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Getter +@Setter +@Accessors(chain = true) +public class ListEtGatewayRequest extends ListRequest { + + /** + * vpcId is required + */ + private String vpcId; + + /** + * optional + */ + private String name; + + /** + * optional + */ + private String etGatewayId; + + /** + * optional + */ + private String status; + + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/ListEtGatewayResponse.java b/src/main/java/com/baidubce/services/etgateway/model/ListEtGatewayResponse.java new file mode 100644 index 00000000..69ada03c --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/ListEtGatewayResponse.java @@ -0,0 +1,30 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.model.ListResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +@Getter +@Setter +@ToString +@Accessors(chain = true) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListEtGatewayResponse extends ListResponse { + private List etGateways; + + @Override + public String toString() { + return "ListEtGatewayResponse{" + + "marker=" + getMarker() + "," + + "isTruncated=" + getIsTruncated() + "," + + "nextMarker=" + getNextMarker() + "," + + "maxKeys=" + getMaxKeys() + "," + + "etGateways=" + etGateways + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/UnbindEtChannelRequest.java b/src/main/java/com/baidubce/services/etgateway/model/UnbindEtChannelRequest.java new file mode 100644 index 00000000..0a67850a --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/UnbindEtChannelRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Getter +@Setter +@Accessors(chain = true) +public class UnbindEtChannelRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + private String etGatewayId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/etgateway/model/UpdateEtGatewayRequest.java b/src/main/java/com/baidubce/services/etgateway/model/UpdateEtGatewayRequest.java new file mode 100644 index 00000000..ce7ea6d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/etgateway/model/UpdateEtGatewayRequest.java @@ -0,0 +1,70 @@ +package com.baidubce.services.etgateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +import java.util.List; + +@Getter +@Setter +@Accessors(chain = true) +public class UpdateEtGatewayRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + + private String etGatewayId; + + /** + * The name of the dedicated line gateway, composed of uppercase and lowercase letters, numbers, + * and special characters -_ /. Must start with a letter and have a length of 1-65 characters + */ + private String name; + + /** + * The speed limit value of the dedicated line gateway bandwidth, measured in Mbps. + * The limit is an integer between 2 and 10000. + */ + private Integer speed; + + /** + * The description of the dedicated line gateway, not exceeding 200 characters + */ + private String description; + + /** + * The cloud-side network of the dedicated line gateway. + * Users can choose the local VPC subnet or define one or more custom subnets. + * This setting is only applicable when parameters etId and channelId exist + */ + private List localCidrs; + + /** + * Whether IPv6 functionality is enabled, 1 for yes, 0 for no. + */ + private Integer enableIpv6; + + /** + * IPv6 cloud-side network + */ + private List ipv6LocalCidrs; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/evs/EvsClient.java b/src/main/java/com/baidubce/services/evs/EvsClient.java new file mode 100644 index 00000000..8783e182 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/EvsClient.java @@ -0,0 +1,1000 @@ +package com.baidubce.services.evs; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.evs.model.BindDeviceRequest; +import com.baidubce.services.evs.model.BindDeviceResponse; +import com.baidubce.services.evs.model.DeviceAiAnalysisListMarkRequest; +import com.baidubce.services.evs.model.DeviceAiAnalysisListMarkResponse; +import com.baidubce.services.evs.model.DeviceChannelListResponse; +import com.baidubce.services.evs.model.DeviceChannelSignedUrlResponse; +import com.baidubce.services.evs.model.DeviceGetResponse; +import com.baidubce.services.evs.model.DeviceMarkListResponse; +import com.baidubce.services.evs.model.DeviceSignedUrlResponse; +import com.baidubce.services.evs.model.DeviceStopRequest; +import com.baidubce.services.evs.model.DeviceTsStorePageListResponse; +import com.baidubce.services.evs.model.DynamicTrafficFrameRequest; +import com.baidubce.services.evs.model.EvsBaseRequest; +import com.baidubce.services.evs.model.EvsBaseResponse; +import com.baidubce.services.evs.model.GbPresetListResponse; +import com.baidubce.services.evs.model.SpaceMarkListResponse; +import com.baidubce.services.evs.model.DeviceChannelGetResponse; +import com.baidubce.services.evs.model.DeviceCountResponse; +import com.baidubce.services.evs.model.DeviceCreateRequest; +import com.baidubce.services.evs.model.DeviceCreateResponse; +import com.baidubce.services.evs.model.DeviceListMarkRequest; +import com.baidubce.services.evs.model.DeviceTsStoreListRequest; +import com.baidubce.services.evs.model.DeviceUpdateRequest; +import com.baidubce.services.evs.model.GBConfigDownloadResponse; +import com.baidubce.services.evs.model.GBDevicePasswordRequest; +import com.baidubce.services.evs.model.GbPresetAddRequest; +import com.baidubce.services.evs.model.GbPresetAddResponse; +import com.baidubce.services.evs.model.SpaceCreateRequest; +import com.baidubce.services.evs.model.SpaceCreateResponse; +import com.baidubce.services.evs.model.SpaceGetResponse; +import com.baidubce.services.evs.model.SpaceListMarkRequest; +import com.baidubce.services.evs.model.SpaceUpdateRequest; +import com.baidubce.util.DateUtils; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; +import java.util.List; + +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkPattern; + +/** + * Provides the client for accessing the Baidu Cloud network Service EVS. + */ +public class EvsClient extends AbstractBceClient { + + private static final String VERSION = "v1"; + + private static final String SDK = "sdk"; + private static final String DISABLE = "disable"; + private static final String ENABLE = "enable"; + private static final String MARKER = "marker"; + private static final String PAGE_NO = "pageNo"; + private static final String PAGE_SIZE = "pageSize"; + private static final String STATUS = "status"; + private static final String MAX_SIZE = "maxSize"; + private static final String COUNT = "count"; + private static final String BEGIN = "begin"; + private static final String END = "end"; + private static final String TYPE = "type"; + private static final String RECORDING = "recording"; + private static final String THUMBNAIL = "thumbnail"; + private static final String AI_ANALYSIS = "aiAnalysisByMarker"; + private static final String SIGNED_URL = "signedUrl"; + private static final String PROTOCOL = "protocol"; + private static final String GB_CONFIG_DOWNLOAD = "gbConfigDownload"; + private static final String GB_DEVICE_PASSWORD = "gbDevicePassword"; + private static final String TELE_BOOT = "teleboot"; + private static final String TRAFFIC_FRAME = "trafficFrame"; + private static final String REFRESH = "refresh"; + private static final String STOP = "stop"; + private static final String START = "start"; + private static final String PTZ = "ptz"; + private static final String BIND_DEVICE_BY_SN_CODE = "bindDeviceBySnCode"; + public static final String PTZ_COMMAND = "ptzCommand"; + public static final String SPEED = "speed"; + public static final String FI = "fi"; + public static final String FI_COMMAND = "fiCommand"; + public static final String PRESET = "preset"; + public static final String GOTO = "goto"; + + private static final String SPACE_URL = "space"; + private static final String SPACE_ID = "spaceId"; + private static final String SPACE_NAME = "spaceName"; + + private static final String DEVICE_URL = "device"; + private static final String DEVICE_NAME = "deviceName"; + private static final String DEVICE_ID = "deviceId"; + + private static final String CHANNEL_URL = "device/channel"; + + private static final String MILLISECONDS_TIMESTAMP = "\\d{13}"; + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + private static final HttpResponseHandler[] EVS_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public EvsClient() { + this(new EvsClientConfiguration()); + } + + public EvsClient(BceClientConfiguration clientConfiguration) { + this(clientConfiguration, EVS_HANDLERS); + } + + public EvsClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers) { + super(config, responseHandlers); + } + + public EvsClient(BceClientConfiguration config, + HttpResponseHandler[] responseHandlers, boolean isHttpAsyncPutEnabled) { + super(config, responseHandlers, isHttpAsyncPutEnabled); + } + + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * Used to create EVS space + * + * @param request Create the required data + * @return spaceId 、Upstream and Downstream domain + */ + public SpaceCreateResponse createSpace(SpaceCreateRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, SPACE_URL); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, SpaceCreateResponse.class); + } + + /** + * Used to delete EVS space. Delete the specified space according to the space ID. + * After the space is deleted, all devices in the space will also be deleted. + * + * @param spaceId space id + */ + public void deleteSpace(long spaceId) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), HttpMethodName.DELETE, + SPACE_URL, String.valueOf(spaceId)); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to modify EVS space configuration. + * + * @param spaceId space id + * @param request Update the required data + */ + public void updateSpace(long spaceId, SpaceUpdateRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, SPACE_URL, + String.valueOf(spaceId)); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to query EVS space configuration information. + * + * @param spaceId space id + * @return matching space details + */ + public SpaceGetResponse getSpace(long spaceId) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, SPACE_URL, + String.valueOf(spaceId)); + return invokeHttpClient(internalRequest, SpaceGetResponse.class); + } + + /** + * Query EVS list of all Spaces under the user account in the way of Marker paging. + * + * @param request Criteria used to filter at query time + * @returnSpace list of marker data + */ + public SpaceMarkListResponse listSpaceByMarker(SpaceListMarkRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, SPACE_URL); + + internalRequest.addParameter(MARKER, null); + internalRequest.addParameter(MAX_SIZE, String.valueOf(request.getMaxSize())); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, String.valueOf(request.getMarker())); + } + if (StringUtils.isNotEmpty(request.getSpaceName())) { + internalRequest.addParameter(SPACE_NAME, request.getSpaceName()); + } + if (request.getStatus() != null) { + internalRequest.addParameter(STATUS, request.getStatus()); + } + if (request.getType() != null) { + internalRequest.addParameter(TYPE, request.getType()); + } + return invokeHttpClient(internalRequest, SpaceMarkListResponse.class); + } + + /** + * Used to deactivate the EVS space. + * + * @param spaceId The space ID to be stopped + */ + public void disableSpace(long spaceId) { + EvsBaseRequest request = new EvsBaseRequest(); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + SPACE_URL, String.valueOf(spaceId)); + internalRequest.addParameter(DISABLE, null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to enable the EVS space. + * + * @param spaceId The space ID to be started + */ + public void enableSpace(long spaceId) { + EvsBaseRequest request = new EvsBaseRequest(); + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, SPACE_URL, + String.valueOf(spaceId)); + internalRequest.addParameter(ENABLE, null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Use to add EVS device. + * + * @param request Create the required data + * @return device id + */ + public DeviceCreateResponse createDevice(DeviceCreateRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DEVICE_URL); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DeviceCreateResponse.class); + } + + /** + * Used to delete EVS device. + * + * @param deviceId device id + */ + public void deleteDevice(long deviceId) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.DELETE, DEVICE_URL, + String.valueOf(deviceId)); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to modify EVS device configuration. + * + * @param deviceId device id + * @param request Modified information + */ + public void updateDevice(long deviceId, DeviceUpdateRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, DEVICE_URL, String.valueOf(deviceId)); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to query EVS devices. + * + * @param deviceId device id + * @return Matching device details + */ + public DeviceGetResponse getDevice(long deviceId) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, DEVICE_URL, + String.valueOf(deviceId)); + return invokeHttpClient(internalRequest, DeviceGetResponse.class); + } + + /** + * Use to query all the devices in user space below the list, by marker query. + * + * @param request Conditions for filtering by paging queries + * @return Device list of marker data + */ + public DeviceMarkListResponse listMarkDevice(DeviceListMarkRequest request) { + checkNotNull(request.getSpaceId(), "spaceId parameter request should not be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DEVICE_URL); + internalRequest.addParameter(MARKER, null); + + internalRequest.addParameter(MAX_SIZE, String.valueOf(request.getMaxSize())); + internalRequest.addParameter(SPACE_ID, String.valueOf(request.getSpaceId())); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, String.valueOf(request.getMarker())); + } + if (StringUtils.isNotEmpty(request.getDeviceName())) { + internalRequest.addParameter(DEVICE_NAME, request.getDeviceName()); + } + if (request.getStatus() != null) { + internalRequest.addParameter(STATUS, request.getStatus()); + } + + return invokeHttpClient(internalRequest, DeviceMarkListResponse.class); + } + + /** + * Used to deactivate EVS devices. + * + * @param deviceId The device ID that needs to be deactivated + * @param request stop time, + * If request is null, the device is permanently deactivated. If the request body contains + * a recoverTime parameter, deactivate the device until the recoverTime time is specified. + */ + public void disableDevice(long deviceId, DeviceStopRequest request) { + InternalRequest internalRequest; + if (request != null) { + internalRequest = createRequest(request, + HttpMethodName.PUT, DEVICE_URL, String.valueOf(deviceId)); + fillPayload(internalRequest, request); + } else { + EvsBaseRequest evsBaseRequest = new EvsBaseRequest(); + internalRequest = createRequest(evsBaseRequest, + HttpMethodName.PUT, DEVICE_URL, String.valueOf(deviceId)); + fillPayload(internalRequest, evsBaseRequest); + } + + internalRequest.addParameter(DISABLE, null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to enable EVS devices. + * + * @param deviceId The device ID that needs to be enabled + */ + public void enableDevice(long deviceId) { + EvsBaseRequest evsBaseRequest = new EvsBaseRequest(); + InternalRequest internalRequest = createRequest(evsBaseRequest, + HttpMethodName.PUT, DEVICE_URL, String.valueOf(deviceId)); + fillPayload(internalRequest, evsBaseRequest); + + internalRequest.addParameter(ENABLE, null); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to query the device's video file list + * + * @param deviceId device id + * @param request Query required conditions:Recording start and end time (Unix timestamp) 、pageNo、pageSize + * @return Matching video file paging data + */ + public DeviceTsStorePageListResponse listDeviceRecord( + long deviceId, DeviceTsStoreListRequest request) { + checkNotNull(request.getBegin(), "DeviceTsStoreListRequest.begin parameter request should not be null."); + checkNotNull(request.getEnd(), "DeviceTsStoreListRequest.end parameter request should not be null."); + checkNotNull(request.getPageNo(), "DeviceTsStoreListRequest.pageNo parameter request should not be null."); + checkNotNull(request.getPageSize(), "DeviceTsStoreListRequest.pageSize parameter request should not be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DEVICE_URL, + String.valueOf(deviceId), RECORDING); + internalRequest.addParameter(BEGIN, String.valueOf(request.getBegin())); + internalRequest.addParameter(END, String.valueOf(request.getEnd())); + internalRequest.addParameter(PAGE_NO, String.valueOf(request.getPageNo())); + internalRequest.addParameter(PAGE_SIZE, String.valueOf(request.getPageSize())); + internalRequest.addParameter(TYPE, String.valueOf(request.getType())); + + return invokeHttpClient(internalRequest, DeviceTsStorePageListResponse.class); + } + + /** + * Used to query the number of video files of the RTMP device. + * + * @param deviceId device id + * @param begin Recording start time, Unix timestamp, in seconds. + * @param end Recording end time, Unix timestamp, in seconds, + * @return Recording count + */ + public DeviceCountResponse countDeviceRecoding(long deviceId, long begin, long end) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, DEVICE_URL, String.valueOf(deviceId), + RECORDING); + internalRequest.addParameter(BEGIN, String.valueOf(begin)); + internalRequest.addParameter(END, String.valueOf(end)); + + internalRequest.addParameter(COUNT, null); + return invokeHttpClient(internalRequest, DeviceCountResponse.class); + } + + /** + * Used to delete the video files of the RTMP device. + * + * @param deviceId device id + * @param begin Recording start time, Unix timestamp, in seconds. + * @param end Recording end time, Unix timestamp, in seconds, + */ + public void removeDeviceRecord(long deviceId, long begin, long end) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.DELETE, DEVICE_URL, + String.valueOf(deviceId), RECORDING); + internalRequest.addParameter(BEGIN, String.valueOf(begin)); + internalRequest.addParameter(END, String.valueOf(end)); + + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to query the device's screenshot file list + * + * @param deviceId device id + * @param request Query required conditions:Thumbnail start and end time (Unix timestamp) 、pageNo、pageSize + * @return Matching screenshot file paging data + */ + public DeviceTsStorePageListResponse listDeviceThumbnail( + long deviceId, DeviceTsStoreListRequest request) { + checkNotNull(request.getBegin(), "DeviceTsStoreListRequest.begin parameter request should not be null."); + checkNotNull(request.getEnd(), "DeviceTsStoreListRequest.end parameter request should not be null."); + checkNotNull(request.getPageNo(), "DeviceTsStoreListRequest.pageNo parameter request should not be null."); + checkNotNull(request.getPageSize(), "DeviceTsStoreListRequest.pageSize parameter request should not be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DEVICE_URL, + String.valueOf(deviceId), THUMBNAIL); + internalRequest.addParameter(BEGIN, String.valueOf(request.getBegin())); + internalRequest.addParameter(END, String.valueOf(request.getEnd())); + internalRequest.addParameter(PAGE_NO, String.valueOf(request.getPageNo())); + internalRequest.addParameter(PAGE_SIZE, String.valueOf(request.getPageSize())); + + return invokeHttpClient(internalRequest, DeviceTsStorePageListResponse.class); + } + + /** + * Used to query the number of screenshot files of the RTMP device. + * + * @param deviceId device id + * @param begin Thumbnail start time, Unix timestamp, in seconds. + * @param end Thumbnail end time, Unix timestamp, in seconds, + * @return Thumbnail count + */ + public DeviceCountResponse countDevicehumbnail(long deviceId, long begin, long end) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, DEVICE_URL, String.valueOf(deviceId), THUMBNAIL); + internalRequest.addParameter(BEGIN, String.valueOf(begin)); + internalRequest.addParameter(END, String.valueOf(end)); + + internalRequest.addParameter(COUNT, null); + return invokeHttpClient(internalRequest, DeviceCountResponse.class); + } + + /** + * Used to delete the screenshot files of the RTMP device. + * + * @param deviceId device id + * @param begin Thumbnail start time, Unix timestamp, in seconds. + * @param end Thumbnail end time, Unix timestamp, in seconds, + */ + public void removeDeviceThumbnail(long deviceId, long begin, long end) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.DELETE, DEVICE_URL, String.valueOf(deviceId), THUMBNAIL); + internalRequest.addParameter(BEGIN, String.valueOf(begin)); + internalRequest.addParameter(END, String.valueOf(end)); + + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to query the AI analysis results of RTMP devices. It is only used for devices with AI skill + * configuration enabled in the space configuration. + * + * @param deviceId device id + * @param aiType AI detection type,Support: + * FACE、BODY、ELECTRIC、CAR_ATTRIBUTE、CAR_MODEL、CAR_PLATE,STATIC_HUMAN_TRAFFIC、STATIC_CAR_TRAFFIC、 + * QUALITY_BRIGHT、QUALITY_COLOR、QUALITY_COVER、QUALITY_BLUR、QUALITY_NOISE + * @param request Query required conditions:Recording start and end time (Unix timestamp) 、pageNo、pageSize + * @return Matching screenshot file paging data + */ + public DeviceAiAnalysisListMarkResponse listDeviceAiAnalysisResultByMarker( + long deviceId, String aiType, DeviceAiAnalysisListMarkRequest request) { + checkNotNull(request.getBegin(), "DeviceTsStoreListRequest.begin parameter request should not be null."); + checkNotNull(request.getEnd(), "DeviceTsStoreListRequest.end parameter request should not be null."); + checkNotNull(aiType, "type parameter request should not be null."); + checkPattern(String.valueOf(request.getBegin()), MILLISECONDS_TIMESTAMP, + "DeviceTsStoreListRequest.begin parameter request should have a millisecond timestamp."); + checkPattern(String.valueOf(request.getEnd()), MILLISECONDS_TIMESTAMP, + "DeviceTsStoreListRequest.end parameter request should have a millisecond timestamp."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DEVICE_URL, + String.valueOf(deviceId), AI_ANALYSIS); + internalRequest.addParameter(TYPE, aiType); + internalRequest.addParameter(MARKER, null); + internalRequest.addParameter(MAX_SIZE, String.valueOf(request.getMaxSize())); + internalRequest.addParameter(BEGIN, String.valueOf(DateUtils.formatIso8601Date(new Date(request.getBegin())))); + internalRequest.addParameter(END, String.valueOf(DateUtils.formatIso8601Date(new Date(request.getEnd())))); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, String.valueOf(request.getMarker())); + } + return invokeHttpClient(internalRequest, DeviceAiAnalysisListMarkResponse.class); + } + + /** + * Used to obtain the device broadcast signature address according to the domain name + * + * @param domain domain name + * @param app device app + * @param stream device stream + * @param protocol Agreement name + * @return url string + */ + public DeviceSignedUrlResponse generateDeviceSignedUrl(String domain, + String app, + String stream, + String protocol) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, DEVICE_URL, domain, app, stream, SIGNED_URL); + if (StringUtils.isNotBlank(protocol)) { + internalRequest.addParameter(PROTOCOL, protocol); + } + internalRequest.addParameter(SDK, null); + + return invokeHttpClient(internalRequest, DeviceSignedUrlResponse.class); + } + + /** + * Used to query national standard equipment configuration information. + * + * @param deviceId gb device id + * @return The configuration details of the designated national standard equipment + */ + public GBConfigDownloadResponse getDeviceGbConfigDownload(long deviceId) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, DEVICE_URL, String.valueOf(deviceId), GB_CONFIG_DOWNLOAD); + + return invokeHttpClient(internalRequest, GBConfigDownloadResponse.class); + } + + /** + * Used to restart the GB28181 device. + * + * @param deviceId gb device id + */ + public void teleBootDevice(long deviceId) { + EvsBaseRequest request = new EvsBaseRequest(); + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, DEVICE_URL, String.valueOf(deviceId)); + internalRequest.addParameter(TELE_BOOT, null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to set the size of the equipment monitoring frame + * + * @param channelId channelId ID + * @param dynamicTrafficFrame equipment monitoring frame config info + * @return channelId id + */ + public DeviceChannelGetResponse trafficFrameDevice(long channelId, DynamicTrafficFrameRequest dynamicTrafficFrame) { + DynamicTrafficFrameRequest.Configuration configuration = dynamicTrafficFrame.getConfiguration(); + checkNotNull(configuration, + "DynamicTrafficFrameRequest.configuration parameter request should NOT be null."); + DynamicTrafficFrameRequest.Configuration.FrameLocation frameLocation = configuration.getFrameLocation(); + checkNotNull(frameLocation, "Configuration.frameLocation parameter request should not be null."); + checkNotNull(frameLocation.getHorizontal(), "FrameLocation.horizontal parameter request should not be null."); + checkNotNull(frameLocation.getVertical(), "FrameLocation.vertical parameter request should not be null."); + checkNotNull(frameLocation.getHeight(), "FrameLocation.height parameter request should not be null."); + checkNotNull(frameLocation.getWidth(), "FrameLocation.width parameter request should not be null."); + InternalRequest internalRequest = createRequest(dynamicTrafficFrame, + HttpMethodName.PUT, CHANNEL_URL, String.valueOf(channelId), TRAFFIC_FRAME); + + fillPayload(internalRequest, dynamicTrafficFrame); + return invokeHttpClient(internalRequest, DeviceChannelGetResponse.class); + } + + /** + * Used to modify the user password of the GB28181 device. + * + * @param deviceId gb device id + * @param request new password + */ + public void modifyDeviceGbPassword(long deviceId, GBDevicePasswordRequest request) { + checkNotNull(request.getPassword(), "GBDevicePasswordRequest.password parameter request should not be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + DEVICE_URL, String.valueOf(deviceId), GB_DEVICE_PASSWORD); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to view the channel list of the GB28181 device. + * + * @param deviceId gb device id + * @return Channel list details of designated national standard equipment + */ + public DeviceChannelListResponse listChannel(long deviceId) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, CHANNEL_URL); + internalRequest.addParameter(SDK, null); + internalRequest.addParameter(DEVICE_ID, String.valueOf(deviceId)); + return invokeHttpClient(internalRequest, DeviceChannelListResponse.class); + } + + /** + * Used to refresh the channel of the specified GB28181 device. + * + * @param deviceId gb device id + */ + public void refreshChannels(long deviceId) { + EvsBaseRequest request = new EvsBaseRequest(); + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, CHANNEL_URL); + internalRequest.addParameter(REFRESH, null); + internalRequest.addParameter(DEVICE_ID, String.valueOf(deviceId)); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to view the specified GB28181 device channel. + * + * @param channelId channel id + * @return Matching channel details + */ + public DeviceChannelGetResponse getChannel(long channelId) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, CHANNEL_URL, + String.valueOf(channelId)); + internalRequest.addParameter(SDK, null); + return invokeHttpClient(internalRequest, DeviceChannelGetResponse.class); + } + + /** + * Used to deactivate the designated channel of the GB28181 device. + * + * @param channelId channel id + * @param request UTZ time, If it is empty, the device will be disabled permanently, if it is not empty, the + * device will be disabled until the recoverTime is specified + */ + public void stopChannel(long channelId, DeviceStopRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, + CHANNEL_URL, String.valueOf(channelId)); + internalRequest.addParameter(STOP, null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to enable the specified channel of the GB28181 device. + * + * @param channelId channel id + */ + public void startChannel(long channelId) { + EvsBaseRequest request = new EvsBaseRequest(); + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, CHANNEL_URL, + String.valueOf(channelId)); + internalRequest.addParameter(START, null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to obtain the channel broadcast signature address according to the domain name + * + * @param channelId channel id + * @param protocol Agreement name + * @return url string + */ + public DeviceChannelSignedUrlResponse generateChannelSignedUrl( + long channelId, String protocol) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, CHANNEL_URL, String.valueOf(channelId), SIGNED_URL); + internalRequest.addParameter(SDK, null); + internalRequest.addParameter(PROTOCOL, protocol); + return invokeHttpClient(internalRequest, DeviceChannelSignedUrlResponse.class); + } + + /** + * Used to query the video file list of GB28181 device channel. + * + * @param channelId channel id + * @param request Query required conditions:Recording start and end time (Unix timestamp) 、pageNo、pageSize + * @return Matching video file paging data + */ + public DeviceTsStorePageListResponse listChannelRecord(long channelId, DeviceTsStoreListRequest request) { + checkNotNull(request.getBegin(), "DeviceTsStoreListRequest.begin parameter request should not be null."); + checkNotNull(request.getEnd(), "DeviceTsStoreListRequest.end parameter request should not be null."); + checkNotNull(request.getPageNo(), "DeviceTsStoreListRequest.pageNo parameter request should not be null."); + checkNotNull(request.getPageSize(), "DeviceTsStoreListRequest.pageSize parameter request should not be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, + CHANNEL_URL, String.valueOf(channelId), RECORDING); + internalRequest.addParameter(BEGIN, String.valueOf(request.getBegin())); + internalRequest.addParameter(END, String.valueOf(request.getEnd())); + internalRequest.addParameter(PAGE_NO, String.valueOf(request.getPageNo())); + internalRequest.addParameter(PAGE_SIZE, String.valueOf(request.getPageSize())); + + return invokeHttpClient(internalRequest, DeviceTsStorePageListResponse.class); + } + + /** + * Used to query the number of video files of GB28181 device channel + * + * @param channelId channel id + * @param begin Recording start time, Unix timestamp, in seconds. + * @param end Recording end time, Unix timestamp, in seconds, + * @return Recording count + */ + public DeviceCountResponse countChannelRecoding(long channelId, long begin, long end) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, CHANNEL_URL, String.valueOf(channelId), + RECORDING); + internalRequest.addParameter(BEGIN, String.valueOf(begin)); + internalRequest.addParameter(END, String.valueOf(end)); + + internalRequest.addParameter(COUNT, null); + return invokeHttpClient(internalRequest, DeviceCountResponse.class); + } + + /** + * Used to delete the video files of the GB28181 device channel. + * + * @param channelId channelId id + * @param begin Recording start time, Unix timestamp, in seconds. + * @param end Recording end time, Unix timestamp, in seconds, + */ + public void removeChannelRecord(long channelId, long begin, long end) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.DELETE, CHANNEL_URL, + String.valueOf(channelId), RECORDING); + internalRequest.addParameter(BEGIN, String.valueOf(begin)); + internalRequest.addParameter(END, String.valueOf(end)); + + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to query the list of screenshot files of GB28181 device channel. + * + * @param channelId channelId id + * @param request Query required conditions:Thumbnail start and end time (Unix timestamp) 、pageNo、pageSize + * @return Matching screenshot file paging data + */ + public DeviceTsStorePageListResponse listChannelThumbnail( + long channelId, DeviceTsStoreListRequest request) { + checkNotNull(request.getBegin(), "DeviceTsStoreListRequest.begin parameter request should not be null."); + checkNotNull(request.getEnd(), "DeviceTsStoreListRequest.end parameter request should not be null."); + checkNotNull(request.getPageNo(), "DeviceTsStoreListRequest.pageNo parameter request should not be null."); + checkNotNull(request.getPageSize(), "DeviceTsStoreListRequest.pageSize parameter request should not be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, CHANNEL_URL, + String.valueOf(channelId), THUMBNAIL); + internalRequest.addParameter(BEGIN, String.valueOf(request.getBegin())); + internalRequest.addParameter(END, String.valueOf(request.getEnd())); + internalRequest.addParameter(PAGE_NO, String.valueOf(request.getPageNo())); + internalRequest.addParameter(PAGE_SIZE, String.valueOf(request.getPageSize())); + return invokeHttpClient(internalRequest, DeviceTsStorePageListResponse.class); + } + + /** + * Used to query the number of screenshot files of the Gb28181 device channel. + * + * @param channelId channel id + * @param begin Thumbnail start time, Unix timestamp, in seconds. + * @param end Thumbnail end time, Unix timestamp, in seconds, + * @return Thumbnail count + */ + public DeviceCountResponse countChannelThumbnail(long channelId, long begin, long end) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, CHANNEL_URL, String.valueOf(channelId), THUMBNAIL); + internalRequest.addParameter(BEGIN, String.valueOf(begin)); + internalRequest.addParameter(END, String.valueOf(end)); + + internalRequest.addParameter(COUNT, null); + return invokeHttpClient(internalRequest, DeviceCountResponse.class); + } + + /** + * Used to delete the screenshot file of the GB28181 device channel. + * + * @param channelId channel id + * @param begin Thumbnail start time, Unix timestamp, in seconds. + * @param end Thumbnail end time, Unix timestamp, in seconds, + */ + public void removeChannelThumbnail(long channelId, long begin, long end) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.DELETE, CHANNEL_URL, String.valueOf(channelId), THUMBNAIL); + internalRequest.addParameter(BEGIN, String.valueOf(begin)); + internalRequest.addParameter(END, String.valueOf(end)); + + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * It is used to query the AI analysis results of GB28181 device channels. + * It is only used for the device channels with AI skill configuration enabled in the space configuration. + * + * @param channelId channel id + * @param aiType AI detection type,Support: + * FACE、BODY、ELECTRIC、CAR_ATTRIBUTE、CAR_MODEL、CAR_PLATE,STATIC_HUMAN_TRAFFIC、STATIC_CAR_TRAFFIC、 + * QUALITY_BRIGHT、QUALITY_COLOR、QUALITY_COVER、QUALITY_BLUR、QUALITY_NOISE + * @param request Query required conditions:Recording start and end time (Unix timestamp) 、pageNo、pageSize + * @return Matching screenshot file paging data + */ + public DeviceAiAnalysisListMarkResponse listChannelAiAnalysisResultByMarker( + long channelId, String aiType, DeviceAiAnalysisListMarkRequest request) { + checkNotNull(request.getBegin(), "DeviceTsStoreListRequest.begin parameter request should not be null."); + checkNotNull(request.getEnd(), "DeviceTsStoreListRequest.end parameter request should not be null."); + checkNotNull(aiType, "type parameter request should not be null."); + checkPattern(String.valueOf(request.getBegin()), MILLISECONDS_TIMESTAMP, + "DeviceTsStoreListRequest.begin parameter request should have a millisecond timestamp."); + checkPattern(String.valueOf(request.getEnd()), MILLISECONDS_TIMESTAMP, + "DeviceTsStoreListRequest.end parameter request should have a millisecond timestamp."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, CHANNEL_URL, + String.valueOf(channelId), AI_ANALYSIS); + internalRequest.addParameter(TYPE, aiType); + internalRequest.addParameter(MARKER, null); + internalRequest.addParameter(MAX_SIZE, String.valueOf(request.getMaxSize())); + if (request.getMarker() != null) { + internalRequest.addParameter(MARKER, String.valueOf(request.getMarker())); + } + internalRequest.addParameter(BEGIN, String.valueOf(DateUtils.formatIso8601Date(new Date(request.getBegin())))); + internalRequest.addParameter(END, String.valueOf(DateUtils.formatIso8601Date(new Date(request.getEnd())))); + return invokeHttpClient(internalRequest, DeviceAiAnalysisListMarkResponse.class); + } + + /** + * Used to perform PTZ operation on the national standard equipment channel. + * + * @param channelId channel id + * @param ptzCommand ptz command, support: + * stop/left/right/up/down/zoomin/zoomout/left_up/left_down/right_up/right_down + * @param speed Adjust the speed, support 1-255 for up, down, + * left and right operation, and 1-15 for zoom operation + */ + public void modifyChannelPtz(long channelId, String ptzCommand, int speed) { + EvsBaseRequest request = new EvsBaseRequest(); + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, CHANNEL_URL, String.valueOf(channelId)); + internalRequest.addParameter(PTZ_COMMAND, ptzCommand.toString()); + internalRequest.addParameter(SPEED, String.valueOf(speed)); + internalRequest.addParameter(PTZ, null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to adjust the aperture and focus of the national standard equipment channel. + * + * @param channelId channel id + * @param fiCommand support:stop/irisin/irisout/focusnear/focusfar + * @param speed Adjust the speed, support 1-255 + */ + public void modifyChannelFi(long channelId, String fiCommand, int speed) { + EvsBaseRequest request = new EvsBaseRequest(); + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, CHANNEL_URL, String.valueOf(channelId)); + internalRequest.addParameter(FI_COMMAND, fiCommand.toString()); + internalRequest.addParameter(SPEED, String.valueOf(speed)); + internalRequest.addParameter(FI, null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to add presets to the national standard equipment channel. + * + * @param channelId channel id + * @param request Preset position name, the maximum length is 100 + * @return Preset Id + *

+ * Note: Before initiating the request to add a preset position, + * make sure that the camera has been adjusted to the expected position and angle through the ptz control. + */ + public GbPresetAddResponse addChannelPreset(long channelId, GbPresetAddRequest request) { + checkNotNull(request.getName(), "GbPresetAddRequest.name parameter request should not be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, + CHANNEL_URL, String.valueOf(channelId), PRESET); + + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, GbPresetAddResponse.class); + } + + /** + * Used to delete the preset position of the national standard equipment channel. + * + * @param channelId channel id + * @param presetId preset Id + */ + public void deleteChannelPreset(long channelId, int presetId) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.DELETE, CHANNEL_URL, String.valueOf(channelId), + PRESET, String.valueOf(presetId)); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to query the preset position list of the national standard equipment channel. + * + * @param channelId channel id + * @return Specify the list of all preset positions of GBT + */ + public GbPresetListResponse listChannelPreset(long channelId) { + InternalRequest internalRequest = createRequest(new EvsBaseRequest(), + HttpMethodName.GET, CHANNEL_URL, String.valueOf(channelId), PRESET); + internalRequest.addParameter(SDK, null); + return invokeHttpClient(internalRequest, GbPresetListResponse.class); + } + + /** + * Used to call the preset position of the national standard equipment channel, and quickly move the camera to + * the preset position. + * + * @param channelId channel id + * @param presetId preset Id + */ + public void gotoChannelPreset(long channelId, int presetId) { + EvsBaseRequest request = new EvsBaseRequest(); + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, CHANNEL_URL, + String.valueOf(channelId), PRESET, + String.valueOf(presetId)); + + internalRequest.addParameter(GOTO, null); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, EvsBaseResponse.class); + } + + /** + * Used to SnCode for binding bvcp equipment + * + * @param request Bind the required data + * @return deviceId and snCode + */ + public BindDeviceResponse bindDeviceBySnCode(BindDeviceRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, + DEVICE_URL); + internalRequest.addParameter(BIND_DEVICE_BY_SN_CODE, null); + checkNotNull(request.getSnCode(), "BindDeviceRequest.snCode parameter request should not be null."); + checkNotNull(request.getDeviceMode(), "BindDeviceRequest.deviceMode parameter request should not be null."); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, BindDeviceResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/evs/EvsClientConfiguration.java b/src/main/java/com/baidubce/services/evs/EvsClientConfiguration.java new file mode 100644 index 00000000..2b6a770d --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/EvsClientConfiguration.java @@ -0,0 +1,9 @@ +package com.baidubce.services.evs; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for evs service. + */ +public class EvsClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/evs/model/AiConfigRequest.java b/src/main/java/com/baidubce/services/evs/model/AiConfigRequest.java new file mode 100644 index 00000000..99c2daa7 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/AiConfigRequest.java @@ -0,0 +1,290 @@ +package com.baidubce.services.evs.model; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +public class AiConfigRequest implements Serializable { + + private static final long serialVersionUID = 6798206332963466508L; + + private boolean enabled; + + private List configuration; + + private FtpConfig ftpConfig; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public List getConfiguration() { + return configuration; + } + + public void setConfiguration(List configuration) { + this.configuration = configuration; + } + + public FtpConfig getFtpConfig() { + return ftpConfig; + } + + public void setFtpConfig(FtpConfig ftpConfig) { + this.ftpConfig = ftpConfig; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + AiConfigRequest that = (AiConfigRequest) o; + + if (enabled != that.enabled) { + return false; + } + if (configuration != null ? !configuration.equals(that.configuration) : that.configuration != null) { + return false; + } + return ftpConfig != null ? ftpConfig.equals(that.ftpConfig) : that.ftpConfig == null; + } + + @Override + public int hashCode() { + int result = (enabled ? 1 : 0); + result = 31 * result + (configuration != null ? configuration.hashCode() : 0); + result = 31 * result + (ftpConfig != null ? ftpConfig.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "AiConfigRequest{" + + "enabled=" + enabled + + ", configuration=" + configuration + + ", ftpConfig=" + ftpConfig + + '}'; + } + + public static class Configuration implements Serializable { + + private static final long serialVersionUID = -4968362421982646857L; + + /** + * Support: + * FACE、BODY、ELECTRIC、CAR_ATTRIBUTE、CAR_MODEL、CAR_PLATE,STATIC_HUMAN_TRAFFIC、STATIC_CAR_TRAFFIC、 + * QUALITY_BRIGHT、QUALITY_COLOR、QUALITY_COVER、QUALITY_BLUR、QUALITY_NOISE + */ + private String type; + + private Long interval; + + /** + * Support:OPTIMAL、FASTEST、 REGULAR + */ + private String strategy; + + private List effectiveTimes; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Long getInterval() { + return interval; + } + + public void setInterval(Long interval) { + this.interval = interval; + } + + public String getStrategy() { + return strategy; + } + + public void setStrategy(String strategy) { + this.strategy = strategy; + } + + public List getEffectiveTimes() { + return effectiveTimes; + } + + public void setEffectiveTimes(List effectiveTimes) { + this.effectiveTimes = effectiveTimes; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Configuration that = (Configuration) o; + + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + if (interval != null ? !interval.equals(that.interval) : that.interval != null) { + return false; + } + if (strategy != null ? !strategy.equals(that.strategy) : that.strategy != null) { + return false; + } + return effectiveTimes != null ? effectiveTimes.equals(that.effectiveTimes) : that.effectiveTimes == null; + } + + @Override + public int hashCode() { + int result = type != null ? type.hashCode() : 0; + result = 31 * result + (interval != null ? interval.hashCode() : 0); + result = 31 * result + (strategy != null ? strategy.hashCode() : 0); + result = 31 * result + (effectiveTimes != null ? effectiveTimes.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "Configuration{" + + "type='" + type + '\'' + + ", interval=" + interval + + ", strategy='" + strategy + '\'' + + ", effectiveTimes=" + effectiveTimes + + '}'; + } + } + + public static class EffectiveTime implements Serializable { + + private static final long serialVersionUID = -6956309119562350698L; + + private Date effectiveTimeStart; + + private Date effectiveTimeEnd; + + public Date getEffectiveTimeStart() { + return effectiveTimeStart; + } + + public void setEffectiveTimeStart(Date effectiveTimeStart) { + this.effectiveTimeStart = effectiveTimeStart; + } + + public Date getEffectiveTimeEnd() { + return effectiveTimeEnd; + } + + public void setEffectiveTimeEnd(Date effectiveTimeEnd) { + this.effectiveTimeEnd = effectiveTimeEnd; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + EffectiveTime that = (EffectiveTime) o; + + if (effectiveTimeStart != null ? + !effectiveTimeStart.equals(that.effectiveTimeStart) : + that.effectiveTimeStart != null) { + return false; + } + return effectiveTimeEnd != null ? + effectiveTimeEnd.equals(that.effectiveTimeEnd) : + that.effectiveTimeEnd == null; + } + + @Override + public int hashCode() { + int result = effectiveTimeStart != null ? effectiveTimeStart.hashCode() : 0; + result = 31 * result + (effectiveTimeEnd != null ? effectiveTimeEnd.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "EffectiveTime{" + + "effectiveTimeStart=" + effectiveTimeStart + + ", effectiveTimeEnd=" + effectiveTimeEnd + + '}'; + } + } + + public static class FtpConfig implements Serializable { + + private static final long serialVersionUID = 8945714201933343920L; + + private boolean enabled; + + private String password; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + FtpConfig ftpConfig = (FtpConfig) o; + + if (enabled != ftpConfig.enabled) { + return false; + } + return password != null ? password.equals(ftpConfig.password) : ftpConfig.password == null; + } + + @Override + public int hashCode() { + int result = (enabled ? 1 : 0); + result = 31 * result + (password != null ? password.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "FtpConfig{" + + "enabled=" + enabled + + ", password='" + password + '\'' + + '}'; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/BindDeviceRequest.java b/src/main/java/com/baidubce/services/evs/model/BindDeviceRequest.java new file mode 100644 index 00000000..ebf254dd --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/BindDeviceRequest.java @@ -0,0 +1,135 @@ +package com.baidubce.services.evs.model; + + + +public class BindDeviceRequest extends EvsBaseRequest { + + private static final long serialVersionUID = 7590066621249900565L; + private Long spaceId; + + private String snCode; + + private String deviceName; + + private String deviceMode; + + private String type ; + + protected String description; + + protected DeviceGis gis; + + public long getSpaceId() { + return spaceId; + } + + public void setSpaceId(Long spaceId) { + this.spaceId = spaceId; + } + + public String getSnCode() { + return snCode; + } + + public void setSnCode(String snCode) { + this.snCode = snCode; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getDeviceMode() { + return deviceMode; + } + + public void setDeviceMode(String deviceMode) { + this.deviceMode = deviceMode; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public DeviceGis getGis() { + return gis; + } + + public void setGis(DeviceGis gis) { + this.gis = gis; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + BindDeviceRequest that = (BindDeviceRequest) o; + + if (spaceId != null ? !spaceId.equals(that.spaceId) : that.spaceId != null) { + return false; + } + if (snCode != null ? !snCode.equals(that.snCode) : that.snCode != null) { + return false; + } + if (deviceName != null ? !deviceName.equals(that.deviceName) : that.deviceName != null) { + return false; + } + if (deviceMode != null ? !deviceMode.equals(that.deviceMode) : that.deviceMode != null) { + return false; + } + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + if (gis != null ? !gis.equals(that.gis) : that.gis != null) { + return false; + } + return description != null ? description.equals(that.description) : that.description == null; + } + + @Override + public int hashCode() { + int result = spaceId != null ? spaceId.hashCode() : 0; + result = 31 * result + (snCode != null ? snCode.hashCode() : 0); + result = 31 * result + (deviceName != null ? deviceName.hashCode() : 0); + result = 31 * result + (deviceMode != null ? deviceMode.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (gis != null ? gis.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "BindDeviceRequest{" + + "spaceId=" + spaceId + + ", snCode='" + snCode + '\'' + + ", deviceName='" + deviceName + '\'' + + ", deviceMode='" + deviceMode + '\'' + + ", type='" + type + '\'' + + ", description='" + description + '\'' + + ", gis=" + gis + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/BindDeviceResponse.java b/src/main/java/com/baidubce/services/evs/model/BindDeviceResponse.java new file mode 100644 index 00000000..3cf05684 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/BindDeviceResponse.java @@ -0,0 +1,57 @@ +package com.baidubce.services.evs.model; + +public class BindDeviceResponse extends EvsBaseResponse{ + + private static final long serialVersionUID = 911116340410567274L; + + private Long deviceId; + private String snCode; + + public Long getDeviceId() { + return deviceId; + } + + public void setDeviceId(Long deviceId) { + this.deviceId = deviceId; + } + + public String getSnCode() { + return snCode; + } + + public void setSnCode(String snCode) { + this.snCode = snCode; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + BindDeviceResponse that = (BindDeviceResponse) o; + + if (deviceId != null ? !deviceId.equals(that.deviceId) : that.deviceId != null) { + return false; + } + return snCode != null ? snCode.equals(that.snCode) : that.snCode == null; + } + + @Override + public int hashCode() { + int result = deviceId != null ? deviceId.hashCode() : 0; + result = 31 * result + (snCode != null ? snCode.hashCode() : 0); + return result; + } + @Override + public String toString() { + return "BindDeviceResponse{" + + "deviceId=" + deviceId + + ", snCode='" + snCode + '\'' + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/evs/model/CallbackGetResponse.java b/src/main/java/com/baidubce/services/evs/model/CallbackGetResponse.java new file mode 100644 index 00000000..290d3f6f --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/CallbackGetResponse.java @@ -0,0 +1,7 @@ +package com.baidubce.services.evs.model; + +public class CallbackGetResponse extends CallbackUpdateRequest { + + private static final long serialVersionUID = -1474299259787650079L; + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/CallbackUpdateRequest.java b/src/main/java/com/baidubce/services/evs/model/CallbackUpdateRequest.java new file mode 100644 index 00000000..b1fd76a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/CallbackUpdateRequest.java @@ -0,0 +1,99 @@ +package com.baidubce.services.evs.model; + +import java.util.List; + +public class CallbackUpdateRequest extends EvsBaseRequest { + + private static final long serialVersionUID = -2343543510056058120L; + + protected boolean enabled; + + protected String endpoint; + + protected boolean authEnabled; + + protected String key; + + /** + * Type Support: + * ON_PUBLISH、ON_UNPUBLISH、ON_SNAPSHOT、ON_RECORD、 + * ON_PLAY、ON_STOP、ON_REGISTER、ON_UNREGISTER、ON_BASE_AI + */ + private List types; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public boolean isAuthEnabled() { + return authEnabled; + } + + public void setAuthEnabled(boolean authEnabled) { + this.authEnabled = authEnabled; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public List getTypes() { + return types; + } + + public void setTypes(List types) { + this.types = types; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + CallbackUpdateRequest that = (CallbackUpdateRequest) o; + + if (enabled != that.enabled) { + return false; + } + if (authEnabled != that.authEnabled) { + return false; + } + if (endpoint != null ? !endpoint.equals(that.endpoint) : that.endpoint != null) { + return false; + } + if (key != null ? !key.equals(that.key) : that.key != null) { + return false; + } + return types != null ? types.equals(that.types) : that.types == null; + } + + @Override + public int hashCode() { + int result = (enabled ? 1 : 0); + result = 31 * result + (endpoint != null ? endpoint.hashCode() : 0); + result = 31 * result + (authEnabled ? 1 : 0); + result = 31 * result + (key != null ? key.hashCode() : 0); + result = 31 * result + (types != null ? types.hashCode() : 0); + return result; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceAiAnalysisListMarkRequest.java b/src/main/java/com/baidubce/services/evs/model/DeviceAiAnalysisListMarkRequest.java new file mode 100644 index 00000000..8f09eccd --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceAiAnalysisListMarkRequest.java @@ -0,0 +1,88 @@ +package com.baidubce.services.evs.model; + +public class DeviceAiAnalysisListMarkRequest extends EvsBaseRequest { + + private static final long serialVersionUID = -4908751589233017851L; + + private Long begin; + + private Long end; + + private Long marker; + + private int maxSize; + + public Long getMarker() { + return marker; + } + + public void setMarker(Long marker) { + this.marker = marker; + } + + public int getMaxSize() { + return maxSize; + } + + public void setMaxSize(int maxSize) { + this.maxSize = maxSize; + } + + public Long getBegin() { + return begin; + } + + public void setBegin(Long begin) { + this.begin = begin; + } + + public Long getEnd() { + return end; + } + + public void setEnd(Long end) { + this.end = end; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceAiAnalysisListMarkRequest that = (DeviceAiAnalysisListMarkRequest) o; + + if (begin != null ? !begin.equals(that.begin) : that.begin != null) { + return false; + } + if (end != null ? !end.equals(that.end) : that.end != null) { + return false; + } + if (maxSize != that.maxSize) { + return false; + } + return marker != null ? marker.equals(that.marker) : that.marker == null; + } + + @Override + public int hashCode() { + int result = begin != null ? begin.hashCode() : 0; + result = 31 * result + (marker != null ? marker.hashCode() : 0); + result = 31 * result + maxSize; + result = 31 * result + (end != null ? end.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceAiAnalysisListMarkRequest{" + + "begin=" + begin + + ", end=" + end + + ", marker=" + marker + + ", maxSize=" + maxSize + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceAiAnalysisListMarkResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceAiAnalysisListMarkResponse.java new file mode 100644 index 00000000..d50ff7c8 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceAiAnalysisListMarkResponse.java @@ -0,0 +1,93 @@ +package com.baidubce.services.evs.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.io.Serializable; +import java.util.Collection; + +public class DeviceAiAnalysisListMarkResponse extends AbstractBceResponse implements Serializable { + + private static final long serialVersionUID = -8493880809212565629L; + + private Collection data; + + private Boolean isTruncated; + + private String marker; + + private String nextMarker; + + public Collection getData() { + return data; + } + + public void setData(Collection data) { + this.data = data; + } + + public Boolean getTruncated() { + return isTruncated; + } + + public void setTruncated(Boolean truncated) { + isTruncated = truncated; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getNextMarker() { + return nextMarker; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceAiAnalysisListMarkResponse that = (DeviceAiAnalysisListMarkResponse) o; + + if (data != null ? !data.equals(that.data) : that.data != null) { + return false; + } + if (isTruncated != null ? !isTruncated.equals(that.isTruncated) : that.isTruncated != null) { + return false; + } + if (marker != null ? !marker.equals(that.marker) : that.marker != null) { + return false; + } + return nextMarker != null ? nextMarker.equals(that.nextMarker) : that.nextMarker == null; + } + + @Override + public int hashCode() { + int result = data != null ? data.hashCode() : 0; + result = 31 * result + (isTruncated != null ? isTruncated.hashCode() : 0); + result = 31 * result + (marker != null ? marker.hashCode() : 0); + result = 31 * result + (nextMarker != null ? nextMarker.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceAiAnalysisListMarkResponse{" + + "data=" + data + + ", isTruncated=" + isTruncated + + ", marker='" + marker + '\'' + + ", nextMarker='" + nextMarker + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceChannelGetResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceChannelGetResponse.java new file mode 100644 index 00000000..277d1782 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceChannelGetResponse.java @@ -0,0 +1,106 @@ +package com.baidubce.services.evs.model; + +public class DeviceChannelGetResponse extends EvsBaseResponse { + + private static final long serialVersionUID = 1055112249058272679L; + + private Long channelId; + + private String channelName; + + private String channelGbId; + + private String channelStatus; + + private String manufacturer; + + private String appStream; + + public Long getChannelId() { + return channelId; + } + + public void setChannelId(Long channelId) { + this.channelId = channelId; + } + + public String getChannelName() { + return channelName; + } + + public void setChannelName(String channelName) { + this.channelName = channelName; + } + + public String getChannelGbId() { + return channelGbId; + } + + public void setChannelGbId(String channelGbId) { + this.channelGbId = channelGbId; + } + + public String getChannelStatus() { + return channelStatus; + } + + public void setChannelStatus(String channelStatus) { + this.channelStatus = channelStatus; + } + + public String getManufacturer() { + return manufacturer; + } + + public void setManufacturer(String manufacturer) { + this.manufacturer = manufacturer; + } + + public String getAppStream() { + return appStream; + } + + public void setAppStream(String appStream) { + this.appStream = appStream; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceChannelGetResponse that = (DeviceChannelGetResponse) o; + + if (channelId != null ? !channelId.equals(that.channelId) : that.channelId != null) { + return false; + } + if (channelName != null ? !channelName.equals(that.channelName) : that.channelName != null) { + return false; + } + if (channelGbId != null ? !channelGbId.equals(that.channelGbId) : that.channelGbId != null) { + return false; + } + if (channelStatus != null ? !channelStatus.equals(that.channelStatus) : that.channelStatus != null) { + return false; + } + if (manufacturer != null ? !manufacturer.equals(that.manufacturer) : that.manufacturer != null) { + return false; + } + return appStream != null ? appStream.equals(that.appStream) : that.appStream == null; + } + + @Override + public int hashCode() { + int result = channelId != null ? channelId.hashCode() : 0; + result = 31 * result + (channelName != null ? channelName.hashCode() : 0); + result = 31 * result + (channelGbId != null ? channelGbId.hashCode() : 0); + result = 31 * result + (channelStatus != null ? channelStatus.hashCode() : 0); + result = 31 * result + (manufacturer != null ? manufacturer.hashCode() : 0); + result = 31 * result + (appStream != null ? appStream.hashCode() : 0); + return result; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceChannelListResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceChannelListResponse.java new file mode 100644 index 00000000..649b33c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceChannelListResponse.java @@ -0,0 +1,44 @@ +package com.baidubce.services.evs.model; + +import java.util.List; + +public class DeviceChannelListResponse extends EvsBaseResponse { + + private static final long serialVersionUID = -4528924813667199321L; + + private List data; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceChannelListResponse that = (DeviceChannelListResponse) o; + + return data != null ? data.equals(that.data) : that.data == null; + } + + @Override + public int hashCode() { + return data != null ? data.hashCode() : 0; + } + + @Override + public String toString() { + return "DeviceChannelListResponse{" + + "data=" + data + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceChannelSignedUrlResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceChannelSignedUrlResponse.java new file mode 100644 index 00000000..acf2e91f --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceChannelSignedUrlResponse.java @@ -0,0 +1,42 @@ +package com.baidubce.services.evs.model; + +public class DeviceChannelSignedUrlResponse extends EvsBaseResponse { + + private static final long serialVersionUID = 9121378066243255436L; + + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceChannelSignedUrlResponse that = (DeviceChannelSignedUrlResponse) o; + + return url != null ? url.equals(that.url) : that.url == null; + } + + @Override + public int hashCode() { + return url != null ? url.hashCode() : 0; + } + + @Override + public String toString() { + return "DeviceChannelSignedUrlResponse{" + + "url='" + url + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceCountResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceCountResponse.java new file mode 100644 index 00000000..1f7314cf --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceCountResponse.java @@ -0,0 +1,41 @@ +package com.baidubce.services.evs.model; + +import java.io.Serializable; + +public class DeviceCountResponse extends EvsBaseResponse { + + private static final long serialVersionUID = 2776564010045866821L; + + private Count data; + + public Count getData() { + return data; + } + + public void setData(Count data) { + this.data = data; + } + + public static class Count implements Serializable { + + private static final long serialVersionUID = 5571959442221427504L; + + private Long count; + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } + + @Override + public String toString() { + return "Count{" + + "count=" + count + + '}'; + } + } + +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceCreateRequest.java b/src/main/java/com/baidubce/services/evs/model/DeviceCreateRequest.java new file mode 100644 index 00000000..b3847fca --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceCreateRequest.java @@ -0,0 +1,70 @@ +package com.baidubce.services.evs.model; + +public class DeviceCreateRequest extends DeviceUpdateRequest { + + private static final long serialVersionUID = 7653894659392858508L; + + /** + * Support:RTMP、GB28181 + */ + protected String type; + + protected String deviceStreamId; + + protected Long spaceId; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDeviceStreamId() { + return deviceStreamId; + } + + public void setDeviceStreamId(String deviceStreamId) { + this.deviceStreamId = deviceStreamId; + } + + public Long getSpaceId() { + return spaceId; + } + + public void setSpaceId(Long spaceId) { + this.spaceId = spaceId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + DeviceCreateRequest request = (DeviceCreateRequest) o; + + if (type != null ? !type.equals(request.type) : request.type != null) { + return false; + } + if (deviceStreamId != null ? !deviceStreamId.equals(request.deviceStreamId) : request.deviceStreamId != null) { + return false; + } + return spaceId != null ? spaceId.equals(request.spaceId) : request.spaceId == null; + } + + @Override + public int hashCode() { + int result = type != null ? type.hashCode() : 0; + result = 31 * result + (deviceStreamId != null ? deviceStreamId.hashCode() : 0); + result = 31 * result + (spaceId != null ? spaceId.hashCode() : 0); + return result; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceCreateResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceCreateResponse.java new file mode 100644 index 00000000..df73120d --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceCreateResponse.java @@ -0,0 +1,42 @@ +package com.baidubce.services.evs.model; + +public class DeviceCreateResponse extends EvsBaseResponse { + + private static final long serialVersionUID = 7846741888943929527L; + + private Long deviceId; + + public Long getDeviceId() { + return deviceId; + } + + public void setDeviceId(Long deviceId) { + this.deviceId = deviceId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceCreateResponse that = (DeviceCreateResponse) o; + + return deviceId != null ? deviceId.equals(that.deviceId) : that.deviceId == null; + } + + @Override + public int hashCode() { + return deviceId != null ? deviceId.hashCode() : 0; + } + + @Override + public String toString() { + return "DeviceCreateResponse{" + + "deviceId=" + deviceId + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceGbConfig.java b/src/main/java/com/baidubce/services/evs/model/DeviceGbConfig.java new file mode 100644 index 00000000..9d699fee --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceGbConfig.java @@ -0,0 +1,93 @@ +package com.baidubce.services.evs.model; + +import java.io.Serializable; + +public class DeviceGbConfig implements Serializable { + + private static final long serialVersionUID = -1408137063853326418L; + + /** + * Support:IPC、NVR + */ + private String platform; + + private String gbId; + + private String username; + + private String password; + + public String getPlatform() { + return platform; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + + public String getGbId() { + return gbId; + } + + public void setGbId(String gbId) { + this.gbId = gbId; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceGbConfig that = (DeviceGbConfig) o; + + if (platform != null ? !platform.equals(that.platform) : that.platform != null) { + return false; + } + if (gbId != null ? !gbId.equals(that.gbId) : that.gbId != null) { + return false; + } + if (username != null ? !username.equals(that.username) : that.username != null) { + return false; + } + return password != null ? password.equals(that.password) : that.password == null; + } + + @Override + public int hashCode() { + int result = platform != null ? platform.hashCode() : 0; + result = 31 * result + (gbId != null ? gbId.hashCode() : 0); + result = 31 * result + (username != null ? username.hashCode() : 0); + result = 31 * result + (password != null ? password.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceGbConfig{" + + "platform='" + platform + '\'' + + ", gbId='" + gbId + '\'' + + ", username='" + username + '\'' + + ", password='" + password + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceGbProperties.java b/src/main/java/com/baidubce/services/evs/model/DeviceGbProperties.java new file mode 100644 index 00000000..d097ca15 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceGbProperties.java @@ -0,0 +1,56 @@ +package com.baidubce.services.evs.model; + +import java.io.Serializable; + +public class DeviceGbProperties implements Serializable { + private static final long serialVersionUID = 8040264671754338493L; + + private String streamType; + private String codeStream; + + public String getStreamType() { + return streamType; + } + + public void setStreamType(String streamType) { + this.streamType = streamType; + } + + public String getCodeStream() { + return codeStream; + } + + public void setCodeStream(String codeStream) { + this.codeStream = codeStream; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeviceGbProperties that = (DeviceGbProperties) o; + if (streamType != null ? !streamType.equals(that.streamType) : that.streamType != null) { + return false; + } + return codeStream != null ? codeStream.equals(that.codeStream) : that.codeStream == null; + } + + @Override + public int hashCode() { + int result = streamType != null ? streamType.hashCode() : 0; + result = 31 * result + (codeStream != null ? codeStream.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceGbProperties{" + + "streamType='" + streamType + '\'' + + ", codeStream='" + codeStream + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceGetResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceGetResponse.java new file mode 100644 index 00000000..70c7df8c --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceGetResponse.java @@ -0,0 +1,316 @@ +package com.baidubce.services.evs.model; + +import java.util.Date; +import java.util.List; + +public class DeviceGetResponse extends EvsBaseResponse { + + private static final long serialVersionUID = 7081701229876538996L; + + private Long deviceId; + + private String deviceName; + + private String type; + + private String deviceStreamId; + + private String status; + + private String description; + + private UpstreamAuth upstreamAuth; + + private DownstreamAuth downstreamAuth; + + private List domains; + + private Recording recording; + + private Thumbnail thumbnail; + + private EdgeGetResponse edge; + + private Long spaceId; + + private String spaceName; + + private Integer channelCount; + + private Date createTime; + + protected DeviceGis gis; + + private String snCode; + + private String deviceMode; + + public DeviceGis getGis() { + return gis; + } + + public void setGis(DeviceGis gis) { + this.gis = gis; + } + + public String getSnCode() { + return snCode; + } + + public void setSnCode(String snCode) { + this.snCode = snCode; + } + + public String getDeviceMode() { + return deviceMode; + } + + public void setDeviceMode(String deviceMode) { + this.deviceMode = deviceMode; + } + + public Long getDeviceId() { + return deviceId; + } + + public void setDeviceId(Long deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDeviceStreamId() { + return deviceStreamId; + } + + public void setDeviceStreamId(String deviceStreamId) { + this.deviceStreamId = deviceStreamId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public UpstreamAuth getUpstreamAuth() { + return upstreamAuth; + } + + public void setUpstreamAuth(UpstreamAuth upstreamAuth) { + this.upstreamAuth = upstreamAuth; + } + + public DownstreamAuth getDownstreamAuth() { + return downstreamAuth; + } + + public void setDownstreamAuth(DownstreamAuth downstreamAuth) { + this.downstreamAuth = downstreamAuth; + } + + public List getDomains() { + return domains; + } + + public void setDomains(List domains) { + this.domains = domains; + } + + public Recording getRecording() { + return recording; + } + + public void setRecording(Recording recording) { + this.recording = recording; + } + + public Thumbnail getThumbnail() { + return thumbnail; + } + + public void setThumbnail(Thumbnail thumbnail) { + this.thumbnail = thumbnail; + } + + public EdgeGetResponse getEdge() { + return edge; + } + + public void setEdge(EdgeGetResponse edge) { + this.edge = edge; + } + + public Long getSpaceId() { + return spaceId; + } + + public void setSpaceId(Long spaceId) { + this.spaceId = spaceId; + } + + public String getSpaceName() { + return spaceName; + } + + public void setSpaceName(String spaceName) { + this.spaceName = spaceName; + } + + public Integer getChannelCount() { + return channelCount; + } + + public void setChannelCount(Integer channelCount) { + this.channelCount = channelCount; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceGetResponse that = (DeviceGetResponse) o; + + if (deviceId != null ? !deviceId.equals(that.deviceId) : that.deviceId != null) { + return false; + } + if (gis != null ? !gis.equals(that.gis) : that.gis != null) { + return false; + } + if (snCode != null ? !snCode.equals(that.snCode) : that.snCode != null) { + return false; + } + if (deviceMode != null ? !deviceMode.equals(that.deviceMode) : that.deviceMode != null) { + return false; + } + if (deviceName != null ? !deviceName.equals(that.deviceName) : that.deviceName != null) { + return false; + } + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + if (deviceStreamId != null ? !deviceStreamId.equals(that.deviceStreamId) : that.deviceStreamId != null) { + return false; + } + if (status != null ? !status.equals(that.status) : that.status != null) { + return false; + } + if (description != null ? !description.equals(that.description) : that.description != null) { + return false; + } + if (upstreamAuth != null ? !upstreamAuth.equals(that.upstreamAuth) : that.upstreamAuth != null) { + return false; + } + if (downstreamAuth != null ? !downstreamAuth.equals(that.downstreamAuth) : that.downstreamAuth != null) { + return false; + } + if (domains != null ? !domains.equals(that.domains) : that.domains != null) { + return false; + } + if (recording != null ? !recording.equals(that.recording) : that.recording != null) { + return false; + } + if (thumbnail != null ? !thumbnail.equals(that.thumbnail) : that.thumbnail != null) { + return false; + } + if (edge != null ? !edge.equals(that.edge) : that.edge != null) { + return false; + } + if (spaceId != null ? !spaceId.equals(that.spaceId) : that.spaceId != null) { + return false; + } + if (spaceName != null ? !spaceName.equals(that.spaceName) : that.spaceName != null) { + return false; + } + if (channelCount != null ? !channelCount.equals(that.channelCount) : that.channelCount != null) { + return false; + } + return createTime != null ? createTime.equals(that.createTime) : that.createTime == null; + } + + @Override + public int hashCode() { + int result = deviceId != null ? deviceId.hashCode() : 0; + result = 31 * result + (deviceName != null ? deviceName.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (deviceStreamId != null ? deviceStreamId.hashCode() : 0); + result = 31 * result + (status != null ? status.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (upstreamAuth != null ? upstreamAuth.hashCode() : 0); + result = 31 * result + (downstreamAuth != null ? downstreamAuth.hashCode() : 0); + result = 31 * result + (domains != null ? domains.hashCode() : 0); + result = 31 * result + (recording != null ? recording.hashCode() : 0); + result = 31 * result + (thumbnail != null ? thumbnail.hashCode() : 0); + result = 31 * result + (edge != null ? edge.hashCode() : 0); + result = 31 * result + (spaceId != null ? spaceId.hashCode() : 0); + result = 31 * result + (spaceName != null ? spaceName.hashCode() : 0); + result = 31 * result + (channelCount != null ? channelCount.hashCode() : 0); + result = 31 * result + (createTime != null ? createTime.hashCode() : 0); + result = 31 * result + (deviceMode != null ? deviceMode.hashCode() : 0); + result = 31 * result + (snCode != null ? snCode.hashCode() : 0); + result = 31 * result + (gis != null ? gis.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceGetResponse{" + + "deviceId=" + deviceId + + ", deviceName='" + deviceName + '\'' + + ", type='" + type + '\'' + + ", deviceStreamId='" + deviceStreamId + '\'' + + ", status='" + status + '\'' + + ", description='" + description + '\'' + + ", upstreamAuth=" + upstreamAuth + + ", downstreamAuth=" + downstreamAuth + + ", domains=" + domains + + ", recording=" + recording + + ", thumbnail=" + thumbnail + + ", edge=" + edge + + ", spaceId=" + spaceId + + ", spaceName='" + spaceName + '\'' + + ", channelCount=" + channelCount + + ", createTime=" + createTime + + ", gis=" + gis + + ", snCode='" + snCode + '\'' + + ", deviceMode='" + deviceMode + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceGis.java b/src/main/java/com/baidubce/services/evs/model/DeviceGis.java new file mode 100644 index 00000000..9b977fb6 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceGis.java @@ -0,0 +1,75 @@ +package com.baidubce.services.evs.model; + +import java.io.Serializable; + +public class DeviceGis implements Serializable { + + private static final long serialVersionUID = -3388008028758290839L; + + private float longitude; + + private float latitude; + + private String name; + + public float getLongitude() { + return longitude; + } + + public void setLongitude(float longitude) { + this.longitude = longitude; + } + + public float getLatitude() { + return latitude; + } + + public void setLatitude(float latitude) { + this.latitude = latitude; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceGis deviceGis = (DeviceGis) o; + + if (Float.compare(deviceGis.longitude, longitude) != 0) { + return false; + } + if (Float.compare(deviceGis.latitude, latitude) != 0) { + return false; + } + return name != null ? name.equals(deviceGis.name) : deviceGis.name == null; + } + + @Override + public int hashCode() { + int result = (longitude != +0.0f ? Float.floatToIntBits(longitude) : 0); + result = 31 * result + (latitude != +0.0f ? Float.floatToIntBits(latitude) : 0); + result = 31 * result + (name != null ? name.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceGis{" + + "longitude=" + longitude + + ", latitude=" + latitude + + ", name='" + name + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceListMarkRequest.java b/src/main/java/com/baidubce/services/evs/model/DeviceListMarkRequest.java new file mode 100644 index 00000000..a5b7d2c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceListMarkRequest.java @@ -0,0 +1,108 @@ +package com.baidubce.services.evs.model; + +public class DeviceListMarkRequest extends EvsBaseRequest { + + private static final long serialVersionUID = 1462348539574354040L; + + private Long spaceId; + + private Long marker; + + private int maxSize; + + private String deviceName; + + /** + * Support: + * Rtmp:ONLINE、RUNNING、OFFLINE + * GB28181:UNREGISTERED、ONLINE、OFFLINE + */ + private String status; + + public Long getSpaceId() { + return spaceId; + } + + public void setSpaceId(Long spaceId) { + this.spaceId = spaceId; + } + + public Long getMarker() { + return marker; + } + + public void setMarker(Long marker) { + this.marker = marker; + } + + public int getMaxSize() { + return maxSize; + } + + public void setMaxSize(int maxSize) { + this.maxSize = maxSize; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceListMarkRequest request = (DeviceListMarkRequest) o; + + if (maxSize != request.maxSize) { + return false; + } + if (spaceId != null ? !spaceId.equals(request.spaceId) : request.spaceId != null) { + return false; + } + if (marker != null ? !marker.equals(request.marker) : request.marker != null) { + return false; + } + if (deviceName != null ? !deviceName.equals(request.deviceName) : request.deviceName != null) { + return false; + } + return status != null ? status.equals(request.status) : request.status == null; + } + + @Override + public int hashCode() { + int result = spaceId != null ? spaceId.hashCode() : 0; + result = 31 * result + (marker != null ? marker.hashCode() : 0); + result = 31 * result + maxSize; + result = 31 * result + (deviceName != null ? deviceName.hashCode() : 0); + result = 31 * result + (status != null ? status.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceListMarkRequest{" + + "spaceId=" + spaceId + + ", marker=" + marker + + ", maxSize=" + maxSize + + ", deviceName='" + deviceName + '\'' + + ", status=" + status + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceListResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceListResponse.java new file mode 100644 index 00000000..fa470d10 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceListResponse.java @@ -0,0 +1,211 @@ +package com.baidubce.services.evs.model; + +import java.io.Serializable; +import java.util.List; + +public class DeviceListResponse implements Serializable { + + private static final long serialVersionUID = -4521760057472611844L; + + private Long deviceId; + + private String deviceName; + + private String spaceName; + + private String type; + + private String platform; + + private String manufacturer; + + private Integer channelCount; + + private String status; + + private String description; + + private String deviceStreamId; + + private DeviceGis gis; + + private List domainList; + + public DeviceGis getGis() { + return gis; + } + + public void setGis(DeviceGis gis) { + this.gis = gis; + } + + public Long getDeviceId() { + return deviceId; + } + + public void setDeviceId(Long deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getSpaceName() { + return spaceName; + } + + public void setSpaceName(String spaceName) { + this.spaceName = spaceName; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getPlatform() { + return platform; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + + public String getManufacturer() { + return manufacturer; + } + + public void setManufacturer(String manufacturer) { + this.manufacturer = manufacturer; + } + + public Integer getChannelCount() { + return channelCount; + } + + public void setChannelCount(Integer channelCount) { + this.channelCount = channelCount; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDeviceStreamId() { + return deviceStreamId; + } + + public void setDeviceStreamId(String deviceStreamId) { + this.deviceStreamId = deviceStreamId; + } + + public List getDomainList() { + return domainList; + } + + public void setDomainList(List domainList) { + this.domainList = domainList; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceListResponse that = (DeviceListResponse) o; + + if (deviceId != null ? !deviceId.equals(that.deviceId) : that.deviceId != null) { + return false; + } + if (deviceName != null ? !deviceName.equals(that.deviceName) : that.deviceName != null) { + return false; + } + if (spaceName != null ? !spaceName.equals(that.spaceName) : that.spaceName != null) { + return false; + } + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + if (platform != null ? !platform.equals(that.platform) : that.platform != null) { + return false; + } + if (manufacturer != null ? !manufacturer.equals(that.manufacturer) : that.manufacturer != null) { + return false; + } + if (channelCount != null ? !channelCount.equals(that.channelCount) : that.channelCount != null) { + return false; + } + if (status != null ? !status.equals(that.status) : that.status != null) { + return false; + } + if (description != null ? !description.equals(that.description) : that.description != null) { + return false; + } + if (deviceStreamId != null ? !deviceStreamId.equals(that.deviceStreamId) : that.deviceStreamId != null) { + return false; + } + if (gis != null ? !gis.equals(that.gis) : that.gis != null) { + return false; + } + return domainList != null ? domainList.equals(that.domainList) : that.domainList == null; + } + + @Override + public int hashCode() { + int result = deviceId != null ? deviceId.hashCode() : 0; + result = 31 * result + (deviceName != null ? deviceName.hashCode() : 0); + result = 31 * result + (gis != null ? gis.hashCode() : 0); + result = 31 * result + (spaceName != null ? spaceName.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (platform != null ? platform.hashCode() : 0); + result = 31 * result + (manufacturer != null ? manufacturer.hashCode() : 0); + result = 31 * result + (channelCount != null ? channelCount.hashCode() : 0); + result = 31 * result + (status != null ? status.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (deviceStreamId != null ? deviceStreamId.hashCode() : 0); + result = 31 * result + (domainList != null ? domainList.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceListResponse{" + + "deviceId=" + deviceId + + ", deviceName='" + deviceName + '\'' + + ", spaceName='" + spaceName + '\'' + + ", type='" + type + '\'' + + ", platform='" + platform + '\'' + + ", manufacturer='" + manufacturer + '\'' + + ", channelCount=" + channelCount + + ", status='" + status + '\'' + + ", description='" + description + '\'' + + ", deviceStreamId='" + deviceStreamId + '\'' + + ", gis=" + gis + + ", domainList=" + domainList + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceMarkListResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceMarkListResponse.java new file mode 100644 index 00000000..465c97bf --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceMarkListResponse.java @@ -0,0 +1,93 @@ +package com.baidubce.services.evs.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.io.Serializable; +import java.util.Collection; + +public class DeviceMarkListResponse extends AbstractBceResponse implements Serializable { + + private static final long serialVersionUID = -62001972372143996L; + + private Collection data; + + private Boolean isTruncated; + + private String marker; + + private String nextMarker; + + public Collection getData() { + return data; + } + + public void setData(Collection data) { + this.data = data; + } + + public Boolean getTruncated() { + return isTruncated; + } + + public void setTruncated(Boolean truncated) { + isTruncated = truncated; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getNextMarker() { + return nextMarker; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceMarkListResponse that = (DeviceMarkListResponse) o; + + if (data != null ? !data.equals(that.data) : that.data != null) { + return false; + } + if (isTruncated != null ? !isTruncated.equals(that.isTruncated) : that.isTruncated != null) { + return false; + } + if (marker != null ? !marker.equals(that.marker) : that.marker != null) { + return false; + } + return nextMarker != null ? nextMarker.equals(that.nextMarker) : that.nextMarker == null; + } + + @Override + public int hashCode() { + int result = data != null ? data.hashCode() : 0; + result = 31 * result + (isTruncated != null ? isTruncated.hashCode() : 0); + result = 31 * result + (marker != null ? marker.hashCode() : 0); + result = 31 * result + (nextMarker != null ? nextMarker.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceMarkListResponse{" + + "data=" + data + + ", isTruncated=" + isTruncated + + ", marker='" + marker + '\'' + + ", nextMarker='" + nextMarker + '\'' + + "} " + super.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceSignedUrlResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceSignedUrlResponse.java new file mode 100644 index 00000000..0927ec14 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceSignedUrlResponse.java @@ -0,0 +1,42 @@ +package com.baidubce.services.evs.model; + +public class DeviceSignedUrlResponse extends EvsBaseResponse { + + private static final long serialVersionUID = -6701495483373638576L; + + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceSignedUrlResponse that = (DeviceSignedUrlResponse) o; + + return url != null ? url.equals(that.url) : that.url == null; + } + + @Override + public int hashCode() { + return url != null ? url.hashCode() : 0; + } + + @Override + public String toString() { + return "DeviceChannelSignedUrlResponse{" + + "url='" + url + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceStopRequest.java b/src/main/java/com/baidubce/services/evs/model/DeviceStopRequest.java new file mode 100644 index 00000000..716657fd --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceStopRequest.java @@ -0,0 +1,44 @@ +package com.baidubce.services.evs.model; + +import java.util.Date; + +public class DeviceStopRequest extends EvsBaseRequest { + + private static final long serialVersionUID = -1466464559725004366L; + + private Date recoverTime; + + public Date getRecoverTime() { + return recoverTime; + } + + public void setRecoverTime(Date recoverTime) { + this.recoverTime = recoverTime; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceStopRequest that = (DeviceStopRequest) o; + + return recoverTime != null ? recoverTime.equals(that.recoverTime) : that.recoverTime == null; + } + + @Override + public int hashCode() { + return recoverTime != null ? recoverTime.hashCode() : 0; + } + + @Override + public String toString() { + return "ChannelStopRequest{" + + "recoverTime=" + recoverTime + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceTsStoreListRequest.java b/src/main/java/com/baidubce/services/evs/model/DeviceTsStoreListRequest.java new file mode 100644 index 00000000..f3f4e435 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceTsStoreListRequest.java @@ -0,0 +1,103 @@ +package com.baidubce.services.evs.model; + +public class DeviceTsStoreListRequest extends EvsBaseRequest { + + private static final long serialVersionUID = -3736470262643576858L; + + private Long begin; + + private Long end; + + private Integer pageNo; + + private Integer pageSize; + + private String type; + + public Long getBegin() { + return begin; + } + + public void setBegin(Long begin) { + this.begin = begin; + } + + public Long getEnd() { + return end; + } + + public void setEnd(Long end) { + this.end = end; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceTsStoreListRequest that = (DeviceTsStoreListRequest) o; + + if (begin != null ? !begin.equals(that.begin) : that.begin != null) { + return false; + } + if (end != null ? !end.equals(that.end) : that.end != null) { + return false; + } + if (pageNo != null ? !pageNo.equals(that.pageNo) : that.pageNo != null) { + return false; + } + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + return pageSize != null ? pageSize.equals(that.pageSize) : that.pageSize == null; + } + + @Override + public int hashCode() { + int result = begin != null ? begin.hashCode() : 0; + result = 31 * result + (end != null ? end.hashCode() : 0); + result = 31 * result + (pageNo != null ? pageNo.hashCode() : 0); + result = 31 * result + (pageSize != null ? pageSize.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceTsStoreListRequest{" + + "begin=" + begin + + ", end=" + end + + ", pageNo=" + pageNo + + ", pageSize=" + pageSize + + ", type='" + type + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceTsStoreListResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceTsStoreListResponse.java new file mode 100644 index 00000000..26a9230a --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceTsStoreListResponse.java @@ -0,0 +1,137 @@ +package com.baidubce.services.evs.model; + +import java.util.Map; + +public class DeviceTsStoreListResponse extends EvsBaseResponse { + + private static final long serialVersionUID = 7665676333267546255L; + + private String title; + + private String thumbnailUrl; + + private Long from; + + private Double duration; + + private String playUrl; + + private String cropThumbnailUrl; + + private Map aiAnalysisData; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getThumbnailUrl() { + return thumbnailUrl; + } + + public void setThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + } + + public String getPlayUrl() { + return playUrl; + } + + public void setPlayUrl(String playUrl) { + this.playUrl = playUrl; + } + + public String getCropThumbnailUrl() { + return cropThumbnailUrl; + } + + public void setCropThumbnailUrl(String cropThumbnailUrl) { + this.cropThumbnailUrl = cropThumbnailUrl; + } + + public Map getAiAnalysisData() { + return aiAnalysisData; + } + + public void setAiAnalysisData(Map aiAnalysisData) { + this.aiAnalysisData = aiAnalysisData; + } + + public Long getFrom() { + return from; + } + + public void setFrom(Long from) { + this.from = from; + } + + public Double getDuration() { + return duration; + } + + public void setDuration(Double duration) { + this.duration = duration; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceTsStoreListResponse that = (DeviceTsStoreListResponse) o; + + if (title != null ? !title.equals(that.title) : that.title != null) { + return false; + } + if (thumbnailUrl != null ? !thumbnailUrl.equals(that.thumbnailUrl) : that.thumbnailUrl != null) { + return false; + } + if (playUrl != null ? !playUrl.equals(that.playUrl) : that.playUrl != null) { + return false; + } + if (from != null ? !from.equals(that.from) : that.from != null) { + return false; + } + if (duration != null ? !duration.equals(that.duration) : that.duration != null) { + return false; + } + if (cropThumbnailUrl != null ? + !cropThumbnailUrl.equals(that.cropThumbnailUrl) : + that.cropThumbnailUrl != null) { + return false; + } + return aiAnalysisData != null ? aiAnalysisData.equals(that.aiAnalysisData) : that.aiAnalysisData == null; + } + + @Override + public int hashCode() { + int result = title != null ? title.hashCode() : 0; + result = 31 * result + (thumbnailUrl != null ? thumbnailUrl.hashCode() : 0); + result = 31 * result + (playUrl != null ? playUrl.hashCode() : 0); + result = 31 * result + (cropThumbnailUrl != null ? cropThumbnailUrl.hashCode() : 0); + result = 31 * result + (from != null ? from.hashCode() : 0); + result = 31 * result + (duration != null ? duration.hashCode() : 0); + result = 31 * result + (aiAnalysisData != null ? aiAnalysisData.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceTsStoreListResponse{" + + "title='" + title + '\'' + + ", thumbnailUrl='" + thumbnailUrl + '\'' + + ", from=" + from + + ", duration=" + duration + + ", playUrl='" + playUrl + '\'' + + ", cropThumbnailUrl='" + cropThumbnailUrl + '\'' + + ", aiAnalysisData=" + aiAnalysisData + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceTsStorePageListResponse.java b/src/main/java/com/baidubce/services/evs/model/DeviceTsStorePageListResponse.java new file mode 100644 index 00000000..e4ef422c --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceTsStorePageListResponse.java @@ -0,0 +1,93 @@ +package com.baidubce.services.evs.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.io.Serializable; +import java.util.Collection; + +public class DeviceTsStorePageListResponse extends AbstractBceResponse implements Serializable { + + private static final long serialVersionUID = -8737069930166501336L; + + private Collection data; + + private Integer pageNo; + + private Integer pageSize; + + private Long totalCount; + + public Collection getData() { + return data; + } + + public void setData(Collection data) { + this.data = data; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Long getTotalCount() { + return totalCount; + } + + public void setTotalCount(Long totalCount) { + this.totalCount = totalCount; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceTsStorePageListResponse that = (DeviceTsStorePageListResponse) o; + + if (data != null ? !data.equals(that.data) : that.data != null) { + return false; + } + if (pageNo != null ? !pageNo.equals(that.pageNo) : that.pageNo != null) { + return false; + } + if (pageSize != null ? !pageSize.equals(that.pageSize) : that.pageSize != null) { + return false; + } + return totalCount != null ? totalCount.equals(that.totalCount) : that.totalCount == null; + } + + @Override + public int hashCode() { + int result = data != null ? data.hashCode() : 0; + result = 31 * result + (pageNo != null ? pageNo.hashCode() : 0); + result = 31 * result + (pageSize != null ? pageSize.hashCode() : 0); + result = 31 * result + (totalCount != null ? totalCount.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceTsStorePageListResponse{" + + "data=" + data + + ", pageNo=" + pageNo + + ", pageSize=" + pageSize + + ", totalCount=" + totalCount + + "} " + super.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/DeviceUpdateRequest.java b/src/main/java/com/baidubce/services/evs/model/DeviceUpdateRequest.java new file mode 100644 index 00000000..b78c17f5 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DeviceUpdateRequest.java @@ -0,0 +1,120 @@ +package com.baidubce.services.evs.model; + +public class DeviceUpdateRequest extends EvsBaseRequest { + + private static final long serialVersionUID = -7575466388901180279L; + + protected String deviceName; + + protected String description; + + protected DeviceGbConfig gbConfig; + + protected Recording recording; + + protected Thumbnail thumbnail; + + protected DeviceGis gis; + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public DeviceGbConfig getGbConfig() { + return gbConfig; + } + + public void setGbConfig(DeviceGbConfig gbConfig) { + this.gbConfig = gbConfig; + } + + public Recording getRecording() { + return recording; + } + + public void setRecording(Recording recording) { + this.recording = recording; + } + + public Thumbnail getThumbnail() { + return thumbnail; + } + + public void setThumbnail(Thumbnail thumbnail) { + this.thumbnail = thumbnail; + } + + public DeviceGis getGis() { + return gis; + } + + public void setGis(DeviceGis gis) { + this.gis = gis; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DeviceUpdateRequest request = (DeviceUpdateRequest) o; + + if (deviceName != null ? !deviceName.equals(request.deviceName) : request.deviceName != null) { + return false; + } + if (description != null ? !description.equals(request.description) : request.description != null) { + return false; + } + if (gbConfig != null ? !gbConfig.equals(request.gbConfig) : request.gbConfig != null) { + return false; + } + if (recording != null ? !recording.equals(request.recording) : request.recording != null) { + return false; + } + if (thumbnail != null ? !thumbnail.equals(request.thumbnail) : request.thumbnail != null) { + return false; + } + return gis != null ? gis.equals(request.gis) : request.gis == null; + } + + @Override + public int hashCode() { + int result = deviceName != null ? deviceName.hashCode() : 0; + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (gbConfig != null ? gbConfig.hashCode() : 0); + result = 31 * result + (recording != null ? recording.hashCode() : 0); + result = 31 * result + (thumbnail != null ? thumbnail.hashCode() : 0); + result = 31 * result + (gis != null ? gis.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DeviceUpdateRequest{" + + "deviceName='" + deviceName + '\'' + + ", description='" + description + '\'' + + ", gbConfig=" + gbConfig + + ", recording=" + recording + + ", thumbnail=" + thumbnail + + ", gis=" + gis + + "} " + super.toString(); + } + + +} diff --git a/src/main/java/com/baidubce/services/evs/model/DomainCreateRequest.java b/src/main/java/com/baidubce/services/evs/model/DomainCreateRequest.java new file mode 100644 index 00000000..95dad93f --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DomainCreateRequest.java @@ -0,0 +1,70 @@ +package com.baidubce.services.evs.model; + +public class DomainCreateRequest extends EvsBaseRequest { + + private static final long serialVersionUID = 8757426093543848248L; + + private String domain; + + /** + * Support: UPSTREAM、DOWNSTREAM + * GB28181 space without push river basin name + */ + private String type; + + public DomainCreateRequest() { + } + + public DomainCreateRequest(String domain, String type) { + this.domain = domain; + this.type = type; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DomainCreateRequest that = (DomainCreateRequest) o; + + if (domain != null ? !domain.equals(that.domain) : that.domain != null) { + return false; + } + return type != null ? type.equals(that.type) : that.type == null; + } + + @Override + public int hashCode() { + int result = domain != null ? domain.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DomainCreateRequest{" + + "domain='" + domain + '\'' + + ", type=" + type + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DomainGetResponse.java b/src/main/java/com/baidubce/services/evs/model/DomainGetResponse.java new file mode 100644 index 00000000..074931c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DomainGetResponse.java @@ -0,0 +1,76 @@ +package com.baidubce.services.evs.model; + +public class DomainGetResponse extends EvsBaseResponse { + + private static final long serialVersionUID = -1340325038447674555L; + + private String domain; + + /** + * Support:UPSTREAM、DOWNSTREAM + */ + private String type; + + private String cname; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCname() { + return cname; + } + + public void setCname(String cname) { + this.cname = cname; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DomainGetResponse that = (DomainGetResponse) o; + + if (domain != null ? !domain.equals(that.domain) : that.domain != null) { + return false; + } + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + return cname != null ? cname.equals(that.cname) : that.cname == null; + } + + @Override + public int hashCode() { + int result = domain != null ? domain.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (cname != null ? cname.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DomainGetResponse{" + + "domain='" + domain + '\'' + + ", type='" + type + '\'' + + ", cname='" + cname + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/DownstreamAuth.java b/src/main/java/com/baidubce/services/evs/model/DownstreamAuth.java new file mode 100644 index 00000000..d5dada09 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DownstreamAuth.java @@ -0,0 +1,7 @@ +package com.baidubce.services.evs.model; + +public class DownstreamAuth extends EvsAuth { + + private static final long serialVersionUID = -3945731711957204162L; + +} diff --git a/src/main/java/com/baidubce/services/evs/model/DynamicTrafficFrameRequest.java b/src/main/java/com/baidubce/services/evs/model/DynamicTrafficFrameRequest.java new file mode 100644 index 00000000..acac19f2 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/DynamicTrafficFrameRequest.java @@ -0,0 +1,167 @@ +package com.baidubce.services.evs.model; + +import java.io.Serializable; + +public class DynamicTrafficFrameRequest extends EvsBaseRequest { + + private static final long serialVersionUID = 5831599197579690891L; + + private boolean enabled; + + private Configuration configuration; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public Configuration getConfiguration() { + return configuration; + } + + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DynamicTrafficFrameRequest that = (DynamicTrafficFrameRequest) o; + + if (enabled != that.enabled) { + return false; + } + return configuration != null ? configuration.equals(that.configuration) : that.configuration == null; + } + + @Override + public int hashCode() { + int result = (enabled ? 1 : 0); + result = 31 * result + (configuration != null ? configuration.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "DynamicTrafficFrameRequest{" + + "enabled=" + enabled + + ", configuration=" + configuration + + "} " + super.toString(); + } + + public static class Configuration implements Serializable { + + private static final long serialVersionUID = 1164073562024136036L; + + private FrameLocation frameLocation; + + public FrameLocation getFrameLocation() { + return frameLocation; + } + + public void setFrameLocation(FrameLocation frameLocation) { + this.frameLocation = frameLocation; + } + + public static class FrameLocation { + + private Double horizontal; + + private Double vertical; + + private Double width; + + private Double height; + + public Double getHorizontal() { + return horizontal; + } + + public void setHorizontal(Double horizontal) { + this.horizontal = horizontal; + } + + public Double getVertical() { + return vertical; + } + + public void setVertical(Double vertical) { + this.vertical = vertical; + } + + public Double getWidth() { + return width; + } + + public void setWidth(Double width) { + this.width = width; + } + + public Double getHeight() { + return height; + } + + public void setHeight(Double height) { + this.height = height; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + FrameLocation that = (FrameLocation) o; + + if (Double.compare(that.horizontal, horizontal) != 0) { + return false; + } + if (Double.compare(that.vertical, vertical) != 0) { + return false; + } + if (Double.compare(that.width, width) != 0) { + return false; + } + return Double.compare(that.height, height) == 0; + } + + @Override + public int hashCode() { + int result; + long temp; + temp = Double.doubleToLongBits(horizontal); + result = (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(vertical); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(width); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(height); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public String toString() { + return "FrameLocation{" + + "horizontal=" + horizontal + + ", vertical=" + vertical + + ", width=" + width + + ", height=" + height + + '}'; + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/EdgeGetResponse.java b/src/main/java/com/baidubce/services/evs/model/EdgeGetResponse.java new file mode 100644 index 00000000..f9069951 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/EdgeGetResponse.java @@ -0,0 +1,208 @@ +package com.baidubce.services.evs.model; + +public class EdgeGetResponse extends EvsBaseResponse { + + private static final long serialVersionUID = 7277118689017561738L; + + private Long edgeId; + + private String region; + + private String city; + + private String serviceProvider; + + private String edgeName; + + private String sipId; + + private String sipIp; + + private Integer sipPort; + + private String sipProtocol; + + private String sipRealm; + + private String ftpIp; + + private Integer ftpPort; + + public Long getEdgeId() { + return edgeId; + } + + public void setEdgeId(Long edgeId) { + this.edgeId = edgeId; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getServiceProvider() { + return serviceProvider; + } + + public void setServiceProvider(String serviceProvider) { + this.serviceProvider = serviceProvider; + } + + public String getEdgeName() { + return edgeName; + } + + public void setEdgeName(String edgeName) { + this.edgeName = edgeName; + } + + public String getSipId() { + return sipId; + } + + public void setSipId(String sipId) { + this.sipId = sipId; + } + + public String getSipIp() { + return sipIp; + } + + public void setSipIp(String sipIp) { + this.sipIp = sipIp; + } + + public Integer getSipPort() { + return sipPort; + } + + public void setSipPort(Integer sipPort) { + this.sipPort = sipPort; + } + + public String getSipProtocol() { + return sipProtocol; + } + + public void setSipProtocol(String sipProtocol) { + this.sipProtocol = sipProtocol; + } + + public String getSipRealm() { + return sipRealm; + } + + public void setSipRealm(String sipRealm) { + this.sipRealm = sipRealm; + } + + public String getFtpIp() { + return ftpIp; + } + + public void setFtpIp(String ftpIp) { + this.ftpIp = ftpIp; + } + + public Integer getFtpPort() { + return ftpPort; + } + + public void setFtpPort(Integer ftpPort) { + this.ftpPort = ftpPort; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + EdgeGetResponse that = (EdgeGetResponse) o; + + if (edgeId != null ? !edgeId.equals(that.edgeId) : that.edgeId != null) { + return false; + } + if (region != null ? !region.equals(that.region) : that.region != null) { + return false; + } + if (city != null ? !city.equals(that.city) : that.city != null) { + return false; + } + if (serviceProvider != null ? !serviceProvider.equals(that.serviceProvider) : that.serviceProvider != null) { + return false; + } + if (edgeName != null ? !edgeName.equals(that.edgeName) : that.edgeName != null) { + return false; + } + if (sipId != null ? !sipId.equals(that.sipId) : that.sipId != null) { + return false; + } + if (sipIp != null ? !sipIp.equals(that.sipIp) : that.sipIp != null) { + return false; + } + if (sipPort != null ? !sipPort.equals(that.sipPort) : that.sipPort != null) { + return false; + } + if (sipProtocol != null ? !sipProtocol.equals(that.sipProtocol) : that.sipProtocol != null) { + return false; + } + if (sipRealm != null ? !sipRealm.equals(that.sipRealm) : that.sipRealm != null) { + return false; + } + if (ftpIp != null ? !ftpIp.equals(that.ftpIp) : that.ftpIp != null) { + return false; + } + return ftpPort != null ? ftpPort.equals(that.ftpPort) : that.ftpPort == null; + } + + @Override + public int hashCode() { + int result = edgeId != null ? edgeId.hashCode() : 0; + result = 31 * result + (region != null ? region.hashCode() : 0); + result = 31 * result + (city != null ? city.hashCode() : 0); + result = 31 * result + (serviceProvider != null ? serviceProvider.hashCode() : 0); + result = 31 * result + (edgeName != null ? edgeName.hashCode() : 0); + result = 31 * result + (sipId != null ? sipId.hashCode() : 0); + result = 31 * result + (sipIp != null ? sipIp.hashCode() : 0); + result = 31 * result + (sipPort != null ? sipPort.hashCode() : 0); + result = 31 * result + (sipProtocol != null ? sipProtocol.hashCode() : 0); + result = 31 * result + (sipRealm != null ? sipRealm.hashCode() : 0); + result = 31 * result + (ftpIp != null ? ftpIp.hashCode() : 0); + result = 31 * result + (ftpPort != null ? ftpPort.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "EdgeGetResponse{" + + "edgeId=" + edgeId + + ", region='" + region + '\'' + + ", city='" + city + '\'' + + ", serviceProvider='" + serviceProvider + '\'' + + ", edgeName='" + edgeName + '\'' + + ", sipId='" + sipId + '\'' + + ", sipIp='" + sipIp + '\'' + + ", sipPort=" + sipPort + + ", sipProtocol='" + sipProtocol + '\'' + + ", sipRealm='" + sipRealm + '\'' + + ", ftpIp='" + ftpIp + '\'' + + ", ftpPort=" + ftpPort + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/EvsAuth.java b/src/main/java/com/baidubce/services/evs/model/EvsAuth.java new file mode 100644 index 00000000..06e06f2f --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/EvsAuth.java @@ -0,0 +1,75 @@ +package com.baidubce.services.evs.model; + +import java.io.Serializable; + +public class EvsAuth extends SameAsSpace implements Serializable { + + private static final long serialVersionUID = -2716207059185435020L; + + private boolean enabled; + + private String key; + + private int expire; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public int getExpire() { + return expire; + } + + public void setExpire(int expire) { + this.expire = expire; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + EvsAuth that = (EvsAuth) o; + + if (enabled != that.enabled) { + return false; + } + if (expire != that.expire) { + return false; + } + return key != null ? key.equals(that.key) : that.key == null; + } + + @Override + public int hashCode() { + int result = (enabled ? 1 : 0); + result = 31 * result + (key != null ? key.hashCode() : 0); + result = 31 * result + expire; + return result; + } + + @Override + public String toString() { + return "EvsAuthRequest{" + + "enabled=" + enabled + + ", key='" + key + '\'' + + ", expire=" + expire + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/EvsBaseRequest.java b/src/main/java/com/baidubce/services/evs/model/EvsBaseRequest.java new file mode 100644 index 00000000..ee0d30ca --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/EvsBaseRequest.java @@ -0,0 +1,17 @@ +package com.baidubce.services.evs.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.io.Serializable; + +public class EvsBaseRequest extends AbstractBceRequest implements Serializable { + + private static final long serialVersionUID = -7831667901482061296L; + + public EvsBaseRequest withRequestCredentials(BceCredentials credentials) { + setRequestCredentials(credentials); + return this; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/EvsBaseResponse.java b/src/main/java/com/baidubce/services/evs/model/EvsBaseResponse.java new file mode 100644 index 00000000..8a6260c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/EvsBaseResponse.java @@ -0,0 +1,9 @@ +package com.baidubce.services.evs.model; + +import com.baidubce.model.AbstractBceResponse; + +public class EvsBaseResponse extends AbstractBceResponse { + + private static final long serialVersionUID = 7445813447031472029L; + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/GBConfigDownloadResponse.java b/src/main/java/com/baidubce/services/evs/model/GBConfigDownloadResponse.java new file mode 100644 index 00000000..64946f38 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/GBConfigDownloadResponse.java @@ -0,0 +1,169 @@ +package com.baidubce.services.evs.model; + +public class GBConfigDownloadResponse extends EvsBaseResponse { + + private static final long serialVersionUID = 3903454530970957047L; + + private String serverIp; + + private Integer serverPort; + + private String sipType; + + private String streamType; + + private Integer configHeartbeatInterval; + + private Integer configRegisterExpire; + + private Integer configHeartbeatCount; + + private Long registerTime; + + private Long aliveTime; + + public String getServerIp() { + return serverIp; + } + + public void setServerIp(String serverIp) { + this.serverIp = serverIp; + } + + public Integer getServerPort() { + return serverPort; + } + + public void setServerPort(Integer serverPort) { + this.serverPort = serverPort; + } + + public String getSipType() { + return sipType; + } + + public void setSipType(String sipType) { + this.sipType = sipType; + } + + public String getStreamType() { + return streamType; + } + + public void setStreamType(String streamType) { + this.streamType = streamType; + } + + public Integer getConfigHeartbeatInterval() { + return configHeartbeatInterval; + } + + public void setConfigHeartbeatInterval(Integer configHeartbeatInterval) { + this.configHeartbeatInterval = configHeartbeatInterval; + } + + public Integer getConfigRegisterExpire() { + return configRegisterExpire; + } + + public void setConfigRegisterExpire(Integer configRegisterExpire) { + this.configRegisterExpire = configRegisterExpire; + } + + public Integer getConfigHeartbeatCount() { + return configHeartbeatCount; + } + + public void setConfigHeartbeatCount(Integer configHeartbeatCount) { + this.configHeartbeatCount = configHeartbeatCount; + } + + public Long getRegisterTime() { + return registerTime; + } + + public void setRegisterTime(Long registerTime) { + this.registerTime = registerTime; + } + + public Long getAliveTime() { + return aliveTime; + } + + public void setAliveTime(Long aliveTime) { + this.aliveTime = aliveTime; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + GBConfigDownloadResponse that = (GBConfigDownloadResponse) o; + + if (serverIp != null ? !serverIp.equals(that.serverIp) : that.serverIp != null) { + return false; + } + if (serverPort != null ? !serverPort.equals(that.serverPort) : that.serverPort != null) { + return false; + } + if (sipType != null ? !sipType.equals(that.sipType) : that.sipType != null) { + return false; + } + if (streamType != null ? !streamType.equals(that.streamType) : that.streamType != null) { + return false; + } + if (configHeartbeatInterval != null ? + !configHeartbeatInterval.equals(that.configHeartbeatInterval) + : that.configHeartbeatInterval != null) { + return false; + } + if (configRegisterExpire != null ? + !configRegisterExpire.equals(that.configRegisterExpire) : + that.configRegisterExpire != null) { + return false; + } + if (configHeartbeatCount != null ? + !configHeartbeatCount.equals(that.configHeartbeatCount) : + that.configHeartbeatCount != null) { + return false; + } + if (registerTime != null ? !registerTime.equals(that.registerTime) : that.registerTime != null) { + return false; + } + return aliveTime != null ? aliveTime.equals(that.aliveTime) : that.aliveTime == null; + } + + @Override + public int hashCode() { + int result = serverIp != null ? serverIp.hashCode() : 0; + result = 31 * result + (serverPort != null ? serverPort.hashCode() : 0); + result = 31 * result + (sipType != null ? sipType.hashCode() : 0); + result = 31 * result + (streamType != null ? streamType.hashCode() : 0); + result = 31 * result + (configHeartbeatInterval != null ? configHeartbeatInterval.hashCode() : 0); + result = 31 * result + (configRegisterExpire != null ? configRegisterExpire.hashCode() : 0); + result = 31 * result + (configHeartbeatCount != null ? configHeartbeatCount.hashCode() : 0); + result = 31 * result + (registerTime != null ? registerTime.hashCode() : 0); + result = 31 * result + (aliveTime != null ? aliveTime.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "GBConfigDownloadResponse{" + + "serverIp='" + serverIp + '\'' + + ", serverPort=" + serverPort + + ", sipType='" + sipType + '\'' + + ", streamType='" + streamType + '\'' + + ", configHeartbeatInterval=" + configHeartbeatInterval + + ", configRegisterExpire=" + configRegisterExpire + + ", configHeartbeatCount=" + configHeartbeatCount + + ", registerTime=" + registerTime + + ", aliveTime=" + aliveTime + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/GBDevicePasswordRequest.java b/src/main/java/com/baidubce/services/evs/model/GBDevicePasswordRequest.java new file mode 100644 index 00000000..7799990e --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/GBDevicePasswordRequest.java @@ -0,0 +1,42 @@ +package com.baidubce.services.evs.model; + +public class GBDevicePasswordRequest extends EvsBaseRequest { + + private static final long serialVersionUID = -1411396149854367205L; + + private String password; + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + GBDevicePasswordRequest that = (GBDevicePasswordRequest) o; + + return password != null ? password.equals(that.password) : that.password == null; + } + + @Override + public int hashCode() { + return password != null ? password.hashCode() : 0; + } + + @Override + public String toString() { + return "GBDevicePasswordRequest{" + + "password='" + password + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/GbPresetAddRequest.java b/src/main/java/com/baidubce/services/evs/model/GbPresetAddRequest.java new file mode 100644 index 00000000..cf383275 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/GbPresetAddRequest.java @@ -0,0 +1,42 @@ +package com.baidubce.services.evs.model; + +public class GbPresetAddRequest extends EvsBaseRequest { + + private static final long serialVersionUID = 1958582712147318940L; + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + GbPresetAddRequest that = (GbPresetAddRequest) o; + + return name != null ? name.equals(that.name) : that.name == null; + } + + @Override + public int hashCode() { + return name != null ? name.hashCode() : 0; + } + + @Override + public String toString() { + return "GbPresetAddRequest{" + + "name='" + name + '\'' + + "} " + super.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/GbPresetAddResponse.java b/src/main/java/com/baidubce/services/evs/model/GbPresetAddResponse.java new file mode 100644 index 00000000..e7c56971 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/GbPresetAddResponse.java @@ -0,0 +1,42 @@ +package com.baidubce.services.evs.model; + +public class GbPresetAddResponse extends EvsBaseResponse { + + private static final long serialVersionUID = -3014110735179084080L; + + private Integer presetId; + + public Integer getPresetId() { + return presetId; + } + + public void setPresetId(Integer presetId) { + this.presetId = presetId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + GbPresetAddResponse that = (GbPresetAddResponse) o; + + return presetId != null ? presetId.equals(that.presetId) : that.presetId == null; + } + + @Override + public int hashCode() { + return presetId != null ? presetId.hashCode() : 0; + } + + @Override + public String toString() { + return "GbPresetAddResponse{" + + "presetId=" + presetId + + "} " + super.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/GbPresetGetResponse.java b/src/main/java/com/baidubce/services/evs/model/GbPresetGetResponse.java new file mode 100644 index 00000000..119e0202 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/GbPresetGetResponse.java @@ -0,0 +1,74 @@ +package com.baidubce.services.evs.model; + +public class GbPresetGetResponse extends EvsBaseResponse { + + private static final long serialVersionUID = -617473319695278892L; + + private Integer presetId; + + private String presetName; + + private String status; + + public Integer getPresetId() { + return presetId; + } + + public void setPresetId(Integer presetId) { + this.presetId = presetId; + } + + public String getPresetName() { + return presetName; + } + + public void setPresetName(String presetName) { + this.presetName = presetName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + GbPresetGetResponse that = (GbPresetGetResponse) o; + + if (presetId != null ? !presetId.equals(that.presetId) : that.presetId != null) { + return false; + } + if (presetName != null ? !presetName.equals(that.presetName) : that.presetName != null) { + return false; + } + return status != null ? status.equals(that.status) : that.status == null; + } + + @Override + public int hashCode() { + int result = presetId != null ? presetId.hashCode() : 0; + result = 31 * result + (presetName != null ? presetName.hashCode() : 0); + result = 31 * result + (status != null ? status.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "GbPresetGetResponse{" + + "presetId=" + presetId + + ", presetName='" + presetName + '\'' + + ", status='" + status + '\'' + + "} " + super.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/GbPresetListResponse.java b/src/main/java/com/baidubce/services/evs/model/GbPresetListResponse.java new file mode 100644 index 00000000..83c8ab1d --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/GbPresetListResponse.java @@ -0,0 +1,40 @@ +package com.baidubce.services.evs.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.io.Serializable; +import java.util.Collection; + +public class GbPresetListResponse extends AbstractBceResponse implements Serializable { + + private static final long serialVersionUID = 4170331210179491182L; + + private Collection data; + + public Collection getData() { + return data; + } + + public void setData(Collection data) { + this.data = data; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + GbPresetListResponse that = (GbPresetListResponse) o; + + return data != null ? data.equals(that.data) : that.data == null; + } + + @Override + public int hashCode() { + return data != null ? data.hashCode() : 0; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/Recording.java b/src/main/java/com/baidubce/services/evs/model/Recording.java new file mode 100644 index 00000000..33a22fb2 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/Recording.java @@ -0,0 +1,111 @@ +package com.baidubce.services.evs.model; + +public class Recording extends SameAsSpace { + + private static final long serialVersionUID = -7058120858705117101L; + + private boolean enabled; + + private int duration; + + /** + * Support: MP4、FLV、M3U8 + */ + private String format; + + private boolean authEnabled; + + private int authExpire; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public boolean isAuthEnabled() { + return authEnabled; + } + + public void setAuthEnabled(boolean authEnabled) { + this.authEnabled = authEnabled; + } + + public int getAuthExpire() { + return authExpire; + } + + public void setAuthExpire(int authExpire) { + this.authExpire = authExpire; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + Recording recording = (Recording) o; + + if (enabled != recording.enabled) { + return false; + } + if (duration != recording.duration) { + return false; + } + if (authEnabled != recording.authEnabled) { + return false; + } + if (authExpire != recording.authExpire) { + return false; + } + return format != null ? format.equals(recording.format) : recording.format == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (enabled ? 1 : 0); + result = 31 * result + duration; + result = 31 * result + (format != null ? format.hashCode() : 0); + result = 31 * result + (authEnabled ? 1 : 0); + result = 31 * result + authExpire; + return result; + } + + @Override + public String toString() { + return "Recording{" + + "enabled=" + enabled + + ", duration=" + duration + + ", format=" + format + + ", authEnabled=" + authEnabled + + ", authExpire=" + authExpire + + "} " + super.toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/evs/model/SameAsSpace.java b/src/main/java/com/baidubce/services/evs/model/SameAsSpace.java new file mode 100644 index 00000000..58322541 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/SameAsSpace.java @@ -0,0 +1,47 @@ +package com.baidubce.services.evs.model; + +import java.io.Serializable; + +/** + * Use of device,Space not need + */ +public class SameAsSpace implements Serializable { + + private static final long serialVersionUID = 5832450552028344214L; + + private boolean sameAsSpace; + + public boolean isSameAsSpace() { + return sameAsSpace; + } + + public void setSameAsSpace(boolean sameAsSpace) { + this.sameAsSpace = sameAsSpace; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SameAsSpace that = (SameAsSpace) o; + + return sameAsSpace == that.sameAsSpace; + } + + @Override + public int hashCode() { + return (sameAsSpace ? 1 : 0); + } + + @Override + public String toString() { + return "SameAsSpace{" + + "sameAsSpace=" + sameAsSpace + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/SpaceCreateRequest.java b/src/main/java/com/baidubce/services/evs/model/SpaceCreateRequest.java new file mode 100644 index 00000000..61b12c42 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/SpaceCreateRequest.java @@ -0,0 +1,116 @@ +package com.baidubce.services.evs.model; + +import java.util.List; + +public class SpaceCreateRequest extends SpaceUpdateRequest { + + private static final long serialVersionUID = -3008218172463593110L; + + /** + * Support: RTMP、GB28181、BVCP + */ + private String type; + + // bvcp空间设备型号 + private String deviceMode = ""; + + private List domains; + + private Long edgeId; + + /** + * Support: BANDWIDTH、TRAFFIC + */ + private String evsChargeType = "TRAFFIC"; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List getDomains() { + return domains; + } + + public void setDomains(List domains) { + this.domains = domains; + } + + public Long getEdgeId() { + return edgeId; + } + + public void setEdgeId(Long edgeId) { + this.edgeId = edgeId; + } + + public String getDeviceMode() { + return deviceMode; + } + + public void setDeviceMode(String deviceMode) { + this.deviceMode = deviceMode; + } + + public String getEvsChargeType() { + return evsChargeType; + } + + public void setEvsChargeType(String evsChargeType) { + this.evsChargeType = evsChargeType; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + SpaceCreateRequest that = (SpaceCreateRequest) o; + + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + if (domains != null ? !domains.equals(that.domains) : that.domains != null) { + return false; + } + if (edgeId != null ? !edgeId.equals(that.edgeId) : that.edgeId != null) { + return false; + } + if (deviceMode != null ? !deviceMode.equals(that.deviceMode) : that.deviceMode != null) { + return false; + } + return evsChargeType != null ? evsChargeType.equals(that.evsChargeType) : that.evsChargeType == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (domains != null ? domains.hashCode() : 0); + result = 31 * result + (edgeId != null ? edgeId.hashCode() : 0); + result = 31 * result + (deviceMode != null ? deviceMode.hashCode() : 0); + result = 31 * result + (evsChargeType != null ? evsChargeType.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SpaceCreateRequest{" + + "type='" + type + '\'' + + ", deviceMode='" + deviceMode + '\'' + + ", domains=" + domains + + ", edgeId=" + edgeId + + ", evsChargeType='" + evsChargeType + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/SpaceCreateResponse.java b/src/main/java/com/baidubce/services/evs/model/SpaceCreateResponse.java new file mode 100644 index 00000000..312d1f7c --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/SpaceCreateResponse.java @@ -0,0 +1,61 @@ +package com.baidubce.services.evs.model; + +import java.util.List; + +public class SpaceCreateResponse extends EvsBaseResponse { + + private static final long serialVersionUID = -2344397488911277215L; + + private Long spaceId; + + private List domains; + + public Long getSpaceId() { + return spaceId; + } + + public void setSpaceId(Long spaceId) { + this.spaceId = spaceId; + } + + public List getDomains() { + return domains; + } + + public void setDomains(List domains) { + this.domains = domains; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SpaceCreateResponse that = (SpaceCreateResponse) o; + + if (spaceId != null ? !spaceId.equals(that.spaceId) : that.spaceId != null) { + return false; + } + return domains != null ? domains.equals(that.domains) : that.domains == null; + } + + @Override + public int hashCode() { + int result = spaceId != null ? spaceId.hashCode() : 0; + result = 31 * result + (domains != null ? domains.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SpaceCreateResponse{" + + "spaceId=" + spaceId + + ", domains=" + domains + + '}'; + } +} + diff --git a/src/main/java/com/baidubce/services/evs/model/SpaceGbProperties.java b/src/main/java/com/baidubce/services/evs/model/SpaceGbProperties.java new file mode 100644 index 00000000..05d63147 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/SpaceGbProperties.java @@ -0,0 +1,42 @@ +package com.baidubce.services.evs.model; + +public class SpaceGbProperties extends DeviceGbProperties { + + private static final long serialVersionUID = -6564985872992248270L; + + private boolean inviteImmediate; + + public boolean isInviteImmediate() { + return inviteImmediate; + } + + public void setInviteImmediate(boolean inviteImmediate) { + this.inviteImmediate = inviteImmediate; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SpaceGbProperties that = (SpaceGbProperties) o; + + return inviteImmediate == that.inviteImmediate; + } + + @Override + public int hashCode() { + return (inviteImmediate ? 1 : 0); + } + + @Override + public String toString() { + return "GbPropertiesRequest{" + + "inviteImmediate=" + inviteImmediate + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/SpaceGetResponse.java b/src/main/java/com/baidubce/services/evs/model/SpaceGetResponse.java new file mode 100644 index 00000000..b92f683c --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/SpaceGetResponse.java @@ -0,0 +1,261 @@ +package com.baidubce.services.evs.model; + +import java.util.Date; +import java.util.List; + +public class SpaceGetResponse extends EvsBaseResponse { + + private static final long serialVersionUID = -40346532593807291L; + + private Long spaceId; + + private String spaceName; + + private String description; + + private String type; + + private String status; + + private List domains; + + private Recording recording; + + private Thumbnail thumbnail; + + private TimeShift timeShift; + + private CallbackGetResponse callback; + + private SpaceGbProperties gbProperties; + + private EdgeGetResponse edge; + + private String serialId; + + private Integer deviceCount; + + private Date createTime; + + private String rtcAppId; + + public Long getSpaceId() { + return spaceId; + } + + public void setSpaceId(Long spaceId) { + this.spaceId = spaceId; + } + + public String getSpaceName() { + return spaceName; + } + + public void setSpaceName(String spaceName) { + this.spaceName = spaceName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getDomains() { + return domains; + } + + public void setDomains(List domains) { + this.domains = domains; + } + + public Recording getRecording() { + return recording; + } + + public void setRecording(Recording recording) { + this.recording = recording; + } + + public Thumbnail getThumbnail() { + return thumbnail; + } + + public void setThumbnail(Thumbnail thumbnail) { + this.thumbnail = thumbnail; + } + + public TimeShift getTimeShift() { + return timeShift; + } + + public void setTimeShift(TimeShift timeShift) { + this.timeShift = timeShift; + } + + public CallbackGetResponse getCallback() { + return callback; + } + + public void setCallback(CallbackGetResponse callback) { + this.callback = callback; + } + + public SpaceGbProperties getGbProperties() { + return gbProperties; + } + + public void setGbProperties(SpaceGbProperties gbProperties) { + this.gbProperties = gbProperties; + } + + public EdgeGetResponse getEdge() { + return edge; + } + + public void setEdge(EdgeGetResponse edge) { + this.edge = edge; + } + + public String getSerialId() { + return serialId; + } + + public void setSerialId(String serialId) { + this.serialId = serialId; + } + + public Integer getDeviceCount() { + return deviceCount; + } + + public void setDeviceCount(Integer deviceCount) { + this.deviceCount = deviceCount; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getRtcAppId() { + return rtcAppId; + } + + public void setRtcAppId(String rtcAppId) { + this.rtcAppId = rtcAppId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SpaceGetResponse response = (SpaceGetResponse) o; + + if (spaceId != null ? !spaceId.equals(response.spaceId) : response.spaceId != null) { + return false; + } + if (spaceName != null ? !spaceName.equals(response.spaceName) : response.spaceName != null) { + return false; + } + if (description != null ? !description.equals(response.description) : response.description != null) { + return false; + } + if (type != response.type) { + return false; + } + if (status != response.status) { + return false; + } + if (domains != null ? !domains.equals(response.domains) : response.domains != null) { + return false; + } + if (recording != null ? !recording.equals(response.recording) : response.recording != null) { + return false; + } + if (thumbnail != null ? !thumbnail.equals(response.thumbnail) : response.thumbnail != null) { + return false; + } + if (timeShift != null ? !timeShift.equals(response.timeShift) : response.timeShift != null) { + return false; + } + if (callback != null ? !callback.equals(response.callback) : response.callback != null) { + return false; + } + if (gbProperties != null ? !gbProperties.equals(response.gbProperties) : response.gbProperties != null) { + return false; + } + if (edge != null ? !edge.equals(response.edge) : response.edge != null) { + return false; + } + if (deviceCount != null ? !deviceCount.equals(response.deviceCount) : response.deviceCount != null) { + return false; + } + return createTime != null ? createTime.equals(response.createTime) : response.createTime == null; + } + + @Override + public int hashCode() { + int result = spaceId != null ? spaceId.hashCode() : 0; + result = 31 * result + (spaceName != null ? spaceName.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (status != null ? status.hashCode() : 0); + result = 31 * result + (domains != null ? domains.hashCode() : 0); + result = 31 * result + (recording != null ? recording.hashCode() : 0); + result = 31 * result + (thumbnail != null ? thumbnail.hashCode() : 0); + result = 31 * result + (timeShift != null ? timeShift.hashCode() : 0); + result = 31 * result + (callback != null ? callback.hashCode() : 0); + result = 31 * result + (gbProperties != null ? gbProperties.hashCode() : 0); + result = 31 * result + (edge != null ? edge.hashCode() : 0); + result = 31 * result + (deviceCount != null ? deviceCount.hashCode() : 0); + result = 31 * result + (createTime != null ? createTime.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SpaceGetResponse{" + + "spaceId=" + spaceId + + ", spaceName='" + spaceName + '\'' + + ", description='" + description + '\'' + + ", type=" + type + + ", status=" + status + + ", domains=" + domains + + ", recording=" + recording + + ", thumbnail=" + thumbnail + + ", timeShift=" + timeShift + + ", callback=" + callback + + ", gbProperties=" + gbProperties + + ", edge=" + edge + + ", deviceCount=" + deviceCount + + ", createTime=" + createTime + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/SpaceListMarkRequest.java b/src/main/java/com/baidubce/services/evs/model/SpaceListMarkRequest.java new file mode 100644 index 00000000..197d9a5f --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/SpaceListMarkRequest.java @@ -0,0 +1,106 @@ +package com.baidubce.services.evs.model; + +public class SpaceListMarkRequest extends EvsBaseRequest { + + private static final long serialVersionUID = -7205390311831772716L; + + private Long marker; + + private int maxSize; + + private String spaceName; + + /** + * Support:OPERATING、RUNNING、STOPPED + */ + private String status; + + private String type; + + public Long getMarker() { + return marker; + } + + public void setMarker(Long marker) { + this.marker = marker; + } + + public int getMaxSize() { + return maxSize; + } + + public void setMaxSize(int maxSize) { + this.maxSize = maxSize; + } + + public String getSpaceName() { + return spaceName; + } + + public void setSpaceName(String spaceName) { + this.spaceName = spaceName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SpaceListMarkRequest that = (SpaceListMarkRequest) o; + + if (maxSize != that.maxSize) { + return false; + } + if (marker != null ? !marker.equals(that.marker) : that.marker != null) { + return false; + } + if (spaceName != null ? !spaceName.equals(that.spaceName) : that.spaceName != null) { + return false; + } + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + return status != null ? status.equals(that.status) : that.status == null; + } + + @Override + public int hashCode() { + int result = marker != null ? marker.hashCode() : 0; + result = 31 * result + maxSize; + result = 31 * result + (spaceName != null ? spaceName.hashCode() : 0); + result = 31 * result + (status != null ? status.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SpaceListMarkRequest{" + + "marker=" + marker + + ", maxSize=" + maxSize + + ", spaceName='" + spaceName + '\'' + + ", status='" + status + '\'' + + ", type='" + type + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/SpaceListResponse.java b/src/main/java/com/baidubce/services/evs/model/SpaceListResponse.java new file mode 100644 index 00000000..c2d8bc57 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/SpaceListResponse.java @@ -0,0 +1,163 @@ +package com.baidubce.services.evs.model; + +public class SpaceListResponse extends EvsBaseResponse { + + private static final long serialVersionUID = -5018672399868262333L; + + private Long spaceId; + + private String spaceName; + + private String type; + + private String status; + + private String deviceMode; + + private String description; + + private Integer deviceCount; + + private Long edgeId; + + private String edgeName; + + public String getDeviceMode() { + return deviceMode; + } + + public void setDeviceMode(String deviceMode) { + this.deviceMode = deviceMode; + } + + public Long getSpaceId() { + return spaceId; + } + + public void setSpaceId(Long spaceId) { + this.spaceId = spaceId; + } + + public String getSpaceName() { + return spaceName; + } + + public void setSpaceName(String spaceName) { + this.spaceName = spaceName; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Integer getDeviceCount() { + return deviceCount; + } + + public void setDeviceCount(Integer deviceCount) { + this.deviceCount = deviceCount; + } + + public Long getEdgeId() { + return edgeId; + } + + public void setEdgeId(Long edgeId) { + this.edgeId = edgeId; + } + + public String getEdgeName() { + return edgeName; + } + + public void setEdgeName(String edgeName) { + this.edgeName = edgeName; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SpaceListResponse that = (SpaceListResponse) o; + + if (spaceId != null ? !spaceId.equals(that.spaceId) : that.spaceId != null) { + return false; + } + if (spaceName != null ? !spaceName.equals(that.spaceName) : that.spaceName != null) { + return false; + } + if (type != null ? !type.equals(that.type) : that.type != null) { + return false; + } + if (deviceMode != null ? !deviceMode.equals(that.deviceMode) : that.deviceMode != null) { + return false; + } + if (status != null ? !status.equals(that.status) : that.status != null) { + return false; + } + if (description != null ? !description.equals(that.description) : that.description != null) { + return false; + } + if (deviceCount != null ? !deviceCount.equals(that.deviceCount) : that.deviceCount != null) { + return false; + } + if (edgeId != null ? !edgeId.equals(that.edgeId) : that.edgeId != null) { + return false; + } + return edgeName != null ? edgeName.equals(that.edgeName) : that.edgeName == null; + } + + @Override + public int hashCode() { + int result = spaceId != null ? spaceId.hashCode() : 0; + result = 31 * result + (spaceName != null ? spaceName.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (deviceMode != null ? deviceMode.hashCode() : 0); + result = 31 * result + (status != null ? status.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (deviceCount != null ? deviceCount.hashCode() : 0); + result = 31 * result + (edgeId != null ? edgeId.hashCode() : 0); + result = 31 * result + (edgeName != null ? edgeName.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SpaceListResponse{" + + "spaceId=" + spaceId + + ", spaceName='" + spaceName + '\'' + + ", type='" + type + '\'' + + ", status='" + status + '\'' + + ", deviceMode='" + deviceMode + '\'' + + ", description='" + description + '\'' + + ", deviceCount=" + deviceCount + + ", edgeId=" + edgeId + + ", edgeName='" + edgeName + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/SpaceMarkListResponse.java b/src/main/java/com/baidubce/services/evs/model/SpaceMarkListResponse.java new file mode 100644 index 00000000..b53c6d3b --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/SpaceMarkListResponse.java @@ -0,0 +1,93 @@ +package com.baidubce.services.evs.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.io.Serializable; +import java.util.Collection; + +public class SpaceMarkListResponse extends AbstractBceResponse implements Serializable { + + private static final long serialVersionUID = -62001972372143996L; + + private Collection data; + + private Boolean isTruncated; + + private String marker; + + private String nextMarker; + + public Collection getData() { + return data; + } + + public void setData(Collection data) { + this.data = data; + } + + public Boolean getTruncated() { + return isTruncated; + } + + public void setTruncated(Boolean truncated) { + isTruncated = truncated; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getNextMarker() { + return nextMarker; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SpaceMarkListResponse that = (SpaceMarkListResponse) o; + + if (data != null ? !data.equals(that.data) : that.data != null) { + return false; + } + if (isTruncated != null ? !isTruncated.equals(that.isTruncated) : that.isTruncated != null) { + return false; + } + if (marker != null ? !marker.equals(that.marker) : that.marker != null) { + return false; + } + return nextMarker != null ? nextMarker.equals(that.nextMarker) : that.nextMarker == null; + } + + @Override + public int hashCode() { + int result = data != null ? data.hashCode() : 0; + result = 31 * result + (isTruncated != null ? isTruncated.hashCode() : 0); + result = 31 * result + (marker != null ? marker.hashCode() : 0); + result = 31 * result + (nextMarker != null ? nextMarker.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SpaceMarkListResponse{" + + "data=" + data + + ", isTruncated=" + isTruncated + + ", marker='" + marker + '\'' + + ", nextMarker='" + nextMarker + '\'' + + "} " + super.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/evs/model/SpaceUpdateRequest.java b/src/main/java/com/baidubce/services/evs/model/SpaceUpdateRequest.java new file mode 100644 index 00000000..f35aa4c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/SpaceUpdateRequest.java @@ -0,0 +1,173 @@ +package com.baidubce.services.evs.model; + +public class SpaceUpdateRequest extends EvsBaseRequest { + + private static final long serialVersionUID = -1113013505386652759L; + + protected String spaceName; + + protected String description; + + protected UpstreamAuth upstreamAuth; + + protected DownstreamAuth downstreamAuth; + + protected Recording recording; + + protected Thumbnail thumbnail; + + protected TimeShift timeShift; + + protected CallbackUpdateRequest callback; + + protected SpaceGbProperties gbProperties; + + protected AiConfigRequest aiConfig; + + public String getSpaceName() { + return spaceName; + } + + public void setSpaceName(String spaceName) { + this.spaceName = spaceName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Recording getRecording() { + return recording; + } + + public void setRecording(Recording recording) { + this.recording = recording; + } + + public Thumbnail getThumbnail() { + return thumbnail; + } + + public void setThumbnail(Thumbnail thumbnail) { + this.thumbnail = thumbnail; + } + + public TimeShift getTimeShift() { + return timeShift; + } + + public void setTimeShift(TimeShift timeShift) { + this.timeShift = timeShift; + } + + public CallbackUpdateRequest getCallback() { + return callback; + } + + public void setCallback(CallbackUpdateRequest callback) { + this.callback = callback; + } + + public AiConfigRequest getAiConfig() { + return aiConfig; + } + + public void setAiConfig(AiConfigRequest aiConfig) { + this.aiConfig = aiConfig; + } + + public UpstreamAuth getUpstreamAuth() { + return upstreamAuth; + } + + public void setUpstreamAuth(UpstreamAuth upstreamAuth) { + this.upstreamAuth = upstreamAuth; + } + + public DownstreamAuth getDownstreamAuth() { + return downstreamAuth; + } + + public void setDownstreamAuth(DownstreamAuth downstreamAuth) { + this.downstreamAuth = downstreamAuth; + } + + public SpaceGbProperties getGbProperties() { + return gbProperties; + } + + public void setGbProperties(SpaceGbProperties gbProperties) { + this.gbProperties = gbProperties; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SpaceUpdateRequest request = (SpaceUpdateRequest) o; + + if (spaceName != null ? !spaceName.equals(request.spaceName) : request.spaceName != null) { + return false; + } + if (description != null ? !description.equals(request.description) : request.description != null) { + return false; + } + if (upstreamAuth != null ? !upstreamAuth.equals(request.upstreamAuth) : request.upstreamAuth != null) { + return false; + } + if (downstreamAuth != null ? !downstreamAuth.equals(request.downstreamAuth) : request.downstreamAuth != null) { + return false; + } + if (recording != null ? !recording.equals(request.recording) : request.recording != null) { + return false; + } + if (thumbnail != null ? !thumbnail.equals(request.thumbnail) : request.thumbnail != null) { + return false; + } + if (timeShift != null ? !timeShift.equals(request.timeShift) : request.timeShift != null) { + return false; + } + if (callback != null ? !callback.equals(request.callback) : request.callback != null) { + return false; + } + return aiConfig != null ? aiConfig.equals(request.aiConfig) : request.aiConfig == null; + } + + @Override + public int hashCode() { + int result = spaceName != null ? spaceName.hashCode() : 0; + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (upstreamAuth != null ? upstreamAuth.hashCode() : 0); + result = 31 * result + (downstreamAuth != null ? downstreamAuth.hashCode() : 0); + result = 31 * result + (recording != null ? recording.hashCode() : 0); + result = 31 * result + (thumbnail != null ? thumbnail.hashCode() : 0); + result = 31 * result + (timeShift != null ? timeShift.hashCode() : 0); + result = 31 * result + (callback != null ? callback.hashCode() : 0); + result = 31 * result + (aiConfig != null ? aiConfig.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SpaceUpdateRequest{" + + "spaceName='" + spaceName + '\'' + + ", description='" + description + '\'' + + ", upstreamAuth=" + upstreamAuth + + ", downstreamAuth=" + downstreamAuth + + ", recording=" + recording + + ", thumbnail=" + thumbnail + + ", timeShift=" + timeShift + + ", callback=" + callback + + ", aiConfig=" + aiConfig + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/Thumbnail.java b/src/main/java/com/baidubce/services/evs/model/Thumbnail.java new file mode 100644 index 00000000..4f265bb9 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/Thumbnail.java @@ -0,0 +1,92 @@ +package com.baidubce.services.evs.model; + +public class Thumbnail extends SameAsSpace { + + private static final long serialVersionUID = -5678090094416783791L; + + private boolean enabled; + + private int interval; + + private boolean authEnabled; + + private int authExpire; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public int getInterval() { + return interval; + } + + public void setInterval(int interval) { + this.interval = interval; + } + + public boolean isAuthEnabled() { + return authEnabled; + } + + public void setAuthEnabled(boolean authEnabled) { + this.authEnabled = authEnabled; + } + + public int getAuthExpire() { + return authExpire; + } + + public void setAuthExpire(int authExpire) { + this.authExpire = authExpire; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + Thumbnail thumbnail = (Thumbnail) o; + + if (enabled != thumbnail.enabled) { + return false; + } + if (interval != thumbnail.interval) { + return false; + } + if (authEnabled != thumbnail.authEnabled) { + return false; + } + return authExpire == thumbnail.authExpire; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (enabled ? 1 : 0); + result = 31 * result + interval; + result = 31 * result + (authEnabled ? 1 : 0); + result = 31 * result + authExpire; + return result; + } + + @Override + public String toString() { + return "Thumbnail{" + + "enabled=" + enabled + + ", interval=" + interval + + ", authEnabled=" + authEnabled + + ", authExpire=" + authExpire + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/TimeShift.java b/src/main/java/com/baidubce/services/evs/model/TimeShift.java new file mode 100644 index 00000000..bbaf5da5 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/TimeShift.java @@ -0,0 +1,62 @@ +package com.baidubce.services.evs.model; + +public class TimeShift extends SameAsSpace { + + private static final long serialVersionUID = -6097367406311037557L; + + private boolean enabled; + + private Integer range; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public Integer getRange() { + return range; + } + + public void setRange(Integer range) { + this.range = range; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + TimeShift timeShift = (TimeShift) o; + + if (enabled != timeShift.enabled) { + return false; + } + return range != null ? range.equals(timeShift.range) : timeShift.range == null; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (enabled ? 1 : 0); + result = 31 * result + (range != null ? range.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "TimeShift{" + + "enabled=" + enabled + + ", range=" + range + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/evs/model/UpstreamAuth.java b/src/main/java/com/baidubce/services/evs/model/UpstreamAuth.java new file mode 100644 index 00000000..a9483ba6 --- /dev/null +++ b/src/main/java/com/baidubce/services/evs/model/UpstreamAuth.java @@ -0,0 +1,7 @@ +package com.baidubce.services.evs.model; + +public class UpstreamAuth extends EvsAuth { + + private static final long serialVersionUID = 6940684455406712332L; + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/havip/HaVipClient.java b/src/main/java/com/baidubce/services/havip/HaVipClient.java new file mode 100644 index 00000000..5e5a7e03 --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/HaVipClient.java @@ -0,0 +1,348 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.havip.model.BindEipRequest; +import com.baidubce.services.havip.model.BindInstanceRequest; +import com.baidubce.services.havip.model.CreateHaVipRequest; +import com.baidubce.services.havip.model.CreateHaVipResponse; +import com.baidubce.services.havip.model.DeleteHaVipRequest; +import com.baidubce.services.havip.model.HaVipResponse; +import com.baidubce.services.havip.model.ListHaVipRequest; +import com.baidubce.services.havip.model.ListHaVipResponse; +import com.baidubce.services.havip.model.UnBindEipRequest; +import com.baidubce.services.havip.model.UnBindInstanceRequest; +import com.baidubce.services.havip.model.UpdateHaVipRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.baidubce.util.Validate; +import com.google.common.base.Strings; + +public class HaVipClient extends AbstractBceClient { + + private static final String VERSION = "v1"; + private static final String HAVIP_PREFIX = "havip"; + private static final String CLIENT_TOKEN = "clientToken"; + private static final String MARKER = "marker"; + private static final String MAX_KEYS = "maxKeys"; + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String NAME_MESSAGE_KEY = "name"; + private static final String HA_VIP_ID_MESSAGE_KEY = "haVipId"; + private static final String BIND_INSTANCE_TYPE_MESSAGE_KEY = "instanceType"; + private static final String BIND_PUBLIC_IP_ADDRESS_MESSAGE_KEY = "publicIpAddress"; + + /** + * Responsible for handling httpResponses from all HaVip network service calls. + */ + private static final HttpResponseHandler[] HAVIP_HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on havip. + */ + public HaVipClient() { + this(new HaVipClientConfiguration()); + } + + /** + * Constructs a new HaVip client using the client configuration to access esg. + */ + public HaVipClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, HAVIP_HANDLERS); + } + + /** + * Creates and initializes a new request object for the specified bcc resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * This method is used to create HaVip + * + * @param createHaVipRequest + * @return CreateHaVipResponse + */ + public CreateHaVipResponse createHaVip(CreateHaVipRequest createHaVipRequest) { + checkNotNull(createHaVipRequest, REQUEST_NULL_ERROR_MESSAGE); + if (Strings.isNullOrEmpty(createHaVipRequest.getClientToken())) { + createHaVipRequest.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(createHaVipRequest.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest(createHaVipRequest, HttpMethodName.POST, HAVIP_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN, createHaVipRequest.getClientToken()); + fillPayload(internalRequest, createHaVipRequest); + return invokeHttpClient(internalRequest, CreateHaVipResponse.class); + } + + public ListHaVipResponse listHaVip(String vpcId) { + ListHaVipRequest listHaVipRequest = new ListHaVipRequest(); + listHaVipRequest.setVpcId(vpcId); + return listHaVip(listHaVipRequest); + } + + /** + * This method is used to list your owen HaVips + * + * @param listHaVipRequest + * @return ListHaVipResponse + */ + public ListHaVipResponse listHaVip(ListHaVipRequest listHaVipRequest) { + checkNotNull(listHaVipRequest, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(listHaVipRequest.getVpcId(), "VpcId not allow empty"); + InternalRequest internalRequest = this.createRequest(listHaVipRequest, HttpMethodName.GET, HAVIP_PREFIX); + if (listHaVipRequest.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(listHaVipRequest.getMaxKeys())); + } else if (listHaVipRequest.getMaxKeys() <= 0) { + internalRequest.addParameter(MAX_KEYS, "1000"); + } + internalRequest.addParameter("vpcId", listHaVipRequest.getVpcId()); + + return invokeHttpClient(internalRequest, ListHaVipResponse.class); + } + + /** + * This method is use to get havip detail + * + * @param haVipId + * @return HaVipResponse + */ + public HaVipResponse getHaVip(String haVipId) { + ListHaVipRequest listHaVipRequest = new ListHaVipRequest(); + InternalRequest internalRequest = + this.createRequest(listHaVipRequest, HttpMethodName.GET, HAVIP_PREFIX, haVipId); + return invokeHttpClient(internalRequest, HaVipResponse.class); + } + + /** + * This method is used to update HaVip's name and description + * + * @param updateHaVipRequest + */ + public void updateHaVip(UpdateHaVipRequest updateHaVipRequest) { + Validate.checkNotNull(updateHaVipRequest, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(updateHaVipRequest.getHaVipId(), checkEmptyExceptionMessageFormat(HA_VIP_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(updateHaVipRequest.getClientToken())) { + updateHaVipRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(updateHaVipRequest, HttpMethodName.PUT, HAVIP_PREFIX, + updateHaVipRequest.getHaVipId()); + internalRequest.addParameter(CLIENT_TOKEN, updateHaVipRequest.getClientToken()); + internalRequest.addParameter("modifyAttribute", null); + fillPayload(internalRequest, updateHaVipRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * This method is used to delete specified HaVip + * + * @param request + */ + public void deleteHaVip(DeleteHaVipRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getHaVipId(), checkEmptyExceptionMessageFormat(HA_VIP_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, HAVIP_PREFIX, request.getHaVipId()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * This method is used to delete specified HaVip + * + * @param haVipId + */ + public void deleteHaVip(String haVipId) { + DeleteHaVipRequest deleteHaVipRequest = new DeleteHaVipRequest(); + deleteHaVipRequest.setHaVipId(haVipId); + deleteHaVip(deleteHaVipRequest); + } + + /** + * The method is used to bind instance like bcc/eni.. to HaVip + * + * @param bindInstanceRequest + */ + public void bindInstance(BindInstanceRequest bindInstanceRequest) { + Validate.checkNotNull(bindInstanceRequest, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(bindInstanceRequest.getHaVipId(), checkEmptyExceptionMessageFormat(HA_VIP_ID_MESSAGE_KEY)); + checkStringNotEmpty(bindInstanceRequest.getInstanceType(), + checkEmptyExceptionMessageFormat(BIND_INSTANCE_TYPE_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(bindInstanceRequest.getClientToken())) { + bindInstanceRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = + this.createRequest(bindInstanceRequest, HttpMethodName.PUT, HAVIP_PREFIX, + bindInstanceRequest.getHaVipId()); + internalRequest.addParameter(CLIENT_TOKEN, bindInstanceRequest.getClientToken()); + internalRequest.addParameter("attach", null); + fillPayload(internalRequest, bindInstanceRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * The method is used to unBind instance like bcc/eni.. from HaVip + * + * @param request + */ + public void unBindInstance(UnBindInstanceRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getHaVipId(), checkEmptyExceptionMessageFormat(HA_VIP_ID_MESSAGE_KEY)); + checkStringNotEmpty(request.getInstanceType(), + checkEmptyExceptionMessageFormat(BIND_INSTANCE_TYPE_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, HAVIP_PREFIX, + request.getHaVipId()); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + internalRequest.addParameter("detach", null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * The method is used to bind eip to HaVip + * + * @param bindEipRequest + */ + public void bindEip(BindEipRequest bindEipRequest) { + Validate.checkNotNull(bindEipRequest, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(bindEipRequest.getHaVipId(), checkEmptyExceptionMessageFormat(HA_VIP_ID_MESSAGE_KEY)); + checkStringNotEmpty(bindEipRequest.getPublicIpAddress(), + checkEmptyExceptionMessageFormat(BIND_PUBLIC_IP_ADDRESS_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(bindEipRequest.getClientToken())) { + bindEipRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = + this.createRequest(bindEipRequest, HttpMethodName.PUT, HAVIP_PREFIX, + bindEipRequest.getHaVipId()); + internalRequest.addParameter(CLIENT_TOKEN, bindEipRequest.getClientToken()); + internalRequest.addParameter("bindPublicIp", null); + fillPayload(internalRequest, bindEipRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * The method is used to unBind eip from HaVip + * + * @param unBindEipRequest + */ + public void unBindEip(UnBindEipRequest unBindEipRequest) { + Validate.checkNotNull(unBindEipRequest, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(unBindEipRequest.getHaVipId(), checkEmptyExceptionMessageFormat(HA_VIP_ID_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(unBindEipRequest.getClientToken())) { + unBindEipRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = + this.createRequest(unBindEipRequest, HttpMethodName.PUT, HAVIP_PREFIX, + unBindEipRequest.getHaVipId()); + internalRequest.addParameter(CLIENT_TOKEN, unBindEipRequest.getClientToken()); + internalRequest.addParameter("unbindPublicIp", null); + fillPayload(internalRequest, unBindEipRequest); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } +} diff --git a/src/main/java/com/baidubce/services/havip/HaVipClientConfiguration.java b/src/main/java/com/baidubce/services/havip/HaVipClientConfiguration.java new file mode 100644 index 00000000..e3a3dfb2 --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/HaVipClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.havip; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for Havip service. + */ +public class HaVipClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/havip/model/BindEipRequest.java b/src/main/java/com/baidubce/services/havip/model/BindEipRequest.java new file mode 100644 index 00000000..cc8cdad6 --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/BindEipRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class BindEipRequest extends AbstractBceRequest { + private String haVipId; + /** + * The publicIpAddress is your owen eip's address + */ + private String publicIpAddress; + + @JsonIgnore + private String clientToken; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/BindInstanceRequest.java b/src/main/java/com/baidubce/services/havip/model/BindInstanceRequest.java new file mode 100644 index 00000000..c56fb1cb --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/BindInstanceRequest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class BindInstanceRequest extends AbstractBceRequest { + /** + * The param havipId is you will operate to bind instance + */ + private String haVipId; + /** + * The instanceIds is A list that you will bind to the HaVip + */ + private List instanceIds; + /** + * The instanceType is Type of instance you will bind ,like BCC/BBC/ENI + */ + private String instanceType; + + @JsonIgnore + private String clientToken; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/CreateHaVipRequest.java b/src/main/java/com/baidubce/services/havip/model/CreateHaVipRequest.java new file mode 100644 index 00000000..c5574b0b --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/CreateHaVipRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class CreateHaVipRequest extends AbstractBceRequest { + + /** + * The name of HaVip which will be created. + */ + private String name; + /** + * The subnetId of HaVip will create in + */ + private String subnetId; + private String privateIpAddress; + /** + * The description of HaVip + */ + private String description; + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/CreateHaVipResponse.java b/src/main/java/com/baidubce/services/havip/model/CreateHaVipResponse.java new file mode 100644 index 00000000..e139f24f --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/CreateHaVipResponse.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class CreateHaVipResponse extends AbstractBceResponse { + private String haVipId; +} diff --git a/src/main/java/com/baidubce/services/havip/model/DeleteHaVipRequest.java b/src/main/java/com/baidubce/services/havip/model/DeleteHaVipRequest.java new file mode 100644 index 00000000..ee17be48 --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/DeleteHaVipRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.havip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +/** + * The request for deleting the specified Elastic Network Interface Card. + */ +@Getter +@Setter +public class DeleteHaVipRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * The request will be idempotent if client token is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of HaVip. + */ + private String haVipId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteEniRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/HaVip.java b/src/main/java/com/baidubce/services/havip/model/HaVip.java new file mode 100644 index 00000000..e96279da --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/HaVip.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class HaVip { + private String haVipId; + private String name; + private String description; + private String vpcId; + private String subnetId; + private String status; + private String privateIpAddress; + private String publicIpAddress; + private String createdTime; + + @Override + public String toString() { + return "HaVip{" + + "haVipId='" + haVipId + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", vpcId='" + vpcId + '\'' + + ", subnetId='" + subnetId + '\'' + + ", status='" + status + '\'' + + ", privateIpAddress='" + privateIpAddress + '\'' + + ", publicIpAddress='" + publicIpAddress + '\'' + + ", createdTime='" + createdTime + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/HaVipResponse.java b/src/main/java/com/baidubce/services/havip/model/HaVipResponse.java new file mode 100644 index 00000000..38875aae --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/HaVipResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class HaVipResponse extends AbstractBceResponse { + private String haVipId; + private String name; + private String description; + private String vpcId; + private String subnetId; + private String status; + private String privateIpAddress; + private String publicIpAddress; + private String createdTime; + + @Override + public String toString() { + return "HaVip{" + + "haVipId='" + haVipId + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", vpcId='" + vpcId + '\'' + + ", subnetId='" + subnetId + '\'' + + ", status='" + status + '\'' + + ", privateIpAddress='" + privateIpAddress + '\'' + + ", publicIpAddress='" + publicIpAddress + '\'' + + ", createdTime='" + createdTime + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/ListHaVipRequest.java b/src/main/java/com/baidubce/services/havip/model/ListHaVipRequest.java new file mode 100644 index 00000000..432ec0c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/ListHaVipRequest.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ListHaVipRequest extends ListRequest { + private String vpcId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/ListHaVipResponse.java b/src/main/java/com/baidubce/services/havip/model/ListHaVipResponse.java new file mode 100644 index 00000000..0e158117 --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/ListHaVipResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ListHaVipResponse extends ListResponse { + private List haVips; + + @Override + public String toString() { + return "ListHaVipResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "haVips=" + haVips + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/UnBindEipRequest.java b/src/main/java/com/baidubce/services/havip/model/UnBindEipRequest.java new file mode 100644 index 00000000..d5da026c --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/UnBindEipRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class UnBindEipRequest extends AbstractBceRequest { + private String haVipId; + + @JsonIgnore + private String clientToken; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/UnBindInstanceRequest.java b/src/main/java/com/baidubce/services/havip/model/UnBindInstanceRequest.java new file mode 100644 index 00000000..6a708416 --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/UnBindInstanceRequest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class UnBindInstanceRequest extends AbstractBceRequest { + /** + * The param haVipId is used to unbind instance + */ + private String haVipId; + /** + * The instanceIds is already binded the haVipId,and you want to unbind + */ + private List instanceIds; + /** + * The instance's type ,like BCC/BBC/ENI.. + */ + private String instanceType; + + @JsonIgnore + private String clientToken; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/havip/model/UpdateHaVipRequest.java b/src/main/java/com/baidubce/services/havip/model/UpdateHaVipRequest.java new file mode 100644 index 00000000..62e0f961 --- /dev/null +++ b/src/main/java/com/baidubce/services/havip/model/UpdateHaVipRequest.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.havip.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class UpdateHaVipRequest extends AbstractBceRequest { + private String name; + private String description; + private String haVipId; + @JsonIgnore + private String clientToken; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iam/IamClient.java b/src/main/java/com/baidubce/services/iam/IamClient.java new file mode 100644 index 00000000..fa1e9cf4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/IamClient.java @@ -0,0 +1,766 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam; + +import java.util.Map; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.common.ApiInfo; +import com.baidubce.common.BaseBceClient; +import com.baidubce.common.BaseBceResponse; +import com.baidubce.common.BceRegion; +import com.baidubce.internal.InternalRequest; +import com.baidubce.services.iam.api.IamApi; +import com.baidubce.services.iam.model.CreateAccessKeyResponse; +import com.baidubce.services.iam.model.CreateGroupRequest; +import com.baidubce.services.iam.model.CreateGroupResponse; +import com.baidubce.services.iam.model.CreatePolicyRequest; +import com.baidubce.services.iam.model.CreatePolicyResponse; +import com.baidubce.services.iam.model.CreateRoleRequest; +import com.baidubce.services.iam.model.CreateRoleResponse; +import com.baidubce.services.iam.model.CreateUserRequest; +import com.baidubce.services.iam.model.CreateUserResponse; +import com.baidubce.services.iam.model.CreateVsAccountRequest; +import com.baidubce.services.iam.model.CreateVsAccountResponse; +import com.baidubce.services.iam.model.DisableAccessKeyResponse; +import com.baidubce.services.iam.model.GetGroupResponse; +import com.baidubce.services.iam.model.GetLoginProfileResponse; +import com.baidubce.services.iam.model.GetPolicyResponse; +import com.baidubce.services.iam.model.GetRoleResponse; +import com.baidubce.services.iam.model.GetUserResponse; +import com.baidubce.services.iam.model.GetVsAccountResponse; +import com.baidubce.services.iam.model.ListAccessKeyResponse; +import com.baidubce.services.iam.model.ListGroupResponse; +import com.baidubce.services.iam.model.ListGroupsForUserResponse; +import com.baidubce.services.iam.model.ListPoliciesForGroupResponse; +import com.baidubce.services.iam.model.ListPoliciesForRoleResponse; +import com.baidubce.services.iam.model.ListPoliciesForUserResponse; +import com.baidubce.services.iam.model.ListPolicyResponse; +import com.baidubce.services.iam.model.ListRoleResponse; +import com.baidubce.services.iam.model.ListUserResponse; +import com.baidubce.services.iam.model.ListUsersInGroupResponse; +import com.baidubce.services.iam.model.EnableAccessKeyResponse; +import com.baidubce.services.iam.model.ListVsAccountsRequest; +import com.baidubce.services.iam.model.ListVsAccountsResponse; +import com.baidubce.services.iam.model.UpdateGroupRequest; +import com.baidubce.services.iam.model.UpdateGroupResponse; +import com.baidubce.services.iam.model.UpdateLoginProfileRequest; +import com.baidubce.services.iam.model.UpdateLoginProfileResponse; +import com.baidubce.services.iam.model.UpdateRoleRequest; +import com.baidubce.services.iam.model.UpdateRoleResponse; +import com.baidubce.services.iam.model.UpdateUserRequest; +import com.baidubce.services.iam.model.UpdateUserResponse; +import com.google.common.collect.ImmutableMap; + +/** + * Iam + */ +public class IamClient extends BaseBceClient { + // ------Endpoints------ + // map of all endpoints + private static final Map ENDPOINTS = ImmutableMap.builder() + .put(BceRegion.DEFAULT, "https://iam.bj.baidubce.com") + .build(); + // ------Endpoints------ + + // ------ServiceInfo------ + /** + * Service name for extra config and handler. + */ + private static final String SERVICE_ID = "Iam"; + + /** + * Constructs a new client to invoke service methods on demo with region. + */ + public IamClient(String ak, String sk, BceRegion region) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(region)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public IamClient(String ak, String sk) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(BceRegion.DEFAULT)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public IamClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Api lists + */ + private static final Map IAM_APIS = IamApi.getApis(); + + /** + * AddUserToGroup + * + * @param userName + * @param groupName + */ + public void addUserToGroup(String userName, String groupName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("addUserToGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName) + .withPathParameter("groupName", groupName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * AttachPolicyToGroup + * + * @param groupName + * @param policyName + * @param policyType + */ + public void attachPolicyToGroup(String groupName, String policyName, String policyType) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("attachPolicyToGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("groupName", groupName) + .withPathParameter("policyName", policyName).get(); + apiInfo.getQueries().put("policyType", policyType); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * AttachPolicyToRole + * + * @param roleName + * @param policyName + * @param policyType + */ + public void attachPolicyToRole(String roleName, String policyName, String policyType) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("attachPolicyToRole")); + String apiPath = apiInfo.getPath() + .withPathParameter("roleName", roleName) + .withPathParameter("policyName", policyName).get(); + apiInfo.getQueries().put("policyType", policyType); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * AttachPolicyToUser + * + * @param userName + * @param policyName + * @param policyType + */ + public void attachPolicyToUser(String userName, String policyName, String policyType) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("attachPolicyToUser")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName) + .withPathParameter("policyName", policyName).get(); + apiInfo.getQueries().put("policyType", policyType); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * CreateAccessKey + * + * @param userName + * @return CreateAccessKeyResponse + */ + public CreateAccessKeyResponse createAccessKey(String userName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("createAccessKey")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, CreateAccessKeyResponse.class); + } + + /** + * CreateGroup + * + * @param body + * @return CreateGroupResponse + */ + public CreateGroupResponse createGroup(CreateGroupRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("createGroup")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreateGroupResponse.class); + } + + /** + * CreatePolicy + * + * @param body + * @return CreatePolicyResponse + */ + public CreatePolicyResponse createPolicy(CreatePolicyRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("createPolicy")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreatePolicyResponse.class); + } + + /** + * CreateRole + * + * @param body + * @return CreateRoleResponse + */ + public CreateRoleResponse createRole(CreateRoleRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("createRole")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreateRoleResponse.class); + } + + /** + * CreateUser + * + * @param body + * @return CreateUserResponse + */ + public CreateUserResponse createUser(CreateUserRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("createUser")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreateUserResponse.class); + } + + /** + * DeleteAccessKey + * + * @param userName + * @param accessKeyId + */ + public void deleteAccessKey(String userName, String accessKeyId) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("deleteAccessKey")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName) + .withPathParameter("accessKeyId", accessKeyId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * DeleteGroup + * + * @param groupName + */ + public void deleteGroup(String groupName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("deleteGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("groupName", groupName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * DeleteLoginProfile + * + * @param userName + */ + public void deleteLoginProfile(String userName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("deleteLoginProfile")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * DeletePolicy + * + * @param policyName + */ + public void deletePolicy(String policyName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("deletePolicy")); + String apiPath = apiInfo.getPath() + .withPathParameter("policyName", policyName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * DeleteRole + * + * @param roleName + */ + public void deleteRole(String roleName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("deleteRole")); + String apiPath = apiInfo.getPath() + .withPathParameter("roleName", roleName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * DeleteUser + * + * @param userName + */ + public void deleteUser(String userName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("deleteUser")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * DetachPolicyFromGroup + * + * @param groupName + * @param policyName + * @param policyType + */ + public void detachPolicyFromGroup(String groupName, String policyName, String policyType) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("detachPolicyFromGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("groupName", groupName) + .withPathParameter("policyName", policyName).get(); + apiInfo.getQueries().put("policyType", policyType); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * DetachPolicyFromRole + * + * @param roleName + * @param policyName + * @param policyType + */ + public void detachPolicyFromRole(String roleName, String policyName, String policyType) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("detachPolicyFromRole")); + String apiPath = apiInfo.getPath() + .withPathParameter("roleName", roleName) + .withPathParameter("policyName", policyName).get(); + apiInfo.getQueries().put("policyType", policyType); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * DetachPolicyFromUser + * + * @param userName + * @param policyName + * @param policyType + */ + public void detachPolicyFromUser(String userName, String policyName, String policyType) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("detachPolicyFromUser")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName) + .withPathParameter("policyName", policyName).get(); + apiInfo.getQueries().put("policyType", policyType); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + /** + * DisableAccessKey + * + * @param userName + * @param accessKeyId + */ + public DisableAccessKeyResponse disableAccessKey(String userName, String accessKeyId) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("disableAccessKey")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName) + .withPathParameter("accessKeyId", accessKeyId).get(); + apiInfo.getQueries().put("disable", null); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, DisableAccessKeyResponse.class); + } + + /** + * EnableAccessKey + * + * @param userName + * @param accessKeyId + */ + public EnableAccessKeyResponse enableAccessKey(String userName, String accessKeyId) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("updateAccessKeyEnable")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName) + .withPathParameter("accessKeyId", accessKeyId).get(); + apiInfo.getQueries().put("enable", null); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, EnableAccessKeyResponse.class); + } + + /** + * GetGroup + * + * @param groupName + * @return GetGroupResponse + */ + public GetGroupResponse getGroup(String groupName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("getGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("groupName", groupName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetGroupResponse.class); + } + + /** + * GetLoginProfile + * + * @param userName + * @return GetLoginProfileResponse + */ + public GetLoginProfileResponse getLoginProfile(String userName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("getLoginProfile")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetLoginProfileResponse.class); + } + + /** + * GetPolicy + * + * @param policyName + * @param policyType + * @return GetPolicyResponse + */ + public GetPolicyResponse getPolicy(String policyName, String policyType) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("getPolicy")); + String apiPath = apiInfo.getPath() + .withPathParameter("policyName", policyName).get(); + apiInfo.getQueries().put("policyType", policyType); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetPolicyResponse.class); + } + + /** + * GetRole + * + * @param roleName + * @return GetRoleResponse + */ + public GetRoleResponse getRole(String roleName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("getRole")); + String apiPath = apiInfo.getPath() + .withPathParameter("roleName", roleName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetRoleResponse.class); + } + + /** + * GetUser + * + * @param userName + * @return GetUserResponse + */ + public GetUserResponse getUser(String userName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("getUser")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetUserResponse.class); + } + + /** + * ListAccessKey + * + * @param userName + * @return ListAccessKeyResponse + */ + public ListAccessKeyResponse listAccessKey(String userName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listAccessKey")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListAccessKeyResponse.class); + } + + /** + * ListGroup + * + * @return ListGroupResponse + */ + public ListGroupResponse listGroup() { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listGroup")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListGroupResponse.class); + } + + /** + * ListGroupsForUser + * + * @param userName + * @return ListGroupsForUserResponse + */ + public ListGroupsForUserResponse listGroupsForUser(String userName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listGroupsForUser")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListGroupsForUserResponse.class); + } + + /** + * ListPoliciesForGroup + * + * @param groupName + * @return ListPoliciesForGroupResponse + */ + public ListPoliciesForGroupResponse listPoliciesForGroup(String groupName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listPoliciesForGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("groupName", groupName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListPoliciesForGroupResponse.class); + } + + /** + * ListPoliciesForRole + * + * @param roleName + * @return ListPoliciesForRoleResponse + */ + public ListPoliciesForRoleResponse listPoliciesForRole(String roleName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listPoliciesForRole")); + String apiPath = apiInfo.getPath() + .withPathParameter("roleName", roleName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListPoliciesForRoleResponse.class); + } + + /** + * ListPoliciesForUser + * + * @param userName + * @return ListPoliciesForUserResponse + */ + public ListPoliciesForUserResponse listPoliciesForUser(String userName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listPoliciesForUser")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListPoliciesForUserResponse.class); + } + + /** + * ListPolicy + * + * @return ListPolicyResponse + */ + public ListPolicyResponse listPolicy(String policyType) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listPolicy")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("policyType", policyType); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListPolicyResponse.class); + } + + /** + * ListRole + * + * @return ListRoleResponse + */ + public ListRoleResponse listRole() { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listRole")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListRoleResponse.class); + } + + /** + * ListUser + * + * @return ListUserResponse + */ + public ListUserResponse listUser() { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listUser")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListUserResponse.class); + } + + /** + * ListUsersInGroup + * + * @param groupName + * @return ListUsersInGroupResponse + */ + public ListUsersInGroupResponse listUsersInGroup(String groupName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listUsersInGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("groupName", groupName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListUsersInGroupResponse.class); + } + + /** + * RemoveUserFromGroup + * + * @param userName + * @param groupName + */ + public void removeUserFromGroup(String userName, String groupName) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("removeUserFromGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName) + .withPathParameter("groupName", groupName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + + /** + * updateGroup + * + * @param groupName + * @param body + * @return UpdateLoginProfileResponse + */ + public UpdateGroupResponse updateGroup(String groupName, UpdateGroupRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("updateGroup")); + String apiPath = apiInfo.getPath() + .withPathParameter("groupName", groupName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, UpdateGroupResponse.class); + } + + /** + * UpdateLoginProfile + * + * @param userName + * @param body + * @return UpdateLoginProfileResponse + */ + public UpdateLoginProfileResponse updateLoginProfile(String userName, UpdateLoginProfileRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("updateLoginProfile")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, UpdateLoginProfileResponse.class); + } + + /** + * UpdateRole + * + * @param roleName + * @param body + * @return UpdateRoleResponse + */ + public UpdateRoleResponse updateRole(String roleName, UpdateRoleRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("updateRole")); + String apiPath = apiInfo.getPath() + .withPathParameter("roleName", roleName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, UpdateRoleResponse.class); + } + + /** + * UpdateUser + * + * @param userName + * @param body + * @return UpdateUserResponse + */ + public UpdateUserResponse updateUser(String userName, UpdateUserRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("updateUser")); + String apiPath = apiInfo.getPath() + .withPathParameter("userName", userName).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, UpdateUserResponse.class); + } + + /** + * CreateVirtualStoreAccount + * + * @param body + * @return + */ + public CreateVsAccountResponse createVsAccount(CreateVsAccountRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("createVsAccount")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreateVsAccountResponse.class); + } + + /** + * GetVirtualStoreAccount + * + * @param userId + * @return + */ + public GetVsAccountResponse getVsAccount(String userId) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("getVsAccount")); + String apiPath = apiInfo.getPath().withPathParameter("userId", userId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetVsAccountResponse.class); + } + + /** + * list Virtual store account + * + * @param body + * @return + */ + public ListVsAccountsResponse listVsAccounts(ListVsAccountsRequest body) { + ApiInfo apiInfo = new ApiInfo(IAM_APIS.get("listVsAccount")); + String apiPath = apiInfo.getPath().get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, ListVsAccountsResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/iam/api/IamApi.java b/src/main/java/com/baidubce/services/iam/api/IamApi.java new file mode 100644 index 00000000..08a5a8f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/api/IamApi.java @@ -0,0 +1,328 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.api; + +import java.util.HashMap; +import java.util.Map; + +import com.baidubce.common.ApiInfo; +import com.baidubce.common.ApiPath; +import com.baidubce.http.HttpMethodName; + +/** + * Iam api + */ +public class IamApi { + /** + * Api list with api name + */ + private static Map APIS = new HashMap(); + + public static Map getApis() { + // AddUserToGroup + APIS.put("addUserToGroup", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/group/[groupName]/user/[userName]"), + new HashMap(), + new HashMap())); + // AttachPolicyToGroup + APIS.put("attachPolicyToGroup", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/group/[groupName]/policy/[policyName]"), + new HashMap(), + new HashMap() { + { + put("policyType", null); + } + })); + // AttachPolicyToRole + APIS.put("attachPolicyToRole", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/role/[roleName]/policy/[policyName]"), + new HashMap(), + new HashMap() { + { + put("policyType", null); + } + })); + // AttachPolicyToUser + APIS.put("attachPolicyToUser", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/user/[userName]/policy/[policyName]"), + new HashMap(), + new HashMap() { + { + put("policyType", null); + } + })); + // CreateAccessKey + APIS.put("createAccessKey", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/user/[userName]/accesskey"), + new HashMap(), + new HashMap())); + // CreateGroup + APIS.put("createGroup", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/group"), + new HashMap(), + new HashMap())); + // CreatePolicy + APIS.put("createPolicy", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/policy"), + new HashMap(), + new HashMap())); + // CreateRole + APIS.put("createRole", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/role"), + new HashMap(), + new HashMap())); + // CreateUser + APIS.put("createUser", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/user"), + new HashMap(), + new HashMap())); + // DeleteAccessKey + APIS.put("deleteAccessKey", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/user/[userName]/accesskey/[accessKeyId]"), + new HashMap(), + new HashMap())); + // DeleteGroup + APIS.put("deleteGroup", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/group/[groupName]"), + new HashMap(), + new HashMap())); + // DeleteLoginProfile + APIS.put("deleteLoginProfile", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/user/[userName]/loginProfile"), + new HashMap(), + new HashMap())); + // DeletePolicy + APIS.put("deletePolicy", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/policy/[policyName]"), + new HashMap(), + new HashMap())); + // DeleteRole + APIS.put("deleteRole", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/role/[roleName]"), + new HashMap(), + new HashMap())); + // DeleteUser + APIS.put("deleteUser", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/user/[userName]"), + new HashMap(), + new HashMap())); + // DetachPolicyFromGroup + APIS.put("detachPolicyFromGroup", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/group/[groupName]/policy/[policyName]"), + new HashMap(), + new HashMap() { + { + put("policyType", null); + } + })); + // DetachPolicyFromRole + APIS.put("detachPolicyFromRole", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/role/[roleName]/policy/[policyName]"), + new HashMap(), + new HashMap() { + { + put("policyType", null); + } + })); + // DetachPolicyFromUser + APIS.put("detachPolicyFromUser", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/user/[userName]/policy/[policyName]"), + new HashMap(), + new HashMap() { + { + put("policyType", null); + } + })); + // DisableAccessKey + APIS.put("disableAccessKey", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/user/[userName]/accesskey/[accessKeyId]"), + new HashMap(), + new HashMap() { + { + put("disable", null); + } + })); + // UpdateAccessKeyEnable + APIS.put("updateAccessKeyEnable", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/user/[userName]/accesskey/[accessKeyId]"), + new HashMap(), + new HashMap() { + { + put("enable", null); + } + })); + // GetGroup + APIS.put("getGroup", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/group/[groupName]"), + new HashMap(), + new HashMap())); + // GetLoginProfile + APIS.put("getLoginProfile", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/user/[userName]/loginProfile"), + new HashMap(), + new HashMap())); + // GetPolicy + APIS.put("getPolicy", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/policy/[policyName]"), + new HashMap(), + new HashMap() { + { + put("policyType", null); + } + })); + // GetRole + APIS.put("getRole", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/role/[roleName]"), + new HashMap(), + new HashMap())); + // GetUser + APIS.put("getUser", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/user/[userName]"), + new HashMap(), + new HashMap())); + // ListAccessKey + APIS.put("listAccessKey", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/user/[userName]/accesskey"), + new HashMap(), + new HashMap())); + // ListGroup + APIS.put("listGroup", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/group"), + new HashMap(), + new HashMap())); + // ListGroupsForUser + APIS.put("listGroupsForUser", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/user/[userName]/group"), + new HashMap(), + new HashMap())); + // ListPoliciesForGroup + APIS.put("listPoliciesForGroup", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/group/[groupName]/policy"), + new HashMap(), + new HashMap())); + // ListPoliciesForRole + APIS.put("listPoliciesForRole", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/role/[roleName]/policy"), + new HashMap(), + new HashMap())); + // ListPoliciesForUser + APIS.put("listPoliciesForUser", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/user/[userName]/policy"), + new HashMap(), + new HashMap())); + // ListPolicy + APIS.put("listPolicy", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/policy"), + new HashMap(), + new HashMap())); + // ListRole + APIS.put("listRole", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/role"), + new HashMap(), + new HashMap())); + // ListUser + APIS.put("listUser", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/user"), + new HashMap(), + new HashMap())); + // ListUsersInGroup + APIS.put("listUsersInGroup", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/group/[groupName]/user"), + new HashMap(), + new HashMap())); + // RemoveUserFromGroup + APIS.put("removeUserFromGroup", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/group/[groupName]/user/[userName]"), + new HashMap(), + new HashMap())); + // UpdateGroup + APIS.put("updateGroup", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/group/[groupName]"), + new HashMap(), + new HashMap())); + // UpdateLoginProfile + APIS.put("updateLoginProfile", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/user/[userName]/loginProfile"), + new HashMap(), + new HashMap())); + // UpdateRole + APIS.put("updateRole", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/role/[roleName]"), + new HashMap(), + new HashMap())); + // UpdateUser + APIS.put("updateUser", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/user/[userName]"), + new HashMap(), + new HashMap())); + // CreateVsAccount + APIS.put("createVsAccount", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/vs/account"), + new HashMap(), + new HashMap())); + // GetVsAccount + APIS.put("getVsAccount", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/vs/account/[userId]"), + new HashMap(), + new HashMap())); + // ListVsAccounts + APIS.put("listVsAccount", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/vs/account/list"), + new HashMap(), + new HashMap())); + return APIS; + } +} diff --git a/src/main/java/com/baidubce/services/iam/model/AccountCancelPreCheckResponse.java b/src/main/java/com/baidubce/services/iam/model/AccountCancelPreCheckResponse.java new file mode 100644 index 00000000..06ab2fff --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/AccountCancelPreCheckResponse.java @@ -0,0 +1,97 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class AccountCancelPreCheckResponse extends BaseBceResponse { + /** + * checkResult + */ + private ModelNull checkResult; + + /** + * checkResultList + */ + private List checkResultList; + + public void setCheckResult(ModelNull checkResult) { + this.checkResult = checkResult; + } + + public ModelNull getCheckResult() { + return this.checkResult; + } + + public void setCheckResultList(List checkResultList) { + this.checkResultList = checkResultList; + } + + public List getCheckResultList() { + return this.checkResultList; + } + + @Override + public String toString() { + return "AccountCancelPreCheckResponse{" + + "checkResult=" + checkResult + "\n" + + "checkResultList=" + checkResultList + "\n" + + "}"; + } + + public static class ModelNull { + private String type; + + private Boolean pass; + + private List reason; + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setPass(Boolean pass) { + this.pass = pass; + } + + public Boolean isPass() { + return this.pass; + } + + public void setReason(List reason) { + this.reason = reason; + } + + public List getReason() { + return this.reason; + } + + @Override + public String toString() { + return "ModelNull{" + + "type=" + type + "\n" + + "pass=" + pass + "\n" + + "reason=" + reason + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/AuthenticationRequest.java b/src/main/java/com/baidubce/services/iam/model/AuthenticationRequest.java new file mode 100644 index 00000000..45de76de --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/AuthenticationRequest.java @@ -0,0 +1,149 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class AuthenticationRequest extends BaseBceRequest { + /** + * auth + */ + private AuthenticationRequestAuth auth; + + public void setAuth(AuthenticationRequestAuth auth) { + this.auth = auth; + } + + public AuthenticationRequestAuth getAuth() { + return this.auth; + } + + @Override + public String toString() { + return "AuthenticationRequest{" + + "auth=" + auth + "\n" + + "}"; + } + + public static class AuthenticationRequestAuth { + private String authorization; + + private String securityToken; + + private SignValidateRequest request; + + public void setAuthorization(String authorization) { + this.authorization = authorization; + } + + public String getAuthorization() { + return this.authorization; + } + + public void setSecurityToken(String securityToken) { + this.securityToken = securityToken; + } + + public String getSecurityToken() { + return this.securityToken; + } + + public void setRequest(SignValidateRequest request) { + this.request = request; + } + + public SignValidateRequest getRequest() { + return this.request; + } + + @Override + public String toString() { + return "AuthenticationRequestAuth{" + + "authorization=" + authorization + "\n" + + "securityToken=" + securityToken + "\n" + + "request=" + request + "\n" + + "}"; + } + + public static class SignValidateRequest { + private String method; + + private String uri; + + private SignValidateRequestParams params; + + private SignValidateRequestHeaders headers; + + public void setMethod(String method) { + this.method = method; + } + + public String getMethod() { + return this.method; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public String getUri() { + return this.uri; + } + + public void setParams(SignValidateRequestParams params) { + this.params = params; + } + + public SignValidateRequestParams getParams() { + return this.params; + } + + public void setHeaders(SignValidateRequestHeaders headers) { + this.headers = headers; + } + + public SignValidateRequestHeaders getHeaders() { + return this.headers; + } + + @Override + public String toString() { + return "SignValidateRequest{" + + "method=" + method + "\n" + + "uri=" + uri + "\n" + + "params=" + params + "\n" + + "headers=" + headers + "\n" + + "}"; + } + + public static class SignValidateRequestParams { + @Override + public String toString() { + return "SignValidateRequestParams{" + + "}"; + } + } + + public static class SignValidateRequestHeaders { + @Override + public String toString() { + return "SignValidateRequestHeaders{" + + "}"; + } + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/AuthenticationResponse.java b/src/main/java/com/baidubce/services/iam/model/AuthenticationResponse.java new file mode 100644 index 00000000..c606a4b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/AuthenticationResponse.java @@ -0,0 +1,125 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class AuthenticationResponse extends BaseBceResponse { + /** + * userId + */ + private String userId; + + /** + * name + */ + private String name; + + /** + * sessionTokenModel + */ + private ModelNull sessionTokenModel; + + /** + * sessionToken + */ + private ModelNull sessionToken; + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserId() { + return this.userId; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setSessionTokenModel(ModelNull sessionTokenModel) { + this.sessionTokenModel = sessionTokenModel; + } + + public ModelNull getSessionTokenModel() { + return this.sessionTokenModel; + } + + public void setSessionToken(ModelNull sessionToken) { + this.sessionToken = sessionToken; + } + + public ModelNull getSessionToken() { + return this.sessionToken; + } + + @Override + public String toString() { + return "AuthenticationResponse{" + + "userId=" + userId + "\n" + + "name=" + name + "\n" + + "sessionTokenModel=" + sessionTokenModel + "\n" + + "sessionToken=" + sessionToken + "\n" + + "}"; + } + + public static class ModelNull { + private String type; + + private Boolean pass; + + private List reason; + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setPass(Boolean pass) { + this.pass = pass; + } + + public Boolean isPass() { + return this.pass; + } + + public void setReason(List reason) { + this.reason = reason; + } + + public List getReason() { + return this.reason; + } + + @Override + public String toString() { + return "ModelNull{" + + "type=" + type + "\n" + + "pass=" + pass + "\n" + + "reason=" + reason + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreateAccessKeyResponse.java b/src/main/java/com/baidubce/services/iam/model/CreateAccessKeyResponse.java new file mode 100644 index 00000000..ff132ad2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreateAccessKeyResponse.java @@ -0,0 +1,98 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class /**/CreateAccessKeyResponse extends BaseBceResponse { + /** + * sk + */ + private String secret; + + /** + * ak + */ + private String id; + + /** + * createTime + */ + private Date createTime; + + /** + * description + */ + private String description; + + /** + * enabled + */ + private Boolean enabled; + + public void setSecret(String secret) { + this.secret = secret; + } + + public String getSecret() { + return this.secret; + } + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return this.enabled; + } + + @Override + public String toString() { + return "CreateAccessKeyResponse{" + + "secret=" + secret + "\n" + + "id=" + id + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "enabled=" + enabled + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreateGroupRequest.java b/src/main/java/com/baidubce/services/iam/model/CreateGroupRequest.java new file mode 100644 index 00000000..a766dc1e --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreateGroupRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateGroupRequest extends BaseBceRequest { + /** + * name + */ + private String name; + + /** + * description + */ + private String description; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "CreateGroupRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreateGroupResponse.java b/src/main/java/com/baidubce/services/iam/model/CreateGroupResponse.java new file mode 100644 index 00000000..f77583fd --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreateGroupResponse.java @@ -0,0 +1,84 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateGroupResponse extends BaseBceResponse { + /** + * id + */ + private String id; + + /** + * name + */ + private String name; + + /** + * createTime + */ + private Date createTime; + + /** + * description + */ + private String description; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "CreateGroupResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreatePolicyRequest.java b/src/main/java/com/baidubce/services/iam/model/CreatePolicyRequest.java new file mode 100644 index 00000000..2828230e --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreatePolicyRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreatePolicyRequest extends BaseBceRequest { + /** + * name + */ + private String name; + + /** + * description + */ + private String description; + + /** + * document + */ + private String document; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setDocument(String document) { + this.document = document; + } + + public String getDocument() { + return this.document; + } + + @Override + public String toString() { + return "CreatePolicyRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "document=" + document + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreatePolicyResponse.java b/src/main/java/com/baidubce/services/iam/model/CreatePolicyResponse.java new file mode 100644 index 00000000..c69f4f2e --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreatePolicyResponse.java @@ -0,0 +1,113 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreatePolicyResponse extends BaseBceResponse { + /** + * id + */ + private String id; + + /** + * name + */ + private String name; + + /** + * type + */ + private String type; + + /** + * createTime + */ + private Date createTime; + + + /** + * description + */ + private String description; + + /** + * document + */ + private String document; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setDocument(String document) { + this.document = document; + } + + public String getDocument() { + return this.document; + } + + @Override + public String toString() { + return "CreatePolicyResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "document=" + document + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreateRoleRequest.java b/src/main/java/com/baidubce/services/iam/model/CreateRoleRequest.java new file mode 100644 index 00000000..3b5fefdf --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreateRoleRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateRoleRequest extends BaseBceRequest { + /** + * name + */ + private String name; + + /** + * description + */ + private String description; + + /** + * assumeRolePolicyDocument + */ + private String assumeRolePolicyDocument; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setAssumeRolePolicyDocument(String assumeRolePolicyDocument) { + this.assumeRolePolicyDocument = assumeRolePolicyDocument; + } + + public String getAssumeRolePolicyDocument() { + return this.assumeRolePolicyDocument; + } + + @Override + public String toString() { + return "CreateRoleRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "assumeRolePolicyDocument=" + assumeRolePolicyDocument + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreateRoleResponse.java b/src/main/java/com/baidubce/services/iam/model/CreateRoleResponse.java new file mode 100644 index 00000000..4e848633 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreateRoleResponse.java @@ -0,0 +1,98 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateRoleResponse extends BaseBceResponse { + /** + * id + */ + private String id; + + /** + * name + */ + private String name; + + /** + * createTime + */ + private Date createTime; + + /** + * description + */ + private String description; + + /** + * assumeRolePolicyDocument + */ + private String assumeRolePolicyDocument; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setAssumeRolePolicyDocument(String assumeRolePolicyDocument) { + this.assumeRolePolicyDocument = assumeRolePolicyDocument; + } + + public String getAssumeRolePolicyDocument() { + return this.assumeRolePolicyDocument; + } + + @Override + public String toString() { + return "CreateRoleResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "assumeRolePolicyDocument=" + assumeRolePolicyDocument + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreateUserRequest.java b/src/main/java/com/baidubce/services/iam/model/CreateUserRequest.java new file mode 100644 index 00000000..31325ca7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreateUserRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateUserRequest extends BaseBceRequest { + /** + * name + */ + private String name; + + /** + * description + */ + private String description; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "CreateUserRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreateUserResponse.java b/src/main/java/com/baidubce/services/iam/model/CreateUserResponse.java new file mode 100644 index 00000000..c0a50830 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreateUserResponse.java @@ -0,0 +1,98 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateUserResponse extends BaseBceResponse { + /** + * 用户身份标识号码 + */ + private String id; + + /** + * 用户名称 + */ + private String name; + + /** + * 描述 + */ + private String description; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 该用户是否有效 + */ + private Boolean enabled; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return this.enabled; + } + + @Override + public String toString() { + return "CreateUserResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "createTime=" + createTime + "\n" + + "enabled=" + enabled + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreateVsAccountRequest.java b/src/main/java/com/baidubce/services/iam/model/CreateVsAccountRequest.java new file mode 100644 index 00000000..1f7f1b07 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreateVsAccountRequest.java @@ -0,0 +1,124 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateVsAccountRequest extends BaseBceRequest { + + /** + * virtual store account id + */ + String accountId; + + /** + * virtual store customer id + */ + String userId; + + /** + * virtual store customer name + */ + String name; + + /** + * virtual store customer email + */ + String email; + + /** + * virtual store customer mobile phone + */ + String mobilePhone; + + /** + * virtual store customer account type + */ + String accountType; + + /** + * virtual store customer company + */ + String company; + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getAccountType() { + return accountType; + } + + public void setAccountType(String accountType) { + this.accountType = accountType; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + @Override + public String toString() { + return "CreateVsAccountRequest{" + + "accountId='" + accountId + '\'' + + ", userId='" + userId + '\'' + + ", name='" + name + '\'' + + ", email='" + email + '\'' + + ", mobilePhone='" + mobilePhone + '\'' + + ", accountType='" + accountType + '\'' + + ", company='" + company + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/CreateVsAccountResponse.java b/src/main/java/com/baidubce/services/iam/model/CreateVsAccountResponse.java new file mode 100644 index 00000000..3f1ad078 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/CreateVsAccountResponse.java @@ -0,0 +1,124 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateVsAccountResponse extends BaseBceResponse { + + /** + * virtual store account id + */ + String accountId; + + /** + * virtual store customer id + */ + String userId; + + /** + * virtual store customer name + */ + String name; + + /** + * virtual store customer email + */ + String email; + + /** + * virtual store customer mobile phone + */ + String mobilePhone; + + /** + * virtual store customer account type + */ + String accountType; + + /** + * virtual store customer company + */ + String company; + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getAccountType() { + return accountType; + } + + public void setAccountType(String accountType) { + this.accountType = accountType; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + @Override + public String toString() { + return "CreateVsAccountResponse{" + + "accountId='" + accountId + '\'' + + ", userId='" + userId + '\'' + + ", name='" + name + '\'' + + ", email='" + email + '\'' + + ", mobilePhone='" + mobilePhone + '\'' + + ", accountType='" + accountType + '\'' + + ", company='" + company + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/DisableAccessKeyResponse.java b/src/main/java/com/baidubce/services/iam/model/DisableAccessKeyResponse.java new file mode 100644 index 00000000..e31c36cf --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/DisableAccessKeyResponse.java @@ -0,0 +1,74 @@ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +/** + * Created by linxiao02 on 2020/6/22 + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class DisableAccessKeyResponse extends BaseBceResponse { + /** + * ak + */ + private String id; + + /** + * createTime + */ + private Date createTime; + + /** + * description + */ + private String description; + + /** + * enabled + */ + private Boolean enabled; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return this.enabled; + } + + @Override + public String toString() { + return "DisableAccessKeyResponse{" + + "id=" + id + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "enabled=" + enabled + "\n" + + "}"; + } +} diff --git a/src/main/java/com/baidubce/services/iam/model/EnableAccessKeyResponse.java b/src/main/java/com/baidubce/services/iam/model/EnableAccessKeyResponse.java new file mode 100644 index 00000000..d69e3213 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/EnableAccessKeyResponse.java @@ -0,0 +1,84 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class EnableAccessKeyResponse extends BaseBceResponse { + /** + * ak + */ + private String id; + + /** + * createTime + */ + private Date createTime; + + /** + * description + */ + private String description; + + /** + * enabled + */ + private Boolean enabled; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return this.enabled; + } + + @Override + public String toString() { + return "EnableAccessKeyResponse{" + + "id=" + id + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "enabled=" + enabled + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/GetGroupResponse.java b/src/main/java/com/baidubce/services/iam/model/GetGroupResponse.java new file mode 100644 index 00000000..4a1591bf --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/GetGroupResponse.java @@ -0,0 +1,84 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetGroupResponse extends BaseBceResponse { + /** + * id + */ + private String id; + + /** + * name + */ + private String name; + + /** + * createTime + */ + private Date createTime; + + /** + * description + */ + private String description; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "GetGroupResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/GetLoginProfileResponse.java b/src/main/java/com/baidubce/services/iam/model/GetLoginProfileResponse.java new file mode 100644 index 00000000..6d1009e5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/GetLoginProfileResponse.java @@ -0,0 +1,110 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetLoginProfileResponse extends BaseBceResponse { + /** + * password + */ + private String password; + + /** + * needResetPassword + */ + private Boolean needResetPassword; + + /** + * enabledLoginMfa + */ + private Boolean enabledLoginMfa; + + /** + * loginMfaType + */ + private String loginMfaType; + + /** + * thirdPartyType + */ + private String thirdPartyType; + + /** + * thirdPartyAccount + */ + private String thirdPartyAccount; + + public void setPassword(String password) { + this.password = password; + } + + public String getPassword() { + return this.password; + } + + public void setNeedResetPassword(Boolean needResetPassword) { + this.needResetPassword = needResetPassword; + } + + public Boolean isNeedResetPassword() { + return this.needResetPassword; + } + + public void setEnabledLoginMfa(Boolean enabledLoginMfa) { + this.enabledLoginMfa = enabledLoginMfa; + } + + public Boolean isEnabledLoginMfa() { + return this.enabledLoginMfa; + } + + public void setLoginMfaType(String loginMfaType) { + this.loginMfaType = loginMfaType; + } + + public String getLoginMfaType() { + return this.loginMfaType; + } + + public void setThirdPartyType(String thirdPartyType) { + this.thirdPartyType = thirdPartyType; + } + + public String getThirdPartyType() { + return this.thirdPartyType; + } + + public void setThirdPartyAccount(String thirdPartyAccount) { + this.thirdPartyAccount = thirdPartyAccount; + } + + public String getThirdPartyAccount() { + return this.thirdPartyAccount; + } + + @Override + public String toString() { + return "GetLoginProfileResponse{" + + "password=" + password + "\n" + + "needResetPassword=" + needResetPassword + "\n" + + "enabledLoginMfa=" + enabledLoginMfa + "\n" + + "loginMfaType=" + loginMfaType + "\n" + + "thirdPartyType=" + thirdPartyType + "\n" + + "thirdPartyAccount=" + thirdPartyAccount + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/GetPolicyResponse.java b/src/main/java/com/baidubce/services/iam/model/GetPolicyResponse.java new file mode 100644 index 00000000..2f8e4888 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/GetPolicyResponse.java @@ -0,0 +1,112 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetPolicyResponse extends BaseBceResponse { + /** + * id + */ + private String id; + + /** + * name + */ + private String name; + + /** + * type + */ + private String type; + + /** + * createTime + */ + private Date createTime; + + /** + * description + */ + private String description; + + /** + * document + */ + private String document; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setDocument(String document) { + this.document = document; + } + + public String getDocument() { + return this.document; + } + + @Override + public String toString() { + return "GetPolicyResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "document=" + document + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/GetRoleResponse.java b/src/main/java/com/baidubce/services/iam/model/GetRoleResponse.java new file mode 100644 index 00000000..a5dd8a26 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/GetRoleResponse.java @@ -0,0 +1,99 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetRoleResponse extends BaseBceResponse { + /** + * id + */ + private String id; + + /** + * name + */ + private String name; + + /** + * createTime + */ + + private Date createTime; + + /** + * description + */ + private String description; + + /** + * assumeRolePolicyDocument + */ + private String assumeRolePolicyDocument; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setAssumeRolePolicyDocument(String assumeRolePolicyDocument) { + this.assumeRolePolicyDocument = assumeRolePolicyDocument; + } + + public String getAssumeRolePolicyDocument() { + return this.assumeRolePolicyDocument; + } + + @Override + public String toString() { + return "GetRoleResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "assumeRolePolicyDocument=" + assumeRolePolicyDocument + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/GetUserResponse.java b/src/main/java/com/baidubce/services/iam/model/GetUserResponse.java new file mode 100644 index 00000000..fbabec38 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/GetUserResponse.java @@ -0,0 +1,98 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetUserResponse extends BaseBceResponse { + /** + * 用户身份标识号码 + */ + private String id; + + /** + * 用户名称 + */ + private String name; + + /** + * 描述 + */ + private String description; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 该用户是否有效 + */ + private Boolean enabled; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return this.enabled; + } + + @Override + public String toString() { + return "GetUserResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "createTime=" + createTime + "\n" + + "enabled=" + enabled + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/GetVsAccountResponse.java b/src/main/java/com/baidubce/services/iam/model/GetVsAccountResponse.java new file mode 100644 index 00000000..dde6a28e --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/GetVsAccountResponse.java @@ -0,0 +1,125 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetVsAccountResponse extends BaseBceResponse { + + /** + * virtual store account id + */ + String accountId; + + /** + * virtual store customer id + */ + String userId; + + /** + * virtual store customer name + */ + String name; + + /** + * virtual store customer email + */ + String email; + + /** + * virtual store customer mobile phone + */ + String mobilePhone; + + /** + * virtual store customer account type + */ + String accountType; + + /** + * virtual store customer company + */ + String company; + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getMobilePhone() { + return mobilePhone; + } + + public void setMobilePhone(String mobilePhone) { + this.mobilePhone = mobilePhone; + } + + public String getAccountType() { + return accountType; + } + + public void setAccountType(String accountType) { + this.accountType = accountType; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + @Override + public String toString() { + return "CreateVsAccountResponse{" + + "accountId='" + accountId + '\'' + + ", userId='" + userId + '\'' + + ", name='" + name + '\'' + + ", email='" + email + '\'' + + ", mobilePhone='" + mobilePhone + '\'' + + ", accountType='" + accountType + '\'' + + ", company='" + company + '\'' + + '}'; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListAccessKeyResponse.java b/src/main/java/com/baidubce/services/iam/model/ListAccessKeyResponse.java new file mode 100644 index 00000000..2e77c833 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListAccessKeyResponse.java @@ -0,0 +1,109 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListAccessKeyResponse extends BaseBceResponse { + /** + * accessKeys + */ + private List accessKeys; + + public void setAccessKeys(List accessKeys) { + this.accessKeys = accessKeys; + } + + public List getAccessKeys() { + return this.accessKeys; + } + + @Override + public String toString() { + return "ListAccessKeyResponse{" + + "accessKeys=" + accessKeys + "\n" + + "}"; + } + + public static class AccessKey { + private String id; + + /** + * createTime + */ + private Date createTime; + + private String description; + + private Boolean enabled; + + private Date lastUsedTime; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return this.enabled; + } + + public Date getLastUsedTime() { + return lastUsedTime; + } + + public void setLastUsedTime(Date lastUsedTime) { + this.lastUsedTime = lastUsedTime; + } + + @Override + public String toString() { + return "AccessKey{" + + "id=" + id + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "enabled=" + enabled + "\n" + + "lastUsedTime=" + lastUsedTime + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListGroupResponse.java b/src/main/java/com/baidubce/services/iam/model/ListGroupResponse.java new file mode 100644 index 00000000..9cf9507c --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListGroupResponse.java @@ -0,0 +1,98 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListGroupResponse extends BaseBceResponse { + /** + * groups + */ + private List groups; + + public void setGroups(List groups) { + this.groups = groups; + } + + public List getGroups() { + return this.groups; + } + + @Override + public String toString() { + return "ListGroupResponse{" + + "groups=" + groups + "\n" + + "}"; + } + + public static class Group { + private String id; + + private String name; + + /** + * createTime + */ + private Date createTime; + + private String description; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "Group{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListGroupsForUserResponse.java b/src/main/java/com/baidubce/services/iam/model/ListGroupsForUserResponse.java new file mode 100644 index 00000000..9c6d00f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListGroupsForUserResponse.java @@ -0,0 +1,95 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListGroupsForUserResponse extends BaseBceResponse { + /** + * groups + */ + private List groups; + + public void setGroups(List groups) { + this.groups = groups; + } + + public List getGroups() { + return this.groups; + } + + @Override + public String toString() { + return "ListGroupsForUserResponse{" + + "groups=" + groups + "\n" + + "}"; + } + + public static class Group { + private String id; + + private String name; + + private Date createTime; + + private String description; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "Group{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListPoliciesForGroupResponse.java b/src/main/java/com/baidubce/services/iam/model/ListPoliciesForGroupResponse.java new file mode 100644 index 00000000..185f2635 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListPoliciesForGroupResponse.java @@ -0,0 +1,117 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListPoliciesForGroupResponse extends BaseBceResponse { + /** + * policies + */ + private List policies; + + public void setPolicies(List policies) { + this.policies = policies; + } + + public List getPolicies() { + return this.policies; + } + + @Override + public String toString() { + return "ListPoliciesForGroupResponse{" + + "policies=" + policies + "\n" + + "}"; + } + + public static class Policy { + private String id; + + private String name; + + private String type; + + private Date createTime; + + private String description; + + private String document; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setDocument(String document) { + this.document = document; + } + + public String getDocument() { + return this.document; + } + + @Override + public String toString() { + return "Policy{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "document=" + document + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListPoliciesForRoleResponse.java b/src/main/java/com/baidubce/services/iam/model/ListPoliciesForRoleResponse.java new file mode 100644 index 00000000..dcc8c0ed --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListPoliciesForRoleResponse.java @@ -0,0 +1,118 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListPoliciesForRoleResponse extends BaseBceResponse { + /** + * policies + */ + private List policies; + + public void setPolicies(List policies) { + this.policies = policies; + } + + public List getPolicies() { + return this.policies; + } + + @Override + public String toString() { + return "ListPoliciesForRoleResponse{" + + "policies=" + policies + "\n" + + "}"; + } + + public static class Policy { + private String id; + + private String name; + + private String type; + + private Date createTime; + + private String description; + + private String document; + + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setDocument(String document) { + this.document = document; + } + + public String getDocument() { + return this.document; + } + + @Override + public String toString() { + return "Policy{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "document=" + document + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListPoliciesForUserResponse.java b/src/main/java/com/baidubce/services/iam/model/ListPoliciesForUserResponse.java new file mode 100644 index 00000000..7498a30a --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListPoliciesForUserResponse.java @@ -0,0 +1,117 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListPoliciesForUserResponse extends BaseBceResponse { + /** + * policies + */ + private List policies; + + public void setPolicies(List policies) { + this.policies = policies; + } + + public List getPolicies() { + return this.policies; + } + + @Override + public String toString() { + return "ListPoliciesForUserResponse{" + + "policies=" + policies + "\n" + + "}"; + } + + public static class Policy { + private String id; + + private String name; + + private String type; + + private Date createTime; + + private String description; + + private String document; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setDocument(String document) { + this.document = document; + } + + public String getDocument() { + return this.document; + } + + @Override + public String toString() { + return "Policy{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "document=" + document + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListPolicyResponse.java b/src/main/java/com/baidubce/services/iam/model/ListPolicyResponse.java new file mode 100644 index 00000000..e3478782 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListPolicyResponse.java @@ -0,0 +1,117 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListPolicyResponse extends BaseBceResponse { + /** + * policies + */ + private List policies; + + public void setPolicies(List policies) { + this.policies = policies; + } + + public List getPolicies() { + return this.policies; + } + + @Override + public String toString() { + return "ListPolicyResponse{" + + "policies=" + policies + "\n" + + "}"; + } + + public static class Policy { + private String id; + + private String name; + + private String type; + + private Date createTime; + + private String description; + + private String document; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setDocument(String document) { + this.document = document; + } + + public String getDocument() { + return this.document; + } + + @Override + public String toString() { + return "Policy{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "document=" + document + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListRoleResponse.java b/src/main/java/com/baidubce/services/iam/model/ListRoleResponse.java new file mode 100644 index 00000000..ab6f03d2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListRoleResponse.java @@ -0,0 +1,106 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListRoleResponse extends BaseBceResponse { + /** + * roles + */ + private List roles; + + public void setRoles(List roles) { + this.roles = roles; + } + + public List getRoles() { + return this.roles; + } + + @Override + public String toString() { + return "ListRoleResponse{" + + "roles=" + roles + "\n" + + "}"; + } + + public static class Role { + private String id; + + private String name; + + private Date createTime; + + private String description; + + private String assumeRolePolicyDocument; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setAssumeRolePolicyDocument(String assumeRolePolicyDocument) { + this.assumeRolePolicyDocument = assumeRolePolicyDocument; + } + + public String getAssumeRolePolicyDocument() { + return this.assumeRolePolicyDocument; + } + + @Override + public String toString() { + return "Role{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "assumeRolePolicyDocument=" + assumeRolePolicyDocument + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListUserResponse.java b/src/main/java/com/baidubce/services/iam/model/ListUserResponse.java new file mode 100644 index 00000000..ecb067a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListUserResponse.java @@ -0,0 +1,106 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import java.util.Date; +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListUserResponse extends BaseBceResponse { + /** + * users + */ + private List users; + + public void setUsers(List users) { + this.users = users; + } + + public List getUsers() { + return this.users; + } + + @Override + public String toString() { + return "ListUserResponse{" + + "users=" + users + "\n" + + "}"; + } + + public static class User { + private String id; + + private String name; + + private String description; + + private Date createTime; + + private Boolean enabled; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return this.enabled; + } + + @Override + public String toString() { + return "User{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "createTime=" + createTime + "\n" + + "enabled=" + enabled + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListUsersInGroupResponse.java b/src/main/java/com/baidubce/services/iam/model/ListUsersInGroupResponse.java new file mode 100644 index 00000000..5f241d99 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListUsersInGroupResponse.java @@ -0,0 +1,106 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import java.util.Date; +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListUsersInGroupResponse extends BaseBceResponse { + /** + * users + */ + private List users; + + public void setUsers(List users) { + this.users = users; + } + + public List getUsers() { + return this.users; + } + + @Override + public String toString() { + return "ListUsersInGroupResponse{" + + "users=" + users + "\n" + + "}"; + } + + public static class User { + private String id; + + private String name; + + private String description; + + private Date createTime; + + private Boolean enabled; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return this.enabled; + } + + @Override + public String toString() { + return "User{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "createTime=" + createTime + "\n" + + "enabled=" + enabled + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListVsAccountsRequest.java b/src/main/java/com/baidubce/services/iam/model/ListVsAccountsRequest.java new file mode 100644 index 00000000..e7e61c38 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListVsAccountsRequest.java @@ -0,0 +1,82 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListVsAccountsRequest extends BaseBceRequest { + + /** + * virtual store account id + */ + String accountId; + + /** + * virtual store customer id + */ + String userId; + + /** + * page number + */ + Integer pageNo = 1; + + /** + * page size + */ + Integer pageSize = 10; + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + @Override + public String toString() { + return "ListVsAccountsRequest{" + + "accountId='" + accountId + '\'' + + ", userId='" + userId + '\'' + + ", pageNo=" + pageNo + + ", pageSize=" + pageSize + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/ListVsAccountsResponse.java b/src/main/java/com/baidubce/services/iam/model/ListVsAccountsResponse.java new file mode 100644 index 00000000..881dfca2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/ListVsAccountsResponse.java @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListVsAccountsResponse extends BaseBceResponse { + + /** + * virtual store customer account total size + */ + Long totalSize; + + /** + * virtual store customer account ids + */ + List uidList; + + public Long getTotalSize() { + return totalSize; + } + + public void setTotalSize(Long totalSize) { + this.totalSize = totalSize; + } + + public List getUidList() { + return uidList; + } + + public void setUidList(List uidList) { + this.uidList = uidList; + } + + @Override + public String toString() { + return "ListVsAccountsResponse{" + + "totalSize=" + totalSize + + ", uidList=" + uidList + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/SignValidateRequest.java b/src/main/java/com/baidubce/services/iam/model/SignValidateRequest.java new file mode 100644 index 00000000..ecfb56f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/SignValidateRequest.java @@ -0,0 +1,97 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class SignValidateRequest { + /** + * method + */ + private String method; + + /** + * uri + */ + private String uri; + + /** + * params + */ + private SignValidateRequestParams params; + + /** + * headers + */ + private SignValidateRequestHeaders headers; + + public void setMethod(String method) { + this.method = method; + } + + public String getMethod() { + return this.method; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public String getUri() { + return this.uri; + } + + public void setParams(SignValidateRequestParams params) { + this.params = params; + } + + public SignValidateRequestParams getParams() { + return this.params; + } + + public void setHeaders(SignValidateRequestHeaders headers) { + this.headers = headers; + } + + public SignValidateRequestHeaders getHeaders() { + return this.headers; + } + + @Override + public String toString() { + return "SignValidateRequest{" + + "method=" + method + "\n" + + "uri=" + uri + "\n" + + "params=" + params + "\n" + + "headers=" + headers + "\n" + + "}"; + } + + public static class SignValidateRequestParams { + @Override + public String toString() { + return "SignValidateRequestParams{" + + "}"; + } + } + + public static class SignValidateRequestHeaders { + @Override + public String toString() { + return "SignValidateRequestHeaders{" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/UpdateGroupRequest.java b/src/main/java/com/baidubce/services/iam/model/UpdateGroupRequest.java new file mode 100644 index 00000000..526e5134 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/UpdateGroupRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateGroupRequest extends BaseBceRequest { + /** + * name + */ + private String name; + + /** + * description + */ + private String description; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "UpdateGroupRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/UpdateGroupResponse.java b/src/main/java/com/baidubce/services/iam/model/UpdateGroupResponse.java new file mode 100644 index 00000000..fce7eabc --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/UpdateGroupResponse.java @@ -0,0 +1,84 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateGroupResponse extends BaseBceResponse { + /** + * id + */ + private String id; + + /** + * name + */ + private String name; + + /** + * createTime + */ + private Date createTime; + + /** + * description + */ + private String description; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "UpdateGroupResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/UpdateLoginProfileRequest.java b/src/main/java/com/baidubce/services/iam/model/UpdateLoginProfileRequest.java new file mode 100644 index 00000000..3bc6ac84 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/UpdateLoginProfileRequest.java @@ -0,0 +1,110 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateLoginProfileRequest extends BaseBceRequest { + /** + * password + */ + private String password; + + /** + * needResetPassword + */ + private Boolean needResetPassword; + + /** + * enabledLoginMfa + */ + private Boolean enabledLoginMfa; + + /** + * loginMfaType + */ + private String loginMfaType; + + /** + * thirdPartyType + */ + private String thirdPartyType; + + /** + * thirdPartyAccount + */ + private String thirdPartyAccount; + + public void setPassword(String password) { + this.password = password; + } + + public String getPassword() { + return this.password; + } + + public void setNeedResetPassword(Boolean needResetPassword) { + this.needResetPassword = needResetPassword; + } + + public Boolean isNeedResetPassword() { + return this.needResetPassword; + } + + public void setEnabledLoginMfa(Boolean enabledLoginMfa) { + this.enabledLoginMfa = enabledLoginMfa; + } + + public Boolean isEnabledLoginMfa() { + return this.enabledLoginMfa; + } + + public void setLoginMfaType(String loginMfaType) { + this.loginMfaType = loginMfaType; + } + + public String getLoginMfaType() { + return this.loginMfaType; + } + + public void setThirdPartyType(String thirdPartyType) { + this.thirdPartyType = thirdPartyType; + } + + public String getThirdPartyType() { + return this.thirdPartyType; + } + + public void setThirdPartyAccount(String thirdPartyAccount) { + this.thirdPartyAccount = thirdPartyAccount; + } + + public String getThirdPartyAccount() { + return this.thirdPartyAccount; + } + + @Override + public String toString() { + return "UpdateLoginProfileRequest{" + + "password=" + password + "\n" + + "needResetPassword=" + needResetPassword + "\n" + + "enabledLoginMfa=" + enabledLoginMfa + "\n" + + "loginMfaType=" + loginMfaType + "\n" + + "thirdPartyType=" + thirdPartyType + "\n" + + "thirdPartyAccount=" + thirdPartyAccount + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/UpdateLoginProfileResponse.java b/src/main/java/com/baidubce/services/iam/model/UpdateLoginProfileResponse.java new file mode 100644 index 00000000..77e0c092 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/UpdateLoginProfileResponse.java @@ -0,0 +1,110 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateLoginProfileResponse extends BaseBceResponse { + /** + * password + */ + private String password; + + /** + * needResetPassword + */ + private Boolean needResetPassword; + + /** + * enabledLoginMfa + */ + private Boolean enabledLoginMfa; + + /** + * loginMfaType + */ + private String loginMfaType; + + /** + * thirdPartyType + */ + private String thirdPartyType; + + /** + * thirdPartyAccount + */ + private String thirdPartyAccount; + + public void setPassword(String password) { + this.password = password; + } + + public String getPassword() { + return this.password; + } + + public void setNeedResetPassword(Boolean needResetPassword) { + this.needResetPassword = needResetPassword; + } + + public Boolean isNeedResetPassword() { + return this.needResetPassword; + } + + public void setEnabledLoginMfa(Boolean enabledLoginMfa) { + this.enabledLoginMfa = enabledLoginMfa; + } + + public Boolean isEnabledLoginMfa() { + return this.enabledLoginMfa; + } + + public void setLoginMfaType(String loginMfaType) { + this.loginMfaType = loginMfaType; + } + + public String getLoginMfaType() { + return this.loginMfaType; + } + + public void setThirdPartyType(String thirdPartyType) { + this.thirdPartyType = thirdPartyType; + } + + public String getThirdPartyType() { + return this.thirdPartyType; + } + + public void setThirdPartyAccount(String thirdPartyAccount) { + this.thirdPartyAccount = thirdPartyAccount; + } + + public String getThirdPartyAccount() { + return this.thirdPartyAccount; + } + + @Override + public String toString() { + return "UpdateLoginProfileResponse{" + + "password=" + password + "\n" + + "needResetPassword=" + needResetPassword + "\n" + + "enabledLoginMfa=" + enabledLoginMfa + "\n" + + "loginMfaType=" + loginMfaType + "\n" + + "thirdPartyType=" + thirdPartyType + "\n" + + "thirdPartyAccount=" + thirdPartyAccount + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/UpdateRoleRequest.java b/src/main/java/com/baidubce/services/iam/model/UpdateRoleRequest.java new file mode 100644 index 00000000..f0ef35c4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/UpdateRoleRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateRoleRequest extends BaseBceRequest { + /** + * name + */ + private String name; + + /** + * description + */ + private String description; + + /** + * assumeRolePolicyDocument + */ + private String assumeRolePolicyDocument; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setAssumeRolePolicyDocument(String assumeRolePolicyDocument) { + this.assumeRolePolicyDocument = assumeRolePolicyDocument; + } + + public String getAssumeRolePolicyDocument() { + return this.assumeRolePolicyDocument; + } + + @Override + public String toString() { + return "UpdateRoleRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "assumeRolePolicyDocument=" + assumeRolePolicyDocument + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/UpdateRoleResponse.java b/src/main/java/com/baidubce/services/iam/model/UpdateRoleResponse.java new file mode 100644 index 00000000..3f32ba6f --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/UpdateRoleResponse.java @@ -0,0 +1,100 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateRoleResponse extends BaseBceResponse { + /** + * id + */ + private String id; + + /** + * name + */ + private String name; + + /** + * createTime + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") + private Date createTime; + + /** + * description + */ + private String description; + + /** + * assumeRolePolicyDocument + */ + private String assumeRolePolicyDocument; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setAssumeRolePolicyDocument(String assumeRolePolicyDocument) { + this.assumeRolePolicyDocument = assumeRolePolicyDocument; + } + + public String getAssumeRolePolicyDocument() { + return this.assumeRolePolicyDocument; + } + + @Override + public String toString() { + return "UpdateRoleResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "createTime=" + createTime + "\n" + + "description=" + description + "\n" + + "assumeRolePolicyDocument=" + assumeRolePolicyDocument + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/UpdateUserRequest.java b/src/main/java/com/baidubce/services/iam/model/UpdateUserRequest.java new file mode 100644 index 00000000..82f9ce36 --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/UpdateUserRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateUserRequest extends BaseBceRequest { + /** + * 用户名称 + */ + private String name; + + /** + * 描述 + */ + private String description; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "UpdateUserRequest{" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iam/model/UpdateUserResponse.java b/src/main/java/com/baidubce/services/iam/model/UpdateUserResponse.java new file mode 100644 index 00000000..ad8e1b8e --- /dev/null +++ b/src/main/java/com/baidubce/services/iam/model/UpdateUserResponse.java @@ -0,0 +1,98 @@ +/* + * Copyright 2020 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iam.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateUserResponse extends BaseBceResponse { + /** + * 用户身份标识号码 + */ + private String id; + + /** + * 用户名称 + */ + private String name; + + /** + * 描述 + */ + private String description; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 该用户是否有效 + */ + private Boolean enabled; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return this.enabled; + } + + @Override + public String toString() { + return "UpdateUserResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "description=" + description + "\n" + + "createTime=" + createTime + "\n" + + "enabled=" + enabled + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java b/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java new file mode 100644 index 00000000..25fa8980 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java @@ -0,0 +1,174 @@ +package com.baidubce.services.iotalarm; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotalarm.model.Alarm; +import com.baidubce.services.iotalarm.model.BatchIds; +import com.baidubce.services.iotalarm.model.CommonResponse; +import com.baidubce.services.iotalarm.model.CreateAlarmRequest; +import com.baidubce.services.iotalarm.model.ListAlarmRequest; +import com.baidubce.services.iotalarm.model.ListAlarmResponse; +import com.baidubce.services.iotalarm.model.UpdateAlarmRequest; +import com.baidubce.services.iotalarm.model.UuidResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +public class IotAlarmClient extends AbstractBceClient { + private static final String ENDPOINT = "re.iot.gz.baidubce.com"; + private static final String VERSION = "v1"; + private static final String ALARM = "alarm"; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + private static final String DISABLE = "disable"; + private static final String ENABLE = "enable"; + private static final String RECOVER = "recover"; + private static final String BATCH = "batch"; + private static final String DELETE = "delete"; + + private static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; + + public IotAlarmClient(BceClientConfiguration config) { + + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, HANDLERS); + } + + public IotAlarmClient(String accessKey, String secretKey) { + this(new BceClientConfiguration() + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)) + .withEndpoint(ENDPOINT)); + } + + public ListAlarmResponse listAlarms(ListAlarmRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.GET, ALARM); + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + if (request.getAlarmState() != null) { + internalRequest.addParameter("alarmState", request.getAlarmState()); + } + if (request.getDisabled() != null) { + internalRequest.addParameter("disabled", request.getDisabled()); + } + if (request.getServerity() != null) { + internalRequest.addParameter("severity", request.getServerity()); + } + return this.invokeHttpClient(internalRequest, ListAlarmResponse.class); + } + + public Alarm getAlarm(String uuid) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.GET, ALARM, uuid); + return this.invokeHttpClient(internalRequest, Alarm.class); + } + + public UuidResponse createAlarm(CreateAlarmRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.POST, ALARM); + return this.invokeHttpClient(internalRequest, UuidResponse.class); + } + + public CommonResponse deleteAlarm(String uuid) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, ALARM, uuid); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse deleteAlarmBatch(List alarmIds) { + BatchIds ids = new BatchIds(); + ids.setIds(alarmIds); + InternalRequest internalRequest = + createRequest(ids, HttpMethodName.POST, ALARM, BATCH, DELETE); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse updateAlarm(UpdateAlarmRequest req, String uuid) { + InternalRequest internalRequest = + createRequest(req, HttpMethodName.PUT, ALARM, uuid); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse disableAlarm(String alarmId) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.PUT, ALARM, alarmId, DISABLE); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse enableAlarm(String alarmId) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.PUT, ALARM, alarmId, ENABLE); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse recoverAlarm(String alarmId) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.PUT, ALARM, alarmId, RECOVER); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse recoverAlarmBatch(List alarmIds) { + BatchIds ids = new BatchIds(); + ids.setIds(alarmIds); + InternalRequest internalRequest = + createRequest(ids, HttpMethodName.POST, ALARM, BATCH, RECOVER); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, request); + } + + return request; + } + + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java b/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java new file mode 100644 index 00000000..04df0c3e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java @@ -0,0 +1,219 @@ +package com.baidubce.services.iotalarm.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class Alarm extends AbstractBceResponse { + public static final String NORMAL = "NORMAL"; + public static final String ALARMING = "ALARMING"; + public static final String WARN = "WARN"; + public static final String DISABLED = "DISABLED"; + public static final String ENABLED = "ENABLED"; + public static final String HIGH = "HIGH"; + public static final String MIDDLE = "MIDDLE"; + public static final String LOW = "LOW"; + + private String uuid; + private String name; + private String desc; + private String kind; + private String severity; + private String accountUuid; + private String endpointName; + private String topic; + private String select; + private String condition; + private String alarmTrigger; + private String smsReceiver; + private String smsVars; + private String smsMsgType; + private String mqttMsgType; + private String destTopic; + private String alarmState; + private long startTime; + private long refreshTime; + private long recoverTime; + private String lastMsg; + private String disabled; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public String getAccountUuid() { + return accountUuid; + } + + public void setAccountUuid(String accountUuid) { + this.accountUuid = accountUuid; + } + + public String getEndpointName() { + return endpointName; + } + + public void setEndpointName(String endpointName) { + this.endpointName = endpointName; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public String getSelect() { + return select; + } + + public void setSelect(String select) { + this.select = select; + } + + public String getCondition() { + return condition; + } + + public void setCondition(String condition) { + this.condition = condition; + } + + public String getAlarmTrigger() { + return alarmTrigger; + } + + public void setAlarmTrigger(String alarmTrigger) { + this.alarmTrigger = alarmTrigger; + } + + public String getSmsReceiver() { + return smsReceiver; + } + + public void setSmsReceiver(String smsReceiver) { + this.smsReceiver = smsReceiver; + } + + public String getSmsVars() { + return smsVars; + } + + public void setSmsVars(String smsVars) { + this.smsVars = smsVars; + } + + public String getSmsMsgType() { + return smsMsgType; + } + + public void setSmsMsgType(String smsMsgType) { + this.smsMsgType = smsMsgType; + } + + public String getMqttMsgType() { + return mqttMsgType; + } + + public void setMqttMsgType(String mqttMsgType) { + this.mqttMsgType = mqttMsgType; + } + + public String getDestTopic() { + return destTopic; + } + + public void setDestTopic(String destTopic) { + this.destTopic = destTopic; + } + + public String getAlarmState() { + return alarmState; + } + + public void setAlarmState(String alarmState) { + this.alarmState = alarmState; + } + + public long getStartTime() { + return startTime; + } + + public void setStartTime(long startTime) { + this.startTime = startTime; + } + + public long getRefreshTime() { + return refreshTime; + } + + public void setRefreshTime(long refreshTime) { + this.refreshTime = refreshTime; + } + + public long getRecoverTime() { + return recoverTime; + } + + public void setRecoverTime(long recoverTime) { + this.recoverTime = recoverTime; + } + + public String getLastMsg() { + return lastMsg; + } + + public void setLastMsg(String lastMsg) { + this.lastMsg = lastMsg; + } + + public String getDisabled() { + return disabled; + } + + public void setDisabled(String disabled) { + this.disabled = disabled; + } + +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/AlarmKind.java b/src/main/java/com/baidubce/services/iotalarm/model/AlarmKind.java new file mode 100644 index 00000000..fbe197a6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/AlarmKind.java @@ -0,0 +1,8 @@ +package com.baidubce.services.iotalarm.model; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +public class AlarmKind { + public static final String DATA_STREAM = "DATA_STREAM"; +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/AlarmNoticeMsgType.java b/src/main/java/com/baidubce/services/iotalarm/model/AlarmNoticeMsgType.java new file mode 100644 index 00000000..eeedcced --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/AlarmNoticeMsgType.java @@ -0,0 +1,11 @@ +package com.baidubce.services.iotalarm.model; + +/** + * Created by yuanyoujun on 2017/7/20. + */ +public class AlarmNoticeMsgType { + public static final String NOTHING = "NOTHING"; + public static final String ALARM = "ALARM"; + public static final String ALARM_RECOVER = "ALARM_RECOVER"; + public static final String ALL = "ALL"; +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/AlarmSeverity.java b/src/main/java/com/baidubce/services/iotalarm/model/AlarmSeverity.java new file mode 100644 index 00000000..265d2fd1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/AlarmSeverity.java @@ -0,0 +1,10 @@ +package com.baidubce.services.iotalarm.model; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +public class AlarmSeverity { + public static final String LOW = "LOW"; + public static final String MIDDLE = "MIDDLE"; + public static final String HIGH = "HIGH"; +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/AlarmTrigger.java b/src/main/java/com/baidubce/services/iotalarm/model/AlarmTrigger.java new file mode 100644 index 00000000..9b567b58 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/AlarmTrigger.java @@ -0,0 +1,16 @@ +package com.baidubce.services.iotalarm.model; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +public class AlarmTrigger { + public static final String COUNT = "COUNT:"; + + public static String createCountType(int cnt) { + if (cnt <= 0) { + throw new IllegalArgumentException("cnt must > 0"); + } + + return COUNT + String.valueOf(cnt); + } +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/BatchIds.java b/src/main/java/com/baidubce/services/iotalarm/model/BatchIds.java new file mode 100644 index 00000000..280a15ea --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/BatchIds.java @@ -0,0 +1,20 @@ +package com.baidubce.services.iotalarm.model; + +import com.baidubce.model.GenericAccountRequest; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/7/20. + */ +public class BatchIds extends GenericAccountRequest { + private List ids; + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/CommonResponse.java b/src/main/java/com/baidubce/services/iotalarm/model/CommonResponse.java new file mode 100644 index 00000000..49c49bf0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/CommonResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.iotalarm.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +public class CommonResponse extends AbstractBceResponse { + private String result; + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/CreateAlarmRequest.java b/src/main/java/com/baidubce/services/iotalarm/model/CreateAlarmRequest.java new file mode 100644 index 00000000..ffb17838 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/CreateAlarmRequest.java @@ -0,0 +1,135 @@ +package com.baidubce.services.iotalarm.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +public class CreateAlarmRequest extends GenericAccountRequest { + private String name; + private String desc; + private String kind; + private String severity; + private String endpointName; + private String topic; + private String select; + private String condition; + private String alarmTrigger; + private String smsReceiver; + private String smsVars; + private String smsMsgType; + private String mqttMsgType; + private String destTopic; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public String getEndpointName() { + return endpointName; + } + + public void setEndpointName(String endpointName) { + this.endpointName = endpointName; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public String getSelect() { + return select; + } + + public void setSelect(String select) { + this.select = select; + } + + public String getCondition() { + return condition; + } + + public void setCondition(String condition) { + this.condition = condition; + } + + public String getAlarmTrigger() { + return alarmTrigger; + } + + public void setAlarmTrigger(String alarmTrigger) { + this.alarmTrigger = alarmTrigger; + } + + public String getSmsReceiver() { + return smsReceiver; + } + + public void setSmsReceiver(String smsReceiver) { + this.smsReceiver = smsReceiver; + } + + public String getSmsVars() { + return smsVars; + } + + public void setSmsVars(String smsVars) { + this.smsVars = smsVars; + } + + public String getSmsMsgType() { + return smsMsgType; + } + + public void setSmsMsgType(String smsMsgType) { + this.smsMsgType = smsMsgType; + } + + public String getMqttMsgType() { + return mqttMsgType; + } + + public void setMqttMsgType(String mqttMsgType) { + this.mqttMsgType = mqttMsgType; + } + + public String getDestTopic() { + return destTopic; + } + + public void setDestTopic(String destTopic) { + this.destTopic = destTopic; + } +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmRequest.java b/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmRequest.java new file mode 100644 index 00000000..956aa86b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmRequest.java @@ -0,0 +1,56 @@ +package com.baidubce.services.iotalarm.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListAlarmRequest extends GenericAccountRequest { + private int pageNo = 1; + private int pageSize = 50; + private String alarmState; + private String disabled; + private String serverity; + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public String getAlarmState() { + return alarmState; + } + + public void setAlarmState(String alarmState) { + this.alarmState = alarmState; + } + + public String getDisabled() { + return disabled; + } + + public void setDisabled(String disabled) { + this.disabled = disabled; + } + + public String getServerity() { + return serverity; + } + + public void setServerity(String serverity) { + this.serverity = serverity; + } +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmResponse.java b/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmResponse.java new file mode 100644 index 00000000..b7960364 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmResponse.java @@ -0,0 +1,49 @@ +package com.baidubce.services.iotalarm.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListAlarmResponse extends AbstractBceResponse { + private List result; + private int totalCount; + private int pageNo; + private int pageSize; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/UpdateAlarmRequest.java b/src/main/java/com/baidubce/services/iotalarm/model/UpdateAlarmRequest.java new file mode 100644 index 00000000..a57091b9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/UpdateAlarmRequest.java @@ -0,0 +1,119 @@ +package com.baidubce.services.iotalarm.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/6/21. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateAlarmRequest extends GenericAccountRequest { + private String name; + private String desc; + private String severity; + private String topic; + private String select; + private String condition; + private String alarmTrigger; + private String smsReceiver; + private String smsVars; + private String smsMsgType; + private String mqttMsgType; + private String destTopic; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public String getSelect() { + return select; + } + + public void setSelect(String select) { + this.select = select; + } + + public String getCondition() { + return condition; + } + + public void setCondition(String condition) { + this.condition = condition; + } + + public String getAlarmTrigger() { + return alarmTrigger; + } + + public void setAlarmTrigger(String alarmTrigger) { + this.alarmTrigger = alarmTrigger; + } + + public String getSmsReceiver() { + return smsReceiver; + } + + public void setSmsReceiver(String smsReceiver) { + this.smsReceiver = smsReceiver; + } + + public String getSmsVars() { + return smsVars; + } + + public void setSmsVars(String smsVars) { + this.smsVars = smsVars; + } + + public String getSmsMsgType() { + return smsMsgType; + } + + public void setSmsMsgType(String smsMsgType) { + this.smsMsgType = smsMsgType; + } + + public String getMqttMsgType() { + return mqttMsgType; + } + + public void setMqttMsgType(String mqttMsgType) { + this.mqttMsgType = mqttMsgType; + } + + public String getDestTopic() { + return destTopic; + } + + public void setDestTopic(String destTopic) { + this.destTopic = destTopic; + } +} diff --git a/src/main/java/com/baidubce/services/iotalarm/model/UuidResponse.java b/src/main/java/com/baidubce/services/iotalarm/model/UuidResponse.java new file mode 100644 index 00000000..378a74d0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/UuidResponse.java @@ -0,0 +1,29 @@ +package com.baidubce.services.iotalarm.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/6/20. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class UuidResponse extends AbstractBceResponse { + private String result; + private String uuid; + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/IotDmClient.java b/src/main/java/com/baidubce/services/iotdm/IotDmClient.java index 47d851f4..42c94fc4 100644 --- a/src/main/java/com/baidubce/services/iotdm/IotDmClient.java +++ b/src/main/java/com/baidubce/services/iotdm/IotDmClient.java @@ -40,6 +40,7 @@ */ public class IotDmClient extends AbstractBceClient { + private static final String ENDPOINT_HOST = "iotdm.gz.baidubce.com"; private static final String DEVICE = "device"; private static final String GROUP = "group"; private static final String CHILDREN = "children"; @@ -56,7 +57,9 @@ public class IotDmClient extends AbstractBceClient { private static final String UPDATE_REGISTRY = "updateRegistry"; public IotDmClient(BceClientConfiguration config) { - super(config, IotDmClientHelper.IOT_DM_HANDLERS); + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT_HOST) : config, + IotDmClientHelper.IOT_DM_HANDLERS); + } public CreateDevicesResponse createDevices(CreateDevicesRequest createDevicesRequest, String clientToken) { @@ -179,7 +182,7 @@ private GroupListResponse getGroups(String param) { private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { - return IotDmClientHelper.createRequest(bceRequest, httpMethod, this.getEndpoint(), null, pathVariables); + return IotDmClientHelper.createRequestForV1(bceRequest, httpMethod, this.getEndpoint(), null, pathVariables); } } diff --git a/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java b/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java index 42aad74a..92100cae 100644 --- a/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java +++ b/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java @@ -37,10 +37,14 @@ class IotDmClientHelper { private static final String VERSION = "v1"; + private static final String VERSION_V2 = "v2"; + private static final String VERSION_V3 = "v3"; private static final String IOT = "iot"; private static final String MANAGEMENT = "management"; + private static final String ENDPOINT = "endpoint"; + private static final String RULES = "rules"; - private static final String[] HEADERS_TO_SIGN = { Headers.HOST, Headers.BCE_DATE }; + private static final String[] HEADERS_TO_SIGN = {Headers.HOST, Headers.BCE_DATE}; private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; /** @@ -50,10 +54,41 @@ class IotDmClientHelper { new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; - static InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + static InternalRequest createRequestForV1(AbstractBceRequest bceRequest, HttpMethodName httpMethod, URI endpoint, SignOptions signOptions, String... pathVariables) { List path = new ArrayList(); path.addAll(Arrays.asList(VERSION, IOT, MANAGEMENT)); + + return createRequest(bceRequest, httpMethod, endpoint, signOptions, path, pathVariables); + } + + static InternalRequest createRequestForV2(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + URI endpoint, SignOptions signOptions, String... pathVariables) { + List path = new ArrayList(); + path.addAll(Arrays.asList(VERSION_V2, IOT, MANAGEMENT, ENDPOINT)); + + return createRequest(bceRequest, httpMethod, endpoint, signOptions, path, pathVariables); + } + + static InternalRequest createRequestForV3(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + URI endpoint, SignOptions signOptions, String... pathVariables) { + List path = new ArrayList(); + path.addAll(Arrays.asList(VERSION_V3, IOT, MANAGEMENT)); + + return createRequest(bceRequest, httpMethod, endpoint, signOptions, path, pathVariables); + } + + static InternalRequest createRequestForRules(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + URI endpoint, SignOptions signOptions, + String... pathVariables) { + List path = new ArrayList(); + path.addAll(Arrays.asList(VERSION_V3, IOT, RULES)); + + return createRequest(bceRequest, httpMethod, endpoint, signOptions, path, pathVariables); + } + + private static InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + URI endpoint, SignOptions signOptions, List path, String... pathVariables) { if (pathVariables != null) { for (String pathVariable : pathVariables) { path.add(pathVariable); diff --git a/src/main/java/com/baidubce/services/iotdm/IotDmV2Client.java b/src/main/java/com/baidubce/services/iotdm/IotDmV2Client.java new file mode 100644 index 00000000..4901c5f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/IotDmV2Client.java @@ -0,0 +1,158 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.internal.InternalRequest; +import com.baidubce.http.HttpMethodName; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdm.model.CreateEndpointResponse; +import com.baidubce.services.iotdm.model.CreateEndpointRequest; +import com.baidubce.services.iotdm.model.GetEndpointsResponse; +import com.baidubce.services.iotdm.model.CreateDevicesRequest; +import com.baidubce.services.iotdm.model.CreateDevicesResponse; +import com.baidubce.services.iotdm.model.DeviceAccessDetail; +import com.baidubce.services.iotdm.model.DeviceOperationRequest; +import com.baidubce.services.iotdm.model.DeviceProfileResponse; +import com.baidubce.services.iotdm.model.DeviceQueryRequest; +import com.baidubce.services.iotdm.model.DeviceQueryResponse; +import com.baidubce.services.iotdm.model.RemoveDevicesRequest; +import com.baidubce.services.iotdm.model.UpdateDeviceProfileRequest; +import com.baidubce.services.iotdm.model.UpdateDeviceRegistryRequest; +import com.google.common.base.Preconditions; + +public class IotDmV2Client extends AbstractBceClient { + + private static final String ENDPOINT_HOST = "iotdm.gz.baidubce.com"; + private static final String DEVICE = "device"; + private static final String CLIENT_TOKEN = "clientToken"; + private static final String CLEAN_HUB = "cleanHub"; + private static final String ACCESS_DETAIL = "accessDetail"; + private static final String REMOVE = "remove"; + private static final String DISABLE = "disable"; + private static final String ENABLE = "enable"; + private static final String QUERY = "query"; + private static final String REBOOT = "reboot"; + private static final String UPDATE_PROFILE = "updateProfile"; + private static final String UPDATE_REGISTRY = "updateRegistry"; + + public IotDmV2Client (BceClientConfiguration config) { + + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT_HOST) : config, + IotDmClientHelper.IOT_DM_HANDLERS); + } + + public CreateEndpointResponse createEndpoint(CreateEndpointRequest createEndpointRequest, String clientToken) { + Preconditions.checkNotNull(createEndpointRequest, "request should not be null."); + Preconditions.checkNotNull(clientToken, "client token should not be null"); + InternalRequest internalRequest = createRequest(createEndpointRequest, HttpMethodName.POST, null); + internalRequest.addParameter(CLIENT_TOKEN, clientToken); + return this.invokeHttpClient(internalRequest, CreateEndpointResponse.class); + } + + public void removeEndpoint(String endpointName, String cleanHub) { + Preconditions.checkNotNull(endpointName, "request should not be null."); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.DELETE, endpointName); + internalRequest.addParameter(CLEAN_HUB, cleanHub); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public GetEndpointsResponse getEndpoints() { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.GET, null); + return this.invokeHttpClient(internalRequest, GetEndpointsResponse.class); + } + + public CreateDevicesResponse createDevices(String endpointName, CreateDevicesRequest createDevicesRequest, + String clientToken) { + return doCreation(createDevicesRequest, endpointName, DEVICE, clientToken, CreateDevicesResponse.class); + } + + public void removeDevices(String endpointName, RemoveDevicesRequest removeDevicesRequest) { + deviceOperation(removeDevicesRequest, endpointName, REMOVE); + } + + public DeviceProfileResponse getDeviceProfile(String endpointName, String deviceName) { + Preconditions.checkNotNull(endpointName, "endpoint name should not be null."); + Preconditions.checkNotNull(deviceName, "device name should not be null."); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, endpointName, DEVICE, deviceName); + return this.invokeHttpClient(internalRequest, DeviceProfileResponse.class); + } + + public DeviceQueryResponse getDeviceProfiles(String endpointName, DeviceQueryRequest deviceQueryRequest) { + Preconditions.checkNotNull(deviceQueryRequest, "request should not be null."); + Preconditions.checkNotNull(endpointName, "endpoint name should not be null."); + InternalRequest internalRequest = createRequest(deviceQueryRequest, + HttpMethodName.PUT, endpointName, DEVICE); + internalRequest.addParameter(QUERY, null); + return this.invokeHttpClient(internalRequest, DeviceQueryResponse.class); + } + + public DeviceAccessDetail getDeviceAccessDetail(String endpointName, String deviceName) { + Preconditions.checkNotNull(deviceName, "device name should not be null."); + Preconditions.checkNotNull(endpointName, "endpoint name should not be null."); + + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.GET, + endpointName, DEVICE, deviceName, ACCESS_DETAIL); + + return this.invokeHttpClient(internalRequest, DeviceAccessDetail.class); + } + + public void updateDeviceProfile(String endpointName, UpdateDeviceProfileRequest updateDeviceProfileRequest) { + deviceOperation(updateDeviceProfileRequest, endpointName, UPDATE_PROFILE); + } + + public void updateDeviceRegistry(String endpointName, UpdateDeviceRegistryRequest updateDeviceRegistryRequest) { + deviceOperation(updateDeviceRegistryRequest, endpointName, UPDATE_REGISTRY); + } + + public void disableDevices(String endpointName, DeviceOperationRequest deviceOperationRequest) { + deviceOperation(deviceOperationRequest, endpointName, DISABLE); + } + + public void enableDevices(String endpointName, DeviceOperationRequest deviceOperationRequest) { + deviceOperation(deviceOperationRequest, endpointName, ENABLE); + } + + public void rebootDevices(String endpointName, DeviceOperationRequest deviceOperationRequest) { + deviceOperation(deviceOperationRequest, endpointName, REBOOT); + } + + private T doCreation(AbstractBceRequest request, + String endpointName, String objectPath, + String clientToken, Class responseClass) { + Preconditions.checkNotNull(request, "request should not be null."); + Preconditions.checkNotNull(endpointName, "endpoint name should not be null"); + Preconditions.checkNotNull(clientToken, "client token should not be null"); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, endpointName, objectPath); + internalRequest.addParameter(CLIENT_TOKEN, clientToken); + return this.invokeHttpClient(internalRequest, responseClass); + } + + private void deviceOperation(AbstractBceRequest request, String endpointName, String parameter) { + Preconditions.checkNotNull(request, "request should not be null."); + Preconditions.checkNotNull(endpointName, "endpoint name should not be null"); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, endpointName, DEVICE); + internalRequest.addParameter(parameter, null); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + return IotDmClientHelper.createRequestForV2(bceRequest, httpMethod, this.getEndpoint(), null, pathVariables); + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java b/src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java new file mode 100644 index 00000000..3f6a2324 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java @@ -0,0 +1,531 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.http.HttpMethodName; +import com.baidubce.internal.InternalRequest; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdm.model.v3.device.CreateDeviceRequest; +import com.baidubce.services.iotdm.model.v3.device.DeviceAccessDetailResponse; +import com.baidubce.services.iotdm.model.v3.device.DeviceListRequest; +import com.baidubce.services.iotdm.model.v3.device.DeviceListResponse; +import com.baidubce.services.iotdm.model.v3.device.DeviceProfileListResponse; +import com.baidubce.services.iotdm.model.v3.device.DeviceProfileResponse; +import com.baidubce.services.iotdm.model.v3.device.DeviceViewResponse; +import com.baidubce.services.iotdm.model.v3.device.UpdateDeviceProfileRequest; +import com.baidubce.services.iotdm.model.v3.device.UpdateDeviceRegistryRequest; +import com.baidubce.services.iotdm.model.v3.device.UpdateDeviceViewRequest; +import com.baidubce.services.iotdm.model.v3.domain.CreateDomainRequest; +import com.baidubce.services.iotdm.model.AccessDetailResponse; +import com.baidubce.services.iotdm.model.v3.domain.DomainDetail; +import com.baidubce.services.iotdm.model.v3.domain.DomainDeviceListResponse; +import com.baidubce.services.iotdm.model.v3.domain.DomainListResponse; +import com.baidubce.services.iotdm.model.v3.domain.UpdateDomainRegistryInfoRequest; +import com.baidubce.services.iotdm.model.v3.domain.UpdateDomainDevicesRequest; +import com.baidubce.services.iotdm.model.v3.domain.UpdateDomainDevicesResponse; +import com.baidubce.services.iotdm.model.v3.rules.DeviceFormatRuleRequest; +import com.baidubce.services.iotdm.model.v3.rules.DeviceFormatRuleResponse; +import com.baidubce.services.iotdm.model.v3.rules.DeviceRuleRequest; +import com.baidubce.services.iotdm.model.v3.rules.DeviceRuleResponse; +import com.baidubce.services.iotdm.model.v3.schema.SchemaCreateRequest; +import com.baidubce.services.iotdm.model.v3.schema.SchemaCreateResponse; +import com.baidubce.services.iotdm.model.v3.schema.SchemaListResponse; +import com.baidubce.services.iotdm.model.v3.schema.SchemaResponse; +import com.baidubce.services.iotdm.model.v3.schema.SchemaUpdateRequest; +import com.google.common.base.Preconditions; + +import org.apache.commons.lang3.StringUtils; + +public class IotDmV3Client extends AbstractBceClient { + + private static final String ENDPOINT_HOST = "iotdm.gz.baidubce.com"; + + private static final String DEVICE = "device"; + private static final String DOMAIN = "domain"; + + private static final String ACCESS_DETAIL = "accessDetail"; + private static final String REMOVE = "remove"; + private static final String RESET = "reset"; + private static final String MODIFY = "modify"; + private static final String DEVICES = "devices"; + private static final String FORMAT = "format"; + + private static final String UPDATE_PROFILE = "updateProfile"; + private static final String UPDATE_REGISTRY = "updateRegistry"; + private static final String UPDATE_SECRET_KEY = "updateSecretKey"; + + private static final String DEVICE_VIEW = "deviceView"; + private static final String UPDATE_VIEW = "updateView"; + + private static final String SCHEMA = "schema"; + + private static final String NULL_DEVICE_NAME = "device name should not be null."; + private static final String NULL_DOMAIN_NAME = "domain name should not be null."; + private static final String NULL_REQUEST = "request should not be null."; + private static final String NULL_SCHEMA_ID = "schema id should not be null."; + private static final String NULL_SOURCES = "sources should not be null"; + private static final String NULL_DESTINATIONS = "destinations should not be null"; + private static final String NULL_FORMAT = "format should not be null"; + + public IotDmV3Client(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT_HOST) : config, + IotDmClientHelper.IOT_DM_HANDLERS); + } + + /** + * Create Device Rule of Device . + * + * @param deviceName Name of Device . + * @param request Params used for create Device Rule . + * @return Device Rule detail . + */ + public DeviceRuleResponse createDeviceRule(String deviceName, DeviceRuleRequest request) { + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + Preconditions.checkNotNull(request, NULL_REQUEST); + + InternalRequest internalRequest = createRequestForRules(request, HttpMethodName.POST, DEVICE, deviceName); + return this.invokeHttpClient(internalRequest, DeviceRuleResponse.class); + } + + /** + * Get Device Rules of Device . + * + * @param deviceName Name of Device . + * @return Device Rule detail . + */ + public DeviceRuleResponse getDeviceRules(String deviceName) { + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + InternalRequest internalRequest = createRequestForRules(new GenericAccountRequest(), HttpMethodName.GET, + DEVICE, deviceName); + return this.invokeHttpClient(internalRequest, DeviceRuleResponse.class); + } + + /** + * Modify Device Rule of Device. + * + * @param deviceName Name of Device . + * @param request Params used for create Device Rule . + * @return Device Rule detail . + */ + public DeviceRuleResponse modifyDeviceRule(String deviceName, DeviceRuleRequest request) { + InternalRequest internalRequest = createRequestForRules(request, HttpMethodName.PUT, + DEVICE, deviceName); + return this.invokeHttpClient(internalRequest, DeviceRuleResponse.class); + } + + /** + * Remove Device Rule of Device . + * + * @param deviceName Name of Device . + */ + public void removeDeviceRule(String deviceName) { + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + InternalRequest internalRequest = createRequestForRules(new GenericAccountRequest(), HttpMethodName.DELETE, + DEVICE, deviceName); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Close Device Rule of Device . + * + * @param deviceName Name of Device . + */ + public void disableDeviceRule(String deviceName) { + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + InternalRequest internalRequest = createRequestForRules(new GenericAccountRequest(), HttpMethodName.PUT, + DEVICE, deviceName); + internalRequest.addParameter("disable", null); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Enable Device Rule of Device . + * + * @param deviceName Name of Device . + */ + public void enableDeviceRule(String deviceName) { + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + InternalRequest internalRequest = createRequestForRules(new GenericAccountRequest(), HttpMethodName.PUT, + DEVICE, deviceName); + internalRequest.addParameter("enable", null); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create TSDB format Rule of Device . + * + * @param deviceName Name of Device . + * @param request Params used for create Device TSDB format Rule . + * @return Device format Rule . + */ + public DeviceFormatRuleResponse createTsdbFormatRule(String deviceName, DeviceFormatRuleRequest request) { + Preconditions.checkNotNull(request, NULL_REQUEST); + Preconditions.checkNotNull(request.getSources(), NULL_SOURCES); + Preconditions.checkNotNull(request.getDestinations(), NULL_DESTINATIONS); + Preconditions.checkNotNull(request.getFormat(), NULL_FORMAT); + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + + InternalRequest internalRequest = createRequestForRules(request, HttpMethodName.POST, DEVICE, + deviceName, FORMAT); + return this.invokeHttpClient(internalRequest, DeviceFormatRuleResponse.class); + } + + /** + * Get TSDB format Rule of Device . + * + * @param deviceName Name of Device . + * @return Device format Rule . + */ + public DeviceFormatRuleResponse getTsdbFormatRule(String deviceName) { + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + InternalRequest internalRequest = createRequestForRules(new GenericAccountRequest(), HttpMethodName.GET, + DEVICE, deviceName, FORMAT); + return this.invokeHttpClient(internalRequest, DeviceFormatRuleResponse.class); + } + + /** + * Modify TSDB format Rule of Device . + * + * @param deviceName Name of Device . + * @param request Params used for modify Device TSDB format Rule . + * @return Device format Rule . + */ + public DeviceFormatRuleResponse modifyTsdbFormatRule(String deviceName, DeviceFormatRuleRequest request) { + InternalRequest internalRequest = createRequestForRules(request, HttpMethodName.PUT, + DEVICE, deviceName, FORMAT); + return this.invokeHttpClient(internalRequest, DeviceFormatRuleResponse.class); + } + + /** + * Create Domain of Device. + * + * @param createDomainRequest Params used for create Domain . + * @return Access detail . + */ + public AccessDetailResponse createDomain(CreateDomainRequest createDomainRequest) { + return doCreation(createDomainRequest, AccessDetailResponse.class, DOMAIN); + } + + /** + * Remove Domain of Device. + * + * @param domainName Name of Domain . + */ + public void removeDomain(String domainName) { + Preconditions.checkNotNull(domainName, NULL_DOMAIN_NAME); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.DELETE, DOMAIN, domainName); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Get Domain of Device . + * + * @param pageNo Page number of Domains . + * @param pageSize Page size of Domains . + * @param orderBy Order by field of Domain . + * @param order ASC or DESC . + * @param key Key to filter Domains . + * @param type Type to filter Domains . + * @param deviceName Name of Device . + * @return Domain list of Device . + */ + public DomainListResponse getDomains(int pageNo, int pageSize, String orderBy, String order, String key, + String type, String deviceName) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.GET, DOMAIN); + addDomainQueryParas(internalRequest, pageNo, pageSize, orderBy, order, key, type, deviceName); + return this.invokeHttpClient(internalRequest, DomainListResponse.class); + } + + /** + * Get Domain detail . + * + * @param domainName Name of Domain . + * @return Domain detail . + */ + public DomainDetail getDomainDetail(String domainName) { + Preconditions.checkNotNull(domainName, NULL_DOMAIN_NAME); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, DOMAIN, domainName); + return this.invokeHttpClient(internalRequest, DomainDetail.class); + } + + /** + * Modify Devices in Domain . + * + * @param domainName Name of Domain . + * @param updateDomainDevicesRequest Params used for Domain Devices . + * @return List of Devices added to Domain and removed from Domain . + */ + public UpdateDomainDevicesResponse modifyDomainDevices(String domainName, + UpdateDomainDevicesRequest updateDomainDevicesRequest) { + Preconditions.checkNotNull(domainName, NULL_DOMAIN_NAME); + return doOperation(updateDomainDevicesRequest, UpdateDomainDevicesResponse.class, + MODIFY, DOMAIN, domainName); + } + + /** + * Modify Domain registery infomation . + * + * @param domainName Name of Domain . + * @param updateDomainRegistryInfoRequest Params used for update Domain registery infomation. + */ + public void modifyDomainRegistryInfo(String domainName, UpdateDomainRegistryInfoRequest + updateDomainRegistryInfoRequest) { + Preconditions.checkNotNull(domainName, NULL_DOMAIN_NAME); + this.doOperation(updateDomainRegistryInfoRequest, AbstractBceResponse.class, + null, DOMAIN, domainName); + } + + /** + * Get Access detail . + * + * @param domainName Name of Domain . + * @return Access detail . + */ + public AccessDetailResponse getDomainAccessDetail(String domainName) { + Preconditions.checkNotNull(domainName, NULL_DOMAIN_NAME); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, DOMAIN, domainName, ACCESS_DETAIL); + return this.invokeHttpClient(internalRequest, AccessDetailResponse.class); + } + + /** + * Update Secret key of Domain . + * + * @param domainName Name of Domain . + * @return Access detail . + */ + public AccessDetailResponse updateDomainSecretKey(String domainName) { + Preconditions.checkNotNull(domainName, NULL_DOMAIN_NAME); + return doOperation(new GenericAccountRequest(), AccessDetailResponse.class, + UPDATE_SECRET_KEY, DOMAIN, domainName); + } + + /** + * Get List of Devices in Domain . + * + * @param domainName Name of Domain . + * @param pageNo Page number of Devices in Domain . + * @param pageSize Page size of Devices in Domain . + * @param orderBy Order by field of Device in Domain . + * @param order ASC or DESC . + * @param name Name to filter Device . + * @param value Value to filter Device . + * @param favourite Favourite to filter Device . + * @return List of Devices in Domain . + */ + public DomainDeviceListResponse getDomainDeviceList(String domainName, int pageNo, int pageSize, String orderBy, + String order, String name, String value, String favourite) { + Preconditions.checkNotNull(domainName, NULL_DOMAIN_NAME); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.GET, DOMAIN, + domainName, DEVICES); + addDomainQueryDeviceParas(internalRequest, pageNo, pageSize, orderBy, order, name, value, favourite); + return this.invokeHttpClient(internalRequest, DomainDeviceListResponse.class); + + } + + public DeviceAccessDetailResponse createDevice(CreateDeviceRequest createDeviceRequest) { + return doCreation(createDeviceRequest, DeviceAccessDetailResponse.class, DEVICE); + } + + public DeviceListResponse removeDevices(DeviceListRequest deviceListRequest) { + return doOperation(deviceListRequest, DeviceListResponse.class, REMOVE, DEVICE); + } + + public DeviceProfileResponse getDeviceProfile(String deviceName) { + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, DEVICE, deviceName); + return this.invokeHttpClient(internalRequest, DeviceProfileResponse.class); + } + + public DeviceProfileResponse updateDeviceProfile(String deviceName, + UpdateDeviceProfileRequest updateDeviceProfileRequest) { + return doOperation(updateDeviceProfileRequest, DeviceProfileResponse.class, + UPDATE_PROFILE, DEVICE, deviceName); + } + + public DeviceProfileListResponse getDeviceProfiles(int pageNo, int pageSize, String orderBy, String order, + String name, String value, String favourite) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.GET, DEVICE); + addDeviceQueryParas(internalRequest, pageNo, pageSize, orderBy, order, name, value, favourite); + return this.invokeHttpClient(internalRequest, DeviceProfileListResponse.class); + } + + public DeviceAccessDetailResponse getDeviceAccessDetail(String deviceName) { + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, DEVICE, deviceName, ACCESS_DETAIL); + return this.invokeHttpClient(internalRequest, DeviceAccessDetailResponse.class); + } + + public DeviceProfileResponse updateDeviceRegistry(String deviceName, + UpdateDeviceRegistryRequest updateDeviceRegistryRequest) { + return doOperation(updateDeviceRegistryRequest, DeviceProfileResponse.class, + UPDATE_REGISTRY, DEVICE, deviceName); + } + + public DeviceAccessDetailResponse updateDeviceSecretKey(String deviceName) { + return doOperation(new GenericAccountRequest(), DeviceAccessDetailResponse.class, + UPDATE_SECRET_KEY, DEVICE, deviceName); + } + + public DeviceListResponse resetDevices(DeviceListRequest request) { + return doOperation(request, DeviceListResponse.class, RESET, DEVICE); + } + + public DeviceViewResponse getDeviceView(String deviceName) { + Preconditions.checkNotNull(deviceName, NULL_DEVICE_NAME); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, DEVICE_VIEW, deviceName); + return this.invokeHttpClient(internalRequest, DeviceViewResponse.class); + } + + public DeviceViewResponse updateDeviceView(String deviceName, + UpdateDeviceViewRequest updateDeviceViewRequest) { + return doOperation(updateDeviceViewRequest, DeviceViewResponse.class, + UPDATE_VIEW, DEVICE_VIEW, deviceName); + } + + public SchemaCreateResponse createSchema(SchemaCreateRequest schemaCreateRequest) { + return doCreation(schemaCreateRequest, SchemaCreateResponse.class, SCHEMA); + } + + public SchemaResponse getSchema(String schemaId) { + Preconditions.checkNotNull(schemaId, NULL_SCHEMA_ID); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, SCHEMA, schemaId); + return this.invokeHttpClient(internalRequest, SchemaResponse.class); + } + + public SchemaListResponse getSchemas(int pageNo, int pageSize, String orderBy, String order, String key) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.GET, SCHEMA); + addSchemaQueryParas(internalRequest, pageNo, pageSize, orderBy, order, key); + return this.invokeHttpClient(internalRequest, SchemaListResponse.class); + } + + public void updateSchema(String schemaId, + SchemaUpdateRequest schemaUpdateRequest) { + this.doOperation(schemaUpdateRequest, AbstractBceResponse.class, null, SCHEMA, schemaId); + } + + public void deleteSchema(String schemaId) { + Preconditions.checkNotNull(schemaId, NULL_SCHEMA_ID); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, + SCHEMA, schemaId); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + + } + + private T doCreation(AbstractBceRequest request, + Class responseClass, String... objectPath) { + Preconditions.checkNotNull(request, NULL_REQUEST); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, objectPath); + return this.invokeHttpClient(internalRequest, responseClass); + } + + private T doOperation(AbstractBceRequest request, Class responseClass, + String parameter, String... pathVariables) { + Preconditions.checkNotNull(request, NULL_REQUEST); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, pathVariables); + if (parameter != null) { + internalRequest.addParameter(parameter, null); + } + + return this.invokeHttpClient(internalRequest, responseClass); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + return IotDmClientHelper.createRequestForV3(bceRequest, httpMethod, this.getEndpoint(), + null, pathVariables); + } + + private InternalRequest createRequestForRules(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + return IotDmClientHelper.createRequestForRules(bceRequest, httpMethod, this.getEndpoint(), + null, pathVariables); + } + + private void addDeviceQueryParas(InternalRequest internalRequest, int pageNo, int pageSize, String orderBy, + String order, String name, String value, String favourite) { + addOrderAndPaginationParas(internalRequest, pageNo, pageSize, orderBy, order); + if (name != null) { + internalRequest.addParameter("name", name); + } + if (value != null) { + internalRequest.addParameter("value", value); + } + if (favourite != null) { + internalRequest.addParameter("favourite", favourite); + } + } + + private void addSchemaQueryParas(InternalRequest internalRequest, + int pageNo, int pageSize, String orderBy, String order, String key) { + addOrderAndPaginationParas(internalRequest, pageNo, pageSize, orderBy, order); + if (key != null) { + internalRequest.addParameter("key", key); + } + } + + private void addDomainQueryParas(InternalRequest internalRequest, int pageNo, int pageSize, String orderBy, + String order, String key, String type, String deviceName) { + addOrderAndPaginationParas(internalRequest, pageNo, pageSize, orderBy, order); + if (StringUtils.isNotBlank(key)) { + internalRequest.addParameter("key", key); + } + if (StringUtils.isBlank(type)) { + type = "ALL"; + } + internalRequest.addParameter("type", type); + + if (StringUtils.isNotBlank(deviceName)) { + internalRequest.addParameter("deviceName", deviceName); + } + } + + private void addDomainQueryDeviceParas(InternalRequest internalRequest, int pageNo, int pageSize, String orderBy, + String order, String name, String value, String favarite) { + addOrderAndPaginationParas(internalRequest, pageNo, pageSize, orderBy, order); + if (StringUtils.isNotBlank(name)) { + internalRequest.addParameter("name", name); + } + if (StringUtils.isNotBlank(value)) { + internalRequest.addParameter("value", value); + } + if (StringUtils.isBlank(favarite)) { + favarite = "all"; + } + internalRequest.addParameter("favarite", favarite); + + } + + private void addOrderAndPaginationParas(InternalRequest internalRequest, + int pageNo, int pageSize, String orderBy, String order) { + internalRequest.addParameter("pageNo", String.valueOf(pageNo)); + internalRequest.addParameter("pageSize", String.valueOf(pageSize)); + if (orderBy != null) { + internalRequest.addParameter("orderBy", orderBy); + } + if (order != null) { + internalRequest.addParameter("order", order); + } + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/AccessDetailResponse.java b/src/main/java/com/baidubce/services/iotdm/model/AccessDetailResponse.java new file mode 100644 index 00000000..d8b7588d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/AccessDetailResponse.java @@ -0,0 +1,78 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model; + +import com.baidubce.model.AbstractBceResponse; + +public class AccessDetailResponse extends AbstractBceResponse { + /** + * Tcp endpoint address . + */ + private String tcpEndpoint; + /** + * Ssl endpoint address . + */ + private String sslEndpoint; + /** + * Wss endpoint address . + */ + private String wssEndpoint; + /** + * Username used for Iothub . + */ + private String username; + /** + * Access key used for Iothub . + */ + private String key; + + public String getTcpEndpoint() { + return tcpEndpoint; + } + + public void setTcpEndpoint(String tcpEndpoint) { + this.tcpEndpoint = tcpEndpoint; + } + + public String getSslEndpoint() { + return sslEndpoint; + } + + public void setSslEndpoint(String sslEndpoint) { + this.sslEndpoint = sslEndpoint; + } + + public String getWssEndpoint() { + return wssEndpoint; + } + + public void setWssEndpoint(String wssEndpoint) { + this.wssEndpoint = wssEndpoint; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/CreateEndpointRequest.java b/src/main/java/com/baidubce/services/iotdm/model/CreateEndpointRequest.java new file mode 100644 index 00000000..550b8bd6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/CreateEndpointRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class CreateEndpointRequest extends AbstractBceRequest { + private String endpointName; + private String newHub; + + public void setEndpointName(String endpointName) { + this.endpointName = endpointName; + } + + public String getEndpointName() { + return endpointName; + } + + public CreateEndpointRequest withEndpointName(String endpointName) { + this.setEndpointName(endpointName); + return this; + } + + public void setNewHub(String newHub) { + this.newHub = newHub; + } + + public String getNewHub() { + return newHub; + } + + public CreateEndpointRequest withNewHub(String newHub) { + this.setNewHub(newHub); + return this; + } + + @Override + public CreateEndpointRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/CreateEndpointResponse.java b/src/main/java/com/baidubce/services/iotdm/model/CreateEndpointResponse.java new file mode 100644 index 00000000..18e76420 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/CreateEndpointResponse.java @@ -0,0 +1,49 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonFormat; + +public class CreateEndpointResponse extends AbstractBceResponse { + private String endpointName; + private String accountUuid; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") + private String createTime; + + public void setEndpointName(String endpointName) { + this.endpointName = endpointName; + } + + public String getEndpointName() { + return endpointName; + } + + public void setAccountUuid(String accountUuid) { + this.accountUuid = accountUuid; + } + + public String getAccountUuid() { + return accountUuid; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateTime() { + return createTime; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceProfile.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceProfile.java index 52b02f44..9b9668ef 100644 --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceProfile.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceProfile.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.JsonNode; /** - * Prepresent the model of device profile. + * Represent the model of device profile. */ public class DeviceProfile { diff --git a/src/main/java/com/baidubce/services/iotdm/model/EndpointInResponse.java b/src/main/java/com/baidubce/services/iotdm/model/EndpointInResponse.java new file mode 100644 index 00000000..fad60593 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/EndpointInResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model; + +import com.fasterxml.jackson.annotation.JsonFormat; + +public class EndpointInResponse { + private String endpointName; + private String accountUuid; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") + private String createTime; + + public void setEndpointName(String endpointName) { + this.endpointName = endpointName; + } + + public String getEndpointName() { + return endpointName; + } + + public void setAccountUuid(String accountUuid) { + this.accountUuid = accountUuid; + } + + public String getAccountUuid() { + return accountUuid; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateTime() { + return createTime; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/GetEndpointsResponse.java b/src/main/java/com/baidubce/services/iotdm/model/GetEndpointsResponse.java new file mode 100644 index 00000000..2574d6f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/GetEndpointsResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.ArrayList; +import java.util.List; + +public class GetEndpointsResponse extends AbstractBceResponse { + private int amount; + private List endpointList = new ArrayList(); + + public void setAmount(int amount) { + this.amount = amount; + } + + public int getAmount() { + return amount; + } + + public void setEndpointList(List endpointList) { + this.endpointList = endpointList; + } + + public List getEndpointList() { + return endpointList; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/CreateDeviceRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/CreateDeviceRequest.java new file mode 100644 index 00000000..4146bb42 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/CreateDeviceRequest.java @@ -0,0 +1,74 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent the request for creating a device. + */ +public class CreateDeviceRequest extends AbstractBceRequest { + + private String deviceName; + + private String description; + + private String schemaId; + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public CreateDeviceRequest withDeviceName(String deviceName) { + setDeviceName(deviceName); + return this; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public CreateDeviceRequest withDescription(String description) { + setDescription(description); + return this; + } + + public String getSchemaId() { + return schemaId; + } + + public void setSchemaId(String schemaId) { + this.schemaId = schemaId; + } + + public CreateDeviceRequest withSchemaId(String schemaId) { + setSchemaId(schemaId); + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAccessDetailResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAccessDetailResponse.java new file mode 100644 index 00000000..0cc4b34f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAccessDetailResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.services.iotdm.model.AccessDetailResponse; + +/** + * Represent the response of getting the access detail of a device. + */ +public class DeviceAccessDetailResponse extends AccessDetailResponse { + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAttributes.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAttributes.java new file mode 100644 index 00000000..835acc8f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAttributes.java @@ -0,0 +1,101 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Represent the model of device attributes. + */ +public class DeviceAttributes { + + private JsonNode reported; + + private JsonNode desired; + + private int profileVersion; + + private TimeAttributes lastUpdatedTime = new TimeAttributes(); + + public JsonNode getReported() { + return reported; + } + + public void setReported(JsonNode reported) { + this.reported = reported; + } + + public DeviceAttributes withReported(JsonNode reported) { + setReported(reported); + return this; + } + + public JsonNode getDesired() { + return desired; + } + + public void setDesired(JsonNode desired) { + this.desired = desired; + } + + public DeviceAttributes withDesired(JsonNode desired) { + setDesired(desired); + return this; + } + + public int getProfileVersion() { + return profileVersion; + } + + public void setProfileVersion(int profileVersion) { + this.profileVersion = profileVersion; + } + + public DeviceAttributes withProfileVersion(int profileVersion) { + setProfileVersion(profileVersion); + return this; + } + + public TimeAttributes getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(TimeAttributes lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + public static class TimeAttributes { + + private JsonNode reported; + + private JsonNode desired; + + public JsonNode getReported() { + return reported; + } + + public void setReported(JsonNode reported) { + this.reported = reported; + } + + public JsonNode getDesired() { + return desired; + } + + public void setDesired(JsonNode desired) { + this.desired = desired; + } + + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceBasicInfoResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceBasicInfoResponse.java new file mode 100644 index 00000000..2f21f438 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceBasicInfoResponse.java @@ -0,0 +1,112 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the response of basic information of a device, + * it is the shared part of a device profile response and a device view response. + */ +public abstract class DeviceBasicInfoResponse extends AbstractBceResponse { + + private String id; + + private String name; + + private String description; + + private Long createTime; + + private String state; + + private Long lastActiveTime; + + private String schemaId; + + private String schemaName; + + private Boolean favourite; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public Long getLastActiveTime() { + return lastActiveTime; + } + + public void setLastActiveTime(Long lastActiveTime) { + this.lastActiveTime = lastActiveTime; + } + + public String getSchemaId() { + return schemaId; + } + + public void setSchemaId(String schemaId) { + this.schemaId = schemaId; + } + + public String getSchemaName() { + return schemaName; + } + + public void setSchemaName(String schemaName) { + this.schemaName = schemaName; + } + + public Boolean getFavourite() { + return favourite; + } + + public void setFavourite(Boolean favourite) { + this.favourite = favourite; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceListRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceListRequest.java new file mode 100644 index 00000000..d4c803bb --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceListRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * Represent the request of a device list. + */ +public class DeviceListRequest extends AbstractBceRequest { + + private List devices; + + public List getDevices() { + return devices; + } + + public DeviceListRequest withDevices(List devices) { + setDevices(devices); + return this; + } + + public void setDevices(List devices) { + this.devices = devices; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceListResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceListResponse.java new file mode 100644 index 00000000..c532b260 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceListResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Represent the response of a device list. + */ +public class DeviceListResponse extends AbstractBceResponse { + + private List devices; + + public List getDevices() { + return devices; + } + + public void setDevices(List devices) { + this.devices = devices; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfile.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfile.java new file mode 100644 index 00000000..9bd014c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfile.java @@ -0,0 +1,123 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Represent the model of a device profile. + */ +public class DeviceProfile { + + + private String name; + + private String description; + + private Long createTime; + + private String state; + + private Long lastActiveTime; + + private String schemaId; + + private String schemaName; + + private Boolean favourite; + + private JsonNode attributes; + + private DeviceAttributes device; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public Long getLastActiveTime() { + return lastActiveTime; + } + + public void setLastActiveTime(Long lastActiveTime) { + this.lastActiveTime = lastActiveTime; + } + + public String getSchemaId() { + return schemaId; + } + + public void setSchemaId(String schemaId) { + this.schemaId = schemaId; + } + + public String getSchemaName() { + return schemaName; + } + + public void setSchemaName(String schemaName) { + this.schemaName = schemaName; + } + + public Boolean getFavourite() { + return favourite; + } + + public void setFavourite(Boolean favourite) { + this.favourite = favourite; + } + + public JsonNode getAttributes() { + return attributes; + } + + public void setAttributes(JsonNode attributes) { + this.attributes = attributes; + } + + public DeviceAttributes getDevice() { + return device; + } + + public void setDevice(DeviceAttributes device) { + this.device = device; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfileListResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfileListResponse.java new file mode 100644 index 00000000..ab29bfc3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfileListResponse.java @@ -0,0 +1,65 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represent the response of getting a device profile list. + */ +public class DeviceProfileListResponse extends AbstractBceResponse { + + private int amount; + + private int pageNo; + + private int pageSize; + + private List devices = new ArrayList(); + + public int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public List getDevices() { + return devices; + } + + public void setDevices(List devices) { + this.devices = devices; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfileResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfileResponse.java new file mode 100644 index 00000000..6a63250b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfileResponse.java @@ -0,0 +1,41 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Represent the response of getting a device profile. + */ +public class DeviceProfileResponse extends DeviceBasicInfoResponse { + + private JsonNode attributes; + + private DeviceAttributes device; + + public JsonNode getAttributes() { + return attributes; + } + + public void setAttributes(JsonNode attributes) { + this.attributes = attributes; + } + + public DeviceAttributes getDevice() { + return device; + } + + public void setDevice(DeviceAttributes device) { + this.device = device; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceViewResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceViewResponse.java new file mode 100644 index 00000000..0637cf77 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceViewResponse.java @@ -0,0 +1,139 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.services.iotdm.model.v3.schema.SchemaProperty; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represent the response of getting a device view. + */ +public class DeviceViewResponse extends DeviceBasicInfoResponse { + + private int profileVersion; + + private List properties = new ArrayList(); + + public int getProfileVersion() { + return profileVersion; + } + + public void setProfileVersion(int profileVersion) { + this.profileVersion = profileVersion; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + public static class DeviceViewAttribute { + + private String attributeName; + + private String showName; + + private String unit; + + private Long reportedTime; + + private Long desiredTime; + + private String reportedValue; + + private String defaultValue; + + private String desiredValue; + + private SchemaProperty.PropertyType type; + + public String getAttributeName() { + return attributeName; + } + + public void setAttributeName(String attributeName) { + this.attributeName = attributeName; + } + + public String getShowName() { + return showName; + } + + public void setShowName(String showName) { + this.showName = showName; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public Long getReportedTime() { + return reportedTime; + } + + public void setReportedTime(Long reportedTime) { + this.reportedTime = reportedTime; + } + + public Long getDesiredTime() { + return desiredTime; + } + + public void setDesiredTime(Long desiredTime) { + this.desiredTime = desiredTime; + } + + public String getReportedValue() { + return reportedValue; + } + + public void setReportedValue(String reportedValue) { + this.reportedValue = reportedValue; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getDesiredValue() { + return desiredValue; + } + + public void setDesiredValue(String desiredValue) { + this.desiredValue = desiredValue; + } + + public SchemaProperty.PropertyType getType() { + return type; + } + + public void setType(SchemaProperty.PropertyType type) { + this.type = type; + } + + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceProfileRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceProfileRequest.java new file mode 100644 index 00000000..d5415696 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceProfileRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Represent the request of updating a device profile. + */ +public class UpdateDeviceProfileRequest extends AbstractBceRequest { + + private JsonNode attributes; + + private DeviceAttributes device; + + public JsonNode getAttributes() { + return attributes; + } + + public void setAttributes(JsonNode attributes) { + this.attributes = attributes; + } + + public UpdateDeviceProfileRequest withAttributes(JsonNode attributes) { + setAttributes(attributes); + return this; + } + + public DeviceAttributes getDevice() { + return device; + } + + public void setDevice(DeviceAttributes device) { + this.device = device; + } + + public UpdateDeviceProfileRequest withDevice(DeviceAttributes device) { + setDevice(device); + return this; + } + + @Override + public UpdateDeviceProfileRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceRegistryRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceRegistryRequest.java new file mode 100644 index 00000000..9e68adfa --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceRegistryRequest.java @@ -0,0 +1,74 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent a request of updating a device registry information. + */ +public class UpdateDeviceRegistryRequest extends AbstractBceRequest { + + private String description; + + private String schemaId; + + private Boolean favourite; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public UpdateDeviceRegistryRequest withDescription(String description) { + setDescription(description); + return this; + } + + public String getSchemaId() { + return schemaId; + } + + public void setSchemaId(String schemaId) { + this.schemaId = schemaId; + } + + public UpdateDeviceRegistryRequest withSchemaId(String schemaId) { + setSchemaId(schemaId); + return this; + } + + public Boolean getFavourite() { + return favourite; + } + + public void setFavourite(Boolean favourite) { + this.favourite = favourite; + } + + public UpdateDeviceRegistryRequest withFavourite(Boolean favourite) { + setFavourite(favourite); + return this; + } + + @Override + public UpdateDeviceRegistryRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceViewRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceViewRequest.java new file mode 100644 index 00000000..45bda0c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceViewRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.device; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Represent the request of updating a device view. + */ +public class UpdateDeviceViewRequest extends AbstractBceRequest { + + private JsonNode reported; + + private JsonNode desired; + + private int profileVersion = 0; + + public JsonNode getReported() { + return reported; + } + + public void setReported(JsonNode reported) { + this.reported = reported; + } + + public UpdateDeviceViewRequest withReported(JsonNode reported) { + setReported(reported); + return this; + } + + public JsonNode getDesired() { + return desired; + } + + public void setDesired(JsonNode desired) { + this.desired = desired; + } + + public UpdateDeviceViewRequest withDesired(JsonNode desired) { + setDesired(desired); + return this; + } + + public int getProfileVersion() { + return profileVersion; + } + + public void setProfileVersion(int profileVersion) { + this.profileVersion = profileVersion; + } + + @Override + public UpdateDeviceViewRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/domain/CreateDomainRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/CreateDomainRequest.java new file mode 100644 index 00000000..4469fba8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/CreateDomainRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.iotdm.model.v3.domain.Domain.DomainType; + +public class CreateDomainRequest extends AbstractBceRequest { + /** + * Name of domain to be created . + */ + private String name; + /** + * Description of domain to be created . + */ + private String description; + /** + * Type of domain to be created . + */ + private DomainType type; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public CreateDomainRequest withName(String name) { + setName(name); + return this; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public CreateDomainRequest withDescription(String description) { + setDescription(description); + return this; + } + + public DomainType getType() { + return type; + } + + public void setType(DomainType type) { + this.type = type; + } + + public CreateDomainRequest withType(DomainType type) { + setType(type); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateDomainRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DeviceInDomain.java b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DeviceInDomain.java new file mode 100644 index 00000000..3fe5b43d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DeviceInDomain.java @@ -0,0 +1,52 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.domain; + +public class DeviceInDomain { + /** + * Name of Device . + */ + private String deviceName; + /** + * Whether Device is in Domian . + */ + private Boolean existed; + /** + * Device number in Domain . + */ + private Integer domainNum; + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public Boolean getExisted() { + return existed; + } + + public void setExisted(Boolean existed) { + this.existed = existed; + } + + public Integer getDomainNum() { + return domainNum; + } + + public void setDomainNum(Integer domainNum) { + this.domainNum = domainNum; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/domain/Domain.java b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/Domain.java new file mode 100644 index 00000000..0be00e25 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/Domain.java @@ -0,0 +1,94 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.domain; + +public class Domain { + /** + * Name of Domain . + */ + private String name; + /** + * Description of Domain . + */ + private String description; + /** + * Type of Domain . + */ + private DomainType type; + /** + * Create time of Domain . + */ + private Long createTime; + /** + * Last updated time of Domain . + */ + private Long lastUpdatedTime; + /** + * Device number in Domain . + */ + private Integer deviceNum; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public DomainType getType() { + return type; + } + + public void setType(DomainType type) { + this.type = type; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public Long getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(Long lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + public Integer getDeviceNum() { + return deviceNum; + } + + public void setDeviceNum(Integer deviceNum) { + this.deviceNum = deviceNum; + } + + public enum DomainType { + ROOT, // Root Privilege . + NORMAL; // Normal Privilege . + + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DomainDetail.java b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DomainDetail.java new file mode 100644 index 00000000..4d122260 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DomainDetail.java @@ -0,0 +1,106 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.domain; + +import com.baidubce.model.AbstractBceResponse; +import com.google.common.collect.Lists; +import com.baidubce.services.iotdm.model.v3.domain.Domain.DomainType; + +import java.util.List; + +public class DomainDetail extends AbstractBceResponse { + /** + * Name of Domain . + */ + private String name; + /** + * Description of Domain . + */ + private String description; + /** + * Type of Domain . + */ + private DomainType type; + /** + * Create time of Domain . + */ + private Long createTime; + /** + * Last updated time of Domain . + */ + private Long lastUpdatedTime; + /** + * Device number in Domain . + */ + private Integer deviceNum; + /** + * List of Devices in Domain . + */ + private List devices = Lists.newArrayList(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public DomainType getType() { + return type; + } + + public void setType(DomainType type) { + this.type = type; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public Long getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(Long lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + public Integer getDeviceNum() { + return deviceNum; + } + + public void setDeviceNum(Integer deviceNum) { + this.deviceNum = deviceNum; + } + + public List getDevices() { + return devices; + } + + public void setDevices(List devices) { + this.devices = devices; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DomainDeviceListResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DomainDeviceListResponse.java new file mode 100644 index 00000000..29d0237b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DomainDeviceListResponse.java @@ -0,0 +1,70 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.domain; + +import com.baidubce.model.AbstractBceResponse; +import com.google.common.collect.Lists; + +import java.util.List; + +public class DomainDeviceListResponse extends AbstractBceResponse { + /** + * Device number in Domain . + */ + private Integer amount; + /** + * Page number of Device in Domain . + */ + private Integer pageNo; + /** + * Page size of Device in Domain . + */ + private Integer pageSize; + /** + * List of Devices in Domain . + */ + private List devices = Lists.newArrayList(); + + + public Integer getAmount() { + return amount; + } + + public void setAmount(Integer amount) { + this.amount = amount; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public List getDevices() { + return devices; + } + + public void setDevices(List devices) { + this.devices = devices; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DomainListResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DomainListResponse.java new file mode 100644 index 00000000..5fa25597 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/DomainListResponse.java @@ -0,0 +1,69 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.domain; + +import com.baidubce.model.AbstractBceResponse; +import com.google.common.collect.Lists; + +import java.util.List; + +public class DomainListResponse extends AbstractBceResponse { + /** + * Domain number . + */ + private int amount; + /** + * Page number of Domains . + */ + private int pageNo; + /** + * Page size of Domains . + */ + private int pageSize; + /** + * List of Domains . + */ + private List domains = Lists.newArrayList(); + + public int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public List getDomains() { + return domains; + } + + public void setDomains(List domains) { + this.domains = domains; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/domain/UpdateDomainDevicesRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/UpdateDomainDevicesRequest.java new file mode 100644 index 00000000..8997e6fc --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/UpdateDomainDevicesRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +public class UpdateDomainDevicesRequest extends AbstractBceRequest { + /** + * List of Devices to be added to Domain . + */ + private List addedDevices; + /** + * List of Devices to be removed from Domain . + */ + private List removedDevices; + + public List getAddedDevices() { + return addedDevices; + } + + public void setAddedDevices(List addedDevices) { + this.addedDevices = addedDevices; + } + + public List getRemovedDevices() { + return removedDevices; + } + + public void setRemovedDevices(List removedDevices) { + this.removedDevices = removedDevices; + } + + public UpdateDomainDevicesRequest withAddedDevices(List addedDevices) { + setAddedDevices(addedDevices); + return this; + } + + public UpdateDomainDevicesRequest withRemovedDevices(List removedDevices) { + setRemovedDevices(removedDevices); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateDomainDevicesRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/domain/UpdateDomainDevicesResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/UpdateDomainDevicesResponse.java new file mode 100644 index 00000000..f1e9f458 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/UpdateDomainDevicesResponse.java @@ -0,0 +1,45 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.domain; + +import com.baidubce.model.AbstractBceResponse; +import com.google.common.collect.Lists; + +import java.util.List; + +public class UpdateDomainDevicesResponse extends AbstractBceResponse { + /** + * List of Devices added to Domain . + */ + private List addedDevices = Lists.newArrayList(); + /** + * List of Devices removed from Domain . + */ + private List removedDevices = Lists.newArrayList(); + + public List getAddedDevices() { + return addedDevices; + } + + public void setAddedDevices(List addedDevices) { + this.addedDevices = addedDevices; + } + + public List getRemovedDevices() { + return removedDevices; + } + + public void setRemovedDevices(List removedDevices) { + this.removedDevices = removedDevices; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/domain/UpdateDomainRegistryInfoRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/UpdateDomainRegistryInfoRequest.java new file mode 100644 index 00000000..bf4694b8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/domain/UpdateDomainRegistryInfoRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.domain; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class UpdateDomainRegistryInfoRequest extends AbstractBceRequest { + /** + * Description of Domain to be updated . + */ + private String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public UpdateDomainRegistryInfoRequest withDescription(String description) { + setDescription(description); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateDomainRegistryInfoRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceFormatRuleRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceFormatRuleRequest.java new file mode 100644 index 00000000..045e7ea9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceFormatRuleRequest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.rules; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class DeviceFormatRuleRequest extends DeviceRuleRequest { + /** + * Format of transfer to TSDB . + */ + private DeviceRuleFormat format; + + public DeviceRuleFormat getFormat() { + return format; + } + + public void setFormat(DeviceRuleFormat format) { + this.format = format; + } + + + public DeviceFormatRuleRequest withFormat(DeviceRuleFormat format) { + setFormat(format); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeviceFormatRuleRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceFormatRuleResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceFormatRuleResponse.java new file mode 100644 index 00000000..b3c008d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceFormatRuleResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.rules; + +public class DeviceFormatRuleResponse extends DeviceRuleResponse { + /** + * Format of transfer to TSDB . + */ + private DeviceRuleFormat format; + + public DeviceRuleFormat getFormat() { + return format; + } + + public void setFormat(DeviceRuleFormat format) { + this.format = format; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleDestination.java b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleDestination.java new file mode 100644 index 00000000..273f6c74 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleDestination.java @@ -0,0 +1,44 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.rules; + +public class DeviceRuleDestination { + /** + * Type of Destination . + */ + private KindType kind; + /** + * Value of Destination . + */ + private String value; + + public KindType getKind() { + return kind; + } + + public void setKind(KindType kind) { + this.kind = kind; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public enum KindType { + TSDB; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleDestinationDetail.java b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleDestinationDetail.java new file mode 100644 index 00000000..7fbfe253 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleDestinationDetail.java @@ -0,0 +1,30 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.rules; + +public class DeviceRuleDestinationDetail extends DeviceRuleDestination { + /** + * ID of Device Rule Destination . + */ + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleFormat.java b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleFormat.java new file mode 100644 index 00000000..9b749dd9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleFormat.java @@ -0,0 +1,72 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.rules; + +import com.fasterxml.jackson.annotation.JsonValue; + +import java.util.Map; + +public class DeviceRuleFormat { + /** + * Mode of Device Rule Format . + */ + private ModeType mode; + /** + * Metric of Device Rule Format . + */ + private String metric; + /** + * List of Tag of Device Rule Format . + */ + private Map tags; + + public ModeType getMode() { + return mode; + } + + public void setMode(ModeType mode) { + this.mode = mode; + } + + public String getMetric() { + return metric; + } + + public void setMetric(String metric) { + this.metric = metric; + } + + public Map getTags() { + return tags; + } + + public void setTags(Map tags) { + this.tags = tags; + } + + public enum ModeType { + METRIC("metric"), // Metric type of Device Rule Format . + FIELD("field"); // Field type of Device Rule Format . + + private String dataType; + + private ModeType(String dataType) { + this.dataType = dataType; + } + + @JsonValue + public String getDataType() { + return dataType; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleRequest.java new file mode 100644 index 00000000..f15da2ce --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleRequest.java @@ -0,0 +1,84 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.rules; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +public class DeviceRuleRequest extends AbstractBceRequest { + /** + * Name of Rule . + */ + private String name; + /** + * List of Device Rule Source . + */ + private List sources; + /** + * List of Device Rule Desctination . + */ + private List destinations; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DeviceRuleRequest withName(String name) { + setName(name); + return this; + } + + public List getSources() { + return sources; + } + + public void setSources(List sources) { + this.sources = sources; + } + + public DeviceRuleRequest withSources(List sources) { + setSources(sources); + return this; + } + + public List getDestinations() { + return destinations; + } + + public void setDestinations(List destinations) { + this.destinations = destinations; + } + + public DeviceRuleRequest withDestinations(List destinations) { + setDestinations(destinations); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeviceRuleRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleResponse.java new file mode 100644 index 00000000..b5bb021c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleResponse.java @@ -0,0 +1,116 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.rules; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +public class DeviceRuleResponse extends AbstractBceResponse { + /** + * ID of Device Rule . + */ + private String id; + /** + * Device name of Device Rule . + */ + private String deviceName; + /** + * Name of Device Rule . + */ + private String name; + /** + * List of Device Rule Source detail . + */ + private List sources; + /** + * List of Device Rule destination detail . + */ + private List destinations; + /** + * Whether open Device Rule or not . + */ + private Boolean enable; + /** + * Create time of Device Rule . + */ + private Long createTime; + /** + * Update time of Device Rule . + */ + private Long updateTime; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getSources() { + return sources; + } + + public void setSources(List sources) { + this.sources = sources; + } + + public List getDestinations() { + return destinations; + } + + public void setDestinations(List destinations) { + this.destinations = destinations; + } + + public Boolean getEnable() { + return enable; + } + + public void setEnable(Boolean enable) { + this.enable = enable; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public Long getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Long updateTime) { + this.updateTime = updateTime; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleSource.java b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleSource.java new file mode 100644 index 00000000..869e63d0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleSource.java @@ -0,0 +1,78 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.rules; + +import com.baidubce.services.iotdm.model.v3.schema.SchemaProperty.PropertyType; + +public class DeviceRuleSource { + /** + * Description of Device Rule . + */ + private String description; + /** + * Name of Device Rule . + */ + private String name; + /** + * Type of Device Rule . + */ + private PropertyType type; + /** + * Condition of Device Rule . + */ + private String condition; + /** + * Value of Device Rule . + */ + private String value; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public PropertyType getType() { + return type; + } + + public void setType(PropertyType type) { + this.type = type; + } + + public String getCondition() { + return condition; + } + + public void setCondition(String condition) { + this.condition = condition; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleSourceDetail.java b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleSourceDetail.java new file mode 100644 index 00000000..fde03bbd --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/rules/DeviceRuleSourceDetail.java @@ -0,0 +1,66 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.rules; + +public class DeviceRuleSourceDetail extends DeviceRuleSource { + /** + * Schema name to be display . + */ + private String displayName; + /** + * Unit of Schema . + */ + private String unit; + /** + * Default value of Schema . + */ + private String defaultValue; + /** + * Last saved time of Device Rule source . + */ + private Long lastSaveTime; + + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + + public Long getLastSaveTime() { + return lastSaveTime; + } + + public void setLastSaveTime(Long lastSaveTime) { + this.lastSaveTime = lastSaveTime; + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/schema/Schema.java b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/Schema.java new file mode 100644 index 00000000..9b1da26d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/Schema.java @@ -0,0 +1,84 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.schema; + +import com.google.common.collect.Lists; + +import java.util.List; + +/** + * Represent the model of Schema. + */ +public class Schema { + + private String id; + + private String name; + + private String description; + + private long createTime; + + private long lastUpdatedTime; + + List properties = Lists.newArrayList(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public long getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(long lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateRequest.java new file mode 100644 index 00000000..a96b0e77 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateRequest.java @@ -0,0 +1,76 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.schema; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * Represent the request of creating a schema. + */ +public class SchemaCreateRequest extends AbstractBceRequest { + + private String name; + + private String description; + + private List properties; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public SchemaCreateRequest withName(String name) { + setName(name); + return this; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public SchemaCreateRequest withDescription(String description) { + setDescription(description); + return this; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + public SchemaCreateRequest withProperties(List properties) { + setProperties(properties); + return this; + } + + @Override + public SchemaCreateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateResponse.java new file mode 100644 index 00000000..359e044f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.schema; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the response of creating a schema. + */ +public class SchemaCreateResponse extends AbstractBceResponse { + + private String schemaId; + + public String getSchemaId() { + return schemaId; + } + + public void setSchemaId(String schemaId) { + this.schemaId = schemaId; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaListResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaListResponse.java new file mode 100644 index 00000000..1ebd7644 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaListResponse.java @@ -0,0 +1,65 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.schema; + +import com.baidubce.model.AbstractBceResponse; +import com.google.common.collect.Lists; + +import java.util.List; + +/** + * Represent the response of getting a schema list. + */ +public class SchemaListResponse extends AbstractBceResponse { + + private int totalCount; + + private int pageNo; + + private int pageSize; + + private List result = Lists.newArrayList(); + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaProperty.java b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaProperty.java new file mode 100644 index 00000000..c33e689a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaProperty.java @@ -0,0 +1,116 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.schema; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Represent the model of Schema Property. + */ +public class SchemaProperty { + + private String name; + + private PropertyType type; + + private String displayName; + + private String defaultValue; + + private String unit; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public SchemaProperty withName(String name) { + setName(name); + return this; + } + + public PropertyType getType() { + return type; + } + + public void setType(PropertyType type) { + this.type = type; + } + + public SchemaProperty withType(PropertyType type) { + setType(type); + return this; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public SchemaProperty withDisplayName(String displayName) { + setDisplayName(displayName); + return this; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public SchemaProperty withDefaultValue(String defaultValue) { + setDefaultValue(defaultValue); + return this; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public SchemaProperty withUnit(String unit) { + setUnit(unit); + return this; + } + + public enum PropertyType { + STRING("string"), + NUMBER("number"), + BOOL("bool"), + OBJECT("object"), + ARRAY("array"); + + private String dataType; + + private PropertyType(String dataType) { + this.dataType = dataType; + } + + @JsonValue + public String getDataType() { + return dataType; + } + + } +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaResponse.java new file mode 100644 index 00000000..b316a022 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaResponse.java @@ -0,0 +1,85 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.schema; + +import com.baidubce.model.AbstractBceResponse; +import com.google.common.collect.Lists; + +import java.util.List; + +/** + * Represent the response of getting a schema. + */ +public class SchemaResponse extends AbstractBceResponse { + + private String id; + + private String name; + + private String description; + + private long createTime; + + private long lastUpdatedTime; + + private List properties = Lists.newArrayList(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public long getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(long lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaUpdateRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaUpdateRequest.java new file mode 100644 index 00000000..ca8cb06e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaUpdateRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2017 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdm.model.v3.schema; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.List; + +/** + * Represent the request of updating a schema. + */ +public class SchemaUpdateRequest extends AbstractBceRequest { + + private String description; + + private List properties; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public SchemaUpdateRequest withDescription(String description) { + setDescription(description); + return this; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + public SchemaUpdateRequest withProperties(List properties) { + setProperties(properties); + return this; + } + + @Override + public SchemaUpdateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iotdmp/PlatformClient.java b/src/main/java/com/baidubce/services/iotdmp/PlatformClient.java new file mode 100644 index 00000000..580feca2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/PlatformClient.java @@ -0,0 +1,3426 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.CommonListRequest; +import com.baidubce.services.iotdmp.model.CommonResult; +import com.baidubce.services.iotdmp.model.alarm.AlarmRecordInfo; +import com.baidubce.services.iotdmp.model.alarm.AlarmRuleInfo; +import com.baidubce.services.iotdmp.model.alarm.BatchDeleteAlarmRuleRequest; +import com.baidubce.services.iotdmp.model.alarm.BatchProcessAlarmRecordRequest; +import com.baidubce.services.iotdmp.model.alarm.CreateAlarmRuleRequest; +import com.baidubce.services.iotdmp.model.alarm.ListAlarmRecordRequest; +import com.baidubce.services.iotdmp.model.alarm.ListAlarmRecordResponse; +import com.baidubce.services.iotdmp.model.alarm.ListAlarmRuleResponse; +import com.baidubce.services.iotdmp.model.alarm.TriggerAlarmRequest; +import com.baidubce.services.iotdmp.model.alarm.UpdateAlarmRuleRequest; +import com.baidubce.services.iotdmp.model.bie.app.AppResponse; +import com.baidubce.services.iotdmp.model.bie.app.ListNodeAppsResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.AppAction; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.AppInfoListResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.BindSubDeviceRequest; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.BusinessTemplatesListResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.DriverInfo; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.DriverListResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.GetAccesstemplatesResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.GetAppInfoResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.GetAppListRequest; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.GetBieDeviceConfigResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.GetBieDeviceListResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.GetBusinessTemplateRequest; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.GetEdgeGatewayNodeDetailResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.GetNodeAppInfoResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.GetNodeDriverRefsRequest; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.ListEdgeGatewayNodeRequest; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.ListEdgeGatewayNodeResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.UnbindEdgeGatewayDriverSubDeviceListRequest; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.UnbindEdgeGatewayDriverSubDeviceListResponse; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.UpdateEdgeGatewayNodeDriverConfigRequest; +import com.baidubce.services.iotdmp.model.bie.edge.gateway.UpdateEdgeGatewaySubDeviceConfigRequest; +import com.baidubce.services.iotdmp.model.bie.node.CreateNodeRequest; +import com.baidubce.services.iotdmp.model.bie.node.DeployBusinessTemplatesRequest; +import com.baidubce.services.iotdmp.model.bie.node.GetInstallNodeInitResponse; +import com.baidubce.services.iotdmp.model.bie.node.GetInstallNodePropertyResponse; +import com.baidubce.services.iotdmp.model.bie.node.InstallMethod; +import com.baidubce.services.iotdmp.model.bie.node.InstallPlatform; +import com.baidubce.services.iotdmp.model.bie.node.ListNodeResponse; +import com.baidubce.services.iotdmp.model.bie.node.ModifyNodeRequest; +import com.baidubce.services.iotdmp.model.bie.node.NodeResponse; +import com.baidubce.services.iotdmp.model.bie.protocol.BusinessTemplatesApp; +import com.baidubce.services.iotdmp.model.bie.protocol.BusinessTemplatesAppRegistry; +import com.baidubce.services.iotdmp.model.bie.protocol.BusinessTemplatesAppRegistryList; +import com.baidubce.services.iotdmp.model.bie.protocol.BusinessTemplatesAppRegistryRequest; +import com.baidubce.services.iotdmp.model.bie.protocol.BusinessTemplatesAppRequest; +import com.baidubce.services.iotdmp.model.bie.protocol.CreateProtocolRequest; +import com.baidubce.services.iotdmp.model.bie.protocol.ListProtocolResponse; +import com.baidubce.services.iotdmp.model.bie.protocol.ProtocolResponse; +import com.baidubce.services.iotdmp.model.bie.protocol.ProtocolsMarkdownRequest; +import com.baidubce.services.iotdmp.model.bie.protocol.ProtocolsMarkdownResponse; +import com.baidubce.services.iotdmp.model.c2c.ComputationSourceResponse; +import com.baidubce.services.iotdmp.model.component.BindComponentRequest; +import com.baidubce.services.iotdmp.model.component.ListBindComponentResponse; +import com.baidubce.services.iotdmp.model.device.AuthRequest; +import com.baidubce.services.iotdmp.model.device.AuthType; +import com.baidubce.services.iotdmp.model.device.BatchCreateDeviceRequest; +import com.baidubce.services.iotdmp.model.device.BatchDeleteDeviceRequest; +import com.baidubce.services.iotdmp.model.device.CreateDeviceRequest; +import com.baidubce.services.iotdmp.model.device.DeviceInfo; +import com.baidubce.services.iotdmp.model.device.DeviceKey; +import com.baidubce.services.iotdmp.model.device.DeviceResourcesConnectionInfo; +import com.baidubce.services.iotdmp.model.device.GetDeviceConnectionInfoRequest; +import com.baidubce.services.iotdmp.model.device.ListDeviceKeyRequest; +import com.baidubce.services.iotdmp.model.device.ListDeviceRequest; +import com.baidubce.services.iotdmp.model.device.ListDeviceResponse; +import com.baidubce.services.iotdmp.model.device.ListDeviceStatesResponse; +import com.baidubce.services.iotdmp.model.device.UpdateDeviceRequest; +import com.baidubce.services.iotdmp.model.device.UpdateDeviceStateRequest; +import com.baidubce.services.iotdmp.model.device.batch.BatchDownloadMqtt; +import com.baidubce.services.iotdmp.model.device.batch.BatchInfoResponse; +import com.baidubce.services.iotdmp.model.device.batch.GetBatchPageResponse; +import com.baidubce.services.iotdmp.model.device.batch.GetBatchTuplesResponse; +import com.baidubce.services.iotdmp.model.device.evs.AddEvsDeviceRequest; +import com.baidubce.services.iotdmp.model.device.evs.EvsDeviceInfo; +import com.baidubce.services.iotdmp.model.device.evs.EvsDurationRequest; +import com.baidubce.services.iotdmp.model.device.evs.EvsPtzRequest; +import com.baidubce.services.iotdmp.model.device.evs.EvsUrlProtocol; +import com.baidubce.services.iotdmp.model.device.evs.GetEvsChannelResponse; +import com.baidubce.services.iotdmp.model.device.evs.GetEvsChannelUrlResponse; +import com.baidubce.services.iotdmp.model.device.evs.GetEvsRecordingResponse; +import com.baidubce.services.iotdmp.model.device.evs.GetEvsThumbnailResponse; +import com.baidubce.services.iotdmp.model.device.evs.UpdateEvsDeviceRequest; +import com.baidubce.services.iotdmp.model.device.tag.ListTagResponse; +import com.baidubce.services.iotdmp.model.device.topic.ListTopicResponse; +import com.baidubce.services.iotdmp.model.device.topo.DeviceSubsetsFileResponse; +import com.baidubce.services.iotdmp.model.fm.AddConfigRequest; +import com.baidubce.services.iotdmp.model.fm.AddTaskRequest; +import com.baidubce.services.iotdmp.model.fm.ConfigManagementListResponse; +import com.baidubce.services.iotdmp.model.fm.ConfigManagementResponse; +import com.baidubce.services.iotdmp.model.fm.ConfigTaskDetailListResponse; +import com.baidubce.services.iotdmp.model.fm.ConfigTaskListResponse; +import com.baidubce.services.iotdmp.model.fm.ConfigVersionListResponse; +import com.baidubce.services.iotdmp.model.fm.GetConfigVersionResponse; +import com.baidubce.services.iotdmp.model.group.CreateGroupRequest; +import com.baidubce.services.iotdmp.model.group.GroupInfo; +import com.baidubce.services.iotdmp.model.group.ListDeviceByGroupResponse; +import com.baidubce.services.iotdmp.model.group.ListGroupRequest; +import com.baidubce.services.iotdmp.model.group.ListGroupResponse; +import com.baidubce.services.iotdmp.model.group.UpdateGroupInfoRequest; +import com.baidubce.services.iotdmp.model.handler.BceDmpHandler; +import com.baidubce.services.iotdmp.model.instance.CreateInstanceRequest; +import com.baidubce.services.iotdmp.model.instance.ExtensionResourceResponse; +import com.baidubce.services.iotdmp.model.instance.InstanceInfo; +import com.baidubce.services.iotdmp.model.instance.ListInstanceResourceResponse; +import com.baidubce.services.iotdmp.model.instance.ListInstancesResponse; +import com.baidubce.services.iotdmp.model.instance.ResourceSupplier; +import com.baidubce.services.iotdmp.model.instance.ResourceType; +import com.baidubce.services.iotdmp.model.instance.UpdateInstanceRequest; +import com.baidubce.services.iotdmp.model.instance.UpdateInstanceResourcePropertiesRequest; +import com.baidubce.services.iotdmp.model.linkage.BatchDeleteLinkageRuleRequest; +import com.baidubce.services.iotdmp.model.linkage.CreateLinkageRuleRequest; +import com.baidubce.services.iotdmp.model.linkage.CreateLinkageRuleResponse; +import com.baidubce.services.iotdmp.model.linkage.LinkageRuleInfo; +import com.baidubce.services.iotdmp.model.linkage.ListLinkageRuleResponse; +import com.baidubce.services.iotdmp.model.linkage.UpdateLinkageRuleRequest; +import com.baidubce.services.iotdmp.model.ota.CommonOtaListRequest; +import com.baidubce.services.iotdmp.model.ota.device.ListAllTestDeviceForTaskResponse; +import com.baidubce.services.iotdmp.model.ota.device.SearchDeviceForTaskResponse; +import com.baidubce.services.iotdmp.model.ota.device.SearchType; +import com.baidubce.services.iotdmp.model.ota.packages.CheckOtaPackageRequest; +import com.baidubce.services.iotdmp.model.ota.packages.CheckOtaPackageResponse; +import com.baidubce.services.iotdmp.model.ota.packages.ListOtaPackageRequest; +import com.baidubce.services.iotdmp.model.ota.packages.ListOtaPackageResponse; +import com.baidubce.services.iotdmp.model.ota.packages.OSStsResponse; +import com.baidubce.services.iotdmp.model.ota.packages.Type; +import com.baidubce.services.iotdmp.model.ota.packages.UploadOtaPackageRequest; +import com.baidubce.services.iotdmp.model.ota.packages.UploadOtaPackageResponse; +import com.baidubce.services.iotdmp.model.ota.packing.CancelOtaPackingResponse; +import com.baidubce.services.iotdmp.model.ota.packing.CreateOtaPackingRequest; +import com.baidubce.services.iotdmp.model.ota.packing.CreateOtaPackingResponse; +import com.baidubce.services.iotdmp.model.ota.packing.DeleteOtaPackingResponse; +import com.baidubce.services.iotdmp.model.ota.packing.GetOtaPackingStatusResponse; +import com.baidubce.services.iotdmp.model.ota.packing.ListOtaCompletedPackingResponse; +import com.baidubce.services.iotdmp.model.ota.packing.ListOtaUncompletedPackingResponse; +import com.baidubce.services.iotdmp.model.ota.product.CreateOtaProductRequest; +import com.baidubce.services.iotdmp.model.ota.product.CreateOtaProductResponse; +import com.baidubce.services.iotdmp.model.ota.product.ListOtaProductOperationRequest; +import com.baidubce.services.iotdmp.model.ota.product.ListOtaProductOperationResponse; +import com.baidubce.services.iotdmp.model.ota.product.ListOtaProductRequest; +import com.baidubce.services.iotdmp.model.ota.product.ListOtaProductResponse; +import com.baidubce.services.iotdmp.model.ota.product.OtaProductConfig; +import com.baidubce.services.iotdmp.model.ota.product.OtaProductDetail; +import com.baidubce.services.iotdmp.model.ota.statistics.OtaTaskIssuedFailedStatisticsResponse; +import com.baidubce.services.iotdmp.model.ota.statistics.OtaTaskIssuedFailureInfoStatisticsResponse; +import com.baidubce.services.iotdmp.model.ota.statistics.OtaTaskIssuedStatisticsResponse; +import com.baidubce.services.iotdmp.model.ota.statistics.OtaTaskProductLineWeekStatisticsResponse; +import com.baidubce.services.iotdmp.model.ota.statistics.OtaTaskStageStatisticsResponse; +import com.baidubce.services.iotdmp.model.ota.statistics.OtaTaskStatisticsResponse; +import com.baidubce.services.iotdmp.model.ota.statistics.Stage; +import com.baidubce.services.iotdmp.model.ota.task.CreateOrUpdateGrayTaskRequest; +import com.baidubce.services.iotdmp.model.ota.task.CreateOtaTaskRequest; +import com.baidubce.services.iotdmp.model.ota.task.CreateOtaTaskResponse; +import com.baidubce.services.iotdmp.model.ota.task.DeleteOtaTaskRequest; +import com.baidubce.services.iotdmp.model.ota.task.GetOtaTaskResponse; +import com.baidubce.services.iotdmp.model.ota.task.GrayTask; +import com.baidubce.services.iotdmp.model.ota.task.ListOtaTaskRequest; +import com.baidubce.services.iotdmp.model.ota.task.UpdateOtaTaskRequest; +import com.baidubce.services.iotdmp.model.ota.task.UpdateOtaTaskResponse; +import com.baidubce.services.iotdmp.model.ota.task.UpdateOtaTaskStatusRequest; +import com.baidubce.services.iotdmp.model.ota.task.UpdateOtaTaskStatusResponse; +import com.baidubce.services.iotdmp.model.ota.task.ListOtaTaskResponse; +import com.baidubce.services.iotdmp.model.platform.AuthRuleChainExternalDestinationResponse; +import com.baidubce.services.iotdmp.model.platform.BatchDeleteRuleChainExternalDestinationRequest; +import com.baidubce.services.iotdmp.model.platform.BatchDeleteRuleChainRequest; +import com.baidubce.services.iotdmp.model.platform.CreateRuleChainExternalDestinationRequest; +import com.baidubce.services.iotdmp.model.platform.CreateRuleChainExternalDestinationRequestV2; +import com.baidubce.services.iotdmp.model.platform.CreateRuleChainExternalDestinationResponse; +import com.baidubce.services.iotdmp.model.platform.CreateRuleChainRequest; +import com.baidubce.services.iotdmp.model.platform.CreateRuleChainResponse; +import com.baidubce.services.iotdmp.model.platform.ListRuleChainDestinationRequest; +import com.baidubce.services.iotdmp.model.platform.ListRuleChainDestinationResponse; +import com.baidubce.services.iotdmp.model.platform.ListRuleChainRequest; +import com.baidubce.services.iotdmp.model.platform.ListRuleChainResponse; +import com.baidubce.services.iotdmp.model.platform.PlatformRuleChainInfo; +import com.baidubce.services.iotdmp.model.platform.RuleChainExternalDestinationType; +import com.baidubce.services.iotdmp.model.platform.UpdatePlatformRuleChainRequest; +import com.baidubce.services.iotdmp.model.platform.UpdateRuleChainStateRequest; +import com.baidubce.services.iotdmp.model.platform.UploadKafkaConfigFileResponse; +import com.baidubce.services.iotdmp.model.platform.ValidateRuleChainRequest; +import com.baidubce.services.iotdmp.model.platform.ValidateRuleChainResponse; +import com.baidubce.services.iotdmp.model.product.CreateProductByModelRequest; +import com.baidubce.services.iotdmp.model.product.CreateProductInfoRequest; +import com.baidubce.services.iotdmp.model.product.CreateTagRequest; +import com.baidubce.services.iotdmp.model.product.ImportProductModelRequest; +import com.baidubce.services.iotdmp.model.product.ListProductCategoryResponse; +import com.baidubce.services.iotdmp.model.product.ListProductModelRequest; +import com.baidubce.services.iotdmp.model.product.ListProductModelResponse; +import com.baidubce.services.iotdmp.model.product.ListProductRequest; +import com.baidubce.services.iotdmp.model.product.ListProductResponse; +import com.baidubce.services.iotdmp.model.product.PermanentConnectRequest; +import com.baidubce.services.iotdmp.model.product.ProductInfo; +import com.baidubce.services.iotdmp.model.product.ProductModelInfo; +import com.baidubce.services.iotdmp.model.product.UpdateProductInfoRequest; +import com.baidubce.services.iotdmp.model.product.evs.CreateEvsSpaceRequest; +import com.baidubce.services.iotdmp.model.product.evs.EvsSpaceInfo; +import com.baidubce.services.iotdmp.model.product.evs.GetEvsStreamResponse; +import com.baidubce.services.iotdmp.model.product.evs.UpdateEvsSpaceRequest; +import com.baidubce.services.iotdmp.model.product.feature.DtmlDetailResponse; +import com.baidubce.services.iotdmp.model.product.feature.command.CreateFeatureCommandRequest; +import com.baidubce.services.iotdmp.model.product.feature.command.ListFeatureCommandResponse; +import com.baidubce.services.iotdmp.model.product.feature.command.ProductFeatureCommandInfo; +import com.baidubce.services.iotdmp.model.product.feature.command.UpdateProductCommandRequest; +import com.baidubce.services.iotdmp.model.product.feature.event.CreateFeatureEventRequest; +import com.baidubce.services.iotdmp.model.product.feature.event.ListFeatureEventResponse; +import com.baidubce.services.iotdmp.model.product.feature.event.ProductFeatureEventInfo; +import com.baidubce.services.iotdmp.model.product.feature.event.UpdateProductEventRequest; +import com.baidubce.services.iotdmp.model.product.feature.property.CreateFeaturePropertyRequest; +import com.baidubce.services.iotdmp.model.product.feature.property.ListFeaturePropertyResponse; +import com.baidubce.services.iotdmp.model.product.feature.property.ProductFeaturePropertyInfo; +import com.baidubce.services.iotdmp.model.product.feature.property.UpdateProductPropertyRequest; +import com.baidubce.services.iotdmp.model.product.feature.thing.Thing; +import com.baidubce.services.iotdmp.model.product.repositories.SaveCustomProductModelRequest; +import com.baidubce.services.iotdmp.model.product.repositories.SaveCustomProductModelResponse; +import com.baidubce.services.iotdmp.model.product.repositories.SimpleProductModelInfo; +import com.baidubce.services.iotdmp.model.product.repositories.UpdateCustomProductModelRequest; +import com.baidubce.services.iotdmp.model.product.version.ListVersionResponse; +import com.baidubce.services.iotdmp.model.service.ConsumerGroupQueueInfoResponse; +import com.baidubce.services.iotdmp.model.service.ConsumerGroupUserInfoResponse; +import com.baidubce.services.iotdmp.model.service.CreateConsumerGroupRequest; +import com.baidubce.services.iotdmp.model.service.CreateConsumerGroupResponse; +import com.baidubce.services.iotdmp.model.service.GetBridgeListResponse; +import com.baidubce.services.iotdmp.model.service.ListConsumerGroupResponse; +import com.baidubce.services.iotdmp.model.service.ListInstanceServiceStateResponse; +import com.baidubce.services.iotdmp.model.service.ListSubResponse; +import com.baidubce.services.iotdmp.model.service.ProductSubscriptionResponse; +import com.baidubce.services.iotdmp.model.service.ResetConsumerGroupUserPwdResponse; +import com.baidubce.services.iotdmp.model.service.SendMessageRequest; +import com.baidubce.services.iotdmp.model.service.ServiceInfoResponse; +import com.baidubce.services.iotdmp.model.service.UpdateProductSubscriptionRequest; +import com.baidubce.services.iotdmp.model.service.rulechain.AvailableMessageTypeResponse; +import com.baidubce.services.iotdmp.model.service.rulechain.BlinkDataPermission; +import com.baidubce.services.iotdmp.model.service.rulechain.TopicDecodeRequest; +import com.baidubce.services.iotdmp.model.service.rulechain.TopicDecodeResponse; +import com.baidubce.services.iotdmp.model.service.rulechain.TopicEncodeRequest; +import com.baidubce.services.iotdmp.model.service.rulechain.TopicEncodeResponse; +import com.baidubce.services.iotdmp.model.shadow.DeviceShadowResponse; +import com.baidubce.services.iotdmp.model.shadow.ListDeviceShadowRequest; +import com.baidubce.services.iotdmp.model.shadow.ListDeviceShadowSnapshotResponse; +import com.baidubce.services.iotdmp.model.shadow.ShadowStatesRequest; +import com.baidubce.services.iotdmp.model.shadow.UpdateDesiredRequest; +import com.baidubce.services.iotdmp.model.statistics.Cycle; +import com.baidubce.services.iotdmp.model.statistics.DeviceStatesStatsResult; +import com.baidubce.services.iotdmp.model.statistics.StatsDeviceMessageResponse; +import com.baidubce.services.iotdmp.model.statistics.StatsDeviceTotalResponse; +import com.baidubce.services.iotdmp.model.statistics.StatsLivelyDeviceResponse; +import com.baidubce.services.iotdmp.model.statistics.StatsProductTotalResponse; +import com.baidubce.services.iotdmp.model.tsdb.TsdbInitRequest; +import com.baidubce.services.iotdmp.model.tsdb.TsdbMappingRequest; +import com.baidubce.services.iotdmp.model.tsdb.TsdbMappingResponse; +import com.baidubce.services.iotdmp.model.tsdb.TsdbQueryRequest; +import com.baidubce.services.iotdmp.model.tsdb.TsdbQueryResponse; +import com.baidubce.services.iotdmp.model.userlog.ListUserLogRequest; +import com.baidubce.services.iotdmp.model.userlog.ListUserLogResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import org.apache.commons.httpclient.methods.multipart.FilePart; +import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; +import org.apache.commons.httpclient.methods.multipart.Part; +import org.apache.commons.httpclient.params.HttpMethodParams; +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +public class PlatformClient extends AbstractBceClient { + + private static final String ENDPOINT = "TBD"; + private static final String VERSION = "v1"; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + private static final String INSTANCE = "instances"; + private static final String EXTENSION = "extensions"; + private static final String AVAILABLE = "available"; + private static final String CONFIG = "config"; + private static final String ENABLED = "enabled"; + private static final String ENABLE = "enable"; + private static final String PLATFORM_RULECHAINS = "platform/rulechains"; + private static final String PLATFORM_LINKAGES = "platform/linkages"; + private static final String BATCH_DELETE = "batchDelete"; + private static final String UPDATE_STATE = "updateState"; + private static final String COMPUTE = "compute"; + private static final String DESTINATIONS = "destinations"; + private static final String SERVICE = "services"; + private static final String C2C = "c2c"; + private static final String DEVICES = "devices"; + private static final String SECRET = "secret"; + private static final String TOPICS = "topics"; + private static final String TAGS = "tags"; + private static final String KEY = "key"; + private static final String EVS = "evs"; + private static final String CHANNEL = "channel"; + private static final String PTZ = "ptz"; + private static final String THUMBNAIL = "thumbnail"; + private static final String RECORDING = "recording"; + private static final String RESOURCES = "resources"; + private static final String STATES = "states"; + private static final String STATE = "state"; + private static final String AUTH = "auth"; + private static final String SHADOWS = "shadows"; + private static final String SHADOW = "shadow"; + private static final String DESIRED = "desired"; + private static final String SIGNED_URL = "signedUrl"; + private static final String PRODUCTS = "products"; + private static final String PRODUCT = "product"; + private static final String PERMANENT_CONNECT = "permanentConnect"; + private static final String FEATURE = "features"; + private static final String DETAIL = "detail"; + private static final String COMMAND = "commands"; + private static final String EVENT = "events"; + private static final String PROPERTIES = "properties"; + private static final String MESSAGES = "messages"; + private static final String BLINK = "blink"; + private static final String ENCODE = "encode"; + private static final String DECODE = "decode"; + private static final String MESSAGE = "message"; + private static final String TYPES = "types"; + private static final String TYPE = "type"; + private static final String SOURCE = "sources"; + private static final String SINK = "sinks"; + private static final String CONSUMER = "consumers"; + private static final String USER = "user"; + private static final String RESET = "reset"; + private static final String SUBSCRIPTIONS = "subscriptions"; + private static final String BATCH = "batch"; + private static final String SUBSET = "subsets"; + private static final String DELETE = "delete"; + private static final String GATEWAY = "gateway"; + private static final String DOWNWARD = "downward"; + private static final String LOG = "logs"; + private static final String GROUPS = "groups"; + private static final String EXPORT = "export"; + private static final String COMPONENTS = "components"; + private static final String VERIFY = "verify"; + private static final String CATEGORIES = "categories"; + private static final String REPOSITORIES = "repositories"; + private static final String MODELS = "models"; + private static final String INFO = "info"; + private static final String ALARMS = "alarms"; + private static final String RULES = "rules"; + private static final String TRIGGER = "trigger"; + private static final String RECORDS = "records"; + private static final String PROCESS = "process"; + private static final String FM = "fm"; + private static final String CONFIG_VERSION = "version"; + private static final String URL = "url"; + private static final String VERSIONS = "versions"; + private static final String TASK = "task"; + private static final String CSV = "csv"; + private static final String IMPORT = "import"; + private static final String TEST = "test"; + private static final String OTA = "ota"; + private static final String OPERATION = "operation"; + private static final String PACKAGES = "packages"; + private static final String CHECK = "check"; + private static final String STS = "sts"; + private static final String STATISTICS = "statistics"; + private static final String ISSUED = "issued"; + private static final String FAILED = "failed"; + private static final String FAILURES = "failures"; + private static final String STATUS = "status"; + private static final String GRAY = "gray"; + private static final String STAGE = "stage"; + private static final String WEEK = "week"; + private static final String COMPLETED = "completed"; + private static final String UNCOMPLETED = "uncompleted"; + private static final String PACKING = "packing"; + private static final String CANCEL = "cancel"; + private static final String MQTT = "mqtt"; + private static final String DOWNLOAD = "download"; + private static final String LIVELY = "lively"; + private static final String TOTAL = "total"; + private static final String DISABLE = "disable"; + private static final String UNBIND = "unbind"; + private static final String FILE = "file"; + private static final String EXTERNAL_KAFKA = "external-kafka"; + private static final String TSDB = "tsdb"; + private static final String QUERY = "query"; + private static final String MAPPING = "mapping"; + private static final String CUSTOM = "custom"; + private static final String PROTOCOLS = "protocols"; + private static final String APP = "app"; + private static final String REGISTRIES = "registries"; + private static final String MARKDOWN = "markdown"; + private static final String NODES = "nodes"; + private static final String INIT = "init"; + private static final String DEPLOY = "deploy"; + private static final String APPS = "apps"; + private static final String EDGE = "edge"; + private static final String ENV = "env"; + private static final String DRIVERREFS = "driverrefs"; + private static final String INTRODUCE = "introduce"; + private static final String DRIVER = "driver"; + private static final String DRIVERS = "drivers"; + private static final String SYNC = "sync"; + private static final String DEVICE = "device"; + private static final String BIND = "bind"; + private static final String ACCESSTEMPLATES = "accesstemplates"; + private static final String DEVICEMODELS = "devicemodels"; + private static final String NODEDEVICES = "nodedevices"; + private static final String SUB_DEVICE = "subDevice"; + private static final String BUSINESSTEMPLATES = "businesstemplates"; + private static final String VERSION_PATH = "version"; + private static final String PUBLISH = "publish"; + + private static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceDmpHandler() }; + + public PlatformClient(String accessKey, String secretKey) { + this(new BceClientConfiguration() + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)) + .withEndpoint(ENDPOINT)); + } + + public PlatformClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, HANDLERS); + } + + // Instance API + public InstanceInfo getInstance(String instanceId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, INSTANCE, instanceId); + return invokeHttpClient(internalRequest, InstanceInfo.class); + } + + public ListInstancesResponse listInstances(int pageNo, int pageSize) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, INSTANCE); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListInstancesResponse.class); + } + + public InstanceInfo createInstance(CreateInstanceRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, INSTANCE); + return invokeHttpClient(internalRequest, InstanceInfo.class); + } + + public CommonResult deleteInstance(String instanceId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, INSTANCE, instanceId); + return invokeHttpClient(internalRequest, CommonResult.class); + } + + public InstanceInfo updateInstance(String instanceId, UpdateInstanceRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, INSTANCE, instanceId); + return invokeHttpClient(internalRequest, InstanceInfo.class); + } + + // extensions + public ExtensionResourceResponse getConfigExtensionResources(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, EXTENSION, CONFIG); + return invokeHttpClient(internalRequest, ExtensionResourceResponse.class); + } + + public ExtensionResourceResponse getConfigExtensionResources(String instanceId, String productKey, + String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + DEVICES, instanceId, productKey, deviceName, EXTENSION, CONFIG); + return invokeHttpClient(internalRequest, ExtensionResourceResponse.class); + } + + public ExtensionResourceResponse getEnabledExtensionResources(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, + instanceId, productKey, EXTENSION, ENABLED); + return invokeHttpClient(internalRequest, ExtensionResourceResponse.class); + } + + + public ExtensionResourceResponse getEnabledExtensionResources(String instanceId, String productKey, + String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + DEVICES, instanceId, productKey, deviceName, EXTENSION, ENABLED); + return invokeHttpClient(internalRequest, ExtensionResourceResponse.class); + } + + public ListInstanceResourceResponse listInstanceResources(String instanceId, ResourceSupplier supplier) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + INSTANCE, instanceId, RESOURCES); + internalRequest.addParameter("supplier", supplier.name()); + return invokeHttpClient(internalRequest, ListInstanceResourceResponse.class); + } + + public void updateResourceProperties(String instanceId, UpdateInstanceResourcePropertiesRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + INSTANCE, instanceId, RESOURCES); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void enableResource(String instanceId, ResourceSupplier supplier, ResourceType resourceType) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + INSTANCE, instanceId, RESOURCES, ENABLE); + internalRequest.addParameter("supplier", supplier.name()); + internalRequest.addParameter("resourceType", resourceType.name()); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void verifyResourceProperties(String instanceId, UpdateInstanceResourcePropertiesRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + INSTANCE, instanceId, RESOURCES, VERIFY); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // Platform API + public CreateRuleChainResponse createRuleChain (String instanceId, CreateRuleChainRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PLATFORM_RULECHAINS, instanceId); + return invokeHttpClient(internalRequest, CreateRuleChainResponse.class); + } + + public void deleteRuleChain (String instanceId, BatchDeleteRuleChainRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PLATFORM_RULECHAINS, instanceId, BATCH_DELETE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void updateRuleChain (String instanceId, String rulechainId, + UpdatePlatformRuleChainRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, PLATFORM_RULECHAINS, instanceId, rulechainId); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void updateRuleChainState (String instanceId, String rulechainId, + UpdateRuleChainStateRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, PLATFORM_RULECHAINS, + instanceId, rulechainId, UPDATE_STATE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public PlatformRuleChainInfo getRuleChain (String instanceId, String rulechainId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PLATFORM_RULECHAINS, instanceId, rulechainId); + return invokeHttpClient(internalRequest, PlatformRuleChainInfo.class); + } + + public ListRuleChainResponse listRuleChain (String instanceId, ListRuleChainRequest request) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PLATFORM_RULECHAINS, instanceId); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (StringUtils.isNotEmpty(request.getState())) { + internalRequest.addParameter("state", request.getState()); + } + if (StringUtils.isNotEmpty(request.getStatus())) { + internalRequest.addParameter("status", request.getStatus()); + } + return invokeHttpClient(internalRequest, ListRuleChainResponse.class); + } + + public ValidateRuleChainResponse validateRuleChain (ValidateRuleChainRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PLATFORM_RULECHAINS, COMPUTE); + return invokeHttpClient(internalRequest, ValidateRuleChainResponse.class); + } + + /** + * @Deprecated As of release v0.10.281, + * replaced by {@link #createRuleChainExternalDestination(String, CreateRuleChainExternalDestinationRequestV2)} + */ + @Deprecated + public CreateRuleChainExternalDestinationResponse createRuleChainExternalDestination ( + String instanceId, + CreateRuleChainExternalDestinationRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PLATFORM_RULECHAINS, instanceId, DESTINATIONS); + return invokeHttpClient(internalRequest, CreateRuleChainExternalDestinationResponse.class); + } + + public CreateRuleChainExternalDestinationResponse createRuleChainExternalDestination ( + String instanceId, + CreateRuleChainExternalDestinationRequestV2 request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PLATFORM_RULECHAINS, instanceId, DESTINATIONS); + return invokeHttpClient(internalRequest, CreateRuleChainExternalDestinationResponse.class); + } + + public ListRuleChainDestinationResponse listRuleChainDestinations (String instanceId, + ListRuleChainDestinationRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, PLATFORM_RULECHAINS, instanceId, DESTINATIONS); + internalRequest.addParameter("sourceType", request.getSourceType()); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getRegion())) { + internalRequest.addParameter("region", request.getRegion()); + } + if (StringUtils.isNotEmpty(request.getType())) { + internalRequest.addParameter("type", request.getType()); + } + return invokeHttpClient(internalRequest, ListRuleChainDestinationResponse.class); + } + + public void batchDeleteRuleChainExternalDestinations (String instanceId, + BatchDeleteRuleChainExternalDestinationRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PLATFORM_RULECHAINS, instanceId, DESTINATIONS, BATCH_DELETE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void validateRuleChainDestinationConnect (String instanceId, String destId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, PLATFORM_RULECHAINS, + instanceId, DESTINATIONS, destId); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public AuthRuleChainExternalDestinationResponse authRuleChainExternalDestination(String instanceId, + String destinationId, + RuleChainExternalDestinationType type) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PLATFORM_RULECHAINS, + instanceId, DESTINATIONS, destinationId, AUTH); + internalRequest.addParameter("type", type.name()); + + return invokeHttpClient(internalRequest, AuthRuleChainExternalDestinationResponse.class); + } + + // C2C API + public ComputationSourceResponse getC2CSource(String instanceId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, instanceId, C2C); + return invokeHttpClient(internalRequest, ComputationSourceResponse.class); + } + + public void updateC2CDownwardState(String instanceId, boolean state) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, SERVICE, instanceId, C2C, DOWNWARD); + internalRequest.addParameter("state", Boolean.toString(state)); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // Device API + public DeviceInfo createDevice(String instanceId, String productKey, CreateDeviceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, DEVICES, instanceId, productKey); + return invokeHttpClient(internalRequest, DeviceInfo.class); + } + + public void importCsvCreateDevice(String instanceId, String productKey, File file) { + InternalRequest internalRequest = createUploadRequest( + "importFile", file, HttpMethodName.POST, DEVICES, instanceId, productKey, CSV, IMPORT); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void importCsvCreateDevice(String instanceId, String productKey, File file, AuthType authType) { + InternalRequest internalRequest = createUploadRequest( + "importFile", file, HttpMethodName.POST, DEVICES, instanceId, productKey, CSV, IMPORT); + internalRequest.addParameter("authType", authType.name()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void importCsvCreateDevice(String instanceId, String productKey, File file, + AuthType authType, String description) { + InternalRequest internalRequest = createUploadRequest( + "importFile", file, HttpMethodName.POST, DEVICES, instanceId, productKey, CSV, IMPORT); + internalRequest.addParameter("authType", authType.name()); + internalRequest.addParameter("description", description); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void importCsvCreateDevice(String instanceId, String productKey, File file, + AuthType authType, String description, boolean isRegisterIotCore) { + InternalRequest internalRequest = createUploadRequest( + "importFile", file, HttpMethodName.POST, DEVICES, instanceId, productKey, CSV, IMPORT); + internalRequest.addParameter("authType", authType.name()); + internalRequest.addParameter("description", description); + internalRequest.addParameter("isRegisterIotCore", Boolean.toString(isRegisterIotCore)); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteDevice(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, DEVICES, instanceId, productKey, deviceName); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void batchDeleteDevice(String instanceId, BatchDeleteDeviceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, DEVICES, instanceId, BATCH, DELETE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public DeviceInfo getDevice(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, DEVICES, instanceId, productKey, deviceName); + return invokeHttpClient(internalRequest, DeviceInfo.class); + } + + public ListDeviceResponse getDeviceList(String instanceId, ListDeviceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, DEVICES, instanceId); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + internalRequest.addParameter("cursor", request.getCursor()); + if (StringUtils.isNotEmpty(request.getProductKey())) { + internalRequest.addParameter("productKey", request.getProductKey()); + } + if (StringUtils.isNotEmpty(request.getAlias())) { + internalRequest.addParameter("alias", request.getAlias()); + } + return invokeHttpClient(internalRequest, ListDeviceResponse.class); + } + + public void resetDeviceSecret(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, DEVICES, + instanceId, productKey, deviceName, SECRET); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void batchCreateDevice(String instanceId, String productKey, BatchCreateDeviceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, DEVICES, + instanceId, productKey, BATCH); + if (request.getAuthType() != null) { + internalRequest.addParameter("authType", request.getAuthType().name()); + } + if (StringUtils.isNotEmpty(request.getDescription())) { + internalRequest.addParameter("description", request.getDescription()); + } + if (request.getIsRegisterIotCore() != null) { + internalRequest.addParameter("isRegisterIotCore", Boolean.toString(request.getIsRegisterIotCore())); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public DeviceInfo updateDevice(String instanceId, String productKey, + String deviceName, UpdateDeviceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, DEVICES, instanceId, productKey, deviceName); + return invokeHttpClient(internalRequest, DeviceInfo.class); + } + + public ListDeviceStatesResponse getDeviceStates(String instanceId, ListDeviceKeyRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, DEVICES, instanceId, STATES); + return invokeHttpClient(internalRequest, ListDeviceStatesResponse.class); + } + + // topic + public ListTopicResponse getDeviceTopic(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, DEVICES, + instanceId, productKey, deviceName, TOPICS); + return invokeHttpClient(internalRequest, ListTopicResponse.class); + } + + // tag + public ListTagResponse createDeviceTag(String instanceId, String productKey, + String deviceName, CreateTagRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, DEVICES, + instanceId, productKey, deviceName, TAGS); + return invokeHttpClient(internalRequest, ListTagResponse.class); + } + + public void deleteDeviceTag(String instanceId, String productKey, + String deviceName, String key) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, DEVICES, + instanceId, productKey, deviceName, TAGS, key); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ListTagResponse getDeviceTagList(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, DEVICES, + instanceId, productKey, deviceName, TAGS); + return invokeHttpClient(internalRequest, ListTagResponse.class); + } + + // video + public EvsSpaceInfo getEvs(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, EVS); + return invokeHttpClient(internalRequest, EvsSpaceInfo.class); + } + + public EvsDeviceInfo getEvs(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, DEVICES, + instanceId, productKey, deviceName, EVS); + return invokeHttpClient(internalRequest, EvsDeviceInfo.class); + } + + public void createEvs(String instanceId, String productKey, + CreateEvsSpaceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + PRODUCTS, instanceId, productKey, EVS); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void createEvs(String instanceId, String productKey, + String deviceName, AddEvsDeviceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, DEVICES, + instanceId, productKey, deviceName, EVS); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public GetEvsChannelUrlResponse getEvsChannelUrl(String instanceId, String productKey, + String deviceName, String channelId, EvsUrlProtocol protocol) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, DEVICES, + instanceId, productKey, deviceName, EVS, CHANNEL, channelId); + + internalRequest.addParameter("protocol", protocol.name()); + + return invokeHttpClient(internalRequest, GetEvsChannelUrlResponse.class); + } + + public void getEvsChannelPtz(String instanceId, String productKey, + String deviceName, String channelId, + EvsPtzRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, DEVICES, + instanceId, productKey, deviceName, EVS, CHANNEL, channelId, PTZ); + internalRequest.addParameter("ptz", request.getPtzCommand()); + if (request.getSpeed() != null) { + internalRequest.addParameter("speed", Integer.toString(request.getSpeed())); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public GetEvsChannelResponse getEvsChannel(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, DEVICES, + instanceId, productKey, deviceName, EVS, CHANNEL); + return invokeHttpClient(internalRequest, GetEvsChannelResponse.class); + } + + public GetEvsThumbnailResponse getEvsThumbnail(String instanceId, String productKey, + String deviceName, EvsDurationRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, DEVICES, + instanceId, productKey, deviceName, EVS, THUMBNAIL); + internalRequest.addParameter("begin", Integer.toString(request.getBegin())); + internalRequest.addParameter("end", Integer.toString(request.getEnd())); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + return invokeHttpClient(internalRequest, GetEvsThumbnailResponse.class); + } + + public GetEvsRecordingResponse getEvsRecording(String instanceId, String productKey, + String deviceName, EvsDurationRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, DEVICES, + instanceId, productKey, deviceName, EVS, RECORDING); + internalRequest.addParameter("begin", Integer.toString(request.getBegin())); + internalRequest.addParameter("end", Integer.toString(request.getEnd())); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + return invokeHttpClient(internalRequest, GetEvsRecordingResponse.class); + } + + public void auth(String instanceId, String productKey, + String deviceName, AuthRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, DEVICES, + instanceId, productKey, deviceName, AUTH); + internalRequest.addHeader("signature", request.getSignature()); + internalRequest.addHeader("expiryTime", Long.toString(request.getExpiryTime())); + if (request.getAlgorithmType() != null) { + internalRequest.addHeader("algorithmType", request.getAlgorithmType().name()); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public DeviceResourcesConnectionInfo getResourcesInfo(String instanceId, String productKey, + String deviceName, GetDeviceConnectionInfoRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, DEVICES, + instanceId, productKey, deviceName, RESOURCES); + return invokeHttpClient(internalRequest, DeviceResourcesConnectionInfo.class); + } + + public void updateDeviceStates(String instanceId, String productKey, + String deviceName, UpdateDeviceStateRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, DEVICES, + instanceId, productKey, deviceName, STATES); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // DeviceShadow API + public DeviceShadowResponse getDeviceShadow(String instanceId, String productKey, + String deviceName, ListDeviceShadowRequest request) { + return getDeviceShadow(instanceId, productKey, deviceName, request, null); + } + + public DeviceShadowResponse getDeviceShadow(String instanceId, String productKey, + String deviceName, ListDeviceShadowRequest request, String version) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, + SHADOWS, instanceId, productKey, deviceName); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + if (StringUtils.isNotEmpty(request.getPropertyName())) { + internalRequest.addParameter("propertyName", request.getPropertyName()); + } + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, DeviceShadowResponse.class); + } + + public void updateDeviceShadowState(String instanceId, String productKey, + boolean shadowState) { + ShadowStatesRequest request = new ShadowStatesRequest(); + request.setShadowState(shadowState); + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + SHADOWS, instanceId, productKey, STATES); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void updateDesired(String instanceId, String productKey, + String deviceName, UpdateDesiredRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + SHADOWS, instanceId, productKey, deviceName, DESIRED); + internalRequest.addParameter("bindName", request.getBindName()); + String jsonStr = JsonUtils.toJsonString(request.getDesired()); + try { + byte[] content = jsonStr.getBytes(DEFAULT_ENCODING); + internalRequest.setContent(RestartableInputStream.wrap(content)); + internalRequest.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ListDeviceShadowSnapshotResponse listShadow(String instanceId, ListDeviceKeyRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + SHADOWS, instanceId, SHADOW, BATCH); + return invokeHttpClient(internalRequest, ListDeviceShadowSnapshotResponse.class); + } + + // EVS + public GetEvsStreamResponse getEvsStream(String domain, String app, + String stream, EvsUrlProtocol protocol) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest() , HttpMethodName.GET, + EVS, domain, app, stream, SIGNED_URL); + internalRequest.addParameter("protocol", protocol.name()); + return invokeHttpClient(internalRequest, GetEvsStreamResponse.class); + } + + // Product API + public ProductInfo createProduct(String instanceId, CreateProductInfoRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + PRODUCTS, instanceId); + return invokeHttpClient(internalRequest, ProductInfo.class); + } + + public void resetSecret(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, + PRODUCTS, instanceId, productKey, SECRET); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ProductInfo updateProduct(String instanceId, String productKey, + UpdateProductInfoRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + PRODUCTS, instanceId, productKey); + return invokeHttpClient(internalRequest, ProductInfo.class); + } + + public ListProductResponse getProductList(String instanceId, ListProductRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, PRODUCTS, instanceId); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + if (StringUtils.isNotEmpty(request.getProductName())) { + internalRequest.addParameter("productName", request.getProductName()); + } + if (StringUtils.isNotEmpty(request.getTagKey())) { + internalRequest.addParameter("tagKey", request.getTagKey()); + } + if (StringUtils.isNotEmpty(request.getTagValue())) { + internalRequest.addParameter("tagValue", request.getTagValue()); + } + if (request.getDeviceType() != null) { + internalRequest.addParameter("deviceType", request.getDeviceType().toString()); + } + return invokeHttpClient(internalRequest, ListProductResponse.class); + } + + public ProductInfo getProduct(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey); + return invokeHttpClient(internalRequest, ProductInfo.class); + } + + public void deleteProduct(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + PRODUCTS, instanceId, productKey); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void updatePermanentConnect(String instanceId, String productKey, + boolean permanentConnect) { + PermanentConnectRequest request = new PermanentConnectRequest(permanentConnect); + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + PRODUCTS, instanceId, productKey, PERMANENT_CONNECT); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // tag + public ListTagResponse createProductTag(String instanceId, String productKey, + CreateTagRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + PRODUCTS, instanceId, productKey, TAGS); + return invokeHttpClient(internalRequest, ListTagResponse.class); + } + + public void deleteProductTag(String instanceId, String productKey, + String key) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + PRODUCTS, instanceId, productKey, TAGS, key); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ListTagResponse getProductTagList(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, TAGS); + return invokeHttpClient(internalRequest, ListTagResponse.class); + } + + // topic + public ListTopicResponse getTopics(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, TOPICS); + return invokeHttpClient(internalRequest, ListTopicResponse.class); + } + + // function + public DtmlDetailResponse getDTMLDetail(String instanceId, String productKey) { + return getDTMLDetail(instanceId, productKey, null); + } + + public DtmlDetailResponse getDTMLDetail(String instanceId, String productKey, String version) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + PRODUCTS, instanceId, productKey, FEATURE, DETAIL); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, DtmlDetailResponse.class); + } + + public void importDTMLDetail(String instanceId, String productKey, Thing thing) { + InternalRequest internalRequest = createRequest( + thing, HttpMethodName.POST, + PRODUCTS, instanceId, productKey, FEATURE, BATCH); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // feature command + public ProductFeatureCommandInfo createFeatureCommand(String instanceId, String productKey, + CreateFeatureCommandRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + PRODUCTS, instanceId, productKey, FEATURE, COMMAND); + return invokeHttpClient(internalRequest, ProductFeatureCommandInfo.class); + } + + public ProductFeatureCommandInfo updateFeatureCommand(String instanceId, String productKey, + String name, UpdateProductCommandRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + PRODUCTS, instanceId, productKey, FEATURE, COMMAND, name); + return invokeHttpClient(internalRequest, ProductFeatureCommandInfo.class); + } + + public void deleteFeatureCommand(String instanceId, String productKey, + String name) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + PRODUCTS, instanceId, productKey, FEATURE, COMMAND, name); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ProductFeatureCommandInfo getFeatureCommand(String instanceId, String productKey, + String name) { + return getFeatureCommand(instanceId, productKey, name, null); + } + + public ProductFeatureCommandInfo getFeatureCommand(String instanceId, String productKey, + String name, String version) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, FEATURE, COMMAND, name); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, ProductFeatureCommandInfo.class); + } + + public ListFeatureCommandResponse getFeatureCommandList(String instanceId, String productKey, + int pageNo, int pageSize) { + return getFeatureCommandList(instanceId, productKey, pageNo, pageSize, null); + } + + public ListFeatureCommandResponse getFeatureCommandList(String instanceId, String productKey, + int pageNo, int pageSize, String version) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, FEATURE, COMMAND); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, ListFeatureCommandResponse.class); + } + + // feature event + public ProductFeatureEventInfo createFeatureEvent(String instanceId, String productKey, + CreateFeatureEventRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + PRODUCTS, instanceId, productKey, FEATURE, EVENT); + return invokeHttpClient(internalRequest, ProductFeatureEventInfo.class); + } + + public ProductFeatureEventInfo updateFeatureEvent(String instanceId, String productKey, + String name, UpdateProductEventRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + PRODUCTS, instanceId, productKey, FEATURE, EVENT, name); + return invokeHttpClient(internalRequest, ProductFeatureEventInfo.class); + } + + public void deleteFeatureEvent(String instanceId, String productKey, + String name) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + PRODUCTS, instanceId, productKey, FEATURE, EVENT, name); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ProductFeatureEventInfo getFeatureEvent(String instanceId, String productKey, String name) { + return getFeatureEvent(instanceId, productKey, name, null); + } + + public ProductFeatureEventInfo getFeatureEvent(String instanceId, String productKey, String name, String version) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, FEATURE, EVENT, name); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, ProductFeatureEventInfo.class); + } + + public ListFeatureEventResponse getFeatureEventList(String instanceId, String productKey, + int pageNo, int pageSize) { + return getFeatureEventList(instanceId, productKey, pageNo, pageSize, null); + } + + public ListFeatureEventResponse getFeatureEventList(String instanceId, String productKey, + int pageNo, int pageSize, String version) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, FEATURE, EVENT); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, ListFeatureEventResponse.class); + } + + // feature property + public ProductFeaturePropertyInfo createFeatureProperty(String instanceId, String productKey, + CreateFeaturePropertyRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + PRODUCTS, instanceId, productKey, FEATURE, PROPERTIES); + return invokeHttpClient(internalRequest, ProductFeaturePropertyInfo.class); + } + + public ProductFeaturePropertyInfo updateFeatureProperty(String instanceId, String productKey, + String name, UpdateProductPropertyRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + PRODUCTS, instanceId, productKey, FEATURE, PROPERTIES, name); + return invokeHttpClient(internalRequest, ProductFeaturePropertyInfo.class); + } + + public void deleteFeatureProperty(String instanceId, String productKey, + String name) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + PRODUCTS, instanceId, productKey, FEATURE, PROPERTIES, name); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ProductFeaturePropertyInfo getFeatureProperty(String instanceId, String productKey, + String name) { + return getFeatureProperty(instanceId, productKey, name, null); + } + + public ProductFeaturePropertyInfo getFeatureProperty(String instanceId, String productKey, + String name, String version) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, FEATURE, PROPERTIES, name); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, ProductFeaturePropertyInfo.class); + } + + public ListFeaturePropertyResponse getFeaturePropertyList(String instanceId, String productKey, + int pageNo, int pageSize) { + return getFeaturePropertyList(instanceId, productKey, pageNo, pageSize, null); + } + + public ListFeaturePropertyResponse getFeaturePropertyList(String instanceId, String productKey, + int pageNo, int pageSize, String version) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, productKey, FEATURE, PROPERTIES); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, ListFeaturePropertyResponse.class); + } + + // video + public void updateEvs(String instanceId, String productKey, + UpdateEvsSpaceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + PRODUCTS, instanceId, productKey, EVS); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void updateEvs(String instanceId, String productKey, String deviceName, + UpdateEvsDeviceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + DEVICES, instanceId, productKey, deviceName, EVS); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // topo + + public ListProductResponse getSubsets(String instanceId, String productKey, + int pageNo, int pageSize) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, SUBSET, productKey); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListProductResponse.class); + } + + public ListDeviceResponse getSubsets(String instanceId, String productKey, String deviceName, + int pageNo, int pageSize, String name) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + DEVICES, instanceId, productKey, deviceName, SUBSET); + if (StringUtils.isNotBlank(name)) { + internalRequest.addParameter("name", name); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListDeviceResponse.class); + } + + public void deleteSubsets(String instanceId, String productKey, + List subProductKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + PRODUCTS, instanceId, SUBSET, productKey, DELETE); + String jsonStr = JsonUtils.toJsonString(subProductKey); + try { + byte[] content = jsonStr.getBytes(DEFAULT_ENCODING); + internalRequest.setContent(RestartableInputStream.wrap(content)); + internalRequest.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteSubsets(String instanceId, String productKey, String deviceName, + List subDeviceKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + DEVICES, instanceId, productKey, deviceName, SUBSET, DELETE); + String jsonStr = JsonUtils.toJsonString(subDeviceKey); + try { + byte[] content = jsonStr.getBytes(DEFAULT_ENCODING); + internalRequest.setContent(RestartableInputStream.wrap(content)); + internalRequest.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ListProductResponse getAllSubsets(String instanceId, String productKey, String subProductName, + int pageNo, int pageSize) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, instanceId, SUBSET); + + internalRequest.addParameter("productKey", productKey); + if (StringUtils.isNotBlank(subProductName)) { + internalRequest.addParameter("subProductName", subProductName); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListProductResponse.class); + } + + public ListDeviceResponse getAllSubsets(String instanceId, String productKey, + String subProductKey, String deviceName, String name, + int pageNo, int pageSize) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + DEVICES, instanceId, productKey, SUBSET); + + internalRequest.addParameter("subProductKey", subProductKey); + internalRequest.addParameter("deviceName", deviceName); + if (StringUtils.isNotBlank(name)) { + internalRequest.addParameter("name", name); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListDeviceResponse.class); + } + + public void addSubsets(String instanceId, String productKey, + List subProductKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + PRODUCTS, instanceId, SUBSET, productKey); + String jsonStr = JsonUtils.toJsonString(subProductKey); + try { + byte[] content = jsonStr.getBytes(DEFAULT_ENCODING); + internalRequest.setContent(RestartableInputStream.wrap(content)); + internalRequest.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void addSubsets(String instanceId, String productKey, String deviceName, + List subDeviceKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + DEVICES, instanceId, productKey, deviceName, SUBSET); + String jsonStr = JsonUtils.toJsonString(subDeviceKey); + try { + byte[] content = jsonStr.getBytes(DEFAULT_ENCODING); + internalRequest.setContent(RestartableInputStream.wrap(content)); + internalRequest.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void importSubsets(String instanceId, String productKey, String deviceName, + File file) { + InternalRequest internalRequest = createUploadRequest( + "importFile", file, HttpMethodName.POST, + DEVICES, instanceId, productKey, deviceName, SUBSET, IMPORT); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public DeviceSubsetsFileResponse exportSubsets(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + DEVICES, instanceId, productKey, deviceName, SUBSET, EXPORT); + return invokeHttpClient(internalRequest, DeviceSubsetsFileResponse.class); + } + + // ruleChain API + public TopicEncodeResponse topicEncode(TopicEncodeRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, SERVICE, + BLINK, TOPICS, ENCODE); + return invokeHttpClient(internalRequest, TopicEncodeResponse.class); + } + + public TopicDecodeResponse topicDecode(TopicDecodeRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, SERVICE, + BLINK, TOPICS, DECODE); + return invokeHttpClient(internalRequest, TopicDecodeResponse.class); + } + + public AvailableMessageTypeResponse getSourceTypes(String instanceId, BlinkDataPermission permission) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, MESSAGES, TYPES, SOURCE); + if (permission != null) { + internalRequest.addParameter("permission", permission.name()); + } + return invokeHttpClient(internalRequest, AvailableMessageTypeResponse.class); + } + + public AvailableMessageTypeResponse getSinkTypes(String instanceId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, MESSAGES, TYPES, SINK); + return invokeHttpClient(internalRequest, AvailableMessageTypeResponse.class); + } + + // service API + public ConsumerGroupUserInfoResponse getUserInfo(String instanceId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, CONSUMER, USER); + return invokeHttpClient(internalRequest, ConsumerGroupUserInfoResponse.class); + } + + public void sendMessage(String instanceId, String productKey, + String deviceName, SendMessageRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, SERVICE, + instanceId, productKey, deviceName, MESSAGE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public CreateConsumerGroupResponse createConsumerGroup(String instanceId, String name) { + CreateConsumerGroupRequest request = new CreateConsumerGroupRequest(name); + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, SERVICE, + instanceId, CONSUMER); + return invokeHttpClient(internalRequest, CreateConsumerGroupResponse.class); + } + + public void deleteConsumerGroup(String instanceId, String consumerGroupId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, SERVICE, + instanceId, CONSUMER, consumerGroupId); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ListConsumerGroupResponse getConsumerGroupList(String instanceId, + CommonListRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, + SERVICE, instanceId, CONSUMER); + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + } + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + return invokeHttpClient(internalRequest, ListConsumerGroupResponse.class); + } + + public ResetConsumerGroupUserPwdResponse resetUserPwd(String instanceId, String username) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, SERVICE, + instanceId, CONSUMER, username, RESET); + return invokeHttpClient(internalRequest, ResetConsumerGroupUserPwdResponse.class); + } + + public ListInstanceServiceStateResponse listInstanceServiceState(String instanceId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, STATE); + return invokeHttpClient(internalRequest, ListInstanceServiceStateResponse.class); + } + + public ConsumerGroupQueueInfoResponse getQueueInfo(String instanceId, String consumerGroupId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, CONSUMER, consumerGroupId); + return invokeHttpClient(internalRequest, ConsumerGroupQueueInfoResponse.class); + } + + public ListSubResponse getSubList(String instanceId, CommonListRequest request) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, SUBSCRIPTIONS); + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + } + if (StringUtils.isNotEmpty(request.getOrderBy())) { + internalRequest.addParameter("orderBy", request.getOrderBy()); + } + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + return invokeHttpClient(internalRequest, ListSubResponse.class); + } + + @Deprecated + public ProductSubscriptionResponse getSub(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, productKey, SUBSCRIPTIONS); + return invokeHttpClient(internalRequest, ProductSubscriptionResponse.class); + } + + public ProductSubscriptionResponse getSubTopics(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, productKey, SUBSCRIPTIONS, TOPICS); + return invokeHttpClient(internalRequest, ProductSubscriptionResponse.class); + } + + @Deprecated + public void updateSub(String instanceId, String productKey, + UpdateProductSubscriptionRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, SERVICE, + instanceId, productKey, SUBSCRIPTIONS); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void updateSubTopics(String instanceId, String productKey, + UpdateProductSubscriptionRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, SERVICE, + instanceId, productKey, SUBSCRIPTIONS, TOPICS); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void updateSubState(String instanceId, String productKey, + boolean state) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, SERVICE, + instanceId, productKey, SUBSCRIPTIONS); + internalRequest.addParameter("state", Boolean.toString(state)); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ProductSubscriptionResponse getMessageType(String instanceId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, MESSAGE, TYPE); + return invokeHttpClient(internalRequest, ProductSubscriptionResponse.class); + } + + // gateway + public void updateGatewayState(String instanceId, String productKey, String deviceName, boolean state) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, SERVICE, + instanceId, productKey, deviceName, GATEWAY); + internalRequest.addParameter("state", Boolean.toString(state)); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ComputationSourceResponse getGatewayInfo(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, SERVICE, + instanceId, productKey, deviceName, GATEWAY); + return invokeHttpClient(internalRequest, ComputationSourceResponse.class); + } + + public void resetGatewaySecret(String instanceId, String productKey, String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, SERVICE, + instanceId, productKey, deviceName, GATEWAY, RESET); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // userlog + public ListUserLogResponse getLogList(String instanceId, ListUserLogRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, LOG, instanceId); + + internalRequest.addParameter("logType", request.getLogType()); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + if (StringUtils.isNotEmpty(request.getLogSubType())) { + internalRequest.addParameter("logSubType", request.getLogSubType()); + } + if (StringUtils.isNotEmpty(request.getFlag())) { + internalRequest.addParameter("flag", request.getFlag()); + } + if (StringUtils.isNotEmpty(request.getProductKey())) { + internalRequest.addParameter("productKey", request.getProductKey()); + } + if (StringUtils.isNotEmpty(request.getDeviceName())) { + internalRequest.addParameter("deviceName", request.getDeviceName()); + } + if (StringUtils.isNotEmpty(request.getKeyword())) { + internalRequest.addParameter("keyword", request.getKeyword()); + } + if (request.getBeginTime() != null) { + internalRequest.addParameter("beginTime", Long.toString(request.getBeginTime())); + } + if (request.getEndTime() != null) { + internalRequest.addParameter("endTime", Long.toString(request.getEndTime())); + } + return invokeHttpClient(internalRequest, ListUserLogResponse.class); + } + + // group + public GroupInfo createGroup(String instanceId, CreateGroupRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, GROUPS, instanceId); + return invokeHttpClient(internalRequest, GroupInfo.class); + } + + public ListGroupResponse getGroupList(String instanceId, ListGroupRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, GROUPS, instanceId); + if (StringUtils.isNotEmpty(request.getSuperGroupId())) { + internalRequest.addParameter("superGroupId", request.getSuperGroupId()); + } + if (StringUtils.isNotEmpty(request.getRootGroupId())) { + internalRequest.addParameter("rootGroupId", request.getRootGroupId()); + } + if (StringUtils.isNotEmpty(request.getKeyword())) { + internalRequest.addParameter("keyword", request.getKeyword()); + } + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + } + return invokeHttpClient(internalRequest, ListGroupResponse.class); + } + + public void deleteGroup(String instanceId, String groupId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, GROUPS, instanceId, groupId); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public GroupInfo updateGroup(String instanceId, String groupId, UpdateGroupInfoRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, GROUPS, instanceId, groupId); + return invokeHttpClient(internalRequest, GroupInfo.class); + } + + public GroupInfo getGroup(String instanceId, String groupId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, GROUPS, instanceId, groupId); + return invokeHttpClient(internalRequest, GroupInfo.class); + } + + public void addDeviceToGroup(String instanceId, String groupId, List listDeviceKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, GROUPS, instanceId, groupId, DEVICES); + String jsonStr = JsonUtils.toJsonString(listDeviceKey); + try { + byte[] content = jsonStr.getBytes(DEFAULT_ENCODING); + internalRequest.setContent(RestartableInputStream.wrap(content)); + internalRequest.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteDeviceFromGroup(String instanceId, String groupId, List listDeviceKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, GROUPS, instanceId, groupId, DEVICES, DELETE); + String jsonStr = JsonUtils.toJsonString(listDeviceKey); + try { + byte[] content = jsonStr.getBytes(DEFAULT_ENCODING); + internalRequest.setContent(RestartableInputStream.wrap(content)); + internalRequest.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ListDeviceByGroupResponse listDeviceByGroup(String instanceId, String groupId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, GROUPS, instanceId, groupId, DEVICES); + return invokeHttpClient(internalRequest, ListDeviceByGroupResponse.class); + } + + // component + public ListBindComponentResponse bindProductComponents(String instanceId, String productKey, + BindComponentRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PRODUCTS, instanceId, productKey, COMPONENTS); + return invokeHttpClient(internalRequest, ListBindComponentResponse.class); + } + + /** + * @Deprecated As of release v0.10.281, + * replaced by {@link #unbindProductComponent(String, String, String)} + */ + @Deprecated + public void unbindProductComponent(String instanceId, String productKey, + String bindName, BindComponentRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.DELETE, PRODUCTS, instanceId, productKey, COMPONENTS, bindName); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void unbindProductComponent(String instanceId, String productKey, + String bindName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, PRODUCTS, instanceId, productKey, COMPONENTS, + bindName); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ListBindComponentResponse listProductComponents(String instanceId, String productKey) { + + return listProductComponents(instanceId, productKey, null); + } + + public ListBindComponentResponse listProductComponents(String instanceId, String productKey, String version) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, instanceId, productKey, COMPONENTS); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, ListBindComponentResponse.class); + } + + public ListBindComponentResponse listDeviceComponents(String instanceId, String productKey, + String deviceName, String bindName) { + return listDeviceComponents(instanceId, productKey, deviceName, bindName, null); + } + + public ListBindComponentResponse listDeviceComponents(String instanceId, String productKey, + String deviceName, String bindName, String version) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, DEVICES, + instanceId, productKey, deviceName, COMPONENTS); + if (StringUtils.isNotEmpty(bindName)) { + internalRequest.addParameter("bindName", bindName); + } + + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, ListBindComponentResponse.class); + } + + // linkage + public CreateLinkageRuleResponse createLinkageRule(String instanceId, CreateLinkageRuleRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PLATFORM_LINKAGES, instanceId); + return invokeHttpClient(internalRequest, CreateLinkageRuleResponse.class); + } + + public void deleteLinkageRule(String instanceId, BatchDeleteLinkageRuleRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PLATFORM_LINKAGES, instanceId, BATCH_DELETE); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void updateLinkageRule(String instanceId, String ruleId, UpdateLinkageRuleRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, PLATFORM_LINKAGES, instanceId, ruleId); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public LinkageRuleInfo getLinkageRule(String instanceId, String ruleId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PLATFORM_LINKAGES, instanceId, ruleId); + return invokeHttpClient(internalRequest, LinkageRuleInfo.class); + } + + public ListLinkageRuleResponse listLinkageRule(String instanceId, int pageNo, int pageSize, String name) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PLATFORM_LINKAGES, instanceId); + if (StringUtils.isNotEmpty(name)) { + internalRequest.addParameter("name", name); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListLinkageRuleResponse.class); + } + + public void updateLinkageRuleState(String instanceId, String ruleId, boolean state) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, PLATFORM_LINKAGES, instanceId, ruleId, STATE); + internalRequest.addParameter("state", Boolean.toString(state)); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // products categories + public ListProductCategoryResponse listProductCategory() { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, CATEGORIES); + + return invokeHttpClient(internalRequest, ListProductCategoryResponse.class); + } + + // products repositories + public ListProductModelResponse listProductModel(ListProductModelRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, PRODUCTS, REPOSITORIES, MODELS); + if (StringUtils.isNotEmpty(request.getProductName())) { + internalRequest.addParameter("productName", request.getProductName()); + } + if (StringUtils.isNotEmpty(request.getKeyword())) { + internalRequest.addParameter("keyword", request.getKeyword()); + } + if (request.getDeviceType() != null) { + internalRequest.addParameter("deviceType", request.getDeviceType().name()); + } + if (request.getType() != null) { + internalRequest.addParameter("type", request.getType().name()); + } + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + return invokeHttpClient(internalRequest, ListProductModelResponse.class); + } + + public ProductModelInfo getMainProductInfo(String modelId) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, REPOSITORIES, MODELS, modelId, INFO); + + return invokeHttpClient(internalRequest, ProductModelInfo.class); + } + + public ListBindComponentResponse getMainProductComponents(String modelId) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, REPOSITORIES, MODELS, modelId, COMPONENTS); + + return invokeHttpClient(internalRequest, ListBindComponentResponse.class); + } + + public ListFeaturePropertyResponse getMainProductProperties(String modelId, + int pageNo, int pageSize) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, REPOSITORIES, MODELS, + modelId, FEATURE, PROPERTIES); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListFeaturePropertyResponse.class); + } + + public ListFeatureEventResponse getMainProductEvents(String modelId, int pageNo, int pageSize) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, REPOSITORIES, MODELS, + modelId, FEATURE, EVENT); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListFeatureEventResponse.class); + } + + public ListFeatureCommandResponse getMainProductCommands(String modelId, + int pageNo, int pageSize) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, REPOSITORIES, MODELS, + modelId, FEATURE, COMMAND); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListFeatureCommandResponse.class); + } + + public DtmlDetailResponse getMainProductDTMLDetail(String modelId) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, REPOSITORIES, MODELS, + modelId, FEATURE, DETAIL); + + return invokeHttpClient(internalRequest, DtmlDetailResponse.class); + } + + public SaveCustomProductModelResponse saveCustomProductModel(String instanceId, String productKey, + SaveCustomProductModelRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PRODUCTS, REPOSITORIES, MODELS, + CUSTOM, instanceId, productKey); + + return invokeHttpClient(internalRequest, SaveCustomProductModelResponse.class); + } + + public void deleteCustomProductModel(String modelId) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, PRODUCTS, REPOSITORIES, MODELS, + CUSTOM, modelId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public SimpleProductModelInfo updateCustomProductModel(String modelId, UpdateCustomProductModelRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, PRODUCTS, REPOSITORIES, MODELS, + CUSTOM, modelId); + + return invokeHttpClient(internalRequest, SimpleProductModelInfo.class); + } + + // product models + public ProductModelInfo exportProductModel(String instanceId, String productKey) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, PRODUCTS, MODELS, instanceId, productKey); + + return invokeHttpClient(internalRequest, ProductModelInfo.class); + } + + public void importProductModel(String instanceId, ImportProductModelRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PRODUCTS, MODELS, instanceId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void importProductModel(String instanceId, String modelId, CreateProductByModelRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, PRODUCTS, MODELS, instanceId, modelId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // Alarm rule + public AlarmRuleInfo createAlarmRule(String instanceId, CreateAlarmRuleRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, ALARMS, RULES, instanceId); + + return invokeHttpClient(internalRequest, AlarmRuleInfo.class); + } + + public AlarmRuleInfo updateAlarmRule(String instanceId, String ruleId, UpdateAlarmRuleRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, ALARMS, RULES, instanceId, ruleId); + + return invokeHttpClient(internalRequest, AlarmRuleInfo.class); + } + + public AlarmRuleInfo getAlarmRule(String instanceId, String ruleId) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, ALARMS, RULES, instanceId, ruleId); + + return invokeHttpClient(internalRequest, AlarmRuleInfo.class); + } + + public ListAlarmRuleResponse listAlarmRule(String instanceId, String name, int pageNo, int pageSize) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, ALARMS, RULES, instanceId); + if (StringUtils.isNotEmpty(name)) { + internalRequest.addParameter("name", name); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ListAlarmRuleResponse.class); + } + + public void updateAlarmRuleActiveState(String instanceId, String ruleId, boolean active) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, ALARMS, RULES, instanceId, ruleId, STATES); + internalRequest.addParameter("active", Boolean.toString(active)); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void triggerAlarmRule(String instanceId, String ruleId, TriggerAlarmRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, ALARMS, RULES, instanceId, ruleId, TRIGGER); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void batchDeleteAlarmRule(String instanceId, BatchDeleteAlarmRuleRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, ALARMS, RULES, instanceId, BATCH, DELETE); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // Alarm records + public void deleteAlarmRecord(String instanceId, String recordId) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, ALARMS, RECORDS, instanceId, recordId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void batchProcessAlarmRecord(String instanceId, BatchProcessAlarmRecordRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, ALARMS, RECORDS, instanceId, BATCH, PROCESS); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public AlarmRecordInfo getAlarmRecord(String instanceId, String recordId) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, ALARMS, RECORDS, instanceId, recordId); + + return invokeHttpClient(internalRequest, AlarmRecordInfo.class); + } + + public ListAlarmRecordResponse listAlarmRecord(String instanceId, ListAlarmRecordRequest request) { + + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, ALARMS, RECORDS, instanceId); + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + } + if (StringUtils.isNotEmpty(request.getCursor())) { + internalRequest.addParameter("cursor", request.getCursor()); + } + if (StringUtils.isNotEmpty(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (request.getAlarmLevel() != null) { + internalRequest.addParameter("alarmLevel", Integer.toString(request.getAlarmLevel())); + } + if (request.getStatus() != null) { + internalRequest.addParameter("status", request.getStatus().name()); + } + return invokeHttpClient(internalRequest, ListAlarmRecordResponse.class); + } + + // 配置管理 fm + public ConfigManagementListResponse getConfigList(String instanceId, String productKey, + String configName, Integer pageNo, + Integer pageSize) { + + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, FM, CONFIG, instanceId); + if (StringUtils.isNotEmpty(productKey)) { + internalRequest.addParameter("productKey", productKey); + } + if (StringUtils.isNotEmpty(configName)) { + internalRequest.addParameter("configName", configName); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + + return invokeHttpClient(internalRequest, ConfigManagementListResponse.class); + } + + public void addConfig(String instanceId, AddConfigRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, FM, CONFIG, instanceId); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteConfig(String instanceId, String productKey, String configId) { + + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.DELETE, FM, CONFIG, instanceId, productKey, configId); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void modifyConfig(String instanceId, String productKey, String configId, AddConfigRequest request) { + + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, FM, CONFIG, instanceId, productKey, configId); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void addConfigVersion(String instanceId, String productKey, String configId, String version, File file) { + InternalRequest internalRequest = createUploadRequest("importFile", file, + HttpMethodName.POST, FM, CONFIG, instanceId, productKey, configId); + internalRequest.addParameter("version", version); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteConfigVersion(String instanceId, String productKey, + String configId, String configVersion) { + + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.DELETE, FM, CONFIG, instanceId, productKey, configId, CONFIG_VERSION); + internalRequest.addParameter("configVersion", configVersion); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public GetConfigVersionResponse downloadConfigVersion(String instanceId, String productKey, + String configId, String configVersion) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, FM, CONFIG, instanceId, productKey, configId, URL); + internalRequest.addParameter("configVersion", configVersion); + return invokeHttpClient(internalRequest, GetConfigVersionResponse.class); + } + + public ConfigVersionListResponse getConfigVersionList(String instanceId, String productKey, String configId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, FM, CONFIG, instanceId, productKey, configId, VERSIONS); + return invokeHttpClient(internalRequest, ConfigVersionListResponse.class); + } + + public ConfigManagementResponse getConfigInfo(String instanceId, String productKey, String configId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, FM, CONFIG, instanceId, productKey, configId); + return invokeHttpClient(internalRequest, ConfigManagementResponse.class); + } + + /** + * @deprecated As of release v0.10.239, + * replaced by {@link #getConfigTaskList(String, String, String, int, int, String)} + */ + @Deprecated + public ConfigTaskListResponse getTaskList(String instanceId, String productKey, + String configId, int pageNo, int pageSize, + String taskId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, FM, CONFIG, instanceId, productKey, configId, TASK); + + if (StringUtils.isNotEmpty(taskId)) { + internalRequest.addParameter("taskId", taskId); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + + return invokeHttpClient(internalRequest, ConfigTaskListResponse.class); + } + + public ConfigTaskListResponse getConfigTaskList(String instanceId, String productKey, + String configId, int pageNo, int pageSize, + String taskId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, FM, CONFIG, instanceId, productKey, configId, TASK); + + if (StringUtils.isNotEmpty(taskId)) { + internalRequest.addParameter("taskId", taskId); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + + return invokeHttpClient(internalRequest, ConfigTaskListResponse.class); + } + + /** + * @deprecated As of release v0.10.239, + * replaced by {@link #addConfigTask(String, String, String, AddTaskRequest)} + */ + @Deprecated + public void addTask(String instanceId, String productKey, + String configId, AddTaskRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.POST, FM, CONFIG, instanceId, productKey, configId, TASK); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void addConfigTask(String instanceId, String productKey, + String configId, AddTaskRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.POST, FM, CONFIG, instanceId, productKey, configId, TASK); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * @deprecated As of release v0.10.239, + * replaced by {@link #getConfigTaskDetail(String, String,String, int, int, String)} + */ + @Deprecated + public ConfigTaskDetailListResponse getTaskDetail(String instanceId, String productKey, + String configId, int pageNo, + int pageSize, String keyword) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, FM, CONFIG, instanceId, productKey, configId, TASK, DETAIL); + if (StringUtils.isNotEmpty(keyword)) { + internalRequest.addParameter("keyword", keyword); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ConfigTaskDetailListResponse.class); + } + + public ConfigTaskDetailListResponse getConfigTaskDetail(String instanceId, String productKey, + String configId, int pageNo, + int pageSize, String keyword) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, FM, CONFIG, instanceId, productKey, configId, TASK, DETAIL); + if (StringUtils.isNotEmpty(keyword)) { + internalRequest.addParameter("keyword", keyword); + } + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, ConfigTaskDetailListResponse.class); + } + + /** + * @deprecated As of release v0.10.239, + * replaced by {@link #addConfigTaskCsv(String, String, String, String, File)} + */ + @Deprecated + public void addTaskCsv(String instanceId, String productKey, + String configId, String configVersion, File file) { + InternalRequest internalRequest = createUploadRequest("importFile", file, + HttpMethodName.POST, FM, CONFIG, instanceId, productKey, configId, TASK, CSV); + internalRequest.addParameter("configVersion", configVersion); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void addConfigTaskCsv(String instanceId, String productKey, + String configId, String configVersion, File file) { + InternalRequest internalRequest = createUploadRequest("importFile", file, + HttpMethodName.POST, FM, CONFIG, instanceId, productKey, configId, TASK, CSV); + internalRequest.addParameter("configVersion", configVersion); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // bridge + public GetBridgeListResponse getBridgeList(String instanceId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, SERVICE, instanceId); + return invokeHttpClient(internalRequest, GetBridgeListResponse.class); + } + + public ServiceInfoResponse getBridge(String instanceId, String serviceId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, SERVICE, instanceId, serviceId); + return invokeHttpClient(internalRequest, ServiceInfoResponse.class); + } + + public void updateBridgeState(String instanceId, String serviceId, boolean state) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.PUT, SERVICE, instanceId, serviceId); + internalRequest.addParameter("state", String.valueOf(state)); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void bridgeReset(String instanceId, String serviceId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.PUT, SERVICE, instanceId, serviceId, RESET); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // ota products + public CreateOtaProductResponse createOtaProduct(String instanceId, String productKey, + CreateOtaProductRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.POST, OTA, PRODUCT, instanceId, productKey); + + return invokeHttpClient(internalRequest, CreateOtaProductResponse.class); + } + + public void deleteOtaProduct(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.DELETE, OTA, PRODUCT, instanceId, productKey); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public OtaProductDetail getOtaProductDetail(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, PRODUCT, instanceId, productKey); + + return invokeHttpClient(internalRequest, OtaProductDetail.class); + } + + public ListOtaProductResponse listOtaProduct(String instanceId, ListOtaProductRequest request) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, PRODUCT, instanceId); + + internalRequest.addParameter("page", Integer.toString(request.getPage())); + internalRequest.addParameter("perPage", Integer.toString(request.getPerPage())); + if (StringUtils.isNotBlank(request.getSearch())) { + internalRequest.addParameter("search", request.getSearch()); + } + return invokeHttpClient(internalRequest, ListOtaProductResponse.class); + } + + public ListOtaProductOperationResponse listOtaProductOperation(String instanceId, String productKey, + ListOtaProductOperationRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.GET, OTA, PRODUCT, instanceId, productKey, OPERATION); + + internalRequest.addParameter("page", Integer.toString(request.getPage())); + internalRequest.addParameter("perPage", Integer.toString(request.getPerPage())); + if (StringUtils.isNotBlank(request.getSearch())) { + internalRequest.addParameter("search", request.getSearch()); + } + + if (StringUtils.isNotBlank(request.getSearch())) { + internalRequest.addParameter("type", Integer.toString(request.getType())); + } + + if (StringUtils.isNotBlank(request.getSearch())) { + internalRequest.addParameter("date", request.getDate()); + } + return invokeHttpClient(internalRequest, ListOtaProductOperationResponse.class); + } + + public OtaProductConfig getOtaProductConfig(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, PRODUCT, instanceId, productKey, CONFIG); + + return invokeHttpClient(internalRequest, OtaProductConfig.class); + } + + // ota packages + public UploadOtaPackageResponse uploadOtaPackage(String instanceId, String productKey, + UploadOtaPackageRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.POST, OTA, PACKAGES, instanceId, productKey); + + return invokeHttpClient(internalRequest, UploadOtaPackageResponse.class); + } + + public ListOtaPackageResponse listOtaPackage(String instanceId, String productKey, + ListOtaPackageRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.GET, OTA, PACKAGES, instanceId, productKey); + internalRequest.addParameter("page", Integer.toString(request.getPage())); + internalRequest.addParameter("perPage", Integer.toString(request.getPerPage())); + if (StringUtils.isNotBlank(request.getSearchStr())) { + internalRequest.addParameter("searchStr", request.getSearchStr()); + } + + if (StringUtils.isNotBlank(request.getLabel())) { + internalRequest.addParameter("label", request.getLabel()); + } + + if (request.getOrderBy() != null) { + internalRequest.addParameter("orderBy", request.getOrderBy().name()); + } + + if (request.getOrderDirection() != null) { + internalRequest.addParameter("orderDirection", request.getOrderDirection().name()); + } + return invokeHttpClient(internalRequest, ListOtaPackageResponse.class); + } + + public void deleteOtaPackage(String instanceId, String productKey, int packageId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.DELETE, OTA, PACKAGES, instanceId, productKey, Integer.toString(packageId)); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public CheckOtaPackageResponse checkOtaPackage(String instanceId, String productKey, + CheckOtaPackageRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.POST, OTA, PACKAGES, instanceId, productKey, CHECK); + + return invokeHttpClient(internalRequest, CheckOtaPackageResponse.class); + } + + public OSStsResponse stsOtaPackage(String instanceId, String productKey, + String fileName, Long timestamp, Type type) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.POST, OTA, PACKAGES, instanceId, productKey, STS); + internalRequest.addParameter("fileName", fileName); + internalRequest.addParameter("timestamp", Long.toString(timestamp)); + internalRequest.addParameter("type", type.name()); + + return invokeHttpClient(internalRequest, OSStsResponse.class); + } + + // ota task + public CreateOtaTaskResponse addOtaTask(String instanceId, String productKey, CreateOtaTaskRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.POST, OTA, TASK, instanceId, productKey); + + return invokeHttpClient(internalRequest, CreateOtaTaskResponse.class); + } + + public void deleteOtaTask(String instanceId, String productKey, + int taskId, DeleteOtaTaskRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.DELETE, OTA, TASK, instanceId, + productKey, String.valueOf(taskId)); + internalRequest.addParameter("isTrashed", request.getIsTrashed().toString()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public UpdateOtaTaskResponse updateOtaTask(String instanceId, String productKey, + int taskId, UpdateOtaTaskRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, OTA, TASK, instanceId, productKey, String.valueOf(taskId)); + + return invokeHttpClient(internalRequest, UpdateOtaTaskResponse.class); + } + + public UpdateOtaTaskStatusResponse updateOtaTaskStatus(String instanceId, String productKey, + int taskId, UpdateOtaTaskStatusRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.PUT, OTA, TASK, + instanceId, productKey, String.valueOf(taskId), STATUS); + + return invokeHttpClient(internalRequest, UpdateOtaTaskStatusResponse.class); + } + + public GetOtaTaskResponse getOtaTask(String instanceId, String productKey, int taskId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, TASK, + instanceId, productKey, String.valueOf(taskId)); + + return invokeHttpClient(internalRequest, GetOtaTaskResponse.class); + } + + public ListOtaTaskResponse listOtaTask(String instanceId, String productKey, ListOtaTaskRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.GET, OTA, TASK, instanceId, productKey); + internalRequest.addParameter("page", Integer.toString(request.getPage())); + internalRequest.addParameter("perPage", Integer.toString(request.getPerPage())); + internalRequest.addParameter("status", request.getStatus()); + if (request.getOrderBy() != null) { + internalRequest.addParameter("orderBy", request.getOrderBy().name()); + } + + if (request.getDirection() != null) { + internalRequest.addParameter("direction", request.getDirection().name()); + } + + if (StringUtils.isNotBlank(request.getKeyword())) { + internalRequest.addParameter("keyword", request.getKeyword()); + } + + if (request.getIsTrashed() != null) { + internalRequest.addParameter("isTrashed", request.getIsTrashed().toString()); + } + + return invokeHttpClient(internalRequest, ListOtaTaskResponse.class); + } + + public void createOrUpdateGrayTask(String instanceId, String productKey, + int taskId, CreateOrUpdateGrayTaskRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.POST, OTA, TASK, + instanceId, productKey, String.valueOf(taskId), GRAY); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void updateGrayTaskStatus(String instanceId, String productKey, int taskId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.PUT, OTA, TASK, + instanceId, productKey, String.valueOf(taskId), GRAY, STATUS); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public GrayTask getGrayTask(String instanceId, String productKey, int taskId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, TASK, + instanceId, productKey, String.valueOf(taskId), GRAY); + + return invokeHttpClient(internalRequest, GrayTask.class); + } + + // ota device + public ListAllTestDeviceForTaskResponse listAllTestDeviceForTask(String instanceId, String productKey, int taskId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, DEVICES, instanceId, productKey, TASK, String.valueOf(taskId), TEST); + return invokeHttpClient(internalRequest, ListAllTestDeviceForTaskResponse.class); + } + + public SearchDeviceForTaskResponse searchDeviceForTask(String instanceId, String productKey, int taskId, + SearchType type, String param) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, DEVICES, instanceId, productKey, TASK, String.valueOf(taskId)); + internalRequest.addParameter("type", type.name()); + internalRequest.addParameter("param", param); + return invokeHttpClient(internalRequest, SearchDeviceForTaskResponse.class); + } + + // ota statistics + public OtaTaskIssuedStatisticsResponse otaTaskIssuedStatistics(String instanceId, String productKey, int taskId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, STATISTICS, instanceId, productKey, + TASK, String.valueOf(taskId), ISSUED); + + return invokeHttpClient(internalRequest, OtaTaskIssuedStatisticsResponse.class); + } + + public OtaTaskStatisticsResponse otaTaskStatistics(String instanceId, String productKey, int taskId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, STATISTICS, instanceId, productKey, + TASK, String.valueOf(taskId)); + + return invokeHttpClient(internalRequest, OtaTaskStatisticsResponse.class); + } + + public OtaTaskIssuedFailedStatisticsResponse otaTaskIssuedFailedStatistics(String instanceId, String productKey, + int taskId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, STATISTICS, instanceId, productKey, + TASK, String.valueOf(taskId), ISSUED, FAILED); + + return invokeHttpClient(internalRequest, OtaTaskIssuedFailedStatisticsResponse.class); + } + + public OtaTaskIssuedFailureInfoStatisticsResponse otaTaskIssuedFailureInfoStatistics(String instanceId, + String productKey, + int taskId, + Stage stage) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, STATISTICS, instanceId, productKey, + TASK, String.valueOf(taskId), ISSUED, FAILURES); + internalRequest.addParameter("stage", stage.getStage()); + return invokeHttpClient(internalRequest, OtaTaskIssuedFailureInfoStatisticsResponse.class); + } + + public OtaTaskStageStatisticsResponse otaTaskStageStatistics(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, STATISTICS, instanceId, productKey, + TASK, STAGE); + return invokeHttpClient(internalRequest, OtaTaskStageStatisticsResponse.class); + } + + public OtaTaskProductLineWeekStatisticsResponse otaTaskProductLineWeekStatistics(String instanceId, + String productKey, String date) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, STATISTICS, instanceId, productKey, + WEEK); + internalRequest.addParameter("date", date); + return invokeHttpClient(internalRequest, OtaTaskProductLineWeekStatisticsResponse.class); + } + + // ota packing + public ListOtaCompletedPackingResponse listOtaCompletedPacking(String instanceId, String productKey, + CommonOtaListRequest request) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, PACKING, instanceId, productKey, + COMPLETED); + internalRequest.addParameter("page", Integer.toString(request.getPage())); + internalRequest.addParameter("perPage", Integer.toString(request.getPerPage())); + return invokeHttpClient(internalRequest, ListOtaCompletedPackingResponse.class); + } + + public ListOtaUncompletedPackingResponse listOtaUncompletedPacking(String instanceId, String productKey, + CommonOtaListRequest request) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, PACKING, instanceId, productKey, + UNCOMPLETED); + internalRequest.addParameter("page", Integer.toString(request.getPage())); + internalRequest.addParameter("perPage", Integer.toString(request.getPerPage())); + return invokeHttpClient(internalRequest, ListOtaUncompletedPackingResponse.class); + } + + public CreateOtaPackingResponse createOtaPacking(String instanceId, String productKey, + CreateOtaPackingRequest request) { + InternalRequest internalRequest = createRequest(request, + HttpMethodName.POST, OTA, PACKING, instanceId, productKey); + return invokeHttpClient(internalRequest, CreateOtaPackingResponse.class); + } + + public GetOtaPackingStatusResponse getOtaPackingStatus(String instanceId, String productKey, + int issueId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, OTA, PACKING, instanceId, productKey, String.valueOf(issueId), STATUS); + return invokeHttpClient(internalRequest, GetOtaPackingStatusResponse.class); + } + + public CancelOtaPackingResponse cancelOtaPacking(String instanceId, String productKey, + int issueId, String stepName, boolean hasNextStep) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.PUT, OTA, PACKING, instanceId, productKey, String.valueOf(issueId), CANCEL); + internalRequest.addParameter("stepName", stepName); + internalRequest.addParameter("hasNextStep", Boolean.toString(hasNextStep)); + return invokeHttpClient(internalRequest, CancelOtaPackingResponse.class); + } + + public DeleteOtaPackingResponse deleteOtaPacking(String instanceId, String productKey, + int issueId, String stepName, boolean hasNextStep) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.DELETE, OTA, PACKING, instanceId, productKey, String.valueOf(issueId)); + internalRequest.addParameter("stepName", stepName); + internalRequest.addParameter("hasNextStep", Boolean.toString(hasNextStep)); + return invokeHttpClient(internalRequest, DeleteOtaPackingResponse.class); + } + + // batch device + public GetBatchPageResponse getBatchPage(String instanceId, CommonListRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, BATCH, instanceId); + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + } + return invokeHttpClient(internalRequest, GetBatchPageResponse.class); + } + + public BatchInfoResponse getBatch(String instanceId, String batchId, CommonListRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, BATCH, instanceId, batchId); + if (request.getPageNo() != null) { + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + } + if (request.getPageSize() != null) { + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + } + return invokeHttpClient(internalRequest, BatchInfoResponse.class); + } + + public BatchDownloadMqtt getBatchMqtt(String instanceId, String batchId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, BATCH, instanceId, batchId, MQTT); + + return invokeHttpClient(internalRequest, BatchDownloadMqtt.class); + } + + public GetBatchTuplesResponse getBatchTuples(String instanceId, String batchId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, BATCH, instanceId, batchId, DOWNLOAD); + + return invokeHttpClient(internalRequest, GetBatchTuplesResponse.class); + } + + //statistics + public StatsDeviceMessageResponse statsDeviceMessage(String instanceId, Cycle cycle, + long beginTime, long endTime) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, STATISTICS, instanceId, DEVICES, MESSAGE); + internalRequest.addParameter("cycle", cycle.name()); + internalRequest.addParameter("beginTime", Long.toString(beginTime)); + internalRequest.addParameter("endTime", Long.toString(endTime)); + + return invokeHttpClient(internalRequest, StatsDeviceMessageResponse.class); + } + + public StatsLivelyDeviceResponse statsLivelyDevice(String instanceId, Cycle cycle, + long beginTime, long endTime) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, STATISTICS, instanceId, DEVICES, LIVELY); + internalRequest.addParameter("cycle", cycle.name()); + internalRequest.addParameter("beginTime", Long.toString(beginTime)); + internalRequest.addParameter("endTime", Long.toString(endTime)); + + return invokeHttpClient(internalRequest, StatsLivelyDeviceResponse.class); + } + + public StatsDeviceTotalResponse statsDeviceTotal(String instanceId, Cycle cycle, + long beginTime, long endTime) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, STATISTICS, instanceId, DEVICES, TOTAL); + internalRequest.addParameter("cycle", cycle.name()); + internalRequest.addParameter("beginTime", Long.toString(beginTime)); + internalRequest.addParameter("endTime", Long.toString(endTime)); + + return invokeHttpClient(internalRequest, StatsDeviceTotalResponse.class); + } + + public DeviceStatesStatsResult statsDeviceStates(String instanceId) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, STATISTICS, instanceId, DEVICES, STATES); + + return invokeHttpClient(internalRequest, DeviceStatesStatsResult.class); + } + + public StatsProductTotalResponse statsProductTotal(String instanceId, Cycle cycle, + long beginTime, long endTime) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), + HttpMethodName.GET, STATISTICS, instanceId, PRODUCTS, TOTAL); + internalRequest.addParameter("cycle", cycle.name()); + internalRequest.addParameter("beginTime", Long.toString(beginTime)); + internalRequest.addParameter("endTime", Long.toString(endTime)); + + return invokeHttpClient(internalRequest, StatsProductTotalResponse.class); + } + + // instance extensions + public void disableResource(String instanceId, ResourceSupplier supplier, ResourceType resourceType) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + INSTANCE, instanceId, RESOURCES, DISABLE); + internalRequest.addParameter("supplier", supplier.name()); + internalRequest.addParameter("resourceType", resourceType.name()); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void unbindResource(String instanceId, ResourceSupplier supplier, ResourceType resourceType) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + INSTANCE, instanceId, RESOURCES, UNBIND); + internalRequest.addParameter("supplier", supplier.name()); + internalRequest.addParameter("resourceType", resourceType.name()); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public UploadKafkaConfigFileResponse uploadKafkaConfigFile(File file) { + InternalRequest internalRequest = createUploadRequest("file", file, + HttpMethodName.POST, PLATFORM_RULECHAINS, FILE, EXTERNAL_KAFKA); + return invokeHttpClient(internalRequest, UploadKafkaConfigFileResponse.class); + } + + // TSDB + public void tsdbModify(String instanceId, String productKey, TsdbInitRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + TSDB, instanceId, productKey); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public TsdbQueryResponse tsdbQueryProperty(String instanceId, String productKey, TsdbQueryRequest request) { + + return tsdbQueryProperty(instanceId, productKey, request, null); + } + + public TsdbQueryResponse tsdbQueryProperty(String instanceId, String productKey, TsdbQueryRequest request, + String version) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + TSDB, instanceId, productKey, QUERY); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, TsdbQueryResponse.class); + } + + public TsdbQueryResponse tsdbQueryEvent(String instanceId, String productKey, String event, + TsdbQueryRequest request) { + return tsdbQueryEvent(instanceId, productKey, event, request, null); + } + + public TsdbQueryResponse tsdbQueryEvent(String instanceId, String productKey, String event, + TsdbQueryRequest request, String version) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + TSDB, instanceId, productKey, QUERY, event); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, TsdbQueryResponse.class); + } + + public TsdbMappingResponse tsdbMapping(String instanceId, String productKey, TsdbMappingRequest request) { + return tsdbMapping(instanceId, productKey, request, null); + } + + public TsdbMappingResponse tsdbMapping(String instanceId, String productKey, TsdbMappingRequest request, + String version) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + TSDB, instanceId, productKey, MAPPING); + if (StringUtils.isNotBlank(version)) { + internalRequest.addParameter("version", version); + } + return invokeHttpClient(internalRequest, TsdbMappingResponse.class); + } + + // BIE Protocols + public ListProtocolResponse getProtocolList(ResourceSupplier supplier, String protocolName, + int pageNo, int pageSize) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PROTOCOLS); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + + if (supplier != null) { + internalRequest.addParameter("supplier", supplier.name()); + } + + if (StringUtils.isNotBlank(protocolName)) { + internalRequest.addParameter("protocolName", protocolName); + } + return invokeHttpClient(internalRequest, ListProtocolResponse.class); + } + + public ProtocolResponse createProtocol(CreateProtocolRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + PROTOCOLS); + + return invokeHttpClient(internalRequest, ProtocolResponse.class); + } + + public void modifyProtocol(String protocolId, BusinessTemplatesAppRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + PROTOCOLS, protocolId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ProtocolResponse getProtocol(String protocolId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PROTOCOLS, protocolId); + + return invokeHttpClient(internalRequest, ProtocolResponse.class); + } + + public void deleteProtocol(String protocolId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + PROTOCOLS, protocolId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public BusinessTemplatesApp getProtocolsApp(String protocolId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PROTOCOLS, protocolId, APP); + + return invokeHttpClient(internalRequest, BusinessTemplatesApp.class); + } + + public BusinessTemplatesAppRegistryList getProtocolsRegistry(String protocolId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PROTOCOLS, protocolId, REGISTRIES); + + return invokeHttpClient(internalRequest, BusinessTemplatesAppRegistryList.class); + } + + public BusinessTemplatesAppRegistry addProtocolsRegistry(String protocolId, + BusinessTemplatesAppRegistryRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + PROTOCOLS, protocolId, REGISTRIES); + + return invokeHttpClient(internalRequest, BusinessTemplatesAppRegistry.class); + } + + public void modifyProtocolsRegistry(String protocolId, String registryId, + BusinessTemplatesAppRegistryRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + PROTOCOLS, protocolId, REGISTRIES, registryId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteProtocolsRegistry(String protocolId, String registryId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + PROTOCOLS, protocolId, REGISTRIES, registryId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + public ProtocolsMarkdownResponse modifyProtocolsMarkdown(String protocolId, + ProtocolsMarkdownRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + PROTOCOLS, protocolId, MARKDOWN); + + return invokeHttpClient(internalRequest, ProtocolsMarkdownResponse.class); + } + + public ProtocolsMarkdownResponse getProtocolsMarkdown(String protocolId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PROTOCOLS, protocolId, MARKDOWN); + + return invokeHttpClient(internalRequest, ProtocolsMarkdownResponse.class); + } + + // BIE Nodes + public ListNodeResponse listNode(String name, int pageNo, int pageSize) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + NODES); + + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + + if (StringUtils.isNotBlank(name)) { + internalRequest.addParameter("name", name); + } + return invokeHttpClient(internalRequest, ListNodeResponse.class); + } + + public NodeResponse getNode(String nodeId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + NODES, nodeId); + + return invokeHttpClient(internalRequest, NodeResponse.class); + } + + public NodeResponse createNode(CreateNodeRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + NODES); + + return invokeHttpClient(internalRequest, NodeResponse.class); + } + + public void modifyNode(String nodeId, ModifyNodeRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + NODES, nodeId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteNode(String nodeId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + NODES, nodeId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public GetInstallNodePropertyResponse getInstallNodeProperty(String nodeId, String property) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + NODES, nodeId, PROPERTIES, property); + + return invokeHttpClient(internalRequest, GetInstallNodePropertyResponse.class); + } + + public GetInstallNodeInitResponse getInstallNodeInit(String nodeId, InstallMethod method, InstallPlatform platform) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + NODES, nodeId, INIT); + + if (method != null) { + internalRequest.addParameter("method", method.name()); + } + if (platform != null) { + internalRequest.addParameter("platform", platform.name()); + } + return invokeHttpClient(internalRequest, GetInstallNodeInitResponse.class); + } + + public void deployProtocol(String nodeId, String protocolId, String instanceId, String amqp, String mqtt, + DeployBusinessTemplatesRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + NODES, nodeId, DEPLOY, protocolId, instanceId); + + if (StringUtils.isNotBlank(amqp)) { + internalRequest.addParameter("amqp", amqp); + } + if (StringUtils.isNotBlank(mqtt)) { + internalRequest.addParameter("mqtt", mqtt); + } + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // BIE Apps + public ListNodeAppsResponse listNodeApps(String nodeId, int pageNo, int pageSize) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PROTOCOLS, APPS, NODES, nodeId); + + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + + + return invokeHttpClient(internalRequest, ListNodeAppsResponse.class); + } + + public ListNodeAppsResponse listInstanceApps(String instanceId, int pageNo, int pageSize) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PROTOCOLS, APPS, INSTANCE, instanceId); + + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + + + return invokeHttpClient(internalRequest, ListNodeAppsResponse.class); + } + + public void modifyInstanceApps(String appId, String nodeId, String instanceId, + String protocolId, boolean upgrade, BusinessTemplatesAppRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + PROTOCOLS, APPS, appId, nodeId, protocolId, instanceId); + + internalRequest.addParameter("upgrade", Boolean.toString(upgrade)); + + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteInstanceApps(String appId, String nodeId, String instanceId, String protocolId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + PROTOCOLS, APPS, appId, nodeId, protocolId, instanceId); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public BusinessTemplatesApp getDeployApp(String appId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PROTOCOLS, APPS, appId, APP); + + return invokeHttpClient(internalRequest, BusinessTemplatesApp.class); + } + + public AppResponse getApp(String appId) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PROTOCOLS, APPS, appId); + + return invokeHttpClient(internalRequest, AppResponse.class); + } + + // BIE + public GetEdgeGatewayNodeDetailResponse getEdgeGatewayNodeDetail(String instanceId, String productKey, + String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, productKey, deviceName); + + return invokeHttpClient(internalRequest, GetEdgeGatewayNodeDetailResponse.class); + } + + public ListEdgeGatewayNodeResponse listEdgeGatewayNode(String instanceId, ListEdgeGatewayNodeRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, + EDGE, GATEWAY, instanceId); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + if (StringUtils.isNotEmpty(request.getProductKey())) { + internalRequest.addParameter("productKey", request.getProductKey()); + } + if (StringUtils.isNotEmpty(request.getAlias())) { + internalRequest.addParameter("alias", request.getAlias()); + } + return invokeHttpClient(internalRequest, ListEdgeGatewayNodeResponse.class); + } + + public GetNodeAppInfoResponse getEdgeGatewayNodeAppInfo(String instanceId, String productKey, + String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, productKey, deviceName, APPS); + + return invokeHttpClient(internalRequest, GetNodeAppInfoResponse.class); + } + + public GetAppInfoResponse deployAndUnloadEdgeGatewayApp(String instanceId, String productKey, + String deviceName, String name, + AppAction appAction) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, + EDGE, GATEWAY, instanceId, productKey, deviceName, APPS); + internalRequest.addParameter("name", name); + internalRequest.addParameter("deploy", appAction.name()); + return invokeHttpClient(internalRequest, GetAppInfoResponse.class); + } + + public GetAppInfoResponse configEdgeGatewayAppEnv(String instanceId, String productKey, + String deviceName, String name) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, + EDGE, GATEWAY, instanceId, productKey, deviceName, APP, ENV); + internalRequest.addParameter("name", name); + return invokeHttpClient(internalRequest, GetAppInfoResponse.class); + } + + public DriverListResponse getEdgeGatewayNodeDriverRefs(String instanceId, String productKey, + String deviceName, + GetNodeDriverRefsRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.GET, + EDGE, GATEWAY, instanceId, productKey, deviceName, DRIVERREFS); + internalRequest.addParameter("driverName", request.getDriverName()); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + + return invokeHttpClient(internalRequest, DriverListResponse.class); + } + + public DriverInfo introduceEdgeGatewayDrivers(String instanceId, String productKey, + String deviceName, + String driverName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + EDGE, GATEWAY, instanceId, productKey, deviceName, INTRODUCE, DRIVER); + internalRequest.addParameter("driverName", driverName); + + return invokeHttpClient(internalRequest, DriverInfo.class); + } + + public DriverListResponse getEdgeGatewayDrivers(String instanceId, String productKey, + String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, productKey, deviceName, DRIVERS); + + return invokeHttpClient(internalRequest, DriverListResponse.class); + } + + public DriverInfo getEdgeGatewayNodeDriverConfig(String instanceId, String productKey, + String deviceName, + String driverInstName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, productKey, deviceName, DRIVER, CONFIG); + internalRequest.addParameter("driverInstName", driverInstName); + + return invokeHttpClient(internalRequest, DriverInfo.class); + } + + public DriverInfo updateEdgeGatewayNodeDriverConfig(String instanceId, String productKey, + String deviceName, + String driverInstName, + UpdateEdgeGatewayNodeDriverConfigRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + EDGE, GATEWAY, instanceId, productKey, deviceName, DRIVER, CONFIG); + internalRequest.addParameter("driverInstName", driverInstName); + + return invokeHttpClient(internalRequest, DriverInfo.class); + } + + public void deployEdgeGatewayDriver(String instanceId, String productKey, + String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + EDGE, GATEWAY, instanceId, productKey, deviceName, DRIVER, DEPLOY); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deleteEdgeGatewayDriver(String instanceId, String productKey, + String deviceName, String driverInstName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + EDGE, GATEWAY, instanceId, productKey, deviceName, DRIVER, DELETE); + internalRequest.addParameter("driverInstName", driverInstName); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void syncEdgeGatewaySubDevices(String instanceId, String productKey, + String deviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + EDGE, GATEWAY, instanceId, productKey, deviceName, SYNC, DEVICE); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public AppInfoListResponse getEdgeGatewayAppList(String instanceId, GetAppListRequest request) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, APPS); + + internalRequest.addParameter("name", request.getName()); + internalRequest.addParameter("selector", request.getSelector()); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + return invokeHttpClient(internalRequest, AppInfoListResponse.class); + } + + public BusinessTemplatesListResponse getEdgeGatewaygetBusinessTemplates(String instanceId, + GetBusinessTemplateRequest request) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, BUSINESSTEMPLATES); + + internalRequest.addParameter("name", request.getName()); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + return invokeHttpClient(internalRequest, BusinessTemplatesListResponse.class); + } + + public void deviceBindEdgeGatewayDriver(String instanceId, String productKey, + String deviceName, BindSubDeviceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + EDGE, GATEWAY, instanceId, productKey, deviceName, DRIVERS, DEVICE, BIND); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deviceUnbindEdgeGatewayDriver(String instanceId, String productKey, + String deviceName, BindSubDeviceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + EDGE, GATEWAY, instanceId, productKey, deviceName, DRIVERS, DEVICE, UNBIND); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public GetBieDeviceListResponse getEdgeGatewayDriverBindSubDeviceList(String instanceId, String productKey, + String deviceName, String driverInstName, + int pageNo, int pageSize) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, productKey, deviceName, driverInstName, DRIVER, DEVICES); + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + return invokeHttpClient(internalRequest, GetBieDeviceListResponse.class); + } + + public GetAccesstemplatesResponse getEdgeGatewayAccessTemplates(String instanceId, String productKey, + String deviceName, String driverName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, productKey, deviceName, ACCESSTEMPLATES, DEVICEMODELS); + internalRequest.addParameter("driverName", driverName); + + return invokeHttpClient(internalRequest, GetAccesstemplatesResponse.class); + } + + public GetBieDeviceConfigResponse updateEdgeGatewaySubDeviceConfig(String instanceId, String productKey, + String deviceName, String subProductKey, + String subDeviceName, + UpdateEdgeGatewaySubDeviceConfigRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + EDGE, GATEWAY, instanceId, productKey, deviceName, NODEDEVICES, CONFIG); + internalRequest.addParameter("subProductKey", subProductKey); + internalRequest.addParameter("subDeviceName", subDeviceName); + return invokeHttpClient(internalRequest, GetBieDeviceConfigResponse.class); + } + + public GetBieDeviceConfigResponse getEdgeGatewaySubDeviceConfig(String instanceId, String productKey, + String deviceName, String subProductKey, + String subDeviceName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, productKey, deviceName, NODEDEVICES, CONFIG); + internalRequest.addParameter("subProductKey", subProductKey); + internalRequest.addParameter("subDeviceName", subDeviceName); + return invokeHttpClient(internalRequest, GetBieDeviceConfigResponse.class); + } + + public UnbindEdgeGatewayDriverSubDeviceListResponse unbindEdgeGatewayDriverSubDeviceList(String instanceId, + String productKey, + String deviceName, + UnbindEdgeGatewayDriverSubDeviceListRequest request) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, productKey, deviceName, UNBIND, DRIVER, SUB_DEVICE); + internalRequest.addParameter("subDeviceName", request.getSubDeviceName()); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + return invokeHttpClient(internalRequest, UnbindEdgeGatewayDriverSubDeviceListResponse.class); + } + + public GetAppInfoResponse getEdgeGatewayAppDetail(String instanceId, String appName) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + EDGE, GATEWAY, instanceId, APP, DETAIL); + internalRequest.addParameter("appName", appName); + + return invokeHttpClient(internalRequest, GetAppInfoResponse.class); + } + + // version + public void publishProductDTMLVersion(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.POST, + PRODUCTS, VERSION_PATH, instanceId, productKey, PUBLISH); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public ListVersionResponse listVersion(String instanceId, String productKey) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + PRODUCTS, VERSION_PATH, instanceId, productKey); + return invokeHttpClient(internalRequest, ListVersionResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, request); + } + return request; + } + + private InternalRequest createUploadRequest(String name, File file, + HttpMethodName httpMethod, String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + FilePart fp; + try { + fp = new FilePart(name, file); + } catch (FileNotFoundException e) { + throw new BceClientException("文件不存在或路径错误."); + } + Part[] parts = {fp}; + MultipartRequestEntity content = new MultipartRequestEntity(parts, new HttpMethodParams()); + request.addHeader(Headers.CONTENT_LENGTH, Long.toString(content.getContentLength())); + request.addHeader(Headers.CONTENT_TYPE, content.getContentType()); + try { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + content.writeRequest(os); + request.setContent(RestartableInputStream.wrap(os.toByteArray())); + } catch (IOException e) { + throw new BceClientException("内部错误.", e); + } + return request; + } + throw new BceClientException("上传文件只能使用post或put请求方法."); + } + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/CommonListRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/CommonListRequest.java new file mode 100644 index 00000000..d3021a2a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/CommonListRequest.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * common list resource request + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CommonListRequest extends GenericAccountRequest { + + private String order; + private String orderBy; + @Builder.Default + private Integer pageNo = 1; + @Builder.Default + private Integer pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/CommonResult.java b/src/main/java/com/baidubce/services/iotdmp/model/CommonResult.java new file mode 100644 index 00000000..d7d6b200 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/CommonResult.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CommonResult extends AbstractBceResponse { + private String result; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/Constant.java b/src/main/java/com/baidubce/services/iotdmp/model/Constant.java new file mode 100644 index 00000000..80ee54ce --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/Constant.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model; + +import java.util.HashSet; +import java.util.Set; + +public class Constant { + + public static final Set CONTEXT = new HashSet() { + { + add("dtml:context:thing;1"); + } + }; + + public static final String COMMAND = "Command"; + public static final String COMPONENT = "Component"; + public static final String EVENT = "Event"; + public static final String PROPERTY = "Property"; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmAction.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmAction.java new file mode 100644 index 00000000..60e6f0a9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmAction.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +public enum AlarmAction { + TRIGGER, PROCESS, IGNORE +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmNotification.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmNotification.java new file mode 100644 index 00000000..5041d4ab --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmNotification.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +public enum AlarmNotification { + + ALARM_CENTRE +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRecordInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRecordInfo.java new file mode 100644 index 00000000..3cb9dbf1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRecordInfo.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AlarmRecordInfo extends AbstractBceResponse { + private String instanceId; + private String ruleId; + private String recordId; + private String name; + private String description; + private int alarmLevel; + private String status; + private String ownerId; + private String ownerName; + private String alarmContent; + private String processContent; + private String triggerTime; + private String processTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRecordStatus.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRecordStatus.java new file mode 100644 index 00000000..85ac7ebf --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRecordStatus.java @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +public enum AlarmRecordStatus { + UNTREATED, + PROCESSED, + IGNORED +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRuleInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRuleInfo.java new file mode 100644 index 00000000..059a4948 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRuleInfo.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.Set; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AlarmRuleInfo extends AbstractBceResponse { + private String instanceId; + private String ruleId; + private String name; + private String description; + private int alarmLevel; + private Set notification; + private boolean activeState; + private String alarmState; + private String alarmPattern; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRuleStatus.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRuleStatus.java new file mode 100644 index 00000000..729a43e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/AlarmRuleStatus.java @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +public enum AlarmRuleStatus { + + NORMAL, + ABNORMAL +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/BatchDeleteAlarmRuleRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/BatchDeleteAlarmRuleRequest.java new file mode 100644 index 00000000..0923ee35 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/BatchDeleteAlarmRuleRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.RequiredArgsConstructor; + +import java.util.Set; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteAlarmRuleRequest extends GenericAccountRequest { + private Set rules; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/BatchProcessAlarmRecordRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/BatchProcessAlarmRecordRequest.java new file mode 100644 index 00000000..5c6c48ce --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/BatchProcessAlarmRecordRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.RequiredArgsConstructor; + +import java.util.Set; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchProcessAlarmRecordRequest extends GenericAccountRequest { + private final AlarmAction action; + private String processContent; + private String ownerId; + private final String ownerName; + private final Set records; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/CreateAlarmRuleRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/CreateAlarmRuleRequest.java new file mode 100644 index 00000000..e725eb21 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/CreateAlarmRuleRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.RequiredArgsConstructor; + +import java.util.Set; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateAlarmRuleRequest extends GenericAccountRequest { + private final String name; + private String description; + private final int alarmLevel; + private final Set notification; + private final String alarmPattern; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/ListAlarmRecordRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/ListAlarmRecordRequest.java new file mode 100644 index 00000000..3ba96d97 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/ListAlarmRecordRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListAlarmRecordRequest extends GenericAccountRequest { + private String cursor; + private String name; + private Integer alarmLevel; + protected Integer pageSize = 10; + private AlarmRecordStatus status; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/ListAlarmRecordResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/ListAlarmRecordResponse.java new file mode 100644 index 00000000..ce8fa356 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/ListAlarmRecordResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListAlarmRecordResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private int pageSize; + private String next; + private String name; + private Integer alarmLevel; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/ListAlarmRuleResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/ListAlarmRuleResponse.java new file mode 100644 index 00000000..820544f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/ListAlarmRuleResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListAlarmRuleResponse extends AbstractBceResponse { + private String name; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/TriggerAlarmRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/TriggerAlarmRequest.java new file mode 100644 index 00000000..76e5e9af --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/TriggerAlarmRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TriggerAlarmRequest extends GenericAccountRequest { + private Map alarmContent; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/alarm/UpdateAlarmRuleRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/alarm/UpdateAlarmRuleRequest.java new file mode 100644 index 00000000..202c9e96 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/alarm/UpdateAlarmRuleRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.alarm; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateAlarmRuleRequest extends GenericAccountRequest { + private String description; + private Integer alarmLevel; + private Set notifications; + private boolean updated; + private String alarmPattern; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/anno/BceJsonStringResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/anno/BceJsonStringResponse.java new file mode 100644 index 00000000..addbe145 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/anno/BceJsonStringResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.anno; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface BceJsonStringResponse { +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/anno/BceListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/anno/BceListResponse.java new file mode 100644 index 00000000..fb0cc695 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/anno/BceListResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.anno; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface BceListResponse { + +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/app/AppResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/app/AppResponse.java new file mode 100644 index 00000000..7fa6a3f2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/app/AppResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.app; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AppResponse extends AbstractBceResponse { + private String protocolId; + private String protocolName; + private String supplierType; + private String protocolVersion; + private String description; + private String appName; + private String appId; + private String instanceId; + private String instanceName; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/app/ListNodeAppsResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/app/ListNodeAppsResponse.java new file mode 100644 index 00000000..9423584c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/app/ListNodeAppsResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.app; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListNodeAppsResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/app/NodeAppResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/app/NodeAppResponse.java new file mode 100644 index 00000000..7cba58a0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/app/NodeAppResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.app; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class NodeAppResponse extends AbstractBceResponse { + private String appId; + private String appName; + private String protocolId; + private String nodeId; + private String protocolName; + private String type; + private String version; + private String instanceId; + private String instanceName; + private String status; + private String description; + private String createTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppAction.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppAction.java new file mode 100644 index 00000000..17933b5f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppAction.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + + +public enum AppAction { + deploy, unload +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoConfig.java new file mode 100644 index 00000000..d3cd63a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoConfig.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AppInfoConfig { + private String name; + private String description; + private Map labels; + private Map data; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoListResponse.java new file mode 100644 index 00000000..47b2a229 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoListResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AppInfoListResponse extends AbstractBceResponse { + private int total; + private int pageNo; + private int pageSize; + private List items; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoRegistry.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoRegistry.java new file mode 100644 index 00000000..000d29bc --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoRegistry.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AppInfoRegistry { + private String name; + private String description; + private String address; + private String username; + private String password; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoService.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoService.java new file mode 100644 index 00000000..33fe54e1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoService.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.services.iotdmp.model.bie.protocol.BiePortProtocol; +import com.baidubce.services.iotdmp.model.bie.protocol.BiePortServiceType; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AppInfoService { + private String name; + private String image; + private List ports; + private List env; + private List volumeMounts; + + @Data + @AllArgsConstructor + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Port { + private Integer containerPort; + private BiePortServiceType serviceType; + private Integer hostPort; + private Integer nodePort; + private BiePortProtocol protocol; + + public Port update(Port other) { + this.hostPort = other.getHostPort(); + this.nodePort = other.getNodePort(); + this.containerPort = other.getContainerPort(); + return this; + } + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Env { + private String name; + private String value; + } + + @Data + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class VolumeMounts { + private String name; + private String mountPath; + private String subPath; + private boolean readOnly = true; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoVolume.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoVolume.java new file mode 100644 index 00000000..f9c4b889 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/AppInfoVolume.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AppInfoVolume { + private String name; + private AppInfoConfig config; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/BindSubDeviceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/BindSubDeviceRequest.java new file mode 100644 index 00000000..34544cf2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/BindSubDeviceRequest.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BindSubDeviceRequest extends GenericAccountRequest { + @NotNull + private List devices; + private String driverInstName; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + @AllArgsConstructor + public static class SubDevicesRequest { + private String productKey; + private String deviceName; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/BusinessTemplatesInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/BusinessTemplatesInfo.java new file mode 100644 index 00000000..3408584e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/BusinessTemplatesInfo.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BusinessTemplatesInfo { + private String name; + private String description; + private String mode; + private Map labels; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/BusinessTemplatesListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/BusinessTemplatesListResponse.java new file mode 100644 index 00000000..ab1a5be1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/BusinessTemplatesListResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BusinessTemplatesListResponse extends AbstractBceResponse { + + private int total; + private int pageNo; + private int pageSize; + private List items; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ChannelConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ChannelConfig.java new file mode 100644 index 00000000..4a57935a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ChannelConfig.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ChannelConfig { + private String channelId; + private ModbusChannel modbus; + private OpcuaChannel opcua; + private OpcdaChannel opcda; + private IEC104Channel iec104; + private BacnetChannel bacnet; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class IEC104Channel { + private String protocol; + private String address; + private int port; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class OpcuaChannel { + private byte id; + private String endpoint; + private int timeout; + private OpcuaSecurity security; + private OpcuaAuth auth; + private OpcuaCertificate certificate; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class OpcdaChannel { + private String server; + private String host; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class BacnetChannel { + private String address; + private int port; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class OpcuaSecurity { + private String policy; + private String mode; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class OpcuaAuth { + private String username; + private String password; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class OpcuaCertificate { + private String cert; + private String key; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/DriverConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/DriverConfig.java new file mode 100644 index 00000000..c3a77bed --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/DriverConfig.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DriverConfig { + private List channels; + private List ipcServices; + private String custom; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/DriverInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/DriverInfo.java new file mode 100644 index 00000000..8dfb72d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/DriverInfo.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DriverInfo extends AbstractBceResponse { + private String name; + private int type; + private String protocol; + private String description; + private boolean bind; + private Object application; + private Object configuration; + private String createTime; + private DriverConfig driverConfig; + private String driverInstName; + private String driverName; + private String namespace; + private String nodeName; + private String updateTime; + private String version; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/DriverListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/DriverListResponse.java new file mode 100644 index 00000000..6711141e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/DriverListResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DriverListResponse extends AbstractBceResponse { + private String name; + private int pageNo; + private int total; + private String selector; + List items; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetAccesstemplatesResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetAccesstemplatesResponse.java new file mode 100644 index 00000000..d4610f23 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetAccesstemplatesResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetAccesstemplatesResponse extends AbstractBceResponse { + private List items; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class AccesstemplatesInfo { + private String name; + private String description; + private String protocol; + private String createTime; + private String updateTime; + + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetAppInfoResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetAppInfoResponse.java new file mode 100644 index 00000000..df3b2d6a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetAppInfoResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetAppInfoResponse extends AbstractBceResponse { + private String name; + private String mode; + private String coreStatus; + private String description; + private Object autoScaleCfg; + private String createTime; + private String coreTime; + private List initServices; + private List services; + private List registries; + private List volumes; + private Object jobConfig; + private Map labels; + private String namespace; + private Object ota; + private int replica; + private String selector; + private boolean system; + private String type; + private String version; + private Object volumeMounts; + private String workload; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetAppListRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetAppListRequest.java new file mode 100644 index 00000000..da548a17 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetAppListRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetAppListRequest extends GenericAccountRequest { + private String name; + private String selector; + private int pageSize = 10; + private int pageNo = 1; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetBieDeviceConfigResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetBieDeviceConfigResponse.java new file mode 100644 index 00000000..244fd2d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetBieDeviceConfigResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetBieDeviceConfigResponse extends AbstractBceResponse { + private String name; + private String productName; + private String productKey; + private String accessTemplate; + private String nodeName; + private String driverName; + private String driverInstName; + private String bieDeviceName; + private SubDeviceConfigUpdate config; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetBieDeviceListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetBieDeviceListResponse.java new file mode 100644 index 00000000..c979bd89 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetBieDeviceListResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetBieDeviceListResponse extends AbstractBceResponse { + private List items; + private int total; + private int pageNo; + private int pageSize; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class SubDeviceBindInfo { + private String name; + private String productKey; + private String productName; + private String deviceModel; + private String bieDeviceName; + private String accessTemplate; + private String nodeName; + private String driverName; + private String driverInstName; + private int status; + private boolean bind; + + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetBusinessTemplateRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetBusinessTemplateRequest.java new file mode 100644 index 00000000..69df6fef --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetBusinessTemplateRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetBusinessTemplateRequest extends GenericAccountRequest { + private String name; + private int pageSize = 10; + private int pageNo = 1; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetEdgeGatewayNodeDetailResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetEdgeGatewayNodeDetailResponse.java new file mode 100644 index 00000000..b7305d4e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetEdgeGatewayNodeDetailResponse.java @@ -0,0 +1,209 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import java.util.List; +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetEdgeGatewayNodeDetailResponse extends AbstractBceResponse { + private String namespace; + private String name; + private String version; + private String createTime; + private String accelerator; + private Map labels; + private Map annotations; + private String appMode; + private List sysApps; + private String description; + private boolean cluster; + private int ready; + private String mode; + private String nodeMode; + private String link; + private String coreId; + private Desire desire; + private Report report; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Desire { + private List apps; + private List devices; + private List sysapps; + + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Report { + private String time; + private List apps; + private List sysapps; + private Core core; + private List appstats; + private List sysappstats; + private Map node; + private Map nodestats; + private Map nodeinsnum; + private String modeinfo; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class AppStat { + private String name; + private String version; + private String deployType; + private String status; + private Map instances; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Instance { + private String name; + private String appName; + private Usage usage; + private String status; + private String ip; + private String nodeName; + private String createTime; + private List containers; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Usage { + private String cpu; + private String memory; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Container { + private String name; + private Usage usage; + private String state; + } + } + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class NodeInfo { + private String hostname; + private String address; + private String arch; + private String kernelVer; + private String os; + private String containerRuntime; + private String machineID; + private String bootID; + private String systemUUID; + private String osImage; + private String role; + private Map labels; + private String clientIP; + + // Getters and setters + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class NodeStats { + private boolean ready; + private Usage usage; + private Capacity capacity; + private Percent percent; + private NetIO netio; + private Extension extension; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Usage { + private String cpu; + private String disk; + private String memory; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Capacity { + private String cpu; + private String disk; + private String memory; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Percent { + private String cpu; + private String disk; + private String memory; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class NetIO { + private String netBytesRecv; + private String netBytesSent; + private String netPacketsRecv; + private String netPacketsSent; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Extension { + private double diskPercent; + private long diskTotal; + private long diskUsed; + private long netBytesRecv; + private long netBytesSent; + private long netPacketsRecv; + private long netPacketsSent; + } + } + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class App { + private String name; + private String version; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Device { + private String name; + private String version; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class SysApp { + private String name; + private String version; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Core { + private String goVersion; + private String binVersion; + private String gitRevision; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetNodeAppInfoResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetNodeAppInfoResponse.java new file mode 100644 index 00000000..37ad5237 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetNodeAppInfoResponse.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetNodeAppInfoResponse extends AbstractBceResponse { + private List items; + private int total; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class AppInfo { + private String name; + private String description; + private Map labels; + private String selector; + private String nodeSelector; + private String version; + private String namespace; + private String createTime; + private String cronTime; + private Object ota; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetNodeDriverRefsRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetNodeDriverRefsRequest.java new file mode 100644 index 00000000..7db94c8a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/GetNodeDriverRefsRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetNodeDriverRefsRequest extends GenericAccountRequest { + private String driverName; + protected int pageNo = 1; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/IpcServiceConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/IpcServiceConfig.java new file mode 100644 index 00000000..e2faca22 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/IpcServiceConfig.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class IpcServiceConfig { + private String name; + @JsonProperty("fps") + private double fPS; + private String imageFormat; + private Scale scale; + private String address; + private IPCRequest request; + private IPCBody body; + private Boolean upload; + private Boolean cache; + private String cachePath; + private int cacheTime = 3; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class IPCRequest { + private Map params; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Scale { + private boolean enable; + private int height; + private int width; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class IPCBody { + private String content; + private String imageType; + private String imageName; + private Map params; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ListEdgeGatewayNodeRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ListEdgeGatewayNodeRequest.java new file mode 100644 index 00000000..261e7d1e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ListEdgeGatewayNodeRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListEdgeGatewayNodeRequest extends GenericAccountRequest { + private String productKey; + private String alias; + private int pageNo = 1; + private int pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ListEdgeGatewayNodeResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ListEdgeGatewayNodeResponse.java new file mode 100644 index 00000000..e8681909 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ListEdgeGatewayNodeResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListEdgeGatewayNodeResponse extends AbstractBceResponse { + private String productKey; + private String alias; + private List result; + private int totalCount; + private int pageSize; + private int pageNo; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class EdgeGateWayNodeInfo { + private String productKey; + private String productName; + private String deviceName; + private String alias; + private boolean activeState; + private String activeTime; + private boolean onlineState; + private String lastOnlineTime; + private boolean enableState; + private boolean banState; + private int connectState; + private String createTime; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ModbusChannel.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ModbusChannel.java new file mode 100644 index 00000000..bbda4a93 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/ModbusChannel.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ModbusChannel { + private TcpConfig tcp; + private RtuConfig rtu; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class TcpConfig { + private String address; + private int port; + } + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class RtuConfig { + private String port; + @JsonProperty("baudrate") + private int baudRate = 19200; + private String parity = "E"; + @JsonProperty("databit") + private int dataBit = 8; + @JsonProperty("stopbit") + private int stopBit = 1; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/SubDeviceConfigUpdate.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/SubDeviceConfigUpdate.java new file mode 100644 index 00000000..1841314d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/SubDeviceConfigUpdate.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SubDeviceConfigUpdate { + private IpcServiceConfig ipc; + private Modbus modbus; + private Opcua opcua; + private Opcda opcda; + private IEC104 iec104; + private Bacnet bacnet; + private String custom; + + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class IpcServiceConfig { + private String name; + private boolean system; + private String remoteAddress; + private boolean agentEnable; + private String serviceName; + private String streamAddress; + private String resultTopic; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Opcda { + private int interval; + private String channelId; + private String group; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Opcua { + private int interval; + private int nsOffset; + private int idOffset; + private String group; + private String channelId; + + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Modbus { + private int slaveId; + private int interval; + private String channelId; + + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class IEC104 { + private String channelId; + private int doOffset; + private int diOffset; + private int piOffset; + private int aiOffset; + private int aoOffset; + private int interval; + + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Bacnet { + private int interval; + private int deviceId; + private String channelId; + private int addressOffset; + + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UnbindEdgeGatewayDriverSubDeviceListRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UnbindEdgeGatewayDriverSubDeviceListRequest.java new file mode 100644 index 00000000..ea570dc6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UnbindEdgeGatewayDriverSubDeviceListRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UnbindEdgeGatewayDriverSubDeviceListRequest extends GenericAccountRequest { + private String subDeviceName; + private int pageSize = 10; + private int pageNo = 1; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UnbindEdgeGatewayDriverSubDeviceListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UnbindEdgeGatewayDriverSubDeviceListResponse.java new file mode 100644 index 00000000..ae081d11 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UnbindEdgeGatewayDriverSubDeviceListResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.device.DeviceInfo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class UnbindEdgeGatewayDriverSubDeviceListResponse extends AbstractBceResponse { + private List result; + private int totalCount; + private int pageSize; + private int pageNo; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UpdateEdgeGatewayNodeDriverConfigRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UpdateEdgeGatewayNodeDriverConfigRequest.java new file mode 100644 index 00000000..0fd43612 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UpdateEdgeGatewayNodeDriverConfigRequest.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateEdgeGatewayNodeDriverConfigRequest extends GenericAccountRequest { + private DriverConfig driverConfig; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UpdateEdgeGatewaySubDeviceConfigRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UpdateEdgeGatewaySubDeviceConfigRequest.java new file mode 100644 index 00000000..91bd9217 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/edge/gateway/UpdateEdgeGatewaySubDeviceConfigRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.edge.gateway; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateEdgeGatewaySubDeviceConfigRequest extends GenericAccountRequest { + private String name; + private String deviceModel; + private String accessTemplate; + private String nodeName; + private String driverName; + private String driverInstName; + private SubDeviceConfigUpdate config; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/node/CreateNodeRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/CreateNodeRequest.java new file mode 100644 index 00000000..24f2a7a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/CreateNodeRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.node; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateNodeRequest extends GenericAccountRequest { + private String name; + private String description = ""; + private Map labels; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/node/DeployBusinessTemplatesRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/DeployBusinessTemplatesRequest.java new file mode 100644 index 00000000..38ec3991 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/DeployBusinessTemplatesRequest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.node; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.bie.protocol.BusinessTemplatesApp; +import com.baidubce.services.iotdmp.model.bie.protocol.BusinessTemplatesAppRegistry; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeployBusinessTemplatesRequest extends GenericAccountRequest { + private String suffix; + private Map labels; + private String selector; + private String dmpDeviceApiUrl; + private List applications; + private List registries; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/node/GetInstallNodeInitResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/GetInstallNodeInitResponse.java new file mode 100644 index 00000000..023a8d8e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/GetInstallNodeInitResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.node; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetInstallNodeInitResponse extends AbstractBceResponse { + private String cmd; + private String apk; + @JsonProperty("apk_sys") + private String apkSys; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/node/GetInstallNodePropertyResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/GetInstallNodePropertyResponse.java new file mode 100644 index 00000000..91a94d87 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/GetInstallNodePropertyResponse.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.node; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetInstallNodePropertyResponse extends AbstractBceResponse { + private String name; + private String value; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/node/InstallMethod.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/InstallMethod.java new file mode 100644 index 00000000..759e0e1b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/InstallMethod.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.node; + +public enum InstallMethod { + curl, wget +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/node/InstallPlatform.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/InstallPlatform.java new file mode 100644 index 00000000..74477dd1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/InstallPlatform.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.node; + +public enum InstallPlatform { + windows, linux +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/node/ListNodeResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/ListNodeResponse.java new file mode 100644 index 00000000..f44e2d8a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/ListNodeResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.node; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListNodeResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/node/ModifyNodeRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/ModifyNodeRequest.java new file mode 100644 index 00000000..18c7889e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/ModifyNodeRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.node; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ModifyNodeRequest extends GenericAccountRequest { + private String name; + private String description; + private Map labels; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/node/NodeResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/NodeResponse.java new file mode 100644 index 00000000..53dcbe63 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/node/NodeResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.node; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class NodeResponse extends AbstractBceResponse { + private String nodeId; + private String nodeName; + private int status; + private String description; + private String createTime; + private String reportTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BieAppType.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BieAppType.java new file mode 100644 index 00000000..9ccdc727 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BieAppType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +public enum BieAppType { + container, function +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BieMode.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BieMode.java new file mode 100644 index 00000000..e1a26953 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BieMode.java @@ -0,0 +1,5 @@ +package com.baidubce.services.iotdmp.model.bie.protocol; + +public enum BieMode { + kube +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BiePortProtocol.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BiePortProtocol.java new file mode 100644 index 00000000..b0290ab8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BiePortProtocol.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +public enum BiePortProtocol { + TCP, UDP +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BiePortServiceType.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BiePortServiceType.java new file mode 100644 index 00000000..ffcfb611 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BiePortServiceType.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +public enum BiePortServiceType { + ClusterIP, NodePort + +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BieWorkload.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BieWorkload.java new file mode 100644 index 00000000..4c6833c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BieWorkload.java @@ -0,0 +1,5 @@ +package com.baidubce.services.iotdmp.model.bie.protocol; + +public enum BieWorkload { + deployment, daemonset, job +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesApp.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesApp.java new file mode 100644 index 00000000..d1036d2f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesApp.java @@ -0,0 +1,27 @@ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BusinessTemplatesApp extends AbstractBceResponse { + private String name; + private String description; + private String selector; + private String version; + private String createTime; + private Map labels; + private List services; + private List initServices; + private List registries; + private List volumes; + private BieWorkload workload; + private BieAppType type; + private BieMode mode; + private int replica; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRegistry.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRegistry.java new file mode 100644 index 00000000..a0fff8f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRegistry.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BusinessTemplatesAppRegistry extends AbstractBceResponse { + private String name; + private String description; + private String address; + private String username; + private String password; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRegistryList.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRegistryList.java new file mode 100644 index 00000000..ad94d14b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRegistryList.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BusinessTemplatesAppRegistryList extends AbstractBceResponse { + private long total; + private List items; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRegistryRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRegistryRequest.java new file mode 100644 index 00000000..612216ed --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRegistryRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BusinessTemplatesAppRegistryRequest extends GenericAccountRequest { + private String name; + private String description; + private String address; + private String username; + private String password; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRequest.java new file mode 100644 index 00000000..810fbbe3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppRequest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BusinessTemplatesAppRequest extends GenericAccountRequest { + private String name; + private String description = ""; + private String selector; + private String version; + private String createTime; + private Map labels; + private List services; + private List initServices; + private List registries; + private List volumes; + @Builder.Default + private BieWorkload workload = BieWorkload.deployment; + @Builder.Default + private BieAppType type = BieAppType.container; + @Builder.Default + private BieMode mode = BieMode.kube; + @Builder.Default + private int replica = 1; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppService.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppService.java new file mode 100644 index 00000000..2ab672ea --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppService.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BusinessTemplatesAppService extends GenericAccountRequest { + private String name; + private String image; + private List ports; + private List env; + private List volumeMounts; + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Port { + private Integer containerPort; + private BiePortServiceType serviceType; + private Integer hostPort; + private Integer nodePort; + private BiePortProtocol protocol; + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Env { + private String name; + private String value; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class VolumeMounts { + private String name; + private String mountPath; + private String subPath; + @Builder.Default + private boolean readOnly = true; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppVolume.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppVolume.java new file mode 100644 index 00000000..228e6851 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesAppVolume.java @@ -0,0 +1,19 @@ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BusinessTemplatesAppVolume { + private String name; + private BusinessTemplatesConfig config; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesConfig.java new file mode 100644 index 00000000..4620b1e6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/BusinessTemplatesConfig.java @@ -0,0 +1,23 @@ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BusinessTemplatesConfig { + private String name; + private String description; + private Map labels; + private Map data; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/CreateProtocolRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/CreateProtocolRequest.java new file mode 100644 index 00000000..e1f3fab3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/CreateProtocolRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateProtocolRequest extends GenericAccountRequest { + private String name; + private ProtocolType protocolType; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ListProtocolResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ListProtocolResponse.java new file mode 100644 index 00000000..5fe6715a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ListProtocolResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListProtocolResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolResponse.java new file mode 100644 index 00000000..3022a92b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProtocolResponse extends AbstractBceResponse { + private String protocolId; + private String protocolName; + private String supplierType; + private String protocolType; + private String description; + private String version; + private String guideDocUrl; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolType.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolType.java new file mode 100644 index 00000000..d8988b83 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +public enum ProtocolType { + IP, NON_IP +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolsMarkdownRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolsMarkdownRequest.java new file mode 100644 index 00000000..82e528c4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolsMarkdownRequest.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ProtocolsMarkdownRequest extends GenericAccountRequest { + private String content; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolsMarkdownResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolsMarkdownResponse.java new file mode 100644 index 00000000..1214852b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/bie/protocol/ProtocolsMarkdownResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.bie.protocol; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProtocolsMarkdownResponse extends AbstractBceResponse { + private String content; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/c2c/ComputationSourceResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/c2c/ComputationSourceResponse.java new file mode 100644 index 00000000..b004a55b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/c2c/ComputationSourceResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.c2c; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ComputationSourceResponse extends AbstractBceResponse { + private String sourceId; + private String username; + private String password; + private String vhost; + private String host; + private int port; + private String sinkQueue; + private String sourceQueue; + private String exchange; + private String topic; + private String routeKey; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/component/BindComponentRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/component/BindComponentRequest.java new file mode 100644 index 00000000..e589edd3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/component/BindComponentRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.component; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BindComponentRequest extends GenericAccountRequest { + + private List components; + + @Data + public static class BindInfo { + private String bindName; + private String component; + private String componentVersion; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/component/ListBindComponentResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/component/ListBindComponentResponse.java new file mode 100644 index 00000000..96859f95 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/component/ListBindComponentResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.component; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListBindComponentResponse extends AbstractBceResponse { + + private int totalCount; + private List> result; + private String bindName; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/AlgorithmType.java b/src/main/java/com/baidubce/services/iotdmp/model/device/AlgorithmType.java new file mode 100644 index 00000000..8707af55 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/AlgorithmType.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +public enum AlgorithmType { + + DEFAULT, SHC +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/AuthRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/AuthRequest.java new file mode 100644 index 00000000..7f42c253 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/AuthRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AuthRequest extends GenericAccountRequest { + + @NonNull + private String signature; + @NonNull + private Long expiryTime; + private AlgorithmType algorithmType; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/AuthType.java b/src/main/java/com/baidubce/services/iotdmp/model/device/AuthType.java new file mode 100644 index 00000000..02f08720 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/AuthType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +public enum AuthType { + SIGNATURE, CERTIFICATE +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/BatchCreateDeviceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/BatchCreateDeviceRequest.java new file mode 100644 index 00000000..d102fdaf --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/BatchCreateDeviceRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class BatchCreateDeviceRequest extends GenericAccountRequest { + + private List devices; + private AuthType authType; + private String description; + private Boolean isRegisterIotCore; + + public BatchCreateDeviceRequest(List devices) { + this.devices = devices; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/BatchDeleteDeviceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/BatchDeleteDeviceRequest.java new file mode 100644 index 00000000..769fa94b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/BatchDeleteDeviceRequest.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteDeviceRequest extends GenericAccountRequest { + private List devices; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/CreateDeviceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/CreateDeviceRequest.java new file mode 100644 index 00000000..04315014 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/CreateDeviceRequest.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.tag.CommonTagInfo; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateDeviceRequest extends GenericAccountRequest { + + @NonNull + private String deviceName; + private String alias; + private String deviceSecret; + private List tags; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceInfo.java new file mode 100644 index 00000000..aebf214c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceInfo.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceInfo extends AbstractBceResponse { + private String instanceId; + private String productKey; + private String deviceName; + private String deviceType; + private String alias; + private String productCategory; + private String authType; + private String deviceSecret; + private List accessType; + private boolean activeState; + private String activeTime; + private boolean onlineState; + private String lastOnlineTime; + private boolean enableState; + private boolean banState; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceKey.java b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceKey.java new file mode 100644 index 00000000..6d73b871 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceKey.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +public class DeviceKey { + private final String productKey; + private final String deviceName; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceResourcesConnectionInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceResourcesConnectionInfo.java new file mode 100644 index 00000000..523af4d5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceResourcesConnectionInfo.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceResourcesConnectionInfo extends AbstractBceResponse { + + private ResourceType resourceType; + private Content content; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Content { + private String broker; + private String clientId; + private int port; + private String password; + private String username; + private String clientCert; + private String privateKey; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceStateType.java b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceStateType.java new file mode 100644 index 00000000..6b7e0b66 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceStateType.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +public enum DeviceStateType { + + BAN_STATE, ENABLE_STATE, ACTIVE_STATE, ONLINE_STATE +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceStatesInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceStatesInfo.java new file mode 100644 index 00000000..854bc0c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceStatesInfo.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceStatesInfo { + private String instanceId; + private String productKey; + private String deviceName; + private boolean activeState; + private boolean onlineState; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceType.java b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceType.java new file mode 100644 index 00000000..2c1237b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/DeviceType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +public enum DeviceType { + DIRECT, GATEWAY, SUBDEVICE, COMPONENT +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/GetDeviceConnectionInfoRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/GetDeviceConnectionInfoRequest.java new file mode 100644 index 00000000..e042d24a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/GetDeviceConnectionInfoRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetDeviceConnectionInfoRequest extends GenericAccountRequest { + + @NonNull + private ResourceType resourceType; + private boolean permanentConnect; + private AuthType authType = AuthType.SIGNATURE; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceKeyRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceKeyRequest.java new file mode 100644 index 00000000..d3a94bc1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceKeyRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListDeviceKeyRequest extends GenericAccountRequest { + + private List devices; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceRequest.java new file mode 100644 index 00000000..a537caf2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListDeviceRequest extends GenericAccountRequest { + + private String productKey; + private String alias; + private String tagKey; + private String tagValue; + private String groupId; + @Deprecated + @Builder.Default + private int pageNo = 1; + @Deprecated + @Builder.Default + private int pageSize = 10; + @Builder.Default + private String cursor = ""; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceResponse.java new file mode 100644 index 00000000..0ca53cf3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListDeviceResponse extends AbstractBceResponse { + + private String productKey; + private String alias; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; + private String tagKey; + private String tagValue; + private String next; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceStatesResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceStatesResponse.java new file mode 100644 index 00000000..e8ee01fa --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/ListDeviceStatesResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListDeviceStatesResponse extends AbstractBceResponse { + List result; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/ResourceType.java b/src/main/java/com/baidubce/services/iotdmp/model/device/ResourceType.java new file mode 100644 index 00000000..ee158a05 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/ResourceType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +public enum ResourceType { + MQTT, EVS, RMQ_QUEUE, RULE_CHAIN, CLOUD_TO_CLOUD, GATEWAY, LINKAGE, OTA, TSDB, HTTP, BIE_GATEWAY +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/UpdateDeviceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/UpdateDeviceRequest.java new file mode 100644 index 00000000..17b75abb --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/UpdateDeviceRequest.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateDeviceRequest extends GenericAccountRequest { + private String alias; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/UpdateDeviceStateRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/UpdateDeviceStateRequest.java new file mode 100644 index 00000000..dc026513 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/UpdateDeviceStateRequest.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +@Data +@AllArgsConstructor +@Builder +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateDeviceStateRequest extends GenericAccountRequest { + + private DeviceStateType type; + private Boolean state; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/batch/BatchDownloadMqtt.java b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/BatchDownloadMqtt.java new file mode 100644 index 00000000..86641c8c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/BatchDownloadMqtt.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.batch; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BatchDownloadMqtt extends AbstractBceResponse { + private String authType; + private List deviceList; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/batch/BatchInfoResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/BatchInfoResponse.java new file mode 100644 index 00000000..e6389180 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/BatchInfoResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.batch; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.device.DeviceInfo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BatchInfoResponse extends AbstractBceResponse { + private String instanceId; + private String batchId; + private String productKey; + private String productName; + private boolean mqttEnabled; + private String mqttAuth; + private long deviceNums; + private String createTime; + private String updateTime; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/batch/BatchManageInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/BatchManageInfo.java new file mode 100644 index 00000000..845ce637 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/BatchManageInfo.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.batch; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class BatchManageInfo extends AbstractBceResponse { + private String instanceId; + private String batchId; + private String productKey; + private String productName; + private boolean mqttEnabled; + private String mqttAuth; + private String deviceType; + private long deviceNums; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/batch/DeviceResourceInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/DeviceResourceInfo.java new file mode 100644 index 00000000..d520edea --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/DeviceResourceInfo.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.batch; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceResourceInfo extends AbstractBceResponse { + private String productKey; + private String deviceName; + private String clientId; + private String clientCert; + private String username; + private String password; + private String broker; + private int port; + private String privateKey; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/batch/DeviceTuples.java b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/DeviceTuples.java new file mode 100644 index 00000000..534d8137 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/DeviceTuples.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.batch; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceTuples { + private String productKey; + private String deviceName; + private String deviceSecret; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/batch/GetBatchPageResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/GetBatchPageResponse.java new file mode 100644 index 00000000..b9c14b89 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/GetBatchPageResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.batch; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetBatchPageResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/batch/GetBatchTuplesResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/GetBatchTuplesResponse.java new file mode 100644 index 00000000..838a996c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/batch/GetBatchTuplesResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.batch; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.anno.BceListResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +@BceListResponse +public class GetBatchTuplesResponse extends AbstractBceResponse { + List result; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/AddEvsDeviceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/AddEvsDeviceRequest.java new file mode 100644 index 00000000..4e8c1634 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/AddEvsDeviceRequest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AddEvsDeviceRequest extends GenericAccountRequest { + + private Long spaceId; + private String deviceName; + @NonNull + private EvsSpaceType type; + private String deviceStreamId; + private String description; + private EvsDeviceGbConfig gbConfig; + private EvsDeviceRecordingConfig recording; + private EvsDeviceThumbnailConfig thumbnail; + + public void setBucket(String bucket) { + if (recording != null && !recording.getSameAsSpace() && recording.getEnabled()) { + recording.setBucket(bucket); + } + + if (thumbnail != null && !thumbnail.getSameAsSpace() && thumbnail.getEnabled()) { + thumbnail.setBucket(bucket); + } + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/Channel.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/Channel.java new file mode 100644 index 00000000..c77df6bc --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/Channel.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Channel { + private String channelName; + private long channelId; + private String channelStatus; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsData.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsData.java new file mode 100644 index 00000000..6aba32f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsData.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class EvsData { + private String title; + private String thumbnailUrl; + private String playUrl; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceGbConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceGbConfig.java new file mode 100644 index 00000000..04364c78 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceGbConfig.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class EvsDeviceGbConfig { + + private String platform; + private String gbId; + private String username; + private String password; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceInfo.java new file mode 100644 index 00000000..1ab5c8e5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceInfo.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.product.evs.EvsContent; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class EvsDeviceInfo extends AbstractBceResponse { + + private boolean open; + private EvsContent content; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceRecordingConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceRecordingConfig.java new file mode 100644 index 00000000..73bfb557 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceRecordingConfig.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class EvsDeviceRecordingConfig { + + private Boolean sameAsSpace = Boolean.TRUE; + private Boolean enabled = Boolean.FALSE; + private String bucket = null; + private Integer duration = null; + private EvsRecordingFormat format = null; + private Boolean authEnabled = Boolean.FALSE; + private Integer authExpire = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceThumbnailConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceThumbnailConfig.java new file mode 100644 index 00000000..1a6d5d74 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDeviceThumbnailConfig.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class EvsDeviceThumbnailConfig { + + private Boolean sameAsSpace = Boolean.TRUE; + private Boolean enabled = Boolean.FALSE; + private String bucket = null; + private Integer interval = null; + private Boolean authEnabled = Boolean.FALSE; + private Integer authExpire = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDurationRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDurationRequest.java new file mode 100644 index 00000000..19df06d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsDurationRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class EvsDurationRequest extends GenericAccountRequest { + @NonNull + private Integer begin; + @NonNull + private Integer end; + @Builder.Default + protected int pageNo = 1; + @Builder.Default + protected int pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsProtocolRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsProtocolRequest.java new file mode 100644 index 00000000..c685a491 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsProtocolRequest.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class EvsProtocolRequest extends GenericAccountRequest { + + private EvsUrlProtocol protocol; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsPtzRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsPtzRequest.java new file mode 100644 index 00000000..51c5e3ff --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsPtzRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class EvsPtzRequest extends GenericAccountRequest { + @NonNull + private String ptzCommand; + @Builder.Default + private Integer speed = 1; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsRecordingConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsRecordingConfig.java new file mode 100644 index 00000000..6db97abc --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsRecordingConfig.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +@AllArgsConstructor +public class EvsRecordingConfig { + + private Boolean enabled = Boolean.FALSE; + private String bucket = null; + private Integer duration = null; + private EvsRecordingFormat format = null; + private Boolean authEnabled = Boolean.FALSE; + private Integer authExpire = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsRecordingFormat.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsRecordingFormat.java new file mode 100644 index 00000000..053f803f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsRecordingFormat.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +public enum EvsRecordingFormat { + + MP4, FLV, M3U8 +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsSpaceType.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsSpaceType.java new file mode 100644 index 00000000..1d3ee621 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsSpaceType.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +public enum EvsSpaceType { + + RTMP, GB28181 +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsThumbnailConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsThumbnailConfig.java new file mode 100644 index 00000000..ff308f06 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsThumbnailConfig.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +@AllArgsConstructor +public class EvsThumbnailConfig { + + private Boolean enabled = Boolean.FALSE; + private String bucket = null; + private Integer interval = null; + private Boolean authEnabled = Boolean.FALSE; + private Integer authExpire = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsUrlProtocol.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsUrlProtocol.java new file mode 100644 index 00000000..d0a4dce2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/EvsUrlProtocol.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +public enum EvsUrlProtocol { + rtmp, flv, hls +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsChannelResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsChannelResponse.java new file mode 100644 index 00000000..3d8a68d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsChannelResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetEvsChannelResponse extends AbstractBceResponse { + private String description; + private String createTime; + private String type; + private String deviceStreamId; + private String status; + private String deviceName; + private long deviceId; + private int channelCount; + private List channels; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsChannelUrlResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsChannelUrlResponse.java new file mode 100644 index 00000000..73055168 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsChannelUrlResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetEvsChannelUrlResponse extends AbstractBceResponse { + private String url; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsRecordingResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsRecordingResponse.java new file mode 100644 index 00000000..030e4450 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsRecordingResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetEvsRecordingResponse extends AbstractBceResponse { + private int totalCount; + private List data; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsThumbnailResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsThumbnailResponse.java new file mode 100644 index 00000000..06fa224c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/GetEvsThumbnailResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetEvsThumbnailResponse extends AbstractBceResponse { + private int totalCount; + private List data; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/evs/UpdateEvsDeviceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/UpdateEvsDeviceRequest.java new file mode 100644 index 00000000..9aab10be --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/evs/UpdateEvsDeviceRequest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.evs; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class UpdateEvsDeviceRequest extends GenericAccountRequest { + + private EvsDeviceRecordingConfig recording; + private EvsDeviceThumbnailConfig thumbnail; + + public void setBucket(String bucket) { + if (recording != null && !recording.getSameAsSpace() && recording.getEnabled()) { + recording.setBucket(bucket); + } + + if (thumbnail != null && !thumbnail.getSameAsSpace() && thumbnail.getEnabled()) { + thumbnail.setBucket(bucket); + } + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/tag/CommonTagInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/device/tag/CommonTagInfo.java new file mode 100644 index 00000000..331e352c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/tag/CommonTagInfo.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.tag; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@NoArgsConstructor +@RequiredArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class CommonTagInfo { + @NonNull + private String key; + @NonNull + private String value; + private Boolean inherited; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/tag/ListTagResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/tag/ListTagResponse.java new file mode 100644 index 00000000..53472363 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/tag/ListTagResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.tag; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListTagResponse extends AbstractBceResponse { + + private List tags; + +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/topic/ListTopicResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/topic/ListTopicResponse.java new file mode 100644 index 00000000..c393fd60 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/topic/ListTopicResponse.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.topic; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListTopicResponse extends AbstractBceResponse { + + private List result; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/topic/MqttTopicInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/device/topic/MqttTopicInfo.java new file mode 100644 index 00000000..6ee09b0e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/topic/MqttTopicInfo.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.topic; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class MqttTopicInfo { + private String type; + private String permission; + private String description; + private String topic; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/topo/DeviceSubsetsFileResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/device/topo/DeviceSubsetsFileResponse.java new file mode 100644 index 00000000..9527858f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/topo/DeviceSubsetsFileResponse.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.topo; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceSubsetsFileResponse extends AbstractBceResponse { + private DeviceSubsetsKey root; + private List leaf; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/device/topo/DeviceSubsetsKey.java b/src/main/java/com/baidubce/services/iotdmp/model/device/topo/DeviceSubsetsKey.java new file mode 100644 index 00000000..cfb1937a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/device/topo/DeviceSubsetsKey.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.device.topo; + +import com.baidubce.services.iotdmp.model.device.DeviceType; +import lombok.Data; + +@Data +public class DeviceSubsetsKey { + private String deviceName; + private String productKey; + private String alias; + private DeviceType deviceType; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/extension/ability/ServiceType.java b/src/main/java/com/baidubce/services/iotdmp/model/extension/ability/ServiceType.java new file mode 100644 index 00000000..cc1e08f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/extension/ability/ServiceType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.extension.ability; + +public enum ServiceType { + MQTT, EVS, RMQ_QUEUE, RULE_CHAIN, CLOUD_TO_CLOUD, GATEWAY, LINKAGE, OTA, TSDB, HTTP, BIE_GATEWAY +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/AddConfigRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/AddConfigRequest.java new file mode 100644 index 00000000..4fee227e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/AddConfigRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AddConfigRequest extends GenericAccountRequest { + private String configName; + private String productKey; + private String description; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/AddTaskRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/AddTaskRequest.java new file mode 100644 index 00000000..790e5760 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/AddTaskRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AddTaskRequest extends GenericAccountRequest { + private String configVersion; + private String fileName; + private String deviceName; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigManagementListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigManagementListResponse.java new file mode 100644 index 00000000..5e36abcd --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigManagementListResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ConfigManagementListResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigManagementResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigManagementResponse.java new file mode 100644 index 00000000..eed08456 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigManagementResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ConfigManagementResponse extends AbstractBceResponse { + private String configName; + private String configId; + private String productKey; + private String productName; + private String description; + private String createTime; + private String updateTime; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTask.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTask.java new file mode 100644 index 00000000..73287ad0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTask.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ConfigTask { + private String taskId; + private String taskType; + private String taskStatus; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTaskDetailListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTaskDetailListResponse.java new file mode 100644 index 00000000..2be96b8a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTaskDetailListResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ConfigTaskDetailListResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTaskDetailResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTaskDetailResponse.java new file mode 100644 index 00000000..dd1a3a50 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTaskDetailResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ConfigTaskDetailResponse extends AbstractBceResponse { + private String taskId; + private String deviceName; + private String updateStatus; + private String detail; + private String configVersion; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTaskListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTaskListResponse.java new file mode 100644 index 00000000..78acd75b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigTaskListResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ConfigTaskListResponse extends AbstractBceResponse { + private String configName; + private String productKey; + private String productName; + private String description; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigVersionListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigVersionListResponse.java new file mode 100644 index 00000000..e4ca3e53 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ConfigVersionListResponse.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ConfigVersionListResponse extends AbstractBceResponse { + private String configName; + private String productKey; + private String productName; + private String description; + private List result; + + + @Data + @NoArgsConstructor + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Result { + private String configVersion; + private String fileType; + private Long fileSize; + private String etag; + private String fileName; + private String createTime; + private String updateTime; + + public Result(ProductConfigVersion v) { + configVersion = v.getConfigVersion(); + fileType = v.getConfigFileType(); + fileSize = v.getConfigFileSize(); + etag = v.getConfigMd5(); + fileName = v.getFileUniqueId(); + createTime = v.getCreateTime(); + updateTime = v.getUpdateTime(); + } + } + +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/GetConfigVersionResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/GetConfigVersionResponse.java new file mode 100644 index 00000000..4c53a73c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/GetConfigVersionResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetConfigVersionResponse extends AbstractBceResponse { + private String downloadUrl; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigDetail.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigDetail.java new file mode 100644 index 00000000..32df773b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigDetail.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ProductConfigDetail { + private Long id; + private String instanceId; + private String productKey; + private String configId; + private String taskId; + private String deviceName; + private String updateStatus; + private String detail; + private String configVersion; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigInfo.java new file mode 100644 index 00000000..706abe18 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigInfo.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ProductConfigInfo { + private String instanceId; + private String productKey; + private String productName; + private String configId; + private String configName; + private String description; + private String createTime; + private String updateTime; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigTask.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigTask.java new file mode 100644 index 00000000..1c27dfb4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigTask.java @@ -0,0 +1,24 @@ +package com.baidubce.services.iotdmp.model.fm; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.hadoop.mapred.TaskStatus; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ProductConfigTask { + private String instanceId; + private String productKey; + private String configId; + private String taskId; + private TaskStatus taskStatus; + private int targetSize; + private int completedSize; + private int failedSize; + private String createTime; + private String updateTime; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigVersion.java b/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigVersion.java new file mode 100644 index 00000000..9258c23c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/fm/ProductConfigVersion.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.fm; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ProductConfigVersion { + private String instanceId; + private String productKey; + private String configId; + private String configVersion; + private String configMd5; + private Long configFileSize; + private String configFileType; + private String fileUniqueId; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/group/CreateGroupRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/group/CreateGroupRequest.java new file mode 100644 index 00000000..1a6bc1c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/group/CreateGroupRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.group; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +@Builder +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateGroupRequest extends GenericAccountRequest { + @NonNull + private String groupName; + private String groupDesc; + private String superGroupId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/group/GroupInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/group/GroupInfo.java new file mode 100644 index 00000000..b3b5d39b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/group/GroupInfo.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.group; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GroupInfo extends AbstractBceResponse { + private String instanceId; + private String groupId; + private String groupName; + private String superGroupId; + private String rootGroupId; + private int depth; + private String groupDesc; + private Boolean hasChildren; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/group/ListDeviceByGroupResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/group/ListDeviceByGroupResponse.java new file mode 100644 index 00000000..a7124c4c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/group/ListDeviceByGroupResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.group; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListDeviceByGroupResponse extends AbstractBceResponse { + private List devices; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/group/ListGroupRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/group/ListGroupRequest.java new file mode 100644 index 00000000..c2877eab --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/group/ListGroupRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.group; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListGroupRequest extends GenericAccountRequest { + private String keyword; + private String superGroupId; + private String rootGroupId; + @Builder.Default + private Integer pageNo = 1; + @Builder.Default + private Integer pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/group/ListGroupResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/group/ListGroupResponse.java new file mode 100644 index 00000000..bd5ff374 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/group/ListGroupResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.group; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListGroupResponse extends AbstractBceResponse { + private String groupName; + private String superGroupId; + private String rootGroupId; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/group/UpdateGroupInfoRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/group/UpdateGroupInfoRequest.java new file mode 100644 index 00000000..555b94c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/group/UpdateGroupInfoRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.group; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateGroupInfoRequest extends GenericAccountRequest { + private String groupName; + private String groupDesc; + private String targetGroupId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/handler/BceDmpHandler.java b/src/main/java/com/baidubce/services/iotdmp/model/handler/BceDmpHandler.java new file mode 100644 index 00000000..482bafe1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/handler/BceDmpHandler.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.handler; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.anno.BceListResponse; +import com.baidubce.services.iotdmp.model.anno.BceJsonStringResponse; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.util.EntityUtils; + +import java.beans.PropertyDescriptor; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +public class BceDmpHandler extends BceJsonResponseHandler { + + public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + InputStream content = httpResponse.getContent(); + + if (content != null) { + if (response.getMetadata().getContentLength() > 0 + || "chunked".equalsIgnoreCase(response.getMetadata().getTransferEncoding())) { + try { + if (response.getClass().isAnnotationPresent(BceListResponse.class)) { + // 获取类对象 + Class aClass = response.getClass(); + // 获取放置list的字段 + Field[] fields = aClass.getDeclaredFields(); + String field = fields[0].getName(); + + // 获取泛型类型 + ParameterizedType type = (ParameterizedType) fields[0].getGenericType(); + Type[] types = type.getActualTypeArguments(); + Class type1 = (Class) types[0]; + JavaType javaType = getCollectionType(ArrayList.class, Class.forName(type1.getName())); + // 获取响应内容 + String value = EntityUtils.toString(httpResponse.getHttpResponse().getEntity()); + List list = OBJECT_MAPPER.readValue(value, javaType); + // 执行set方法 + PropertyDescriptor descriptor = new PropertyDescriptor(field, aClass); + Method setMethod = descriptor.getWriteMethod(); + setMethod.invoke(response, list); + } + + if (response.getClass().isAnnotationPresent(BceJsonStringResponse.class)) { + // 获取类对象 + Class aClass = response.getClass(); + // 获取响应内容 + String value = EntityUtils.toString(httpResponse.getHttpResponse().getEntity()); + // 解析JSON数据copy到response中 + copyFields(JsonUtils.fromJsonString(value, aClass), response); + } + JsonUtils.load(content, response); + } catch (Exception e) {} + } + content.close(); + } + + return true; + } + + public static JavaType getCollectionType(Class collectionClass, Class... elementClasses) { + return OBJECT_MAPPER.getTypeFactory().constructParametricType(collectionClass, elementClasses); + } + + private void copyFields(Object source, Object target) throws IllegalAccessException { + Field[] fields = source.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + Object value = field.get(source); + Field targetField = null; + try { + targetField = target.getClass().getDeclaredField(field.getName()); + } catch (NoSuchFieldException e) { + continue; + } + targetField.setAccessible(true); + targetField.set(target, value); + } + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/CreateInstanceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/CreateInstanceRequest.java new file mode 100644 index 00000000..912e922d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/CreateInstanceRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateInstanceRequest extends GenericAccountRequest { + private String name; + private String description; + + public CreateInstanceRequest(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/ExtensionResourceResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/ExtensionResourceResponse.java new file mode 100644 index 00000000..da292696 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/ExtensionResourceResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ExtensionResourceResponse extends AbstractBceResponse { + + private List extensions; + +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/InstanceInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/InstanceInfo.java new file mode 100644 index 00000000..952d1e20 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/InstanceInfo.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class InstanceInfo extends AbstractBceResponse { + + private String instanceId; + private String name; + private String description; + private String state; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/InstanceResourceManageInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/InstanceResourceManageInfo.java new file mode 100644 index 00000000..3fdb8002 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/InstanceResourceManageInfo.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +import lombok.Data; +import java.util.Map; + +@Data +public class InstanceResourceManageInfo { + + private String instanceId; + private String name; + private ResourceSupplier supplier; + private String resourceType; + private String description; + private String state; + private Map properties; + private String createTime; + private String updateTime; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/ListInstanceResourceResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/ListInstanceResourceResponse.java new file mode 100644 index 00000000..8504524a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/ListInstanceResourceResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListInstanceResourceResponse extends AbstractBceResponse { + + private int total; + private List resources; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/ListInstancesResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/ListInstancesResponse.java new file mode 100644 index 00000000..cd14b141 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/ListInstancesResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListInstancesResponse extends AbstractBceResponse { + + private int totalCount; + private List> result; + protected int pageNo = 1; + protected int pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/ResourceSupplier.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/ResourceSupplier.java new file mode 100644 index 00000000..1e40eb99 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/ResourceSupplier.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +public enum ResourceSupplier { + + SYSTEM, USER +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/ResourceType.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/ResourceType.java new file mode 100644 index 00000000..0da6d183 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/ResourceType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +public enum ResourceType { + MQTT, EVS, RULE_CHAIN, RABBITMQ, LINKAGE, TSDB, BIE +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/UpdateInstanceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/UpdateInstanceRequest.java new file mode 100644 index 00000000..0b6a4fde --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/UpdateInstanceRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class UpdateInstanceRequest extends GenericAccountRequest { + private String name; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/instance/UpdateInstanceResourcePropertiesRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/instance/UpdateInstanceResourcePropertiesRequest.java new file mode 100644 index 00000000..832a09cf --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/instance/UpdateInstanceResourcePropertiesRequest.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.instance; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateInstanceResourcePropertiesRequest extends GenericAccountRequest { + + @NotNull + private ResourceType resourceType; + @NotNull + private Map properties; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/ActionVo.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/ActionVo.java new file mode 100644 index 00000000..85f70ba9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/ActionVo.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ActionVo { + private Mode mode; + private String productKey; + private String deviceName; + private String commandName; + private FeatureType type; + private String ruleChainId; + private String alarmId; + private Map params; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/BatchDeleteLinkageRuleRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/BatchDeleteLinkageRuleRequest.java new file mode 100644 index 00000000..e8771a78 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/BatchDeleteLinkageRuleRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Set; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteLinkageRuleRequest extends GenericAccountRequest { + private Set ruleIds; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/CompareMode.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/CompareMode.java new file mode 100644 index 00000000..c3363fcc --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/CompareMode.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +public enum CompareMode { + EQ, NE, LT, LTE, GT, GTE, IN, BETWEEN; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/ConditionVo.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/ConditionVo.java new file mode 100644 index 00000000..687b972e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/ConditionVo.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ConditionVo { + private Mode mode; + private String productKey; + private String deviceName; + private String propName; + private Integer windowTime; + private Integer count; + private FeatureType type; + private WindowCondition condition; + private CompareMode compareMode; + private String opNum; + private List opList; + private String start; + private String end; + private boolean state; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/CreateLinkageRuleRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/CreateLinkageRuleRequest.java new file mode 100644 index 00000000..33e8649c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/CreateLinkageRuleRequest.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateLinkageRuleRequest extends GenericAccountRequest { + private String name; + private String description; + private List trigger = new ArrayList(); + private List condition = new ArrayList(); + private List action = new ArrayList(); +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/CreateLinkageRuleResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/CreateLinkageRuleResponse.java new file mode 100644 index 00000000..72e98883 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/CreateLinkageRuleResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateLinkageRuleResponse extends AbstractBceResponse { + private String ruleId; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/FeatureType.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/FeatureType.java new file mode 100644 index 00000000..d73505cd --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/FeatureType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +public enum FeatureType { + PROPERTY, EVENT, COMMAND, ONLINE_STATE; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/LinkageRuleInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/LinkageRuleInfo.java new file mode 100644 index 00000000..f01aa53f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/LinkageRuleInfo.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class LinkageRuleInfo extends AbstractBceResponse { + private String ruleId; + private String instanceId; + private String name; + private String description; + private LinkageRuleVo info; + private boolean state; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/LinkageRuleVo.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/LinkageRuleVo.java new file mode 100644 index 00000000..d060ee1b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/LinkageRuleVo.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class LinkageRuleVo { + private List trigger; + private List condition; + private List action; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/ListLinkageRuleResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/ListLinkageRuleResponse.java new file mode 100644 index 00000000..9ba87c20 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/ListLinkageRuleResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListLinkageRuleResponse extends AbstractBceResponse { + private String name; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/Mode.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/Mode.java new file mode 100644 index 00000000..5104b0f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/Mode.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +public enum Mode { + COMPARE, CRONTAB, TIME, SLIDING_WINDOW, DURATION_WINDOW, RE, DEVICE, ALARM +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/TriggerVo.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/TriggerVo.java new file mode 100644 index 00000000..a5bf0740 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/TriggerVo.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TriggerVo { + private Mode mode; + private String productKey; + private String deviceName; + private String propName; + private String output; + private String eventName; + private Integer windowTime; + private FeatureType type; + private WindowCondition condition; + private CompareMode compareMode; + private String opNum; + private List opList; + private String cron; + private String start; + private String end; + private boolean state; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/UpdateLinkageRuleRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/UpdateLinkageRuleRequest.java new file mode 100644 index 00000000..74a736b4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/UpdateLinkageRuleRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateLinkageRuleRequest extends GenericAccountRequest { + private String name; + private String description; + private LinkageRuleVo info; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/linkage/WindowCondition.java b/src/main/java/com/baidubce/services/iotdmp/model/linkage/WindowCondition.java new file mode 100644 index 00000000..e0337eed --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/linkage/WindowCondition.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.linkage; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class WindowCondition { + private String instanceId; + private String productKey; + private String deviceName; + private String propName; + private String keyName; + private CompareMode compareMode; + private Object opNum; + private List opList; + private String topic; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/CommonOtaListRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/CommonOtaListRequest.java new file mode 100644 index 00000000..113db0f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/CommonOtaListRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CommonOtaListRequest extends GenericAccountRequest { + @Builder.Default + private int page = 1; + @Builder.Default + private int perPage = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/device/DeviceStatus.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/DeviceStatus.java new file mode 100644 index 00000000..3a16ea7e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/DeviceStatus.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.device; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceStatus { + @JsonProperty("dev_id") + private String devId; + private String status; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/device/ListAllTestDeviceForTaskResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/ListAllTestDeviceForTaskResponse.java new file mode 100644 index 00000000..88a78373 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/ListAllTestDeviceForTaskResponse.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.device; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListAllTestDeviceForTaskResponse extends AbstractBceResponse { + @JsonProperty("device_status") + private List deviceStatus; + @JsonProperty("success_count") + private Integer successCount; + @JsonProperty("failed_count") + private Integer failedCount; + private List devices; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/device/SearchDeviceForTaskResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/SearchDeviceForTaskResponse.java new file mode 100644 index 00000000..6f3fca25 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/SearchDeviceForTaskResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.device; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class SearchDeviceForTaskResponse extends AbstractBceResponse { + private String deviceId; + private String dev; + private String status; + @JsonProperty("server_time") + private String serverTime; + private Integer total; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/device/SearchTaskDeviceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/SearchTaskDeviceRequest.java new file mode 100644 index 00000000..618bd23f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/SearchTaskDeviceRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.device; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SearchTaskDeviceRequest extends GenericAccountRequest { + @NotNull + private String type; + @NotNull + private String param; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/device/SearchType.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/SearchType.java new file mode 100644 index 00000000..a928ce86 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/device/SearchType.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.device; + + +public enum SearchType { + devquery_status, devquery_id +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/CheckOtaPackageRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/CheckOtaPackageRequest.java new file mode 100644 index 00000000..cafb466b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/CheckOtaPackageRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packages; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CheckOtaPackageRequest extends GenericAccountRequest { + @NotNull + private String showName; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/CheckOtaPackageResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/CheckOtaPackageResponse.java new file mode 100644 index 00000000..6a474be4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/CheckOtaPackageResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packages; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CheckOtaPackageResponse extends AbstractBceResponse { + private String showName; + private Boolean isDiffPack; + private Boolean isExist; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/ListOtaPackageRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/ListOtaPackageRequest.java new file mode 100644 index 00000000..ff95e9dd --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/ListOtaPackageRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packages; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ListOtaPackageRequest extends GenericAccountRequest { + @Builder.Default + private int page = 1; + @Builder.Default + private int perPage = 10; + private String searchStr = null; + private String label = null; + private OrderBy orderBy = null; + private OrderDirection orderDirection = null; + + public enum OrderBy { + showName, desVersion, id + } + + public enum OrderDirection { + desc, asc + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/ListOtaPackageResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/ListOtaPackageResponse.java new file mode 100644 index 00000000..9540a6f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/ListOtaPackageResponse.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packages; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListOtaPackageResponse extends AbstractBceResponse { + private int total; + private int page; + private int perPage; + private List labels; + private List packages; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class OtaPackageData { + private int id; + private String packageType; + private int fileType; + private String fileName; + private String showName; + private String packageName; + private Boolean isDiffPack; + private Boolean isEncrypted; + private String url; + private String md5; + private String sha1; + private String srcSha1; + private String insertTime; + private String fileSource; + private String uploadUser; + private long fileSize; + private String srcVersion; + private String dstVersion; + private List label; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/OSStsResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/OSStsResponse.java new file mode 100644 index 00000000..bb9ecb41 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/OSStsResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packages; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OSStsResponse extends AbstractBceResponse { + private String ak; + private String sk; + private String token; + private long expiration; + private String fileKey; + private String bucket; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/OtaPackage.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/OtaPackage.java new file mode 100644 index 00000000..0fd77988 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/OtaPackage.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packages; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class OtaPackage { + private int id; + private String packageType; + private int filetype; + private String filename; + @JsonProperty("show_name") + private String showName; + @JsonProperty("package_name") + private String packageName; + @JsonProperty("isDiffPack") + private Boolean isDiffPack; + @JsonProperty("is_encrypted") + private Boolean isEncrypted; + private String url; + private String md5; + private String sha1; + private String srcSha1; + private String insertTime; + private String fileSource; + private String uploadUser; + private long filesize; + @JsonProperty("src_version") + private String srcVersion; + private List label; + private String version; + private int updatetype; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/Type.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/Type.java new file mode 100644 index 00000000..fd46a1c8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/Type.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packages; + + +public enum Type { + ota, group, packing +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/UploadOtaPackageRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/UploadOtaPackageRequest.java new file mode 100644 index 00000000..0e31abc7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/UploadOtaPackageRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packages; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class UploadOtaPackageRequest extends GenericAccountRequest { + @NotNull + private String fileName; + @NotNull + private String suffix; + @NotNull + private String showName; + @NotNull + private Boolean isEncrypted; + @NotNull + private String url; + @NotNull + private String md5; + @NotNull + private String sha1; + @NotNull + private System system; + @NotNull + private String fileSize; + @NotNull + private String dstVersion; + private String label = null; + private String packageType = "system"; + private int fileType = 0; + private String fileSource = "user"; + private boolean isDiffPack = false; + private String srcVersion = null; + private String srcSha1 = null; + private String packageName = null; + + public enum System { + linux, android, rost, other + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/UploadOtaPackageResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/UploadOtaPackageResponse.java new file mode 100644 index 00000000..23ce4474 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packages/UploadOtaPackageResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packages; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class UploadOtaPackageResponse extends AbstractBceResponse { + private int packageId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/CancelOtaPackingResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/CancelOtaPackingResponse.java new file mode 100644 index 00000000..a7852046 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/CancelOtaPackingResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packing; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CancelOtaPackingResponse extends AbstractBceResponse { + private int pid; + private int issueId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/CreateOtaPackingRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/CreateOtaPackingRequest.java new file mode 100644 index 00000000..1ab9f193 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/CreateOtaPackingRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packing; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateOtaPackingRequest extends GenericAccountRequest { + @NotNull + private String showName; + @NotNull + private int platform; + @NotNull + private int type; + @NotNull + private String targetPath; + @NotNull + private String targetVersion; + private String srcSha1; + private String srcPath; + private String srcVersion; + private String packageName; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/CreateOtaPackingResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/CreateOtaPackingResponse.java new file mode 100644 index 00000000..a47e5b74 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/CreateOtaPackingResponse.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packing; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateOtaPackingResponse extends AbstractBceResponse { + private int pid; + @JsonProperty("issue_id") + private int issueId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/DeleteOtaPackingResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/DeleteOtaPackingResponse.java new file mode 100644 index 00000000..f367c42e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/DeleteOtaPackingResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packing; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeleteOtaPackingResponse extends AbstractBceResponse { + private int pid; + private int issueId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/GetOtaPackingStatusResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/GetOtaPackingStatusResponse.java new file mode 100644 index 00000000..51636b5c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/GetOtaPackingStatusResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packing; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetOtaPackingStatusResponse extends AbstractBceResponse { + private int pid; + private int issueId; + private int status; + private boolean hasNextStep; + private String stepName; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/ListOtaCompletedPackingResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/ListOtaCompletedPackingResponse.java new file mode 100644 index 00000000..1226162b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/ListOtaCompletedPackingResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packing; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListOtaCompletedPackingResponse extends AbstractBceResponse { + private int pid; + private int total; + private int page; + private int perPage; + private List fileList; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/ListOtaUncompletedPackingResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/ListOtaUncompletedPackingResponse.java new file mode 100644 index 00000000..77a87164 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/ListOtaUncompletedPackingResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packing; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListOtaUncompletedPackingResponse extends AbstractBceResponse { + private int pid; + private int total; + private int page; + private int perPage; + private List fileList; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/Packing.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/Packing.java new file mode 100644 index 00000000..4f4df3c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/packing/Packing.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.packing; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Packing extends AbstractBceResponse { + private int issueId; + private int platform; + private int type; + private String stepName; + private boolean hasNextStep; + private int status; + private String packageUrl; + private String srcSha1; + private int fileSize; + private String fileMd5; + private String fileSha1; + private String submitTime; + private String packageName; + private String showName; + private String dstVersion; + private String srcVersion; + private int fileType; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/CreateOtaProductRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/CreateOtaProductRequest.java new file mode 100644 index 00000000..68e3f81e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/CreateOtaProductRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateOtaProductRequest extends GenericAccountRequest { + @NotNull + private OtaProductOS os; + private String chipType = "Unknown"; + private String remark; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/CreateOtaProductResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/CreateOtaProductResponse.java new file mode 100644 index 00000000..a975ee23 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/CreateOtaProductResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateOtaProductResponse extends AbstractBceResponse { + private String id; + private String pid; + private String productSecret; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductOperationRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductOperationRequest.java new file mode 100644 index 00000000..e62c5808 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductOperationRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ListOtaProductOperationRequest extends GenericAccountRequest { + @Builder.Default + private Integer page = 1; + @Builder.Default + private Integer perPage = 10; + private String search = null; + private Integer type = null; + private String date = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductOperationResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductOperationResponse.java new file mode 100644 index 00000000..de8cab63 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductOperationResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListOtaProductOperationResponse extends AbstractBceResponse { + private int total; + private int page; + private int perPage; + private List logs; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductRequest.java new file mode 100644 index 00000000..2973d8b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ListOtaProductRequest extends GenericAccountRequest { + + @Builder.Default + private int page = 1; + @Builder.Default + private int perPage = 10; + private String search = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductResponse.java new file mode 100644 index 00000000..0a4ea8f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/ListOtaProductResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListOtaProductResponse extends AbstractBceResponse { + private int total; + private int page; + private int perPage; + private List products; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProduct.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProduct.java new file mode 100644 index 00000000..d4a74cff --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProduct.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaProduct { + private Integer pid; + private String name; + private String status; + private String os; + private Integer groupId; + private Boolean isAdmin; + private Integer activeDevAmount; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductConfig.java new file mode 100644 index 00000000..fb017f56 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductConfig.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaProductConfig extends AbstractBceResponse { + private Integer pid; + private String name; + private String status; + private String company; + private Integer groupId; + private String chipType; + private String deviceType; + private String remark; + private String os; + private Integer combinePid; + private String priceType; + private String discount; + private Integer exclusive; + private Boolean enableService; + private Integer servicePrice; + private List ability; + private Integer activeDevAmount; + private String createdAt; + private String updatedAt; + private Boolean isAiotProduct; + private String productSecret; + private Boolean enableResToken; + private Boolean enableAdvance; + private Boolean enableAuthDev; + private Boolean enableGrayRelease; + private Integer enableChannel; + private Boolean enableDiffLimit; + @JsonProperty("threshold_pcdn") + private Integer thresholdPcdn; + private TaskConfig taskConfig; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductDetail.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductDetail.java new file mode 100644 index 00000000..765858e5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductDetail.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaProductDetail extends AbstractBceResponse { + private Integer pid; + private String name; + private String status; + private String company; + private Integer groupId; + private String chipType; + private String remark; + private String os; + private Integer combinePid; + private String priceType; + private String discount; + private Boolean enableService; + private Integer servicePrice; + private List ability; + private Integer activeDevAmount; + private String createdAt; + private String updatedAt; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductOS.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductOS.java new file mode 100644 index 00000000..d68c9fe8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductOS.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +public enum OtaProductOS { + Linux, Android, RTOS, Other +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductOperationLog.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductOperationLog.java new file mode 100644 index 00000000..9b4f1570 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/OtaProductOperationLog.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaProductOperationLog { + private String operator; + private String operatedAt; + private int type; + private String typeName; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/TaskApproval.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/TaskApproval.java new file mode 100644 index 00000000..17398f0e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/TaskApproval.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class TaskApproval { + private List levels; + @JsonProperty("level_total") + private String levelTotal; + @JsonProperty("life_time_second") + private String lifeTimeSecond; + + @JsonIgnoreProperties(ignoreUnknown = true) + public class Level { + @JsonProperty("level_no") + private String levelNo; + private List reviewers; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/product/TaskConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/TaskConfig.java new file mode 100644 index 00000000..e4230da1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/product/TaskConfig.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.product; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class TaskConfig { + @JsonProperty("task_approval") + private TaskApproval taskApproval; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/DownloadDevCount.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/DownloadDevCount.java new file mode 100644 index 00000000..2589b784 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/DownloadDevCount.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DownloadDevCount { + @JsonProperty("start_count") + private Integer startCount; + @JsonProperty("pause_count") + private Integer pauseCount; + @JsonProperty("resume_count") + private Integer resumeCount; + @JsonProperty("cancel_count") + private Integer cancelCount; + @JsonProperty("success_count") + private Integer successCount; + @JsonProperty("failed_count") + private Integer failedCount; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/FailureReason.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/FailureReason.java new file mode 100644 index 00000000..f1c5c04b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/FailureReason.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class FailureReason { + private Integer code; + @JsonProperty("display_name") + private String displayName; + private String reason; + private Integer amount; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/InstallDevCount.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/InstallDevCount.java new file mode 100644 index 00000000..24d64557 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/InstallDevCount.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class InstallDevCount { + @JsonProperty("start_count") + private Integer startCount; + @JsonProperty("fsync_count") + private Integer fsyncCount; + @JsonProperty("success_count") + private Integer successCount; + @JsonProperty("failed_count") + private Integer failedCount; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskIssuedFailedStatisticsResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskIssuedFailedStatisticsResponse.java new file mode 100644 index 00000000..8125d83a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskIssuedFailedStatisticsResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaTaskIssuedFailedStatisticsResponse extends AbstractBceResponse { + @JsonProperty("failed_download_devcount") + private Integer failedDownloadDevcount; + @JsonProperty("failed_upgrade_devcount") + private Integer failedUpgradeDevcount; + @JsonProperty("failed_devcount") + private Integer failedDevcount; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskIssuedFailureInfoStatisticsResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskIssuedFailureInfoStatisticsResponse.java new file mode 100644 index 00000000..bf1a4481 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskIssuedFailureInfoStatisticsResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaTaskIssuedFailureInfoStatisticsResponse extends AbstractBceResponse { + private String stage; + private Integer total; + private List summary; + private List top10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskIssuedStatisticsResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskIssuedStatisticsResponse.java new file mode 100644 index 00000000..0c24b086 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskIssuedStatisticsResponse.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaTaskIssuedStatisticsResponse extends AbstractBceResponse { + @JsonProperty("task_status") + private String taskStatus; + @JsonProperty("active_devtotal") + private Integer activeDevtotal; + @JsonProperty("active_devcount") + private Integer activeDevcount; + @JsonProperty("success_devcount") + private Integer successDevcount; + @JsonProperty("failed_devcount") + private Integer failedDevcount; + @JsonProperty("upgrade_total_count") + private Integer upgradeTotalCount; + @JsonProperty("assign_count") + private Integer assignCount; + @JsonProperty("deduplication_issued_count") + private Integer deduplicationIssuedCount; + @JsonProperty("planned_upgrade_count") + private Integer plannedUpgradeCount; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskProductLineWeekStatisticsResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskProductLineWeekStatisticsResponse.java new file mode 100644 index 00000000..137c648d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskProductLineWeekStatisticsResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaTaskProductLineWeekStatisticsResponse extends AbstractBceResponse { + private List weekData; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Item { + private String date; + private Integer rate; + private Integer failedCount; + private Integer succeededCount; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskStageStatisticsResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskStageStatisticsResponse.java new file mode 100644 index 00000000..f74ff9f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskStageStatisticsResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaTaskStageStatisticsResponse extends AbstractBceResponse { + @JsonProperty("status_ending") + private Integer statusEnding; + @JsonProperty("status_issueding") + private Integer statusIssueding; + @JsonProperty("status_testing") + private Integer statusTesting; + @JsonProperty("total") + private Integer total; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskStatisticsResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskStatisticsResponse.java new file mode 100644 index 00000000..b2ce8fe8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/OtaTaskStatisticsResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class OtaTaskStatisticsResponse extends AbstractBceResponse { + @JsonProperty("update_at") + private String updateAt; + @JsonProperty("next_update_at") + private String nextUpdateAt; + @JsonProperty("request_dev_count") + private Integer requestDevCount; + @JsonProperty("download_dev_count") + private DownloadDevCount downloadDevCount; + @JsonProperty("install_dev_count") + private InstallDevCount installDevCount; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/Stage.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/Stage.java new file mode 100644 index 00000000..1e0274de --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/statistics/Stage.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.statistics; + +import lombok.Getter; + +@Getter +public enum Stage { + DOWNLOAD("download"), INSTALL("install"); + + private String stage; + + Stage(String stage) { + this.stage = stage; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Basic.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Basic.java new file mode 100644 index 00000000..e0393994 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Basic.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Basic { + private Integer tid; + private String tname; + private String comment; + private Integer priority; + private String type; + private String creator; + @JsonProperty("created_at") + private String createdAt; + @JsonProperty("update_at") + private String updateAt; + private String status; + @JsonProperty("test_status") + private String testStatus; + @JsonProperty("issueding_at") + private String issuedingAt; + @JsonProperty("complete_at") + private String completeAt; + @JsonProperty("deleted_at") + private String deletedAt; + @JsonProperty("parent_id") + private String parentId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/CreateOrUpdateGrayTaskRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/CreateOrUpdateGrayTaskRequest.java new file mode 100644 index 00000000..29b0ae98 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/CreateOrUpdateGrayTaskRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateOrUpdateGrayTaskRequest extends GenericAccountRequest { + @NotNull + private Integer total; + @NotNull + private Type type; + @NotNull + private List setting; + @NotNull + private Boolean auto; + + public enum Type { + percent, count + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/CreateOtaTaskRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/CreateOtaTaskRequest.java new file mode 100644 index 00000000..718c02af --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/CreateOtaTaskRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.ota.packages.OtaPackage; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateOtaTaskRequest extends GenericAccountRequest { + private Basic basic; + @JsonProperty("package_data") + private PackageData packageData; + private Policy policy; + @JsonProperty("target_set") + private TargetSet targetSet; + @JsonProperty("delivery_config") + private DeliveryConfig deliveryConfig; + @JsonProperty("origin_task_id") + private Integer originTakId; + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class Basic { + private String tname; + private String comment; + private Integer priority; + private Type type; + + public enum Type { + online, test + } + } + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class PackageData { + @JsonProperty("package_type") + private String packageType; + @JsonProperty("upgrade_type") + private String upgradeType; + private List list; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/CreateOtaTaskResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/CreateOtaTaskResponse.java new file mode 100644 index 00000000..a7d2b45f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/CreateOtaTaskResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateOtaTaskResponse extends AbstractBceResponse { + private Task task; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Task { + private int id; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DailySchedule.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DailySchedule.java new file mode 100644 index 00000000..305b2642 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DailySchedule.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DailySchedule { + // switch为关键字,无法命名 + @JsonProperty("switch") + private Boolean isSwitch; + @JsonProperty("start_time") + private String startTime; + @JsonProperty("stop_time") + private String stopTime; + @JsonProperty("auto_check_update_only") + private Boolean autoCheckUpdateOnly; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeleteOtaTaskRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeleteOtaTaskRequest.java new file mode 100644 index 00000000..c0c6be6a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeleteOtaTaskRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DeleteOtaTaskRequest extends GenericAccountRequest { + @NotNull + private Boolean isTrashed; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeliveryConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeliveryConfig.java new file mode 100644 index 00000000..96632d73 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeliveryConfig.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DeliveryConfig { + @JsonProperty("enable_pcdn") + private Integer enablePcdn; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeviceEnv.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeviceEnv.java new file mode 100644 index 00000000..90c63dbe --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeviceEnv.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeviceEnv { + @JsonProperty("wifi_download_only") + private Boolean wifiDownloadOnly; + @JsonProperty("battery_protect") + private Integer batteryProtect; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeviceGroup.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeviceGroup.java new file mode 100644 index 00000000..9f9bfb89 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/DeviceGroup.java @@ -0,0 +1,19 @@ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeviceGroup { + private String option; + private String url; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/GetOtaTaskResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/GetOtaTaskResponse.java new file mode 100644 index 00000000..26b59cbe --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/GetOtaTaskResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetOtaTaskResponse extends AbstractBceResponse { + private Integer pid; + private Basic basic; + @JsonProperty("package_data") + private PackageData packageData; + @JsonProperty("target_set") + private TargetSet targetSet; + private Policy policy; + private Rollback rollback; + @JsonProperty("condition_expr") + private String conditionExpr; + @JsonProperty("gray_rate") + private Integer grayRate; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/GrayTask.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/GrayTask.java new file mode 100644 index 00000000..58519667 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/GrayTask.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GrayTask extends AbstractBceResponse { + private Integer total; + private String type; + private List setting; + private Boolean auto; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/ListOtaTaskRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/ListOtaTaskRequest.java new file mode 100644 index 00000000..4de02f71 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/ListOtaTaskRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ListOtaTaskRequest extends GenericAccountRequest { + @Builder.Default + private int page = 1; + @Builder.Default + private int perPage = 10; + private OrderBy orderBy = OrderBy.task_status; + private Direction direction = Direction.desc; + private Boolean isTrashed = false; + private String keyword; + @NotNull + private String status; + + public enum Direction { + asc, desc + } + + public enum OrderBy { + priority, task_status, create_time + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/ListOtaTaskResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/ListOtaTaskResponse.java new file mode 100644 index 00000000..0a6ec60e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/ListOtaTaskResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListOtaTaskResponse extends AbstractBceResponse { + private Integer total; + @JsonProperty("current_page") + private Integer currentPage; + @JsonProperty("count_per_page") + private Integer countPerPage; + private List tasks; + + +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Notify.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Notify.java new file mode 100644 index 00000000..5183ecac --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Notify.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Notify { + @JsonProperty("force_upgrade") + private Boolean forceUpgrade; + @JsonProperty("release_note") + private String releaseNote; + @JsonProperty("silence_update_type") + private Integer silenceUpdateType; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/PackageData.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/PackageData.java new file mode 100644 index 00000000..758d7f83 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/PackageData.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.services.iotdmp.model.ota.packages.OtaPackage; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PackageData { + @JsonProperty("package_type") + private String packageType; + @JsonProperty("upgrade_type") + private String upgradeType; + @JsonProperty("package_name") + private String packageName; + private String version; + private long filesize; + private int filetype; + @JsonProperty("is_encrypted") + private String isEncrypted; + private List list; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Policy.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Policy.java new file mode 100644 index 00000000..6dab8cbf --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Policy.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Policy { + private Notify notify; + @JsonProperty("device_env") + private DeviceEnv deviceEnv; + @JsonProperty("upgrade_timing") + private UpgradeTiming upgradeTiming; + @JsonProperty("user_define") + private UserDefine userDefine; + @JsonProperty("daily_schedule") + private DailySchedule dailySchedule; + + @Data + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class UserDefine { + @JsonProperty("user_data") + private String userData; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Rollback.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Rollback.java new file mode 100644 index 00000000..bc22bbac --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Rollback.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Rollback { + private Basic basic; + @JsonProperty("package_data") + private PackageData packageData; + @JsonProperty("test_device_group") + private DeviceGroup testDeviceGroup; + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Basic { + private String tname; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class DeviceGroup { + private String option; + private String url; + @JsonProperty("device_group_id") + private Integer deviceGroupId; + @JsonProperty("show_name") + private String showName; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/TargetSet.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/TargetSet.java new file mode 100644 index 00000000..6c5d7534 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/TargetSet.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TargetSet { + private Quantity quantity; + @JsonProperty("test_device_group") + private DeviceGroup testDeviceGroup; + @JsonProperty("device_group") + private DeviceGroup deviceGroup; + private Channel channel; + private Version version; + @JsonProperty("advanced_expr") + private String advancedExpr; + @JsonProperty("min_sys_cache_mb") + private String minSysCacheMb; + private String deviceFilter; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Quantity { + private String option; + @JsonProperty("quota_quantities") + private Integer quotaQuantities; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class DeviceGroup { + private String option; + private String url; + @JsonProperty("device_group_id") + private Integer deviceGroupId; + @JsonProperty("show_name") + private String showName; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Version { + private List system; + private String[] app; + private String[] code; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class System { + @JsonProperty("min_version") + private String minVersion; + @JsonProperty("max_version") + private String maxVersion; + } + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class Channel { + private String option; + private List data; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Task.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Task.java new file mode 100644 index 00000000..7261db88 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/Task.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Task { + private Basic basic; + @JsonProperty("package_data") + private PackageData packageData; + @JsonProperty("test_info") + private TaskInfo testInfo; + @JsonProperty("issue_info") + private TaskInfo issueInfo; + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class TaskInfo { + @JsonProperty("amount_total") + private Integer amountTotal; + @JsonProperty("amount_success") + private Integer amountSuccess; + @JsonProperty("amount_failed") + private Integer amountFailed; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskRequest.java new file mode 100644 index 00000000..18be2b27 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class UpdateOtaTaskRequest extends GenericAccountRequest { + private Integer priority; + private Notify notify; + private DailySchedule dailySchedule; + private String userData; + private DeviceGroup deviceGroup; + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class Notify { + private Boolean forceUpgrade; + private String releaseNote; + private Integer silenceUpdateType; + } + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class DailySchedule { + @JsonProperty("switch") + private Boolean isSwitch; + private String startTime; + private String stopTime; + private Boolean autoCheckUpdateOnly; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskResponse.java new file mode 100644 index 00000000..a38fa02e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateOtaTaskResponse extends AbstractBceResponse { + private Integer modified; + private Boolean needApproval; + private Integer approvalId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskStatusRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskStatusRequest.java new file mode 100644 index 00000000..bf4d2098 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskStatusRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class UpdateOtaTaskStatusRequest extends GenericAccountRequest { + @NotNull + private Status status; + + public enum Status { + status_testing, status_issueding, status_pause, status_stop, status_completed, status_issued + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskStatusResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskStatusResponse.java new file mode 100644 index 00000000..02038dcb --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpdateOtaTaskStatusResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateOtaTaskStatusResponse extends AbstractBceResponse { + private String status; + @JsonProperty("test_status") + private String testStatus; + @JsonProperty("complete_time") + private String completeTime; + @JsonProperty("issueding_time") + private String issuedingTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpgradeTiming.java b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpgradeTiming.java new file mode 100644 index 00000000..95e0dd14 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/ota/task/UpgradeTiming.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.ota.task; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpgradeTiming { + @JsonProperty("is_delay") + private Boolean isDelay; + @JsonProperty("effective_time") + private String effectiveTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/AuthRuleChainExternalDestinationResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/AuthRuleChainExternalDestinationResponse.java new file mode 100644 index 00000000..a9c23608 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/AuthRuleChainExternalDestinationResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AuthRuleChainExternalDestinationResponse extends AbstractBceResponse { + private String instanceId; + private String destinationId; + private String status; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/BatchDeleteRuleChainExternalDestinationRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/BatchDeleteRuleChainExternalDestinationRequest.java new file mode 100644 index 00000000..42e0b8f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/BatchDeleteRuleChainExternalDestinationRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; + +import java.util.Set; + +@Data +@Builder +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BatchDeleteRuleChainExternalDestinationRequest extends GenericAccountRequest { + + @NonNull + private Set destinationIds; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/BatchDeleteRuleChainRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/BatchDeleteRuleChainRequest.java new file mode 100644 index 00000000..1bc9a544 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/BatchDeleteRuleChainRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.util.Set; + +@Data +@Builder +@AllArgsConstructor +public class BatchDeleteRuleChainRequest extends GenericAccountRequest { + + private Set rulechainIds; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainExternalDestinationRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainExternalDestinationRequest.java new file mode 100644 index 00000000..72e0ea6c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainExternalDestinationRequest.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +@Deprecated +public class CreateRuleChainExternalDestinationRequest extends GenericAccountRequest { + + @NonNull + private RuleChainExternalDestinationType type; + private String description; + @NonNull + private RuleChainExternalDestinationArgsInfo args; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainExternalDestinationRequestV2.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainExternalDestinationRequestV2.java new file mode 100644 index 00000000..c70210c9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainExternalDestinationRequestV2.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.baidubce.model.GenericAccountRequest; +import lombok.Data; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateRuleChainExternalDestinationRequestV2 extends GenericAccountRequest { + private RuleChainExternalDestinationType type; + private String description; + private RuleChainExternalDestinationArgs args; + + public CreateRuleChainExternalDestinationRequestV2(RuleChainExternalDestinationArgs args, String description) { + this.type = args.getType(); + this.description = description; + this.args = args; + } + + public CreateRuleChainExternalDestinationRequestV2(RuleChainExternalDestinationArgs args) { + this.type = args.getType(); + this.args = args; + } + + private void setType(RuleChainExternalDestinationType type) { + this.type = type; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainExternalDestinationResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainExternalDestinationResponse.java new file mode 100644 index 00000000..7a05f239 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainExternalDestinationResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateRuleChainExternalDestinationResponse extends AbstractBceResponse { + String id; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainRequest.java new file mode 100644 index 00000000..2ba22a07 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainRequest.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +@Data +@AllArgsConstructor +@Builder +public class CreateRuleChainRequest extends GenericAccountRequest { + + private String name; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainResponse.java new file mode 100644 index 00000000..4ba98003 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/CreateRuleChainResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateRuleChainResponse extends AbstractBceResponse { + + private String rulechainId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalHttpArgs.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalHttpArgs.java new file mode 100644 index 00000000..e151dc67 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalHttpArgs.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ExternalHttpArgs extends RuleChainExternalDestinationArgs { + private String name; + private String address; + + public ExternalHttpArgs() { + super(RuleChainExternalDestinationType.EXTERNAL_HTTP); + } + + public ExternalHttpArgs(String name, String address) { + super(RuleChainExternalDestinationType.EXTERNAL_HTTP); + this.name = name; + this.address = address; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalKafkaArgs.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalKafkaArgs.java new file mode 100644 index 00000000..210706b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalKafkaArgs.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ExternalKafkaArgs extends RuleChainExternalDestinationArgs { + private RuleChainExternalDestinationAuthType authType; + private String address; + private String truststoreId; + private String truststorePassword; + private String keystoreId; + private String keystorePassword; + private String topic; + + public ExternalKafkaArgs() { + super(RuleChainExternalDestinationType.EXTERNAL_KAFKA); + } + + public ExternalKafkaArgs(RuleChainExternalDestinationAuthType authType, String address, String truststoreId, + String truststorePassword, String keystoreId, String keystorePassword, String topic) { + super(RuleChainExternalDestinationType.EXTERNAL_KAFKA); + this.authType = authType; + this.address = address; + this.truststoreId = truststoreId; + this.truststorePassword = truststorePassword; + this.keystoreId = keystoreId; + this.keystorePassword = keystorePassword; + this.topic = topic; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalMinioArgs.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalMinioArgs.java new file mode 100644 index 00000000..7903e8d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalMinioArgs.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ExternalMinioArgs extends RuleChainExternalDestinationArgs { + private String name; + private String address; + private String accessKey; + private String secretKey; + private String region; + private String bucket; + + public ExternalMinioArgs() { + super(RuleChainExternalDestinationType.EXTERNAL_MINIO); + } + + public ExternalMinioArgs(String name, String address, String accessKey, + String secretKey, String region, String bucket) { + super(RuleChainExternalDestinationType.EXTERNAL_MINIO); + this.name = name; + this.address = address; + this.accessKey = accessKey; + this.secretKey = secretKey; + this.region = region; + this.bucket = bucket; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalMysqlArgs.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalMysqlArgs.java new file mode 100644 index 00000000..9f6d8714 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalMysqlArgs.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ExternalMysqlArgs extends RuleChainExternalDestinationArgs { + private String name; + private String host; + private String port; + private String accountName; + private String accountPassword; + private String dbName; + + public ExternalMysqlArgs() { + super(RuleChainExternalDestinationType.EXTERNAL_MYSQL); + } + + public ExternalMysqlArgs(String name, String host, String port, + String accountName, String accountPassword, String dbName) { + super(RuleChainExternalDestinationType.EXTERNAL_MYSQL); + this.name = name; + this.host = host; + this.port = port; + this.accountName = accountName; + this.accountPassword = accountPassword; + this.dbName = dbName; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalRocketmqArgs.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalRocketmqArgs.java new file mode 100644 index 00000000..3bd96d88 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalRocketmqArgs.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ExternalRocketmqArgs extends RuleChainExternalDestinationArgs { + private String name; + private String address; + private String accessKey; + private String secretKey; + private String topic; + + public ExternalRocketmqArgs() { + super(RuleChainExternalDestinationType.EXTERNAL_ROCKETMQ); + } + + public ExternalRocketmqArgs(String name, String address, String accessKey, String secretKey, String topic) { + super(RuleChainExternalDestinationType.EXTERNAL_ROCKETMQ); + this.name = name; + this.address = address; + this.accessKey = accessKey; + this.secretKey = secretKey; + this.topic = topic; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalTsdbArgs.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalTsdbArgs.java new file mode 100644 index 00000000..eff3e668 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalTsdbArgs.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ExternalTsdbArgs extends RuleChainExternalDestinationArgs { + private String name; + private String ingestAddress; + private String accessKey; + private String secretKey; + private String database; + + public ExternalTsdbArgs() { + super(RuleChainExternalDestinationType.EXTERNAL_TSDB); + } + + public ExternalTsdbArgs(String name, String ingestAddress, String accessKey, String secretKey, String database) { + super(RuleChainExternalDestinationType.EXTERNAL_TSDB); + this.name = name; + this.ingestAddress = ingestAddress; + this.accessKey = accessKey; + this.secretKey = secretKey; + this.database = database; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalYMatrixArgs.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalYMatrixArgs.java new file mode 100644 index 00000000..e8a9477a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ExternalYMatrixArgs.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ExternalYMatrixArgs extends RuleChainExternalDestinationArgs { + private String name; + private String host; + private String port; + private String accountName; + private String accountPassword; + private String dbName; + + public ExternalYMatrixArgs() { + super(RuleChainExternalDestinationType.EXTERNAL_YMATRIX); + } + + public ExternalYMatrixArgs(String name, String host, String port, String accountName, + String accountPassword, String dbName) { + super(RuleChainExternalDestinationType.EXTERNAL_YMATRIX); + this.name = name; + this.host = host; + this.port = port; + this.accountName = accountName; + this.accountPassword = accountPassword; + this.dbName = dbName; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainDestinationRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainDestinationRequest.java new file mode 100644 index 00000000..1ba5cfb2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainDestinationRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListRuleChainDestinationRequest extends GenericAccountRequest { + + @NonNull + private String sourceType; + private String type; + @Builder.Default + private String region = "default"; + @Builder.Default + private String order = "desc"; + @Builder.Default + private String orderBy = "createTime"; + @Builder.Default + private int pageNo = 1; + @Builder.Default + private int pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainDestinationResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainDestinationResponse.java new file mode 100644 index 00000000..ad65e253 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainDestinationResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListRuleChainDestinationResponse extends AbstractBceResponse { + + private String orderBy; + private String order; + private String sourceType; + private String type; + private String region; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainRequest.java new file mode 100644 index 00000000..ec09ec93 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainRequest.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListRuleChainRequest extends GenericAccountRequest { + + private String name; + private String state; + private String status; + private String order; + private String orderBy; + @Builder.Default + private int pageNo = 1; + @Builder.Default + private int pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainResponse.java new file mode 100644 index 00000000..87ff254c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ListRuleChainResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListRuleChainResponse extends AbstractBceResponse { + + private String orderBy; + private String order; + private String name; + private String state; + private String status; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/PlatformRuleChainInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/PlatformRuleChainInfo.java new file mode 100644 index 00000000..c5d51026 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/PlatformRuleChainInfo.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.Collections; +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class PlatformRuleChainInfo extends AbstractBceResponse { + + private String name; + private String description = ""; + private String status; + private String createTime; + private String source; + private RuleChainComputeInfo compute; + private List destinations = Collections.emptyList(); + private List errorDestinations = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainComputeInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainComputeInfo.java new file mode 100644 index 00000000..ed3639c2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainComputeInfo.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import lombok.Data; + +@Data +public class RuleChainComputeInfo { + + private String type; + private String query = null; + private String filter = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDTO.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDTO.java new file mode 100644 index 00000000..80d0870f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDTO.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import lombok.Data; + +@Data +public class RuleChainDTO { + + private String rulechainId; + private String name; + private String description; + private String state; + private String status; + private String createTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDestinationInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDestinationInfo.java new file mode 100644 index 00000000..d05fc1c2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDestinationInfo.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class RuleChainDestinationInfo { + + private String type; + private Map args; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDestinationProfile.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDestinationProfile.java new file mode 100644 index 00000000..c30b4f92 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDestinationProfile.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class RuleChainDestinationProfile { + + private String id; + private String name; + private String type; + private String status; + private Map args; + private String description; + private String createTime; + private boolean enableDelete; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDestinationType.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDestinationType.java new file mode 100644 index 00000000..50e4bf81 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainDestinationType.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +public enum RuleChainDestinationType { + + TSDB, EXTERNAL_KAFKA, IOT_PLATFORM, DEVICE +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationArgs.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationArgs.java new file mode 100644 index 00000000..ddead685 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationArgs.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public abstract class RuleChainExternalDestinationArgs { + + @JsonIgnore + private RuleChainExternalDestinationType type; + + public RuleChainExternalDestinationArgs(RuleChainExternalDestinationType type) { + this.type = type; + } + + public RuleChainExternalDestinationArgs() { + } + + public RuleChainExternalDestinationType getType() { + return type; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationArgsInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationArgsInfo.java new file mode 100644 index 00000000..d7b77f03 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationArgsInfo.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class RuleChainExternalDestinationArgsInfo { + + + private RuleChainExternalDestinationAuthType authType; + private String address; + private String truststoreId; + private String truststorePassword; + private String keystoreId; + private String keystorePassword; + private String topic; + private String name; + private String ingestAddress; + private String accessKey; + private String secretKey; + private String database; + private String host; + private String port; + private String accountName; + private String accountPassword; + private String dbName; + private String region; + private String bucket; + + public RuleChainExternalDestinationArgsInfo(RuleChainExternalDestinationAuthType authType) { + this.authType = authType; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationAuthType.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationAuthType.java new file mode 100644 index 00000000..4ca72158 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationAuthType.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +public enum RuleChainExternalDestinationAuthType { + + CERT, ACCOUNT_PASSWORD +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationType.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationType.java new file mode 100644 index 00000000..3348a68e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainExternalDestinationType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +public enum RuleChainExternalDestinationType { + EXTERNAL_KAFKA, EXTERNAL_HTTP, EXTERNAL_TSDB, EXTERNAL_ROCKETMQ, EXTERNAL_MYSQL, EXTERNAL_MINIO, EXTERNAL_YMATRIX +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainState.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainState.java new file mode 100644 index 00000000..68e5d583 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/RuleChainState.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import lombok.Getter; + +public enum RuleChainState { + + ENABLED(true), DISABLED(false); + + RuleChainState(boolean boolVal) { + this.boolVal = boolVal; + } + + @Getter + private boolean boolVal; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/UpdatePlatformRuleChainRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/UpdatePlatformRuleChainRequest.java new file mode 100644 index 00000000..a88f3d5f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/UpdatePlatformRuleChainRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +import java.util.Collections; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdatePlatformRuleChainRequest extends GenericAccountRequest { + + @NonNull + private String source; + private String description = ""; + private RuleChainComputeInfo compute; + private List destinations = Collections.emptyList(); + private List errorDestinations = null; + +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/UpdateRuleChainStateRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/UpdateRuleChainStateRequest.java new file mode 100644 index 00000000..3cc82a8a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/UpdateRuleChainStateRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +@Data +@AllArgsConstructor +@Builder +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateRuleChainStateRequest extends GenericAccountRequest { + + private RuleChainState state; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/UploadKafkaConfigFileResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/UploadKafkaConfigFileResponse.java new file mode 100644 index 00000000..281f18f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/UploadKafkaConfigFileResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class UploadKafkaConfigFileResponse extends AbstractBceResponse { + private String id; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ValidateResult.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ValidateResult.java new file mode 100644 index 00000000..9ce3cdda --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ValidateResult.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import lombok.Data; + +@Data +public class ValidateResult { + + private boolean valid; + private String exception; + private String output; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ValidateRuleChainRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ValidateRuleChainRequest.java new file mode 100644 index 00000000..eae34e23 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ValidateRuleChainRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@Builder +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ValidateRuleChainRequest extends GenericAccountRequest { + + private String message; + private String query; + private String filter; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/platform/ValidateRuleChainResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/platform/ValidateRuleChainResponse.java new file mode 100644 index 00000000..55648063 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/platform/ValidateRuleChainResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.platform; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ValidateRuleChainResponse extends AbstractBceResponse { + + private ValidateResult message; + private ValidateResult query; + private ValidateResult filter; + private ValidateResult result; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/CreateProductByModelRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/CreateProductByModelRequest.java new file mode 100644 index 00000000..b0e03d37 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/CreateProductByModelRequest.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.baidubce.services.iotdmp.model.extension.ability.ServiceType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collections; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateProductByModelRequest extends GenericAccountRequest { + private String productName; + private String productKey; + private String description; + private DeviceType deviceType; + private List accessType; + private String productCategory; + private List extensions = Collections.emptyList(); +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/CreateProductInfoRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/CreateProductInfoRequest.java new file mode 100644 index 00000000..b3382086 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/CreateProductInfoRequest.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.baidubce.services.iotdmp.model.device.ResourceType; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.NonNull; +import java.util.ArrayList; +import java.util.List; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateProductInfoRequest extends GenericAccountRequest { + + @NonNull + private String productName; + private String productKey; + private String description; + @NonNull + private DeviceType deviceType; + @NonNull + private List accessType; + private List extensions; + private String productCategory; + private ProductType productType; + + public CreateProductInfoRequest(String productName, DeviceType deviceType, List accessType) { + this.productName = productName; + this.deviceType = deviceType; + this.accessType = convertAlias(accessType); + this.productCategory = "用户自定义"; + } + + public CreateProductInfoRequest(String productName, DeviceType deviceType, String productCategory, + List accessType) { + this.productName = productName; + this.deviceType = deviceType; + this.accessType = convertAlias(accessType); + this.productCategory = productCategory; + } + + public CreateProductInfoRequest(String productName, String productKey, String description, + DeviceType deviceType, String productCategory, List accessType, + List extensions) { + this.productName = productName; + this.productKey = productKey; + this.description = description; + this.deviceType = deviceType; + this.accessType = convertAlias(accessType); + this.extensions = extensions; + this.productCategory = productCategory; + } + + public static CreateProductInfoRequest.Builder builder() { + return new CreateProductInfoRequest.Builder(); + } + + public static class Builder { + private String productName; + private String productKey; + private String description; + private DeviceType deviceType; + private String productCategory; + private List accessType; + private List extensions; + + public Builder() { } + + public Builder productName(String productName) { + this.productName = productName; + return this; + } + + public Builder productKey(String productKey) { + this.productKey = productKey; + return this; + } + + public Builder description(String description) { + this.description = description; + return this; + } + + public Builder deviceType(DeviceType deviceType) { + this.deviceType = deviceType; + return this; + } + + public Builder productCategory(String productCategory) { + this.productCategory = productCategory; + return this; + } + + public Builder accessType(List accessType) { + this.accessType = accessType; + return this; + } + + public Builder extensions(List extensions) { + this.extensions = extensions; + return this; + } + + public CreateProductInfoRequest build() { + return new CreateProductInfoRequest(this.productName, this.productKey, this.description, + this.deviceType, this.productCategory, this.accessType, this.extensions); + } + } + + public void setAccessType(List accessType) { + this.accessType = convertAlias(accessType); + } + + private List convertAlias(List accessTypes) { + ArrayList aliasAccessTypes = new ArrayList(); + for (ProductAccessType productAccessType : accessTypes) { + aliasAccessTypes.add(productAccessType.getAlias()); + } + return aliasAccessTypes; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/CreateTagRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/CreateTagRequest.java new file mode 100644 index 00000000..8b6203b6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/CreateTagRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.tag.CommonTagInfo; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateTagRequest extends GenericAccountRequest { + + private List tags; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/GetProductSubsetsRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/GetProductSubsetsRequest.java new file mode 100644 index 00000000..e4bf7d44 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/GetProductSubsetsRequest.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.services.iotshc.model.CommonListRequest; +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +public class GetProductSubsetsRequest extends CommonListRequest { + private final String productKey; + private String subProductName; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ImportProductModelRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ImportProductModelRequest.java new file mode 100644 index 00000000..9a5103d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ImportProductModelRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.baidubce.services.iotdmp.model.device.tag.CommonTagInfo; +import com.baidubce.services.iotdmp.model.product.feature.thing.Thing; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ImportProductModelRequest extends GenericAccountRequest { + private String modelId = null; + private String bindName = null; + private String productKey; + private String productName; + private String description; + private String productCategory; + private DeviceType deviceType; + private List accessType = null; + private Long offlineDetectCycle = null; + private List tags = null; + private Thing features; + private List components = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductCategoryResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductCategoryResponse.java new file mode 100644 index 00000000..86227365 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductCategoryResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListProductCategoryResponse extends AbstractBceResponse { + private String categoryName; + List categoryList = new ArrayList(); +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductModelRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductModelRequest.java new file mode 100644 index 00000000..3f32833e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductModelRequest.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.baidubce.services.iotdmp.model.product.repositories.ProductModelType; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListProductModelRequest extends GenericAccountRequest { + private String productName; + @Builder.Default + private final int pageNo = 1; + @Builder.Default + private final int pageSize = 10; + private ProductModelType type; + private DeviceType deviceType; + private String keyword; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductModelResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductModelResponse.java new file mode 100644 index 00000000..db935cb7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductModelResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListProductModelResponse extends AbstractBceResponse { + private String productName; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductRequest.java new file mode 100644 index 00000000..abb8f172 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductRequest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListProductRequest extends GenericAccountRequest { + + private String productName; + private String tagKey; + private String tagValue; + private DeviceType deviceType; + private String productCategory; + @Builder.Default + private final int pageNo = 1; + @Builder.Default + private final int pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductResponse.java new file mode 100644 index 00000000..a2f02818 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ListProductResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListProductResponse extends AbstractBceResponse { + + private String productName; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; + private String tagKey; + private String tagValue; + private String deviceType; + +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ListSubsetProductResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ListSubsetProductResponse.java new file mode 100644 index 00000000..c1ab3e11 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ListSubsetProductResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListSubsetProductResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/PermanentConnectRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/PermanentConnectRequest.java new file mode 100644 index 00000000..48c9f3c4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/PermanentConnectRequest.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.GenericAccountRequest; +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +public class PermanentConnectRequest extends GenericAccountRequest { + private final boolean permanentConnect; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ProductAccessType.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ProductAccessType.java new file mode 100644 index 00000000..3d1ea020 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ProductAccessType.java @@ -0,0 +1,26 @@ +package com.baidubce.services.iotdmp.model.product; + +public enum ProductAccessType { + WIFI("WIFI"), + OTHER_GENERATION("2G/3G/4G"), + FIFTH_GENERATION("5G"), + ETHERNET("ETHERNET"), + NB_IOT("NB-IOT"), + BLE("BLE"), + ZIGBEE("ZigBee"), + MODBUS("Modbus"), + OPC_UA("OPC UA"), + HTTP("HTTP/HTTPS"), + MQTT("MQTT"), + OTHER("OTHER"); + + private String alias; + + ProductAccessType(String alias) { + this.alias = alias; + } + + public String getAlias() { + return alias; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ProductInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ProductInfo.java new file mode 100644 index 00000000..aac47e1b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ProductInfo.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductInfo extends AbstractBceResponse { + private String instanceId; + private String productKey; + private String productSecret; + private String productName; + private String description; + private String deviceType; + private List accessType; + private List extensions; + private boolean permanentConnect; + private boolean offlineDetectState; + private Long offlineDetectCycle; + private boolean logState; + private boolean dynamicRegisterState; + private String createTime; + private String updateTime; + private String productCategory; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ProductModelInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ProductModelInfo.java new file mode 100644 index 00000000..513ba421 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ProductModelInfo.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.baidubce.services.iotdmp.model.device.tag.CommonTagInfo; +import com.baidubce.services.iotdmp.model.product.feature.thing.Thing; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductModelInfo extends AbstractBceResponse { + private String modelId = null; + private String bindName = null; + private String productKey; + private String productName; + private String description; + private String productCategory; + private DeviceType deviceType; + private List accessType = null; + private Long offlineDetectCycle = null; + private List tags = null; + private Thing features; + private List components = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/ProductType.java b/src/main/java/com/baidubce/services/iotdmp/model/product/ProductType.java new file mode 100644 index 00000000..a4cb9e90 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/ProductType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +public enum ProductType { + kube +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/UpdateProductInfoRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/UpdateProductInfoRequest.java new file mode 100644 index 00000000..443f1ef3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/UpdateProductInfoRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.ResourceType; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateProductInfoRequest extends GenericAccountRequest { + + private String productName; + private String description; + private Boolean offlineDetectState; + private Long offlineDetectCycle; + private List extensions; + private Boolean logState; + private Boolean dynamicRegisterState; + private String productCategory; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/CommonEvsAuthInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/CommonEvsAuthInfo.java new file mode 100644 index 00000000..cf83afa4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/CommonEvsAuthInfo.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +@AllArgsConstructor +public class CommonEvsAuthInfo { + + private Boolean enabled = Boolean.FALSE; + private String key = null; + private Integer expire = null; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/CreateEvsSpaceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/CreateEvsSpaceRequest.java new file mode 100644 index 00000000..f8feba39 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/CreateEvsSpaceRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.evs.EvsRecordingConfig; +import com.baidubce.services.iotdmp.model.device.evs.EvsSpaceType; +import com.baidubce.services.iotdmp.model.device.evs.EvsThumbnailConfig; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateEvsSpaceRequest extends GenericAccountRequest { + + private String spaceName; + private String description; + @NonNull + @Builder.Default + private EvsSpaceType type = EvsSpaceType.RTMP; + private List domains; + private CommonEvsAuthInfo upstreamAuth; + private CommonEvsAuthInfo downstreamAuth; + private EvsRecordingConfig recording; + private EvsThumbnailConfig thumbnail; + private EvsTimeShiftConfig timeShift; + private EvsCallbackConfig callback; + private EvsGbProperties gbProperties; + private Long edgeId; + + public void setBucket(String bucket) { + if (recording != null && recording.getEnabled()) { + recording.setBucket(bucket); + } + + if (thumbnail != null && thumbnail.getEnabled()) { + thumbnail.setBucket(bucket); + } + } + + public CreateEvsSpaceRequest(EvsSpaceType type) { + this.type = type; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Domains.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Domains.java new file mode 100644 index 00000000..0e77a132 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Domains.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Domains { + private String domain; + private String type; + private String cname; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/DownstreamAuth.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/DownstreamAuth.java new file mode 100644 index 00000000..4ce09b45 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/DownstreamAuth.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DownstreamAuth { + private boolean enabled; + private boolean sameAsSpace; + private int expire; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Edge.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Edge.java new file mode 100644 index 00000000..63eb88cd --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Edge.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Edge { + private Integer sipPort; + private String region; + private Long edgeId; + private String ftpIp; + private String sipProtocol; + private Integer ftpPort; + private String sipIp; + private String sipRealm; + private String serviceProvider; + private String sipId; + private String city; + private String edgeName; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsCallbackConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsCallbackConfig.java new file mode 100644 index 00000000..af99b6ad --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsCallbackConfig.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class EvsCallbackConfig { + + private Boolean enabled = Boolean.FALSE; + private List types = null; + private String endpoint = null; + private Boolean authEnabled = Boolean.FALSE; + private String key = null; + + public EvsCallbackConfig(Boolean enabled, List types, String endpoint) { + this.enabled = enabled; + this.types = types; + this.endpoint = endpoint; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsCallbackType.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsCallbackType.java new file mode 100644 index 00000000..48df971d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsCallbackType.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +public enum EvsCallbackType { + + ON_PUBLISH, ON_UNPUBLISH, ON_SNAPSHOT, ON_PLAY, ON_STOP +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsContent.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsContent.java new file mode 100644 index 00000000..87815938 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsContent.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class EvsContent { + private String type; + private UpstreamAuth upstreamAuth; + private String description; + private Recording recording; + private DownstreamAuth downstreamAuth; + private String status; + private Edge edge; + private String createTime; + private TimeShift timeShift; + private Long deviceId; + private Long spaceId; + private List domains; + private String spaceName; + private String deviceStreamId; + private String deviceName; + private Thumbnail thumbnail; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsGbProperties.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsGbProperties.java new file mode 100644 index 00000000..3f12e140 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsGbProperties.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import lombok.Data; + +@Data +public class EvsGbProperties { + + private Boolean inviteImmediate = Boolean.TRUE; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsSpaceDomain.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsSpaceDomain.java new file mode 100644 index 00000000..11fb56a0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsSpaceDomain.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class EvsSpaceDomain { + + private String domain; + private EvsSpaceDomainType type; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsSpaceDomainType.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsSpaceDomainType.java new file mode 100644 index 00000000..26709236 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsSpaceDomainType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +public enum EvsSpaceDomainType { + UPSTREAM, DOWNSTREAM +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsSpaceInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsSpaceInfo.java new file mode 100644 index 00000000..2fb06045 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsSpaceInfo.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class EvsSpaceInfo extends AbstractBceResponse { + + private boolean open = false; + private EvsContent content = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsTimeShiftConfig.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsTimeShiftConfig.java new file mode 100644 index 00000000..01517d58 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/EvsTimeShiftConfig.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +@AllArgsConstructor +public class EvsTimeShiftConfig { + + private Boolean enabled = Boolean.FALSE; + private Integer range = null; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/GetEvsStreamResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/GetEvsStreamResponse.java new file mode 100644 index 00000000..bf814ed5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/GetEvsStreamResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetEvsStreamResponse extends AbstractBceResponse { + private String url; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Recording.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Recording.java new file mode 100644 index 00000000..bbe56b10 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Recording.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Recording { + private boolean authEnabled; + private boolean sameAsSpace; + private int authExpire; + private String format; + private boolean enabled; + private int duration; + private String bucket; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Thumbnail.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Thumbnail.java new file mode 100644 index 00000000..180a8ce5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/Thumbnail.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Thumbnail { + private boolean sameAsSpace; + private int interval; + private boolean enabled; + private String bucket; + private boolean authEnabled; + private int authExpire; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/TimeShift.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/TimeShift.java new file mode 100644 index 00000000..081cc4b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/TimeShift.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class TimeShift { + private boolean sameAsSpace; + private Integer range; + private boolean enabled; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/UpdateEvsSpaceRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/UpdateEvsSpaceRequest.java new file mode 100644 index 00000000..3db0d115 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/UpdateEvsSpaceRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.device.evs.EvsRecordingConfig; +import com.baidubce.services.iotdmp.model.device.evs.EvsThumbnailConfig; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateEvsSpaceRequest extends GenericAccountRequest { + + private CommonEvsAuthInfo upstreamAuth; + private CommonEvsAuthInfo downstreamAuth; + private EvsRecordingConfig recording; + private EvsThumbnailConfig thumbnail; + private EvsTimeShiftConfig timeShift; + private EvsCallbackConfig callback; + private EvsGbProperties gbProperties; + + public void setBucket(String bucket) { + if (recording != null && recording.getEnabled()) { + recording.setBucket(bucket); + } + + if (thumbnail != null && thumbnail.getEnabled()) { + thumbnail.setBucket(bucket); + } + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/evs/UpstreamAuth.java b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/UpstreamAuth.java new file mode 100644 index 00000000..6334d893 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/evs/UpstreamAuth.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.evs; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpstreamAuth { + private int expire; + private boolean sameAsSpace; + private boolean enabled; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/CreateFeatureRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/CreateFeatureRequest.java new file mode 100644 index 00000000..ea66387e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/CreateFeatureRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature; + +import com.baidubce.model.GenericAccountRequest; +import lombok.Data; + +import java.util.HashMap; + +@Data +public class CreateFeatureRequest extends GenericAccountRequest { + + private String instanceId; + private String productKey; + private String featureId = ""; + private FeatureType featureType; + private String featureName = ""; + private HashMap featureContent; + private String description = ""; + + public CreateFeatureRequest(FeatureType featureType, String featureName, + HashMap featureContent) { + this.featureType = featureType; + this.featureName = featureName; + this.featureContent = featureContent; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/DtmlDetailResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/DtmlDetailResponse.java new file mode 100644 index 00000000..c8831569 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/DtmlDetailResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DtmlDetailResponse extends AbstractBceResponse { + @JsonProperty("@id") + private String id; + @JsonProperty("@context") + private List context; + private Map properties; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/FeatureType.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/FeatureType.java new file mode 100644 index 00000000..34b79435 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/FeatureType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature; + +public enum FeatureType { + PROPERTY, EVENT, COMMAND +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/ListFeatureRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/ListFeatureRequest.java new file mode 100644 index 00000000..4fcea09a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/ListFeatureRequest.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature; + +import com.baidubce.model.GenericAccountRequest; +import lombok.Data; + +@Data +public class ListFeatureRequest extends GenericAccountRequest { + + private String featureName; + private int pageNo = 1; + private int pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/ListFeatureResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/ListFeatureResponse.java new file mode 100644 index 00000000..ff5a9fcd --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/ListFeatureResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListFeatureResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/ProductFeatureInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/ProductFeatureInfo.java new file mode 100644 index 00000000..917747ef --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/ProductFeatureInfo.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.HashMap; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductFeatureInfo extends AbstractBceResponse { + + private String instanceId; + private String productKey; + private String featureId = ""; + @NotNull + private FeatureType featureType; + private String featureName = ""; + private HashMap featureContent; + private String description = ""; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/UpdateProductFeatureRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/UpdateProductFeatureRequest.java new file mode 100644 index 00000000..2870e632 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/UpdateProductFeatureRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature; + +import com.baidubce.model.GenericAccountRequest; +import lombok.Data; + +import java.util.HashMap; + +@Data +public class UpdateProductFeatureRequest extends GenericAccountRequest { + + private String featureName; + private HashMap featureContent; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/CreateFeatureCommandRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/CreateFeatureCommandRequest.java new file mode 100644 index 00000000..9f538a3d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/CreateFeatureCommandRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.command; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateFeatureCommandRequest extends GenericAccountRequest { + + private String instanceId; + private String productKey; + @NonNull + private String name; + private Map input; + private Map output; + @NonNull + private String displayName; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/ListFeatureCommandResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/ListFeatureCommandResponse.java new file mode 100644 index 00000000..2f6d07de --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/ListFeatureCommandResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.command; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListFeatureCommandResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/ProductFeatureCommandInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/ProductFeatureCommandInfo.java new file mode 100644 index 00000000..c06724f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/ProductFeatureCommandInfo.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.command; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductFeatureCommandInfo extends AbstractBceResponse { + + private String instanceId; + private String productKey; + private String name = ""; + private Map input = null; + private Map output = null; + private String displayName = ""; + private String description = ""; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/UpdateProductCommandRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/UpdateProductCommandRequest.java new file mode 100644 index 00000000..4fc61f37 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/command/UpdateProductCommandRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.command; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateProductCommandRequest extends GenericAccountRequest { + + private Map input; + private Map output; + private String displayName; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/CreateFeatureEventRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/CreateFeatureEventRequest.java new file mode 100644 index 00000000..0887534f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/CreateFeatureEventRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.event; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@RequiredArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateFeatureEventRequest extends GenericAccountRequest { + + @NonNull + private String name; + @NonNull + private ProductFeatureEventType type; + private Map dataSchema; + @NonNull + private String displayName; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/ListFeatureEventResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/ListFeatureEventResponse.java new file mode 100644 index 00000000..e21ef6ef --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/ListFeatureEventResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.event; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListFeatureEventResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/ProductFeatureEventInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/ProductFeatureEventInfo.java new file mode 100644 index 00000000..93f58115 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/ProductFeatureEventInfo.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.event; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductFeatureEventInfo extends AbstractBceResponse { + + private String instanceId; + private String productKey; + private String name = ""; + private ProductFeatureEventType type; + private Map dataSchema = null; + private String displayName = ""; + private String description = ""; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/ProductFeatureEventType.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/ProductFeatureEventType.java new file mode 100644 index 00000000..6edf3096 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/ProductFeatureEventType.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.event; + +public enum ProductFeatureEventType { + + InfoEvent, AlertEvent, ErrorEvent, LogEvent +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/UpdateProductEventRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/UpdateProductEventRequest.java new file mode 100644 index 00000000..eca28f47 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/event/UpdateProductEventRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.event; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateProductEventRequest extends GenericAccountRequest { + + private ProductFeatureEventType type; + private Map dataSchema; + private String displayName; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/CreateFeaturePropertyRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/CreateFeaturePropertyRequest.java new file mode 100644 index 00000000..795cc152 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/CreateFeaturePropertyRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.property; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateFeaturePropertyRequest extends GenericAccountRequest { + + @NonNull + private String name; + @NonNull + private Map dataSchema; + @NonNull + private String displayName; + private String description; + private boolean writable; + private String unitType; + private String unit; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/ListFeaturePropertyResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/ListFeaturePropertyResponse.java new file mode 100644 index 00000000..bfdac53d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/ListFeaturePropertyResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.property; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListFeaturePropertyResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/ProductFeaturePropertyInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/ProductFeaturePropertyInfo.java new file mode 100644 index 00000000..4aacf54f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/ProductFeaturePropertyInfo.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.property; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductFeaturePropertyInfo extends AbstractBceResponse { + private String instanceId; + private String productKey; + private String name; + private Map dataSchema; + private String displayName; + private String description; + private boolean writable; + private String unitType; + private String unit; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/UpdateProductPropertyRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/UpdateProductPropertyRequest.java new file mode 100644 index 00000000..e34fbba9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/property/UpdateProductPropertyRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.property; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateProductPropertyRequest extends GenericAccountRequest { + + private Map dataSchema; + private String displayName; + private String description; + private Boolean writable; + private String unitType; + private String unit; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Command.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Command.java new file mode 100644 index 00000000..e4a64232 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Command.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.thing; + +import com.baidubce.services.iotdmp.model.Constant; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Command { + + @JsonProperty("@id") + private String id = null; + @JsonProperty(value = "@type") + private String type = Constant.COMMAND; + private Object input = null; + private Object output = null; + private String displayName = null; + private String description = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Event.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Event.java new file mode 100644 index 00000000..b990745b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Event.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.thing; + +import com.baidubce.services.iotdmp.model.Constant; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Event { + @JsonProperty("@id") + private String id; + @JsonProperty("@type") + private String type = Constant.EVENT; + Object data; + private String displayName = null; + private String description = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Property.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Property.java new file mode 100644 index 00000000..87d23229 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Property.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.thing; + +import com.baidubce.services.iotdmp.model.Constant; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Property { + + private static final Set DEFAULT_TYPE = new HashSet() { + { + add(Constant.PROPERTY); + } + }; + + private Map dataSchema; + @JsonProperty("@id") + private String id = null; + @JsonProperty("@type") + private Set type = DEFAULT_TYPE; + private boolean writable = false; + private String unit = null; + private String displayName = null; + private String description = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Thing.java b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Thing.java new file mode 100644 index 00000000..d9bf6a23 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/feature/thing/Thing.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.feature.thing; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.Constant; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; +import java.util.Set; + +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Thing extends GenericAccountRequest { + + @JsonProperty("@id") + private String id; + @JsonProperty("@context") + private Set context = Constant.CONTEXT; + private Map properties = null; + private Map commands = null; + private Map events = null; + private String displayName = null; + private String description = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/ProductModelType.java b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/ProductModelType.java new file mode 100644 index 00000000..1ed73d5a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/ProductModelType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.repositories; + +public enum ProductModelType { + PLATFORM, CUSTOM; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/SaveCustomProductModelRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/SaveCustomProductModelRequest.java new file mode 100644 index 00000000..8dbd484d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/SaveCustomProductModelRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.repositories; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class SaveCustomProductModelRequest extends GenericAccountRequest { + private String modelProductKey; + private String modelProductName; + private String description; + private String brand; + private String model; + private String manufacturer; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/SaveCustomProductModelResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/SaveCustomProductModelResponse.java new file mode 100644 index 00000000..5b5910c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/SaveCustomProductModelResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.repositories; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class SaveCustomProductModelResponse extends AbstractBceResponse { + private String modelId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/SimpleProductModelInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/SimpleProductModelInfo.java new file mode 100644 index 00000000..8d5086a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/SimpleProductModelInfo.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.repositories; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.baidubce.services.iotdmp.model.device.tag.CommonTagInfo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class SimpleProductModelInfo extends AbstractBceResponse { + private String modelId; + private String productKey; + private String productName; + private String description; + private String productCategory; + private DeviceType deviceType; + private List accessType = null; + private List tags; + private String brand = ""; + private String model = ""; + private String manufacturer = ""; + private String updateTime; + private String createTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/UpdateCustomProductModelRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/UpdateCustomProductModelRequest.java new file mode 100644 index 00000000..6c078ac8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/repositories/UpdateCustomProductModelRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.repositories; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class UpdateCustomProductModelRequest extends GenericAccountRequest { + private String modelProductKey; + private String modelProductName; + private String description; + private String brand; + private String model; + private String manufacturer; + private String instanceId; + private String productKey; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/product/version/ListVersionResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/product/version/ListVersionResponse.java new file mode 100644 index 00000000..73d5b7b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/product/version/ListVersionResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.product.version; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListVersionResponse extends AbstractBceResponse { + private String instanceId; + private String productKey; + private List result; + + @Data + public static class SimpleVersionInfo { + String version; + String state; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ConsumerGroupQueueInfoResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ConsumerGroupQueueInfoResponse.java new file mode 100644 index 00000000..1d5d72db --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ConsumerGroupQueueInfoResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ConsumerGroupQueueInfoResponse extends AbstractBceResponse { + + private String host; + private Integer port; + private String vhost; + private String queue; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ConsumerGroupType.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ConsumerGroupType.java new file mode 100644 index 00000000..c9ba744c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ConsumerGroupType.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +public enum ConsumerGroupType { + DEFAULT, CUSTOM +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ConsumerGroupUserInfoResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ConsumerGroupUserInfoResponse.java new file mode 100644 index 00000000..f5f13fe9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ConsumerGroupUserInfoResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ConsumerGroupUserInfoResponse extends AbstractBceResponse { + + private String username; + private String password; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/CreateConsumerGroupRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/service/CreateConsumerGroupRequest.java new file mode 100644 index 00000000..5d4e706b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/CreateConsumerGroupRequest.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class CreateConsumerGroupRequest extends GenericAccountRequest { + + private String name; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/CreateConsumerGroupResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/CreateConsumerGroupResponse.java new file mode 100644 index 00000000..df51ce9e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/CreateConsumerGroupResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateConsumerGroupResponse extends AbstractBceResponse { + private String consumerGroupId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/GetBridgeListResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/GetBridgeListResponse.java new file mode 100644 index 00000000..a0fa6a7b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/GetBridgeListResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.anno.BceListResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@BceListResponse +public class GetBridgeListResponse extends AbstractBceResponse { + private List result; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ListConsumerGroupRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ListConsumerGroupRequest.java new file mode 100644 index 00000000..a911bcbe --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ListConsumerGroupRequest.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.GenericAccountRequest; +import lombok.Data; + +@Data +public class ListConsumerGroupRequest extends GenericAccountRequest { + private String order; + private String orderBy; + private int pageNo; + private int pageSize; +} + diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ListConsumerGroupResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ListConsumerGroupResponse.java new file mode 100644 index 00000000..b566623a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ListConsumerGroupResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListConsumerGroupResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ListInstanceServiceStateResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ListInstanceServiceStateResponse.java new file mode 100644 index 00000000..e80eae74 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ListInstanceServiceStateResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.extension.ability.ServiceType; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListInstanceServiceStateResponse extends AbstractBceResponse { + private List result; + + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class ServiceStateItem { + private ServiceType serviceType; + private boolean state; + private String failureCause; + private String failureStartTime; + private String failureRecoverTime; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ListSubResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ListSubResponse.java new file mode 100644 index 00000000..01b262d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ListSubResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListSubResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/MessageTypeResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/MessageTypeResponse.java new file mode 100644 index 00000000..3a018226 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/MessageTypeResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class MessageTypeResponse extends AbstractBceResponse { + + private List messageTypes; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ProductSubscriptionResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ProductSubscriptionResponse.java new file mode 100644 index 00000000..42dcf690 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ProductSubscriptionResponse.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductSubscriptionResponse extends AbstractBceResponse { + + private String instanceId; + private String productKey; + private DeviceType deviceType; + private List messageTypes; + private List consumerGroups; + private Boolean state; + + @Data + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class MsgType { + private String enumName; + private String description; + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class ConsumerGroup { + private String consumerGroupName; + private String consumerGroupId; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/RabbitmqQueueInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/service/RabbitmqQueueInfo.java new file mode 100644 index 00000000..c0bb2aa9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/RabbitmqQueueInfo.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import lombok.Data; + +@Data +public class RabbitmqQueueInfo { + + private String instanceId; + private String consumerGroupName; + private String consumerGroupId; + private ConsumerGroupType consumerGroupType; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/RabbitmqSubMap.java b/src/main/java/com/baidubce/services/iotdmp/model/service/RabbitmqSubMap.java new file mode 100644 index 00000000..e226e6c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/RabbitmqSubMap.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.services.iotdmp.model.device.DeviceType; +import com.baidubce.services.iotdmp.model.service.rulechain.MessageType; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +@Data +public class RabbitmqSubMap { + + private String instanceId; + private String productKey; + private String productName; + private DeviceType deviceType; + + @JsonIgnore + private List messageTypeList; + @JsonIgnore + private List consumerGroupIdList; + private boolean state; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ResetConsumerGroupUserPwdResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ResetConsumerGroupUserPwdResponse.java new file mode 100644 index 00000000..66e6adf9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ResetConsumerGroupUserPwdResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResetConsumerGroupUserPwdResponse extends AbstractBceResponse { + + private String password; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/SendMessageRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/service/SendMessageRequest.java new file mode 100644 index 00000000..0534e487 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/SendMessageRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; + +@Data +@AllArgsConstructor +@Builder +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SendMessageRequest extends GenericAccountRequest { + + @NonNull + private String topic; + @NonNull + private String message; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ServiceInfoResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ServiceInfoResponse.java new file mode 100644 index 00000000..ae85fbfc --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ServiceInfoResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ServiceInfoResponse extends AbstractBceResponse { + private String sourceId; + private String username; + private String password; + private String vhost; + private String host; + private Integer port; + private String sinkQueue; + private String sourceQueue; + private String exchange; + private String topic; + private String routeKey; + private Boolean state; + private String protocol; + private String clientId; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/ServiceResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/ServiceResponse.java new file mode 100644 index 00000000..6d79df3b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/ServiceResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ServiceResponse extends AbstractBceResponse { + private String name; + private String serviceId; + private String serviceType; + private String description; + private String protocol; + private Boolean state; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/UpdateProductSubscriptionRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/service/UpdateProductSubscriptionRequest.java new file mode 100644 index 00000000..15231fcd --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/UpdateProductSubscriptionRequest.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotdmp.model.service.rulechain.BlinkTopicInfo; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateProductSubscriptionRequest extends GenericAccountRequest { + + private List messageTypes = new ArrayList(); + private List consumerGroupIds = new ArrayList(); + private Set topics = Collections.emptySet(); +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/AvailableMessageTypeResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/AvailableMessageTypeResponse.java new file mode 100644 index 00000000..ced9168b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/AvailableMessageTypeResponse.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class AvailableMessageTypeResponse extends AbstractBceResponse { + private List mainTypeList; + + @Data + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class MainType { + private String typeName; + private BlinkDataType dataType; + + private List subTypeList = new ArrayList(); + } + + @Data + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + @JsonInclude(JsonInclude.Include.NON_NULL) + public static class SubType { + private String description; + private String topic; + private String subDataType; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/BlinkDataPermission.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/BlinkDataPermission.java new file mode 100644 index 00000000..d0a91882 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/BlinkDataPermission.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * created by menglinhao on 2021/5/6 + */ +@Getter +@AllArgsConstructor +public enum BlinkDataPermission { + // 上行对应MQTT pub 下同 + UPWARD(MqttTopicPermission.PUB), + DOWNWARD(MqttTopicPermission.SUB), + /** + * 系统产生的数据, + * 1、设备只能订阅该类型消息 + * 2、该类型消息在数据处理上等同于设备上报数据 + */ + SYSTEM(MqttTopicPermission.SUB); + + private MqttTopicPermission mqttTopicPermission; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/BlinkDataType.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/BlinkDataType.java new file mode 100644 index 00000000..41f64868 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/BlinkDataType.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum BlinkDataType { + DEVICE_MESSAGE("物模型消息上下行"), + DEVICE_STATE_CHANGE("设备生命周期变更"); + + private String typeName; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/BlinkTopicInfo.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/BlinkTopicInfo.java new file mode 100644 index 00000000..5df25a6d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/BlinkTopicInfo.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum BlinkTopicInfo { + PROPERTY_POST, + PROPERTY_BATCH, + PROPERTY_UPLOAD, + PROPERTY_DESIRED, + PROPERTY_GET, + PROPERTY_SNAPSHOT, + PROPERTY_DELTA, + PROPERTY_DOCUMENT, + PROPERTY_DELETE, + EVENT_POST, + EVENT_BATCH, + EVENT_UPLOAD, + PROPERTY_INVOKE, + COMMAND_INVOKE, + SERVICE_INVOKE, + CLOUD_TO_DEVICE, + DEVICE_TO_CLOUD, + LIFECYCLE_UPDATE, + LIFECYCLE_POST, + RAW_D2C, + RAW_C2D +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/MessageType.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/MessageType.java new file mode 100644 index 00000000..78fd3f99 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/MessageType.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +import lombok.Getter; + +public enum MessageType { + DEVICE_MESSAGE("设备上报消息"), + DEVICE_STATE_CHANGE("设备生命周期变更"); + + @Getter + private String description; + + MessageType(String description) { + this.description = description; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/MqttTopicPermission.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/MqttTopicPermission.java new file mode 100644 index 00000000..2b3a683c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/MqttTopicPermission.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +public enum MqttTopicPermission { + PUB, SUB, ALL +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicDecodeRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicDecodeRequest.java new file mode 100644 index 00000000..399b5b1e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicDecodeRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +@Data +@AllArgsConstructor +@Builder +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TopicDecodeRequest extends GenericAccountRequest { + + private String topic; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicDecodeResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicDecodeResponse.java new file mode 100644 index 00000000..5b5b5a7e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicDecodeResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class TopicDecodeResponse extends AbstractBceResponse { + + private String productKey; + private String deviceName; + private BlinkDataType dataType; + private BlinkTopicInfo subDataType; + private String typeName; + private String description; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicEncodeRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicEncodeRequest.java new file mode 100644 index 00000000..67ba0ce6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicEncodeRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; + + +@Data +@AllArgsConstructor +@Builder +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TopicEncodeRequest extends GenericAccountRequest { + + @NonNull + private String productKey; + @NonNull + private String deviceName; + @NonNull + private BlinkDataType dataType; + @NonNull + private BlinkTopicInfo subDataType; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicEncodeResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicEncodeResponse.java new file mode 100644 index 00000000..92951b6c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/service/rulechain/TopicEncodeResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.service.rulechain; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class TopicEncodeResponse extends AbstractBceResponse { + + private String topic; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iotdmp/model/shadow/DeviceShadowProperty.java b/src/main/java/com/baidubce/services/iotdmp/model/shadow/DeviceShadowProperty.java new file mode 100644 index 00000000..1f2f7009 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/shadow/DeviceShadowProperty.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.shadow; + +import com.fasterxml.jackson.annotation.JsonAlias; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DeviceShadowProperty { + + private String name = ""; + private String displayName = ""; + private Object value = null; + private String unitType = ""; + private String unit = ""; + @JsonAlias("timeStamp") + private String timestamp = null; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/shadow/DeviceShadowResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/shadow/DeviceShadowResponse.java new file mode 100644 index 00000000..68a4b238 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/shadow/DeviceShadowResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.shadow; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceShadowResponse extends AbstractBceResponse { + + private String deviceShadow; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/shadow/DeviceShadowSnapshot.java b/src/main/java/com/baidubce/services/iotdmp/model/shadow/DeviceShadowSnapshot.java new file mode 100644 index 00000000..3b0456af --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/shadow/DeviceShadowSnapshot.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.shadow; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@NoArgsConstructor +public class DeviceShadowSnapshot { + private String productKey; + private String deviceName; + private String bindName; + private ShadowSnapshot shadowSnapshot; + + @Data + public class ShadowSnapshot { + private Map reported; + private Map desired; + private Map lastUpdated; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/shadow/ListDeviceShadowRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/shadow/ListDeviceShadowRequest.java new file mode 100644 index 00000000..b9fb6a6c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/shadow/ListDeviceShadowRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.shadow; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListDeviceShadowRequest extends GenericAccountRequest { + + private String propertyName; + @Builder.Default + private int pageNo = 1; + @Builder.Default + private int pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/shadow/ListDeviceShadowSnapshotResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/shadow/ListDeviceShadowSnapshotResponse.java new file mode 100644 index 00000000..72dd5601 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/shadow/ListDeviceShadowSnapshotResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.shadow; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListDeviceShadowSnapshotResponse extends AbstractBceResponse { + private List result; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/shadow/ShadowStatesRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/shadow/ShadowStatesRequest.java new file mode 100644 index 00000000..f89ab999 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/shadow/ShadowStatesRequest.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.shadow; + +import com.baidubce.model.GenericAccountRequest; +import lombok.Data; + +@Data +public class ShadowStatesRequest extends GenericAccountRequest { + + boolean shadowState = false; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/shadow/UpdateDesiredRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/shadow/UpdateDesiredRequest.java new file mode 100644 index 00000000..6364dcd7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/shadow/UpdateDesiredRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.shadow; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@RequiredArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateDesiredRequest extends GenericAccountRequest { + @NonNull + private Map desired; + private String bindName; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/Cycle.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/Cycle.java new file mode 100644 index 00000000..106518da --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/Cycle.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +public enum Cycle { + HOUR, DAY, WEEK, MONTH +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/DeviceMessageStatsResult.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/DeviceMessageStatsResult.java new file mode 100644 index 00000000..92f6d40f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/DeviceMessageStatsResult.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceMessageStatsResult { + private int upwardMessageCount; + private int downwardMessageCount; + private int errorMessageCount; + private String timeNode; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/DeviceStatesStatsResult.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/DeviceStatesStatsResult.java new file mode 100644 index 00000000..f3f842d7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/DeviceStatesStatsResult.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceStatesStatsResult extends AbstractBceResponse { + private long onlineCount; + private long offlineCount; + private long inactiveCount; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/DeviceTotalStatsResult.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/DeviceTotalStatsResult.java new file mode 100644 index 00000000..725a2bc8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/DeviceTotalStatsResult.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceTotalStatsResult { + private int deviceCount; + private int activeCount; + private int inactiveCount; + private String timeNode; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/LivelyDeviceStatsResult.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/LivelyDeviceStatsResult.java new file mode 100644 index 00000000..f0ed9347 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/LivelyDeviceStatsResult.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class LivelyDeviceStatsResult { + private int newlyIncreaseCount; + private int newlyActiveCount; + private int livelyCount; + private String timeNode; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/ProductTotalStatsResult.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/ProductTotalStatsResult.java new file mode 100644 index 00000000..61397a5a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/ProductTotalStatsResult.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductTotalStatsResult { + private int productCount; + private String timeNode; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsDeviceMessageResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsDeviceMessageResponse.java new file mode 100644 index 00000000..8c8b6982 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsDeviceMessageResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class StatsDeviceMessageResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private Long beginTime; + private Long endTime; + private Cycle cycle; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsDeviceTotalResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsDeviceTotalResponse.java new file mode 100644 index 00000000..78ad5c84 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsDeviceTotalResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class StatsDeviceTotalResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private Long beginTime; + private Long endTime; + private Cycle cycle; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsLivelyDeviceResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsLivelyDeviceResponse.java new file mode 100644 index 00000000..b9695980 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsLivelyDeviceResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class StatsLivelyDeviceResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private Long beginTime; + private Long endTime; + private Cycle cycle; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsProductTotalResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsProductTotalResponse.java new file mode 100644 index 00000000..b808af06 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/statistics/StatsProductTotalResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.statistics; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class StatsProductTotalResponse extends AbstractBceResponse { + private int totalCount; + private List result; + private Long beginTime; + private Long endTime; + private Cycle cycle; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbInitRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbInitRequest.java new file mode 100644 index 00000000..0ad79d33 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbInitRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.tsdb; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TsdbInitRequest extends GenericAccountRequest { + private Boolean tsdbProperty; + private Boolean tsdbEvent; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbMappingRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbMappingRequest.java new file mode 100644 index 00000000..9066685b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbMappingRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.tsdb; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TsdbMappingRequest extends GenericAccountRequest { + private List events = new ArrayList(); + private List properties = new ArrayList(); +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbMappingResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbMappingResponse.java new file mode 100644 index 00000000..740d726a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbMappingResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.tsdb; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class TsdbMappingResponse extends AbstractBceResponse { + private Map propertyFieldMapping; + private Map> eventFieldMapping; + private String propertyMetricMapping; + private String eventMetricMapping; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbQueryRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbQueryRequest.java new file mode 100644 index 00000000..f1148d30 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbQueryRequest.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.tsdb; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TsdbQueryRequest extends GenericAccountRequest { + private Long start; + private Long end; + private List fields = new ArrayList(); + private String nextMarker; + @NotNull + private String deviceName; + private Integer pageSize = 20; + + public TsdbQueryRequest(String deviceName) { + this.deviceName = deviceName; + } +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbQueryResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbQueryResponse.java new file mode 100644 index 00000000..227d7e16 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/tsdb/TsdbQueryResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.tsdb; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iotdmp.model.anno.BceJsonStringResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +@BceJsonStringResponse +public class TsdbQueryResponse extends AbstractBceResponse { + private String nextMarker; + private List> result; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/userlog/DisplayLog.java b/src/main/java/com/baidubce/services/iotdmp/model/userlog/DisplayLog.java new file mode 100644 index 00000000..41a74088 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/userlog/DisplayLog.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.userlog; + +import lombok.Data; + +@Data +public class DisplayLog { + + private String timestamp; + private UserLog message; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/userlog/ListUserLogRequest.java b/src/main/java/com/baidubce/services/iotdmp/model/userlog/ListUserLogRequest.java new file mode 100644 index 00000000..a731f349 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/userlog/ListUserLogRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.userlog; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Data +@Builder +@RequiredArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListUserLogRequest extends GenericAccountRequest { + @NonNull + private String logType; + private String logSubType; + private String flag; + private String productKey; + private String deviceName; + private String keyword; + private Long beginTime; + private Long endTime; + @Builder.Default + private Integer pageNo = 1; + @Builder.Default + private Integer pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/userlog/ListUserLogResponse.java b/src/main/java/com/baidubce/services/iotdmp/model/userlog/ListUserLogResponse.java new file mode 100644 index 00000000..3e4f9e2e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/userlog/ListUserLogResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.userlog; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListUserLogResponse extends AbstractBceResponse { + + private String logType; + private String logSubType; + private String flag; + private String productKey; + private String deviceName; + private String keyword; + private Long beginTime; + private Long endTime; + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotdmp/model/userlog/UserLog.java b/src/main/java/com/baidubce/services/iotdmp/model/userlog/UserLog.java new file mode 100644 index 00000000..63c65dcf --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdmp/model/userlog/UserLog.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotdmp.model.userlog; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.io.Serializable; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class UserLog implements Serializable { + private String instanceId; + private String productKey; + private String deviceName; + private String logType; + private String logSubType; + private String flag; + private String blinkTopic; + private Object content; + private long timestamp; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iothisk/AbstractIotHiskBceClient.java b/src/main/java/com/baidubce/services/iothisk/AbstractIotHiskBceClient.java new file mode 100644 index 00000000..7d41fb9a --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/AbstractIotHiskBceClient.java @@ -0,0 +1,123 @@ +/* + * Copyright 2018 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +/** + * Abstract client for accessing the iot hisk service. + */ +public abstract class AbstractIotHiskBceClient extends AbstractBceClient { + + private static final String[] HEADERS_TO_SIGN = { Headers.HOST }; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + + /** + * Responsible for handling httpResponses from all hisk service calls. + */ + protected static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceIotHiskJsonResponseHandler() }; + + public AbstractIotHiskBceClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers) { + super(config, responseHandlers); + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param signOptions The options for signature. + * @param path The options for URI prefix. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object populated with endpoint, resource path and specific parameters to send. + */ + protected InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + SignOptions signOptions, List path, String... pathVariables) { + if (path == null) { + path = new ArrayList(); + } + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + if (signOptions == null) { + signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.PUT || httpMethod == HttpMethodName.POST) { + fillInHeaderAndBody(bceRequest, request); + } + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * + * @param bceRequest The original request, as created by the user. + * @param request A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + protected static void fillInHeaderAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + /** + * Return a json byte array representation of the object. + * + * @param request request object to be parsed as json byte array. + * @return a byte array representation of the object + */ + protected static byte[] toJson(AbstractBceRequest request) { + String jsonStr = JsonUtils.toJsonString(request); + + try { + return jsonStr.getBytes(AbstractBceClient.DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/BceIotHiskJsonResponseHandler.java b/src/main/java/com/baidubce/services/iothisk/BceIotHiskJsonResponseHandler.java new file mode 100644 index 00000000..95a8d603 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/BceIotHiskJsonResponseHandler.java @@ -0,0 +1,28 @@ +package com.baidubce.services.iothisk; + +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iothisk.model.IotPkiManageDataResponse; + +/** + * HTTP body json response handler for Baidu BCE iot hisk responses. + */ +public class BceIotHiskJsonResponseHandler extends BceJsonResponseHandler { + + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + if (response instanceof IotPkiManageDataResponse) { + InputStream content = httpResponse.getContent(); + ((IotPkiManageDataResponse) response).setData(IOUtils.toByteArray(content)); + content.close(); + return true; + } + + return super.handle(httpResponse, response); + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/IotHiskClient.java b/src/main/java/com/baidubce/services/iothisk/IotHiskClient.java new file mode 100644 index 00000000..2406aec5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/IotHiskClient.java @@ -0,0 +1,122 @@ +/* + * Copyright 2018 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.http.HttpMethodName; +import com.baidubce.internal.InternalRequest; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.iothisk.model.ActiveRequest; +import com.baidubce.services.iothisk.model.ActiveResponse; +import com.baidubce.services.iothisk.model.AuthRequest; +import com.baidubce.services.iothisk.model.CipherRequest; +import com.baidubce.services.iothisk.model.CipherResponse; + +/** + * Provides the client for accessing the iot hisk service. + */ +public class IotHiskClient extends AbstractIotHiskBceClient { + + private static final String ENDPOINT = "hisk.baidubce.com"; + private static final String VERSION = "v1"; + + private static final String TSM = "tsm"; + private static final String DEVICE = "device"; + private static final String DECRYPT = "decrypt"; + private static final String ENCRYPT = "encrypt"; + private static final String ACTIVE = "active"; + private static final String AUTH = "auth"; + + private static final String NULL_DEVICE_ID = "device id should not be null."; + private static final String NULL_REQUEST = "request should not be null."; + + /** + * Constructs a new hisk client using the client configuration to access hisk. + * + * @param config The bcc client configuration options controlling how this client + * connects to bcc (e.g. proxy settings, retry counts, etc). + */ + public IotHiskClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, HANDLERS); + } + + /** + * Encrypt message for specified device. + * + * @param deviceId specified device id + * @param request plain text request message(base64 encoding), which required be encrypted + * @return encrypted cipher message(base64 encoding) + */ + public CipherResponse encrypt(String deviceId, CipherRequest request) { + checkNotNull(request, NULL_REQUEST); + checkNotNull(deviceId, NULL_DEVICE_ID); + InternalRequest internalRequest = createTsmDeviceRequest(request, HttpMethodName.POST, deviceId, ENCRYPT); + return this.invokeHttpClient(internalRequest, CipherResponse.class); + } + + /** + * Decrypt message for specified device. + * + * @param deviceId specified device id + * @param request cipher request message(base64 encoding), which required be decrypted + * @return decrypted plain text message(base64 encoding) + */ + public CipherResponse decrypt(String deviceId, CipherRequest request) { + checkNotNull(request, NULL_REQUEST); + checkNotNull(deviceId, NULL_DEVICE_ID); + InternalRequest internalRequest = createTsmDeviceRequest(request, HttpMethodName.POST, deviceId, DECRYPT); + return this.invokeHttpClient(internalRequest, CipherResponse.class); + } + + /** + * Active specified device + * + * @param deviceId specified device id + * @param request activation message + * @return successful activation result with device id, otherwise an exception will be thrown + */ + public ActiveResponse active(String deviceId, ActiveRequest request) { + checkNotNull(request, NULL_REQUEST); + checkNotNull(deviceId, NULL_DEVICE_ID); + InternalRequest internalRequest = createTsmDeviceRequest(request, HttpMethodName.POST, deviceId, ACTIVE); + return this.invokeHttpClient(internalRequest, ActiveResponse.class); + } + + /** + * Authenticate for specified device. + * + * @param deviceId specified device id + * @param request device authentication message + */ + public void auth(String deviceId, AuthRequest request) { + checkNotNull(request, NULL_REQUEST); + checkNotNull(deviceId, NULL_DEVICE_ID); + InternalRequest internalRequest = createTsmDeviceRequest(request, HttpMethodName.POST, deviceId, AUTH); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + private InternalRequest createTsmDeviceRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String deviceId, String action) { + List path = new ArrayList(); + path.addAll(Arrays.asList(VERSION, TSM, DEVICE)); + return createRequest(bceRequest, httpMethod, null, path, deviceId, action); + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/IotPkiManageClient.java b/src/main/java/com/baidubce/services/iothisk/IotPkiManageClient.java new file mode 100644 index 00000000..4de414a3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/IotPkiManageClient.java @@ -0,0 +1,549 @@ +/* + * Copyright 2018 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.http.HttpMethodName; +import com.baidubce.internal.InternalRequest; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.iothisk.model.BatchCreateClientCertRequest; +import com.baidubce.services.iothisk.model.BatchCreateClientCertResponse; +import com.baidubce.services.iothisk.model.CreateCertGroupRequest; +import com.baidubce.services.iothisk.model.CreateCertGroupResponse; +import com.baidubce.services.iothisk.model.CreateRootCACertRequest; +import com.baidubce.services.iothisk.model.CreateRootCACertResponse; +import com.baidubce.services.iothisk.model.CreateSubCertRequest; +import com.baidubce.services.iothisk.model.CreateSubCertResponse; +import com.baidubce.services.iothisk.model.DefaultIotPkiManageRequest; +import com.baidubce.services.iothisk.model.DefaultIotPkiManageResponse; +import com.baidubce.services.iothisk.model.DownloadCrlResponse; +import com.baidubce.services.iothisk.model.GetBatchCreateStatusResponse; +import com.baidubce.services.iothisk.model.GetCertGroupResponse; +import com.baidubce.services.iothisk.model.GetCertStatusRequest; +import com.baidubce.services.iothisk.model.GetCertStatusResponse; +import com.baidubce.services.iothisk.model.GetOcspResponse; +import com.baidubce.services.iothisk.model.GetRootCACertResponse; +import com.baidubce.services.iothisk.model.GetSubCertResponse; +import com.baidubce.services.iothisk.model.IotPkiManageResponse; +import com.baidubce.services.iothisk.model.QueryClientCertResponse; +import com.baidubce.services.iothisk.model.QueryServerCertResponse; +import com.baidubce.services.iothisk.model.RenewSubCertRequest; +import com.baidubce.services.iothisk.model.RenewSubCertResponse; + +/** + * Provides the client for accessing the iot pki service. + */ +public class IotPkiManageClient extends AbstractIotHiskBceClient { + + /** + * Constructs a new pki client using the client configuration to access hisk pki. + * + * @param config The bcc client configuration options controlling how this client + * connects to bcc (e.g. proxy settings, retry counts, etc). + */ + public IotPkiManageClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(IotPkiManageConstants.ENDPOINT) : config, HANDLERS); + } + + /** + * Create a root cert. + * + * @param request The request object containing all options for creating a root cert. + * @param clientToken A random string to make request idempotent. + * @return The created root cert ID. + */ + public CreateRootCACertResponse createRootCACert(CreateRootCACertRequest request, String clientToken) { + checkNotNull(request, IotPkiManageConstants.NULL_REQUEST); + checkClientToken(clientToken); + InternalRequest internalRequest = + createIotPkiManageRequest(request, HttpMethodName.POST, IotPkiManageConstants.ROOT_CERT); + internalRequest.addParameter(IotPkiManageConstants.CLIENT_TOKEN, clientToken); + return this.invokeHttpClient(internalRequest, CreateRootCACertResponse.class); + } + + /** + * Delete a root cert. + * + * @param certId The cert ID of the root cert which will be deleted. + */ + public void deleteRootCACert(String certId) { + checkCertId(certId); + InternalRequest internalRequest = createIotPkiManageRequest( + new DefaultIotPkiManageRequest(), HttpMethodName.DELETE, IotPkiManageConstants.ROOT_CERT, certId); + this.invokeHttpClient(internalRequest, DefaultIotPkiManageResponse.class); + } + + /** + * Get a root cert. + * + * @param certId The cert ID of the root cert which will be got. + * @return Crl download url and root cert download url. + */ + public GetRootCACertResponse getRootCACert(String certId) { + checkCertId(certId); + InternalRequest internalRequest = createIotPkiManageRequest( + new DefaultIotPkiManageRequest(), HttpMethodName.GET, IotPkiManageConstants.ROOT_CERT, certId); + return this.invokeHttpClient(internalRequest, GetRootCACertResponse.class); + } + + /** + * Create a cert group. + * + * @param request The request object containing all options for creating a cert group. + * @param clientToken A random string to make request idempotent. + * @return The created cert group ID. + */ + public CreateCertGroupResponse createCertGroup(CreateCertGroupRequest request, String clientToken) { + checkNotNull(request, IotPkiManageConstants.NULL_REQUEST); + checkClientToken(clientToken); + InternalRequest internalRequest = createIotPkiManageRequest( + request, HttpMethodName.POST, IotPkiManageConstants.CERT_GROUP); + internalRequest.addParameter(IotPkiManageConstants.CLIENT_TOKEN, clientToken); + return this.invokeHttpClient(internalRequest, CreateCertGroupResponse.class); + } + + /** + * Delete a cert group. + * + * @param groupId The group ID of the cert group which will be deleted. + */ + public void deleteCertGroup(String groupId) { + checkCertId(groupId); + InternalRequest internalRequest = createIotPkiManageRequest( + new DefaultIotPkiManageRequest(), HttpMethodName.DELETE, IotPkiManageConstants.CERT_GROUP, groupId); + this.invokeHttpClient(internalRequest, DefaultIotPkiManageResponse.class); + } + + /** + * Get a cert group. + * + * @param groupId The group ID of the cert group which will be got. + * @return Root cert ID and sub cert' ID of this group. + */ + public GetCertGroupResponse getCertGroup(String groupId) { + checkCertId(groupId); + InternalRequest internalRequest = createIotPkiManageRequest( + new DefaultIotPkiManageRequest(), HttpMethodName.GET, IotPkiManageConstants.CERT_GROUP, groupId); + return this.invokeHttpClient(internalRequest, GetCertGroupResponse.class); + } + + /** + * Create a server cert. + * + * @param request The request object containing all options for creating a server cert. + * @param clientToken A random string to make request idempotent. + * @return The created server cert ID. + */ + public CreateSubCertResponse createServerCert(CreateSubCertRequest request, String clientToken) { + return createSubCert(request, clientToken, CertType.SERVER); + } + + /** + * Delete a server cert. + * + * @param serverCertId The server cert ID of the cert which will be deleted. + */ + public void deleteServerCert(String serverCertId) { + deleteSubCert(serverCertId, CertType.SERVER); + } + + /** + * Get a server cert. + * + * @param serverCertId The server cert ID of the cert which will be got. + * @return Root cert ID, cert group ID and cert download url of this cert. + */ + public GetSubCertResponse getServerCert(String serverCertId) { + return getSubCert(serverCertId, CertType.SERVER); + } + + /** + * Query server certs. + * + * @param rootCACertId The root cert ID of server certs which will be queried. + * @param groupId The cert group ID of server certs which will be queried. + * @return Server cert list of the query. + */ + public QueryServerCertResponse queryServerCerts(String rootCACertId, String groupId) { + return querySubCerts(rootCACertId, groupId, CertType.SERVER, QueryServerCertResponse.class); + } + + /** + * Renew a server cert. + * + * @param request The request object containing all options for renewing a server cert. + * @param serverCertId The server cert ID of the cert which will be renewed. + * @param clientToken A random string to make request idempotent. + * @return Download url of the new server cert. + */ + public RenewSubCertResponse renewServerCert(RenewSubCertRequest request, String serverCertId, String clientToken) { + return renewSubCert(request, serverCertId, clientToken, CertType.SERVER); + } + + /** + * Create a client cert. + * + * @param request The request object containing all options for creating a client cert. + * @param clientToken A random string to make request idempotent. + * @return The created client cert ID. + */ + public CreateSubCertResponse createClientCert(CreateSubCertRequest request, String clientToken) { + return createSubCert(request, clientToken, CertType.CLIENT); + } + + /** + * Delete a client cert. + * + * @param clientCertId The client cert ID of the cert which will be deleted. + */ + public void deleteClientCert(String clientCertId) { + deleteSubCert(clientCertId, CertType.CLIENT); + } + + /** + * Get a client cert. + * + * @param clientCertId The client cert ID of the cert which will be got. + * @return Root cert ID, cert group ID and cert download url of this cert. + */ + public GetSubCertResponse getClientCert(String clientCertId) { + return getSubCert(clientCertId, CertType.CLIENT); + } + + /** + * Query client certs. + * + * @param rootCACertId The root cert ID of client certs which will be queried. + * @param groupId The cert group ID of client certs which will be queried. + * @return Client cert list of the query. + */ + public QueryClientCertResponse queryClientCerts(String rootCACertId, String groupId) { + return querySubCerts(rootCACertId, groupId, CertType.CLIENT, QueryClientCertResponse.class); + } + + /** + * Renew a client cert. + * + * @param request The request object containing all options for renewing a client cert. + * @param clientCertId The client cert ID of the cert which will be renewed. + * @param clientToken A random string to make request idempotent. + * @return Download url of the new client cert. + */ + public RenewSubCertResponse renewClientCert(RenewSubCertRequest request, String clientCertId, String clientToken) { + return renewSubCert(request, clientCertId, clientToken, CertType.CLIENT); + } + + /** + * Batch create client certs. + * + * @param request The request object containing all options for creating client certs. + * @param clientToken A random string to make request idempotent. + * @return The create batch ID. + */ + public BatchCreateClientCertResponse batchCreateClientCert( + BatchCreateClientCertRequest request, String clientToken) { + checkNotNull(request, IotPkiManageConstants.NULL_REQUEST); + checkClientToken(clientToken); + + InternalRequest internalRequest = createIotPkiManageRequest( + request, HttpMethodName.POST, IotPkiManageConstants.CLIENT_CERT, IotPkiManageConstants.JOB); + internalRequest.addParameter(IotPkiManageConstants.CLIENT_TOKEN, clientToken); + return this.invokeHttpClient(internalRequest, BatchCreateClientCertResponse.class); + } + + /** + * Get batch create status + * + * @param jobId The create batch ID. + * @return Status of the create batch. + */ + public GetBatchCreateStatusResponse getBatchCreateStatus(String jobId) { + checkJobId(jobId); + + InternalRequest internalRequest = createIotPkiManageRequest(new DefaultIotPkiManageRequest(), + HttpMethodName.GET, IotPkiManageConstants.CLIENT_CERT, IotPkiManageConstants.JOB, jobId); + return this.invokeHttpClient(internalRequest, GetBatchCreateStatusResponse.class); + } + + /** + * Download client cert. + * + * @param clientCertId The client cert ID which will be downloaded. + * @return Cert content string, encoded by base64, using PEM format. + */ + public String downloadClientCert(String clientCertId) { + return downloadCert(clientCertId, CertType.CLIENT); + } + + /** + * Download server cert. + * + * @param serverCertId The server cert ID which will be downloaded. + * @return Cert content string, encoded by base64, using PEM format. + */ + public String downloadServerCert(String serverCertId) { + return downloadCert(serverCertId, CertType.SERVER); + } + + /** + * Download root cert. + * + * @param rootCertId The root cert ID which will be downloaded. + * @return Cert content string, encoded by base64, using PEM format. + */ + public String downloadRootCert(String rootCertId) { + return downloadCert(rootCertId, CertType.ROOT); + } + + /** + * Download batch create certs. + * + * @param jobId The create batch ID which will be downloaded. + * @return null if create failed or processing, + * or a map which maps device ID and cert content. + */ + public Map downloadBatchCreateCerts(String jobId) { + checkJobId(jobId); + + GetBatchCreateStatusResponse response = getBatchCreateStatus(jobId); + if (response.isSucceed() || response.isPartialSucceed()) { + try { + return unzipCert(IOUtils.toByteArray(new URL(response.getDownloadUrl()))); + } catch (IOException e) { + throw new RuntimeException(IotPkiManageConstants.DOWNLOAD_CERT_FAILED); + } + } else { + return null; + } + } + + /** + * Get cert status. + * + * @param request The request object containing all options for creating client certs. + * @return Cert status of request. + */ + public GetCertStatusResponse getCertStatus(GetCertStatusRequest request) { + checkNotNull(request, IotPkiManageConstants.NULL_REQUEST); + + InternalRequest internalRequest = createIotPkiManageRequest( + request, HttpMethodName.PUT, IotPkiManageConstants.CERT, IotPkiManageConstants.GET_STATUS); + return this.invokeHttpClient(internalRequest, GetCertStatusResponse.class); + } + + /** + * Download root cert. + * + * @param issuerDN The root cert DN, can be found in root cert. + * @return Crl content string, encoded by base64, using PEM format. + */ + public DownloadCrlResponse downloadCrl(String issuerDN) { + checkIssuerDN(issuerDN); + + InternalRequest internalRequest = createIotPkiManageRequest( + new DefaultIotPkiManageRequest(), HttpMethodName.GET, IotPkiManageConstants.CRL); + internalRequest.setParameters(IotPkiManageConstants.CRL_PARAMS); + internalRequest.addParameter(IotPkiManageConstants.ISSUER, issuerDN); + return this.invokeHttpClient(internalRequest, DownloadCrlResponse.class); + } + + /** + * Standard ocsp query use HTTP GET method. + * + * @param ocspRequest Standard ocsp request. + * @return Standard ocsp response. + */ + public GetOcspResponse getOcspResponse(byte[] ocspRequest) { + checkNotNull(ocspRequest, IotPkiManageConstants.NULL_REQUEST); + + String encodedOcspRequest = encodeOcspReqeust(ocspRequest); + InternalRequest internalRequest = createIotPkiManageRequest( + new DefaultIotPkiManageRequest(), HttpMethodName.GET, IotPkiManageConstants.OCSP, encodedOcspRequest); + return this.invokeHttpClient(internalRequest, GetOcspResponse.class); + } + + private InternalRequest createIotPkiManageRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String subPath, String... pathVariables) { + List path = new ArrayList(); + path.addAll(Arrays.asList(IotPkiManageConstants.VERSION, IotPkiManageConstants.PKI, subPath)); + return createRequest(bceRequest, httpMethod, null, path, pathVariables); + } + + private void checkClientToken(String clientToken) { + checkArgument(StringUtils.isNotEmpty(clientToken), IotPkiManageConstants.EMPTY_CLIENT_TOKEN); + checkArgument(StringUtils.length(clientToken) <= IotPkiManageConstants.MAX_CLIENT_TOKEN_LENGTH, + IotPkiManageConstants.TOO_LONG_CLIENT_TOKEN); + } + + private void checkCertId(String certId) { + checkArgument(StringUtils.length(certId) == IotPkiManageConstants.CERT_ID_LENGTH, + IotPkiManageConstants.INVALID_CERT_ID); + } + + private void checkIssuerDN(String issuerDN) { + checkArgument(StringUtils.isNotEmpty(issuerDN), IotPkiManageConstants.INVALID_ISSUER_DN); + } + + private void checkJobId(String jobId) { + checkArgument(StringUtils.length(jobId) == IotPkiManageConstants.JOB_ID_LENGTH, + IotPkiManageConstants.INVALID_JOB_ID); + } + + private void checkAddressNotEmpty(List address) { + checkArgument(address != null && !address.isEmpty(), IotPkiManageConstants.EMPTY_ADDRESS); + } + + private CreateSubCertResponse createSubCert(CreateSubCertRequest request, String clientToken, CertType certType) { + checkNotNull(request, IotPkiManageConstants.NULL_REQUEST); + checkClientToken(clientToken); + if (certType == CertType.SERVER) { + checkAddressNotEmpty(request.getAddress()); + } + + InternalRequest internalRequest = + createIotPkiManageRequest(request, HttpMethodName.POST, getSubCertPathByCertType(certType)); + internalRequest.addParameter(IotPkiManageConstants.CLIENT_TOKEN, clientToken); + return this.invokeHttpClient(internalRequest, CreateSubCertResponse.class); + } + + private void deleteSubCert(String subCertId, CertType certType) { + checkCertId(subCertId); + InternalRequest internalRequest = createIotPkiManageRequest(new DefaultIotPkiManageRequest(), + HttpMethodName.DELETE, getSubCertPathByCertType(certType), subCertId); + this.invokeHttpClient(internalRequest, DefaultIotPkiManageResponse.class); + } + + private GetSubCertResponse getSubCert(String subCertId, CertType certType) { + checkCertId(subCertId); + InternalRequest internalRequest = createIotPkiManageRequest(new DefaultIotPkiManageRequest(), + HttpMethodName.GET, getSubCertPathByCertType(certType), subCertId); + return this.invokeHttpClient(internalRequest, GetSubCertResponse.class); + } + + private T querySubCerts( + String rootCACertId, String groupId, CertType certType, Class responseClass) { + checkArgument(rootCACertId != null || groupId != null); + + InternalRequest internalRequest = createIotPkiManageRequest(new DefaultIotPkiManageRequest(), + HttpMethodName.GET, getSubCertPathByCertType(certType), IotPkiManageConstants.QUERY); + if (rootCACertId != null) { + internalRequest.addParameter(IotPkiManageConstants.ROOT_CERT_ID, rootCACertId); + } + if (groupId != null) { + internalRequest.addParameter(IotPkiManageConstants.GROUP_ID, groupId); + } + return this.invokeHttpClient(internalRequest, responseClass); + } + + private RenewSubCertResponse renewSubCert( + RenewSubCertRequest request, String subCertId, String clientToken, CertType certType) { + checkNotNull(request, IotPkiManageConstants.NULL_REQUEST); + checkCertId(subCertId); + checkClientToken(clientToken); + if (certType == CertType.SERVER) { + checkAddressNotEmpty(request.getNewAddress()); + } + + InternalRequest internalRequest = createIotPkiManageRequest( + request, HttpMethodName.PUT, getSubCertPathByCertType(certType), + subCertId, IotPkiManageConstants.RENEW); + internalRequest.addParameter(IotPkiManageConstants.CLIENT_TOKEN, clientToken); + return this.invokeHttpClient(internalRequest, RenewSubCertResponse.class); + } + + private String downloadCert(String certId, CertType certType) { + checkCertId(certId); + + switch (certType) { + case SERVER: + case CLIENT: + return downloadCert(getSubCert(certId, certType).getDownloadUrl()); + case ROOT: + return downloadCert(getRootCACert(certId).getDownloadUrl()); + default: + throw new RuntimeException(IotPkiManageConstants.INVALID_CERT_TYPE); + } + } + + private String downloadCert(String downloadUrl) { + try { + return IOUtils.toString(new URL(downloadUrl)); + } catch (IOException e) { + throw new RuntimeException(IotPkiManageConstants.DOWNLOAD_CERT_FAILED); + } + } + + private String getSubCertPathByCertType(CertType certType) { + return certType == CertType.SERVER ? IotPkiManageConstants.SEVER_CERT : IotPkiManageConstants.CLIENT_CERT; + } + + private Map unzipCert(byte[] certZip) throws IOException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(certZip); + ZipInputStream zipInputStream = new ZipInputStream(byteArrayInputStream); + Map deviceIdCertMap = new HashMap(); + ZipEntry entry = zipInputStream.getNextEntry(); + byte[] buffer = new byte[1024]; + while (entry != null) { + String name = entry.getName(); + + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + int len; + while ((len = zipInputStream.read(buffer)) > 0) { + byteArrayOutputStream.write(buffer, 0, len); + } + zipInputStream.closeEntry(); + deviceIdCertMap.put(name, new String(byteArrayOutputStream.toByteArray())); + byteArrayOutputStream.close(); + + entry = zipInputStream.getNextEntry(); + } + zipInputStream.close(); + return deviceIdCertMap; + } + + private String encodeOcspReqeust(byte[] ocspRequest) { + try { + return URLEncoder.encode(Base64.encodeBase64String(ocspRequest), "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(IotPkiManageConstants.INVALID_OCSP_REQUEST); + } + } + + private enum CertType { + SERVER, + CLIENT, + ROOT + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/IotPkiManageConstants.java b/src/main/java/com/baidubce/services/iothisk/IotPkiManageConstants.java new file mode 100644 index 00000000..a4b89956 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/IotPkiManageConstants.java @@ -0,0 +1,54 @@ +package com.baidubce.services.iothisk; + +import java.util.Map; + +import com.google.common.collect.ImmutableMap; + +/** + * IotPkiManage Constants used by the IotPkiManage Java client. + */ +public class IotPkiManageConstants { + + public static final String ENDPOINT = "pkiiov.baidubce.com"; + public static final String VERSION = "v1"; + + public static final String PKI = "pki"; + public static final String OCSP = "ocsp"; + public static final String CERT = "cert"; + public static final String CRL = "crl"; + public static final String CERT_GROUP = "certgroup"; + public static final String ROOT_CERT = "rootcert"; + public static final String CLIENT_CERT = "clientcert"; + public static final String SEVER_CERT = "servercert"; + public static final String JOB = "job"; + public static final String RENEW = "renew"; + public static final String CLIENT_TOKEN = "clientToken"; + public static final String QUERY = "query"; + public static final String ROOT_CERT_ID = "rootCertId"; + public static final String GROUP_ID = "groupId"; + public static final String GET_STATUS = "getstatus"; + + public static final String CMD = "cmd"; + public static final String FORMAT = "format"; + public static final String PEM = "PEM"; + public static final String ISSUER = "issuer"; + public static final Map CRL_PARAMS = ImmutableMap.of(CMD, CRL, FORMAT, PEM); + public static final int MAX_CLIENT_TOKEN_LENGTH = 64; + public static final int CERT_ID_LENGTH = 32; + public static final int JOB_ID_LENGTH = 32; + + public static final String NULL_REQUEST = "Request should not be null."; + public static final String EMPTY_CLIENT_TOKEN = "Client token can not be empty"; + public static final String DOWNLOAD_CERT_FAILED = "Download cert failed"; + public static final String DOWNLOAD_CRL_FAILED = "Download crl failed"; + public static final String INVALID_CERT_TYPE = "Invalid cert type"; + public static final String INVALID_CERT_ID = "Invalid cert ID"; + public static final String INVALID_JOB_ID = "Invalid job ID"; + public static final String INVALID_OCSP_REQUEST = "Invalid ocsp request"; + public static final String INVALID_ISSUER_DN = "Invalid issuer DN"; + public static final String TOO_LONG_CLIENT_TOKEN = + String.format("Client token can not be longer than %d", MAX_CLIENT_TOKEN_LENGTH); + public static final String EMPTY_ADDRESS = "Address should not be empty when created server cert."; + + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/IotHiskDevice.java b/src/main/java/com/baidubce/services/iothisk/device/IotHiskDevice.java new file mode 100644 index 00000000..14f5f809 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/IotHiskDevice.java @@ -0,0 +1,217 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device; + +import static com.baidubce.services.iothisk.device.utils.CounterUtils.validCounter; +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_DEVICE_COMPANY; +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_DEVICE_TYPE; +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_SERIAL_NUMBER; +import static com.baidubce.services.iothisk.device.utils.Message.NULL_CONTRACT; +import static com.baidubce.services.iothisk.device.utils.Message.NULL_DEVICE_SDK_TYPE; +import static com.baidubce.services.iothisk.device.utils.Message.NULL_SERIAL_NUMBER; +import static com.baidubce.services.iothisk.device.utils.Message.UNKNOWN_DEVICE_SDK_TYPE; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME; + +import java.security.Security; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.StringUtils; +import org.bouncycastle.jce.provider.BouncyCastleProvider; + +import com.baidubce.services.iothisk.device.model.ActiveMessage; +import com.baidubce.services.iothisk.device.model.CipherMessage; +import com.baidubce.services.iothisk.device.model.Device; +import com.baidubce.services.iothisk.device.model.DeviceKey; +import com.baidubce.services.iothisk.device.model.PlainMessage; +import com.baidubce.services.iothisk.device.seplatform.SecureElement; +import com.baidubce.services.iothisk.device.seplatform.SecureElementFactory; + +/** + * Provides the hisk device with the local secure element ability. + * Currently, only baidu mbed_akey secure element is supported. + */ +public class IotHiskDevice { + + /** + * Provided device basic info + */ + private final Device device; + + /** + * Device key info, generated by provided device + */ + private final DeviceKey deviceKey; + + /** + * Current device client counter, initially default value is 0. + */ + private long currentCounter = 0L; + + private static final int SERIAL_NUMBER_MAX_LENGTH = 32; + private static final int DEVICE_COMPANY_MAX_LENGTH = 32; + private static final int DEVICE_TYPE_MAX_LENGTH = 48; + private static final int DEVICE_COMPANY_AND_TYPE_MIN_LENTH = 3; + private static final Pattern namePattern = Pattern.compile("[\u4e00-\u9fa5\\w-]+"); + + /** + * Loads bouncy castle security provider + */ + static { + if (Security.getProvider(PROVIDER_NAME) == null) { + Security.addProvider(new BouncyCastleProvider()); + } + } + + /** + * Constructs a new hisk device client using the provided hisk device info. + * + * @param device specified hisk basic device info, corresponding to the contract created in hisk cloud service. + */ + public IotHiskDevice(Device device) { + checkNotNull(device, NULL_CONTRACT); + validDevice(device); + + this.device = device; + this.deviceKey = generateDeviceKey(device); + } + + /** + * Get unique device id in ascii encoding + * + * @return unique device id + */ + public String getDeviceId() { + return deviceKey.getDeviceId(); + } + + /** + * Get device active data generated by device secure element + * + * @return successful device active data in byte array, otherwise an exception will be thrown + */ + public byte[] getActiveData() { + ActiveMessage activeMessage = new ActiveMessage(); + activeMessage.setDeviceId(deviceKey.getDeviceId()); + activeMessage.setSdkType(device.getDeviceSdkType()); + activeMessage.setSeId(deviceKey.getSeId()); + + return encrypt(activeMessage.getBytes()); + } + + /** + * Encrypt message with device secure element. + * + * @param message plain message in byte array + * @return successful cipher message in byte array, otherwise an exception will be thrown + */ + public byte[] encrypt(byte[] message) { + PlainMessage plainMessage = new PlainMessage(getCurrentCounter(), message); + return deviceKey.getSe().encryptThenSign(plainMessage).getBytes(); + } + + /** + * Decrypt cipher with device secure element. + * + * @param cipherMessage cipher message in byte array + * @return successful plain message in byte array, otherwise an exception will be thrown + */ + public byte[] decrypt(byte[] cipherMessage) { + CipherMessage cipher = deviceKey.getSe().parseCipherMessage(cipherMessage); + PlainMessage plainMessage = deviceKey.getSe().verifyThenDecrypt(cipher); + validCounter(device.getDeviceSdkType(), plainMessage.getCounter(), getCurrentCounter()); + setCurrentCounter(plainMessage.getCounter()); + + return plainMessage.getMessage(); + } + + /** + * Get device client current counter. Counter will be used to check message to resist replay attack. + * + * @return current device counter. + */ + public long getCurrentCounter() { + switch (device.getDeviceSdkType()) { + case NONE_RTC: + return currentCounter; + case RTC: + return System.currentTimeMillis() / 1000; + case NONE_COUNTER: + // no counter check, anything is ok + return System.currentTimeMillis() / 1000; + default: + throw new IllegalArgumentException(UNKNOWN_DEVICE_SDK_TYPE); + } + } + + /** + * Set device counter by user specified counter. + * + * @param counter specified counter + */ + public void setCurrentCounter(long counter) { + switch (device.getDeviceSdkType()) { + case NONE_RTC: + this.currentCounter = counter; + break; + case NONE_COUNTER: + case RTC: + // no thing to do + break; + default: + throw new IllegalArgumentException(UNKNOWN_DEVICE_SDK_TYPE); + } + } + + /** + * Generate local hisk device key, which will be used during message encryption and decryption. + * Device key contains security element information as well. + * + * @param device specified hisk basic device info, corresponding to the contract created in hisk cloud service. + * @return local hisk device key + */ + private DeviceKey generateDeviceKey(Device device) { + DeviceKey deviceKey = new DeviceKey(); + deviceKey.setSeId(device.getSerialNumber()); + deviceKey.setSeType(device.getType()); + + SecureElement se = SecureElementFactory.createSe(device, deviceKey); + deviceKey.setDeviceId(se.generateId()); + deviceKey.setSe(se); + return deviceKey; + } + + private static void validDevice(Device device) { + checkNotNull(device.getSerialNumber(), NULL_SERIAL_NUMBER); + checkNotNull(device.getDeviceSdkType(), NULL_DEVICE_SDK_TYPE); + + validateName(device.getDeviceCompany(), DEVICE_COMPANY_MAX_LENGTH, INVALID_DEVICE_COMPANY); + validateName(device.getDeviceType(), DEVICE_TYPE_MAX_LENGTH, INVALID_DEVICE_TYPE); + validateSerialNumber(device.getSerialNumber()); + } + + private static void validateName(String name, int maxLength, String errorMessage) { + if (StringUtils.isBlank(name) || StringUtils.length(name) < DEVICE_COMPANY_AND_TYPE_MIN_LENTH + || StringUtils.length(name) > maxLength + || !namePattern.matcher(name).matches()) { + throw new IllegalArgumentException(errorMessage); + } + } + + private static void validateSerialNumber(String serialNumber) { + if (StringUtils.isBlank(serialNumber) || StringUtils.length(serialNumber) > SERIAL_NUMBER_MAX_LENGTH) { + throw new IllegalArgumentException(INVALID_SERIAL_NUMBER); + } + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/crypto/AesEncrypt.java b/src/main/java/com/baidubce/services/iothisk/device/crypto/AesEncrypt.java new file mode 100644 index 00000000..30f2a135 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/crypto/AesEncrypt.java @@ -0,0 +1,154 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.crypto; + +import static com.baidubce.services.iothisk.device.utils.Message.FAIL_AES_DECRYPT; +import static com.baidubce.services.iothisk.device.utils.Message.FAIL_AES_ENCRYPT; +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_AES_CIPHER_NAME; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.commons.lang3.StringUtils; + +/** + * Provides AES crypto functions + */ +public class AesEncrypt { + + // default Cipher: AES/ECB/PKCS5Padding + private static final String AES_ALGORITHM = "AES"; + private static final String AES_CTR_NO_PADDING_CIPHER = "AES/CTR/NoPadding"; + + private static final Set AES_MODES_WITH_IV = new HashSet( + Arrays.asList("CBC", "CFB", "CTR", "OFB", "PCBC")); + private static final Set AES_MODES_WITHOUT_IV = new HashSet( + Arrays.asList("ECB")); + + /** + * Load secret key with provided key data and specified algorithm + * + * @param key specified key data in btye array + * @param algorithm specified algorithm + * @return secret key + */ + public static SecretKey loadKey(byte[] key, String algorithm) { + return new SecretKeySpec(key, algorithm); + } + + /** + * Encrypt message with specified secret key and cipher name. + * + * @param data specified message data in byte array + * @param key specified secret key + * @param cipherName specified cipher name + * @return cipher message in byte array + */ + public static byte[] encrypt(byte[] data, SecretKey key, String cipherName) { + return encrypt(data, key, null, cipherName); + } + + /** + * Encrypt message with specified secret key, cipher name, init vector and cipher name. + * + * @param data specified message data in byte array + * @param key specified secret key + * @param iv specified init vector + * @param cipherName specified cipher name + * @return cipher message in byte array + */ + public static byte[] encrypt(byte[] data, SecretKey key, IvParameterSpec iv, String cipherName) { + try { + Cipher cipher = Cipher.getInstance(cipherName); + String mode = getModeName(cipherName); + + if (AES_MODES_WITHOUT_IV.contains(mode)) { + cipher.init(Cipher.ENCRYPT_MODE, key); + } else { + iv = iv == null ? new IvParameterSpec(new byte[cipher.getBlockSize()]) : iv; + cipher.init(Cipher.ENCRYPT_MODE, key, iv); + } + return cipher.doFinal(data); + } catch (Exception e) { + throw new IllegalStateException(FAIL_AES_ENCRYPT, e); + } + } + + /** + * Decrypt message with specified secret key, cipher name, init vector and cipher name. + * + * @param data specified cipher message data in byte array + * @param key specified secret key + * @param iv specified init vector + * @param cipherName specified cipher name + * @return plain message in byte array + */ + public static byte[] decrypt(byte[] data, SecretKey key, IvParameterSpec iv, String cipherName) { + try { + Cipher cipher = Cipher.getInstance(cipherName); + String mode = getModeName(cipherName); + + if (AES_MODES_WITHOUT_IV.contains(mode)) { + cipher.init(Cipher.DECRYPT_MODE, key); + } else { + iv = iv == null ? new IvParameterSpec(new byte[cipher.getBlockSize()]) : iv; + cipher.init(Cipher.DECRYPT_MODE, key, iv); + } + return cipher.doFinal(data); + } catch (Exception e) { + throw new IllegalStateException(FAIL_AES_DECRYPT, e); + } + } + + /** + * Encrypt message with AES/CTR/NoPadding cipher + * + * @param data specified message data in byte array + * @param key specified key in byte array + * @param iv specified init vector + * @return cipher message in byte array + */ + public static byte[] encryptByCTRNoPadding(byte[] data, byte[] key, byte[] iv) { + return encrypt(data, loadKey(key, AES_ALGORITHM), new IvParameterSpec(iv), AES_CTR_NO_PADDING_CIPHER); + } + + /** + * Decrypt message with AES/CTR/NoPadding cipher + * + * @param data specified message data in byte array + * @param key specified key in byte array + * @param iv specified init vector + * @return plain message in byte array + */ + public static byte[] decryptByCTRNoPadding(byte[] data, byte[] key, byte[] iv) { + return decrypt(data, loadKey(key, AES_ALGORITHM), new IvParameterSpec(iv), AES_CTR_NO_PADDING_CIPHER); + } + + private static String getModeName(String cipherName) { + if (StringUtils.contains(cipherName, "/")) { + String mode = StringUtils.split(cipherName, "/")[1]; + if (AES_MODES_WITHOUT_IV.contains(mode) || AES_MODES_WITH_IV.contains(mode)) { + return mode; + } + } + + throw new IllegalArgumentException(INVALID_AES_CIPHER_NAME); + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/crypto/HashCrypto.java b/src/main/java/com/baidubce/services/iothisk/device/crypto/HashCrypto.java new file mode 100644 index 00000000..64efce9e --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/crypto/HashCrypto.java @@ -0,0 +1,62 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.crypto; + +import javax.crypto.Mac; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; + +import org.bouncycastle.crypto.digests.SHA256Digest; +import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator; +import org.bouncycastle.crypto.params.KeyParameter; + +/** + * Provides hash crypto operations + */ +public class HashCrypto { + + private static final String HMAC_SHA256 = "HmacSHA256"; + private static final int PBKDF2_DERIVED_KEY_LENGTH_IN_BIT = 16 * 8; + + /** + * HMAC_SHA56 hash function + * + * @param data specified message data in byte array + * @param keyBytes specified key in byte array + * @return hash data in byte array + * @throws Exception NoSuchAlgorithmException, InvalidKeyException, IllegalStateException, IllegalArgumentException + */ + public static byte[] hmacSha256(byte[] data, byte[] keyBytes) throws Exception { + Mac mac = Mac.getInstance(HMAC_SHA256); + SecretKey key = new SecretKeySpec(keyBytes, HMAC_SHA256); + mac.init(key); + mac.reset(); + mac.update(data, 0, data.length); + return mac.doFinal(); + } + + /** + * PBKDF2(Password-Based Key Derivation Function) with hmac sha256 key derivation function. + * + * @param password specified password in byte array + * @param salt specified salt in byte array + * @param iteration iteration counter + * @return derived key in byte array + */ + public static byte[] pbkdf2WithHmacSha256(byte[] password, byte[] salt, int iteration) { + PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator(new SHA256Digest()); + generator.init(password, salt, iteration); + return ((KeyParameter) generator.generateDerivedParameters(PBKDF2_DERIVED_KEY_LENGTH_IN_BIT)).getKey(); + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/model/ActiveMessage.java b/src/main/java/com/baidubce/services/iothisk/device/model/ActiveMessage.java new file mode 100644 index 00000000..31e51d2f --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/model/ActiveMessage.java @@ -0,0 +1,101 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.model; + +import static com.baidubce.services.iothisk.device.utils.ByteUtils.toBytesFromInt; +import static com.google.common.primitives.Bytes.concat; + +/** + * Represent the device active message + */ +public class ActiveMessage { + + /** + * Device unique id, which is hex string + */ + private String deviceId; + + /** + * Device secure element id + */ + private String seId; + + /** + * Device sdk type + */ + private DeviceSdkType sdkType; + + /** + * Get device id + * + * @return device id in hex string format + */ + public String getDeviceId() { + return deviceId; + } + + /** + * Set device id + * + * @param deviceId device id + */ + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + /** + * Get secure element id + * + * @return secure element id + */ + public String getSeId() { + return seId; + } + + /** + * Set secure element id + * + * @param seId secure element id + */ + public void setSeId(String seId) { + this.seId = seId; + } + + /** + * Get device sdk type + * + * @return device sdk type + */ + public DeviceSdkType getSdkType() { + return sdkType; + } + + /** + * Set device sdk type + * + * @param sdkType device sdk type + */ + public void setSdkType(DeviceSdkType sdkType) { + this.sdkType = sdkType; + } + + /** + * Get active message in byte array + * + * @return active message in byte array + */ + public byte[] getBytes() { + return concat(deviceId.getBytes(), seId.getBytes(), toBytesFromInt(sdkType.getStatusCode())); + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/model/CipherMessage.java b/src/main/java/com/baidubce/services/iothisk/device/model/CipherMessage.java new file mode 100644 index 00000000..9b920d63 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/model/CipherMessage.java @@ -0,0 +1,94 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.model; + +import static com.google.common.primitives.Bytes.concat; + +/** + * Represent the cipher message + */ +public class CipherMessage { + + /** + * encrypted message + */ + private byte[] encryption; + + /** + * message signature + */ + private byte[] signature; + + /** + * Constructs cipher message + * + * @param encryption encrypted cipher message + * @param signature message signature + */ + public CipherMessage(byte[] encryption, byte[] signature) { + this.encryption = encryption; + this.signature = signature; + } + + /** + * Constructs cipher message + */ + public CipherMessage() { + } + + /** + * Get cipher message, including encrypted message and message signature + * + * @return cipher message in byte array + */ + public byte[] getBytes() { + return concat(encryption, signature); + } + + /** + * Set encrypted message + * + * @param encryption encrypted message + */ + public void setEncryption(byte[] encryption) { + this.encryption = encryption; + } + + /** + * Get encrypted message + * + * @return encrypted message + */ + public byte[] getEncryption() { + return encryption; + } + + /** + * Set message signature + * + * @param signature message signature + */ + public void setSignature(byte[] signature) { + this.signature = signature; + } + + /** + * Get message signature + * + * @return message signature + */ + public byte[] getSignature() { + return signature; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/model/Device.java b/src/main/java/com/baidubce/services/iothisk/device/model/Device.java new file mode 100644 index 00000000..26ba6d40 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/model/Device.java @@ -0,0 +1,162 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.model; + +/** + * Represent the device basic information, which is part of the contact made with hisk cloud service. + */ +public class Device { + + /** + * device secure element type, + * corresponding to the se type name contained in the created contract with hisk cloud service. + */ + private SeType type; + + /** + * device company name, 3-32 ascii characters, contained by English, Chinese, digital, underline('_') and hypen('-') + * corresponding to the device company name contained in the created contract with hisk cloud service. + */ + private String deviceCompany; + + /** + * device type name, 3-48 ascii characters, contained by English, Chinese, digital, underline('_') and hypen('-') + * corresponding to the device type name contained in the created contract with hisk cloud service. + */ + private String deviceType; + + /** + * device master key, hex string in upper case + * corresponding to the master key contained in the created contract with hisk cloud service. + */ + private String masterKey; + + /** + * device sdk type + */ + private DeviceSdkType deviceSdkType; + + /** + * device serial number + */ + private String serialNumber; + + /** + * Get device secure element type + * + * @return device secure element type + */ + public SeType getType() { + return type; + } + + /** + * Set device secure element type + * + * @param type + */ + public void setType(SeType type) { + this.type = type; + } + + /** + * Get device company name + * + * @return device company name + */ + public String getDeviceCompany() { + return deviceCompany; + } + + /** + * Set device company name + * + * @param deviceCompany device company name + */ + public void setDeviceCompany(String deviceCompany) { + this.deviceCompany = deviceCompany; + } + + /** + * Get device type name + * + * @return device type name + */ + public String getDeviceType() { + return deviceType; + } + + /** + * Set device type name + * + * @param deviceType device type name + */ + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + /** + * Get device master key + * + * @return device master key + */ + public String getMasterKey() { + return masterKey; + } + + /** + * Set device master key + * + * @param masterKey device master key + */ + public void setMasterKey(String masterKey) { + this.masterKey = masterKey; + } + + /** + * Get device sdk type + * + * @return device sdk type + */ + public DeviceSdkType getDeviceSdkType() { + return deviceSdkType; + } + + /** + * Set device sdk type + * + * @param deviceSdkType device sdk type + */ + public void setDeviceSdkType(DeviceSdkType deviceSdkType) { + this.deviceSdkType = deviceSdkType; + } + + /** + * Get device serial number + * + * @return device serial number + */ + public String getSerialNumber() { + return serialNumber; + } + + /** + * Set device serial number + * + * @param serialNumber serial number + */ + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/model/DeviceKey.java b/src/main/java/com/baidubce/services/iothisk/device/model/DeviceKey.java new file mode 100644 index 00000000..fdbaacc2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/model/DeviceKey.java @@ -0,0 +1,114 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.model; + +import com.baidubce.services.iothisk.device.seplatform.SecureElement; + +/** + * Represents device key, corresponding to specified device + */ +public class DeviceKey { + + /** + * device unique id + */ + private String deviceId; + + /** + * device secure element id + */ + private String seId; + + /** + * device secure element type + */ + private SeType seType; + + /** + * device secure element crypto object + */ + private SecureElement se; + + /** + * Get device unique id + * + * @return device unique id + */ + public String getDeviceId() { + return deviceId; + } + + /** + * Set device unique id + * + * @param deviceId device unique id + */ + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + /** + * Get secure element id + * + * @return secure element id + */ + public String getSeId() { + return seId; + } + + /** + * Set secure element id + * + * @param seId secure element id + */ + public void setSeId(String seId) { + this.seId = seId; + } + + /** + * Get secure element type + * + * @return secure element type + */ + public SeType getSeType() { + return seType; + } + + /** + * Set secure element type + * + * @param seType secure element type + */ + public void setSeType(SeType seType) { + this.seType = seType; + } + + /** + * Get device secure element crypto object + * + * @return device secure element crypto object + */ + public SecureElement getSe() { + return se; + } + + /** + * Set device secure element crypto object + * + * @param se device secure element crypto object + */ + public void setSe(SecureElement se) { + this.se = se; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/model/DeviceSdkType.java b/src/main/java/com/baidubce/services/iothisk/device/model/DeviceSdkType.java new file mode 100644 index 00000000..f55b507a --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/model/DeviceSdkType.java @@ -0,0 +1,85 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.model; + +import static com.baidubce.services.iothisk.device.utils.Message.UNKNOWN_DEVICE_SDK_TYPE; + +/** + * Represents device sdk type. + */ +public enum DeviceSdkType { + + /** + * NONE_RTC device sdk type + * Message replay attack will be check by none_rtc counter method, + * in which the counter may be an increased int value. + */ + NONE_RTC(0), + + /** + * RTC device sdk type + * Message replay attack will be check by rtc counter method, + * in which the counter may be an timestamp in seconds generated from rtc. + */ + RTC(1), + + /** + * NONE_COUNTER device sdk type + * It specifies that the device will not check message counter to against replay attack. + */ + NONE_COUNTER(2); + + /** + * status code of device sdk type + */ + private final int statusCode; + + /** + * Construct device sdk type with an status code + * + * @param statusCode status code + */ + DeviceSdkType(int statusCode) { + this.statusCode = statusCode; + } + + /** + * Get status code of related device sdk type + * + * @return status code + */ + public int getStatusCode() { + return statusCode; + } + + /** + * Parse string type status code to corresponding device sdk type + * + * @param value string type status code + * @return successful return an device sdk type, otherwise an exception will be thrown + */ + public static DeviceSdkType parse(String value) { + try { + int sdkTypeCode = Integer.valueOf(value); + for (DeviceSdkType type : DeviceSdkType.values()) { + if (type.statusCode == sdkTypeCode) { + return type; + } + } + throw new IllegalArgumentException(UNKNOWN_DEVICE_SDK_TYPE); + } catch (Exception e) { + throw new IllegalArgumentException(UNKNOWN_DEVICE_SDK_TYPE); + } + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/model/PlainMessage.java b/src/main/java/com/baidubce/services/iothisk/device/model/PlainMessage.java new file mode 100644 index 00000000..c42ed197 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/model/PlainMessage.java @@ -0,0 +1,96 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.model; + +import static com.baidubce.services.iothisk.device.utils.ByteUtils.getCounterBytes; +import static com.google.common.primitives.Bytes.concat; + +/** + * Represent plain message, including message counter and message content. + */ +public class PlainMessage { + + /** + * Message counter + */ + private long counter; + + /** + * Message content + */ + private byte[] message; + + /** + * Construct plain message + * + * @param counter message counter + * @param message message content + */ + public PlainMessage(long counter, byte[] message) { + this.counter = counter; + this.message = message; + } + + /** + * Construct plain message + */ + public PlainMessage() { + + } + + /** + * Get message whole content + * + * @return message whole content + */ + public byte[] getBytes() { + return concat(getCounterBytes(counter), message); + } + + /** + * Get message counter + * + * @return message counter + */ + public long getCounter() { + return counter; + } + + /** + * Set message counter + * + * @param counter message counter + */ + public void setCounter(long counter) { + this.counter = counter; + } + + /** + * Get message content + * + * @return message content + */ + public byte[] getMessage() { + return message; + } + + /** + * Set message content + * + * @param message message context + */ + public void setMessage(byte[] message) { + this.message = message; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/model/SeType.java b/src/main/java/com/baidubce/services/iothisk/device/model/SeType.java new file mode 100644 index 00000000..e0304609 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/model/SeType.java @@ -0,0 +1,48 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.model; + +/** + * Provides secure element type. + */ +public enum SeType { + + /** + * Mbed akey secure element type + */ + MBED_AKEY(1); + + /** + * status code of secure element type + */ + private final int statusCode; + + /** + * Construct secure element from specified status code + * + * @param statusCode + */ + SeType(int statusCode) { + this.statusCode = statusCode; + } + + /** + * Get status code of corresponding secure element type + * + * @return status code of secure element type + */ + public int getStatusCode() { + return statusCode; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/seplatform/MbedAkeySe.java b/src/main/java/com/baidubce/services/iothisk/device/seplatform/MbedAkeySe.java new file mode 100644 index 00000000..edbcbe4b --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/seplatform/MbedAkeySe.java @@ -0,0 +1,329 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.seplatform; + +import static com.baidubce.services.iothisk.device.crypto.AesEncrypt.decryptByCTRNoPadding; +import static com.baidubce.services.iothisk.device.crypto.AesEncrypt.encryptByCTRNoPadding; +import static com.baidubce.services.iothisk.device.utils.ByteUtils.toBytesFromHex; +import static com.baidubce.services.iothisk.device.utils.ByteUtils.toHexStringFromBytes; +import static com.baidubce.services.iothisk.device.utils.ByteUtils.toLongFromBytes; +import static com.baidubce.services.iothisk.device.crypto.HashCrypto.hmacSha256; +import static com.baidubce.services.iothisk.device.crypto.HashCrypto.pbkdf2WithHmacSha256; +import static com.baidubce.services.iothisk.device.utils.Message.DEVICE_SE_ID_CONFLICT; +import static com.baidubce.services.iothisk.device.utils.Message.FAIL_GENERATE_ID; +import static com.baidubce.services.iothisk.device.utils.Message.FAIL_SIGN; +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_CIPHER_DATA; +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_DEVICE_ID; +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_SIGNATURE; +import static java.lang.Math.min; + +import java.util.Arrays; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + +import com.baidubce.services.iothisk.device.model.ActiveMessage; +import com.baidubce.services.iothisk.device.model.CipherMessage; +import com.baidubce.services.iothisk.device.model.Device; +import com.baidubce.services.iothisk.device.model.DeviceKey; +import com.baidubce.services.iothisk.device.model.DeviceSdkType; +import com.baidubce.services.iothisk.device.model.PlainMessage; + +/** + * Mbed akey secure element. + * + * It provides mbed_akey type secure element. + */ +public class MbedAkeySe implements SecureElement { + + private final Device device; + private final DeviceKey deviceKey; + + private final byte[] seKey; + private final byte[] seIv; + + private static final int DEVICE_ID_BYTES_LENGTH = 64; + private static final int CIPHER_MESSAGE_SIGNATURE_BYTE_LENGTH = 32; + private static final int KEY_ITERATION_COUNT = 50; + private static final int IV_ITERATION_COUNT = 25; + private static final int TIMESTAMP_BYTE_LENGTH = 4; + private static final int SDK_TYPE_BYTES_LENGTH = 1; + + /** + * Construct a mbed akey secure element using the specified device and device key + * + * @param device specified device + * @param deviceKey specified device key + */ + public MbedAkeySe(Device device, DeviceKey deviceKey) { + this.device = device; + this.deviceKey = deviceKey; + + byte[] masterKeyBytes = toBytesFromHex(device.getMasterKey()); + this.seKey = pbkdf2WithHmacSha256(masterKeyBytes, deviceKey.getSeId().getBytes(), KEY_ITERATION_COUNT); + this.seIv = pbkdf2WithHmacSha256(masterKeyBytes, deviceKey.getSeId().getBytes(), IV_ITERATION_COUNT); + } + + /** + * Generate device unique id + * + * @return device unique id in ascii encoding + */ + @Override + public String generateId() { + String idBeforeHash = device.getDeviceCompany() + device.getDeviceType() + deviceKey.getSeId(); + byte[] masterKeyBytes = toBytesFromHex(device.getMasterKey()); + + try { + byte[] deviceIdBytes = hmacSha256(idBeforeHash.getBytes(), masterKeyBytes); + return toHexStringFromBytes(deviceIdBytes); + } catch (Exception e) { + throw new IllegalStateException(FAIL_GENERATE_ID); + } + } + + /** + * Encrypt and sign provided plain message + * + * @param plainMessage specified plain message + * @return cipher message, including encrypted message and its signature + */ + @Override + public CipherMessage encryptThenSign(PlainMessage plainMessage) { + return encryptThenSign(plainMessage, seKey); + } + + /** + * Encrypt plain message, and sign the signature with provided private key + * + * @param plainMessage specified plain message + * @param signPrivateKey specified signature private key + * @return cipher message, including encrypted message and its signature + */ + @Override + public CipherMessage encryptThenSign(PlainMessage plainMessage, byte[] signPrivateKey) { + byte[] encryption = encryptByCTRNoPadding(plainMessage.getBytes(), seKey, seIv); + + try { + byte[] signature = hmacSha256(encryption, signPrivateKey); + return new CipherMessage(encryption, signature); + } catch (Exception e) { + throw new IllegalStateException(FAIL_SIGN, e); + } + } + + /** + * Decrypt encrypted message + * + * @param encryption specified encrypted message in byte array + * @return plain message in byte array + */ + @Override + public byte[] decrypt(byte[] encryption) { + return decryptByCTRNoPadding(encryption, seKey, seIv); + } + + /** + * Verify message signature. + * If failed, an exception will be thrown. + * + * @param message specified message in byte array + * @param signature specified signature in byte array + */ + @Override + public void verifySignature(byte[] message, byte[] signature) { + byte[] calculatedSign = null; + + try { + calculatedSign = hmacSha256(message, seKey); + } catch (Exception e) { + throw new IllegalStateException(FAIL_SIGN, e); + } + + if (!Arrays.equals(calculatedSign, signature)) { + throw new IllegalArgumentException(INVALID_SIGNATURE); + } + } + + /** + * Verify message and decrypt cipher message. + * + * @param cipherMessage specified cipher message + * @return plain message decrypted from cipher message, if failed an exception will be thrown. + */ + @Override + public PlainMessage verifyThenDecrypt(CipherMessage cipherMessage) { + verifySignature(cipherMessage.getEncryption(), cipherMessage.getSignature()); + byte[] message = decrypt(cipherMessage.getEncryption()); + + return parsePlainMessage(message); + } + + /** + * Parse byte array cipher message. + * + * @param cipherMessage specified cipher message in byte array + * @return cipher message object + */ + @Override + public CipherMessage parseCipherMessage(byte[] cipherMessage) { + if (ArrayUtils.getLength(cipherMessage) <= TIMESTAMP_BYTE_LENGTH + CIPHER_MESSAGE_SIGNATURE_BYTE_LENGTH) { + throw new IllegalArgumentException(INVALID_CIPHER_DATA); + } + + CipherMessage cipher = new CipherMessage(); + cipher.setEncryption(Arrays.copyOfRange(cipherMessage, 0, + cipherMessage.length - CIPHER_MESSAGE_SIGNATURE_BYTE_LENGTH)); + cipher.setSignature(Arrays.copyOfRange(cipherMessage, + cipherMessage.length - CIPHER_MESSAGE_SIGNATURE_BYTE_LENGTH, cipherMessage.length)); + return cipher; + } + + /** + * Parse byte array plain message. + * + * @param plainMessage specified plain message + * @return plain message object + */ + @Override + public PlainMessage parsePlainMessage(byte[] plainMessage) { + PlainMessage message = new PlainMessage(); + message.setMessage(getMessage(plainMessage)); + message.setCounter(getTimestamp(plainMessage)); + + return message; + } + + /** + * Parse byte array active message + * + * @param activeMessage specified active message + * @return active message object + */ + @Override + public ActiveMessage parseActiveMessage(byte[] activeMessage) { + ActiveMessage message = new ActiveMessage(); + message.setDeviceId(getDeviceId(activeMessage)); + message.setSeId(getSeId(activeMessage)); + message.setSdkType(getSdkType(activeMessage)); + + return message; + } + + /** + * Valid active message with secure element. + * If failed, an exception will be thrown. + * + * @param activeMessage specified active message + */ + @Override + public void checkActiveMessage(ActiveMessage activeMessage) { + checkDeviceId(activeMessage.getDeviceId()); + checkSeId(activeMessage.getSeId()); + } + + private void checkDeviceId(String deviceId) { + if (!StringUtils.equals(generateId(), deviceId)) { + throw new IllegalArgumentException(INVALID_DEVICE_ID); + } + } + + private void checkSeId(String seId) { + if (StringUtils.isEmpty(deviceKey.getSeId()) || StringUtils.isEmpty(seId)) { + return; + } + + if (!StringUtils.equals(deviceKey.getSeId(), seId)) { + throw new IllegalArgumentException(DEVICE_SE_ID_CONFLICT); + } + } + + private String getSeId(byte[] activeMessage) { + return new String(getSeIdBytes(activeMessage)); + } + + /** + * Split active cipher data to device id/se id/sdk type + * Active text format: + * ----- x bytes ----| ---- n bytes -----| ---- 1 bytes ----| + * | device id | SE ID | sdk type | + * @param activeMessage the plain active message, the se id may be empty + * @return the SE ID in string + */ + private byte[] getSeIdBytes(byte[] activeMessage) { + if (activeMessage.length <= DEVICE_ID_BYTES_LENGTH + SDK_TYPE_BYTES_LENGTH) { + return ArrayUtils.EMPTY_BYTE_ARRAY; + } + return Arrays.copyOfRange(activeMessage, DEVICE_ID_BYTES_LENGTH, activeMessage.length - SDK_TYPE_BYTES_LENGTH); + } + + /** + * Split active cipher data to device id/se id/sdk type + * Active text format: + * ----- x bytes ----| ---- n bytes -----| ---- 1 bytes ----| + * | device id | SE ID | sdk type | + * @param activeMessage the plain active message, the se id may be empty + * @return the sdk type + */ + private DeviceSdkType getSdkType(byte[] activeMessage) { + if (activeMessage.length <= DEVICE_ID_BYTES_LENGTH) { + return DeviceSdkType.NONE_RTC; + } + + String sdkTypeStr = toHexStringFromBytes(Arrays.copyOfRange(activeMessage, + activeMessage.length - SDK_TYPE_BYTES_LENGTH, activeMessage.length)); + return DeviceSdkType.parse(sdkTypeStr); + } + + /** + * Split active cipher data to device id/se id/sdk type + * Active text format: + * ----- x bytes ----| ---- n bytes -----| ---- 1 bytes ----| + * | device id | SE ID | sdk type | + * @param activeMessage the plain active message + * @return the device id in string + */ + private String getDeviceId(byte[] activeMessage) { + int len = min(DEVICE_ID_BYTES_LENGTH, activeMessage.length); + return new String(activeMessage, 0, len); + } + + /** + * Split decrypted text to message and counter + * decrypted text format: + * ----- 4 bytes ----| ---- n bytes ----- + * | counter | message | + * + * @param plaintext the decrypted text + * @return the list contains the message and counter + */ + private static byte[] getMessage(byte[] plaintext) { + return Arrays.copyOfRange(plaintext, TIMESTAMP_BYTE_LENGTH, plaintext.length); + } + + /** + * Split decrypted text to message and counter + * decrypted text format: + * ----- 4 bytes ----| ---- n bytes ----- + * | counter | message | + * + * @param plaintext the decrypted text + * @return the counter in long + */ + private static long getTimestamp(byte[] plaintext) { + byte[] timestamp = Arrays.copyOfRange(plaintext, 0, TIMESTAMP_BYTE_LENGTH); + return toLongFromBytes(timestamp); + } + + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/seplatform/SecureElement.java b/src/main/java/com/baidubce/services/iothisk/device/seplatform/SecureElement.java new file mode 100644 index 00000000..02e0bcde --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/seplatform/SecureElement.java @@ -0,0 +1,107 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.seplatform; + +import com.baidubce.services.iothisk.device.model.ActiveMessage; +import com.baidubce.services.iothisk.device.model.CipherMessage; +import com.baidubce.services.iothisk.device.model.PlainMessage; + +/** + * Secure element interfaces. + * It defines secure element basic operation interfaces, including encryption, decryption, + * sign signature and message parsing. + */ +public interface SecureElement { + + /** + * Generate device unique id + * + * @return device unique id in ascii encoding + */ + String generateId(); + + /** + * Encrypt and sign provided plain message + * + * @param plainMessage specified plain message + * @return cipher message, including encrypted message and its signature + */ + CipherMessage encryptThenSign(PlainMessage plainMessage); + + /** + * Encrypt plain message, and sign the signature with provided private key + * + * @param plainMessage specified plain message + * @param signPrivateKey specified signature private key + * @return cipher message, including encrypted message and its signature + */ + CipherMessage encryptThenSign(PlainMessage plainMessage, byte[] signPrivateKey); + + /** + * Decrypt encrypted message + * + * @param encryption specified encrypted message in byte array + * @return plain message in byte array + */ + byte[] decrypt(byte[] encryption); + + /** + * Verify message signature. + * If failed, an exception will be thrown. + * + * @param message specified message in byte array + * @param signature specified signature in byte array + */ + void verifySignature(byte[] message, byte[] signature); + + /** + * Verify message and decrypt cipher message. + * + * @param cipherMessage specified cipher message + * @return plain message decrypted from cipher message, if failed an exception will be thrown. + */ + PlainMessage verifyThenDecrypt(CipherMessage cipherMessage); + + /** + * Parse byte array cipher message. + * + * @param cipherMessage specified cipher message in byte array + * @return cipher message object + */ + CipherMessage parseCipherMessage(byte[] cipherMessage); + + /** + * Parse byte array plain message. + * + * @param plainMessage specified plain message + * @return plain message object + */ + PlainMessage parsePlainMessage(byte[] plainMessage); + + /** + * Parse byte array active message + * + * @param activeMessage specified active message + * @return active message object + */ + ActiveMessage parseActiveMessage(byte[] activeMessage); + + /** + * Valid active message with secure element. + * If failed, an exception will be thrown. + * + * @param activeMessage specified active message + */ + void checkActiveMessage(ActiveMessage activeMessage); + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/seplatform/SecureElementFactory.java b/src/main/java/com/baidubce/services/iothisk/device/seplatform/SecureElementFactory.java new file mode 100644 index 00000000..ae74c2b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/seplatform/SecureElementFactory.java @@ -0,0 +1,42 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.seplatform; + +import static com.baidubce.services.iothisk.device.utils.Message.UNSUPPORTED_SE_TYPE; + +import com.baidubce.services.iothisk.device.model.Device; +import com.baidubce.services.iothisk.device.model.DeviceKey; + +/** + * Provides secure element factory according to device se type. + * Currently, only MBED_AKEY is supported. + */ +public class SecureElementFactory { + + /** + * Provides secure element by device contract and device key. + * + * @param contract specified device contract + * @param deviceKey specified device key + * @return successful secure element, otherwise an exception will be thrown + */ + public static SecureElement createSe(Device contract, DeviceKey deviceKey) { + switch (deviceKey.getSeType()) { + case MBED_AKEY: + return new MbedAkeySe(contract, deviceKey); + default: + throw new IllegalArgumentException(UNSUPPORTED_SE_TYPE); + } + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/utils/ByteUtils.java b/src/main/java/com/baidubce/services/iothisk/device/utils/ByteUtils.java new file mode 100644 index 00000000..aeebd842 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/utils/ByteUtils.java @@ -0,0 +1,99 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.utils; + +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_BYTES; +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_INT; +import static com.baidubce.services.iothisk.device.utils.Message.INVALID_TIMESTAMP; +import static com.google.common.primitives.UnsignedLongs.parseUnsignedLong; +import static javax.xml.bind.DatatypeConverter.parseHexBinary; +import static javax.xml.bind.DatatypeConverter.printHexBinary; + +import org.apache.commons.lang3.StringUtils; + +/** + * Provides byte array operation utilities + */ +public class ByteUtils { + + /** + * Get byte array from hex string + * + * @param data specified hex string data + * @return byte array + */ + public static byte[] toBytesFromHex(String data) { + // add leading 0 to even-length format required by `DatatypeConverter.parseHexBinary` + if (data.length() % 2 == 1) { + data = StringUtils.leftPad(data, data.length() + 1, '0'); + } + return parseHexBinary(data); + } + + /** + * Get hex string from byte array + * + * @param data specified byte array + * @return hex string + */ + public static String toHexStringFromBytes(byte[] data) { + return printHexBinary(data); + } + + /** + * Get byte array from int type value + * + * @param number specified in type value + * @return byte array + */ + public static byte[] toBytesFromInt(int number) { + try { + String hexNumber = Integer.toHexString(number); + return toBytesFromHex(hexNumber); + } catch (Exception e) { + throw new IllegalArgumentException(INVALID_INT); + } + } + + /** + * Get long value from byte array + * + * @param data specified byte array + * @return successful long type value, otherwise an exception will be thrown + */ + public static long toLongFromBytes(byte[] data) { + try { + return parseUnsignedLong(printHexBinary(data), 16); + } catch (Exception e) { + throw new IllegalArgumentException(INVALID_BYTES); + } + } + + /** + * Get byte array from counter value + * + * @param counter specified counter value + * @return successful byte value array, otherwise an exception will be thrown + */ + public static byte[] getCounterBytes(long counter) { + try { + String hexCounter = Long.toHexString(counter); + // counter represent in 4 bytes + hexCounter = StringUtils.leftPad(hexCounter, 8, '0'); + return toBytesFromHex(hexCounter); + } catch (Exception e) { + throw new IllegalArgumentException(INVALID_TIMESTAMP); + } + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/utils/CounterUtils.java b/src/main/java/com/baidubce/services/iothisk/device/utils/CounterUtils.java new file mode 100644 index 00000000..0b6b0a6c --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/utils/CounterUtils.java @@ -0,0 +1,55 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.utils; + +import static com.baidubce.services.iothisk.device.utils.Message.EXPIRED_MESSAGE; +import static com.baidubce.services.iothisk.device.utils.Message.UNKNOWN_DEVICE_SDK_TYPE; +import static java.lang.Math.abs; + +import com.baidubce.services.iothisk.device.model.DeviceSdkType; + +/** + * Provides counter utils to valid device counter according to device sdk type + */ +public class CounterUtils { + + private static final long RTC_COUNTER_INTERVAL = 120; + + /** + * Check message counter to against replay attack. + * + * @param deviceSdkType device sdk type + * @param counter message counter + * @param currentCounter current device counter + */ + public static void validCounter(DeviceSdkType deviceSdkType, long counter, long currentCounter) { + switch (deviceSdkType) { + case NONE_RTC: + if (counter <= currentCounter) { + throw new IllegalArgumentException(EXPIRED_MESSAGE); + } + break; + case RTC: + if (abs(currentCounter - counter) > RTC_COUNTER_INTERVAL) { + throw new IllegalArgumentException(EXPIRED_MESSAGE); + } + break; + case NONE_COUNTER: + // no counter check + break; + default: + throw new RuntimeException(UNKNOWN_DEVICE_SDK_TYPE); + } + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/device/utils/Message.java b/src/main/java/com/baidubce/services/iothisk/device/utils/Message.java new file mode 100644 index 00000000..f5b2f032 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/device/utils/Message.java @@ -0,0 +1,66 @@ +/* + * Copyright 2018-2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.device.utils; + +/** + * Provides error message + */ +public class Message { + + public static final String INVALID_CIPHER_DATA = "The data to be encrypted or decrypted is invalid."; + + public static final String INVALID_DEVICE_ID = "The device ID is invalid."; + + public static final String DEVICE_SE_ID_CONFLICT = "This device se id conflicts with the exist se id."; + + public static final String INVALID_TIMESTAMP = "The counter to be encrypted or decrypted is invalid."; + + public static final String NULL_CONTRACT = "contract should not be null"; + + public static final String NULL_SERIAL_NUMBER = "serial number should not be null"; + + public static final String NULL_DEVICE_SDK_TYPE = "device sdk type should not be null"; + + public static final String EXPIRED_MESSAGE = "Expired message"; + + public static final String UNKNOWN_DEVICE_SDK_TYPE = "Unknown device key sdk type"; + + public static final String INVALID_INT = "Invalid int data"; + + public static final String INVALID_BYTES = "Invalid bytes"; + + public static final String UNSUPPORTED_SE_TYPE = "Unsupported se type."; + + public static final String FAIL_GENERATE_ID = "Generate device id failed."; + + public static final String FAIL_SIGN = "Calculate signature failed."; + + public static final String INVALID_SIGNATURE = "Invalid signature."; + + public static final String FAIL_AES_ENCRYPT = "AES encrypt failed"; + + public static final String FAIL_AES_DECRYPT = "AES decrypt failed"; + + public static final String INVALID_AES_CIPHER_NAME = "Invalid AES cipher name."; + + public static final String INVALID_SERIAL_NUMBER = "Serial number is empty or its length greater than 32."; + + public static final String INVALID_DEVICE_COMPANY = + "Device company name must consist of Chinese or English characters, numbers, hypen \"-\", " + + "or the underscore \"_\", and between 3 and 32 characters in length."; + + public static final String INVALID_DEVICE_TYPE = + "Device type name must consist of Chinese or English characters, numbers, hypen \"-\", " + + "or the underscore \"_\", and between 3 and 32 characters in length."; + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/ActiveRequest.java b/src/main/java/com/baidubce/services/iothisk/model/ActiveRequest.java new file mode 100644 index 00000000..3feb26f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/ActiveRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright 2018 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.model; + +import static com.baidubce.services.iothisk.model.EncodeType.BASE64; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent the request for HISK Device ID Activation. + */ +public class ActiveRequest extends AbstractBceRequest { + + /** + * Device id activation message data, generated by SE. + */ + private String data; + + /** + * Cipher message data encoding type, default is base64. + */ + private EncodeType type = BASE64; + + /** + * Set device id activation message data. + * + * @param data device id activation message data + */ + public void setData(String data) { + this.data = data; + } + + /** + * Get device id activation message data. + * + * @return device id activation message data + */ + public String getData() { + return data; + } + + /** + * Set data encoding type. + * + * @param encodeType data encoding type. + */ + public void setType(EncodeType encodeType) { + this.type = encodeType; + } + + /** + * Get data encoding type. + * + * @return data encoding type. + */ + public EncodeType getType() { + return type; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ActiveRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/ActiveResponse.java b/src/main/java/com/baidubce/services/iothisk/model/ActiveResponse.java new file mode 100644 index 00000000..04d97413 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/ActiveResponse.java @@ -0,0 +1,68 @@ +/* + * Copyright 2018 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the response of HISK device id activation. + */ +public class ActiveResponse extends AbstractBceResponse { + + /** + * Device id activation result data, which normally is the corresponding device id. + */ + private String data; + + /** + * Sdk type, which is parsed from active data. + */ + private int sdkType; + + /** + * Get the activation result data. + * + * @return activation result data. + */ + public String getData() { + return data; + } + + /** + * Set the activation result data. + * + * @param data activation result data. + */ + public void setData(String data) { + this.data = data; + } + + /** + * Get the sdk type. + * + * @return device sdk type. + */ + public int getSdkType() { + return sdkType; + } + + /** + * Set the sdk type. + * + * @param sdkType device sdk type. + */ + public void setSdkType(int sdkType) { + this.sdkType = sdkType; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/AuthRequest.java b/src/main/java/com/baidubce/services/iothisk/model/AuthRequest.java new file mode 100644 index 00000000..3d82bdad --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/AuthRequest.java @@ -0,0 +1,69 @@ +package com.baidubce.services.iothisk.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent the request for HISK Device authentication. + */ +public class AuthRequest extends AbstractBceRequest { + + /** + * Device authentication code + */ + private String authCode; + + /** + * Device extra message applied in authentication + */ + private String extra; + + /** + * Set the device authentication code + * + * @param authCode device authentication code + */ + public void setAuthCode(String authCode) { + this.authCode = authCode; + } + + /** + * Get the device authentication code + * + * @return device authentication code + */ + public String getAuthCode() { + return authCode; + } + + /** + * Set the device extra message applied in authentication + * + * @param extra the device extra message applied in authentication + */ + public void setExtra(String extra) { + this.extra = extra; + } + + /** + * Get the device extra message applied in authentication + * + * @return get the extra message applied in authentication + */ + public String getExtra() { + return extra; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ActiveRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/BatchCreateClientCertRequest.java b/src/main/java/com/baidubce/services/iothisk/model/BatchCreateClientCertRequest.java new file mode 100644 index 00000000..7b25f4bb --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/BatchCreateClientCertRequest.java @@ -0,0 +1,128 @@ +package com.baidubce.services.iothisk.model; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import org.apache.commons.codec.binary.Base64; + +/** + * Represent the request for batch create client cert. + */ +public class BatchCreateClientCertRequest extends IotPkiManageRequest { + + /** + * Cert group ID of the certs which will be created + */ + private String groupId; + + /** + * Device IDs of the certs which will be created + */ + private List deviceIds; + + /** + * Validity period of sub certs in days. + */ + private int duration; + + /** + * Csr zip of the certs which will be created + */ + private String csrs; + + /** + * Create a batch create client cert request. + * Recommend to use this method to create batch create request. + * + * @param groupId Cert group ID of the certs which will be created. + * @param duration Validity period of sub certs in days. + * @param deviceIdAndCsr A map which maps device ID and csr. + * @return Batch create client cert request. + * @throws Exception If input arguments are illegal. + */ + public static BatchCreateClientCertRequest create(String groupId, int duration, Map deviceIdAndCsr) + throws Exception { + checkNotNull(groupId); + checkNotNull(deviceIdAndCsr); + + BatchCreateClientCertRequest request = new BatchCreateClientCertRequest() + .withGroupId(groupId) + .withDuration(duration); + + List deviceIds = new ArrayList(); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream); + for (Map.Entry deviceIdAndCsrEntry : deviceIdAndCsr.entrySet()) { + deviceIds.add(deviceIdAndCsrEntry.getKey()); + byte[] certContent = deviceIdAndCsrEntry.getValue().getBytes(); + zipOutputStream.putNextEntry(new ZipEntry(deviceIdAndCsrEntry.getKey())); + zipOutputStream.write(certContent, 0, certContent.length); + zipOutputStream.closeEntry(); + + } + zipOutputStream.finish(); + zipOutputStream.close(); + + request.setCsrs(Base64.encodeBase64String(byteArrayOutputStream.toByteArray())); + request.setDeviceIds(deviceIds); + return request; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public BatchCreateClientCertRequest withGroupId(String groupId) { + this.groupId = groupId; + return this; + } + + public List getDeviceIds() { + return deviceIds; + } + + public void setDeviceIds(List deviceIds) { + this.deviceIds = deviceIds; + } + + public BatchCreateClientCertRequest withDeviceIds(List deviceIds) { + this.deviceIds = deviceIds; + return this; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public BatchCreateClientCertRequest withDuration(int duration) { + this.duration = duration; + return this; + } + + public String getCsrs() { + return csrs; + } + + public void setCsrs(String csrs) { + this.csrs = csrs; + } + + public BatchCreateClientCertRequest withCsrs(String csrs) { + this.csrs = csrs; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/BatchCreateClientCertResponse.java b/src/main/java/com/baidubce/services/iothisk/model/BatchCreateClientCertResponse.java new file mode 100644 index 00000000..ffae39bb --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/BatchCreateClientCertResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the response of batch create client certs. + */ +public class BatchCreateClientCertResponse extends IotPkiManageResponse { + + /** + * Job ID of the create batch. + */ + private String jobId; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/CertStatus.java b/src/main/java/com/baidubce/services/iothisk/model/CertStatus.java new file mode 100644 index 00000000..f00e3001 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/CertStatus.java @@ -0,0 +1,22 @@ +package com.baidubce.services.iothisk.model; + +/** + * Possible status of get cert status. + */ +public enum CertStatus { + NotRevoke(0), + Revoked(1), + CertNotFound(2), + CANotFount(3), + UnknownError(4); + + private int statusCode; + + CertStatus(int statusCode) { + this.statusCode = statusCode; + } + + public int getStatusCode() { + return statusCode; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/CipherRequest.java b/src/main/java/com/baidubce/services/iothisk/model/CipherRequest.java new file mode 100644 index 00000000..0acdace9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/CipherRequest.java @@ -0,0 +1,106 @@ +/* + * Copyright 2018 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.model; + +import static com.baidubce.services.iothisk.model.EncodeType.BASE64; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent the request for message encryption/decryption. + */ +public class CipherRequest extends AbstractBceRequest { + + /** + * Message data requiring for encryption / decryption. + */ + private String data; + + /** + * Plain message encoding type, default is base64. + */ + private EncodeType type = BASE64; + + /** + * Cipher message encoding type, default is base64. + */ + private EncodeType cipherEncodeType = BASE64; + + /** + * Get the message data requiring for encryption / decryption. + * + * @return message data requiring for encryption / decryption + */ + public String getData() { + return data; + } + + /** + * Set the message data requiring for encryption / decryption. + * + * @param data message data requiring for encryption / decryption + */ + public void setData(String data) { + this.data = data; + } + + /** + * Get the message encoding type. + * + * @return message encoding type + */ + public EncodeType getType() { + return type; + } + + /** + * Set the message encoding type. + * + * @param encodeType message encoding type + */ + public void setType(EncodeType encodeType) { + this.type = encodeType; + } + + /** + * Get the cipher message encoding type. + * + * @return cipher message encoding type + */ + public EncodeType getCipherEncodeType() { + return cipherEncodeType; + } + + /** + * Set the cipher message encoding type. + * + * @param encodeType cipher message encoding type + */ + public void setCipherEncodeType(EncodeType encodeType) { + this.cipherEncodeType = encodeType; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CipherRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/CipherResponse.java b/src/main/java/com/baidubce/services/iothisk/model/CipherResponse.java new file mode 100644 index 00000000..e996b7a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/CipherResponse.java @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the response of encryption/decryption result. + */ +public class CipherResponse extends AbstractBceResponse { + + /** + * Encryption / decryption result data. + */ + private String data; + + /** + * Get the encryption / decryption result data. + * + * @return the encryption / decryption result data + */ + public String getData() { + return data; + } + + /** + * Set the encryption / decryption result data. + * + * @param data encryption / decryption result data + */ + public void setData(String data) { + this.data = data; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/CreateCertGroupRequest.java b/src/main/java/com/baidubce/services/iothisk/model/CreateCertGroupRequest.java new file mode 100644 index 00000000..8e47c76d --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/CreateCertGroupRequest.java @@ -0,0 +1,44 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the request for create cert group. + */ +public class CreateCertGroupRequest extends IotPkiManageRequest { + + /** + * Root cert ID of the group which will be created + */ + private String rootCertId; + + /** + * Group name of the group which will be created + */ + private String groupName; + + public String getRootCertId() { + return rootCertId; + } + + public void setRootCertId(String rootCertId) { + this.rootCertId = rootCertId; + } + + public CreateCertGroupRequest withRootCertId(String rootCertId) { + this.rootCertId = rootCertId; + return this; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public CreateCertGroupRequest withGroupName(String groupName) { + this.groupName = groupName; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/CreateCertGroupResponse.java b/src/main/java/com/baidubce/services/iothisk/model/CreateCertGroupResponse.java new file mode 100644 index 00000000..c93c032c --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/CreateCertGroupResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the response of create cert group. + */ +public class CreateCertGroupResponse extends IotPkiManageResponse { + + /** + * Group ID of the group. + */ + private String groupId; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/CreateRootCACertRequest.java b/src/main/java/com/baidubce/services/iothisk/model/CreateRootCACertRequest.java new file mode 100644 index 00000000..291898d5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/CreateRootCACertRequest.java @@ -0,0 +1,141 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the request for create root cert. + */ +public class CreateRootCACertRequest extends IotPkiManageRequest { + + /** + * Validity period of root cert in days. + */ + private int duration; + + /** + * Root cert info. + */ + private CertRequestInfo certRequestInfo; + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public CreateRootCACertRequest withDuration(int duration) { + this.duration = duration; + return this; + } + + public CertRequestInfo getCertRequestInfo() { + return certRequestInfo; + } + + public void setCertRequestInfo(CertRequestInfo certRequestInfo) { + this.certRequestInfo = certRequestInfo; + } + + public CreateRootCACertRequest withCertRequestInfo(CertRequestInfo certRequestInfo) { + this.certRequestInfo = certRequestInfo; + return this; + } + + /** + * Represent the info for create root cert. + */ + public static class CertRequestInfo { + + /** + * Country or region of root cert applicant. + */ + private String country; + + /** + * Common name of root cert applicant. + */ + private String commonName; + + /** + * Organization of root cert applicant. + */ + private String organization; + + /** + * Organization unit of root cert applicant. + */ + private String unit; + + /** + * Email address of root cert applicant. + */ + private String emailAddress; + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public CertRequestInfo withCountry(String country) { + this.country = country; + return this; + } + + public String getCommonName() { + return commonName; + } + + public void setCommonName(String commonName) { + this.commonName = commonName; + } + + public CertRequestInfo withCommonName(String commonName) { + this.commonName = commonName; + return this; + } + + public String getOrganization() { + return organization; + } + + public void setOrganization(String organization) { + this.organization = organization; + } + + public CertRequestInfo withOrganization(String organization) { + this.organization = organization; + return this; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public CertRequestInfo withUnit(String unit) { + this.unit = unit; + return this; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public CertRequestInfo withEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + return this; + } + + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/CreateRootCACertResponse.java b/src/main/java/com/baidubce/services/iothisk/model/CreateRootCACertResponse.java new file mode 100644 index 00000000..76cfa4fe --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/CreateRootCACertResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the response of create root cert. + */ +public class CreateRootCACertResponse extends IotPkiManageResponse { + + /** + * Cert ID of the root cert. + */ + private String certId; + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/CreateSubCertRequest.java b/src/main/java/com/baidubce/services/iothisk/model/CreateSubCertRequest.java new file mode 100644 index 00000000..a250bb1d --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/CreateSubCertRequest.java @@ -0,0 +1,99 @@ +package com.baidubce.services.iothisk.model; + +import java.util.List; + +/** + * Represent the request for create sub cert. + */ +public class CreateSubCertRequest extends IotPkiManageRequest { + + /** + * Cert group ID of the cert which will be created + */ + private String groupId; + + /** + * Device ID of the cert which will be created + */ + private String deviceId; + + /** + * Validity period of sub cert in days. + */ + private int duration; + + /** + * Csr file of the cert which will be created, encoded by base64, using PEM format. + */ + private String csr; + + /** + * Address list of the cert which will be created, only server cert can set it + */ + private List address; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public CreateSubCertRequest withGroupId(String groupId) { + this.groupId = groupId; + return this; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public CreateSubCertRequest withDeviceId(String deviceId) { + this.deviceId = deviceId; + return this; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public CreateSubCertRequest withDuration(int duration) { + this.duration = duration; + return this; + } + + public String getCsr() { + return csr; + } + + public void setCsr(String csr) { + this.csr = csr; + } + + public CreateSubCertRequest withCsr(String csr) { + this.csr = csr; + return this; + } + + public List getAddress() { + return address; + } + + public void setAddress(List address) { + this.address = address; + } + + public CreateSubCertRequest withAddress(List address) { + this.address = address; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/CreateSubCertResponse.java b/src/main/java/com/baidubce/services/iothisk/model/CreateSubCertResponse.java new file mode 100644 index 00000000..475b741a --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/CreateSubCertResponse.java @@ -0,0 +1,33 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the response of create sub cert. + */ +public class CreateSubCertResponse extends IotPkiManageResponse { + + /** + * Cert ID of the sub cert. + */ + private String certId; + + /** + * Sub cert download url + */ + private String downloadUrl; + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } + + public String getDownloadUrl() { + return downloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/DefaultIotPkiManageRequest.java b/src/main/java/com/baidubce/services/iothisk/model/DefaultIotPkiManageRequest.java new file mode 100644 index 00000000..e4df2cef --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/DefaultIotPkiManageRequest.java @@ -0,0 +1,7 @@ +package com.baidubce.services.iothisk.model; + +/** + * The default class of pki request. + */ +public class DefaultIotPkiManageRequest extends IotPkiManageRequest { +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/DefaultIotPkiManageResponse.java b/src/main/java/com/baidubce/services/iothisk/model/DefaultIotPkiManageResponse.java new file mode 100644 index 00000000..8c5460ad --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/DefaultIotPkiManageResponse.java @@ -0,0 +1,7 @@ +package com.baidubce.services.iothisk.model; + +/** + * The default class of pki response. + */ +public class DefaultIotPkiManageResponse extends IotPkiManageResponse { +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/DownloadCrlResponse.java b/src/main/java/com/baidubce/services/iothisk/model/DownloadCrlResponse.java new file mode 100644 index 00000000..cdbcd3f2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/DownloadCrlResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the response of download crl. + */ +public class DownloadCrlResponse extends IotPkiManageDataResponse { + + public String getCrlContent() { + return new String(data); + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/EncodeType.java b/src/main/java/com/baidubce/services/iothisk/model/EncodeType.java new file mode 100644 index 00000000..d56f513f --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/EncodeType.java @@ -0,0 +1,30 @@ +/* + * Copyright 2018 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothisk.model; + +/** + * Represent the type of message encoding type, including base64. + */ +public enum EncodeType { + + /** + * Base64 encoding cipher type + */ + BASE64, + + /** + * Hex encoding cipher type + */ + HEX + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/GetBatchCreateStatusResponse.java b/src/main/java/com/baidubce/services/iothisk/model/GetBatchCreateStatusResponse.java new file mode 100644 index 00000000..1b84ea1b --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/GetBatchCreateStatusResponse.java @@ -0,0 +1,125 @@ +package com.baidubce.services.iothisk.model; + +import java.util.List; + +/** + * Represent the response of get batch create status. + */ +public class GetBatchCreateStatusResponse extends IotPkiManageResponse { + + /** + * Status of the create batch. + */ + private JobStatus jobStatus; + + /** + * Show the fail detail when create some client certs failed. + */ + private String message; + + /** + * Cert count of the create batch. + */ + private int certCount; + + /** + * Handled cert count of the create batch. + */ + private int finishCount; + + /** + * Created cert ID list, contains device ID and cert ID. + */ + private List certIds ; + + /** + * Certs zip download url of the create batch. + */ + private String downloadUrl; + + public boolean isSucceed() { + if (jobStatus == null) { + return false; + } + return jobStatus.equals(JobStatus.Succeed); + } + + public boolean isPartialSucceed() { + if (jobStatus == null) { + return false; + } + return jobStatus.equals(JobStatus.PartialSucceed); + } + + public JobStatus getJobStatus() { + return jobStatus; + } + + public void setJobStatus(JobStatus jobStatus) { + this.jobStatus = jobStatus; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int getCertCount() { + return certCount; + } + + public void setCertCount(int certCount) { + this.certCount = certCount; + } + + public int getFinishCount() { + return finishCount; + } + + public void setFinishCount(int finishCount) { + this.finishCount = finishCount; + } + + public List getCertIds() { + return certIds; + } + + public void setCertIds(List certIds) { + this.certIds = certIds; + } + + public String getDownloadUrl() { + return downloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } + + public static class DeviceIdAndCertId { + + private String deviceId; + + private String certId; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getCertId() { + return certId; + } + + public void setCertId(String certId) { + this.certId = certId; + } + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/GetCertGroupResponse.java b/src/main/java/com/baidubce/services/iothisk/model/GetCertGroupResponse.java new file mode 100644 index 00000000..37d9eedc --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/GetCertGroupResponse.java @@ -0,0 +1,49 @@ +package com.baidubce.services.iothisk.model; + +import java.util.List; + +/** + * Represent the response of get cert group. + */ +public class GetCertGroupResponse extends IotPkiManageResponse { + + /** + * Root cert ID of the group. + */ + private String rootCertId; + + /** + * Server cert ID list of the group. + */ + private List serverCerts; + + /** + * Client cert ID list of the group. + */ + private List clientCerts; + + public String getRootCertId() { + return rootCertId; + } + + public void setRootCertId(String rootCertId) { + this.rootCertId = rootCertId; + } + + public List getServerCerts() { + return serverCerts; + } + + public void setServerCerts(List serverCerts) { + this.serverCerts = serverCerts; + } + + public List getClientCerts() { + return clientCerts; + } + + public void setClientCerts(List clientCerts) { + this.clientCerts = clientCerts; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iothisk/model/GetCertStatusRequest.java b/src/main/java/com/baidubce/services/iothisk/model/GetCertStatusRequest.java new file mode 100644 index 00000000..4999f2a3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/GetCertStatusRequest.java @@ -0,0 +1,44 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the request for get cert status. + */ +public class GetCertStatusRequest extends IotPkiManageRequest { + + /** + * Issuer DN of the cert which will be queried, can be found in cert content. + */ + private String issuerDN; + + /** + * Certificate serial number of the cert which will be queried, can be found in cert content. + * For example: 2c932aea1bc3dce9 + */ + private String certificateSN; + + public String getIssuerDN() { + return issuerDN; + } + + public void setIssuerDN(String issuerDN) { + this.issuerDN = issuerDN; + } + + public GetCertStatusRequest withIssuerDN(String issuerDN) { + this.issuerDN = issuerDN; + return this; + } + + public String getCertificateSN() { + return certificateSN; + } + + public void setCertificateSN(String certificateSN) { + this.certificateSN = certificateSN; + } + + public GetCertStatusRequest withCertificateSN(String certificateSN) { + this.certificateSN = certificateSN; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/GetCertStatusResponse.java b/src/main/java/com/baidubce/services/iothisk/model/GetCertStatusResponse.java new file mode 100644 index 00000000..bcf5c0a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/GetCertStatusResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.iothisk.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represent the response of get cert status. + */ +public class GetCertStatusResponse extends IotPkiManageResponse { + + @JsonProperty("statusCode") + private CertStatus status; + + public CertStatus getStatus() { + return status; + } + + public void setStatus(CertStatus status) { + this.status = status; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iothisk/model/GetOcspResponse.java b/src/main/java/com/baidubce/services/iothisk/model/GetOcspResponse.java new file mode 100644 index 00000000..0490b9eb --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/GetOcspResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the response of get ocsp response. + */ +public class GetOcspResponse extends IotPkiManageDataResponse { + + public byte[] getOcspResponse() { + return data; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/GetRootCACertResponse.java b/src/main/java/com/baidubce/services/iothisk/model/GetRootCACertResponse.java new file mode 100644 index 00000000..56be286a --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/GetRootCACertResponse.java @@ -0,0 +1,33 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the response of get root cert. + */ +public class GetRootCACertResponse extends IotPkiManageResponse { + + /** + * Crl download url + */ + private String crl; + + /** + * Root cert download url + */ + private String downloadUrl; + + public String getCrl() { + return crl; + } + + public void setCrl(String crl) { + this.crl = crl; + } + + public String getDownloadUrl() { + return downloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iothisk/model/GetSubCertResponse.java b/src/main/java/com/baidubce/services/iothisk/model/GetSubCertResponse.java new file mode 100644 index 00000000..f0740368 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/GetSubCertResponse.java @@ -0,0 +1,46 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the response of get sub cert. + */ +public class GetSubCertResponse extends IotPkiManageResponse { + + /** + * Root cert ID of the sub cert. + */ + private String rootCertId; + + /** + * Cert group ID of the sub cert. + */ + private String groupId; + + /** + * Download url of the sub cert. + */ + private String downloadUrl; + + public String getRootCertId() { + return rootCertId; + } + + public void setRootCertId(String rootCertId) { + this.rootCertId = rootCertId; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getDownloadUrl() { + return downloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/IotPkiManageDataResponse.java b/src/main/java/com/baidubce/services/iothisk/model/IotPkiManageDataResponse.java new file mode 100644 index 00000000..30e8d75f --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/IotPkiManageDataResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.iothisk.model; + +/** + * The base class of pki response which contains binary data. + */ +public abstract class IotPkiManageDataResponse extends IotPkiManageResponse { + + protected byte[] data; + + public byte[] getData() { + return data; + } + + public void setData(byte[] data) { + this.data = data; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/IotPkiManageRequest.java b/src/main/java/com/baidubce/services/iothisk/model/IotPkiManageRequest.java new file mode 100644 index 00000000..06add559 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/IotPkiManageRequest.java @@ -0,0 +1,17 @@ +package com.baidubce.services.iothisk.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The base class of all pki request. + */ +public abstract class IotPkiManageRequest extends AbstractBceRequest { + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/IotPkiManageResponse.java b/src/main/java/com/baidubce/services/iothisk/model/IotPkiManageResponse.java new file mode 100644 index 00000000..6adcf8e1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/IotPkiManageResponse.java @@ -0,0 +1,9 @@ +package com.baidubce.services.iothisk.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The base class of all pki response. + */ +public abstract class IotPkiManageResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/JobStatus.java b/src/main/java/com/baidubce/services/iothisk/model/JobStatus.java new file mode 100644 index 00000000..3cb2b5b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/JobStatus.java @@ -0,0 +1,11 @@ +package com.baidubce.services.iothisk.model; + +/** + * Possible status of batch create status. + */ +public enum JobStatus { + Processing, + PartialSucceed, + Succeed, + Failed +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iothisk/model/QueryClientCertResponse.java b/src/main/java/com/baidubce/services/iothisk/model/QueryClientCertResponse.java new file mode 100644 index 00000000..24db6202 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/QueryClientCertResponse.java @@ -0,0 +1,22 @@ +package com.baidubce.services.iothisk.model; + +import java.util.List; + +/** + * Represent the response of query client certs. + */ +public class QueryClientCertResponse extends IotPkiManageResponse { + + /** + * Client cert list. + */ + private List clientCerts; + + public List getClientCerts() { + return clientCerts; + } + + public void setClientCerts(List clientCerts) { + this.clientCerts = clientCerts; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/QueryServerCertResponse.java b/src/main/java/com/baidubce/services/iothisk/model/QueryServerCertResponse.java new file mode 100644 index 00000000..7445a013 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/QueryServerCertResponse.java @@ -0,0 +1,23 @@ +package com.baidubce.services.iothisk.model; + +import java.util.List; + +/** + * Represent the response of query server certs. + */ +public class QueryServerCertResponse extends IotPkiManageResponse { + + /** + * Server cert list. + */ + private List serverCerts; + + public List getServerCerts() { + return serverCerts; + } + + public void setServerCerts(List serverCerts) { + this.serverCerts = serverCerts; + } + +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/RenewSubCertRequest.java b/src/main/java/com/baidubce/services/iothisk/model/RenewSubCertRequest.java new file mode 100644 index 00000000..82a3a244 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/RenewSubCertRequest.java @@ -0,0 +1,81 @@ +package com.baidubce.services.iothisk.model; + +import java.util.List; + +/** + * Represent the request for renew sub cert. + */ +public class RenewSubCertRequest extends IotPkiManageRequest { + + /** + * New device ID of the cert which will be renewed + */ + private String newDeviceId; + + /** + * Validity period of sub cert in days. + */ + private int duration; + + /** + * Csr file of the cert which will be renewed, PEM format, encoded by base64 + */ + private String csr; + + /** + * New address list of the cert which will be renewed, only server cert can set it + */ + private List newAddress; + + public String getNewDeviceId() { + return newDeviceId; + } + + public void setNewDeviceId(String newDeviceId) { + this.newDeviceId = newDeviceId; + } + + public RenewSubCertRequest withNewDeviceId(String newDeviceId) { + this.newDeviceId = newDeviceId; + return this; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public RenewSubCertRequest withDuration(int duration) { + this.duration = duration; + return this; + } + + public String getCsr() { + return csr; + } + + public void setCsr(String csr) { + this.csr = csr; + } + + public RenewSubCertRequest withCsr(String csr) { + this.csr = csr; + return this; + } + + public List getNewAddress() { + return newAddress; + } + + public void setNewAddress(List newAddress) { + this.newAddress = newAddress; + } + + public RenewSubCertRequest withNewAddress(List newAddress) { + this.newAddress = newAddress; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iothisk/model/RenewSubCertResponse.java b/src/main/java/com/baidubce/services/iothisk/model/RenewSubCertResponse.java new file mode 100644 index 00000000..e11a8942 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothisk/model/RenewSubCertResponse.java @@ -0,0 +1,20 @@ +package com.baidubce.services.iothisk.model; + +/** + * Represent the response of renew sub cert. + */ +public class RenewSubCertResponse extends IotPkiManageResponse { + + /** + * Download url of the sub cert. + */ + private String downloadUrl; + + public String getDownloadUrl() { + return downloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/IoTCoreClient.java b/src/main/java/com/baidubce/services/iothub/IoTCoreClient.java new file mode 100644 index 00000000..091e7f7f --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/IoTCoreClient.java @@ -0,0 +1,349 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.iothub.model.BaseRequest; +import com.baidubce.services.iothub.model.BaseResponse; +import com.baidubce.services.iothub.model.iotcore.AddPolicyRequest; +import com.baidubce.services.iothub.model.iotcore.AddPolicyResponse; +import com.baidubce.services.iothub.model.iotcore.AlgorithmType; +import com.baidubce.services.iothub.model.iotcore.CreateDeviceRequest; +import com.baidubce.services.iothub.model.iotcore.CreateDeviceResponse; +import com.baidubce.services.iothub.model.iotcore.CreateTemplateRequest; +import com.baidubce.services.iothub.model.iotcore.CreateTemplateResponse; +import com.baidubce.services.iothub.model.iotcore.GetDeviceResponse; +import com.baidubce.services.iothub.model.iotcore.GetDeviceSignatureResponse; +import com.baidubce.services.iothub.model.iotcore.GetTemplateResponse; +import com.baidubce.services.iothub.model.iotcore.PaginationResponse; +import com.baidubce.services.iothub.model.iotcore.ResetDeviceSecretResponse; +import com.baidubce.services.iothub.model.iotcore.ScrollPaginationResponse; +import com.baidubce.services.iothub.model.iotcore.SecretKeyRequest; +import com.baidubce.services.iothub.model.iotcore.UpdateDeviceRequest; +import com.baidubce.services.iothub.model.iotcore.UpdateDeviceResponse; +import com.baidubce.services.iothub.model.iotcore.UpdatePolicyRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the IoT Core. + */ +public class IoTCoreClient extends AbstractBceClient { + + private static final ObjectMapper mapper = new ObjectMapper(); + + private static final String ENDPOINT_HOST = "iot.baidubce.com"; + private static final String VERSION = "v1"; + private static final String IOT_CORE = "iotcore"; + private static final String[] HEADERS_TO_SIGN = { Headers.HOST, Headers.BCE_DATE }; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + + private static final String DEVICE = "device"; + private static final String NEW = "new"; + private static final String SCROLL = "scroll"; + private static final String LIST = "list"; + private static final String SIGNATURE = "signature"; + private static final String SECRET = "secret"; + private static final String TEMPLATE = "template"; + private static final String POLICY = "policy"; + + /** + * Responsible for handling HttpResponse from all Iothub service calls. + */ + private static final HttpResponseHandler[] IOTCORE_HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; + + public IoTCoreClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT_HOST) : config, + IOTCORE_HANDLERS); + } + + public CreateDeviceResponse createDevice(String iotCoreId, CreateDeviceRequest createDeviceRequest) { + checkNotNull(createDeviceRequest, "iotCoreId should not be null."); + checkNotNull(createDeviceRequest, "request should not be null."); + return this.invokeHttpClient( + createRequest(createDeviceRequest, HttpMethodName.POST, iotCoreId, DEVICE, NEW), + CreateDeviceResponse.class); + } + + public GetDeviceResponse getDevice(String iotCoreId, String deviceName) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(deviceName, "deviceName should not be null."); + return this.invokeHttpClient( + createRequest(new BaseRequest(), HttpMethodName.GET, iotCoreId, DEVICE, deviceName), + GetDeviceResponse.class); + } + + public UpdateDeviceResponse updateDevice(String iotCoreId, String deviceName, + UpdateDeviceRequest updateDeviceRequest) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(deviceName, "deviceName should not be null."); + checkNotNull(updateDeviceRequest, "request should not be null."); + return this.invokeHttpClient( + createRequest(updateDeviceRequest, HttpMethodName.PUT, iotCoreId, DEVICE, deviceName), + UpdateDeviceResponse.class); + } + + public void deleteDevice(String iotCoreId, String deviceName) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(deviceName, "deviceName should not be null."); + this.invokeHttpClient( + createRequest(new BaseRequest(), HttpMethodName.DELETE, iotCoreId, DEVICE, deviceName), + BaseResponse.class); + } + + public ScrollPaginationResponse getDevices(String iotCoreId) { + return getDevices(iotCoreId, System.currentTimeMillis(), 20, ""); + } + + public ScrollPaginationResponse getDevices( + String iotCoreId, long createTimeBefore, int pageSize, String deviceNamePrefix) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(deviceNamePrefix, "deviceNamePrefix should not be null."); + checkArgument(createTimeBefore > 0L, "Illegal create time before"); + checkArgument(pageSize > 0 && pageSize < 200, "Illegal page size"); + + Map parameters = new HashMap(); + parameters.put("createTimeBefore", String.valueOf(createTimeBefore)); + parameters.put("pageSize", String.valueOf(pageSize)); + parameters.put("name", deviceNamePrefix); + ScrollPaginationResponse response = this.invokeHttpClient( + createRequest(new BaseRequest(), HttpMethodName.GET, parameters, iotCoreId, DEVICE, SCROLL, LIST), + ScrollPaginationResponse.class); + List responses = new ArrayList(); + for (Object data : response.getData()) { + responses.add(mapper.convertValue(data, GetDeviceResponse.class)); + } + + return new ScrollPaginationResponse( + responses, response.getTotal(), response.getPageSize(), response.getCreateTimeBefore()); + } + + public GetDeviceSignatureResponse getDeviceSignature(String iotCoreId, String deviceName) { + return getDeviceSignature(iotCoreId, deviceName, 0L, AlgorithmType.MD5); + } + + public GetDeviceSignatureResponse getDeviceSignature(String iotCoreId, String deviceName, + long timestamp, AlgorithmType algorithmType) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(deviceName, "deviceName should not be null."); + checkNotNull(algorithmType, "algorithmType should not be null."); + checkArgument(timestamp >= 0L, "Illegal timestamp"); + + Map parameters = new HashMap(); + parameters.put("timestamp", String.valueOf(timestamp)); + parameters.put("algorithmType", algorithmType.name()); + return this.invokeHttpClient( + createRequest(new BaseRequest(), HttpMethodName.GET, + parameters, iotCoreId, DEVICE, deviceName, SIGNATURE), + GetDeviceSignatureResponse.class); + } + + public ResetDeviceSecretResponse resetDeviceSecret(String iotCoreId, String deviceName) { + return resetDeviceSecret(iotCoreId, deviceName, null); + } + + public ResetDeviceSecretResponse resetDeviceSecret(String iotCoreId, String deviceName, String secretKey) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(deviceName, "deviceName should not be null."); + BaseRequest request; + if (secretKey != null) { + request = SecretKeyRequest.builder() + .secretKey(secretKey) + .build(); + } else { + request = new BaseRequest(); + } + return this.invokeHttpClient( + createRequest(request, HttpMethodName.PUT, iotCoreId, DEVICE, deviceName, SECRET), + ResetDeviceSecretResponse.class); + } + + // template + public CreateTemplateResponse createTemplate(String iotCoreId, String templateName) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(templateName, "templateName should not be null."); + + CreateTemplateRequest request = CreateTemplateRequest.builder() + .name(templateName) + .build(); + return this.invokeHttpClient( + createRequest(request, HttpMethodName.POST, iotCoreId, TEMPLATE), + CreateTemplateResponse.class); + } + + public GetTemplateResponse getTemplate(String iotCoreId, String templateId) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(templateId, "templateId should not be null."); + + return this.invokeHttpClient( + createRequest(new BaseRequest(), HttpMethodName.GET, iotCoreId, TEMPLATE, templateId), + GetTemplateResponse.class); + } + + public PaginationResponse getTemplates(String iotCoreId) { + return getTemplates(iotCoreId, 1, 20); + } + + public PaginationResponse getTemplates(String iotCoreId, int pageNo, int pageSize) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkArgument(pageNo > 0, "Illegal page no"); + checkArgument(pageSize > 0 && pageSize < 200, "Illegal page size"); + + Map parameters = new HashMap(); + parameters.put("pageNo", String.valueOf(pageNo)); + parameters.put("pageSize", String.valueOf(pageSize)); + PaginationResponse response = this.invokeHttpClient( + createRequest(new BaseRequest(), HttpMethodName.GET, parameters, iotCoreId, TEMPLATE, LIST), + PaginationResponse.class); + List responses = new ArrayList(); + for (Object data : response.getData()) { + responses.add(mapper.convertValue(data, GetTemplateResponse.class)); + } + return new PaginationResponse(responses, response.getTotal(), response.getPageNo(), + response.getPageSize(), response.getOrder(), response.getOrderBy()); + } + + public void deleteTemplate(String iotCoreId, String templateId) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(templateId, "iotCoreId should not be null."); + + this.invokeHttpClient( + createRequest(new BaseRequest(), HttpMethodName.DELETE, iotCoreId, TEMPLATE, templateId), + BaseResponse.class); + } + + public AddPolicyResponse addPolicy(String iotCoreId, String templateId, AddPolicyRequest request) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(templateId, "iotCoreId should not be null."); + checkNotNull(request, "request should not be null."); + + return this.invokeHttpClient( + createRequest(request, HttpMethodName.POST, iotCoreId, TEMPLATE, templateId, POLICY), + AddPolicyResponse.class); + } + + public void updatePolicy(String iotCoreId, String templateId, String policyId, UpdatePolicyRequest request) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(templateId, "iotCoreId should not be null."); + checkNotNull(policyId, "iotCoreId should not be null."); + checkNotNull(request, "request should not be null."); + + this.invokeHttpClient( + createRequest(request, HttpMethodName.PUT, iotCoreId, TEMPLATE, templateId, POLICY, policyId), + BaseResponse.class); + } + + public void removePolicy(String iotCoreId, String templateId, String policyId) { + checkNotNull(iotCoreId, "iotCoreId should not be null."); + checkNotNull(templateId, "iotCoreId should not be null."); + checkNotNull(policyId, "iotCoreId should not be null."); + + this.invokeHttpClient( + createRequest(new BaseRequest(), HttpMethodName.DELETE, + iotCoreId, TEMPLATE, templateId, POLICY, policyId), + BaseResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + Map parameters, + String... pathVariables) { + return createRequest(bceRequest, httpMethod, null, parameters, pathVariables); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + return createRequest(bceRequest, httpMethod, null, null, pathVariables); + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param signOptions The options for signature. + * @param parameters The http query params. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object populated with endpoint, resource path and specific parameters to send. + */ + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + SignOptions signOptions, Map parameters, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + path.add(IOT_CORE); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + if (signOptions == null) { + signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + } + if (parameters != null) { + request.setParameters(parameters); + } + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + + fillInHeadAndBody(bceRequest, request); + return request; + } + + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/iothub/IotHubClient.java b/src/main/java/com/baidubce/services/iothub/IotHubClient.java index 3779e6b7..f3b6f9ab 100644 --- a/src/main/java/com/baidubce/services/iothub/IotHubClient.java +++ b/src/main/java/com/baidubce/services/iothub/IotHubClient.java @@ -25,10 +25,16 @@ import com.baidubce.internal.InternalRequest; import com.baidubce.internal.RestartableInputStream; import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.iothub.model.AccountMqttUsageRequest; import com.baidubce.services.iothub.model.AttachPrincipalToPolicyRequest; import com.baidubce.services.iothub.model.AttachThingToPrincipalRequest; import com.baidubce.services.iothub.model.BaseRequest; import com.baidubce.services.iothub.model.BaseResponse; +import com.baidubce.services.iothub.model.BatchGetMqttClientStatusRequest; +import com.baidubce.services.iothub.model.BatchGetMqttClientStatusResponse; +import com.baidubce.services.iothub.model.CreatePrincipalWithCertResponse; +import com.baidubce.services.iothub.model.MqttClientStatusRequest; +import com.baidubce.services.iothub.model.MqttClientStatusResponse; import com.baidubce.services.iothub.model.CreatePermissionRequest; import com.baidubce.services.iothub.model.CreatePrincipalResponse; import com.baidubce.services.iothub.model.DeleteThingRequest; @@ -37,7 +43,10 @@ import com.baidubce.services.iothub.model.ListPolicyRequest; import com.baidubce.services.iothub.model.ListPrincipalsRequest; import com.baidubce.services.iothub.model.ListResponse; +import com.baidubce.services.iothub.model.MqttUsageResponse; import com.baidubce.services.iothub.model.Operation; +import com.baidubce.services.iothub.model.QueryEndpointDailyMqttUsageRequest; +import com.baidubce.services.iothub.model.QueryEndpointDailyMqttUsageResponse; import com.baidubce.services.iothub.model.QueryEndpointRequest; import com.baidubce.services.iothub.model.QueryEndpointResponse; import com.baidubce.services.iothub.model.QueryPermissionRequest; @@ -48,11 +57,16 @@ import com.baidubce.services.iothub.model.QueryPrincipalResponse; import com.baidubce.services.iothub.model.QueryThingRequest; import com.baidubce.services.iothub.model.QueryThingResponse; -import com.baidubce.services.iothub.model.RegenerateCertRequest; +import com.baidubce.services.iothub.model.RegeneratePasswordRequest; +import com.baidubce.services.iothub.model.RenewCertificateRequest; +import com.baidubce.services.iothub.model.RenewCertificateResponse; import com.baidubce.services.iothub.model.UpdatePermissionRequest; import com.baidubce.util.HttpUtils; import com.baidubce.util.JsonUtils; +import org.joda.time.format.ISODateTimeFormat; + import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkArgument; import java.io.UnsupportedEncodingException; import java.net.URI; @@ -63,11 +77,17 @@ /** * Provides the client for accessing the Iothub(Internet of Things hub). + * + * @deprecated Use {@link IoTCoreClient}, IoT-hub will not be supported in the future. */ +@Deprecated public class IotHubClient extends AbstractBceClient { + private static final String ENDPOINT_HOST = "iot.gz.baidubce.com"; private static final String VERSION = "v1"; private static final String ENDPOINT = "endpoint"; + private static final String CERT = "cert"; + private static final String RENEW = "renew-certificate"; private static final String THING = "thing"; private static final String PRINCIPAL = "principal"; private static final String POLICY = "policy"; @@ -77,6 +97,13 @@ public class IotHubClient extends AbstractBceClient { private static final String REMOVETHINGPRINCIPAL = "remove-thing-principal"; private static final String ATTACHPRINCIPALPOLICY = "attach-principal-policy"; private static final String REMOVEPRINCIPALPOLICY = "remove-principal-policy"; + private static final String CLIENT = "client"; + private static final String BATCH_CLIENT = "batch-client"; + private static final String STATUS = "status"; + private static final String USAGE = "usage"; + private static final String USAGE_QUERY = "usage-query"; + private static final String START = "start"; + private static final String END = "end"; private static final String[] HEADERS_TO_SIGN = { Headers.HOST, Headers.BCE_DATE }; private static final String DEFAULT_ENCODING = "UTF-8"; @@ -90,7 +117,9 @@ public class IotHubClient extends AbstractBceClient { new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; public IotHubClient(BceClientConfiguration config) { - super(config, IOTHUB_HANDLERS); + + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT_HOST) : config, + IOTHUB_HANDLERS); } public ListResponse listEndpoints() { @@ -301,6 +330,7 @@ public CreatePrincipalResponse createPrincipal(String endpointName, String princ .withEndpointName(endpointName) .withPrincipalName(principalName)); } + public CreatePrincipalResponse createPrincipal(QueryPrincipalRequest createPrincipalRequest) { checkNotNull(createPrincipalRequest, "request should not be null."); InternalRequest internalRequest = createRequest(createPrincipalRequest, @@ -312,33 +342,76 @@ public CreatePrincipalResponse createPrincipal(QueryPrincipalRequest createPrin return this.invokeHttpClient(internalRequest, CreatePrincipalResponse.class); } - public CreatePrincipalResponse regenerateCert(String endpointName, String principalName) { + public CreatePrincipalWithCertResponse createPrincipalWithCert(String endpointName, String principalName) { + checkNotNull(endpointName, "endpointName should not be null"); + checkNotNull(principalName, "principalName should not be null"); + return createPrincipalWithCert(new QueryPrincipalRequest() + .withEndpointName(endpointName) + .withPrincipalName(principalName)); + } + + public CreatePrincipalWithCertResponse createPrincipalWithCert(QueryPrincipalRequest createPrincipalRequest) { + checkNotNull(createPrincipalRequest, "request should not be null."); + InternalRequest internalRequest = createRequest(createPrincipalRequest, + HttpMethodName.POST, + ENDPOINT, + createPrincipalRequest.getEndpointName(), + PRINCIPAL); + internalRequest.addParameter("withCert", "true"); + fillInHeadAndBody(createPrincipalRequest, internalRequest); + return this.invokeHttpClient(internalRequest, CreatePrincipalWithCertResponse.class); + } + + public CreatePrincipalResponse regeneratePassword(String endpointName, String principalName) { checkNotNull(endpointName, "endpointName should not be null"); checkNotNull(principalName, "principalName should not be null"); - return regenerateCert(new RegenerateCertRequest() + return regeneratePassword(new RegeneratePasswordRequest() .withEndpointName(endpointName) .withPrincipalName(principalName)); } - public CreatePrincipalResponse regenerateCert(String endpointName, String principalName, String target) { + public CreatePrincipalResponse regeneratePassword(String endpointName, String principalName, String target) { checkNotNull(endpointName, "endpointName should not be null"); checkNotNull(principalName, "principalName should not be null"); - return regenerateCert(new RegenerateCertRequest() + return regeneratePassword(new RegeneratePasswordRequest() .withEndpointName(endpointName) .withPrincipalName(principalName) .withTarget(target)); } - public CreatePrincipalResponse regenerateCert(RegenerateCertRequest regenerateCertRequest) { - checkNotNull(regenerateCertRequest, "request should not be null."); - InternalRequest internalRequest = createRequest(regenerateCertRequest, + public CreatePrincipalResponse regeneratePassword(RegeneratePasswordRequest regeneratePasswordRequest) { + checkNotNull(regeneratePasswordRequest, "request should not be null."); + InternalRequest internalRequest = createRequest(regeneratePasswordRequest, HttpMethodName.POST, ENDPOINT, - regenerateCertRequest.getEndpointName(), + regeneratePasswordRequest.getEndpointName(), PRINCIPAL, - regenerateCertRequest.getPrincipalName() ); - fillInHeadAndBody(regenerateCertRequest, internalRequest); + regeneratePasswordRequest.getPrincipalName() ); + fillInHeadAndBody(regeneratePasswordRequest, internalRequest); return this.invokeHttpClient(internalRequest, CreatePrincipalResponse.class); } + public RenewCertificateResponse renewCertificate(String endpointName, String principalName) { + checkNotNull(endpointName, "endpointName should not be null"); + checkNotNull(principalName, "principalName should not be null"); + return renewCertificate(new RenewCertificateRequest() + .withEndpointName(endpointName) + .withPrincipalName(principalName)); + + } + + public RenewCertificateResponse renewCertificate(RenewCertificateRequest renewCertificateRequest) { + checkNotNull(renewCertificateRequest, "request should not be null."); + InternalRequest internalRequest = createRequest(renewCertificateRequest, + HttpMethodName.POST, + ENDPOINT, + renewCertificateRequest.getEndpointName(), + PRINCIPAL, + renewCertificateRequest.getPrincipalName(), + CERT, + RENEW); + fillInHeadAndBody(renewCertificateRequest, internalRequest); + return this.invokeHttpClient(internalRequest, RenewCertificateResponse.class); + } + public BaseResponse deletePrincipal(String endpointName, String principalName) { checkNotNull(endpointName, "endpointName should not be null"); checkNotNull(principalName, "principalName should not be null"); @@ -654,6 +727,49 @@ public BaseResponse removePrincipalToPolicy(AttachPrincipalToPolicyRequest attac return this.invokeHttpClient(internalRequest, BaseResponse.class); } + public MqttClientStatusResponse getClientStatus(MqttClientStatusRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getEndpointName(), "endpointName should not be null."); + checkNotNull(request.getClientId(), "clientId should not be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, ENDPOINT, + request.getEndpointName(), CLIENT, request.getClientId(), STATUS); + return this.invokeHttpClient(internalRequest, MqttClientStatusResponse.class); + } + + public BatchGetMqttClientStatusResponse batchGetClientStatus(BatchGetMqttClientStatusRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getEndpointName(), "endpointName should not be null."); + checkNotNull(request.getClientIdList(), "clientIdList should not be null."); + checkArgument(!request.getClientIdList().isEmpty(), "clientIdList should not be empty."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, ENDPOINT, + request.getEndpointName(), BATCH_CLIENT, STATUS); + fillInHeadAndBody(request, internalRequest); + return this.invokeHttpClient(internalRequest, BatchGetMqttClientStatusResponse.class); + } + + public MqttUsageResponse getAccountMqttUsageOfCurrentBillingMonth(AccountMqttUsageRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, USAGE); + return this.invokeHttpClient(internalRequest, MqttUsageResponse.class); + } + + public MqttUsageResponse getEndpointMqttUsageOfCurrentBillingMonth(BaseRequest request) { + checkNotNull(request.getEndpointName(), "endpointName should not be null"); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, ENDPOINT, + request.getEndpointName(), USAGE); + return this.invokeHttpClient(internalRequest, MqttUsageResponse.class); + } + + public QueryEndpointDailyMqttUsageResponse queryEndpointDailyMqttUsage(QueryEndpointDailyMqttUsageRequest request) { + checkNotNull(request.getEndpointName(), "endpointName should not be null"); + checkNotNull(request.getStart(), "start should not be null"); + checkNotNull(request.getEnd(), "end should not be null"); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, ENDPOINT, + request.getEndpointName(), USAGE_QUERY); + internalRequest.addParameter(START, ISODateTimeFormat.date().print(request.getStart())); + internalRequest.addParameter(END, ISODateTimeFormat.date().print(request.getEnd())); + return this.invokeHttpClient(internalRequest, QueryEndpointDailyMqttUsageResponse.class); + } + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { return createRequest(bceRequest, httpMethod, null, pathVariables); @@ -691,12 +807,14 @@ private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodN return request; } + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { byte[] content = toJson(bceRequest); request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); request.setContent(RestartableInputStream.wrap(content)); } + private byte[] toJson(AbstractBceRequest bceRequest) { String jsonStr = JsonUtils.toJsonString(bceRequest); try { diff --git a/src/main/java/com/baidubce/services/iothub/model/AccountMqttUsageRequest.java b/src/main/java/com/baidubce/services/iothub/model/AccountMqttUsageRequest.java new file mode 100644 index 00000000..beddfe7b --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/AccountMqttUsageRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.iothub.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class AccountMqttUsageRequest extends AbstractBceRequest { + private String endpointName; + + public AccountMqttUsageRequest withEndpointName(String endpointName) { + this.endpointName = endpointName; + return this; + } + + public String getEndpointName() { + return endpointName; + } + + public void setEndpointName(String endpointName) { + this.endpointName = endpointName; + } + + @Override + public AccountMqttUsageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iothub/model/BatchGetMqttClientStatusRequest.java b/src/main/java/com/baidubce/services/iothub/model/BatchGetMqttClientStatusRequest.java new file mode 100644 index 00000000..7c9bc23b --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/BatchGetMqttClientStatusRequest.java @@ -0,0 +1,16 @@ +package com.baidubce.services.iothub.model; + +import java.util.List; + +public class BatchGetMqttClientStatusRequest extends BaseRequest { + + private List clientIdList; + + public List getClientIdList() { + return clientIdList; + } + + public void setClientIdList(List clientIdList) { + this.clientIdList = clientIdList; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/BatchGetMqttClientStatusResponse.java b/src/main/java/com/baidubce/services/iothub/model/BatchGetMqttClientStatusResponse.java new file mode 100644 index 00000000..0720e2e3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/BatchGetMqttClientStatusResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.iothub.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.Map; + +public class BatchGetMqttClientStatusResponse extends AbstractBceResponse { + + private Map value; + + public Map getValue() { + return value; + } + + public void setValue(Map value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/CreatePrincipalWithCertResponse.java b/src/main/java/com/baidubce/services/iothub/model/CreatePrincipalWithCertResponse.java new file mode 100644 index 00000000..41b49f45 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/CreatePrincipalWithCertResponse.java @@ -0,0 +1,90 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model; + +/** + * Represent the create Principal with certificate response. + */ +public class CreatePrincipalWithCertResponse extends QueryResponse { + + + private String privateKey; + + private String publicKey; + + private String clientCertId; + + private String clientCertDownloadUrl; + + private String principalName; + + private String certificate; + + private String clientCertCA; + + public String getPrivateKey() { + return privateKey; + } + + public void setPrivateKey(String privateKey) { + this.privateKey = privateKey; + } + + public String getPublicKey() { + return publicKey; + } + + public void setPublicKey(String publicKey) { + this.publicKey = publicKey; + } + + public String getClientCertId() { + return clientCertId; + } + + public void setClientCertId(String clientCertId) { + this.clientCertId = clientCertId; + } + + public String getClientCertDownloadUrl() { + return clientCertDownloadUrl; + } + + public void setClientCertDownloadUrl(String clientCertDownloadUrl) { + this.clientCertDownloadUrl = clientCertDownloadUrl; + } + + public String getPrincipalName() { + return principalName; + } + + public void setPrincipalName(String principalName) { + this.principalName = principalName; + } + + public String getCertificate() { + return certificate; + } + + public void setCertificate(String certificate) { + this.certificate = certificate; + } + + public String getClientCertCA() { + return clientCertCA; + } + + public void setClientCertCA(String clientCertCA) { + this.clientCertCA = clientCertCA; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/DailyMqttUsage.java b/src/main/java/com/baidubce/services/iothub/model/DailyMqttUsage.java new file mode 100644 index 00000000..2766b5d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/DailyMqttUsage.java @@ -0,0 +1,42 @@ +package com.baidubce.services.iothub.model; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.joda.time.LocalDate; + +import java.io.IOException; + +public class DailyMqttUsage { + + private static class LocalDateSerializer extends JsonDeserializer { + + @Override + public LocalDate deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) + throws IOException { + return new LocalDate(jsonParser.getValueAsString()); + } + } + + @JsonDeserialize(using = LocalDateSerializer.class) + private LocalDate date; + + private MqttUsage usage; + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public MqttUsage getUsage() { + return usage; + } + + public void setUsage(MqttUsage usage) { + this.usage = usage; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/MqttClientStatus.java b/src/main/java/com/baidubce/services/iothub/model/MqttClientStatus.java new file mode 100644 index 00000000..8102df26 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/MqttClientStatus.java @@ -0,0 +1,14 @@ +package com.baidubce.services.iothub.model; + +public class MqttClientStatus { + + private boolean online; + + public boolean isOnline() { + return online; + } + + public void setOnline(boolean online) { + this.online = online; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/MqttClientStatusRequest.java b/src/main/java/com/baidubce/services/iothub/model/MqttClientStatusRequest.java new file mode 100644 index 00000000..49abab60 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/MqttClientStatusRequest.java @@ -0,0 +1,19 @@ +package com.baidubce.services.iothub.model; + +public class MqttClientStatusRequest extends BaseRequest { + + private String clientId; + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public MqttClientStatusRequest withClientId(String clientId) { + this.clientId = clientId; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/MqttClientStatusResponse.java b/src/main/java/com/baidubce/services/iothub/model/MqttClientStatusResponse.java new file mode 100644 index 00000000..7cf8ea11 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/MqttClientStatusResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.iothub.model; + +import com.baidubce.model.AbstractBceResponse; + +public class MqttClientStatusResponse extends AbstractBceResponse { + + private boolean online; + + public boolean isOnline() { + return online; + } + + public void setOnline(boolean online) { + this.online = online; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/MqttUsage.java b/src/main/java/com/baidubce/services/iothub/model/MqttUsage.java new file mode 100644 index 00000000..debec0ee --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/MqttUsage.java @@ -0,0 +1,28 @@ +package com.baidubce.services.iothub.model; + +public class MqttUsage { + + private long publishReceived; + + private long publishSent; + + public long getPublishReceived() { + return publishReceived; + } + + public void setPublishReceived(long value) { + publishReceived = value; + } + + public long getPublishSent() { + return publishSent; + } + + public void setPublishSent(long value) { + publishSent = value; + } + + public long getTotal() { + return publishReceived + publishSent; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/MqttUsageResponse.java b/src/main/java/com/baidubce/services/iothub/model/MqttUsageResponse.java new file mode 100644 index 00000000..0b93eb7e --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/MqttUsageResponse.java @@ -0,0 +1,30 @@ +package com.baidubce.services.iothub.model; + +import com.baidubce.model.AbstractBceResponse; + +public class MqttUsageResponse extends AbstractBceResponse { + + private long publishReceived; + + private long publishSent; + + public long getPublishReceived() { + return publishReceived; + } + + public void setPublishReceived(long value) { + publishReceived = value; + } + + public long getPublishSent() { + return publishSent; + } + + public void setPublishSent(long value) { + publishSent = value; + } + + public long getTotal() { + return publishReceived + publishSent; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryEndpointDailyMqttUsageRequest.java b/src/main/java/com/baidubce/services/iothub/model/QueryEndpointDailyMqttUsageRequest.java new file mode 100644 index 00000000..f3f23720 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/QueryEndpointDailyMqttUsageRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.iothub.model; + +import org.joda.time.LocalDate; + +public class QueryEndpointDailyMqttUsageRequest extends BaseRequest { + + private LocalDate start; + + private LocalDate end; + + public LocalDate getStart() { + return start; + } + + public void setStart(LocalDate start) { + this.start = start; + } + + public LocalDate getEnd() { + return end; + } + + public void setEnd(LocalDate end) { + this.end = end; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryEndpointDailyMqttUsageResponse.java b/src/main/java/com/baidubce/services/iothub/model/QueryEndpointDailyMqttUsageResponse.java new file mode 100644 index 00000000..818a5790 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/QueryEndpointDailyMqttUsageResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.iothub.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +public class QueryEndpointDailyMqttUsageResponse extends AbstractBceResponse { + + private List value; + + public List getValue() { + return value; + } + + public void setValue(List value) { + this.value = value; + } +} diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalResponse.java b/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalResponse.java index 6d97409b..3ee207e2 100644 --- a/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalResponse.java @@ -18,6 +18,12 @@ public class QueryPrincipalResponse extends QueryResponse { private String principalName; + private String certificate; + + private Boolean isWithCert; + + private String clientCertCA; + public String getPrincipalName() { return principalName; } @@ -25,4 +31,29 @@ public String getPrincipalName() { public void setPrincipalName(String principalName) { this.principalName = principalName; } + + public String getCertificate() { + return certificate; + } + + public void setCertificate(String certificate) { + this.certificate = certificate; + } + + public Boolean getIsWithCert() { + return this.isWithCert; + } + + public void setIsWithCert(Boolean withCert) { + this.isWithCert = withCert; + } + + public String getClientCertCA() { + return clientCertCA; + } + + public void setClientCertCA(String clientCertCA) { + this.clientCertCA = clientCertCA; + } + } diff --git a/src/main/java/com/baidubce/services/iothub/model/RegenerateCertRequest.java b/src/main/java/com/baidubce/services/iothub/model/RegeneratePasswordRequest.java similarity index 75% rename from src/main/java/com/baidubce/services/iothub/model/RegenerateCertRequest.java rename to src/main/java/com/baidubce/services/iothub/model/RegeneratePasswordRequest.java index f88537ef..2ee62071 100644 --- a/src/main/java/com/baidubce/services/iothub/model/RegenerateCertRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/RegeneratePasswordRequest.java @@ -13,23 +13,23 @@ package com.baidubce.services.iothub.model; /** - * Represent the request to regenerate cert and pwd. + * Represent the request to regenerate pwd. */ -public class RegenerateCertRequest extends QueryPrincipalRequest { +public class RegeneratePasswordRequest extends QueryPrincipalRequest { private String target; - public RegenerateCertRequest withTarget(String target) { + public RegeneratePasswordRequest withTarget(String target) { this.target = target; return this; } - public RegenerateCertRequest withPrincipalName(String principalName) { + public RegeneratePasswordRequest withPrincipalName(String principalName) { this.setPrincipalName(principalName); return this; } - public RegenerateCertRequest withEndpointName(String endpointName) { + public RegeneratePasswordRequest withEndpointName(String endpointName) { this.setEndpointName(endpointName); return this; } diff --git a/src/main/java/com/baidubce/services/iothub/model/RenewCertificateRequest.java b/src/main/java/com/baidubce/services/iothub/model/RenewCertificateRequest.java new file mode 100644 index 00000000..32be73bb --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/RenewCertificateRequest.java @@ -0,0 +1,20 @@ +package com.baidubce.services.iothub.model; + +/** + * Represent the request to renew the certificate. + */ +public class RenewCertificateRequest extends QueryPrincipalRequest { + + + public RenewCertificateRequest withPrincipalName(String principalName) { + this.setPrincipalName(principalName); + return this; + } + + public RenewCertificateRequest withEndpointName(String endpointName) { + this.setEndpointName(endpointName); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/RenewCertificateResponse.java b/src/main/java/com/baidubce/services/iothub/model/RenewCertificateResponse.java new file mode 100644 index 00000000..b2e93f95 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/RenewCertificateResponse.java @@ -0,0 +1,70 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model; + +/** + * Represent the Renew certificate response . + */ +public class RenewCertificateResponse extends BaseResponse { + + private String certificateUrl; + + private String certificateContent; + + private String publicKey; + + private String privateKey; + + private String clientCertCA; + + public String getCertificateUrl() { + return certificateUrl; + } + + public void setCertificateUrl(String certificateUrl) { + this.certificateUrl = certificateUrl; + } + + public String getCertificateContent() { + return certificateContent; + } + + public void setCertificateContent(String certificateContent) { + this.certificateContent = certificateContent; + } + + public String getPublicKey() { + return publicKey; + } + + public void setPublicKey(String publicKey) { + this.publicKey = publicKey; + } + + public String getPrivateKey() { + return privateKey; + } + + public void setPrivateKey(String privateKey) { + this.privateKey = privateKey; + } + + public String getClientCertCA() { + return clientCertCA; + } + + public void setClientCertCA(String clientCertCA) { + this.clientCertCA = clientCertCA; + } + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/AddPolicyRequest.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/AddPolicyRequest.java new file mode 100644 index 00000000..1fc82d9b --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/AddPolicyRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseRequest; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +/** + * Represent the add policy request. + */ +@Builder +@Getter +public class AddPolicyRequest extends BaseRequest { + @NonNull + private final String topicFilter; + private final String desc; + @NonNull + private final Permission permission; +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/AddPolicyResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/AddPolicyResponse.java new file mode 100644 index 00000000..f3f3bae0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/AddPolicyResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Represent the response to add policy. + */ +@Getter +@Setter +@ToString +public class AddPolicyResponse extends BaseResponse { + private String policyId; + private long createTs; +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/AlgorithmType.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/AlgorithmType.java new file mode 100644 index 00000000..54609ad3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/AlgorithmType.java @@ -0,0 +1,21 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +/** + * Represent the kind of signature algorithm type. + */ +public enum AlgorithmType { + SHA256, + MD5 +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/AuthType.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/AuthType.java new file mode 100644 index 00000000..3f76f936 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/AuthType.java @@ -0,0 +1,21 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +/** + * Represent the kind of device auth type. + */ +public enum AuthType { + SIGNATURE, + CERTIFICATE +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateDeviceRequest.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateDeviceRequest.java new file mode 100644 index 00000000..614aaa3c --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateDeviceRequest.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseRequest; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +import java.util.Map; + +/** + * Represent the create device request. + */ +@Getter +@Builder +public class CreateDeviceRequest extends BaseRequest { + @NonNull + private final String name; + private final String desc; + @NonNull + private final String templateId; + private final AuthType authType; + private final String secretKey; + private final String groupKey; + private final Map tags; + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateDeviceResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateDeviceResponse.java new file mode 100644 index 00000000..1a3e1a2a --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateDeviceResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +/** + * Represent the response to create device. + */ +@Getter +@Setter +@ToString +public class CreateDeviceResponse extends BaseResponse { + + private String name; + + private String desc; + + private String groupKey; + + private Map tags; + + private Long createTs; + + private AuthType authType; + + private String secretKey; + + private String privateKey; + + private String clientCert; + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateTemplateRequest.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateTemplateRequest.java new file mode 100644 index 00000000..dd5528c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateTemplateRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseRequest; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +/** + * Represent the create template request. + */ +@Getter +@Builder +public class CreateTemplateRequest extends BaseRequest { + @NonNull + private final String name; +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateTemplateResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateTemplateResponse.java new file mode 100644 index 00000000..ba2f7387 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/CreateTemplateResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Represent the response to create template. + */ +@Getter +@Setter +@ToString +public class CreateTemplateResponse extends BaseResponse { + private String id; + private String name; + private long createTs; +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/GetDeviceResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/GetDeviceResponse.java new file mode 100644 index 00000000..aaf593b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/GetDeviceResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +/** + * Represent the response to get device. + */ +@Getter +@Setter +@ToString +public class GetDeviceResponse extends BaseResponse { + + private String name; + + private String desc; + + private Long createTs; + + private Long updateTs; + + private String authType; + + private String templateId; + + private String groupKey; + + private Map tags; + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/GetDeviceSignatureResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/GetDeviceSignatureResponse.java new file mode 100644 index 00000000..356de8e6 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/GetDeviceSignatureResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Represent the response to get device signature. + */ +@Getter +@Setter +@ToString +public class GetDeviceSignatureResponse extends BaseResponse { + + private String signature; + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/GetPolicyResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/GetPolicyResponse.java new file mode 100644 index 00000000..3fd7936d --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/GetPolicyResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Represent the response to get policy. + */ +@Getter +@Setter +@ToString +public class GetPolicyResponse { + private String id; + private String topicFilter; + private String desc; + private String type; + private String permission; + private Long createTs; + private Long updateTs; +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/GetTemplateResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/GetTemplateResponse.java new file mode 100644 index 00000000..b748a16e --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/GetTemplateResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * Represent the response to get template. + */ +@Getter +@Setter +@ToString +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetTemplateResponse extends BaseResponse { + private String templateId; + private String name; + private Long createTs; + private Long updateTs; + private List policies; +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/PaginationResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/PaginationResponse.java new file mode 100644 index 00000000..1b2ff87d --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/PaginationResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * Represent the response to pagination data. + */ +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class PaginationResponse extends BaseResponse { + private List data; + private long total; + private long pageNo; + private int pageSize; + private String order; + private String orderBy; +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/Permission.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/Permission.java new file mode 100644 index 00000000..e9317b5e --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/Permission.java @@ -0,0 +1,7 @@ +package com.baidubce.services.iothub.model.iotcore; + +public enum Permission { + PUB, + SUB, + ALL +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/ResetDeviceSecretResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/ResetDeviceSecretResponse.java new file mode 100644 index 00000000..1ccfeb75 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/ResetDeviceSecretResponse.java @@ -0,0 +1,36 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Represent the response to reset device secret. + */ +@Getter +@Setter +@ToString +public class ResetDeviceSecretResponse extends BaseResponse { + + private String authType; + + private String secretKey; + + private String privateKey; + + private String clientCert; + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/ScrollPaginationResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/ScrollPaginationResponse.java new file mode 100644 index 00000000..6cabe0ef --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/ScrollPaginationResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; + +/** + * Represent the response to scroll pagination data. + */ +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class ScrollPaginationResponse extends BaseResponse { + private List data; + private long total; + private Integer pageSize; + private long createTimeBefore; +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/SecretKeyRequest.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/SecretKeyRequest.java new file mode 100644 index 00000000..403ef67f --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/SecretKeyRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseRequest; +import lombok.Builder; +import lombok.Getter; + +/** + * Represent the secret key request. + */ +@Getter +@Builder +public class SecretKeyRequest extends BaseRequest { + + private final String secretKey; + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/UpdateDeviceRequest.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/UpdateDeviceRequest.java new file mode 100644 index 00000000..7f66dbe3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/UpdateDeviceRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseRequest; +import lombok.Builder; +import lombok.Getter; + +import java.util.Map; + +/** + * Represent the update device request. + */ +@Getter +@Builder +public class UpdateDeviceRequest extends BaseRequest { + + private final String desc; + + private final String groupKey; + + private final Map tags; + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/UpdateDeviceResponse.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/UpdateDeviceResponse.java new file mode 100644 index 00000000..6b925cba --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/UpdateDeviceResponse.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +/** + * Represent the response to update device. + */ +@Getter +@Setter +@ToString +public class UpdateDeviceResponse extends BaseResponse { + + private String name; + + private String desc; + + private String groupKey; + + private Map tags; + +} diff --git a/src/main/java/com/baidubce/services/iothub/model/iotcore/UpdatePolicyRequest.java b/src/main/java/com/baidubce/services/iothub/model/iotcore/UpdatePolicyRequest.java new file mode 100644 index 00000000..131d38c4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iothub/model/iotcore/UpdatePolicyRequest.java @@ -0,0 +1,28 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iothub.model.iotcore; + +import com.baidubce.services.iothub.model.BaseRequest; +import lombok.Builder; +import lombok.Getter; + +/** + * Represent the update policy request. + */ +@Getter +@Builder +public class UpdatePolicyRequest extends BaseRequest { + private final String topicFilter; + private final String desc; + private final Permission permission; +} diff --git a/src/main/java/com/baidubce/services/iotshc/IotShcClient.java b/src/main/java/com/baidubce/services/iotshc/IotShcClient.java new file mode 100644 index 00000000..29096c94 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/IotShcClient.java @@ -0,0 +1,328 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotshc.model.CommonListRequest; +import com.baidubce.services.iotshc.model.CommonResponse; +import com.baidubce.services.iotshc.model.CommonResult; +import com.baidubce.services.iotshc.model.ai.TtsServiceRequest; +import com.baidubce.services.iotshc.model.ai.TtsServiceResponse; +import com.baidubce.services.iotshc.model.ai.UnitServiceRequest; +import com.baidubce.services.iotshc.model.ai.UnitServiceResponse; +import com.baidubce.services.iotshc.model.deivce.DeviceInfo; +import com.baidubce.services.iotshc.model.deivce.DeviceInfoListRequest; +import com.baidubce.services.iotshc.model.deivce.DeviceInfoListResponse; +import com.baidubce.services.iotshc.model.deivce.ImportBatchDevicesRequest; +import com.baidubce.services.iotshc.model.factory.FactoryInfo; +import com.baidubce.services.iotshc.model.factory.FactoryInfoListResponse; +import com.baidubce.services.iotshc.model.factory.UpdateFactoryInfoRequest; +import com.baidubce.services.iotshc.model.mqtt.GetMqttInfoRequest; +import com.baidubce.services.iotshc.model.mqtt.GetMqttInfoResponse; +import com.baidubce.services.iotshc.model.mqtt.SendMessageRequest; +import com.baidubce.services.iotshc.model.product.ProductKeyInfo; +import com.baidubce.services.iotshc.model.product.ProductKeyInfoListRequest; +import com.baidubce.services.iotshc.model.product.ProductKeyInfoListResponse; +import com.baidubce.services.iotshc.model.product.ProductKeyTypeListResponse; +import com.baidubce.services.iotshc.model.product.UpdateProductKeyInfoRequest; +import com.baidubce.services.iotshc.model.token.GetTokenRequest; +import com.baidubce.services.iotshc.model.token.GetTokenResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Provides the client for accessing the IotShc. + */ +public class IotShcClient extends AbstractBceClient { + + private static final String ENDPOINT = "smarthome.baidubce.com"; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + private static final String VERSION = "v1"; + private static final String MANAGE = "manage"; + private static final String MESSAGE = "message"; + private static final String SERVICE = "service"; + + private static final String FACTORY = "factory"; + + private static final String PRODUCT = "product"; + private static final String PRODUCT_TYPES = "types"; + + private static final String DEVICE = "device"; + private static final String DELETE_BATCH_DEVICE = "delete/batch"; + private static final String DISABLE_DEVICE = "disable"; + private static final String ENABLE_DEVICE = "enable"; + private static final String TOKEN = "token"; + + private static final String MQTT = "mqtt"; + + private static final String SEND = "send"; + private static final String BROADCAST = "broadcast"; + + private static final String UNIT = "unit"; + private static final String TTS = "tts"; + + /** + * Responsible for handling HttpResponse. + */ + private static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; + + public IotShcClient(String accessKey, String secretKey) { + this(new BceClientConfiguration() + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)) + .withEndpoint(ENDPOINT)); + } + + public IotShcClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, HANDLERS); + } + + public CommonResult deleteFactoryInfo(String fc) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + MANAGE, FACTORY, fc); + return invokeHttpClient(internalRequest, CommonResult.class); + } + + public FactoryInfo updateFactoryInfo(String fc, UpdateFactoryInfoRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + MANAGE, FACTORY, fc); + return invokeHttpClient(internalRequest, FactoryInfo.class); + } + + public FactoryInfo getFactoryInfo(String fc) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + MANAGE, FACTORY, fc); + return invokeHttpClient(internalRequest, FactoryInfo.class); + } + + public FactoryInfoListResponse listFactoryInfo(CommonListRequest request) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + MANAGE, FACTORY); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + return invokeHttpClient(internalRequest, FactoryInfoListResponse.class); + } + + public CommonResult deleteProductKey(String fc, String pk) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + MANAGE, PRODUCT, fc, pk); + return invokeHttpClient(internalRequest, CommonResult.class); + } + + public ProductKeyInfo updateProductKeyInfo(String fc, String pk, UpdateProductKeyInfoRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.PUT, + MANAGE, PRODUCT, fc, pk); + return invokeHttpClient(internalRequest, ProductKeyInfo.class); + } + + public ProductKeyInfo getProductKeyInfo(String fc, String pk) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + MANAGE, PRODUCT, fc, pk); + return invokeHttpClient(internalRequest, ProductKeyInfo.class); + } + + public ProductKeyInfoListResponse listProductKeyInfo(ProductKeyInfoListRequest request) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + MANAGE, PRODUCT); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + if (StringUtils.isNotEmpty(request.getFc())) { + internalRequest.addParameter("fc", request.getFc()); + } + return invokeHttpClient(internalRequest, ProductKeyInfoListResponse.class); + } + + public ProductKeyTypeListResponse listProductKeyType(CommonListRequest request) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + MANAGE, PRODUCT, PRODUCT_TYPES); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + return invokeHttpClient(internalRequest, ProductKeyTypeListResponse.class); + } + + public CommonResponse importBatchDevices(ImportBatchDevicesRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + MANAGE, DEVICE); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResult deleteDeviceInfo(String fc, String pk, String ak) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + MANAGE, DEVICE, fc, pk, ak); + return invokeHttpClient(internalRequest, CommonResult.class); + } + + public CommonResult deleteDevices(String fc, String pk) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.DELETE, + MANAGE, DEVICE, fc, pk, DELETE_BATCH_DEVICE); + return invokeHttpClient(internalRequest, CommonResult.class); + } + + public CommonResult banDevice(String fc, String pk, String ak) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, + MANAGE, DEVICE, fc, pk, ak, DISABLE_DEVICE); + return invokeHttpClient(internalRequest, CommonResult.class); + } + + public CommonResult activeDevice(String fc, String pk, String ak) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.PUT, + MANAGE, DEVICE, fc, pk, ak, ENABLE_DEVICE); + return invokeHttpClient(internalRequest, CommonResult.class); + } + + public DeviceInfo getDeviceInfo(String fc, String pk, String ak) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + MANAGE, DEVICE, fc, pk, ak); + return invokeHttpClient(internalRequest, DeviceInfo.class); + } + + public DeviceInfoListResponse listDeviceInfo(DeviceInfoListRequest request) { + InternalRequest internalRequest = createRequest( + new GenericAccountRequest(), HttpMethodName.GET, + MANAGE, DEVICE); + internalRequest.addParameter("fc", request.getFc()); + internalRequest.addParameter("pk", request.getPk()); + internalRequest.addParameter("pageNo", Integer.toString(request.getPageNo())); + internalRequest.addParameter("pageSize", Integer.toString(request.getPageSize())); + if (StringUtils.isNotEmpty(request.getState())) { + internalRequest.addParameter("state", request.getState()); + } + if (StringUtils.isNotEmpty(request.getOrder())) { + internalRequest.addParameter("order", request.getOrder()); + } + return invokeHttpClient(internalRequest, DeviceInfoListResponse.class); + } + + public GetTokenResponse getToken(int tokenLifeSpanInDays) { + GetTokenRequest request = new GetTokenRequest(tokenLifeSpanInDays); + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + MANAGE, DEVICE, TOKEN); + return invokeHttpClient(internalRequest, GetTokenResponse.class); + } + + public GetMqttInfoResponse getMqttInfo(GetMqttInfoRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + MANAGE, MQTT); + return invokeHttpClient(internalRequest, GetMqttInfoResponse.class); + } + + public CommonResponse sendMqttMessage(SendMessageRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + MESSAGE, SEND); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse broadcastMqttMessage(SendMessageRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + MESSAGE, BROADCAST); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse sendTtsMessage(SendMessageRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + MESSAGE, TTS, SEND); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse broadcastTtsMessage(SendMessageRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + MESSAGE, TTS, BROADCAST); + return invokeHttpClient(internalRequest, CommonResponse.class); + } + + public UnitServiceResponse invokeUnit(UnitServiceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + SERVICE, UNIT); + return invokeHttpClient(internalRequest, UnitServiceResponse.class); + } + + public TtsServiceResponse invokeTts(TtsServiceRequest request) { + InternalRequest internalRequest = createRequest( + request, HttpMethodName.POST, + SERVICE, TTS); + return invokeHttpClient(internalRequest, TtsServiceResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, request); + } + return request; + } + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/CommonListRequest.java b/src/main/java/com/baidubce/services/iotshc/model/CommonListRequest.java new file mode 100644 index 00000000..860f47b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/CommonListRequest.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * common list resource request + */ +@Data +@NoArgsConstructor +public class CommonListRequest { + + private String order = ""; + private String orderBy = ""; + private int pageNo = 1; + private int pageSize = 10; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/CommonResponse.java b/src/main/java/com/baidubce/services/iotshc/model/CommonResponse.java new file mode 100644 index 00000000..f1aa946c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/CommonResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * common response with errorCode + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class CommonResponse extends AbstractBceResponse { + + private int code; + private String message; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/CommonResult.java b/src/main/java/com/baidubce/services/iotshc/model/CommonResult.java new file mode 100644 index 00000000..b7f0ec8f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/CommonResult.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * common response + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class CommonResult extends AbstractBceResponse { + + private String result; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/ai/ProcessQueryContent.java b/src/main/java/com/baidubce/services/iotshc/model/ai/ProcessQueryContent.java new file mode 100644 index 00000000..8f9faafd --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/ai/ProcessQueryContent.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.ai; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * unit response content + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProcessQueryContent { + + private int error_code = 0; + private String err_msg = ""; + private String sessionId = ""; + // 技能id + private String origin = ""; + private String detail = null; + private ActionType action_type; + private TtsResp ttsResp; + private List query; + private String intent; + private List slots; + private List custom_reply; + + @Data + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Slot { + private String name; + private String value; + } + + @Data + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + public static class CustomReply { + private String type; + private Object value; + } + + @Data + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + public static class TtsResp { + private String text; + private String param; + } + + public enum ActionType { + asr_none, asrnlp_none, asrnlp_tts, asrnlp_url, asrnlp_mix + } +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/ai/TtsServiceRequest.java b/src/main/java/com/baidubce/services/iotshc/model/ai/TtsServiceRequest.java new file mode 100644 index 00000000..2d84ecfb --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/ai/TtsServiceRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.ai; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * tts service request + */ +@Data +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TtsServiceRequest extends GenericAccountRequest { + + private String fc; + private String pk; + private String ak; + private String text; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/ai/TtsServiceResponse.java b/src/main/java/com/baidubce/services/iotshc/model/ai/TtsServiceResponse.java new file mode 100644 index 00000000..b629718d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/ai/TtsServiceResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.ai; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * tts service response + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class TtsServiceResponse extends AbstractBceResponse { + + private int error_code; + private String url; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/ai/UnitServiceRequest.java b/src/main/java/com/baidubce/services/iotshc/model/ai/UnitServiceRequest.java new file mode 100644 index 00000000..6edb27f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/ai/UnitServiceRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.ai; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * unit service request + */ +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UnitServiceRequest extends GenericAccountRequest { + + private String fc; + private String pk; + private String ak; + private String query; + + // optional parameter + private String sessionId = null; + private String custom = ""; + private boolean detail = false; + + public UnitServiceRequest(String fc, String pk, String ak, String query) { + this.fc = fc; + this.pk = pk; + this.ak = ak; + this.query = query; + } +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/ai/UnitServiceResponse.java b/src/main/java/com/baidubce/services/iotshc/model/ai/UnitServiceResponse.java new file mode 100644 index 00000000..2c18981d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/ai/UnitServiceResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.ai; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * unit service response + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class UnitServiceResponse extends AbstractBceResponse { + + private int error_code = 0; + private String err_msg; + private ProcessQueryContent content; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/deivce/DeviceInfo.java b/src/main/java/com/baidubce/services/iotshc/model/deivce/DeviceInfo.java new file mode 100644 index 00000000..af07b213 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/deivce/DeviceInfo.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.deivce; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * device information + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceInfo extends AbstractBceResponse { + + private String accountUuid; + private String fc; + private String pk; + private String ak; + private String sk; + private String state; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/deivce/DeviceInfoListRequest.java b/src/main/java/com/baidubce/services/iotshc/model/deivce/DeviceInfoListRequest.java new file mode 100644 index 00000000..28bdfa0b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/deivce/DeviceInfoListRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.deivce; + +import com.baidubce.services.iotshc.model.CommonListRequest; +import lombok.Data; + +/** + * list device information request + */ +@Data +public class DeviceInfoListRequest extends CommonListRequest { + + private String fc; + private String pk; + private String state; + + public DeviceInfoListRequest(String fc, String pk) { + this.fc = fc; + this.pk = pk; + } +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/deivce/DeviceInfoListResponse.java b/src/main/java/com/baidubce/services/iotshc/model/deivce/DeviceInfoListResponse.java new file mode 100644 index 00000000..b417491f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/deivce/DeviceInfoListResponse.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.deivce; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * list device information response + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceInfoListResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; + private String fc; + private String fcName; + private String pk; + private String devSku; + private String orderBy; + private String order; + private String state; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/deivce/ImportBatchDevicesRequest.java b/src/main/java/com/baidubce/services/iotshc/model/deivce/ImportBatchDevicesRequest.java new file mode 100644 index 00000000..6ba0ab66 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/deivce/ImportBatchDevicesRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.deivce; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +/** + * import devices request + */ +@Data +@AllArgsConstructor +public class ImportBatchDevicesRequest extends GenericAccountRequest { + + private String fc; + private String pk; + private List devices; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/factory/FactoryInfo.java b/src/main/java/com/baidubce/services/iotshc/model/factory/FactoryInfo.java new file mode 100644 index 00000000..a254daa8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/factory/FactoryInfo.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.factory; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * factory information + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class FactoryInfo extends AbstractBceResponse { + + private String accountUuid; + private String fc; + private String name; + private String description; + private boolean enableDelete; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/factory/FactoryInfoListResponse.java b/src/main/java/com/baidubce/services/iotshc/model/factory/FactoryInfoListResponse.java new file mode 100644 index 00000000..63b5271d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/factory/FactoryInfoListResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.factory; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * list factory information response + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class FactoryInfoListResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/factory/UpdateFactoryInfoRequest.java b/src/main/java/com/baidubce/services/iotshc/model/factory/UpdateFactoryInfoRequest.java new file mode 100644 index 00000000..d334ec79 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/factory/UpdateFactoryInfoRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.factory; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * update factory information request + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateFactoryInfoRequest extends GenericAccountRequest { + + private String name = null; + private String description = null; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/mqtt/GetMqttInfoRequest.java b/src/main/java/com/baidubce/services/iotshc/model/mqtt/GetMqttInfoRequest.java new file mode 100644 index 00000000..1dbd540a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/mqtt/GetMqttInfoRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.mqtt; + +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotshc.utils.CommonUtils; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; + +/** + * get device mqtt connection information request + */ +@Getter +public class GetMqttInfoRequest extends GenericAccountRequest { + + private String fc; + private String pk; + private String ak; + private String signature; + @JsonProperty(value = "time_stamp") + private long timestamp; + + public GetMqttInfoRequest(String fc, String pk, String ak, String sk) { + this.fc = fc; + this.pk = pk; + this.ak = ak; + this.timestamp = CommonUtils.getCurrentTimeMinutes(); + this.signature = CommonUtils.getSignature(ak, timestamp, sk); + } +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/mqtt/GetMqttInfoResponse.java b/src/main/java/com/baidubce/services/iotshc/model/mqtt/GetMqttInfoResponse.java new file mode 100644 index 00000000..ed5171a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/mqtt/GetMqttInfoResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.mqtt; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * get device mqtt connection information response + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetMqttInfoResponse extends AbstractBceResponse { + + private String broker; + private String user; + private String pass; + private String clientID; + private String broadcastTopic; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/mqtt/SendMessageRequest.java b/src/main/java/com/baidubce/services/iotshc/model/mqtt/SendMessageRequest.java new file mode 100644 index 00000000..27c0c56f --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/mqtt/SendMessageRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.mqtt; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * send message to device by mqtt request + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SendMessageRequest extends GenericAccountRequest { + + private String fc; + private String pk; + private String ak; + private String message; + @JsonProperty("trannum") + private Integer tranNum; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyInfo.java b/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyInfo.java new file mode 100644 index 00000000..14de28f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyInfo.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * product key information + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductKeyInfo extends AbstractBceResponse { + + private String accountUuid; + private String fc; + private String fcName; + private String pk; + private String devSku; + private String devType; + private String description; + private int pid; + private String key; + private String unitServiceId; + private String unitUsid; + private String kafka; + private String asrKafka; + private boolean enableDelete; + private String unitContext; + private String createTime; + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyInfoListRequest.java b/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyInfoListRequest.java new file mode 100644 index 00000000..1acc7fc9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyInfoListRequest.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.product; + +import com.baidubce.services.iotshc.model.CommonListRequest; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * list product key information request + */ +@Data +@NoArgsConstructor +public class ProductKeyInfoListRequest extends CommonListRequest { + + private String fc; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyInfoListResponse.java b/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyInfoListResponse.java new file mode 100644 index 00000000..179449f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyInfoListResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * list product key information response + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductKeyInfoListResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; + private String fc; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyTypeListResponse.java b/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyTypeListResponse.java new file mode 100644 index 00000000..c4121cc8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/product/ProductKeyTypeListResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.product; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * list product key type response + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductKeyTypeListResponse extends AbstractBceResponse { + + private int totalCount; + private List result; + private int pageNo; + private int pageSize; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/product/UpdateProductKeyInfoRequest.java b/src/main/java/com/baidubce/services/iotshc/model/product/UpdateProductKeyInfoRequest.java new file mode 100644 index 00000000..c054f80e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/product/UpdateProductKeyInfoRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.product; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * update product key information request + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateProductKeyInfoRequest extends GenericAccountRequest { + + private String devSku = null; + private String devType = null; + private String kafka = null; + private String asrKafka = null; + private String description = null; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/token/GetTokenRequest.java b/src/main/java/com/baidubce/services/iotshc/model/token/GetTokenRequest.java new file mode 100644 index 00000000..16c0f26a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/token/GetTokenRequest.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.token; + +import com.baidubce.model.GenericAccountRequest; +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * get token request + */ +@Data +@AllArgsConstructor +public class GetTokenRequest extends GenericAccountRequest { + + private int tokenLifeSpanInDays; +} diff --git a/src/main/java/com/baidubce/services/iotshc/model/token/GetTokenResponse.java b/src/main/java/com/baidubce/services/iotshc/model/token/GetTokenResponse.java new file mode 100644 index 00000000..abcb7cdb --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/model/token/GetTokenResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.model.token; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * get token response + */ +@Data +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetTokenResponse extends AbstractBceResponse { + + private String token; +} diff --git a/src/main/java/com/baidubce/services/iotshc/utils/CommonUtils.java b/src/main/java/com/baidubce/services/iotshc/utils/CommonUtils.java new file mode 100644 index 00000000..251babcb --- /dev/null +++ b/src/main/java/com/baidubce/services/iotshc/utils/CommonUtils.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotshc.utils; + +import org.apache.commons.codec.binary.Hex; +import org.apache.commons.codec.binary.StringUtils; +import org.apache.commons.codec.digest.DigestUtils; + +/** + * common utilities + */ +public class CommonUtils { + + public static String getSignature(String ak, Long ts, String sk) { + if (org.apache.commons.lang3.StringUtils.isEmpty(ak) + || org.apache.commons.lang3.StringUtils.isEmpty(sk)) { + return ""; + } + String srcStr = String.format("%s&%d", ak, ts); + return Hex.encodeHexString(DigestUtils.md5(StringUtils.getBytesUtf8(srcStr + sk))); + } + + public static long getCurrentTimeMinutes() { + return System.currentTimeMillis() / 60000; + } +} diff --git a/src/main/java/com/baidubce/services/iotsmsreceiver/IotSmsReceiverClient.java b/src/main/java/com/baidubce/services/iotsmsreceiver/IotSmsReceiverClient.java new file mode 100644 index 00000000..fbfb554d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotsmsreceiver/IotSmsReceiverClient.java @@ -0,0 +1,130 @@ +package com.baidubce.services.iotsmsreceiver; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotalarm.model.CommonResponse; +import com.baidubce.services.iotalarm.model.UuidResponse; +import com.baidubce.services.iotsmsreceiver.model.CreateIotSmsReceiverRequest; +import com.baidubce.services.iotsmsreceiver.model.IotSmsReceiver; +import com.baidubce.services.iotsmsreceiver.model.ListIotSmsReceiverRequest; +import com.baidubce.services.iotsmsreceiver.model.ListIotSmsReceiverResponse; +import com.baidubce.services.iotsmsreceiver.model.UpdateIotSmsReceiverRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yuanyoujun on 2017/8/13. + */ +public class IotSmsReceiverClient extends AbstractBceClient { + private static final String ENDPOINT = "re.iot.gz.baidubce.com"; + private static final String VERSION = "v1"; + private static final String SMSRECEIVER = "smsreceiver"; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + + private static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; + + public IotSmsReceiverClient(BceClientConfiguration config) { + + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, HANDLERS); + } + + public IotSmsReceiverClient(String accessKey, String secretKey) { + this(new BceClientConfiguration() + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)) + .withEndpoint(ENDPOINT)); + } + + public ListIotSmsReceiverResponse list(ListIotSmsReceiverRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.GET, SMSRECEIVER); + + if (request.getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + return this.invokeHttpClient(internalRequest, ListIotSmsReceiverResponse.class); + } + + public IotSmsReceiver get(String uuid) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.GET, SMSRECEIVER, uuid); + return this.invokeHttpClient(internalRequest, IotSmsReceiver.class); + } + + public UuidResponse create(CreateIotSmsReceiverRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.POST, SMSRECEIVER); + return this.invokeHttpClient(internalRequest, UuidResponse.class); + } + + public CommonResponse update(UpdateIotSmsReceiverRequest req, String uuid) { + InternalRequest internalRequest = + createRequest(req, HttpMethodName.PUT, SMSRECEIVER, uuid); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse delete(String uuid) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, SMSRECEIVER, uuid); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, request); + } + + return request; + } + + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/iotsmsreceiver/model/CreateIotSmsReceiverRequest.java b/src/main/java/com/baidubce/services/iotsmsreceiver/model/CreateIotSmsReceiverRequest.java new file mode 100644 index 00000000..f145cf3b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotsmsreceiver/model/CreateIotSmsReceiverRequest.java @@ -0,0 +1,47 @@ +package com.baidubce.services.iotsmsreceiver.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/8/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateIotSmsReceiverRequest extends GenericAccountRequest { + private String name; + private String signature; + private String template; + private String receivers; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public String getTemplate() { + return template; + } + + public void setTemplate(String template) { + this.template = template; + } + + public String getReceivers() { + return receivers; + } + + public void setReceivers(String receivers) { + this.receivers = receivers; + } +} diff --git a/src/main/java/com/baidubce/services/iotsmsreceiver/model/IotSmsReceiver.java b/src/main/java/com/baidubce/services/iotsmsreceiver/model/IotSmsReceiver.java new file mode 100644 index 00000000..4ecd12c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotsmsreceiver/model/IotSmsReceiver.java @@ -0,0 +1,65 @@ +package com.baidubce.services.iotsmsreceiver.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/8/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class IotSmsReceiver extends AbstractBceResponse { + private String uuid; + private String accountUuid; + private String name; + private String signature; + private String template; + private String receivers; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getAccountUuid() { + return accountUuid; + } + + public void setAccountUuid(String accountUuid) { + this.accountUuid = accountUuid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public String getTemplate() { + return template; + } + + public void setTemplate(String template) { + this.template = template; + } + + public String getReceivers() { + return receivers; + } + + public void setReceivers(String receivers) { + this.receivers = receivers; + } +} diff --git a/src/main/java/com/baidubce/services/iotsmsreceiver/model/ListIotSmsReceiverRequest.java b/src/main/java/com/baidubce/services/iotsmsreceiver/model/ListIotSmsReceiverRequest.java new file mode 100644 index 00000000..47d4d0c9 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotsmsreceiver/model/ListIotSmsReceiverRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.iotsmsreceiver.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/8/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListIotSmsReceiverRequest extends GenericAccountRequest { + private int pageNo = 1; + private int pageSize = 50; + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/iotsmsreceiver/model/ListIotSmsReceiverResponse.java b/src/main/java/com/baidubce/services/iotsmsreceiver/model/ListIotSmsReceiverResponse.java new file mode 100644 index 00000000..d3008a33 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotsmsreceiver/model/ListIotSmsReceiverResponse.java @@ -0,0 +1,47 @@ +package com.baidubce.services.iotsmsreceiver.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Created by yuanyoujun on 2017/8/13. + */ +public class ListIotSmsReceiverResponse extends AbstractBceResponse { + private List result; + private int totalCount; + private int pageNo; + private int pageSize; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/iotsmsreceiver/model/UpdateIotSmsReceiverRequest.java b/src/main/java/com/baidubce/services/iotsmsreceiver/model/UpdateIotSmsReceiverRequest.java new file mode 100644 index 00000000..8f1d213c --- /dev/null +++ b/src/main/java/com/baidubce/services/iotsmsreceiver/model/UpdateIotSmsReceiverRequest.java @@ -0,0 +1,47 @@ +package com.baidubce.services.iotsmsreceiver.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Created by yuanyoujun on 2017/8/13. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateIotSmsReceiverRequest extends GenericAccountRequest { + private String name; + private String signature; + private String template; + private String receivers; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public String getTemplate() { + return template; + } + + public void setTemplate(String template) { + this.template = template; + } + + public String getReceivers() { + return receivers; + } + + public void setReceivers(String receivers) { + this.receivers = receivers; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/iottimer/IotTimerClient.java b/src/main/java/com/baidubce/services/iottimer/IotTimerClient.java new file mode 100644 index 00000000..ef2d49fd --- /dev/null +++ b/src/main/java/com/baidubce/services/iottimer/IotTimerClient.java @@ -0,0 +1,129 @@ +package com.baidubce.services.iottimer; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.iotalarm.model.CommonResponse; +import com.baidubce.services.iotalarm.model.UuidResponse; +import com.baidubce.services.iottimer.model.CreateIotTimerRequest; +import com.baidubce.services.iottimer.model.IotTimer; +import com.baidubce.services.iottimer.model.ListIotTimerRequest; +import com.baidubce.services.iottimer.model.ListIotTimerResponse; +import com.baidubce.services.iottimer.model.UpdateIotTimerRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +public class IotTimerClient extends AbstractBceClient { + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + private static final String VERSION = "v1"; + private static final String TIMER = "timer"; + private static final String ENDPOINT = "re.iot.gz.baidubce.com"; + + /** + * Responsible for handling HttpResponse from all Tsdb service calls. + */ + private static final HttpResponseHandler[] HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; + + public IotTimerClient(BceClientConfiguration config) { + + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, HANDLERS); + } + + public IotTimerClient(String accessKey, String secretKey) { + this(new BceClientConfiguration() + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)) + .withEndpoint(ENDPOINT)); + } + + public UuidResponse create(CreateIotTimerRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.POST, TIMER); + return this.invokeHttpClient(internalRequest, UuidResponse.class); + } + + public IotTimer get(String uuid) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.GET, TIMER, uuid); + return this.invokeHttpClient(internalRequest, IotTimer.class); + } + + public ListIotTimerResponse list(ListIotTimerRequest request) { + InternalRequest internalRequest = + createRequest(request, HttpMethodName.GET, TIMER); + if (request.getPageNo() > 0) { + internalRequest.addParameter("pageNo", String.valueOf(request.getPageNo())); + } + if (request.getPageSize() > 0) { + internalRequest.addParameter("pageSize", String.valueOf(request.getPageSize())); + } + return this.invokeHttpClient(internalRequest, ListIotTimerResponse.class); + } + + public CommonResponse update(UpdateIotTimerRequest req, String uuid) { + InternalRequest internalRequest = + createRequest(req, HttpMethodName.PUT, TIMER, uuid); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + public CommonResponse delete(String uuid) { + InternalRequest internalRequest = + createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, TIMER, uuid); + return this.invokeHttpClient(internalRequest, CommonResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, request); + } + + return request; + } + + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/iottimer/model/CreateIotTimerRequest.java b/src/main/java/com/baidubce/services/iottimer/model/CreateIotTimerRequest.java new file mode 100644 index 00000000..5f4a5e32 --- /dev/null +++ b/src/main/java/com/baidubce/services/iottimer/model/CreateIotTimerRequest.java @@ -0,0 +1,80 @@ +package com.baidubce.services.iottimer.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateIotTimerRequest extends GenericAccountRequest { + private String name; + private String description; + private long period; + private long beginAt; + private long times; + private String endpointName; + private String topic; + private String msg; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public long getPeriod() { + return period; + } + + public void setPeriod(long period) { + this.period = period; + } + + public long getBeginAt() { + return beginAt; + } + + public void setBeginAt(long beginAt) { + this.beginAt = beginAt; + } + + public long getTimes() { + return times; + } + + public void setTimes(long times) { + this.times = times; + } + + public String getEndpointName() { + return endpointName; + } + + public void setEndpointName(String endpointName) { + this.endpointName = endpointName; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/src/main/java/com/baidubce/services/iottimer/model/IotTimer.java b/src/main/java/com/baidubce/services/iottimer/model/IotTimer.java new file mode 100644 index 00000000..99367c80 --- /dev/null +++ b/src/main/java/com/baidubce/services/iottimer/model/IotTimer.java @@ -0,0 +1,151 @@ +package com.baidubce.services.iottimer.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class IotTimer extends AbstractBceResponse { + public static final String RUNNING = "RUNNING"; + public static final String FINISHED = "FINISHED"; + public static final String DELETED = "DELETED"; + + private String uuid; + private String name; + private String accountUuid; + private String description; + private long beginAt; + private long period; + private long times; + private long executedTimes; + private String endpointName; + private String topic; + private String msg; + private long lastExecuteTime; + private String status; + private String createTime; + private String updateTime; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAccountUuid() { + return accountUuid; + } + + public void setAccountUuid(String accountUuid) { + this.accountUuid = accountUuid; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public long getBeginAt() { + return beginAt; + } + + public void setBeginAt(long beginAt) { + this.beginAt = beginAt; + } + + public long getPeriod() { + return period; + } + + public void setPeriod(long period) { + this.period = period; + } + + public long getTimes() { + return times; + } + + public void setTimes(long times) { + this.times = times; + } + + public long getExecutedTimes() { + return executedTimes; + } + + public void setExecutedTimes(long executedTimes) { + this.executedTimes = executedTimes; + } + + public String getEndpointName() { + return endpointName; + } + + public void setEndpointName(String endpointName) { + this.endpointName = endpointName; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public long getLastExecuteTime() { + return lastExecuteTime; + } + + public void setLastExecuteTime(long lastExecuteTime) { + this.lastExecuteTime = lastExecuteTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public boolean isFinished() { + return FINISHED.equals(status); + } +} diff --git a/src/main/java/com/baidubce/services/iottimer/model/ListIotTimerRequest.java b/src/main/java/com/baidubce/services/iottimer/model/ListIotTimerRequest.java new file mode 100644 index 00000000..878f32ef --- /dev/null +++ b/src/main/java/com/baidubce/services/iottimer/model/ListIotTimerRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.iottimer.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ListIotTimerRequest extends GenericAccountRequest { + private int pageNo = 1; + private int pageSize = 50; + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/iottimer/model/ListIotTimerResponse.java b/src/main/java/com/baidubce/services/iottimer/model/ListIotTimerResponse.java new file mode 100644 index 00000000..6c35bada --- /dev/null +++ b/src/main/java/com/baidubce/services/iottimer/model/ListIotTimerResponse.java @@ -0,0 +1,46 @@ +package com.baidubce.services.iottimer.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListIotTimerResponse extends AbstractBceResponse { + private List result; + private int totalCount; + private int pageNo; + private int pageSize; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/src/main/java/com/baidubce/services/iottimer/model/UpdateIotTimerRequest.java b/src/main/java/com/baidubce/services/iottimer/model/UpdateIotTimerRequest.java new file mode 100644 index 00000000..9462333d --- /dev/null +++ b/src/main/java/com/baidubce/services/iottimer/model/UpdateIotTimerRequest.java @@ -0,0 +1,71 @@ +package com.baidubce.services.iottimer.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateIotTimerRequest extends GenericAccountRequest { + private String name; + private String description; + private long period; + private long times; + private String endpointName; + private String topic; + private String msg; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public long getPeriod() { + return period; + } + + public void setPeriod(long period) { + this.period = period; + } + + public long getTimes() { + return times; + } + + public void setTimes(long times) { + this.times = times; + } + + public String getEndpointName() { + return endpointName; + } + + public void setEndpointName(String endpointName) { + this.endpointName = endpointName; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/src/main/java/com/baidubce/services/iotviz/IotVizClient.java b/src/main/java/com/baidubce/services/iotviz/IotVizClient.java new file mode 100644 index 00000000..c7988b3a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotviz/IotVizClient.java @@ -0,0 +1,124 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.iotviz; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.iotviz.model.CreateTokenRequest; +import com.baidubce.services.iotviz.model.CreateTokenResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import static com.google.common.base.Preconditions.checkArgument; + +/** + * Provides the client for accessing iot viz services. + */ +public class IotVizClient extends AbstractBceClient { + + private static final String ENDPOINT_HOST = "viz.baidubce.com"; + private static final String VERSION = "v2"; + private static final String[] HEADERS_TO_SIGN = {Headers.HOST, Headers.BCE_DATE}; + + private static final String TOKEN = "tokens"; + + /** + * Responsible for handling HttpResponse from all IotViz service calls. + */ + private static final HttpResponseHandler[] IOTVIZ_HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public IotVizClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT_HOST) : config, IOTVIZ_HANDLERS); + } + + /** + * Create a token + * @param ttl - token's time to live, in seconds + * @return a string token + */ + public String createToken(int ttl) { + checkArgument(ttl > 0); + + CreateTokenRequest request = new CreateTokenRequest(); + request.setTtl(ttl); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, null, TOKEN); + CreateTokenResponse response = this.invokeHttpClient(internalRequest, CreateTokenResponse.class); + return response.getToken(); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + SignOptions signOptions, String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + + if (signOptions == null) { + signOptions = SignOptions.DEFAULT; + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + } + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeaderAndBody(bceRequest, request); + } + + return request; + } + + private void fillInHeaderAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] bytes = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(bytes.length)); + request.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(bytes)); + } + + private byte[] toJson(AbstractBceRequest bceRequest) { + String jsonStr = JsonUtils.toJsonString(bceRequest); + try { + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/iotviz/model/CreateTokenRequest.java b/src/main/java/com/baidubce/services/iotviz/model/CreateTokenRequest.java new file mode 100644 index 00000000..792c0aa0 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotviz/model/CreateTokenRequest.java @@ -0,0 +1,18 @@ +package com.baidubce.services.iotviz.model; + +import com.baidubce.services.iothub.model.BaseRequest; + +/** + * Request to create a token + */ +public class CreateTokenRequest extends BaseRequest { + private int ttl; + + public int getTtl() { + return ttl; + } + + public void setTtl(int ttl) { + this.ttl = ttl; + } +} diff --git a/src/main/java/com/baidubce/services/iotviz/model/CreateTokenResponse.java b/src/main/java/com/baidubce/services/iotviz/model/CreateTokenResponse.java new file mode 100644 index 00000000..20723a2b --- /dev/null +++ b/src/main/java/com/baidubce/services/iotviz/model/CreateTokenResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.iotviz.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Response of token create result + */ +public class CreateTokenResponse extends AbstractBceResponse { + private String token; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/IpCollectionClient.java b/src/main/java/com/baidubce/services/ipcollection/IpCollectionClient.java new file mode 100644 index 00000000..b4725493 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/IpCollectionClient.java @@ -0,0 +1,513 @@ +package com.baidubce.services.ipcollection; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.ipcollection.emum.IpCollectionAction; +import com.baidubce.services.ipcollection.model.ipgroup.BindIpSetRequest; +import com.baidubce.services.ipcollection.model.ipgroup.CreateIpAddressGroupRequest; +import com.baidubce.services.ipcollection.model.ipgroup.CreateIpAddressGroupResponse; +import com.baidubce.services.ipcollection.model.ipgroup.DeleteIpGroupRequest; +import com.baidubce.services.ipcollection.model.ipgroup.QueryIpGroupDetailRequest; +import com.baidubce.services.ipcollection.model.ipgroup.QueryIpGroupDetailResponse; +import com.baidubce.services.ipcollection.model.ipgroup.QueryIpGroupListRequest; +import com.baidubce.services.ipcollection.model.ipgroup.QueryIpGroupListResponse; +import com.baidubce.services.ipcollection.model.ipgroup.UnBindIpSetRequest; +import com.baidubce.services.ipcollection.model.ipgroup.UpdateIpGroupRequest; +import com.baidubce.services.ipcollection.model.ipset.AddIpAddressToIpSetRequest; +import com.baidubce.services.ipcollection.model.ipset.CreateIpAddressSetRequest; +import com.baidubce.services.ipcollection.model.ipset.CreateIpAddressSetResponse; +import com.baidubce.services.ipcollection.model.ipset.DeleteIpSetRequest; +import com.baidubce.services.ipcollection.model.ipset.QueryIpSetDetailRequest; +import com.baidubce.services.ipcollection.model.ipset.QueryIpSetDetailResponse; +import com.baidubce.services.ipcollection.model.ipset.QueryIpSetListRequest; +import com.baidubce.services.ipcollection.model.ipset.QueryIpSetListResponse; +import com.baidubce.services.ipcollection.model.ipset.RemoveIpAddressFromIpSetRequest; +import com.baidubce.services.ipcollection.model.ipset.UpdateIpSetRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.baidubce.util.Validate; +import com.google.common.base.Strings; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; + +/** + * Provides the client for accessing the Baidu Cloud network Service param template part. + */ +public class IpCollectionClient extends AbstractBceClient { + + /** + * default version of param template. + */ + private static final String VERSION = "v1"; + + /** + * The headers to sign for the request. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * The header to sign for the request. + */ + private static final String CLIENT_TOKEN = "clientToken"; + + /** + * The default max keys value. + */ + private static final String QUERY_MAX_KEYS_VALUE = "1000"; + + /** + * url prefix. + */ + private static final String IP_SET_URL_PREFIX = "ipSet"; + private static final String IP_GROUP_URL_PREFIX = "ipGroup"; + private static final String IP_ADDRESS = "ipAddress"; + private static final String DELETE_IP_ADDRESS = "deleteIpAddress"; + private static final String MARKER = "marker"; + private static final String MAX_KEYS = "maxKeys"; + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String IP_SET_NAME = "name"; + private static final String IP_GROUP_NAME = "name"; + private static final String IP_VERSION = "ipVersion"; + private static final String IP_ADDRESS_INFO = "ipAddressInfo"; + private static final String IP_SET_IDS = "ipSetIds"; + private static final String IP_SET_ID = "ipSetId"; + private static final String IP_GROUP_ID = "ipGroupId"; + private static final String BIND_IP_SET = "bindIpSet"; + private static final String UN_BIND_IP_SET = "unbindIpSet"; + + private static final HttpResponseHandler[] CONN_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on network. + */ + public IpCollectionClient() { + this(new IpCollectionClientConfiguration()); + } + + /** + * Constructs a new network client using the client configuration to access network. + * + * @param clientConfiguration The network client configuration options controlling how this client + * connects to network + */ + public IpCollectionClient(IpCollectionClientConfiguration clientConfiguration) { + super(clientConfiguration, CONN_HANDLERS); + } + + /** + * create ip address set + * + * @param request request + * @return CreateIpAddressGroupResponse + */ + public CreateIpAddressSetResponse createIpAddressSet(CreateIpAddressSetRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(IP_SET_NAME)); + Validate.checkStringNotEmpty(request.getIpVersion(), checkEmptyExceptionMessageFormat(IP_VERSION)); + Validate.checkListNotEmpty(request.getIpAddressInfo(), checkEmptyExceptionMessageFormat(IP_ADDRESS_INFO)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, IP_SET_URL_PREFIX); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateIpAddressSetResponse.class); + } + + /** + * add ip address to ip set + * + * @param request request + */ + public void addIpAddressToIpSet(AddIpAddressToIpSetRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpSetId(), checkEmptyExceptionMessageFormat(IP_SET_ID)); + Validate.checkListNotEmpty(request.getIpAddressInfo(), checkEmptyExceptionMessageFormat(IP_ADDRESS_INFO)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, IP_SET_URL_PREFIX, request.getIpSetId(), IP_ADDRESS); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * remove ip address from ip set + * + * @param request request + */ + public void removeIpAddressFromIpSet(RemoveIpAddressFromIpSetRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpSetId(), checkEmptyExceptionMessageFormat(IP_SET_ID)); + Validate.checkListNotEmpty(request.getIpAddressInfo(), checkEmptyExceptionMessageFormat(IP_ADDRESS_INFO)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, IP_SET_URL_PREFIX, request.getIpSetId(), DELETE_IP_ADDRESS); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * update ip set + * + * @param request request + */ + public void updateIpSet(UpdateIpSetRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpSetId(), checkEmptyExceptionMessageFormat(IP_SET_ID)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, IP_SET_URL_PREFIX, request.getIpSetId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(IpCollectionAction.modifyAttribute.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * delete ip set by request + * + * @param request request + */ + public void deleteIpSet(DeleteIpSetRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpSetId(), checkEmptyExceptionMessageFormat(IP_SET_ID)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, IP_SET_URL_PREFIX, request.getIpSetId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * delete ip set by ipSetId + * + * @param ipSetId ipSetId + */ + public void deleteIpSet(String ipSetId) { + DeleteIpSetRequest request = new DeleteIpSetRequest(); + request.setIpSetId(ipSetId); + deleteIpSet(request); + } + + /** + * query ip set list + * + * @param request request + * @return QueryIpSetListResponse + */ + public QueryIpSetListResponse queryIpSetList(QueryIpSetListRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, IP_SET_URL_PREFIX, null); + if (!Strings.isNullOrEmpty(request.getIpVersion())) { + internalRequest.addParameter(IP_VERSION, request.getIpVersion()); + } + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } else { + internalRequest.addParameter(MAX_KEYS, QUERY_MAX_KEYS_VALUE); + } + + return invokeHttpClient(internalRequest, QueryIpSetListResponse.class); + } + + /** + * query ip set detail by request + * + * @param request request + * @return QueryIpSetDetailResponse + */ + public QueryIpSetDetailResponse queryIpSetDetail(QueryIpSetDetailRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpSetId(), checkEmptyExceptionMessageFormat(IP_SET_ID)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, IP_SET_URL_PREFIX, request.getIpSetId()); + + return invokeHttpClient(internalRequest, QueryIpSetDetailResponse.class); + } + + /** + * query ip set detail by ipSetId + * + * @param ipSetId ipSetId + * @return QueryIpSetDetailResponse + */ + public QueryIpSetDetailResponse queryIpSetDetail(String ipSetId) { + QueryIpSetDetailRequest request = new QueryIpSetDetailRequest(); + request.setIpSetId(ipSetId); + return queryIpSetDetail(request); + } + + /** + * create ip address group + * + * @param request request + * @return CreateIpAddressGroupResponse + */ + public CreateIpAddressGroupResponse createIpAddressGroup(CreateIpAddressGroupRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(IP_GROUP_NAME)); + Validate.checkStringNotEmpty(request.getIpVersion(), checkEmptyExceptionMessageFormat(IP_VERSION)); + Validate.checkListNotEmpty(request.getIpSetIds(), checkEmptyExceptionMessageFormat(IP_SET_IDS)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, IP_GROUP_URL_PREFIX); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + + return invokeHttpClient(internalRequest, CreateIpAddressGroupResponse.class); + } + + /** + * bind ip set to group + * + * @param request request + */ + public void bindIpSet(BindIpSetRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID)); + Validate.checkListNotEmpty(request.getIpSetIds(), checkEmptyExceptionMessageFormat(IP_SET_IDS)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, IP_GROUP_URL_PREFIX, request.getIpGroupId(), BIND_IP_SET); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + fillPayload(internalRequest, request); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * unbind ip set from group + * + * @param request request + */ + public void unBindIpSet(UnBindIpSetRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID)); + Validate.checkListNotEmpty(request.getIpSetIds(), checkEmptyExceptionMessageFormat(IP_SET_IDS)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, IP_GROUP_URL_PREFIX, request.getIpGroupId(), UN_BIND_IP_SET); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + fillPayload(internalRequest, request); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * update ip group + * + * @param request request + */ + public void updateIpGroup(UpdateIpGroupRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, IP_GROUP_URL_PREFIX, request.getIpGroupId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + internalRequest.addParameter(IpCollectionAction.modifyAttribute.name(), null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * delete ip group by request + * + * @param request request + */ + public void deleteIpGroup(DeleteIpGroupRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, IP_GROUP_URL_PREFIX, request.getIpGroupId()); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * delete ip group by ipGroupId + * + * @param ipGroupId ipGroupId + */ + public void deleteIpGroup(String ipGroupId) { + DeleteIpGroupRequest request = new DeleteIpGroupRequest(); + request.setIpGroupId(ipGroupId); + deleteIpGroup(request); + } + + /** + * query ip group list + * + * @param request request + * @return QueryIpGroupListResponse + */ + public QueryIpGroupListResponse queryIpGroupList(QueryIpGroupListRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, IP_GROUP_URL_PREFIX, null); + if (!Strings.isNullOrEmpty(request.getIpVersion())) { + internalRequest.addParameter(IP_VERSION, request.getIpVersion()); + } + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } else { + internalRequest.addParameter(MAX_KEYS, QUERY_MAX_KEYS_VALUE); + } + + return invokeHttpClient(internalRequest, QueryIpGroupListResponse.class); + } + + /** + * query ip group detail by request + * + * @param request request + * @return QueryIpGroupDetailResponse + */ + public QueryIpGroupDetailResponse queryIpGroupDetail(QueryIpGroupDetailRequest request) { + Validate.checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + Validate.checkStringNotEmpty(request.getIpGroupId(), checkEmptyExceptionMessageFormat(IP_GROUP_ID)); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, IP_GROUP_URL_PREFIX, request.getIpGroupId()); + + return invokeHttpClient(internalRequest, QueryIpGroupDetailResponse.class); + } + + /** + * query ip group detail by ipGroupId + * + * @param ipGroupId ipGroupId + * @return QueryIpGroupDetailResponse + */ + public QueryIpGroupDetailResponse queryIpGroupDetail(String ipGroupId) { + QueryIpGroupDetailRequest request = new QueryIpGroupDetailRequest(); + request.setIpGroupId(ipGroupId); + return queryIpGroupDetail(request); + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * Creates and initializes a new request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/ipcollection/IpCollectionClientConfiguration.java b/src/main/java/com/baidubce/services/ipcollection/IpCollectionClientConfiguration.java new file mode 100644 index 00000000..de8a181b --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/IpCollectionClientConfiguration.java @@ -0,0 +1,9 @@ +package com.baidubce.services.ipcollection; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for param template service + */ +public class IpCollectionClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/ipcollection/emum/IpCollectionAction.java b/src/main/java/com/baidubce/services/ipcollection/emum/IpCollectionAction.java new file mode 100644 index 00000000..f9bfb6a3 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/emum/IpCollectionAction.java @@ -0,0 +1,17 @@ +package com.baidubce.services.ipcollection.emum; + +/** + * ip collection action + */ +public enum IpCollectionAction { + /** + * update specified ip collection name or description + */ + modifyAttribute, + attach, + detach, + bind, + unBind, + bindSg, + bindEsg, +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/ipcollection/model/IpCollectionBindedInstance.java b/src/main/java/com/baidubce/services/ipcollection/model/IpCollectionBindedInstance.java new file mode 100644 index 00000000..d4863c35 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/IpCollectionBindedInstance.java @@ -0,0 +1,24 @@ +package com.baidubce.services.ipcollection.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * Ip Collection Binded Instance + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class IpCollectionBindedInstance { + private String instanceId; + private String instanceType; +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/TemplateIpAddressInfo.java b/src/main/java/com/baidubce/services/ipcollection/model/TemplateIpAddressInfo.java new file mode 100644 index 00000000..76697eee --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/TemplateIpAddressInfo.java @@ -0,0 +1,24 @@ +package com.baidubce.services.ipcollection.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * template ip address info + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class TemplateIpAddressInfo { + private String ipAddress; + private String description; +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/BindIpSetRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/BindIpSetRequest.java new file mode 100644 index 00000000..7e2b4457 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/BindIpSetRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * bind ip set request + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class BindIpSetRequest extends AbstractBceRequest { + private String ipGroupId; + private List ipSetIds; + @JsonIgnore + private String clientToken; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/CreateIpAddressGroupRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/CreateIpAddressGroupRequest.java new file mode 100644 index 00000000..f004a645 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/CreateIpAddressGroupRequest.java @@ -0,0 +1,47 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * create ip address group request + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class CreateIpAddressGroupRequest extends AbstractBceRequest { + private String name; + private String ipVersion; + private List ipSetIds; + private String description; + @JsonIgnore + private String clientToken; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/CreateIpAddressGroupResponse.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/CreateIpAddressGroupResponse.java new file mode 100644 index 00000000..ff4c3bb6 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/CreateIpAddressGroupResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * create ip address group response. + */ +@Getter +@Setter +@ToString +public class CreateIpAddressGroupResponse extends AbstractBceResponse { + private String ipSetId; +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/DeleteIpGroupRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/DeleteIpGroupRequest.java new file mode 100644 index 00000000..fbb48b88 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/DeleteIpGroupRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + + +/** + * delete ip group request + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class DeleteIpGroupRequest extends AbstractBceRequest { + private String ipGroupId; + + @JsonIgnore + private String clientToken; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/IpGroup.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/IpGroup.java new file mode 100644 index 00000000..4094cd12 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/IpGroup.java @@ -0,0 +1,30 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * ip group + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class IpGroup { + private String ipGroupId; + private String name; + private String description; + private String ipVersion; + private List ipSetIds; + private Integer bindedInstanceNum; +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupDetailRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupDetailRequest.java new file mode 100644 index 00000000..18c6c776 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupDetailRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * query ip group detail request. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class QueryIpGroupDetailRequest extends AbstractBceRequest { + + private String ipGroupId; + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupDetailResponse.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupDetailResponse.java new file mode 100644 index 00000000..145a6dc6 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupDetailResponse.java @@ -0,0 +1,21 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.ipcollection.model.IpCollectionBindedInstance; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +@Setter +@Getter +@ToString +public class QueryIpGroupDetailResponse extends AbstractBceResponse { + private String ipGroupId; + private String name; + private String description; + private String ipVersion; + private List ipSetIds; + private List bindedInstances; +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupListRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupListRequest.java new file mode 100644 index 00000000..220a8d2d --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupListRequest.java @@ -0,0 +1,41 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * query ip group list request. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class QueryIpGroupListRequest extends AbstractBceRequest { + private String ipVersion; + private String marker; + private Integer maxKeys = -1; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupListResponse.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupListResponse.java new file mode 100644 index 00000000..2b64a867 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/QueryIpGroupListResponse.java @@ -0,0 +1,22 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * query ip group list response + */ +@Setter +@Getter +@ToString +public class QueryIpGroupListResponse extends AbstractBceResponse { + private List ipGroups; + private String marker; + private boolean isTruncated; + private String nextMarker; + private int maxKeys; +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/UnBindIpSetRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/UnBindIpSetRequest.java new file mode 100644 index 00000000..d066eb68 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/UnBindIpSetRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * un bind ip set request. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class UnBindIpSetRequest extends AbstractBceRequest { + private String ipGroupId; + @JsonIgnore + private String clientToken; + private List ipSetIds; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/UpdateIpGroupRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/UpdateIpGroupRequest.java new file mode 100644 index 00000000..e8a93c5a --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipgroup/UpdateIpGroupRequest.java @@ -0,0 +1,44 @@ +package com.baidubce.services.ipcollection.model.ipgroup; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * update ip group request + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class UpdateIpGroupRequest extends AbstractBceRequest { + private String ipGroupId; + private String name; + private String description; + @JsonIgnore + private String clientToken; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/AddIpAddressToIpSetRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/AddIpAddressToIpSetRequest.java new file mode 100644 index 00000000..39523aa4 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/AddIpAddressToIpSetRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.ipcollection.model.TemplateIpAddressInfo; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; +import java.util.List; + +/** + * AddIpAddressFromIpSet request + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class AddIpAddressToIpSetRequest extends AbstractBceRequest { + private String ipSetId; + @JsonIgnore + private String clientToken; + private List ipAddressInfo; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/CreateIpAddressSetRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/CreateIpAddressSetRequest.java new file mode 100644 index 00000000..1952b79e --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/CreateIpAddressSetRequest.java @@ -0,0 +1,48 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.ipcollection.model.TemplateIpAddressInfo; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * createIPAddressGroup request. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class CreateIpAddressSetRequest extends AbstractBceRequest { + private String name; + private String ipVersion; + private List ipAddressInfo; + private String description; + @JsonIgnore + private String clientToken; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/CreateIpAddressSetResponse.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/CreateIpAddressSetResponse.java new file mode 100644 index 00000000..3dc461a3 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/CreateIpAddressSetResponse.java @@ -0,0 +1,26 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; + +/** + * createIpAddressGroup response. + */ +@Getter +@Setter +public class CreateIpAddressSetResponse extends AbstractBceResponse { + + private String ipSetId; + + /** + * toString + * @return string + */ + @Override + public String toString() { + return "CreateIpAddressGroupResponse{" + + "ipSetId='" + ipSetId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/DeleteIpSetRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/DeleteIpSetRequest.java new file mode 100644 index 00000000..b0a580de --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/DeleteIpSetRequest.java @@ -0,0 +1,42 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * del IpSet request + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class DeleteIpSetRequest extends AbstractBceRequest { + private String ipSetId; + @JsonIgnore + private String clientToken; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/IpSet.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/IpSet.java new file mode 100644 index 00000000..0cab76fd --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/IpSet.java @@ -0,0 +1,31 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.services.ipcollection.model.TemplateIpAddressInfo; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * ip set + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class IpSet { + private String ipSetId; + private String name; + private String description; + private String ipVersion; + private List ipAddressInfo; + private Integer bindedInstanceNum; +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetDetailRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetDetailRequest.java new file mode 100644 index 00000000..493e676c --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetDetailRequest.java @@ -0,0 +1,40 @@ +package com.baidubce.services.ipcollection.model.ipset; + + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * Query IpSet Detail Request. + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class QueryIpSetDetailRequest extends AbstractBceRequest { + private String ipSetId; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetDetailResponse.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetDetailResponse.java new file mode 100644 index 00000000..4c003af1 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetDetailResponse.java @@ -0,0 +1,39 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.ipcollection.model.IpCollectionBindedInstance; +import com.baidubce.services.ipcollection.model.TemplateIpAddressInfo; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * Query IpSet Detail Response + */ +@Getter +@Setter +public class QueryIpSetDetailResponse extends AbstractBceResponse { + private String ipSetId; + private String name; + private String description; + private String ipVersion; + private List ipAddressInfo; + private List bindedInstances; + + /** + * toString + * @return string + */ + @Override + public String toString() { + return "QueryIpSetDetailResponse{" + + "ipSetId='" + ipSetId + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", ipVersion='" + ipVersion + '\'' + + ", ipAddressInfo=" + ipAddressInfo + + ", bindedInstances=" + bindedInstances + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetListRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetListRequest.java new file mode 100644 index 00000000..dab774a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetListRequest.java @@ -0,0 +1,41 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * query ip set request + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class QueryIpSetListRequest extends AbstractBceRequest { + private String ipVersion; + private String marker; + private Integer maxKeys = -1; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetListResponse.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetListResponse.java new file mode 100644 index 00000000..aee2db4b --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/QueryIpSetListResponse.java @@ -0,0 +1,35 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * query ip set list response. + */ +@Getter +@Setter +public class QueryIpSetListResponse extends AbstractBceResponse { + private List ipSets; + private String marker; + private boolean isTruncated; + private String nextMarker; + private Integer maxKeys; + + /** + * toString + * @return string + */ + @Override + public String toString() { + return "QueryIpSetListResponse{" + + "ipSets=" + ipSets + + ", marker='" + marker + '\'' + + ", isTruncated=" + isTruncated + + ", nextMarker='" + nextMarker + '\'' + + ", maxKeys=" + maxKeys + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/RemoveIpAddressFromIpSetRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/RemoveIpAddressFromIpSetRequest.java new file mode 100644 index 00000000..e25d894b --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/RemoveIpAddressFromIpSetRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * RemoveIpAddressFromIpSetRequest request + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class RemoveIpAddressFromIpSetRequest extends AbstractBceRequest { + private String ipSetId; + @JsonIgnore + private String clientToken; + private List ipAddressInfo; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipcollection/model/ipset/UpdateIpSetRequest.java b/src/main/java/com/baidubce/services/ipcollection/model/ipset/UpdateIpSetRequest.java new file mode 100644 index 00000000..abeda9ad --- /dev/null +++ b/src/main/java/com/baidubce/services/ipcollection/model/ipset/UpdateIpSetRequest.java @@ -0,0 +1,44 @@ +package com.baidubce.services.ipcollection.model.ipset; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +/** + * update IpSet request + */ +@Getter +@Setter +@ToString +@Builder +@Accessors(chain = true) +@AllArgsConstructor +@NoArgsConstructor +public class UpdateIpSetRequest extends AbstractBceRequest { + private String ipSetId; + private String name; + private String description; + @JsonIgnore + private String clientToken; + + /** + * {@inheritDoc} + * 重写父类方法,实现AbstractBceRequest接口的withRequestCredentials方法。 + * 该方法用于设置请求凭证(BceCredentials),并返回当前对象自身。 + * + * @param credentials BceCredentials类型的请求凭证 + * @return AbstractBceRequest类型,当前对象自身 + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/Ipv6GatewayClient.java b/src/main/java/com/baidubce/services/ipv6Gateway/Ipv6GatewayClient.java new file mode 100644 index 00000000..7a11624d --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/Ipv6GatewayClient.java @@ -0,0 +1,471 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ipv6Gateway; + +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.ipv6Gateway.model.Billing; +import com.baidubce.services.ipv6Gateway.model.CreateEgressOnlyRuleRequest; +import com.baidubce.services.ipv6Gateway.model.CreateEgressOnlyRuleResponse; +import com.baidubce.services.ipv6Gateway.model.CreateIpv6GatewayRequest; +import com.baidubce.services.ipv6Gateway.model.CreateIpv6GatewayResponse; +import com.baidubce.services.ipv6Gateway.model.CreateRateLimitRuleRequest; +import com.baidubce.services.ipv6Gateway.model.DeleteIpv6EgressOnlyRuleRequest; +import com.baidubce.services.ipv6Gateway.model.DeleteIpv6GatewayRequest; +import com.baidubce.services.ipv6Gateway.model.DeleteIpv6RateLimitRuleRequest; +import com.baidubce.services.ipv6Gateway.model.Ipv6GatewayResponse; +import com.baidubce.services.ipv6Gateway.model.ListEgressOnlyRuleRequest; +import com.baidubce.services.ipv6Gateway.model.ListEgressOnlyRuleResponse; +import com.baidubce.services.ipv6Gateway.model.ListIpv6GatewayRequest; +import com.baidubce.services.ipv6Gateway.model.ListRateLimitRuleResponse; +import com.baidubce.services.ipv6Gateway.model.RateLimitRuleResponse; +import com.baidubce.services.ipv6Gateway.model.ResizeIpv6GatewayRequest; +import com.baidubce.services.ipv6Gateway.model.UpdateRateLimitRuleRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.base.Strings; + +/** + * Provides the client for accessing the Ipv6Gateway Service (Ipv6Gateway). + */ +public class Ipv6GatewayClient extends AbstractBceClient { + /** + * Ipv6Gateway API pathVersion + */ + private static final String VERSION = "v1"; + + private static final String PREFIX = "IPv6Gateway"; + + private static final String EGRESS_ONLY_RULE_PREFIX = "egressOnlyRule"; + + private static final String RATE_LIMIT_RULE_PREFIX = "rateLimitRule"; + + private static final String CLIENT_TOKEN_IDENTIFY = "clientToken"; + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static HttpResponseHandler[] ipv6GatewayHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public Ipv6GatewayClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new InstanceClient to invoke service methods on Ipv6Gateway instance. + * + * @param clientConfiguration The BCE client configuration options. + */ + public Ipv6GatewayClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, ipv6GatewayHandlers); + } + + /** + * Create an Ipv6Gateway with the specified options. + * + * @param vpcId specify the vpc + * @param name specify the name for ipv6Gateway + * @param bandwidthInMbps specify the bandwidth in Mbps + * + * @return + */ + public CreateIpv6GatewayResponse createIpv6Gateway(String vpcId, String name, int bandwidthInMbps) { + Billing billing = new Billing(); + billing.setPaymentTiming("Postpaid"); + return createIpv6Gateway(new CreateIpv6GatewayRequest().withVpcId(vpcId).withName(name).withBandwith + (bandwidthInMbps).withBilling(billing)); + } + + /** + * Create an Ipv6gateway with the specified options. + * This is an asynchronous interface + * + * @param request The request containing all options for creating an Ipv6Gateway. + * + * @return created ipv6Gateway gatewayId + */ + public CreateIpv6GatewayResponse createIpv6Gateway(CreateIpv6GatewayRequest request) { + checkNotNull(request.getName(), "name should not be null"); + checkNotNull(request.getVpcId(), "vpcId should not be null"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, null); + + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + try { + System.out.println(JsonUtils.toJsonPrettyString(internalRequest)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return this.invokeHttpClient(internalRequest, CreateIpv6GatewayResponse.class); + } + + /** + * Resizing Ipv6Gateway + * + * @param ipv6GatewayId ipv6Gateway to be resized + * @param newBandwidthInMbps specify new bandwidth in Mbps for ipv6Gateway + */ + public void resizeIpv6Gateway(String ipv6GatewayId, int newBandwidthInMbps) { + this.resizeIpv6Gateway( + new ResizeIpv6GatewayRequest().withIpv6Gateway(ipv6GatewayId).withBandwidth(newBandwidthInMbps)); + } + + /** + * Resizing Ipv6Gateway + * + * @param request IPv6GatewayId & BandwidthInMbps must be provided + */ + public void resizeIpv6Gateway(ResizeIpv6GatewayRequest request) { + checkStringNotEmpty(request.getIpv6GatewayId(), "ipv6GatewayId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT, request.getIpv6GatewayId()); + internalRequest.addParameter("resize", null); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * delete the Ipv6Gateway + * + * @param gatewayId the ipv6Gateway to be deleted + */ + public void deleteIpv6Gateway(String gatewayId) { + this.deleteIpv6Gateway(new DeleteIpv6GatewayRequest().withGatewayId(gatewayId)); + } + + /** + * delete the Ipv6Gateway + * + * @param request The request containing all options for delete Ipv6Gateway + */ + public void deleteIpv6Gateway(DeleteIpv6GatewayRequest request) { + checkStringNotEmpty(request.getGatewayId(), "gatewayId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.DELETE, request.getGatewayId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * get a list of Ipv6Gateway owned by the authenticated user and default conditions + * + * @return + */ + public Ipv6GatewayResponse getIpv6Gateway(String vpcId) { + ListIpv6GatewayRequest listIpv6GatewayRequest = new ListIpv6GatewayRequest(); + listIpv6GatewayRequest.withRequestVpcId(vpcId); + return getIpv6Gateway(listIpv6GatewayRequest); + } + + /** + * get a single Ipv6Gateway owned by the authenticated user and specified conditions + * + * @return + */ + public Ipv6GatewayResponse getIpv6Gateway(ListIpv6GatewayRequest request) { + checkStringNotEmpty(request.getVpcId(), "vpcId should not be empty"); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, null); + internalRequest.addParameter("vpcId", request.getVpcId()); + return this.invokeHttpClient(internalRequest, Ipv6GatewayResponse.class); + } + + /** + * Add an EgressOnluRule to the Ipv6Gateway with the specified options. + * + * @param gatewayId specify the ipv6GatewayId to add egressOnlyRule + * @param cidr specify the cidr for ipv6Gateway egressOnlyRule + * + * @return the id of EgressOnlyRule + */ + public CreateEgressOnlyRuleResponse craeteEgressOnlyRule(String gatewayId, String cidr) { + CreateEgressOnlyRuleRequest createEgressOnlyRuleRequest = new CreateEgressOnlyRuleRequest(); + createEgressOnlyRuleRequest.setGatewayId(gatewayId); + createEgressOnlyRuleRequest.setCidr(cidr); + + return createEgressOnlyRule(createEgressOnlyRuleRequest); + } + + /** + * Add an EgressOnluRule to the Ipv6Gateway with the specified options. + * + * @param request the request to create Ipv6Gateway egressOnlyRule + * + * @return the id of EgressOnlyRule + */ + public CreateEgressOnlyRuleResponse createEgressOnlyRule(CreateEgressOnlyRuleRequest request) { + checkStringNotEmpty(request.getGatewayId(), "gatewayId should not be empty"); + checkStringNotEmpty(request.getCidr(), "cidr should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = + createRequest(request, HttpMethodName.POST, request.getGatewayId(), EGRESS_ONLY_RULE_PREFIX); + fillPayload(internalRequest, request); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + return invokeHttpClient(internalRequest, CreateEgressOnlyRuleResponse.class); + } + + /** + * Return a list of Ipv6Gateway's egressOnlyRule owned by the authenticated user. + * + * @return The response containing a list of egressOnlyRule owned by the authenticated user. + */ + public ListEgressOnlyRuleResponse listEgressOnlyRule(String gatewayId) { + return this.listEgressOnlyRule(new ListEgressOnlyRuleRequest().withRequestGatewayId(gatewayId)); + } + + /** + * Return a list of Ipv6Gateway's egressOnlyRule owned by the authenticated user. + * + * @param request The request containing all options for listing own's egressOnlyRule. + * + * @return The response containing a list of the Ipv6Gateway's egressOnlyRule owned by the authenticated user. + */ + public ListEgressOnlyRuleResponse listEgressOnlyRule(ListEgressOnlyRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getGatewayId(), "the gatewyId should not be null"); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, request.getGatewayId(), EGRESS_ONLY_RULE_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + + return invokeHttpClient(internalRequest, ListEgressOnlyRuleResponse.class); + } + + /** + * delete the Ipv6Gateway's egressOnlyRule + * + * @param gatewayId the ipv6Gateway's egressOnlyRuleId to be deleted + */ + public void deleteIpv6GatewayEgressOnlyRule(String gatewayId, String egressOnlyRuleId) { + deleteIpv6GatewayEgressOnlyRule(new DeleteIpv6EgressOnlyRuleRequest().withRequestGatewayId(gatewayId) + .wirhRequestEgressOnlyRuleId(egressOnlyRuleId)); + } + + public void deleteIpv6GatewayEgressOnlyRule(DeleteIpv6EgressOnlyRuleRequest deleteIpv6EgressOnlyRuleRequest) { + checkNotNull(deleteIpv6EgressOnlyRuleRequest, "the deleteIpv6EgressOnlyRuleRequest should not be null"); + checkStringNotEmpty(deleteIpv6EgressOnlyRuleRequest.getEgressOnlyRuleId(), "egressOnlyRuleId should not be " + + "empty"); + checkStringNotEmpty(deleteIpv6EgressOnlyRuleRequest.getGatewayId(), "ipv6GatewayId should not be empty"); + if (Strings.isNullOrEmpty(deleteIpv6EgressOnlyRuleRequest.getClientToken())) { + deleteIpv6EgressOnlyRuleRequest.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = + this.createRequest(deleteIpv6EgressOnlyRuleRequest, HttpMethodName.DELETE, + deleteIpv6EgressOnlyRuleRequest.getGatewayId(), EGRESS_ONLY_RULE_PREFIX, + deleteIpv6EgressOnlyRuleRequest.getEgressOnlyRuleId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, deleteIpv6EgressOnlyRuleRequest.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * create the rateLimitRule for the Ipv6Gateway's + */ + public RateLimitRuleResponse createRateLimitRule(CreateRateLimitRuleRequest request) { + checkNotNull(request, "the request should not be null"); + checkStringNotEmpty(request.getGatewayId(), "the gatewayId should not be null"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.POST, + request.getGatewayId(), RATE_LIMIT_RULE_PREFIX); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, RateLimitRuleResponse.class); + } + + /** + * update the rateLimitRule for the Ipv6Gateway's + */ + public void updateRateLimitRule(UpdateRateLimitRuleRequest request) { + checkNotNull(request, "the request should not be null"); + checkStringNotEmpty(request.getGatewayId(), "the gatewayId should not be null"); + checkStringNotEmpty(request.getRateLimitRuleId(), "the rateLimitRuleId should not be null"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, + request.getGatewayId(), RATE_LIMIT_RULE_PREFIX, request.getRateLimitRuleId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * delete the Ipv6Gateway's rateLimitRule + * + * @param gatewayId the ipv6Gateway's rateLimitRule to be deleted + */ + public void deleteIpv6GatewayRateLimitRule(String gatewayId, String rateLimitRuleId) { + deleteIpv6GatewayEgressOnlyRule(new DeleteIpv6RateLimitRuleRequest().withRequestGatewayId(gatewayId) + .withRequestRateLimitRuleId(rateLimitRuleId)); + } + + public void deleteIpv6GatewayEgressOnlyRule(DeleteIpv6RateLimitRuleRequest request) { + checkNotNull(request, "the deleteIpv6EgressOnlyRuleRequest should not be null"); + checkStringNotEmpty(request.getRateLimitRuleId(), "rateLimitRuleId should not be empty"); + checkStringNotEmpty(request.getGatewayId(), "ipv6GatewayId should not be empty"); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(generateDefaultClientToken()); + } + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, + request.getGatewayId(), RATE_LIMIT_RULE_PREFIX, + request.getRateLimitRuleId()); + internalRequest.addParameter(CLIENT_TOKEN_IDENTIFY, request.getClientToken()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * list ipv6Gateway's rateLimitRule + * + * @param gatewayId the Ipv6Gateway's id + */ + public ListRateLimitRuleResponse listRateLimitRule(String gatewayId) { + return listRateLimitRule(new ListEgressOnlyRuleRequest().withRequestGatewayId(gatewayId)); + } + + public ListRateLimitRuleResponse listRateLimitRule(ListEgressOnlyRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getGatewayId(), "the gatewyId should not be null"); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.GET, request.getGatewayId(), RATE_LIMIT_RULE_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + + return invokeHttpClient(internalRequest, ListRateLimitRuleResponse.class); + + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + path.add(PREFIX); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateDefaultClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * The method to generate a default Billing which is Postpaid. + * + * @return The Billing object with Postpaid PaymentTiming. + */ + private Billing generateDefaultBilling() { + Billing billing = new Billing(); + billing.setPaymentTiming("Postpaid"); + return billing; + } + +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/Ipv6GatewayClientConfiguration.java b/src/main/java/com/baidubce/services/ipv6Gateway/Ipv6GatewayClientConfiguration.java new file mode 100644 index 00000000..1eb9f972 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/Ipv6GatewayClientConfiguration.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.ipv6Gateway; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for Ipv6Gateway service. + */ +public class Ipv6GatewayClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/Billing.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/Billing.java new file mode 100644 index 00000000..dd5d222e --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/Billing.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +/** + * The model for billing information. + */ +public class Billing { + /** + * The pay time of the payment, + */ + private String paymentTiming; + + /** + * The way of ipv6Gateway charging + */ + private String billingMethod; + + /** + * The reservation model to specify the detail to buy. + * be used when Prepaid + */ + private Reservation reservation; + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getBillingMethod() { + return billingMethod; + } + + public void setBillingMethod(String billingMethod) { + this.billingMethod = billingMethod; + } + + public Reservation getReservation() { + return reservation; + } + + public void setReservation(Reservation reservation) { + this.reservation = reservation; + } + + public Billing withPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + return this; + } + + public Billing withBillingMethod(String billingMethod) { + this.billingMethod = billingMethod; + return this; + } + + public Billing withReservation(Reservation reservation) { + this.reservation = reservation; + return this; + } + + /** + * The reservation model to specify the detail to buy. + */ + public static class Reservation { + /** + * purchase length + */ + private int reservationLength; + + /** + * time unit of purchasing,default 'Month' + */ + private String reservationTimeUnit = "Month"; + + public int getReservationLength() { + return reservationLength; + } + + public void setReservationLength(int reservationLength) { + this.reservationLength = reservationLength; + } + + public String getReservationTimeUnit() { + return reservationTimeUnit; + } + + public void setReservationTimeUnit(String reservationTimeUnit) { + this.reservationTimeUnit = reservationTimeUnit; + } + + public Reservation withReservationLength(int reservationLength) { + this.reservationLength = reservationLength; + return this; + } + + public Reservation withReservationTimeUnit(String reservationTimeUnit) { + this.reservationTimeUnit = reservationTimeUnit; + return this; + } + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateEgressOnlyRuleRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateEgressOnlyRuleRequest.java new file mode 100644 index 00000000..a3e94dd0 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateEgressOnlyRuleRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + + +public class CreateEgressOnlyRuleRequest extends AbstractBceRequest { + + private String cidr; + + private String gatewayId; + + private String clientToken; + + @Override + public CreateEgressOnlyRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public CreateEgressOnlyRuleRequest withRequestCidr(String cidr) { + this.cidr = cidr; + return this; + } + + public CreateEgressOnlyRuleRequest withRequestGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + return this; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getCidr() { + return cidr; + } + + public void setCidr(String cidr) { + this.cidr = cidr; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateEgressOnlyRuleResponse.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateEgressOnlyRuleResponse.java new file mode 100644 index 00000000..9f41313a --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateEgressOnlyRuleResponse.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.ToString; + +@ToString +public class CreateEgressOnlyRuleResponse extends AbstractBceResponse { + private String egressOnlyRuleId; + + public String getEgressOnlyRuleId() { + return egressOnlyRuleId; + } + + public void setEgressOnlyRuleId(String egressOnlyRuleId) { + this.egressOnlyRuleId = egressOnlyRuleId; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateIpv6GatewayRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateIpv6GatewayRequest.java new file mode 100644 index 00000000..908ef2b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateIpv6GatewayRequest.java @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for creating a newly Ipv6Gateway. + */ +public class CreateIpv6GatewayRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The name of Ipv6Gateway that will be created. + */ + private String name; + + /** + * The vpcId of this Ipv6Gateway belong. + */ + private String vpcId; + + /** + * The bandwidthInMbps of Ipv6Gateway that will be created. + */ + private int bandwidthInMbps; + + private Billing billing; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * + * @return CreateIpv6GatewayRequest with credentials. + */ + public CreateIpv6GatewayRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure name for the request. + * + * @param name The name of vpc + * + * @return CreateIpv6GatewayRequest with specific name + */ + public CreateIpv6GatewayRequest withName(String name) { + this.name = name; + return this; + } + + /** + * Configure vpcId for the request. + * + * @param vpcId the vpcId of Ipv6Gateway + * + * @return CreateIpv6GatewayRequest with vpcId + */ + public CreateIpv6GatewayRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + /** + * Configure bandwidthInMbps for the request. + * + * @param bandwidthInMbps the bandwidthInMbps of Ipv6Gateway + * + * @return CreateIpv6GatewayRequest with bandwidthInMbps + */ + public CreateIpv6GatewayRequest withBandwith(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + return this; + } + + /** + * Configure bandwidthInMbps for the request. + * + * @param billing the Billing of Ipv6Gateway + * + * @return CreateIpv6GatewayRequest with billing + */ + public CreateIpv6GatewayRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public int getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateIpv6GatewayResponse.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateIpv6GatewayResponse.java new file mode 100644 index 00000000..0b66f451 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateIpv6GatewayResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.model.AbstractBceResponse; + +public class CreateIpv6GatewayResponse extends AbstractBceResponse { + /** + * The Ipv6Gateway's id + */ + private String gatewayId; + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateRateLimitRuleRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateRateLimitRuleRequest.java new file mode 100644 index 00000000..82f19b67 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/CreateRateLimitRuleRequest.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class CreateRateLimitRuleRequest extends AbstractBceRequest { + + private String gatewayId; + private String ipv6Address; + private int ingressBandwidthInMbps; + private int egressBandwidthInMbps; + private String clientToken; + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getIpv6Address() { + return ipv6Address; + } + + public void setIpv6Address(String ipv6Address) { + this.ipv6Address = ipv6Address; + } + + public int getIngressBandwidthInMbps() { + return ingressBandwidthInMbps; + } + + public void setIngressBandwidthInMbps(int ingressBandwidthInMbps) { + this.ingressBandwidthInMbps = ingressBandwidthInMbps; + } + + public int getEgressBandwidthInMbps() { + return egressBandwidthInMbps; + } + + public void setEgressBandwidthInMbps(int egressBandwidthInMbps) { + this.egressBandwidthInMbps = egressBandwidthInMbps; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public CreateRateLimitRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/DeleteIpv6EgressOnlyRuleRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/DeleteIpv6EgressOnlyRuleRequest.java new file mode 100644 index 00000000..bb85c23f --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/DeleteIpv6EgressOnlyRuleRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class DeleteIpv6EgressOnlyRuleRequest extends AbstractBceRequest { + private String gatewayId; + + private String egressOnlyRuleId; + + private String clientToken; + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getEgressOnlyRuleId() { + return egressOnlyRuleId; + } + + public void setEgressOnlyRuleId(String egressOnlyRuleId) { + this.egressOnlyRuleId = egressOnlyRuleId; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public DeleteIpv6EgressOnlyRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public DeleteIpv6EgressOnlyRuleRequest withRequestGatewayId(String gatewayId) { + this.setGatewayId(gatewayId); + return this; + } + + public DeleteIpv6EgressOnlyRuleRequest wirhRequestEgressOnlyRuleId(String egressOnlyRuleId) { + this.egressOnlyRuleId = egressOnlyRuleId; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/DeleteIpv6GatewayRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/DeleteIpv6GatewayRequest.java new file mode 100644 index 00000000..bc829591 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/DeleteIpv6GatewayRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class DeleteIpv6GatewayRequest extends AbstractBceRequest { + String gatewayId; + + private String clientToken; + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public DeleteIpv6GatewayRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public DeleteIpv6GatewayRequest withGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/DeleteIpv6RateLimitRuleRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/DeleteIpv6RateLimitRuleRequest.java new file mode 100644 index 00000000..e980cd69 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/DeleteIpv6RateLimitRuleRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class DeleteIpv6RateLimitRuleRequest extends AbstractBceRequest { + private String gatewayId; + + private String rateLimitRuleId; + + private String clientToken; + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getRateLimitRuleId() { + return rateLimitRuleId; + } + + public void setRateLimitRuleId(String rateLimitRuleId) { + this.rateLimitRuleId = rateLimitRuleId; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public DeleteIpv6RateLimitRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public DeleteIpv6RateLimitRuleRequest withRequestGatewayId(String gatewayId) { + this.setGatewayId(gatewayId); + return this; + } + + public DeleteIpv6RateLimitRuleRequest withRequestRateLimitRuleId(String rateLimitRuleId) { + this.setRateLimitRuleId(rateLimitRuleId); + return this; + } + + public DeleteIpv6RateLimitRuleRequest() { + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/EgressOnlyRule.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/EgressOnlyRule.java new file mode 100644 index 00000000..6d11a0ac --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/EgressOnlyRule.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class EgressOnlyRule { + private String egressOnlyRuleId; + private String cidr; + + public String getEgressOnlyRuleId() { + return egressOnlyRuleId; + } + + public void setEgressOnlyRuleId(String egressOnlyRuleId) { + this.egressOnlyRuleId = egressOnlyRuleId; + } + + public String getCidr() { + return cidr; + } + + public void setCidr(String cidr) { + this.cidr = cidr; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/Ipv6GatewayResponse.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/Ipv6GatewayResponse.java new file mode 100644 index 00000000..510b2e5e --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/Ipv6GatewayResponse.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class Ipv6GatewayResponse extends ListResponse { + private String name; + private String gatewayId; + private int bandwidthInMbps; + private String vpcId; + + private List egressOnlyRules; + private List rateLimitRules; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public int getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public List getEgressOnlyRules() { + return egressOnlyRules; + } + + public void setEgressOnlyRules( + List egressOnlyRules) { + this.egressOnlyRules = egressOnlyRules; + } + + public List getRateLimitRules() { + return rateLimitRules; + } + + public void setRateLimitRules( + List rateLimitRules) { + this.rateLimitRules = rateLimitRules; + } + +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/ListEgressOnlyRuleRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListEgressOnlyRuleRequest.java new file mode 100644 index 00000000..3d15b50f --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListEgressOnlyRuleRequest.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +public class ListEgressOnlyRuleRequest extends ListRequest { + + private String gatewayId; + + @Override + public ListEgressOnlyRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public ListEgressOnlyRuleRequest withRequestGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + return this; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/ListEgressOnlyRuleResponse.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListEgressOnlyRuleResponse.java new file mode 100644 index 00000000..88fe6155 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListEgressOnlyRuleResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +public class ListEgressOnlyRuleResponse extends ListResponse { + /** + * List of ipv6Gateway' EgressOnlyRule info + */ + private List egressOnlyRules; + + public List getEgressOnlyRules() { + return egressOnlyRules; + } + + public void setEgressOnlyRules(List egressOnlyRules) { + this.egressOnlyRules = egressOnlyRules; + } + + @Override + public String toString() { + return "ListEgressOnlyRuleResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "egressOnlyRules=" + egressOnlyRules + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/ListIpv6GatewayRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListIpv6GatewayRequest.java new file mode 100644 index 00000000..5cd4a963 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListIpv6GatewayRequest.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * Created by wangkai on 2019/8/16 + */ +public class ListIpv6GatewayRequest extends ListRequest { + + @JsonIgnore + private String vpcId; + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + @Override + public ListIpv6GatewayRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public ListIpv6GatewayRequest withRequestVpcId(String vpcId) { + this.setVpcId(vpcId); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/ListRateLimitRuleRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListRateLimitRuleRequest.java new file mode 100644 index 00000000..6c279b93 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListRateLimitRuleRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +public class ListRateLimitRuleRequest extends ListRequest { + + private String gatewayId; + + @Override + public ListRateLimitRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public ListRateLimitRuleRequest withRequestGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + return this; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public ListRateLimitRuleRequest() { + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/ListRateLimitRuleResponse.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListRateLimitRuleResponse.java new file mode 100644 index 00000000..f4b55720 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/ListRateLimitRuleResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + + +public class ListRateLimitRuleResponse extends ListResponse { + /** + * List of ipv6Gateway' RateLimitRule info + */ + private List rateLimitRules; + + public List getRateLimitRules() { + return rateLimitRules; + } + + public void setRateLimitRules(List rateLimitRules) { + this.rateLimitRules = rateLimitRules; + } + + @Override + public String toString() { + return "ListRateLimitRuleResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "rateLimitRules=" + rateLimitRules + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/RateLimitRule.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/RateLimitRule.java new file mode 100644 index 00000000..a3e495c2 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/RateLimitRule.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import lombok.ToString; + +@ToString +public class RateLimitRule { + + private String rateLimitRuleId; + private String ipv6Address; + private int ingressBandwidthInMbps; + private int egressBandwidthInMbps; + + public String getRateLimitRuleId() { + return rateLimitRuleId; + } + + public void setRateLimitRuleId(String rateLimitRuleId) { + this.rateLimitRuleId = rateLimitRuleId; + } + + public String getIpv6Address() { + return ipv6Address; + } + + public void setIpv6Address(String ipv6Address) { + this.ipv6Address = ipv6Address; + } + + public int getIngressBandwidthInMbps() { + return ingressBandwidthInMbps; + } + + public int getEgressBandwidthInMbps() { + return egressBandwidthInMbps; + } + + public void setIngressBandwidthInMbps(int ingressBandwidthInMbps) { + this.ingressBandwidthInMbps = ingressBandwidthInMbps; + } + + public void setEgressBandwidthInMbps(int egressBandwidthInMbps) { + this.egressBandwidthInMbps = egressBandwidthInMbps; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/RateLimitRuleResponse.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/RateLimitRuleResponse.java new file mode 100644 index 00000000..a150ae85 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/RateLimitRuleResponse.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.ToString; + +/** + * Created by wangkai on 2019/8/19 + */ + +@ToString +public class RateLimitRuleResponse extends AbstractBceResponse { + /* + * the id of rateLimit rule + */ + private String rateLimitRuleId; + + public String getRateLimitRuleId() { + return rateLimitRuleId; + } + + public void setRateLimitRuleId(String rateLimitRuleId) { + this.rateLimitRuleId = rateLimitRuleId; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/ResizeIpv6GatewayRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/ResizeIpv6GatewayRequest.java new file mode 100644 index 00000000..3194b3c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/ResizeIpv6GatewayRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class ResizeIpv6GatewayRequest extends AbstractBceRequest { + private int bandwidthInMbps; + + private String ipv6GatewayId; + + private String clientToken; + + @Override + public ResizeIpv6GatewayRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public ResizeIpv6GatewayRequest withIpv6Gateway(String ipv6GatewayId) { + this.ipv6GatewayId = ipv6GatewayId; + return this; + } + + public ResizeIpv6GatewayRequest withBandwidth(int bandwidth) { + this.bandwidthInMbps = bandwidth; + return this; + } + + public String getIpv6GatewayId() { + return ipv6GatewayId; + } + + public void setIpv6GatewayId(String ipv6GatewayId) { + this.ipv6GatewayId = ipv6GatewayId; + } + + public int getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } +} diff --git a/src/main/java/com/baidubce/services/ipv6Gateway/model/UpdateRateLimitRuleRequest.java b/src/main/java/com/baidubce/services/ipv6Gateway/model/UpdateRateLimitRuleRequest.java new file mode 100644 index 00000000..66db6214 --- /dev/null +++ b/src/main/java/com/baidubce/services/ipv6Gateway/model/UpdateRateLimitRuleRequest.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.ipv6Gateway.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_DEFAULT) +public class UpdateRateLimitRuleRequest extends AbstractBceRequest { + + private String gatewayId; + private String rateLimitRuleId; + private int ingressBandwidthInMbps = -1; + private int egressBandwidthInMbps = -1; + private String clientToken; + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getRateLimitRuleId() { + return rateLimitRuleId; + } + + public void setRateLimitRuleId(String rateLimitRuleId) { + this.rateLimitRuleId = rateLimitRuleId; + } + + public int getIngressBandwidthInMbps() { + return ingressBandwidthInMbps; + } + + public void setIngressBandwidthInMbps(int ingressBandwidthInMbps) { + this.ingressBandwidthInMbps = ingressBandwidthInMbps; + } + + public int getEgressBandwidthInMbps() { + return egressBandwidthInMbps; + } + + public void setEgressBandwidthInMbps(int egressBandwidthInMbps) { + this.egressBandwidthInMbps = egressBandwidthInMbps; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public UpdateRateLimitRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/KafkaClient.java b/src/main/java/com/baidubce/services/kafka/KafkaClient.java new file mode 100644 index 00000000..daf20512 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/KafkaClient.java @@ -0,0 +1,1534 @@ +package com.baidubce.services.kafka; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.kafka.model.acl.CreateAclRequest; +import com.baidubce.services.kafka.model.acl.CreateAclResponse; +import com.baidubce.services.kafka.model.acl.DeleteAclRequest; +import com.baidubce.services.kafka.model.acl.DeleteAclResponse; +import com.baidubce.services.kafka.model.acl.ListAclRequest; +import com.baidubce.services.kafka.model.acl.ListAclResponse; +import com.baidubce.services.kafka.model.cluster.CreateClusterRequest; +import com.baidubce.services.kafka.model.cluster.CreateClusterResponse; +import com.baidubce.services.kafka.model.cluster.DecreaseBrokerCountRequest; +import com.baidubce.services.kafka.model.cluster.DecreaseBrokerCountResponse; +import com.baidubce.services.kafka.model.cluster.DeleteClusterRequest; +import com.baidubce.services.kafka.model.cluster.DeleteClusterResponse; +import com.baidubce.services.kafka.model.cluster.ExpandBrokerDiskCapacityRequest; +import com.baidubce.services.kafka.model.cluster.ExpandBrokerDiskCapacityResponse; +import com.baidubce.services.kafka.model.cluster.GetClusterAccessEndpointsRequest; +import com.baidubce.services.kafka.model.cluster.GetClusterAccessEndpointsResponse; +import com.baidubce.services.kafka.model.cluster.GetClusterConfigurationsRequest; +import com.baidubce.services.kafka.model.cluster.GetClusterConfigurationsResponse; +import com.baidubce.services.kafka.model.cluster.GetClusterCurrentControllerRequest; +import com.baidubce.services.kafka.model.cluster.GetClusterCurrentControllerResponse; +import com.baidubce.services.kafka.model.cluster.GetClusterDetailRequest; +import com.baidubce.services.kafka.model.cluster.GetClusterDetailResponse; +import com.baidubce.services.kafka.model.cluster.GetClusterHistoryControllerRequest; +import com.baidubce.services.kafka.model.cluster.GetClusterHistoryControllerResponse; +import com.baidubce.services.kafka.model.cluster.GetClusterNodesRequest; +import com.baidubce.services.kafka.model.cluster.GetClusterNodesResponse; +import com.baidubce.services.kafka.model.cluster.IncreaseBrokerCountRequest; +import com.baidubce.services.kafka.model.cluster.IncreaseBrokerCountResponse; +import com.baidubce.services.kafka.model.cluster.ListClustersRequest; +import com.baidubce.services.kafka.model.cluster.ListClustersResponse; +import com.baidubce.services.kafka.model.cluster.ResizeClusterEipBandwidthRequest; +import com.baidubce.services.kafka.model.cluster.ResizeClusterEipBandwidthResponse; +import com.baidubce.services.kafka.model.cluster.RestartBrokerRequest; +import com.baidubce.services.kafka.model.cluster.RestartBrokerResponse; +import com.baidubce.services.kafka.model.cluster.RestartClusterRequest; +import com.baidubce.services.kafka.model.cluster.RestartClusterResponse; +import com.baidubce.services.kafka.model.cluster.StartClusterRequest; +import com.baidubce.services.kafka.model.cluster.StartClusterResponse; +import com.baidubce.services.kafka.model.cluster.StopClusterRequest; +import com.baidubce.services.kafka.model.cluster.StopClusterResponse; +import com.baidubce.services.kafka.model.cluster.SwitchClusterEipRequest; +import com.baidubce.services.kafka.model.cluster.SwitchClusterEipResponse; +import com.baidubce.services.kafka.model.cluster.SwitchClusterIntranetIpRequest; +import com.baidubce.services.kafka.model.cluster.SwitchClusterIntranetIpResponse; +import com.baidubce.services.kafka.model.cluster.UpdateAccessConfigRequest; +import com.baidubce.services.kafka.model.cluster.UpdateAccessConfigResponse; +import com.baidubce.services.kafka.model.cluster.UpdateBrokerNodeTypeRequest; +import com.baidubce.services.kafka.model.cluster.UpdateBrokerNodeTypeResponse; +import com.baidubce.services.kafka.model.cluster.UpdateKafkaConfigRequest; +import com.baidubce.services.kafka.model.cluster.UpdateKafkaConfigResponse; +import com.baidubce.services.kafka.model.cluster.UpdateSecurityGroupRequest; +import com.baidubce.services.kafka.model.cluster.UpdateSecurityGroupResponse; +import com.baidubce.services.kafka.model.cluster.UpdateStoragePolicyRequest; +import com.baidubce.services.kafka.model.cluster.UpdateStoragePolicyResponse; +import com.baidubce.services.kafka.model.config.CreateClusterConfigRequest; +import com.baidubce.services.kafka.model.config.CreateClusterConfigResponse; +import com.baidubce.services.kafka.model.config.CreateClusterConfigRevisionRequest; +import com.baidubce.services.kafka.model.config.CreateClusterConfigRevisionResponse; +import com.baidubce.services.kafka.model.config.DeleteClusterConfigRequest; +import com.baidubce.services.kafka.model.config.DeleteClusterConfigResponse; +import com.baidubce.services.kafka.model.config.GetClusterConfigRequest; +import com.baidubce.services.kafka.model.config.GetClusterConfigResponse; +import com.baidubce.services.kafka.model.config.GetClusterConfigRevisionRequest; +import com.baidubce.services.kafka.model.config.GetClusterConfigRevisionResponse; +import com.baidubce.services.kafka.model.config.ListClusterConfigRevisionsRequest; +import com.baidubce.services.kafka.model.config.ListClusterConfigRevisionsResponse; +import com.baidubce.services.kafka.model.config.ListClusterConfigsRequest; +import com.baidubce.services.kafka.model.config.ListClusterConfigsResponse; +import com.baidubce.services.kafka.model.consumer.DeleteConsumerGroupRequest; +import com.baidubce.services.kafka.model.consumer.DeleteConsumerGroupResponse; +import com.baidubce.services.kafka.model.consumer.GetSubscribedTopicOverviewRequest; +import com.baidubce.services.kafka.model.consumer.GetSubscribedTopicOverviewResponse; +import com.baidubce.services.kafka.model.consumer.ListConsumerGroupRequest; +import com.baidubce.services.kafka.model.consumer.ListConsumerGroupResponse; +import com.baidubce.services.kafka.model.consumer.ListSubscribedTopicsRequest; +import com.baidubce.services.kafka.model.consumer.ListSubscribedTopicsResponse; +import com.baidubce.services.kafka.model.consumer.ResetConsumerGroupRequest; +import com.baidubce.services.kafka.model.consumer.ResetConsumerGroupResponse; +import com.baidubce.services.kafka.model.job.CancelJobRequest; +import com.baidubce.services.kafka.model.job.CancelJobResponse; +import com.baidubce.services.kafka.model.job.GetJobDetailRequest; +import com.baidubce.services.kafka.model.job.GetJobDetailResponse; +import com.baidubce.services.kafka.model.job.GetOperationDetailRequest; +import com.baidubce.services.kafka.model.job.GetOperationDetailResponse; +import com.baidubce.services.kafka.model.job.ListJobsRequest; +import com.baidubce.services.kafka.model.job.ListJobsResponse; +import com.baidubce.services.kafka.model.job.ResumeJobRequest; +import com.baidubce.services.kafka.model.job.ResumeJobResponse; +import com.baidubce.services.kafka.model.job.StartJobRequest; +import com.baidubce.services.kafka.model.job.StartJobResponse; +import com.baidubce.services.kafka.model.job.SuspendJobRequest; +import com.baidubce.services.kafka.model.job.SuspendJobResponse; +import com.baidubce.services.kafka.model.quota.CreateQuotaRequest; +import com.baidubce.services.kafka.model.quota.CreateQuotaResponse; +import com.baidubce.services.kafka.model.quota.DeleteQuotaRequest; +import com.baidubce.services.kafka.model.quota.DeleteQuotaResponse; +import com.baidubce.services.kafka.model.quota.ListQuotasRequest; +import com.baidubce.services.kafka.model.quota.ListQuotasResponse; +import com.baidubce.services.kafka.model.quota.UpdateQuotaRequest; +import com.baidubce.services.kafka.model.quota.UpdateQuotaResponse; +import com.baidubce.services.kafka.model.topic.CreateTopicRequest; +import com.baidubce.services.kafka.model.topic.CreateTopicResponse; +import com.baidubce.services.kafka.model.topic.DeleteTopicRequest; +import com.baidubce.services.kafka.model.topic.DeleteTopicResponse; +import com.baidubce.services.kafka.model.topic.GetSubscribedGroupDetailRequest; +import com.baidubce.services.kafka.model.topic.GetSubscribedGroupDetailResponse; +import com.baidubce.services.kafka.model.topic.GetSubscribedGroupOverviewRequest; +import com.baidubce.services.kafka.model.topic.GetSubscribedGroupOverviewResponse; +import com.baidubce.services.kafka.model.topic.GetTopicDetailRequest; +import com.baidubce.services.kafka.model.topic.GetTopicDetailResponse; +import com.baidubce.services.kafka.model.topic.GetTopicPartitionDetailRequest; +import com.baidubce.services.kafka.model.topic.GetTopicPartitionDetailResponse; +import com.baidubce.services.kafka.model.topic.GetTopicPartitionOverviewRequest; +import com.baidubce.services.kafka.model.topic.GetTopicPartitionOverviewResponse; +import com.baidubce.services.kafka.model.topic.ListSubscribedGroupsRequest; +import com.baidubce.services.kafka.model.topic.ListSubscribedGroupsResponse; +import com.baidubce.services.kafka.model.topic.ListTopicConfigOptionsRequest; +import com.baidubce.services.kafka.model.topic.ListTopicConfigOptionsResponse; +import com.baidubce.services.kafka.model.topic.ListTopicPartitionsRequest; +import com.baidubce.services.kafka.model.topic.ListTopicPartitionsResponse; +import com.baidubce.services.kafka.model.topic.ListTopicRequest; +import com.baidubce.services.kafka.model.topic.ListTopicResponse; +import com.baidubce.services.kafka.model.topic.QueryTopicMessagesByStartOffsetRequest; +import com.baidubce.services.kafka.model.topic.QueryTopicMessagesByStartOffsetResponse; +import com.baidubce.services.kafka.model.topic.QueryTopicMessagesByStartTimeRequest; +import com.baidubce.services.kafka.model.topic.QueryTopicMessagesByStartTimeResponse; +import com.baidubce.services.kafka.model.topic.SendTopicMessageRequest; +import com.baidubce.services.kafka.model.topic.SendTopicMessageResponse; +import com.baidubce.services.kafka.model.topic.UpdateTopicRequest; +import com.baidubce.services.kafka.model.topic.UpdateTopicResponse; +import com.baidubce.services.kafka.model.user.CreateUserRequest; +import com.baidubce.services.kafka.model.user.CreateUserResponse; +import com.baidubce.services.kafka.model.user.DeleteUserRequest; +import com.baidubce.services.kafka.model.user.DeleteUserResponse; +import com.baidubce.services.kafka.model.user.ListUserResponse; +import com.baidubce.services.kafka.model.user.ListUsersRequest; +import com.baidubce.services.kafka.model.user.ResetUserPasswordRequest; +import com.baidubce.services.kafka.model.user.ResetUserPasswordResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; +import org.apache.commons.codec.binary.Hex; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; + +/** + * Provides the client for accessing the Baidu Message Service(kafka). + */ +public class KafkaClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(KafkaClient.class); + + private static final String VERSION = "v2"; + private static final String CLUSTERS_PREFIX = "clusters"; + private static final String TOPICS_PREFIX = "topics"; + private static final String CONSUMER_GROUPS_PREFIX = "consumer-groups"; + private static final String USERS_PREFIX = "users"; + private static final String ACLS_PREFIX = "acls"; + private static final String ACCESS_ENDPOINTS_PREFIX = "access-endpoints"; + private static final String NODES_PREFIX = "nodes"; + private static final String OFFSETS_PREFIX = "offsets"; + private static final String PARTITONS_PREFIX = "partitions"; + private static final String JOBS_PREFIX = "jobs"; + private static final String OPERATIONS_PREFIX = "operations"; + private static final String CONFIGURATIONS_PREFIX = "configurations"; + private static final String CONFIGS_PREFIX = "configs"; + private static final String REVISIONS_PREFIX = "revisions"; + private static final String MESSAGES_PREFIX = "messages"; + private static final String QUOTAS_PREFIX = "quotas"; + + private static final String PAGE_NO = "pageNo"; + private static final String PAGE_SIZE = "pageSize"; + private static final String MARKER = "marker"; + private static final String MAX_KEYS = "maxKeys"; + private static final String STATE = "state"; + private static final String MODE = "mode"; + private static final String NAME = "name"; + private static final String KAFKA_VERSION = "kafkaVersion"; + private static final String PAYMENT = "payment"; + private static final String TAG_KEY = "tagKey"; + private static final String TAG_VALUE = "tagValue"; + private static final String START_TIME = "startTime"; + private static final String START_OFFSET = "startOffset"; + + /** + * Exception messages. + */ + private static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + private static final String CLUSTERID_MESSAGE_KEY = "clusterId"; + private static final String CLUSTER_NAME_MESSAGE_KEY = "clusterName"; + private static final String NAME_MESSAGE_KEY = "name"; + private static final String TOPIC_NAME_MESSAGE_KEY = "topicName"; + private static final String GROUP_NAME_MESSAGE_KEY = "groupName"; + private static final String CONFIG_NAME_MESSAGE_KEY = "configName"; + private static final String JOBID_MESSAGE_KEY = "jobId"; + private static final String OPERATIONID_MESSAGE_KEY = "operationId"; + private static final String CONFIGID_MESSAGE_KEY = "configId"; + private static final String REVISIONID_MESSAGE_KEY = "revisionId"; + private static final String NODEID_MESSAGE_KEY = "nodeId"; + private static final String PARTITIONID_MESSAGE_KEY = "partitionId"; + + private static final String USERNAME_MESSAGE_KEY = "username"; + private static final String PASSWORD_MESSAGE_KEY = "password"; + private static final String PATTERN_TYPE_MESSAGE_KEY = "patternType"; + private static final String RESOURCE_TYPE_MESSAGE_KEY = "resourceType"; + private static final String RESOURCE_NAME_MESSAGE_KEY = "resourceName"; + private static final String OPERATION_MESSAGE_KEY = "operation"; + private static final String QUOTA_ENTITY_TYPE_KEY = "entityType"; + private static final String QUOTA_USERNAME_KEY = "username"; + private static final String QUOTA_USER_DEFAULT_KEY = "userDefault"; + private static final String QUOTA_CLIENT_ID_KEY = "clientId"; + private static final String QUOTA_CLIENT_DEFAULT_KEY = "clientDefault"; + + + + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling httpResponses from all kafka service calls. + */ + private static final HttpResponseHandler[] KAFKA_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on kafka. + */ + public KafkaClient() { + this(new KafkaClientConfiguration()); + } + + /** + * Constructs a new kafka client using the client configuration to access kafka. + * + * @param clientConfiguration The bcc client configuration options controlling how this client + * connects to bcc (e.g. proxy settings, retry counts, etc). + */ + public KafkaClient(KafkaClientConfiguration clientConfiguration) { + super(clientConfiguration, KAFKA_HANDLERS); + } + + /** + * Creates and initializes a new request object for the specified kafka resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + * + * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * The encryption implement for AES-128 algorithm for BCE password encryption. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + * + * See more detail on + * + * BCE API doc + * + * @param content The content String to encrypt. + * @param privateKey The security key to encrypt. + * Only the first 16 bytes of privateKey will be used to encrypt the content. + * @return The encrypted string of the original content with AES-128 algorithm. + * @throws GeneralSecurityException + */ + private String aes128WithFirst16Char(String content, String privateKey) throws GeneralSecurityException { + + byte[] crypted = null; + SecretKeySpec skey = new SecretKeySpec(privateKey.substring(0, 16).getBytes(), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, skey); + crypted = cipher.doFinal(content.getBytes()); + return new String(Hex.encodeHex(crypted, false)); + } + + + /** ========================================= cluster API ======================================================== */ + + /** + * 创建集群 + * @param request + * @return + */ + public CreateClusterResponse createCluster(CreateClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CLUSTERS_PREFIX); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateClusterResponse.class); + } + + /** + * 释放集群 + * @param request + * @return + */ + public DeleteClusterResponse deleteCluster(DeleteClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, CLUSTERS_PREFIX, request.getClusterId()); + return invokeHttpClient(internalRequest, DeleteClusterResponse.class); + } + + /** + * 查询集群列表 + * @param request + * @return + */ + public ListClustersResponse listClusters(ListClustersRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CLUSTERS_PREFIX); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() <= 1000 && request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getClusterName())) { + internalRequest.addParameter(CLUSTER_NAME_MESSAGE_KEY, request.getClusterName()); + } + if (!Strings.isNullOrEmpty(request.getState())) { + internalRequest.addParameter(STATE, request.getState()); + } + if (!Strings.isNullOrEmpty(request.getMode())) { + internalRequest.addParameter(MODE, request.getMode()); + } + if (!Strings.isNullOrEmpty(request.getKafkaVersion())) { + internalRequest.addParameter(KAFKA_VERSION, request.getKafkaVersion()); + } + if (!Strings.isNullOrEmpty(request.getPayment())) { + internalRequest.addParameter(PAYMENT, request.getPayment()); + } + if (!Strings.isNullOrEmpty(request.getTagKey())) { + if (request.getTagValue() != null) { + internalRequest.addParameter(TAG_KEY, request.getTagKey()); + internalRequest.addParameter(TAG_VALUE, request.getTagValue()); + } else { + throw new IllegalArgumentException("Request tagValue should not be null."); + } + } else if (request.getTagValue() != null) { + throw new IllegalArgumentException("Request tagKey should not be null or empty."); + } + return invokeHttpClient(internalRequest, ListClustersResponse.class); + } + + /** + * 查询集群详情 + * @param request + * @return + */ + public GetClusterDetailResponse getClusterDetail(GetClusterDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId()); + return invokeHttpClient(internalRequest, GetClusterDetailResponse.class); + } + + /** + * 查询集群接入点 + * @param request + * @return + */ + public GetClusterAccessEndpointsResponse getClusterAccessEndpoints(GetClusterAccessEndpointsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), ACCESS_ENDPOINTS_PREFIX); + return invokeHttpClient(internalRequest, GetClusterAccessEndpointsResponse.class); + } + + /** + * 查询集群节点列表 + * @param request + * @return + */ + public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), NODES_PREFIX); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() <= 1000 && request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getState())) { + internalRequest.addParameter(STATE, request.getState()); + } + return invokeHttpClient(internalRequest, GetClusterNodesResponse.class); + } + + /** + * 查询集群配置信息 + * @param request + * @return + */ + public GetClusterConfigurationsResponse getClusterConfigurations(GetClusterConfigurationsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), CONFIGURATIONS_PREFIX); + return invokeHttpClient(internalRequest, GetClusterConfigurationsResponse.class); + } + + /** + * 增加节点数量 + * @param request + * @return + */ + public IncreaseBrokerCountResponse increaseBrokerCount(IncreaseBrokerCountRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "increase-broker-count"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, IncreaseBrokerCountResponse.class); + } + + /** + * 减少节点数量 + * @param request + * @return + */ + public DecreaseBrokerCountResponse decreaseBrokerCount(DecreaseBrokerCountRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "decrease-broker-count"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, DecreaseBrokerCountResponse.class); + } + + /** + * 变更节点机型 + * @param request + * @return + */ + public UpdateBrokerNodeTypeResponse updateBrokerNodeType(UpdateBrokerNodeTypeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "update-broker-node-type"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateBrokerNodeTypeResponse.class); + } + + /** + * 扩容磁盘容量 + * @param request + * @return + */ + public ExpandBrokerDiskCapacityResponse expandBrokerDiskCapacity(ExpandBrokerDiskCapacityRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "expand-broker-disk-capacity"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ExpandBrokerDiskCapacityResponse.class); + } + + /** + * 变更访问配置 + * @param request + * @return + */ + public UpdateAccessConfigResponse updateAccessConfig(UpdateAccessConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "update-access-config"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateAccessConfigResponse.class); + } + + /** + * 启动集群 + * @param request + * @return + */ + public StartClusterResponse startCluster(StartClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "start"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, StartClusterResponse.class); + } + + /** + * 停止集群 + * @param request + * @return + */ + public StopClusterResponse stopCluster(StopClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "stop"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, StopClusterResponse.class); + } + + /** + * 变更公网带宽 + * @param request + * @return + */ + public ResizeClusterEipBandwidthResponse resizeClusterEipBandwidth(ResizeClusterEipBandwidthRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "eip-bandwidths/resize"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ResizeClusterEipBandwidthResponse.class); + } + + /** + * 集群公网开关 + * @param request + * @return + */ + public SwitchClusterEipResponse switchClusterEip(SwitchClusterEipRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "eips/switch"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, SwitchClusterEipResponse.class); + } + + /** + * 变更磁盘阈值策略 + * @param request + * @return + */ + public UpdateStoragePolicyResponse updateStoragePolicy(UpdateStoragePolicyRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "update-storage-policy"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateStoragePolicyResponse.class); + } + + /** + * 变更集群 kafka 配置 + * @param request + * @return + */ + public UpdateKafkaConfigResponse updateKafkaConfig(UpdateKafkaConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "update-kafka-config"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateKafkaConfigResponse.class); + } + + /** + * 变更用户安全组 + * @param request + * @return + */ + public UpdateSecurityGroupResponse updateSecurityGroup(UpdateSecurityGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "security-groups"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateSecurityGroupResponse.class); + } + + /** + * 集群产品间转储开关 + * @param request + * @return + */ + public SwitchClusterIntranetIpResponse switchClusterIntranetIp(SwitchClusterIntranetIpRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "intranet-ips/switch"); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, SwitchClusterIntranetIpResponse.class); + } + + /** + * 获取集群当前 Controller 信息 + * @param request + * @return + */ + public GetClusterCurrentControllerResponse getClusterCurrentController(GetClusterCurrentControllerRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), "controller"); + return invokeHttpClient(internalRequest, GetClusterCurrentControllerResponse.class); + } + + /** + * 获取集群历史 Controller 信息 + * @param request + * @return + */ + public GetClusterHistoryControllerResponse getClusterHistoryController(GetClusterHistoryControllerRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), "controller/history"); + return invokeHttpClient(internalRequest, GetClusterHistoryControllerResponse.class); + } + + /** + * 重启整个 Kafka 集群服务 + * @param request + * @return + */ + public RestartClusterResponse restartCluster(RestartClusterRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), "restart"); + return invokeHttpClient(internalRequest, RestartClusterResponse.class); + } + + /** + * 重启指定 Broker 节点服务 + * @param request + * @return + */ + public RestartBrokerResponse restartBroker(RestartBrokerRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getNodeId(), checkEmptyExceptionMessageFormat(NODEID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), NODES_PREFIX, + request.getNodeId(), "restart-broker"); + return invokeHttpClient(internalRequest, RestartBrokerResponse.class); + } + + /** ========================================= config API ======================================================== */ + + /** + * 创建集群配置 + * @param request + * @return + */ + public CreateClusterConfigResponse createClusterConfig(CreateClusterConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CONFIGS_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateClusterConfigResponse.class); + } + + /** + * 查询集群配置列表 + * @param request + * @return + */ + public ListClusterConfigsResponse listClusterConfigs(ListClusterConfigsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CONFIGS_PREFIX); + if (!Strings.isNullOrEmpty(request.getMarker())) { + internalRequest.addParameter(MARKER, request.getMarker()); + } + if (request.getMaxKeys() <= 1000 && request.getMaxKeys() > 0) { + internalRequest.addParameter(MAX_KEYS, String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getConfigName())) { + internalRequest.addParameter(CONFIG_NAME_MESSAGE_KEY, request.getConfigName()); + } + if (!Strings.isNullOrEmpty(request.getState())) { + internalRequest.addParameter(STATE, request.getState()); + } + return invokeHttpClient(internalRequest, ListClusterConfigsResponse.class); + } + + /** + * 删除集群配置 + * @param request + * @return + */ + public DeleteClusterConfigResponse deleteClusterConfig(DeleteClusterConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getConfigId(), checkEmptyExceptionMessageFormat(CONFIGID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, CONFIGS_PREFIX, request.getConfigId()); + return invokeHttpClient(internalRequest, DeleteClusterConfigResponse.class); + } + + /** + * 查询集群配置详情 + * @param request + * @return + */ + public GetClusterConfigResponse getClusterConfig(GetClusterConfigRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getConfigId(), checkEmptyExceptionMessageFormat(CONFIGID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CONFIGS_PREFIX, request.getConfigId()); + return invokeHttpClient(internalRequest, GetClusterConfigResponse.class); + } + + /** + * 新增集群配置版本 + * @param request + * @return + */ + public CreateClusterConfigRevisionResponse createClusterConfigRevision(CreateClusterConfigRevisionRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getConfigId(), checkEmptyExceptionMessageFormat(CONFIGID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, CONFIGS_PREFIX, request.getConfigId(), REVISIONS_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateClusterConfigRevisionResponse.class); + } + + /** + * 查询集群配置版本列表 + * @param request + * @return + */ + public ListClusterConfigRevisionsResponse listClusterConfigRevisions(ListClusterConfigRevisionsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getConfigId(), checkEmptyExceptionMessageFormat(CONFIGID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CONFIGS_PREFIX, request.getConfigId(), REVISIONS_PREFIX); + if (!Strings.isNullOrEmpty(request.getState())) { + internalRequest.addParameter(STATE, request.getState()); + } + return invokeHttpClient(internalRequest, ListClusterConfigRevisionsResponse.class); + } + + /** + * 查询集群配置版本详情 + * @param request + * @return + */ + public GetClusterConfigRevisionResponse getClusterConfigRevision(GetClusterConfigRevisionRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getConfigId(), checkEmptyExceptionMessageFormat(CONFIGID_MESSAGE_KEY)); + checkNotNull(request.getRevisionId(), checkEmptyExceptionMessageFormat(REVISIONID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CONFIGS_PREFIX, request.getConfigId(), + REVISIONS_PREFIX, String.valueOf(request.getRevisionId())); + return invokeHttpClient(internalRequest, GetClusterConfigRevisionResponse.class); + } + + /** ========================================= topic API ======================================================== */ + + /** + * 变更主题 + * @param request + * @return + */ + public UpdateTopicResponse updateTopic(UpdateTopicRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, request.getTopicName()); + if (request.getPartitionNum() != null || MapUtils.isNotEmpty(request.getOtherConfigs())) { + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateTopicResponse.class); + } else { + throw new IllegalArgumentException("Request fields should not be both null or empty."); + } + } + + /** + * 查询主题订阅详情 + * @param request + * @return + */ + public GetSubscribedGroupDetailResponse getSubscribedGroupDetail(GetSubscribedGroupDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getGroupName(), checkEmptyExceptionMessageFormat(GROUP_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, request.getTopicName(), + CONSUMER_GROUPS_PREFIX, request.getGroupName(), "subscribe-details"); + return invokeHttpClient(internalRequest, GetSubscribedGroupDetailResponse.class); + } + + /** + * 查询主题分区列表 + * @param request + * @return + */ + public ListTopicPartitionsResponse listTopicPartitions(ListTopicPartitionsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, request.getTopicName(), "partitions", "statuses"); + internalRequest.addParameter(PAGE_NO, String.valueOf(request.getPageNo())); + if (request.getPageSize() > 0) { + internalRequest.addParameter(PAGE_SIZE, String.valueOf(request.getPageSize())); + } + return invokeHttpClient(internalRequest, ListTopicPartitionsResponse.class); + } + + /** + * 查询主题分区详情 + * @param request + * @return + */ + public GetTopicPartitionDetailResponse getTopicPartitionDetail(GetTopicPartitionDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getPartitionId(), checkEmptyExceptionMessageFormat(PARTITIONID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, request.getTopicName(), + "partitions", request.getPartitionId(), "statuses"); + return invokeHttpClient(internalRequest, GetTopicPartitionDetailResponse.class); + } + + /** + * 查询主题列表 + * @param request + * @return + */ + public ListTopicResponse listTopic(ListTopicRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX); + if (!Strings.isNullOrEmpty(request.getTopicName())) { + internalRequest.addParameter(TOPIC_NAME_MESSAGE_KEY, request.getTopicName()); + } + return invokeHttpClient(internalRequest, ListTopicResponse.class); + } + + /** + * 查询主题详情 + * @param request + * @return + */ + public GetTopicDetailResponse getTopicDetail(GetTopicDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, request.getTopicName()); + return invokeHttpClient(internalRequest, GetTopicDetailResponse.class); + } + + /** + * 创建主题 + * @param request + * @return + */ + public CreateTopicResponse createTopic(CreateTopicRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + checkNotNull(request.getPartitionNum(), "Request partitionNum should not be null."); + checkNotNull(request.getReplicationFactor(), "Request replicationFactor should not be null."); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateTopicResponse.class); + } + + /** + * 获取订阅主题的消费组列表 + * @param request + * @return + */ + public ListSubscribedGroupsResponse listSubscribedGroups(ListSubscribedGroupsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, request.getTopicName(), "consumer-groups"); + return invokeHttpClient(internalRequest, ListSubscribedGroupsResponse.class); + } + + /** + * 删除主题 + * @param request + * @return + */ + public DeleteTopicResponse deleteTopic(DeleteTopicRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, request.getTopicName()); + return invokeHttpClient(internalRequest, DeleteTopicResponse.class); + } + + /** + * 查询主题分区信息概览 + * @param request + * @return + */ + public GetTopicPartitionOverviewResponse getTopicPartitionOverview(GetTopicPartitionOverviewRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, + request.getTopicName(), PARTITONS_PREFIX, "statuses/overview"); + return invokeHttpClient(internalRequest, GetTopicPartitionOverviewResponse.class); + } + + /** + * 查询主题订阅关系概览 + * @param request + * @return + */ + public GetSubscribedGroupOverviewResponse getSubscribedGroupOverview(GetSubscribedGroupOverviewRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, + request.getTopicName(), CONSUMER_GROUPS_PREFIX, "overview"); + return invokeHttpClient(internalRequest, GetSubscribedGroupOverviewResponse.class); + } + + /** + * 查询主题支持的参数信息 + * @return + */ + public ListTopicConfigOptionsResponse listTopicConfigOptions() { + ListTopicConfigOptionsRequest request = new ListTopicConfigOptionsRequest(); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CLUSTERS_PREFIX, + TOPICS_PREFIX, "config-options"); + return invokeHttpClient(internalRequest, ListTopicConfigOptionsResponse.class); + } + + /** + * 消息发送 + * @param request + * @return + */ + public SendTopicMessageResponse sendTopicMessage(SendTopicMessageRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + if (Strings.isNullOrEmpty(request.getValue())) { + throw new IllegalArgumentException("Value cannot be null or empty."); + } + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CLUSTERS_PREFIX, + request.getClusterId(), TOPICS_PREFIX, request.getTopicName(), MESSAGES_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, SendTopicMessageResponse.class); + } + + /** + * 根据时间进行消息查询 + * @param request + * @return + */ + public QueryTopicMessagesByStartTimeResponse queryTopicMessagesByStartTime(QueryTopicMessagesByStartTimeRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + if (request.getStartTime() <= 0) { + throw new IllegalArgumentException("Start time must be positive."); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, + request.getTopicName(), MESSAGES_PREFIX, "query-by-start-time"); + if (request.getPartitionId() != null) { + internalRequest.addParameter(PARTITIONID_MESSAGE_KEY, String.valueOf(request.getPartitionId())); + } + internalRequest.addParameter("startTime", String.valueOf(request.getStartTime())); + return invokeHttpClient(internalRequest, QueryTopicMessagesByStartTimeResponse.class); + } + + /** + * 根据位点进行消息查询 + * @param request + * @return + */ + public QueryTopicMessagesByStartOffsetResponse queryTopicMessagesByStartOffset(QueryTopicMessagesByStartOffsetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + if (request.getPartitionId() < 0) { + throw new IllegalArgumentException("Partition id must be positive."); + } + if (request.getStartOffset() < 0) { + throw new IllegalArgumentException("Start offset must be positive."); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), TOPICS_PREFIX, + request.getTopicName(), MESSAGES_PREFIX, "query-by-start-offset"); + internalRequest.addParameter(PARTITIONID_MESSAGE_KEY, String.valueOf(request.getPartitionId())); + internalRequest.addParameter(START_OFFSET, String.valueOf(request.getStartOffset())); + return invokeHttpClient(internalRequest, QueryTopicMessagesByStartOffsetResponse.class); + } + + /** ========================================= consumer API ==================================================== */ + + /** + * 查询消费组订阅的主题列表 + * @param request + * @return + */ + public ListSubscribedTopicsResponse listSubscribedTopics(ListSubscribedTopicsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getGroupName(), checkEmptyExceptionMessageFormat(GROUP_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), CONSUMER_GROUPS_PREFIX, request.getGroupName(), TOPICS_PREFIX); + return invokeHttpClient(internalRequest, ListSubscribedTopicsResponse.class); + } + + /** + * 查询消费组列表 + * @param request + * @return + */ + public ListConsumerGroupResponse listConsumerGroup(ListConsumerGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), CONSUMER_GROUPS_PREFIX); + return invokeHttpClient(internalRequest, ListConsumerGroupResponse.class); + } + + /** + * 删除消费组 + * @param request + * @return + */ + public DeleteConsumerGroupResponse deleteConsumerGroup(DeleteConsumerGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getGroupName(), checkEmptyExceptionMessageFormat(GROUP_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, CLUSTERS_PREFIX, request.getClusterId(), CONSUMER_GROUPS_PREFIX, request.getGroupName()); + return invokeHttpClient(internalRequest, DeleteConsumerGroupResponse.class); + } + + /** + * 重置消费组位点 + * @param request + * @return + */ + public ResetConsumerGroupResponse resetConsumerGroup(ResetConsumerGroupRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getGroupName(), checkEmptyExceptionMessageFormat(GROUP_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, CLUSTERS_PREFIX, request.getClusterId(), CONSUMER_GROUPS_PREFIX, request.getGroupName(), OFFSETS_PREFIX); + checkStringNotEmpty(request.getTopicName(), checkEmptyExceptionMessageFormat(TOPIC_NAME_MESSAGE_KEY)); + if (CollectionUtils.isEmpty(request.getPartitions())) { + throw new IllegalArgumentException("Request partitions should not be both null or empty."); + } + checkStringNotEmpty(request.getResetStrategy(), checkEmptyExceptionMessageFormat("resetStrategy")); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ResetConsumerGroupResponse.class); + } + + /** + * 查询消费组订阅关系概览 + * @param request + * @return + */ + public GetSubscribedTopicOverviewResponse getSubscribedTopicOverview(GetSubscribedTopicOverviewRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getGroupName(), checkEmptyExceptionMessageFormat(GROUP_NAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), CONSUMER_GROUPS_PREFIX, + request.getGroupName(), "topics/overview"); + return invokeHttpClient(internalRequest, GetSubscribedTopicOverviewResponse.class); + } + + /** ========================================= user API ======================================================== */ + + /** + * 创建用户 + * Create a user with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + * + * @param request The request containing all options for creating a user. + * @return Username newly created. + * @throws BceClientException + */ + public CreateUserResponse createUser(CreateUserRequest request) + throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getUsername(), checkEmptyExceptionMessageFormat(USERNAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getPassword(), checkEmptyExceptionMessageFormat(PASSWORD_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, CLUSTERS_PREFIX, request.getClusterId(), USERS_PREFIX); + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setPassword(this.aes128WithFirst16Char(request.getPassword(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateUserResponse.class); + } + + /** + * 删除用户 + * Delete a user by username. + * + * @param request The request for deleting a user. + * @return Username deleted. + */ + public DeleteUserResponse deleteUser(DeleteUserRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getUsername(), checkEmptyExceptionMessageFormat(USERNAME_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, CLUSTERS_PREFIX, request.getClusterId(), USERS_PREFIX, request.getUsername()); + return invokeHttpClient(internalRequest, DeleteUserResponse.class); + } + + /** + * 重置用户密码 + * Reset a password of a user. + * + * @param request The request for reseting a user's password. + * @return Username reseted password. + * @throws BceClientException + */ + public ResetUserPasswordResponse resetUserPassword(ResetUserPasswordRequest request) + throws BceClientException { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getUsername(), checkEmptyExceptionMessageFormat(USERNAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getPassword(), checkEmptyExceptionMessageFormat(PASSWORD_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), USERS_PREFIX, request.getUsername()); + BceCredentials credentials = config.getCredentials(); + if (internalRequest.getCredentials() != null) { + credentials = internalRequest.getCredentials(); + } + try { + request.setPassword(this.aes128WithFirst16Char(request.getPassword(), credentials.getSecretKey())); + } catch (GeneralSecurityException e) { + throw new BceClientException("Encryption procedure exception", e); + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, ResetUserPasswordResponse.class); + } + + /** + * 查询用户列表 + * Return a list of users owned by the cluster. + * + * @param clusterId The id of cluster. + * @return The response containing a list of users owned by the cluster. + */ + @Deprecated + public ListUserResponse listUsers(String clusterId) { + return listUsers(ListUsersRequest.builder().clusterId(clusterId).build()); + } + + /** + * 查询用户列表 + * Return a list of users owned by the cluster. + * + * @param request The request for listing all of the available specifications of user. + * @return The response containing a list of users owned by the cluster. + */ + public ListUserResponse listUsers(ListUsersRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), USERS_PREFIX); + return invokeHttpClient(internalRequest, ListUserResponse.class); + } + + + /** ========================================= acl API ======================================================== */ + + /** + * 创建权限 + * @param request + * @return + */ + public CreateAclResponse createAcl(CreateAclRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getUsername(), checkEmptyExceptionMessageFormat(USERNAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getPatternType(), checkEmptyExceptionMessageFormat(PATTERN_TYPE_MESSAGE_KEY)); + checkStringNotEmpty(request.getResourceType(), checkEmptyExceptionMessageFormat(RESOURCE_TYPE_MESSAGE_KEY)); + checkStringNotEmpty(request.getResourceName(), checkEmptyExceptionMessageFormat(RESOURCE_NAME_MESSAGE_KEY)); + if (CollectionUtils.isEmpty(request.getOperations())) { + throw new IllegalArgumentException(checkEmptyExceptionMessageFormat(OPERATION_MESSAGE_KEY)); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, CLUSTERS_PREFIX, request.getClusterId(), ACLS_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateAclResponse.class); + } + + /** + * 删除权限 + * @param request + * @return + */ + public DeleteAclResponse deleteAcl(DeleteAclRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, CLUSTERS_PREFIX, request.getClusterId(), ACLS_PREFIX); + checkStringNotEmpty(request.getUsername(), checkEmptyExceptionMessageFormat(USERNAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getPatternType(), checkEmptyExceptionMessageFormat(PATTERN_TYPE_MESSAGE_KEY)); + checkStringNotEmpty(request.getResourceType(), checkEmptyExceptionMessageFormat(RESOURCE_TYPE_MESSAGE_KEY)); + checkStringNotEmpty(request.getResourceName(), checkEmptyExceptionMessageFormat(RESOURCE_NAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getOperation(), checkEmptyExceptionMessageFormat(OPERATION_MESSAGE_KEY)); + internalRequest.addParameter(USERNAME_MESSAGE_KEY, request.getUsername()); + internalRequest.addParameter(PATTERN_TYPE_MESSAGE_KEY, request.getPatternType()); + internalRequest.addParameter(RESOURCE_TYPE_MESSAGE_KEY, request.getResourceType()); + internalRequest.addParameter(RESOURCE_NAME_MESSAGE_KEY, request.getResourceName()); + internalRequest.addParameter(OPERATION_MESSAGE_KEY, request.getOperation()); + + return invokeHttpClient(internalRequest, DeleteAclResponse.class); + } + + /** + * 查询权限列表 + * @param clusterId + * @return + */ + public ListAclResponse listAcls(String clusterId) { + return listAcls(ListAclRequest.builder().clusterId(clusterId).build()); + } + + /** + * 查询权限列表 + * @param request + * @return + */ + public ListAclResponse listAcls(ListAclRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), ACLS_PREFIX); + if (!Strings.isNullOrEmpty(request.getUsername())) { + internalRequest.addParameter(USERNAME_MESSAGE_KEY, request.getUsername()); + } + if (!Strings.isNullOrEmpty(request.getPatternType())) { + internalRequest.addParameter(PATTERN_TYPE_MESSAGE_KEY, request.getPatternType()); + } + if (!Strings.isNullOrEmpty(request.getResourceType())) { + internalRequest.addParameter(RESOURCE_TYPE_MESSAGE_KEY, request.getResourceType()); + } + if (!Strings.isNullOrEmpty(request.getResourceName())) { + internalRequest.addParameter(RESOURCE_NAME_MESSAGE_KEY, request.getResourceName()); + } + return invokeHttpClient(internalRequest, ListAclResponse.class); + } + + /** ========================================= job API ======================================================== */ + + /** + * 查询作业列表 + * @param request + * @return + */ + public ListJobsResponse listJobs(ListJobsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), JOBS_PREFIX); + if (!Strings.isNullOrEmpty(request.getName())) { + internalRequest.addParameter(NAME, request.getName()); + } + return invokeHttpClient(internalRequest, ListJobsResponse.class); + } + + /** + * 查询作业详情 + * @param request + * @return + */ + public GetJobDetailResponse getJob(GetJobDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), JOBS_PREFIX, request.getJobId()); + return invokeHttpClient(internalRequest, GetJobDetailResponse.class); + } + + /** + * 查询操作详情 + * @param request + * @return + */ + public GetOperationDetailResponse getOperation(GetOperationDetailRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); + checkStringNotEmpty(request.getOperationId(), checkEmptyExceptionMessageFormat(OPERATIONID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), JOBS_PREFIX, request.getJobId(), + OPERATIONS_PREFIX, request.getOperationId()); + return invokeHttpClient(internalRequest, GetOperationDetailResponse.class); + } + + /** + * 启动作业 + * @param request + * @return + */ + public StartJobResponse startJob(StartJobRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), JOBS_PREFIX, request.getJobId(), "start"); + return invokeHttpClient(internalRequest, StartJobResponse.class); + } + + /** + * 取消作业 + * @param request + * @return + */ + public CancelJobResponse cancelJob(CancelJobRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), JOBS_PREFIX, request.getJobId(), "cancel"); + return invokeHttpClient(internalRequest, CancelJobResponse.class); + } + + /** + * 暂停作业 + * @param request + * @return + */ + public SuspendJobResponse suspendJob(SuspendJobRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), JOBS_PREFIX, request.getJobId(), "suspend"); + return invokeHttpClient(internalRequest, SuspendJobResponse.class); + } + + /** + * 恢复作业 + * @param request + * @return + */ + public ResumeJobResponse resumeJob(ResumeJobRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), JOBS_PREFIX, request.getJobId(), "resume"); + return invokeHttpClient(internalRequest, ResumeJobResponse.class); + } + + /** ========================================= job API ======================================================== */ + + /** + * 查询 Quota 列表 + * @param request + * @return + */ + public ListQuotasResponse listQuotas(ListQuotasRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, CLUSTERS_PREFIX, request.getClusterId(), QUOTAS_PREFIX); + if (!Strings.isNullOrEmpty(request.getEntityType())) { + internalRequest.addParameter(QUOTA_ENTITY_TYPE_KEY, request.getEntityType()); + } + return invokeHttpClient(internalRequest, ListQuotasResponse.class); + } + + /** + * 创建 Quota + * @param request + * @return + */ + public CreateQuotaResponse createQuota(CreateQuotaRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.POST, CLUSTERS_PREFIX, request.getClusterId(), QUOTAS_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateQuotaResponse.class); + } + + /** + * 更新 Quota + * @param request + * @return + */ + public UpdateQuotaResponse updateQuota(UpdateQuotaRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, CLUSTERS_PREFIX, request.getClusterId(), QUOTAS_PREFIX); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, UpdateQuotaResponse.class); + } + + /** + * 删除 Quota + * @param request + * @return + */ + public DeleteQuotaResponse deleteQuota(DeleteQuotaRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getClusterId(), checkEmptyExceptionMessageFormat(CLUSTERID_MESSAGE_KEY)); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, CLUSTERS_PREFIX, request.getClusterId(), QUOTAS_PREFIX); + if (!Strings.isNullOrEmpty(request.getUsername())) { + internalRequest.addParameter(QUOTA_USERNAME_KEY, request.getUsername()); + } + if (request.getUserDefault() != null) { + internalRequest.addParameter(QUOTA_USER_DEFAULT_KEY, String.valueOf(request.getUserDefault())); + } + if (!Strings.isNullOrEmpty(request.getClientId())) { + internalRequest.addParameter(QUOTA_CLIENT_ID_KEY, request.getClientId()); + } + if (request.getClientDefault() != null) { + internalRequest.addParameter(QUOTA_CLIENT_DEFAULT_KEY, String.valueOf(request.getClientDefault())); + } + return invokeHttpClient(internalRequest, DeleteQuotaResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/kafka/KafkaClientConfiguration.java b/src/main/java/com/baidubce/services/kafka/KafkaClientConfiguration.java new file mode 100644 index 00000000..744ed6f2 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/KafkaClientConfiguration.java @@ -0,0 +1,9 @@ +package com.baidubce.services.kafka; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for kafka service. + */ +public class KafkaClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/kafka/model/PageListRequest.java b/src/main/java/com/baidubce/services/kafka/model/PageListRequest.java new file mode 100644 index 00000000..345ace9a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/PageListRequest.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model; + + +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public abstract class PageListRequest extends AbstractBceRequest { + + private int pageNo = 1; + + private int pageSize = 10 ; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/PageListResponse.java b/src/main/java/com/baidubce/services/kafka/model/PageListResponse.java new file mode 100644 index 00000000..c3623669 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/PageListResponse.java @@ -0,0 +1,14 @@ +package com.baidubce.services.kafka.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class PageListResponse extends AbstractBceResponse { + + private int pageNo; + + private int pageSize; + + private int total; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/acl/Acl.java b/src/main/java/com/baidubce/services/kafka/model/acl/Acl.java new file mode 100644 index 00000000..b0107fcf --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/acl/Acl.java @@ -0,0 +1,17 @@ +package com.baidubce.services.kafka.model.acl; + +import lombok.Data; + +@Data +public class Acl { + + private String username; + + private String patternType; + + private String resourceType; + + private String resourceName; + + private String operation; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/acl/CreateAclRequest.java b/src/main/java/com/baidubce/services/kafka/model/acl/CreateAclRequest.java new file mode 100644 index 00000000..0be11893 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/acl/CreateAclRequest.java @@ -0,0 +1,38 @@ +package com.baidubce.services.kafka.model.acl; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class CreateAclRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String username; + + private String patternType; + + private String resourceType; + + private String resourceName; + + private List operations; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public CreateAclRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public CreateAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/acl/CreateAclResponse.java b/src/main/java/com/baidubce/services/kafka/model/acl/CreateAclResponse.java new file mode 100644 index 00000000..377006ba --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/acl/CreateAclResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.acl; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class CreateAclResponse extends AbstractBceResponse { + + private String username; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/acl/DeleteAclRequest.java b/src/main/java/com/baidubce/services/kafka/model/acl/DeleteAclRequest.java new file mode 100644 index 00000000..077e3533 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/acl/DeleteAclRequest.java @@ -0,0 +1,36 @@ +package com.baidubce.services.kafka.model.acl; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class DeleteAclRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String username; + + private String patternType; + + private String resourceType; + + private String resourceName; + + private String operation; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public DeleteAclRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public DeleteAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/acl/DeleteAclResponse.java b/src/main/java/com/baidubce/services/kafka/model/acl/DeleteAclResponse.java new file mode 100644 index 00000000..758dbeeb --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/acl/DeleteAclResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.acl; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class DeleteAclResponse extends AbstractBceResponse { + + private String username; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/acl/ListAclRequest.java b/src/main/java/com/baidubce/services/kafka/model/acl/ListAclRequest.java new file mode 100644 index 00000000..3dfbc343 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/acl/ListAclRequest.java @@ -0,0 +1,46 @@ +package com.baidubce.services.kafka.model.acl; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ListAclRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + @JsonIgnore + private String clusterId; + + @JsonIgnore + private String username; + + @JsonIgnore + private String patternType; + + @JsonIgnore + private String resourceType; + + @JsonIgnore + private String resourceName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListAclRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListAclRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/acl/ListAclResponse.java b/src/main/java/com/baidubce/services/kafka/model/acl/ListAclResponse.java new file mode 100644 index 00000000..28581719 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/acl/ListAclResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.acl; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListAclResponse extends AbstractBceResponse { + + private List acls; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/AccessEndpoint.java b/src/main/java/com/baidubce/services/kafka/model/cluster/AccessEndpoint.java new file mode 100644 index 00000000..fcbdc30d --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/AccessEndpoint.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.Data; + +@Data +public class AccessEndpoint { + + private String securityProtocol; + + private String endpoints; + + private String network; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/AuthMode.java b/src/main/java/com/baidubce/services/kafka/model/cluster/AuthMode.java new file mode 100644 index 00000000..58b7bc6d --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/AuthMode.java @@ -0,0 +1,9 @@ +package com.baidubce.services.kafka.model.cluster; + +public enum AuthMode { + NONE, + SSL, + SASL_IAM, + SASL_SCRAM, + SASL_PLAIN +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Authentication.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Authentication.java new file mode 100644 index 00000000..bd5d4ece --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Authentication.java @@ -0,0 +1,15 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Authentication { + private String mode; + private String context; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Billing.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Billing.java new file mode 100644 index 00000000..8d4574bc --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Billing.java @@ -0,0 +1,33 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Billing { + + private String payment; + + private int timeLength; + + private String timeUnit = "month"; + + private String expireTime; + + private boolean autoRenewEnabled; + + private int autoRenewTimeLength; + + private String autoRenewTimeUnit = "month"; + + private List couponIds; + + private Boolean isAutoPay = true; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Cluster.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Cluster.java new file mode 100644 index 00000000..8277e236 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Cluster.java @@ -0,0 +1,47 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Cluster { + + private String clusterId; + + private String clusterSid; + + private String name; + + private String region; + + private String type; + + private String mode; + + private String state; + + private String kafkaVersion; + + private List logicalZones; + + private String payment; + + private Boolean aclEnabled; + + private Boolean publicIpEnabled; + + private Boolean intranetIpEnabled; + + private List authenticationModes; + + private List tags; + + private String createTime; + + private String expirationTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ClusterConfigOption.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ClusterConfigOption.java new file mode 100644 index 00000000..558a821a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ClusterConfigOption.java @@ -0,0 +1,32 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ClusterConfigOption { + private String name; + + private String description; + + private String updateMode; + + private Object[] scope; + + private Object defaultValue; + + private Object currentValue; + + private String type; + + private String unit; + + private String category; + + private ClusterConfigOverrideMode overrideMode; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ClusterConfigOverrideMode.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ClusterConfigOverrideMode.java new file mode 100644 index 00000000..2e66ee16 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ClusterConfigOverrideMode.java @@ -0,0 +1,6 @@ +package com.baidubce.services.kafka.model.cluster; + +public enum ClusterConfigOverrideMode { + REQUIRED, + OPTIONAL; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ClusterDetail.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ClusterDetail.java new file mode 100644 index 00000000..31a24e12 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ClusterDetail.java @@ -0,0 +1,35 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ClusterDetail { + + private String clusterId; + + private String clusterSid; + + private String name; + + private String region; + + private String type; + + private String mode; + + private String state; + + private Provisioned provisioned; + + private List tags; + + private String createTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ConfigMeta.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ConfigMeta.java new file mode 100644 index 00000000..a388c695 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ConfigMeta.java @@ -0,0 +1,22 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.LinkedHashMap; +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ConfigMeta { + + private String configId; + + private String revisionId; + + private Map context = new LinkedHashMap(); +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Controller.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Controller.java new file mode 100644 index 00000000..9fe93c3b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Controller.java @@ -0,0 +1,21 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Controller { + + private Integer brokerId; + + private String changeTime; + + private String publicIp; + + private String internalIp; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/CreateClusterRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/CreateClusterRequest.java new file mode 100644 index 00000000..36441f5e --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/CreateClusterRequest.java @@ -0,0 +1,41 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import java.util.List; + +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class CreateClusterRequest extends AbstractBceRequest { + + private String name; + + private Mode mode; + + private Type type; + + private Provisioned provisioned; + + private List tags; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/CreateClusterResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/CreateClusterResponse.java new file mode 100644 index 00000000..72df451c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/CreateClusterResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class CreateClusterResponse extends AbstractBceResponse { + + private String clusterId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/DecreaseBrokerCountRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/DecreaseBrokerCountRequest.java new file mode 100644 index 00000000..fa086921 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/DecreaseBrokerCountRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class DecreaseBrokerCountRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private Integer numberOfBrokerNodes; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public DecreaseBrokerCountRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public DecreaseBrokerCountRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/DecreaseBrokerCountResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/DecreaseBrokerCountResponse.java new file mode 100644 index 00000000..09858e08 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/DecreaseBrokerCountResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class DecreaseBrokerCountResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/DeleteClusterRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/DeleteClusterRequest.java new file mode 100644 index 00000000..8e0ea154 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/DeleteClusterRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class DeleteClusterRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public DeleteClusterRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public DeleteClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/DeleteClusterResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/DeleteClusterResponse.java new file mode 100644 index 00000000..13050710 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/DeleteClusterResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class DeleteClusterResponse extends AbstractBceResponse { + + /** + * The id of cluster. + */ + private String clusterId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ExpandBrokerDiskCapacityRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ExpandBrokerDiskCapacityRequest.java new file mode 100644 index 00000000..039cac3f --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ExpandBrokerDiskCapacityRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class ExpandBrokerDiskCapacityRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private Long storageSize; + + private List couponIds; + + private Boolean isAutoPay; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ExpandBrokerDiskCapacityRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ExpandBrokerDiskCapacityRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ExpandBrokerDiskCapacityResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ExpandBrokerDiskCapacityResponse.java new file mode 100644 index 00000000..791638c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ExpandBrokerDiskCapacityResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class ExpandBrokerDiskCapacityResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterAccessEndpointsRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterAccessEndpointsRequest.java new file mode 100644 index 00000000..676e2067 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterAccessEndpointsRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetClusterAccessEndpointsRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetClusterAccessEndpointsRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetClusterAccessEndpointsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterAccessEndpointsResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterAccessEndpointsResponse.java new file mode 100644 index 00000000..01ff8065 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterAccessEndpointsResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class GetClusterAccessEndpointsResponse extends AbstractBceResponse { + + private List accessEndpoints; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterConfigurationsRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterConfigurationsRequest.java new file mode 100644 index 00000000..4dfda797 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterConfigurationsRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetClusterConfigurationsRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetClusterConfigurationsRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetClusterConfigurationsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterConfigurationsResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterConfigurationsResponse.java new file mode 100644 index 00000000..d6d3a9cb --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterConfigurationsResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class GetClusterConfigurationsResponse extends AbstractBceResponse { + + private List context; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterCurrentControllerRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterCurrentControllerRequest.java new file mode 100644 index 00000000..616e5fa7 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterCurrentControllerRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class GetClusterCurrentControllerRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetClusterCurrentControllerRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetClusterCurrentControllerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterCurrentControllerResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterCurrentControllerResponse.java new file mode 100644 index 00000000..54675171 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterCurrentControllerResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class GetClusterCurrentControllerResponse extends AbstractBceResponse { + + private Controller controller; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterDetailRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterDetailRequest.java new file mode 100644 index 00000000..13fb8cac --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterDetailRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetClusterDetailRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetClusterDetailRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetClusterDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterDetailResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterDetailResponse.java new file mode 100644 index 00000000..738765f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterDetailResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class GetClusterDetailResponse extends AbstractBceResponse { + + private ClusterDetail cluster; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterHistoryControllerRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterHistoryControllerRequest.java new file mode 100644 index 00000000..b264428c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterHistoryControllerRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class GetClusterHistoryControllerRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetClusterHistoryControllerRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetClusterHistoryControllerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterHistoryControllerResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterHistoryControllerResponse.java new file mode 100644 index 00000000..03752b91 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterHistoryControllerResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.cluster; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class GetClusterHistoryControllerResponse extends AbstractBceResponse { + + private List controllers; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterNodesRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterNodesRequest.java new file mode 100644 index 00000000..70838f81 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterNodesRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; +import lombok.Data; + +@Data +public class GetClusterNodesRequest extends ListRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String state; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetClusterNodesRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetClusterNodesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterNodesResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterNodesResponse.java new file mode 100644 index 00000000..1454444b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/GetClusterNodesResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.ListResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class GetClusterNodesResponse extends ListResponse { + + private List nodes; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/IncreaseBrokerCountRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/IncreaseBrokerCountRequest.java new file mode 100644 index 00000000..b0671935 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/IncreaseBrokerCountRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class IncreaseBrokerCountRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private Integer numberOfBrokerNodes; + + private List couponIds; + + private Boolean isAutoPay; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public IncreaseBrokerCountRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public IncreaseBrokerCountRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/IncreaseBrokerCountResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/IncreaseBrokerCountResponse.java new file mode 100644 index 00000000..5b1a594e --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/IncreaseBrokerCountResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class IncreaseBrokerCountResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ListClustersRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ListClustersRequest.java new file mode 100644 index 00000000..9ee28fe9 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ListClustersRequest.java @@ -0,0 +1,36 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; +import lombok.Data; + +@Data +public class ListClustersRequest extends ListRequest { + + private String clusterName; + + private String state; + + private String mode; + + private String kafkaVersion; + + private String payment; + + private String tagKey; + + private String tagValue; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListClustersRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListClustersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ListClustersResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ListClustersResponse.java new file mode 100644 index 00000000..a3b6e6cb --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ListClustersResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.ListResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListClustersResponse extends ListResponse { + + private List clusters; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Mode.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Mode.java new file mode 100644 index 00000000..83aa17a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Mode.java @@ -0,0 +1,6 @@ +package com.baidubce.services.kafka.model.cluster; + +public enum Mode { + HA, + HP +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Node.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Node.java new file mode 100644 index 00000000..e52e5160 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Node.java @@ -0,0 +1,19 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.Data; + +@Data +public class Node { + + private String brokerId; + + private String host; + + private String nodeId; + + private String state; + + private String publicIp; + + private String internalIp; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Provisioned.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Provisioned.java new file mode 100644 index 00000000..3b6a7f11 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Provisioned.java @@ -0,0 +1,59 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Provisioned { + + private String kafkaVersion; + + private Billing billing; + + private Vpc vpc; + + private List subnets; + + private List logicalZones; + + private List securityGroup; + + private String vpcId; + + private List subnetIds; + + private List securityGroupIds; + + private boolean publicIpEnabled; + + private int publicIpBandwidth = 0; + + private boolean intranetIpEnabled; + + private List authentications; + + private boolean aclEnabled; + + private int numberOfBrokerNodes; + + private Integer numberOfBrokerNodesPerZone; + + private String nodeType; + + private StorageMeta storageMeta; + + private Boolean storagePolicyEnabled; + + private StoragePolicy storagePolicy; + + private ConfigMeta configMeta; + + private boolean deploySetEnabled; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ResizeClusterEipBandwidthRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ResizeClusterEipBandwidthRequest.java new file mode 100644 index 00000000..b502a879 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ResizeClusterEipBandwidthRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class ResizeClusterEipBandwidthRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private Integer publicIpBandwidth; + + private List couponIds; + + private Boolean isAutoPay; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ResizeClusterEipBandwidthRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ResizeClusterEipBandwidthRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/ResizeClusterEipBandwidthResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/ResizeClusterEipBandwidthResponse.java new file mode 100644 index 00000000..82760443 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/ResizeClusterEipBandwidthResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class ResizeClusterEipBandwidthResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/RestartBrokerRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/RestartBrokerRequest.java new file mode 100644 index 00000000..4c65bb39 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/RestartBrokerRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class RestartBrokerRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String nodeId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public RestartBrokerRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public RestartBrokerRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/RestartBrokerResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/RestartBrokerResponse.java new file mode 100644 index 00000000..4263ed65 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/RestartBrokerResponse.java @@ -0,0 +1,15 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class RestartBrokerResponse extends AbstractBceResponse { + + private String clusterId; + + private String nodeId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/RestartClusterRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/RestartClusterRequest.java new file mode 100644 index 00000000..966fb9de --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/RestartClusterRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class RestartClusterRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public RestartClusterRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public RestartClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/RestartClusterResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/RestartClusterResponse.java new file mode 100644 index 00000000..8f586a89 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/RestartClusterResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class RestartClusterResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/SecurityGroup.java b/src/main/java/com/baidubce/services/kafka/model/cluster/SecurityGroup.java new file mode 100644 index 00000000..d36ee70a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/SecurityGroup.java @@ -0,0 +1,23 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SecurityGroup { + + private String securityGroupId; + + private String securityGroupUuid; + + private String name; + + private String vpcId; + + private String vpcUuid; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StartClusterRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StartClusterRequest.java new file mode 100644 index 00000000..6471c3d9 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StartClusterRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class StartClusterRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public StartClusterRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public StartClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StartClusterResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StartClusterResponse.java new file mode 100644 index 00000000..1b578572 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StartClusterResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class StartClusterResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StopClusterRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StopClusterRequest.java new file mode 100644 index 00000000..6a46ee12 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StopClusterRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class StopClusterRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public StopClusterRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public StopClusterRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StopClusterResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StopClusterResponse.java new file mode 100644 index 00000000..787b6635 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StopClusterResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class StopClusterResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StorageAutoDelete.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageAutoDelete.java new file mode 100644 index 00000000..f65297f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageAutoDelete.java @@ -0,0 +1,16 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StorageAutoDelete { + private Integer diskUsedThresholdPercent; + private Long logMinRetentionMs; + private Long logMinRetentionBytes; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StorageAutoExpand.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageAutoExpand.java new file mode 100644 index 00000000..108d73ad --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageAutoExpand.java @@ -0,0 +1,17 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StorageAutoExpand { + private Integer diskUsedThresholdPercent; + private Integer stepForwardPercent; + private Integer stepForwardSize; + private Integer maxStorageSize; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StorageDynamicRetention.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageDynamicRetention.java new file mode 100644 index 00000000..4afd7b76 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageDynamicRetention.java @@ -0,0 +1,16 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StorageDynamicRetention { + private Integer diskUsedThresholdPercent; + private Integer stepForwardPercent; + private Long logMinRetentionMs; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StorageMeta.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageMeta.java new file mode 100644 index 00000000..2a0adb80 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageMeta.java @@ -0,0 +1,19 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StorageMeta { + + private StorageType storageType; + + private int storageSize; + + private int numberOfDisk = 1; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StoragePolicy.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StoragePolicy.java new file mode 100644 index 00000000..89b78d81 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StoragePolicy.java @@ -0,0 +1,17 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StoragePolicy { + private StoragePolicyType type; + private StorageAutoDelete autoDelete; + private StorageAutoExpand autoExpand; + private StorageDynamicRetention dynamicRetention; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StoragePolicyType.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StoragePolicyType.java new file mode 100644 index 00000000..05deee4b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StoragePolicyType.java @@ -0,0 +1,8 @@ +package com.baidubce.services.kafka.model.cluster; + +public enum StoragePolicyType { + NONE, + AUTO_DELETE, + AUTO_EXPAND, + DYNAMIC_RETENTION; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/StorageType.java b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageType.java new file mode 100644 index 00000000..f55aaf48 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/StorageType.java @@ -0,0 +1,6 @@ +package com.baidubce.services.kafka.model.cluster; + +public enum StorageType { + SSD, + ENHANCED_SSD_PL1 +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Subnet.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Subnet.java new file mode 100644 index 00000000..32562b98 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Subnet.java @@ -0,0 +1,27 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Subnet { + + private String subnetId; + + private String subnetUuid; + + private String name; + + private String subnetType; + + private String zone; + + private String vpcId; + + private String cidr; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterEipRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterEipRequest.java new file mode 100644 index 00000000..2c3ae075 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterEipRequest.java @@ -0,0 +1,41 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +@Data +public class SwitchClusterEipRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private Boolean publicIpEnabled; + + private Integer publicIpBandwidth; + + private Boolean aclEnabled; + + private Set authenticationMode; + + private List couponIds; + + private Boolean isAutoPay; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public SwitchClusterEipRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public SwitchClusterEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterEipResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterEipResponse.java new file mode 100644 index 00000000..ab616c05 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterEipResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class SwitchClusterEipResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterIntranetIpRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterIntranetIpRequest.java new file mode 100644 index 00000000..bd3693f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterIntranetIpRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.kafka.model.cluster; + +import java.util.Set; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class SwitchClusterIntranetIpRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private Boolean intranetIpEnabled; + + private Set authenticationMode; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public SwitchClusterIntranetIpRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public SwitchClusterIntranetIpRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterIntranetIpResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterIntranetIpResponse.java new file mode 100644 index 00000000..96b35c63 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/SwitchClusterIntranetIpResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class SwitchClusterIntranetIpResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Tag.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Tag.java new file mode 100644 index 00000000..aaf0754b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Tag.java @@ -0,0 +1,17 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Tag { + + private String tagKey; + + private String tagValue; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Type.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Type.java new file mode 100644 index 00000000..4ff3f744 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Type.java @@ -0,0 +1,6 @@ +package com.baidubce.services.kafka.model.cluster; + +public enum Type { + PROVISIONED, + SERVERLESS +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateAccessConfigRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateAccessConfigRequest.java new file mode 100644 index 00000000..d7fcd711 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateAccessConfigRequest.java @@ -0,0 +1,32 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class UpdateAccessConfigRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private Boolean aclEnabled; + + private List authentications; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public UpdateAccessConfigRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public UpdateAccessConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateAccessConfigResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateAccessConfigResponse.java new file mode 100644 index 00000000..d964a4ce --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateAccessConfigResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class UpdateAccessConfigResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateBrokerNodeTypeRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateBrokerNodeTypeRequest.java new file mode 100644 index 00000000..513a7695 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateBrokerNodeTypeRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class UpdateBrokerNodeTypeRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String nodeType; + + private List couponIds; + + private Boolean isAutoPay; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public UpdateBrokerNodeTypeRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public UpdateBrokerNodeTypeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateBrokerNodeTypeResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateBrokerNodeTypeResponse.java new file mode 100644 index 00000000..3786bfa3 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateBrokerNodeTypeResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class UpdateBrokerNodeTypeResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateKafkaConfigRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateKafkaConfigRequest.java new file mode 100644 index 00000000..1b9d644b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateKafkaConfigRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class UpdateKafkaConfigRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String configId; + + private Integer revisionId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public UpdateKafkaConfigRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public UpdateKafkaConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateKafkaConfigResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateKafkaConfigResponse.java new file mode 100644 index 00000000..a982b787 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateKafkaConfigResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class UpdateKafkaConfigResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateSecurityGroupRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateSecurityGroupRequest.java new file mode 100644 index 00000000..88ed8d39 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateSecurityGroupRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class UpdateSecurityGroupRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private List securityGroupIds; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public UpdateSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public UpdateSecurityGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateSecurityGroupResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateSecurityGroupResponse.java new file mode 100644 index 00000000..396756d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateSecurityGroupResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class UpdateSecurityGroupResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateStoragePolicyRequest.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateStoragePolicyRequest.java new file mode 100644 index 00000000..6505f308 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateStoragePolicyRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class UpdateStoragePolicyRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private Boolean storagePolicyEnabled; + + private StoragePolicy storagePolicy; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public UpdateStoragePolicyRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public UpdateStoragePolicyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateStoragePolicyResponse.java b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateStoragePolicyResponse.java new file mode 100644 index 00000000..7c377441 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/UpdateStoragePolicyResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.cluster; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class UpdateStoragePolicyResponse extends AbstractBceResponse { + + private String clusterId; + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/cluster/Vpc.java b/src/main/java/com/baidubce/services/kafka/model/cluster/Vpc.java new file mode 100644 index 00000000..45b06a4f --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/cluster/Vpc.java @@ -0,0 +1,21 @@ +package com.baidubce.services.kafka.model.cluster; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Vpc { + + private String vpcId; + + private String vpcUuid; + + private String name; + + private String cidr; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfig.java b/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfig.java new file mode 100644 index 00000000..fb83c23d --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfig.java @@ -0,0 +1,23 @@ +package com.baidubce.services.kafka.model.config; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ClusterConfig { + + private String configId; + + private String name; + + private String state; + + private String description; + + private String createTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfigOption.java b/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfigOption.java new file mode 100644 index 00000000..3d9669de --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfigOption.java @@ -0,0 +1,24 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.services.kafka.model.cluster.ClusterConfigOverrideMode; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ClusterConfigOption { + private String name; + private String description; + private String updateMode; + private Object[] scope; + private Object defaultValue; + private Object currentValue; + private String type; + private String unit; + private String category; + private ClusterConfigOverrideMode overrideMode; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfigRevision.java b/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfigRevision.java new file mode 100644 index 00000000..93943af3 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfigRevision.java @@ -0,0 +1,17 @@ +package com.baidubce.services.kafka.model.config; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ClusterConfigRevision { + private Integer revisionId; + private String state; + private String description; + private String createTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfigRevisionDetail.java b/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfigRevisionDetail.java new file mode 100644 index 00000000..3ab7da2b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/ClusterConfigRevisionDetail.java @@ -0,0 +1,20 @@ +package com.baidubce.services.kafka.model.config; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ClusterConfigRevisionDetail { + private Integer revisionId; + private String state; + private String description; + private String createTime; + private List context; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigRequest.java b/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigRequest.java new file mode 100644 index 00000000..987b8953 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.Map; + +@Data +public class CreateClusterConfigRequest extends AbstractBceRequest { + + private String name; + + private String description; + + private Map context; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public CreateClusterConfigRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public CreateClusterConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigResponse.java b/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigResponse.java new file mode 100644 index 00000000..f2e1e5a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class CreateClusterConfigResponse extends AbstractBceResponse { + + private String configId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigRevisionRequest.java b/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigRevisionRequest.java new file mode 100644 index 00000000..e27c6d6c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigRevisionRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.Map; + +@Data +public class CreateClusterConfigRevisionRequest extends AbstractBceRequest { + + /** + * The id of config. + */ + private String configId; + + private Integer revisionId; + + private String description; + + private Map context; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public CreateClusterConfigRevisionRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public CreateClusterConfigRevisionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigRevisionResponse.java b/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigRevisionResponse.java new file mode 100644 index 00000000..33aa4365 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/CreateClusterConfigRevisionResponse.java @@ -0,0 +1,9 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class CreateClusterConfigRevisionResponse extends AbstractBceResponse { + private Integer revisionId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/DeleteClusterConfigRequest.java b/src/main/java/com/baidubce/services/kafka/model/config/DeleteClusterConfigRequest.java new file mode 100644 index 00000000..9ee7b54b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/DeleteClusterConfigRequest.java @@ -0,0 +1,27 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class DeleteClusterConfigRequest extends AbstractBceRequest { + + /** + * The id of config. + */ + private String configId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public DeleteClusterConfigRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public DeleteClusterConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/DeleteClusterConfigResponse.java b/src/main/java/com/baidubce/services/kafka/model/config/DeleteClusterConfigResponse.java new file mode 100644 index 00000000..4690b0fa --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/DeleteClusterConfigResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class DeleteClusterConfigResponse extends AbstractBceResponse { + + /** + * The id of config. + */ + private String configId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigRequest.java b/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigRequest.java new file mode 100644 index 00000000..102fcdd6 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigRequest.java @@ -0,0 +1,26 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetClusterConfigRequest extends AbstractBceRequest { + + /** + * The id of config. + */ + private String configId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetClusterConfigRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetClusterConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigResponse.java b/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigResponse.java new file mode 100644 index 00000000..c876c046 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class GetClusterConfigResponse extends AbstractBceResponse { + + private ClusterConfig config; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigRevisionRequest.java b/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigRevisionRequest.java new file mode 100644 index 00000000..4a3ad566 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigRevisionRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetClusterConfigRevisionRequest extends AbstractBceRequest { + /** + * The id of config. + */ + private String configId; + + /** + * The revision id of config. + */ + private Integer revisionId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetClusterConfigRevisionRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetClusterConfigRevisionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigRevisionResponse.java b/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigRevisionResponse.java new file mode 100644 index 00000000..76e596f4 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/GetClusterConfigRevisionResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class GetClusterConfigRevisionResponse extends AbstractBceResponse { + + private ClusterConfigRevisionDetail revision; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigRevisionsRequest.java b/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigRevisionsRequest.java new file mode 100644 index 00000000..858aae88 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigRevisionsRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class ListClusterConfigRevisionsRequest extends AbstractBceRequest { + + private String configId; + + private String state; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListClusterConfigRevisionsRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListClusterConfigRevisionsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigRevisionsResponse.java b/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigRevisionsResponse.java new file mode 100644 index 00000000..ec32fcce --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigRevisionsResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListClusterConfigRevisionsResponse extends AbstractBceResponse { + private List revisions; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigsRequest.java b/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigsRequest.java new file mode 100644 index 00000000..53a6dd09 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigsRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; +import lombok.Data; + +@Data +public class ListClusterConfigsRequest extends ListRequest { + + private String configName; + + private String state; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListClusterConfigsRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListClusterConfigsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigsResponse.java b/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigsResponse.java new file mode 100644 index 00000000..b09b451a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/config/ListClusterConfigsResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.config; + +import com.baidubce.model.ListResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListClusterConfigsResponse extends ListResponse { + + private List configs; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/DeleteConsumerGroupRequest.java b/src/main/java/com/baidubce/services/kafka/model/consumer/DeleteConsumerGroupRequest.java new file mode 100644 index 00000000..03f867de --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/DeleteConsumerGroupRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class DeleteConsumerGroupRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String groupName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public DeleteConsumerGroupRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public DeleteConsumerGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/DeleteConsumerGroupResponse.java b/src/main/java/com/baidubce/services/kafka/model/consumer/DeleteConsumerGroupResponse.java new file mode 100644 index 00000000..168145b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/DeleteConsumerGroupResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class DeleteConsumerGroupResponse extends AbstractBceResponse { + + private String groupName; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/GetSubscribedTopicOverviewRequest.java b/src/main/java/com/baidubce/services/kafka/model/consumer/GetSubscribedTopicOverviewRequest.java new file mode 100644 index 00000000..16bdf3a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/GetSubscribedTopicOverviewRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class GetSubscribedTopicOverviewRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String groupName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetSubscribedTopicOverviewRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetSubscribedTopicOverviewRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/GetSubscribedTopicOverviewResponse.java b/src/main/java/com/baidubce/services/kafka/model/consumer/GetSubscribedTopicOverviewResponse.java new file mode 100644 index 00000000..952c8184 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/GetSubscribedTopicOverviewResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class GetSubscribedTopicOverviewResponse extends AbstractBceResponse { + + private SubscribedTopicOverview overview; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/Group.java b/src/main/java/com/baidubce/services/kafka/model/consumer/Group.java new file mode 100644 index 00000000..18244af5 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/Group.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.consumer; + +import lombok.Data; + +@Data +public class Group { + + private String groupName; + + private String updateTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/ListConsumerGroupRequest.java b/src/main/java/com/baidubce/services/kafka/model/consumer/ListConsumerGroupRequest.java new file mode 100644 index 00000000..d7ca7b46 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/ListConsumerGroupRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class ListConsumerGroupRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String groupName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListConsumerGroupRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListConsumerGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/ListConsumerGroupResponse.java b/src/main/java/com/baidubce/services/kafka/model/consumer/ListConsumerGroupResponse.java new file mode 100644 index 00000000..af7fffc7 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/ListConsumerGroupResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListConsumerGroupResponse extends AbstractBceResponse { + + private List groups; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/ListSubscribedTopicsRequest.java b/src/main/java/com/baidubce/services/kafka/model/consumer/ListSubscribedTopicsRequest.java new file mode 100644 index 00000000..f278ca04 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/ListSubscribedTopicsRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class ListSubscribedTopicsRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String groupName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListSubscribedTopicsRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListSubscribedTopicsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/ListSubscribedTopicsResponse.java b/src/main/java/com/baidubce/services/kafka/model/consumer/ListSubscribedTopicsResponse.java new file mode 100644 index 00000000..69467d4c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/ListSubscribedTopicsResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListSubscribedTopicsResponse extends AbstractBceResponse { + + private List topics; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/ResetConsumerGroupRequest.java b/src/main/java/com/baidubce/services/kafka/model/consumer/ResetConsumerGroupRequest.java new file mode 100644 index 00000000..5b84b212 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/ResetConsumerGroupRequest.java @@ -0,0 +1,38 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class ResetConsumerGroupRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String groupName; + + private String topicName; + + private List partitions; + + private String resetStrategy; + + private String resetValue; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ResetConsumerGroupRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ResetConsumerGroupRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/ResetConsumerGroupResponse.java b/src/main/java/com/baidubce/services/kafka/model/consumer/ResetConsumerGroupResponse.java new file mode 100644 index 00000000..cc23d97f --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/ResetConsumerGroupResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.consumer; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class ResetConsumerGroupResponse extends AbstractBceResponse { + + private String groupName; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/consumer/SubscribedTopicOverview.java b/src/main/java/com/baidubce/services/kafka/model/consumer/SubscribedTopicOverview.java new file mode 100644 index 00000000..d3642e1a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/consumer/SubscribedTopicOverview.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.consumer; + +import lombok.Data; + +@Data +public class SubscribedTopicOverview { + + private int subscribedTopicNum; + + private String lastConsumeTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/CancelJobRequest.java b/src/main/java/com/baidubce/services/kafka/model/job/CancelJobRequest.java new file mode 100644 index 00000000..3f7caeea --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/CancelJobRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class CancelJobRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String jobId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public CancelJobRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public CancelJobRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/CancelJobResponse.java b/src/main/java/com/baidubce/services/kafka/model/job/CancelJobResponse.java new file mode 100644 index 00000000..42448ffa --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/CancelJobResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class CancelJobResponse extends AbstractBceResponse { + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/GetJobDetailRequest.java b/src/main/java/com/baidubce/services/kafka/model/job/GetJobDetailRequest.java new file mode 100644 index 00000000..dacd5dba --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/GetJobDetailRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetJobDetailRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String jobId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetJobDetailRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetJobDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/GetJobDetailResponse.java b/src/main/java/com/baidubce/services/kafka/model/job/GetJobDetailResponse.java new file mode 100644 index 00000000..1b40fdf7 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/GetJobDetailResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class GetJobDetailResponse extends AbstractBceResponse { + + private Job job; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/kafka/model/job/GetOperationDetailRequest.java b/src/main/java/com/baidubce/services/kafka/model/job/GetOperationDetailRequest.java new file mode 100644 index 00000000..dc6af2b9 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/GetOperationDetailRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetOperationDetailRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String jobId; + + private String operationId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetOperationDetailRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetOperationDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/GetOperationDetailResponse.java b/src/main/java/com/baidubce/services/kafka/model/job/GetOperationDetailResponse.java new file mode 100644 index 00000000..dd3b043b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/GetOperationDetailResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class GetOperationDetailResponse extends AbstractBceResponse { + + private OperationDetail operation; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/Job.java b/src/main/java/com/baidubce/services/kafka/model/job/Job.java new file mode 100644 index 00000000..6847fb09 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/Job.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.job; + +import lombok.Data; + +import java.util.List; + +@Data +public class Job { + private String name ; + private String jobId; + private String status; + private List operations; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/JobGroup.java b/src/main/java/com/baidubce/services/kafka/model/job/JobGroup.java new file mode 100644 index 00000000..ab43df16 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/JobGroup.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.job; + +import lombok.Data; + +@Data +public class JobGroup { + + private String groupName; + + private String state; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/ListJobsRequest.java b/src/main/java/com/baidubce/services/kafka/model/job/ListJobsRequest.java new file mode 100644 index 00000000..1cff1706 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/ListJobsRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; +import lombok.Data; + +@Data +public class ListJobsRequest extends ListRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String name; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListOperationsRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListJobsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/ListJobsResponse.java b/src/main/java/com/baidubce/services/kafka/model/job/ListJobsResponse.java new file mode 100644 index 00000000..d466b5c8 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/ListJobsResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.model.ListResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListJobsResponse extends ListResponse { + + private List jobs; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/Operation.java b/src/main/java/com/baidubce/services/kafka/model/job/Operation.java new file mode 100644 index 00000000..36c32483 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/Operation.java @@ -0,0 +1,18 @@ +package com.baidubce.services.kafka.model.job; + +import lombok.Data; + +@Data +public class Operation { + private String jobId; + private String name; + private String status; + private String operationId; + private String type; + private String state; + private Integer process; + private String schedule; + private String createTime; + private String startTime; + private String endTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/OperationDetail.java b/src/main/java/com/baidubce/services/kafka/model/job/OperationDetail.java new file mode 100644 index 00000000..7a16ec48 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/OperationDetail.java @@ -0,0 +1,31 @@ +package com.baidubce.services.kafka.model.job; + +import lombok.Data; + +import java.util.List; + +@Data +public class OperationDetail { + + private String jobId; + + private String operationId; + + private String type; + + private String state; + + private int process; + + private List groups; + + private String sourceContext; + + private String targetContext; + + private String createTime; + + private String startTime; + + private String endTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/ResumeJobRequest.java b/src/main/java/com/baidubce/services/kafka/model/job/ResumeJobRequest.java new file mode 100644 index 00000000..f1bfaa9c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/ResumeJobRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class ResumeJobRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String jobId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ResumeOperationRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ResumeJobRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/ResumeJobResponse.java b/src/main/java/com/baidubce/services/kafka/model/job/ResumeJobResponse.java new file mode 100644 index 00000000..6e3efb3c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/ResumeJobResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class ResumeJobResponse extends AbstractBceResponse { + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/StartJobRequest.java b/src/main/java/com/baidubce/services/kafka/model/job/StartJobRequest.java new file mode 100644 index 00000000..7493b670 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/StartJobRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class StartJobRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String jobId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public StartJobRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public StartJobRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/StartJobResponse.java b/src/main/java/com/baidubce/services/kafka/model/job/StartJobResponse.java new file mode 100644 index 00000000..25903ef7 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/StartJobResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class StartJobResponse extends AbstractBceResponse { + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/SuspendJobRequest.java b/src/main/java/com/baidubce/services/kafka/model/job/SuspendJobRequest.java new file mode 100644 index 00000000..69dbdd17 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/SuspendJobRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class SuspendJobRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String jobId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public SuspendJobRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public SuspendJobRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/job/SuspendJobResponse.java b/src/main/java/com/baidubce/services/kafka/model/job/SuspendJobResponse.java new file mode 100644 index 00000000..a86f4a6a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/job/SuspendJobResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.job; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class SuspendJobResponse extends AbstractBceResponse { + + private String jobId; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/quota/CreateQuotaRequest.java b/src/main/java/com/baidubce/services/kafka/model/quota/CreateQuotaRequest.java new file mode 100644 index 00000000..40b69c7d --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/quota/CreateQuotaRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.kafka.model.quota; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class CreateQuotaRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String username; + + private Boolean userDefault; + + private String clientId; + + private Boolean clientDefault; + + private Long producerByteRate; + + private Long consumerByteRate; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public CreateQuotaRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public CreateQuotaRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/quota/CreateQuotaResponse.java b/src/main/java/com/baidubce/services/kafka/model/quota/CreateQuotaResponse.java new file mode 100644 index 00000000..bb276393 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/quota/CreateQuotaResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.quota; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class CreateQuotaResponse extends AbstractBceResponse { + + private Quota quota; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/quota/DeleteQuotaRequest.java b/src/main/java/com/baidubce/services/kafka/model/quota/DeleteQuotaRequest.java new file mode 100644 index 00000000..268c997c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/quota/DeleteQuotaRequest.java @@ -0,0 +1,35 @@ +package com.baidubce.services.kafka.model.quota; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class DeleteQuotaRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String username; + + private Boolean userDefault; + + private String clientId; + + private Boolean clientDefault; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public DeleteQuotaRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public DeleteQuotaRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/quota/DeleteQuotaResponse.java b/src/main/java/com/baidubce/services/kafka/model/quota/DeleteQuotaResponse.java new file mode 100644 index 00000000..61117432 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/quota/DeleteQuotaResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.kafka.model.quota; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class DeleteQuotaResponse extends AbstractBceResponse { + + private String username; + + private Boolean userDefault; + + private String clientId; + + private Boolean clientDefault; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/quota/ListQuotasRequest.java b/src/main/java/com/baidubce/services/kafka/model/quota/ListQuotasRequest.java new file mode 100644 index 00000000..4cece43b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/quota/ListQuotasRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.kafka.model.quota; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class ListQuotasRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String entityType; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListQuotasRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListQuotasRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/quota/ListQuotasResponse.java b/src/main/java/com/baidubce/services/kafka/model/quota/ListQuotasResponse.java new file mode 100644 index 00000000..5b717a8a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/quota/ListQuotasResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.quota; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListQuotasResponse extends AbstractBceResponse { + + private List quotas; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/quota/Quota.java b/src/main/java/com/baidubce/services/kafka/model/quota/Quota.java new file mode 100644 index 00000000..946ecab5 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/quota/Quota.java @@ -0,0 +1,19 @@ +package com.baidubce.services.kafka.model.quota; + +import lombok.Data; + +@Data +public class Quota { + + private String username; + + private Boolean userDefault; + + private String clientId; + + private Boolean clientDefault; + + private Long producerByteRate; + + private Long consumerByteRate; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/quota/UpdateQuotaRequest.java b/src/main/java/com/baidubce/services/kafka/model/quota/UpdateQuotaRequest.java new file mode 100644 index 00000000..0e63bd6d --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/quota/UpdateQuotaRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.kafka.model.quota; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class UpdateQuotaRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String username; + + private Boolean userDefault; + + private String clientId; + + private Boolean clientDefault; + + private Long producerByteRate; + + private Long consumerByteRate; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public UpdateQuotaRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public UpdateQuotaRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/quota/UpdateQuotaResponse.java b/src/main/java/com/baidubce/services/kafka/model/quota/UpdateQuotaResponse.java new file mode 100644 index 00000000..6997f8b0 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/quota/UpdateQuotaResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.quota; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class UpdateQuotaResponse extends AbstractBceResponse { + + private Quota quota; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/CreateTopicRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/CreateTopicRequest.java new file mode 100644 index 00000000..62e7be27 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/CreateTopicRequest.java @@ -0,0 +1,36 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.Map; + +@Data +public class CreateTopicRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + private int partitionNum; + + private int replicationFactor; + + private Map otherConfigs; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public CreateTopicRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public CreateTopicRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/CreateTopicResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/CreateTopicResponse.java new file mode 100644 index 00000000..d86bd93c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/CreateTopicResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class CreateTopicResponse extends AbstractBceResponse { + + private String topicName; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/DeleteTopicRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/DeleteTopicRequest.java new file mode 100644 index 00000000..2a2ffb14 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/DeleteTopicRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class DeleteTopicRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public DeleteTopicRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public DeleteTopicRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/DeleteTopicResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/DeleteTopicResponse.java new file mode 100644 index 00000000..e9d8a6c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/DeleteTopicResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class DeleteTopicResponse extends AbstractBceResponse { + + private String topicName; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupDetailRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupDetailRequest.java new file mode 100644 index 00000000..b57bf9c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupDetailRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetSubscribedGroupDetailRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + private String groupName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetSubscribedGroupDetailRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetSubscribedGroupDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupDetailResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupDetailResponse.java new file mode 100644 index 00000000..2a9cf13a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupDetailResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class GetSubscribedGroupDetailResponse extends AbstractBceResponse { + + private List subscribePartitions; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupOverviewRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupOverviewRequest.java new file mode 100644 index 00000000..7790568f --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupOverviewRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class GetSubscribedGroupOverviewRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetSubscribedGroupOverviewRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetSubscribedGroupOverviewRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupOverviewResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupOverviewResponse.java new file mode 100644 index 00000000..f6c3607f --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetSubscribedGroupOverviewResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class GetSubscribedGroupOverviewResponse extends AbstractBceResponse { + + private SubscribedGroupOverview overview; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicDetailRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicDetailRequest.java new file mode 100644 index 00000000..4903e5b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicDetailRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetTopicDetailRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetTopicDetailRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetTopicDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicDetailResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicDetailResponse.java new file mode 100644 index 00000000..182d0628 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicDetailResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class GetTopicDetailResponse extends AbstractBceResponse { + + private TopicDetail topic; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionDetailRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionDetailRequest.java new file mode 100644 index 00000000..e7666fd4 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionDetailRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class GetTopicPartitionDetailRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + private String partitionId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetTopicPartitionDetailRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetTopicPartitionDetailRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setPartitionId(int partitionId) { + this.partitionId = String.valueOf(partitionId); + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionDetailResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionDetailResponse.java new file mode 100644 index 00000000..f5f52584 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionDetailResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class GetTopicPartitionDetailResponse extends AbstractBceResponse { + + private String topicName; + private TopicPartition partition; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionOverviewRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionOverviewRequest.java new file mode 100644 index 00000000..a32874bd --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionOverviewRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class GetTopicPartitionOverviewRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public GetTopicPartitionOverviewRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public GetTopicPartitionOverviewRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionOverviewResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionOverviewResponse.java new file mode 100644 index 00000000..8135da77 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GetTopicPartitionOverviewResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class GetTopicPartitionOverviewResponse extends AbstractBceResponse { + + private TopicPartitionOverview overview; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/GroupTopicPartition.java b/src/main/java/com/baidubce/services/kafka/model/topic/GroupTopicPartition.java new file mode 100644 index 00000000..85e9d565 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/GroupTopicPartition.java @@ -0,0 +1,25 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +@Data +public class GroupTopicPartition { + + private String topicName; + + private int partitionId; + + private String consumerId; + + private String clientId; + + private String host; + + private long maxOffset; + + private long committedOffset; + + private long lag; + + private String lastConsumeTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/ListSubscribedGroupsRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/ListSubscribedGroupsRequest.java new file mode 100644 index 00000000..9e2d5c66 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/ListSubscribedGroupsRequest.java @@ -0,0 +1,29 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +@Data +public class ListSubscribedGroupsRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListSubscribedGroupsRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListSubscribedGroupsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/ListSubscribedGroupsResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/ListSubscribedGroupsResponse.java new file mode 100644 index 00000000..c26b35c4 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/ListSubscribedGroupsResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListSubscribedGroupsResponse extends AbstractBceResponse { + + private List groups; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicConfigOptionsRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicConfigOptionsRequest.java new file mode 100644 index 00000000..cf9a8c0a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicConfigOptionsRequest.java @@ -0,0 +1,22 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class ListTopicConfigOptionsRequest extends AbstractBceRequest { + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListTopicConfigOptionsRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListTopicConfigOptionsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicConfigOptionsResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicConfigOptionsResponse.java new file mode 100644 index 00000000..a462375d --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicConfigOptionsResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.topic; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class ListTopicConfigOptionsResponse extends AbstractBceResponse { + + private List topicConfigs; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicPartitionsRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicPartitionsRequest.java new file mode 100644 index 00000000..cd99dcf6 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicPartitionsRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.services.kafka.model.PageListRequest; +import lombok.Data; + +@Data +public class ListTopicPartitionsRequest extends PageListRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListTopicPartitionsRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListTopicPartitionsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicPartitionsResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicPartitionsResponse.java new file mode 100644 index 00000000..d50bfef8 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicPartitionsResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.services.kafka.model.PageListResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListTopicPartitionsResponse extends PageListResponse { + + private List partitions; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicRequest.java new file mode 100644 index 00000000..65a3d520 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicRequest.java @@ -0,0 +1,30 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; +import org.apache.htrace.fasterxml.jackson.annotation.JsonIgnore; + +@Data +public class ListTopicRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + @JsonIgnore + private String topicName; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ListTopicRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ListTopicRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicResponse.java new file mode 100644 index 00000000..f30097e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/ListTopicResponse.java @@ -0,0 +1,12 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ListTopicResponse extends AbstractBceResponse { + + private List topics; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartOffsetRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartOffsetRequest.java new file mode 100644 index 00000000..32258614 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartOffsetRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class QueryTopicMessagesByStartOffsetRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + private int partitionId; + + private long startOffset; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public QueryTopicMessagesByStartOffsetRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public QueryTopicMessagesByStartOffsetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartOffsetResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartOffsetResponse.java new file mode 100644 index 00000000..a4da39f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartOffsetResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.topic; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class QueryTopicMessagesByStartOffsetResponse extends AbstractBceResponse { + + private List messages; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartTimeRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartTimeRequest.java new file mode 100644 index 00000000..7c9a9842 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartTimeRequest.java @@ -0,0 +1,33 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class QueryTopicMessagesByStartTimeRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + private Integer partitionId; + + private long startTime; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public QueryTopicMessagesByStartTimeRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public QueryTopicMessagesByStartTimeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartTimeResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartTimeResponse.java new file mode 100644 index 00000000..41669505 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicMessagesByStartTimeResponse.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.topic; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class QueryTopicMessagesByStartTimeResponse extends AbstractBceResponse { + + private List messages; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicRecord.java b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicRecord.java new file mode 100644 index 00000000..5890d5e3 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/QueryTopicRecord.java @@ -0,0 +1,25 @@ +package com.baidubce.services.kafka.model.topic; + +import java.util.List; + +import lombok.Data; + +@Data +public class QueryTopicRecord { + + private String topicName; + + private int partitionId; + + private long offset; + + private long timestamp; + + private String key; + + private String value; + + private int size; + + private List headers; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/SendTopicMessageRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/SendTopicMessageRequest.java new file mode 100644 index 00000000..16e5c915 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/SendTopicMessageRequest.java @@ -0,0 +1,35 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +@Data +public class SendTopicMessageRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + private Integer partitionId; + + private String key; + + private String value; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public SendTopicMessageRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public SendTopicMessageRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/SendTopicMessageResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/SendTopicMessageResponse.java new file mode 100644 index 00000000..79fd099c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/SendTopicMessageResponse.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +@Data +public class SendTopicMessageResponse extends AbstractBceResponse { + + private SendTopicRecord message; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/SendTopicRecord.java b/src/main/java/com/baidubce/services/kafka/model/topic/SendTopicRecord.java new file mode 100644 index 00000000..2519f33a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/SendTopicRecord.java @@ -0,0 +1,23 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +@Data +public class SendTopicRecord { + + private String topicName; + + private int partitionId; + + private long offset; + + private long timestamp; + + private String key; + + private String value; + + private int serializedKeySize; + + private int serializedValueSize; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/SubscribedGroupOverview.java b/src/main/java/com/baidubce/services/kafka/model/topic/SubscribedGroupOverview.java new file mode 100644 index 00000000..32aa2262 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/SubscribedGroupOverview.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +@Data +public class SubscribedGroupOverview { + + private Integer subscribedGroupNum; + + private String lastConsumeTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/Topic.java b/src/main/java/com/baidubce/services/kafka/model/topic/Topic.java new file mode 100644 index 00000000..aba59d1c --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/Topic.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +@Data +public class Topic { + private String topicName; + + private String createTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/TopicConfig.java b/src/main/java/com/baidubce/services/kafka/model/topic/TopicConfig.java new file mode 100644 index 00000000..4bb108a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/TopicConfig.java @@ -0,0 +1,13 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +@Data +public class TopicConfig { + + private String key; + + private Object value; + + private String unit; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/TopicConfigOption.java b/src/main/java/com/baidubce/services/kafka/model/topic/TopicConfigOption.java new file mode 100644 index 00000000..c86dd344 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/TopicConfigOption.java @@ -0,0 +1,19 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +@Data +public class TopicConfigOption { + + private String name; + + private Object defaultValue; + + private String description; + + private String type; + + private String unit; + + private Object[] valueScope; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/TopicDetail.java b/src/main/java/com/baidubce/services/kafka/model/topic/TopicDetail.java new file mode 100644 index 00000000..b232a2df --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/TopicDetail.java @@ -0,0 +1,27 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +import java.util.List; + +@Data +public class TopicDetail { + + private String topicName; + + private int partitionNum; + + private int replicationFactor; + + private double brokersSkewed; + + private double brokersLeaderSkewed; + + private double brokersSpread; + + private double preferredReplicas; + + private double underReplicated; + + private List otherConfigs; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/TopicPartition.java b/src/main/java/com/baidubce/services/kafka/model/topic/TopicPartition.java new file mode 100644 index 00000000..adcb9280 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/TopicPartition.java @@ -0,0 +1,26 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +import java.util.List; + +@Data +public class TopicPartition { + private String topicName; + + private int partitionId; + + private int leaderId; + + private List replicas; + + private List inSyncReplicas; + + private long minOffset; + + private long maxOffset; + + private long messageNum; + + private String lastUpdateTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/TopicPartitionOverview.java b/src/main/java/com/baidubce/services/kafka/model/topic/TopicPartitionOverview.java new file mode 100644 index 00000000..e5023e9d --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/TopicPartitionOverview.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +@Data +public class TopicPartitionOverview { + + private long totalMessageNum; + + private String lastUpdateTime; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/TopicRecordHeader.java b/src/main/java/com/baidubce/services/kafka/model/topic/TopicRecordHeader.java new file mode 100644 index 00000000..a17b2089 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/TopicRecordHeader.java @@ -0,0 +1,11 @@ +package com.baidubce.services.kafka.model.topic; + +import lombok.Data; + +@Data +public class TopicRecordHeader { + + private String key; + + private String value; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/UpdateTopicRequest.java b/src/main/java/com/baidubce/services/kafka/model/topic/UpdateTopicRequest.java new file mode 100644 index 00000000..a1ac7fe4 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/UpdateTopicRequest.java @@ -0,0 +1,38 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import java.util.Map; + +@Data +public class UpdateTopicRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + private String topicName; + + private String partitionNum; + + private Map otherConfigs; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public UpdateTopicRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public UpdateTopicRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setPartitionNum(int partitionNum) { + this.partitionNum = String.valueOf(partitionNum); + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/topic/UpdateTopicResponse.java b/src/main/java/com/baidubce/services/kafka/model/topic/UpdateTopicResponse.java new file mode 100644 index 00000000..40c42e4b --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/topic/UpdateTopicResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.kafka.model.topic; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +@Data +public class UpdateTopicResponse extends AbstractBceResponse { + + private String topicName; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/user/CreateUserRequest.java b/src/main/java/com/baidubce/services/kafka/model/user/CreateUserRequest.java new file mode 100644 index 00000000..2ad52571 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/user/CreateUserRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.kafka.model.user; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for creating a newly user. + */ +@Data +public class CreateUserRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * The parameter to specified the username. + */ + private String username; + + /** + * The parameter to specified the password. + */ + private String password; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public CreateUserRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public CreateUserRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/kafka/model/user/CreateUserResponse.java b/src/main/java/com/baidubce/services/kafka/model/user/CreateUserResponse.java new file mode 100644 index 00000000..82c3f2b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/user/CreateUserResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.kafka.model.user; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * The response for creating a newly user. + */ +@Data +public class CreateUserResponse extends AbstractBceResponse { + + /** + * The username of user created. + */ + private String username; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/kafka/model/user/DeleteUserRequest.java b/src/main/java/com/baidubce/services/kafka/model/user/DeleteUserRequest.java new file mode 100644 index 00000000..e8199786 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/user/DeleteUserRequest.java @@ -0,0 +1,34 @@ +package com.baidubce.services.kafka.model.user; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for deleting a user. + */ +@Data +public class DeleteUserRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * The username of user which to delete. + */ + private String username; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteUserRequest with credentials. + */ + @Override + public DeleteUserRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/kafka/model/user/DeleteUserResponse.java b/src/main/java/com/baidubce/services/kafka/model/user/DeleteUserResponse.java new file mode 100644 index 00000000..4a0efe5e --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/user/DeleteUserResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.kafka.model.user; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * The response for deleting a user. + */ +@Data +public class DeleteUserResponse extends AbstractBceResponse { + + /** + * The username of user which deleted. + */ + private String username; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/kafka/model/user/ListUserResponse.java b/src/main/java/com/baidubce/services/kafka/model/user/ListUserResponse.java new file mode 100644 index 00000000..f9e07a6a --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/user/ListUserResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.kafka.model.user; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * The response for listing all of the available specifications of user. + */ +@Data +public class ListUserResponse extends AbstractBceResponse { + + /** + * List of user info. + */ + private List users; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/kafka/model/user/ListUsersRequest.java b/src/main/java/com/baidubce/services/kafka/model/user/ListUsersRequest.java new file mode 100644 index 00000000..641c3b15 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/user/ListUsersRequest.java @@ -0,0 +1,37 @@ +package com.baidubce.services.kafka.model.user; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The request for listing all of the available specifications of user. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ListUsersRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + @JsonIgnore + private String clusterId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListUserRequest with credentials. + */ + @Override + public ListUsersRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/kafka/model/user/ResetUserPasswordRequest.java b/src/main/java/com/baidubce/services/kafka/model/user/ResetUserPasswordRequest.java new file mode 100644 index 00000000..300bfdaa --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/user/ResetUserPasswordRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.kafka.model.user; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for reseting a password of a user. + */ +@Data +public class ResetUserPasswordRequest extends AbstractBceRequest { + + /** + * The id of cluster. + */ + private String clusterId; + + /** + * The parameter to specified the username. + */ + private String username; + + /** + * The parameter to specified the password. + */ + private String password; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return public ResetUserPasswordRequest withRequestCredentials(BceCredentials credentials) { with credentials. + */ + @Override + public ResetUserPasswordRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kafka/model/user/ResetUserPasswordResponse.java b/src/main/java/com/baidubce/services/kafka/model/user/ResetUserPasswordResponse.java new file mode 100644 index 00000000..6e6ccb32 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/user/ResetUserPasswordResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.kafka.model.user; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * The response for reseting a password of a user. + */ +@Data +public class ResetUserPasswordResponse extends AbstractBceResponse { + + /** + * The username of the user reseted. + */ + private String username; +} diff --git a/src/main/java/com/baidubce/services/kafka/model/user/User.java b/src/main/java/com/baidubce/services/kafka/model/user/User.java new file mode 100644 index 00000000..123aae18 --- /dev/null +++ b/src/main/java/com/baidubce/services/kafka/model/user/User.java @@ -0,0 +1,19 @@ +package com.baidubce.services.kafka.model.user; + +import lombok.Data; + +/** + * user detail info model. + */ +@Data +public class User { + /** + * user's name. + */ + private String username; + + /** + * the time for creating user. + */ + private String createTime; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/kms/KmsClient.java b/src/main/java/com/baidubce/services/kms/KmsClient.java new file mode 100644 index 00000000..dfb8df8c --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/KmsClient.java @@ -0,0 +1,613 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.kms.model.EncryptedRsaKey; +import com.baidubce.services.kms.model.EncryptedSm2Key; +import com.baidubce.services.kms.model.KmsResponse; +import com.baidubce.services.kms.model.ImportAsymmetricKeyRequest; +import com.baidubce.services.kms.model.ImportKeyRequest; +import com.baidubce.services.kms.model.CreateKeyResponse; +import com.baidubce.services.kms.model.CreateKeyRequest; +import com.baidubce.services.kms.model.GetParametersForImportResponse; +import com.baidubce.services.kms.model.GetParametersForImportRequest; +import com.baidubce.services.kms.model.Constants; +import com.baidubce.services.kms.model.ListKeysRequest; +import com.baidubce.services.kms.model.ListKeysResponse; +import com.baidubce.services.kms.model.EncryptRequest; +import com.baidubce.services.kms.model.EncryptResponse; +import com.baidubce.services.kms.model.DecryptRequest; +import com.baidubce.services.kms.model.DecryptResponse; +import com.baidubce.services.kms.model.GenerateDataKeyRequest; +import com.baidubce.services.kms.model.GenerateDataKeyResponse; +import com.baidubce.services.kms.model.EnableKeyRequest; +import com.baidubce.services.kms.model.UpdateRotationRequest; +import com.baidubce.services.kms.model.UpdateRotationResponse; +import com.baidubce.services.kms.model.DisableKeyRequest; +import com.baidubce.services.kms.model.ScheduleKeyDeletionRequest; +import com.baidubce.services.kms.model.ScheduleKeyDeletionResponse; +import com.baidubce.services.kms.model.CancelKeyDeletionRequest; +import com.baidubce.services.kms.model.DescribeKeyRequest; +import com.baidubce.services.kms.model.DescribeKeyResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Key Manager Service. + */ +public class KmsClient extends AbstractBceClient { + + /** + * Responsible for handing httpResponses from all Kms service calls. + */ + private static final HttpResponseHandler[] kmsHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + + public KmsClient() { + this(new KmsClientConfiguration()); + } + + public KmsClient(KmsClientConfiguration clientConfiguration) { + super(clientConfiguration, kmsHandlers, true); + } + + /** + * Creates a new master key. + * + * @param request The request object containing all options for creating master key. + * + * @return The newly created master key. + */ + public CreateKeyResponse createKey(CreateKeyRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "CreateKey"); + + byte[] json = null; + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_DESCRIPTION, request.getDescription()); + jsonGenerator.writeStringField(Constants.FIELD_KEYUSAGE, request.getKeyUsage()); + jsonGenerator.writeStringField(Constants.FIELD_KEYSPEC, request.getKeySpec()); + jsonGenerator.writeStringField(Constants.FIELD_PROTECTEDBY, request.getProtectedBy()); + jsonGenerator.writeStringField(Constants.FIELD_ORIGIN, request.getOrigin()); + jsonGenerator.writeNumberField(Constants.FIELD_ROTATECYCLE, request.getRotateCycle()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException(Constants.FAIL_TO_GET_UTF8_BYTES, e); + } + + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + + CreateKeyResponse response = this.invokeHttpClient(internalRequest, CreateKeyResponse.class); + return response; + } + + /** + * Returns ListKeysResponse containing master keys. + * + * @param request The request object containing limit and marker for listing master keys. + * + * @return ListKeysResponse containing a listing of the master keys. + */ + public ListKeysResponse listKeys(ListKeysRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "ListKeys"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeNumberField(Constants.FIELD_LIMIT, request.getLimit()); + jsonGenerator.writeStringField(Constants.FIELD_MARKER, request.getMarker()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + + ListKeysResponse response = this.invokeHttpClient(internalRequest, ListKeysResponse.class); + return response; + } + + /** + * Returns EncryptResponse containing ciphertext which is encrypted using plaintext by master key. + * + * @param request The request object containing masterKeyId and plaintext. + * + * @return EncryptResponse containing ciphertext and master key id. + */ + public EncryptResponse encrypt(EncryptRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter("action", "Encrypt"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeStringField(Constants.FIELD_PLAINTEXT, request.getPlaintext()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + + EncryptResponse response = this.invokeHttpClient(internalRequest, EncryptResponse.class); + return response; + } + + /** + * Returns DecryptResponse containing plaintext which is decrypted using ciphertext. + * MasterKeyId is in ciphertext. + * + * @param request The request object containing ciphertext. + * + * @return DecryptResponse containing master key id and plaintext . + */ + public DecryptResponse decrypt(DecryptRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "Decrypt"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeStringField(Constants.FIELD_CIPHERTEXT, request.getCiphertext()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + + DecryptResponse response = this.invokeHttpClient(internalRequest, DecryptResponse.class); + return response; + } + + /** + * Returns GenerateDataKeyResponse containing ciphertext, keyId and plaintext which is random generated + * by kms. + * + * @param request The request object containing master key id, keySpec and numberOfBytes. + * + * @return GenerateDataKeyResponse containing ciphertext, keyId and plaintext. + */ + public GenerateDataKeyResponse generateDataKey(GenerateDataKeyRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "GenerateDataKey"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeStringField(Constants.FIELD_KEYSPEC, request.getKeySpec()); + jsonGenerator.writeNumberField(Constants.FIELD_NUMBEROFBYTES, request.getNumberOfBytes()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + + GenerateDataKeyResponse response = this.invokeHttpClient(internalRequest, GenerateDataKeyResponse.class); + return response; + } + + /** + * Enable the specified master key. + * + * @param request The request object containing master key id. + */ + public void enableKey(EnableKeyRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "EnableKey"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + + this.invokeHttpClient(internalRequest, KmsResponse.class); + return ; + } + + /** + * Disable the specified master key. + * + * @param request The request object containing master key id. + */ + public void disableKey(DisableKeyRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "DisableKey"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + + this.invokeHttpClient(internalRequest, KmsResponse.class); + } + + /** + * Returns ScheduleKeyDeletionResponse containing deletionDate of specified master key and master key id. + * + * @param request The request object containing master key id, pendingWindowsInDays. + * + * @return ScheduleKeyDeletionResponse containing deletionDate and master key id. + */ + public ScheduleKeyDeletionResponse scheduleKeyDeletion(ScheduleKeyDeletionRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "ScheduleKeyDeletion"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeNumberField(Constants.FIELD_PENDINGWINDOWINDAYS, request.getPendingWindowsInDays()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + + ScheduleKeyDeletionResponse response = this.invokeHttpClient(internalRequest, + ScheduleKeyDeletionResponse.class); + return response; + } + + /** + * Cancels deletion of the specified master key. + * + * @param request The request object containing master key id. + */ + public void cancelKeyDeletion(CancelKeyDeletionRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "CancelKeyDeletion"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + this.invokeHttpClient(internalRequest, KmsResponse.class); + + } + + /** + * Returns DescribeKeyResponse containing deletionDate of specified master key and master key id. + * + * @param request The request object containing master key id, pendingWindowsInDays. + * + * @return DescribeKeyResponse containing deletionDate and master key id. + */ + public DescribeKeyResponse describeKey(DescribeKeyRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "DescribeKey"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + DescribeKeyResponse response = this.invokeHttpClient(internalRequest, DescribeKeyResponse.class); + return response; + } + + public GetParametersForImportResponse getParametersForImport(GetParametersForImportRequest request) + throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "GetParametersForImport"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeStringField(Constants.FIELD_WRAPPINGALGORITHM, request.getWrappingAlgorithm()); + jsonGenerator.writeStringField(Constants.FIELD_WRAPPINGKEYSPEC, request.getWrappingKeySpec()); + jsonGenerator.writeStringField(Constants.FIELD_PUBLICKEYENCODING, request.getPublicKeyEncoding()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + GetParametersForImportResponse response = this.invokeHttpClient(internalRequest, + GetParametersForImportResponse.class); + return response; + } + + public KmsResponse importKey(ImportKeyRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "ImportKey"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeStringField(Constants.FIELD_IMPORTTOKEN, request.getImportToken()); + jsonGenerator.writeStringField(Constants.FIELD_ENCRYPTEDKEY, request.getEncryptedKey()); + jsonGenerator.writeStringField(Constants.FIELD_KEYSPEC, request.getKeySpec()); + jsonGenerator.writeStringField(Constants.FIELD_KEYUSAGE, request.getKeyUsage()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + KmsResponse response = this.invokeHttpClient(internalRequest, KmsResponse.class); + return response; + } + + public KmsResponse importAsymmetricKey(ImportAsymmetricKeyRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "ImportAsymmetricKey"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeStringField(Constants.FIELD_IMPORTTOKEN, request.getImportToken()); + jsonGenerator.writeStringField(Constants.FIELD_ASYMMETRICKEYSPEC, request.getAsymmetricKeySpec()); + jsonGenerator.writeStringField(Constants.FIELD_ASYMMETRICKEYUSAGE, request.getAsymmetricKeyUsage()); + jsonGenerator.writeStringField(Constants.FIELD_ENCRYPTEDKEYENCRYPTIONKEY, + request.getEncryptedKeyEncryptionKey()); + if (request.getEncryptedRsaKey() != null) { + EncryptedRsaKey rsaKey = request.getEncryptedRsaKey(); + jsonGenerator.writeObjectFieldStart(Constants.FIELD_ENCRYPTEDRSAKEY); + jsonGenerator.writeStringField("publicKeyDer", rsaKey.getPublicKeyDer()); + jsonGenerator.writeStringField("encryptedD", rsaKey.getEncryptedD()); + jsonGenerator.writeStringField("encryptedP", rsaKey.getEncryptedP()); + jsonGenerator.writeStringField("encryptedQ", rsaKey.getEncryptedQ()); + jsonGenerator.writeStringField("encryptedDp", rsaKey.getEncryptedDp()); + jsonGenerator.writeStringField("encryptedDq", rsaKey.getEncryptedDq()); + jsonGenerator.writeStringField("encryptedQinv", rsaKey.getEncryptedQinv()); + jsonGenerator.writeEndObject(); + } else if (request.getEncryptedSm2Key() != null) { + EncryptedSm2Key sm2Key = request.getEncryptedSm2Key(); + jsonGenerator.writeObjectFieldStart(Constants.FIELD_ENCRYPTEDSM2KEY); + jsonGenerator.writeStringField("publicKeyDer", sm2Key.getPublicKeyDer()); + jsonGenerator.writeStringField("encryptedPrivateKey", sm2Key.getEncryptedPrivateKey()); + jsonGenerator.writeEndObject(); + } + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + + setInternalRequest(internalRequest, writer); + KmsResponse response = this.invokeHttpClient(internalRequest, KmsResponse.class); + return response; + } + + public UpdateRotationResponse updateRotateKey(UpdateRotationRequest request) throws Exception { + checkNotNull(request, Constants.REQUEST_SHOULD_NOT_BE_NULL); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter(Constants.ACTION, "EnableRotation"); + + StringWriter writer = new StringWriter(); + JsonGenerator jsonGenerator = null; + try { + jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField(Constants.FIELD_KEYID, request.getKeyId()); + jsonGenerator.writeNumberField(Constants.FIELD_ROTATECYCLE, request.getRotateCycle()); + jsonGenerator.writeEndObject(); + } catch (IOException e) { + throw new BceClientException(Constants.FAIL_TO_GENERATE_JSON, e); + } finally { + if (jsonGenerator != null) { + jsonGenerator.close(); + } + } + setInternalRequest(internalRequest, writer); + + UpdateRotationResponse response = this.invokeHttpClient(internalRequest, UpdateRotationResponse.class); + return response; + } + + + /** + * set InternalRequest with StringWriter + * + * @param internalRequest + * @param writer + */ + public void setInternalRequest(InternalRequest internalRequest, StringWriter writer) { + + byte[] json = null; + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException(Constants.FAIL_TO_GET_UTF8_BYTES, e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, Constants.APPLICATION_JSON); + internalRequest.setContent(RestartableInputStream.wrap(json)); + } + + /** + * Creates and initializes a new request object for the specified KMS resource. This method is responsible + * for determining the right way to address resources. + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod) { + InternalRequest request = + new InternalRequest(httpMethod, HttpUtils.appendUri(this.getEndpoint())); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + +} + + +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/KmsClientConfiguration.java b/src/main/java/com/baidubce/services/kms/KmsClientConfiguration.java new file mode 100644 index 00000000..a76a380a --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/KmsClientConfiguration.java @@ -0,0 +1,32 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms; + +import com.baidubce.BceClientConfiguration; + +public class KmsClientConfiguration extends BceClientConfiguration { + + public KmsClientConfiguration() { + super(); + } + + public KmsClientConfiguration(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, null); + } + + public KmsClientConfiguration(BceClientConfiguration clientConfiguration, String kmsEndpoint) { + super(clientConfiguration, kmsEndpoint); + } +} + +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/CancelKeyDeletionRequest.java b/src/main/java/com/baidubce/services/kms/model/CancelKeyDeletionRequest.java new file mode 100644 index 00000000..d2e12d9a --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/CancelKeyDeletionRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for canceling master key deletion. + */ +public class CancelKeyDeletionRequest extends GenericKmsRequest { + + private String keyId; + + public CancelKeyDeletionRequest() { + } + + public CancelKeyDeletionRequest(String keyId) { + this.setKeyId(keyId); + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public CancelKeyDeletionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/Constants.java b/src/main/java/com/baidubce/services/kms/model/Constants.java new file mode 100644 index 00000000..170ac90a --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/Constants.java @@ -0,0 +1,164 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.kms.model; + +/** + * Contains constants of kms source code + */ +public class Constants { + + + public static final String ACTION = "action"; + + public static final String FIELD_DESCRIPTION = "description"; + + public static final String FIELD_KEYUSAGE = "keyUsage"; + + public static final String FIELD_KEYID = "keyId"; + + public static final String FIELD_PENDINGWINDOWINDAYS = "pendingWindowInDays"; + + public static final String FIELD_KEYSPEC = "keySpec"; + + public static final String FIELD_PROTECTEDBY = "protectedBy"; + + public static final String FIELD_ORIGIN = "origin"; + + public static final String FIELD_ROTATECYCLE = "rotateCycle"; + + public static final String FIELD_NUMBEROFBYTES = "numberOfBytes"; + + public static final String FIELD_CIPHERTEXT = "ciphertext"; + + public static final String FIELD_PLAINTEXT = "plaintext"; + + public static final String FIELD_LIMIT = "limit"; + + public static final String FIELD_MARKER = "marker"; + + public static final String FIELD_WRAPPINGALGORITHM = "wrappingAlgorithm"; + + public static final String FIELD_WRAPPINGKEYSPEC = "wrappingKeySpec"; + + public static final String FIELD_PUBLICKEYENCODING = "publicKeyEncoding"; + + public static final String FIELD_IMPORTTOKEN = "importToken"; + + public static final String FIELD_ENCRYPTEDKEY = "encryptedKey"; + + public static final String FIELD_ASYMMETRICKEYSPEC = "asymmetricKeySpec"; + + public static final String FIELD_ASYMMETRICKEYUSAGE = "asymmetricKeyUsage"; + + public static final String FIELD_ENCRYPTEDRSAKEY = "encryptedRsaKey"; + + public static final String FIELD_ENCRYPTEDSM2KEY = "encryptedSm2Key"; + + public static final String FIELD_ENCRYPTEDKEYENCRYPTIONKEY = "encryptedKeyEncryptionKey"; + + public static final String REQUEST_SHOULD_NOT_BE_NULL = "request should not be null"; + + public static final String FAIL_TO_GENERATE_JSON = "Fail to generate json"; + + public static final String APPLICATION_JSON = "application/json"; + + public static final String FAIL_TO_GET_UTF8_BYTES = "Fail to get UTF-8 bytes"; + + public static final String FAIL_TO_SUPPORT = "Sorry, don't support"; + + + public enum KeySpec { + BAIDU_ASE_256("BAIDU_ASE_256"), + + AES_128("AES_128"), + + AES_256("AES_256"), + + SM1_128("SM1_128"), + + SM4_128("SM4_128"), + + RSA_1024("RSA_1024"), + + RSA_2048("RSA_2048"), + + RSA_4096("RSA_4096"), + + SM2_256("SM2_256"); + + private final String specific; + + private KeySpec(String specific) { + this.specific = specific; + } + + @Override + public String toString() { + return this.specific; + } + } + + public enum Origin { + BAIDU_KMS("BAIDU_KMS"), + + EXTERNAL("EXTERNAL"); + + private final String specific; + + private Origin(String specific) { + this.specific = specific; + } + + @Override + public String toString() { + return this.specific; + } + } + + public enum ProtectedBy { + HSM("HSM"), + + SOFTWARE("SOFTWARE"); + + private final String specific; + + private ProtectedBy(String specific) { + this.specific = specific; + } + + @Override + public String toString() { + return this.specific; + } + } + + public enum PublicKeyEncoding { + RAW_HEX("RAW_HEX"), + + BASE64("BASE64"), + + PEM("PEM"); + + private final String specific; + + private PublicKeyEncoding(String specific) { + this.specific = specific; + } + + @Override + public String toString() { + return this.specific; + } + } +} diff --git a/src/main/java/com/baidubce/services/kms/model/CreateKeyRequest.java b/src/main/java/com/baidubce/services/kms/model/CreateKeyRequest.java new file mode 100644 index 00000000..57bd0039 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/CreateKeyRequest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for creating master key. + */ +public class CreateKeyRequest extends GenericKmsRequest { + + private String description; + + private String protectedBy; + + private String keySpec; + + private String keyUsage; + + private String origin; + + private int rotateCycle; + + public CreateKeyRequest() { + } + + public CreateKeyRequest(String description, String protectedBy, String keyUsage, + String keySpec, String origin) { + this.setDescription(description); + this.setProtectedBy(protectedBy); + this.setKeySpec(keySpec); + this.setKeyUsage(keyUsage); + this.setOrigin(origin); + this.setRotateCycle(0); + } + + public CreateKeyRequest(String description, String protectedBy, String keyUsage, + String keySpec, String origin, int rotateCycle) { + this.setDescription(description); + this.setProtectedBy(protectedBy); + this.setKeySpec(keySpec); + this.setKeyUsage(keyUsage); + this.setOrigin(origin); + this.setRotateCycle(rotateCycle); + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public CreateKeyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setKeyUsage(String keyUsage) { + this.keyUsage = keyUsage; + } + + public String getKeyUsage() { + return keyUsage; + } + + public String getProtectedBy() { + return protectedBy; + } + + public void setProtectedBy(String protectedBy) { + this.protectedBy = protectedBy; + } + public String getKeySpec() { + return keySpec; + } + + public void setKeySpec(String keySpec) { + this.keySpec = keySpec; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String origin) { + this.origin = origin; + } + + public void setRotateCycle(int rotateCycle){ + this.rotateCycle = rotateCycle; + } + + public int getRotateCycle(){ + return this.rotateCycle; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/CreateKeyResponse.java b/src/main/java/com/baidubce/services/kms/model/CreateKeyResponse.java new file mode 100644 index 00000000..41c9c440 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/CreateKeyResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +/** + * Contains the details returned from Kms after calling the CreateKey operation. + */ +public class CreateKeyResponse extends KmsResponse { + + private KeyMetadata keyMetadata; + + public void setKeyMetadata(KeyMetadata keyMetadata) { + this.keyMetadata = keyMetadata; + } + + public KeyMetadata getKeyMetadata() { + return keyMetadata; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/DecryptRequest.java b/src/main/java/com/baidubce/services/kms/model/DecryptRequest.java new file mode 100644 index 00000000..0d6c1a7f --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/DecryptRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for decrypting ciphertext. + */ +public class DecryptRequest extends GenericKmsRequest { + + private String keyId; + + private String ciphertext; + + public DecryptRequest() { + } + + public DecryptRequest(String keyId, String ciphertext) { + this.keyId = keyId; + this.ciphertext = ciphertext; + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public DecryptRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setCiphertext(String ciphertext) { + this.ciphertext = ciphertext; + } + + public String getCiphertext() { + return ciphertext; + } + + public String getKeyId() { + return keyId; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/DecryptResponse.java b/src/main/java/com/baidubce/services/kms/model/DecryptResponse.java new file mode 100644 index 00000000..7dea5269 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/DecryptResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +/** + * Contains the details returned from Kms after calling the Decrypt operation. + */ +public class DecryptResponse extends KmsResponse { + + private String keyId; + + private String plaintext; + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } + + public void setPlaintext(String plaintext) { + this.plaintext = plaintext; + } + + public String getPlaintext() { + return plaintext; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/DescribeKeyRequest.java b/src/main/java/com/baidubce/services/kms/model/DescribeKeyRequest.java new file mode 100644 index 00000000..952807ec --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/DescribeKeyRequest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for describe master key. + */ +public class DescribeKeyRequest extends GenericKmsRequest { + + private String keyId; + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } + + public DescribeKeyRequest() { + super(); + } + + public DescribeKeyRequest(String keyId) { + this.setKeyId(keyId); + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public DescribeKeyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/DescribeKeyResponse.java b/src/main/java/com/baidubce/services/kms/model/DescribeKeyResponse.java new file mode 100644 index 00000000..e2786c50 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/DescribeKeyResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +/** + * Contains the details returned from Kms after calling the DescribeKey operation. + */ +public class DescribeKeyResponse extends KmsResponse { + + private KeyMetadata keyMetadata; + + public void setKeyMetadata(KeyMetadata keyMetadata) { + this.keyMetadata = keyMetadata; + } + + public KeyMetadata getKeyMetadata() { + return keyMetadata; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/DisableKeyRequest.java b/src/main/java/com/baidubce/services/kms/model/DisableKeyRequest.java new file mode 100644 index 00000000..352a2ea7 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/DisableKeyRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for disable key. + */ +public class DisableKeyRequest extends GenericKmsRequest { + + private String keyId; + + public DisableKeyRequest() { + } + + public DisableKeyRequest(String keyId) { + this.setKeyId(keyId); + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public DisableKeyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/EnableKeyRequest.java b/src/main/java/com/baidubce/services/kms/model/EnableKeyRequest.java new file mode 100644 index 00000000..9efb4e93 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/EnableKeyRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for enableKey master key. + */ +public class EnableKeyRequest extends GenericKmsRequest { + + private String keyId; + + public EnableKeyRequest() { + } + + public EnableKeyRequest(String keyId) { + this.setKeyId(keyId); + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public EnableKeyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/EncryptRequest.java b/src/main/java/com/baidubce/services/kms/model/EncryptRequest.java new file mode 100644 index 00000000..3ba2d7e0 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/EncryptRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for encrypt plaintext. + */ +public class EncryptRequest extends GenericKmsRequest { + + private String keyId; + + private String plaintext; + + public EncryptRequest() { + } + + public EncryptRequest(String keyId, String plaintext) { + this.setKeyId(keyId); + this.setPlaintext(plaintext); + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public EncryptRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setPlaintext(String plaintext) { + this.plaintext = plaintext; + } + + public String getPlaintext() { + return plaintext; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/EncryptResponse.java b/src/main/java/com/baidubce/services/kms/model/EncryptResponse.java new file mode 100644 index 00000000..1e397d8e --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/EncryptResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +/** + * Contains the details returned from Kms after calling the Encrypt operation. + */ +public class EncryptResponse extends KmsResponse { + + private String ciphertext; + + private String keyId; + + public void setCiphertext(String ciphertext) { + this.ciphertext = ciphertext; + } + + public String getCiphertext() { + return ciphertext; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/EncryptedRsaKey.java b/src/main/java/com/baidubce/services/kms/model/EncryptedRsaKey.java new file mode 100644 index 00000000..5b43a8d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/EncryptedRsaKey.java @@ -0,0 +1,89 @@ +package com.baidubce.services.kms.model; + +public class EncryptedRsaKey { + + private String publicKeyDer; + + private String encryptedD; + + private String encryptedP; + + private String encryptedQ; + + private String encryptedDp; + + private String encryptedDq; + + private String encryptedQinv; + + public EncryptedRsaKey() { + } + + public EncryptedRsaKey(String publicKeyDer, String encryptedD, + String encryptedP, String encryptedQ, String encryptedDp, + String encryptedDq, String encryptedQinv) { + this.publicKeyDer = publicKeyDer; + this.encryptedD = encryptedD; + this.encryptedP = encryptedP; + this.encryptedQ = encryptedQ; + this.encryptedDp = encryptedDp; + this.encryptedDq = encryptedDq; + this.encryptedQinv = encryptedQinv; + } + + public String getPublicKeyDer() { + return publicKeyDer; + } + + public void setPublicKeyDer(String publicKeyDer) { + this.publicKeyDer = publicKeyDer; + } + + public String getEncryptedD() { + return encryptedD; + } + + public void setEncryptedD(String encryptedD) { + this.encryptedD = encryptedD; + } + + public String getEncryptedP() { + return encryptedP; + } + + public void setEncryptedP(String encryptedP) { + this.encryptedP = encryptedP; + } + + public String getEncryptedQ() { + return encryptedQ; + } + + public void setEncryptedQ(String encryptedQ) { + this.encryptedQ = encryptedQ; + } + + public String getEncryptedDp() { + return encryptedDp; + } + + public void setEncryptedDp(String encryptedDp) { + this.encryptedDp = encryptedDp; + } + + public String getEncryptedDq() { + return encryptedDq; + } + + public void setEncryptedDq(String encryptedDq) { + this.encryptedDq = encryptedDq; + } + + public String getEncryptedQinv() { + return encryptedQinv; + } + + public void setEncryptedQinv(String encryptedQinv) { + this.encryptedQinv = encryptedQinv; + } +} diff --git a/src/main/java/com/baidubce/services/kms/model/EncryptedSm2Key.java b/src/main/java/com/baidubce/services/kms/model/EncryptedSm2Key.java new file mode 100644 index 00000000..c428021e --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/EncryptedSm2Key.java @@ -0,0 +1,32 @@ +package com.baidubce.services.kms.model; + +public class EncryptedSm2Key { + + private String publicKeyDer; + + private String encryptedPrivateKey; + + public EncryptedSm2Key() { + } + + public EncryptedSm2Key(String publicKeyDer, String encryptedPrivateKey) { + this.publicKeyDer = publicKeyDer; + this.encryptedPrivateKey = encryptedPrivateKey; + } + + public String getPublicKeyDer() { + return publicKeyDer; + } + + public void setPublicKeyDer(String publicKeyDer) { + this.publicKeyDer = publicKeyDer; + } + + public String getEncryptedPrivateKey() { + return encryptedPrivateKey; + } + + public void setEncryptedPrivateKey(String encryptedPrivateKey) { + this.encryptedPrivateKey = encryptedPrivateKey; + } +} diff --git a/src/main/java/com/baidubce/services/kms/model/GenerateDataKeyRequest.java b/src/main/java/com/baidubce/services/kms/model/GenerateDataKeyRequest.java new file mode 100644 index 00000000..b31630f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/GenerateDataKeyRequest.java @@ -0,0 +1,76 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for generating data key. + */ +public class GenerateDataKeyRequest extends GenericKmsRequest { + + private String keyId; + + /** + * Type of data key, AES_128 or AES_256 + */ + private String keySpec; + + /** + * The length of data key + */ + private int numberOfBytes; + + public GenerateDataKeyRequest() { + } + + public GenerateDataKeyRequest(String keyId, Constants.KeySpec keySpec, int numberOfBytes) { + this.setKeyId(keyId); + this.setKeySpec(keySpec); + this.setNumberOfBytes(numberOfBytes); + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public GenerateDataKeyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } + + public void setKeySpec(Constants.KeySpec keySpec) { + this.keySpec = keySpec.toString(); + } + + public String getKeySpec() { + return keySpec; + } + + public void setNumberOfBytes(int numberOfBytes) { + this.numberOfBytes = numberOfBytes; + } + + public int getNumberOfBytes() { + return numberOfBytes; + } + +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/GenerateDataKeyResponse.java b/src/main/java/com/baidubce/services/kms/model/GenerateDataKeyResponse.java new file mode 100644 index 00000000..2fa2c42c --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/GenerateDataKeyResponse.java @@ -0,0 +1,50 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +/** + * Contains the details returned from Kms after calling the GenerateDataKey operation. + */ +public class GenerateDataKeyResponse extends KmsResponse { + + private String ciphertext; + + private String keyId; + + private String plaintext; + + public void setCiphertext(String ciphertext) { + this.ciphertext = ciphertext; + } + + public String getCiphertext() { + return ciphertext; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } + + public void setPlaintext(String plaintext) { + this.plaintext = plaintext; + } + + public String getPlaintext() { + return plaintext; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/GenericKmsRequest.java b/src/main/java/com/baidubce/services/kms/model/GenericKmsRequest.java new file mode 100644 index 00000000..dc733af2 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/GenericKmsRequest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.model.AbstractBceRequest; + +/** + * Provides options for generic kms request. + */ +public abstract class GenericKmsRequest extends AbstractBceRequest { + + public GenericKmsRequest() { + } + +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/GetParametersForImportRequest.java b/src/main/java/com/baidubce/services/kms/model/GetParametersForImportRequest.java new file mode 100644 index 00000000..f6d8ff93 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/GetParametersForImportRequest.java @@ -0,0 +1,84 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for creating master key. + */ +public class GetParametersForImportRequest extends GenericKmsRequest { + + /** + * master key id + */ + private String keyId; + + /** + * the algorithm for user encrypt local key + */ + private String wrappingAlgorithm; + + /** + * the pubkey spec for user encrypt local key + */ + private String wrappingKeySpec; + + /** + * the type of + */ + private String publicKeyEncoding; + + public GetParametersForImportRequest() { + this.wrappingAlgorithm = "RSAES_PKCS1_V1_5"; + this.wrappingKeySpec = "RSA_2048"; + } + + public GetParametersForImportRequest(String keyId, String publicKeyEncoding) { + this.keyId = keyId; + this.wrappingAlgorithm = "RSAES_PKCS1_V1_5"; + this.wrappingKeySpec = "RSA_2048"; + this.publicKeyEncoding = publicKeyEncoding; + } + + @Override + public GetParametersForImportRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getKeyId() { + return keyId; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getWrappingAlgorithm() { + return wrappingAlgorithm; + } + + public String getWrappingKeySpec() { + return wrappingKeySpec; + } + + public String getPublicKeyEncoding() { + return publicKeyEncoding; + } + + public void setPublicKeyEncoding(String publicKeyEncoding) { + this.publicKeyEncoding = publicKeyEncoding; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/GetParametersForImportResponse.java b/src/main/java/com/baidubce/services/kms/model/GetParametersForImportResponse.java new file mode 100644 index 00000000..300613ee --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/GetParametersForImportResponse.java @@ -0,0 +1,83 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +/** + * Provides options for creating master key. + */ +public class GetParametersForImportResponse extends KmsResponse { + + /** + * master key id + */ + private String keyId; + + /** + * the token for import local key + */ + private String importToken; + + /** + * the valid deadline for import local key + */ + private String tokenValidTill; + + /** + * the publicKey for import local key + */ + private String publicKey; + + public GetParametersForImportResponse() { + } + + public GetParametersForImportResponse(String keyId, String importToken, String tokenValidTill, String publicKey) { + this.keyId = keyId; + this.importToken = importToken; + this.tokenValidTill = tokenValidTill; + this.publicKey = publicKey; + } + + public String getKeyId() { + return keyId; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getImportToken() { + return importToken; + } + + public void setImportToken(String importToken) { + this.importToken = importToken; + } + + public String getTokenValidTill() { + return tokenValidTill; + } + + public void setTokenValidTill(String tokenValidTill) { + this.tokenValidTill = tokenValidTill; + } + + public String getPublicKey() { + return publicKey; + } + + public void setPublicKey(String publicKey) { + this.publicKey = publicKey; + } + +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/ImportAsymmetricKeyRequest.java b/src/main/java/com/baidubce/services/kms/model/ImportAsymmetricKeyRequest.java new file mode 100644 index 00000000..eba005f8 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/ImportAsymmetricKeyRequest.java @@ -0,0 +1,107 @@ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +public class ImportAsymmetricKeyRequest extends GenericKmsRequest { + + private String keyId; + + private String importToken; + + private String asymmetricKeySpec; + + private String asymmetricKeyUsage; + + private String encryptedKeyEncryptionKey; + + private EncryptedRsaKey encryptedRsaKey; + + private EncryptedSm2Key encryptedSm2Key; + + public ImportAsymmetricKeyRequest() { + } + + public ImportAsymmetricKeyRequest(String keyId, String importToken, + String asymmetricKeySpec, String asymmetricKeyUsage, + String encryptedKeyEncryptionKey, EncryptedRsaKey encryptedRsaKey) { + this.keyId = keyId; + this.importToken = importToken; + this.asymmetricKeySpec = asymmetricKeySpec; + this.asymmetricKeyUsage = asymmetricKeyUsage; + this.encryptedKeyEncryptionKey = encryptedKeyEncryptionKey; + this.encryptedRsaKey = encryptedRsaKey; + } + + public ImportAsymmetricKeyRequest(String keyId, String importToken, + String asymmetricKeySpec, String asymmetricKeyUsage, + String encryptedKeyEncryptionKey, EncryptedSm2Key encryptedSm2Key) { + this.keyId = keyId; + this.importToken = importToken; + this.asymmetricKeySpec = asymmetricKeySpec; + this.asymmetricKeyUsage = asymmetricKeyUsage; + this.encryptedKeyEncryptionKey = encryptedKeyEncryptionKey; + this.encryptedSm2Key = encryptedSm2Key; + } + + @Override + public ImportAsymmetricKeyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getKeyId() { + return keyId; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getImportToken() { + return importToken; + } + + public void setImportToken(String importToken) { + this.importToken = importToken; + } + + public String getAsymmetricKeySpec() { + return asymmetricKeySpec; + } + + public void setAsymmetricKeySpec(String asymmetricKeySpec) { + this.asymmetricKeySpec = asymmetricKeySpec; + } + + public String getAsymmetricKeyUsage() { + return asymmetricKeyUsage; + } + + public void setAsymmetricKeyUsage(String asymmetricKeyUsage) { + this.asymmetricKeyUsage = asymmetricKeyUsage; + } + + public String getEncryptedKeyEncryptionKey() { + return encryptedKeyEncryptionKey; + } + + public void setEncryptedKeyEncryptionKey(String encryptedKeyEncryptionKey) { + this.encryptedKeyEncryptionKey = encryptedKeyEncryptionKey; + } + + public EncryptedRsaKey getEncryptedRsaKey() { + return encryptedRsaKey; + } + + public void setEncryptedRsaKey(EncryptedRsaKey encryptedRsaKey) { + this.encryptedRsaKey = encryptedRsaKey; + } + + public EncryptedSm2Key getEncryptedSm2Key() { + return encryptedSm2Key; + } + + public void setEncryptedSm2Key(EncryptedSm2Key encryptedSm2Key) { + this.encryptedSm2Key = encryptedSm2Key; + } +} diff --git a/src/main/java/com/baidubce/services/kms/model/ImportKeyRequest.java b/src/main/java/com/baidubce/services/kms/model/ImportKeyRequest.java new file mode 100644 index 00000000..a919693d --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/ImportKeyRequest.java @@ -0,0 +1,73 @@ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +public class ImportKeyRequest extends GenericKmsRequest { + + private String keyId; + + private String importToken; + + private String encryptedKey; + + private String keySpec; + + private String keyUsage; + + public ImportKeyRequest() { + } + + public ImportKeyRequest(String keyId, String importToken, String encryptedKey, String keySpec, String keyUsage) { + this.keyId = keyId; + this.importToken = importToken; + this.encryptedKey = encryptedKey; + this.keySpec = keySpec; + this.keyUsage = keyUsage; + } + + public String getKeyId() { + return keyId; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getImportToken() { + return importToken; + } + + public void setImportToken(String importToken) { + this.importToken = importToken; + } + + public String getEncryptedKey() { + return encryptedKey; + } + + public void setEncryptedKey(String encryptedKey) { + this.encryptedKey = encryptedKey; + } + + public String getKeySpec() { + return keySpec; + } + + public void setKeySpec(String keySpec) { + this.keySpec = keySpec; + } + + public String getKeyUsage() { + return keyUsage; + } + + public void setKeyUsage(String keyUsage) { + this.keyUsage = keyUsage; + } + + @Override + public ImportKeyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/kms/model/KeyMetadata.java b/src/main/java/com/baidubce/services/kms/model/KeyMetadata.java new file mode 100644 index 00000000..ea6a71aa --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/KeyMetadata.java @@ -0,0 +1,175 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import java.util.Date; +import java.text.SimpleDateFormat; +import java.text.ParseException; + +/** + * Master key information. + */ +public class KeyMetadata { + /** + * It is masterKeyId + */ + private String keyId = null; + + /** + * the time that create master key + */ + private Date creationDate; + + /** + * The state of master key + */ + private String keyState = null; + + /** + * The description of master key + */ + private String description = null; + + /** + * The deletion date of master key + */ + private String deletionDate = null; + + /** + * The Usage of master key + */ + private String keyUsage = null; + + /** + * The region of master key + */ + private String region = null; + + /** + * The origin of master key + */ + private String origin = null; + + /** + *The keySpec of master key + */ + private String keySpec = null; + + private String protectedBy = null; + + private int rotateCycle = 0; + + private String nextRotateTime = null; + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } + + public void setCreationDate(String creationDate) { + try { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); + this.creationDate = formatter.parse(creationDate.replaceAll("Z$", "+0000")); + } catch (ParseException e) { + this.creationDate = new Date(); + e.printStackTrace(); + } + } + + public Date getCreationDate() { + return creationDate; + } + + public void setKeyState(String keyState) { + this.keyState = keyState; + } + + public String getKeyState() { + return keyState; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setKeyUsage(String keyUsage) { + this.keyUsage = keyUsage; + } + public String getKeyUsage() { + return keyUsage; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getRegion() { + return region; + } + + public void setDeletionDate(String deletionDate) { + this.deletionDate = deletionDate; + } + + public String getDeletionDate() { + return deletionDate; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String origin) { + this.origin = origin; + } + + public String getKeySpec() { + return keySpec; + } + + public void setKeySpec(String keySpec) { + this.keySpec = keySpec; + } + + public String getProtectedBy() { + return protectedBy; + } + + public void setProtectedBy(String protectedBy) { + this.protectedBy = protectedBy; + } + + public void setRotateCycle(int rotateCycle) { + this.rotateCycle = rotateCycle; + } + + public int getRotateCycle() { + return this.rotateCycle; + } + + public void setNextRotateTime(String nextRotateTime) { + this.nextRotateTime = nextRotateTime; + } + + public String getNextRotateTime() { + return this.nextRotateTime; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/KmsResponse.java b/src/main/java/com/baidubce/services/kms/model/KmsResponse.java new file mode 100644 index 00000000..f47cbe6b --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/KmsResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Common kms response. + */ +public class KmsResponse extends AbstractBceResponse { +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/ListKeysRequest.java b/src/main/java/com/baidubce/services/kms/model/ListKeysRequest.java new file mode 100644 index 00000000..f384f352 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/ListKeysRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for listing master keys. + */ +public class ListKeysRequest extends GenericKmsRequest { + + private int limit; + + private String marker; + + public ListKeysRequest() { + } + + public ListKeysRequest(int limit, String marker) { + this.setLimit(limit); + this.setMarker(marker); + } + + public ListKeysRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setLimit(int limit) { + this.limit = limit; + } + + public int getLimit() { + return limit; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return marker; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/ListKeysResponse.java b/src/main/java/com/baidubce/services/kms/model/ListKeysResponse.java new file mode 100644 index 00000000..f1a534c9 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/ListKeysResponse.java @@ -0,0 +1,70 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import java.util.List; + +/** + * Contains the details returned from Kms after calling the ListKeys operation. + */ +public class ListKeysResponse extends KmsResponse { + + private String nextMarker; + + private boolean truncated; + + private List keys; + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return nextMarker; + } + + public void setTruncated(boolean truncated) { + this.truncated = truncated; + } + + public boolean getTruncated() { + return truncated; + } + + public void setKeys(List keys) { + this.keys = keys; + } + + public List getKeys() { + return keys; + } + + public static class Key { + /** + * keyId for ListKeys + */ + private String keyId; + + public Key() { + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/ScheduleKeyDeletionRequest.java b/src/main/java/com/baidubce/services/kms/model/ScheduleKeyDeletionRequest.java new file mode 100644 index 00000000..629f1393 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/ScheduleKeyDeletionRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for deleting master key. + */ +public class ScheduleKeyDeletionRequest extends GenericKmsRequest { + + private String keyId; + + private int pendingWindowInDays; + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public ScheduleKeyDeletionRequest() { + } + + public ScheduleKeyDeletionRequest(String keyId, int pendingWindowsInDays) { + this.setPendingWindowInDays(pendingWindowsInDays); + this.setKeyId(keyId); + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public ScheduleKeyDeletionRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getKeyId() { + return keyId; + } + + public void setPendingWindowInDays(int pendingWindowInDays) { + this.pendingWindowInDays = pendingWindowInDays; + } + + public int getPendingWindowsInDays() { + return pendingWindowInDays; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/ScheduleKeyDeletionResponse.java b/src/main/java/com/baidubce/services/kms/model/ScheduleKeyDeletionResponse.java new file mode 100644 index 00000000..b75d23bb --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/ScheduleKeyDeletionResponse.java @@ -0,0 +1,50 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import java.util.Date; +import java.text.SimpleDateFormat; +import java.text.ParseException; + +/** + * Contains the details returned from Kms after calling the ScheduleKeyDeletion operation. + */ +public class ScheduleKeyDeletionResponse extends KmsResponse { + + private Date deletionDate; + + private String keyId; + + public void setDeletionDate(String deletionDate) { + try { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); + this.deletionDate = formatter.parse(deletionDate.replaceAll("Z$", "+0000")); + } catch (ParseException e) { + this.deletionDate = new Date(); + e.printStackTrace(); + } + } + + public Date getDeletionDate() { + return deletionDate; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/UpdateRotationRequest.java b/src/main/java/com/baidubce/services/kms/model/UpdateRotationRequest.java new file mode 100644 index 00000000..26337d05 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/UpdateRotationRequest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +import com.baidubce.auth.BceCredentials; + +/** + * Provides options for enableKey master key. + */ +public class UpdateRotationRequest extends GenericKmsRequest { + + private String keyId; + + private int rotateCycle; + + public UpdateRotationRequest() { + } + + public UpdateRotationRequest(String keyId, int rotateCycle) { + this.setKeyId(keyId); + this.setRotateCycle(rotateCycle); + } + + /** + * Overrides abstract method withRequestCredentials(BceCredentials) in AbstractBceRequest + */ + public UpdateRotationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public void setKeyId(String keyId) { + this.keyId = keyId; + } + + public String getKeyId() { + return keyId; + } + + public void setRotateCycle(int rotateCycle){ + this.rotateCycle = rotateCycle; + } + + public int getRotateCycle() { + return this.rotateCycle; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/kms/model/UpdateRotationResponse.java b/src/main/java/com/baidubce/services/kms/model/UpdateRotationResponse.java new file mode 100644 index 00000000..ca2aa807 --- /dev/null +++ b/src/main/java/com/baidubce/services/kms/model/UpdateRotationResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2018 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.kms.model; + +/** + * Provides options for enableKey master key. + */ +public class UpdateRotationResponse extends KmsResponse { + + private int success; + + public void setSuccess(int success) { + this.success = success; + } + + public int getSuccess() { + return this.success; + } +} +// vim: et tw=100 ts=4 sw=4 cc=120 diff --git a/src/main/java/com/baidubce/services/lbdc/LbdcClient.java b/src/main/java/com/baidubce/services/lbdc/LbdcClient.java new file mode 100644 index 00000000..949de8fd --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/LbdcClient.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc; + +import java.util.Map; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.common.ApiInfo; +import com.baidubce.common.BaseBceClient; +import com.baidubce.common.BaseBceResponse; +import com.baidubce.common.BceRegion; +import com.baidubce.internal.InternalRequest; +import com.baidubce.services.lbdc.api.LbdcApi; +import com.baidubce.services.lbdc.model.CreateLbdcRequest; +import com.baidubce.services.lbdc.model.CreateLbdcResponse; +import com.baidubce.services.lbdc.model.GetBoundBlBListOfLbdcResponse; +import com.baidubce.services.lbdc.model.GetLbdcResponse; +import com.baidubce.services.lbdc.model.ListLbdcResponse; +import com.baidubce.services.lbdc.model.RenewLbdcRequest; +import com.baidubce.services.lbdc.model.UpdateLbdcRequest; +import com.baidubce.services.lbdc.model.UpgradeLbdcRequest; +import com.google.common.collect.ImmutableMap; + +/** + * Lbdc + */ +public class LbdcClient extends BaseBceClient { + private static final Map ENDPOINTS = ImmutableMap.builder() + .put(BceRegion.BJ, "http://blb.bj.baidubce.com") + .build(); + /** + * Service name for extra config and handler. + */ + private static final String SERVICE_ID = "Lbdc"; + + /** + * Constructs a new client to invoke service methods on demo with region. + */ + public LbdcClient(String ak, String sk, BceRegion region) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(region)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public LbdcClient(String ak, String sk) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(BceRegion.DEFAULT)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public LbdcClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Api lists + */ + private static final Map LBDC_APIS = LbdcApi.getApis(); + + public CreateLbdcResponse createLbdc(CreateLbdcRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LBDC_APIS.get("createLbdc")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreateLbdcResponse.class); + } + + public GetBoundBlBListOfLbdcResponse getBoundBlBListOfLbdc(String id) { + ApiInfo apiInfo = new ApiInfo(LBDC_APIS.get("getBoundBlBListOfLbdc")); + String apiPath = apiInfo.getPath() + .withPathParameter("id", id).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetBoundBlBListOfLbdcResponse.class); + } + + public GetLbdcResponse getLbdc(String id) { + ApiInfo apiInfo = new ApiInfo(LBDC_APIS.get("getLbdc")); + String apiPath = apiInfo.getPath() + .withPathParameter("id", id).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetLbdcResponse.class); + } + + public ListLbdcResponse listLbdc(String id, String name) { + ApiInfo apiInfo = new ApiInfo(LBDC_APIS.get("listLbdc")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("id", id); + apiInfo.getQueries().put("name", name); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListLbdcResponse.class); + } + + public void renewLbdc(String id, RenewLbdcRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LBDC_APIS.get("renewLbdc")); + String apiPath = apiInfo.getPath() + .withPathParameter("id", id).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void updateLbdc(String id, UpdateLbdcRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LBDC_APIS.get("updateLbdc")); + String apiPath = apiInfo.getPath() + .withPathParameter("id", id).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void upgradeLbdc(String id, UpgradeLbdcRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LBDC_APIS.get("upgradeLbdc")); + String apiPath = apiInfo.getPath() + .withPathParameter("id", id).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/lbdc/api/LbdcApi.java b/src/main/java/com/baidubce/services/lbdc/api/LbdcApi.java new file mode 100644 index 00000000..e47f5142 --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/api/LbdcApi.java @@ -0,0 +1,96 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc.api; + +import java.util.HashMap; +import java.util.Map; + +import com.baidubce.common.ApiInfo; +import com.baidubce.common.ApiPath; +import com.baidubce.http.HttpMethodName; + +public class LbdcApi { + /** + * Api list with api name + */ + private static Map apis = new HashMap(); + + public static Map getApis() { + // + apis.put("createLbdc", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/lbdc"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("getBoundBlBListOfLbdc", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/lbdc/[id]/blb"), + new HashMap(), + new HashMap())); + // + apis.put("getLbdc", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/lbdc/[id]"), + new HashMap(), + new HashMap())); + // + apis.put("listLbdc", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/lbdc"), + new HashMap() { + { + put("id", null); + put("name", null); + } + }, + new HashMap())); + // + apis.put("renewLbdc", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/lbdc/[id]"), + new HashMap() { + { + put("purchaseReserved", ""); + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("updateLbdc", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/lbdc/[id]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("upgradeLbdc", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/lbdc/[id]"), + new HashMap() { + { + put("resize", ""); + put("clientToken", null); + } + }, + new HashMap())); + return apis; + } +} diff --git a/src/main/java/com/baidubce/services/lbdc/model/CreateLbdcRequest.java b/src/main/java/com/baidubce/services/lbdc/model/CreateLbdcRequest.java new file mode 100644 index 00000000..a41f368d --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/model/CreateLbdcRequest.java @@ -0,0 +1,159 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateLbdcRequest extends BaseBceRequest { + /** + * 集群名称,长度1~65个字节,字母开头,_可包含字母数字-/.字符 + */ + private String name; + + /** + * 集群类型,取值为4Layer或者7Layer + */ + private String type; + + /** + * 集群性能容量单位CCU(Cluster Capacity Unit)是用来衡量BLB集群处理流量时涉及的各个指标。 + */ + private Integer ccuCount; + + /** + * LBDC的描述,最大支持200字符 + */ + private String desc; + + /** + * billing + */ + private BillingForCreate billing; + + /** + * renewReservation + */ + private Reservation renewReservation; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setCcuCount(Integer ccuCount) { + this.ccuCount = ccuCount; + } + + public Integer getCcuCount() { + return this.ccuCount; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getDesc() { + return this.desc; + } + + public void setBilling(BillingForCreate billing) { + this.billing = billing; + } + + public BillingForCreate getBilling() { + return this.billing; + } + + public void setRenewReservation(Reservation renewReservation) { + this.renewReservation = renewReservation; + } + + public Reservation getRenewReservation() { + return this.renewReservation; + } + + @Override + public String toString() { + return "CreateLbdcRequest{" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "ccuCount=" + ccuCount + "\n" + + "desc=" + desc + "\n" + + "billing=" + billing + "\n" + + "renewReservation=" + renewReservation + "\n" + + "}"; + } + + public static class BillingForCreate { + private String paymentTiming; + + private Reservation reservation; + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getPaymentTiming() { + return this.paymentTiming; + } + + public void setReservation(Reservation reservation) { + this.reservation = reservation; + } + + public Reservation getReservation() { + return this.reservation; + } + + @Override + public String toString() { + return "BillingForCreate{" + + "paymentTiming=" + paymentTiming + "\n" + + "reservation=" + reservation + "\n" + + "}"; + } + } + + public static class Reservation { + private Integer reservationLength; + + public void setReservationLength(Integer reservationLength) { + this.reservationLength = reservationLength; + } + + public Integer getReservationLength() { + return this.reservationLength; + } + + @Override + public String toString() { + return "Reservation{" + + "reservationLength=" + reservationLength + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lbdc/model/CreateLbdcResponse.java b/src/main/java/com/baidubce/services/lbdc/model/CreateLbdcResponse.java new file mode 100644 index 00000000..9a01909d --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/model/CreateLbdcResponse.java @@ -0,0 +1,68 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateLbdcResponse extends BaseBceResponse { + /** + * 集群id + */ + private String id; + + /** + * 集群类型 + */ + private String type; + + /** + * 描述信息 + */ + private String desc; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getDesc() { + return this.desc; + } + + @Override + public String toString() { + return "CreateLbdcResponse{" + + "id=" + id + "\n" + + "type=" + type + "\n" + + "desc=" + desc + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lbdc/model/GetBoundBlBListOfLbdcResponse.java b/src/main/java/com/baidubce/services/lbdc/model/GetBoundBlBListOfLbdcResponse.java new file mode 100644 index 00000000..ff87ab13 --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/model/GetBoundBlBListOfLbdcResponse.java @@ -0,0 +1,149 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetBoundBlBListOfLbdcResponse extends BaseBceResponse { + /** + * 集群id + */ + private List blbList; + + public void setBlbList(List blbList) { + this.blbList = blbList; + } + + public List getBlbList() { + return this.blbList; + } + + @Override + public String toString() { + return "GetBoundBlBListOfLbdcResponse{" + + "blbList=" + blbList + "\n" + + "}"; + } + + public static class AssociateBlbModel { + private String blbId; + + private String name; + + private String type; + + private String blbType; + + private Integer bandwidth; + + private String address; + + private String ipv6; + + private String vpcId; + + private String subnetId; + + public void setBlbId(String blbId) { + this.blbId = blbId; + } + + public String getBlbId() { + return this.blbId; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setBlbType(String blbType) { + this.blbType = blbType; + } + + public String getBlbType() { + return this.blbType; + } + + public void setBandwidth(Integer bandwidth) { + this.bandwidth = bandwidth; + } + + public Integer getBandwidth() { + return this.bandwidth; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getAddress() { + return this.address; + } + + public void setIpv6(String ipv6) { + this.ipv6 = ipv6; + } + + public String getIpv6() { + return this.ipv6; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getVpcId() { + return this.vpcId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getSubnetId() { + return this.subnetId; + } + + @Override + public String toString() { + return "AssociateBlbModel{" + + "blbId=" + blbId + "\n" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "blbType=" + blbType + "\n" + + "bandwidth=" + bandwidth + "\n" + + "address=" + address + "\n" + + "ipv6=" + ipv6 + "\n" + + "vpcId=" + vpcId + "\n" + + "subnetId=" + subnetId + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lbdc/model/GetLbdcResponse.java b/src/main/java/com/baidubce/services/lbdc/model/GetLbdcResponse.java new file mode 100644 index 00000000..d3d6c2d4 --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/model/GetLbdcResponse.java @@ -0,0 +1,250 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetLbdcResponse extends BaseBceResponse { + /** + * 集群id + */ + private String id; + + /** + * 集群名称 + */ + private String name; + + /** + * 集群类型 + */ + private String type; + + /** + * 集群状态 + */ + private String status; + + /** + * 集群性能容量 + */ + private String ccuCount; + + /** + * 集群创建时间 + */ + private String createTime; + + /** + * 集群失效时间 + */ + private String expireTime; + + /** + * 并发连接数 + */ + private String totalConnectCount; + + /** + * 新建连接速度 + */ + private String newConnectCps; + + /** + * 网络输入带宽 + */ + private String networkInBps; + + /** + * 网络输出带宽 + */ + private String networkOutBps; + + /** + * https的qps + */ + private String httpsQps; + + /** + * http的qps + */ + private String httpQps; + + /** + * http新建速度 + */ + private String httpNewConnectCps; + + /** + * https新建速度 + */ + private String httpsNewConnectCps; + + /** + * ssl新建速度 + */ + private String sslNewConnectCps; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + public void setCcuCount(String ccuCount) { + this.ccuCount = ccuCount; + } + + public String getCcuCount() { + return this.ccuCount; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateTime() { + return this.createTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + public String getExpireTime() { + return this.expireTime; + } + + public void setTotalConnectCount(String totalConnectCount) { + this.totalConnectCount = totalConnectCount; + } + + public String getTotalConnectCount() { + return this.totalConnectCount; + } + + public void setNewConnectCps(String newConnectCps) { + this.newConnectCps = newConnectCps; + } + + public String getNewConnectCps() { + return this.newConnectCps; + } + + public void setNetworkInBps(String networkInBps) { + this.networkInBps = networkInBps; + } + + public String getNetworkInBps() { + return this.networkInBps; + } + + public void setNetworkOutBps(String networkOutBps) { + this.networkOutBps = networkOutBps; + } + + public String getNetworkOutBps() { + return this.networkOutBps; + } + + public void setHttpsQps(String httpsQps) { + this.httpsQps = httpsQps; + } + + public String getHttpsQps() { + return this.httpsQps; + } + + public void setHttpQps(String httpQps) { + this.httpQps = httpQps; + } + + public String getHttpQps() { + return this.httpQps; + } + + public void setHttpNewConnectCps(String httpNewConnectCps) { + this.httpNewConnectCps = httpNewConnectCps; + } + + public String getHttpNewConnectCps() { + return this.httpNewConnectCps; + } + + public void setHttpsNewConnectCps(String httpsNewConnectCps) { + this.httpsNewConnectCps = httpsNewConnectCps; + } + + public String getHttpsNewConnectCps() { + return this.httpsNewConnectCps; + } + + public void setSslNewConnectCps(String sslNewConnectCps) { + this.sslNewConnectCps = sslNewConnectCps; + } + + public String getSslNewConnectCps() { + return this.sslNewConnectCps; + } + + @Override + public String toString() { + return "GetLbdcResponse{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "status=" + status + "\n" + + "ccuCount=" + ccuCount + "\n" + + "createTime=" + createTime + "\n" + + "expireTime=" + expireTime + "\n" + + "totalConnectCount=" + totalConnectCount + "\n" + + "newConnectCps=" + newConnectCps + "\n" + + "networkInBps=" + networkInBps + "\n" + + "networkOutBps=" + networkOutBps + "\n" + + "httpsQps=" + httpsQps + "\n" + + "httpQps=" + httpQps + "\n" + + "httpNewConnectCps=" + httpNewConnectCps + "\n" + + "httpsNewConnectCps=" + httpsNewConnectCps + "\n" + + "sslNewConnectCps=" + sslNewConnectCps + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lbdc/model/ListLbdcResponse.java b/src/main/java/com/baidubce/services/lbdc/model/ListLbdcResponse.java new file mode 100644 index 00000000..b22da19d --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/model/ListLbdcResponse.java @@ -0,0 +1,194 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListLbdcResponse extends BaseBceResponse { + /** + * 标记查询的起始位置 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private Integer maxKeys; + + /** + * 包含查询结果的LBDC列表 + */ + private List clusterList; + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + public void setClusterList(List clusterList) { + this.clusterList = clusterList; + } + + public List getClusterList() { + return this.clusterList; + } + + @Override + public String toString() { + return "ListLbdcResponse{" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "clusterList=" + clusterList + "\n" + + "}"; + } + + public static class ClusterModel { + private String id; + + private String name; + + private String type; + + private String status; + + private Integer ccuCount; + + private String createTime; + + private String expireTime; + + private String desc; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + public void setCcuCount(Integer ccuCount) { + this.ccuCount = ccuCount; + } + + public Integer getCcuCount() { + return this.ccuCount; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateTime() { + return this.createTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + public String getExpireTime() { + return this.expireTime; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getDesc() { + return this.desc; + } + + @Override + public String toString() { + return "ClusterModel{" + + "id=" + id + "\n" + + "name=" + name + "\n" + + "type=" + type + "\n" + + "status=" + status + "\n" + + "ccuCount=" + ccuCount + "\n" + + "createTime=" + createTime + "\n" + + "expireTime=" + expireTime + "\n" + + "desc=" + desc + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lbdc/model/RenewLbdcRequest.java b/src/main/java/com/baidubce/services/lbdc/model/RenewLbdcRequest.java new file mode 100644 index 00000000..a4132411 --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/model/RenewLbdcRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class RenewLbdcRequest extends BaseBceRequest { + /** + * billing + */ + private BillingForRenew billing; + + public BillingForRenew getBilling() { + return billing; + } + + public void setBilling(BillingForRenew billing) { + this.billing = billing; + } + + @Override + public String toString() { + return "RenewLbdcRequest{" + + "billing=" + billing + + '}'; + } + + public static class BillingForRenew { + private Reservation reservation; + + public void setReservation(Reservation reservation) { + this.reservation = reservation; + } + + public Reservation getReservation() { + return this.reservation; + } + + @Override + public String toString() { + return "BillingForRenew{" + + "reservation=" + reservation + "\n" + + "}"; + } + + public static class Reservation { + private Integer reservationLength; + + public void setReservationLength(Integer reservationLength) { + this.reservationLength = reservationLength; + } + + public Integer getReservationLength() { + return this.reservationLength; + } + + @Override + public String toString() { + return "Reservation{" + + "reservationLength=" + reservationLength + "\n" + + "}"; + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lbdc/model/UpdateLbdcRequest.java b/src/main/java/com/baidubce/services/lbdc/model/UpdateLbdcRequest.java new file mode 100644 index 00000000..273306dc --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/model/UpdateLbdcRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateLbdcRequest extends BaseBceRequest { + /** + * 集群名称。长度1~65个字节,字母开头,_可包含字母数字-/.字符。 + */ + private String name; + + /** + * 集群描述,最大支持200字符 + */ + private String desc; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getDesc() { + return this.desc; + } + + @Override + public String toString() { + return "UpdateLbdcRequest{" + + "name=" + name + "\n" + + "desc=" + desc + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lbdc/model/UpgradeLbdcRequest.java b/src/main/java/com/baidubce/services/lbdc/model/UpgradeLbdcRequest.java new file mode 100644 index 00000000..44a15d97 --- /dev/null +++ b/src/main/java/com/baidubce/services/lbdc/model/UpgradeLbdcRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lbdc.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpgradeLbdcRequest extends BaseBceRequest { + /** + * 集群性能容量单位CCU(Cluster Capacity Unit)是用来衡量BLB集群处理流量时涉及的各个指标。 + */ + private Integer ccuCount; + + public Integer getCcuCount() { + return ccuCount; + } + + public void setCcuCount(Integer ccuCount) { + this.ccuCount = ccuCount; + } + + @Override + public String toString() { + return "UpgradeLbdcRequest{" + + "ccuCount=" + ccuCount + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/LdClient.java b/src/main/java/com/baidubce/services/localdns/LdClient.java new file mode 100644 index 00000000..03a9c6d0 --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/LdClient.java @@ -0,0 +1,188 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.common.ApiInfo; +import com.baidubce.common.BaseBceClient; +import com.baidubce.common.BaseBceResponse; +import com.baidubce.common.BceRegion; +import com.baidubce.internal.InternalRequest; +import com.baidubce.services.localdns.api.LdApi; +import com.baidubce.services.localdns.model.AddRecordRequest; +import com.baidubce.services.localdns.model.AddRecordResponse; +import com.baidubce.services.localdns.model.BindVpcRequest; +import com.baidubce.services.localdns.model.CreatePrivateZoneRequest; +import com.baidubce.services.localdns.model.CreatePrivateZoneResponse; +import com.baidubce.services.localdns.model.GetPrivateZoneResponse; +import com.baidubce.services.localdns.model.ListPrivateZoneResponse; +import com.baidubce.services.localdns.model.ListRecordResponse; +import com.baidubce.services.localdns.model.UnbindVpcRequest; +import com.baidubce.services.localdns.model.UpdateRecordRequest; +import com.google.common.collect.ImmutableMap; + +import java.util.Map; + +/** + * Ld + */ +public class LdClient extends BaseBceClient { + + private static final Map ENDPOINTS = ImmutableMap.builder() + .put(BceRegion.BJ, "http://privatezone.baidubce.com") + .build(); + /** + * Service name for extra config and handler. + */ + private static final String SERVICE_ID = "Ld"; + + /** + * Constructs a new client to invoke service methods on demo with region. + */ + public LdClient(String ak, String sk, BceRegion region) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(region)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public LdClient(String ak, String sk) { + super(SERVICE_ID, ak, sk, ENDPOINTS.get(BceRegion.DEFAULT)); + } + + /** + * Constructs a new client to invoke service methods on demo. + */ + public LdClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Api lists + */ + private static final Map LD_APIS = LdApi.getApis(); + + public AddRecordResponse addRecord(String zoneId, AddRecordRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("addRecord")); + String apiPath = apiInfo.getPath().withPathParameter("zoneId", zoneId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, AddRecordResponse.class); + } + + public void bindVpc(String zoneId, BindVpcRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("bindVpc")); + String apiPath = apiInfo.getPath().withPathParameter("zoneId", zoneId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public CreatePrivateZoneResponse createPrivateZone(CreatePrivateZoneRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("createPrivateZone")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + return invokeHttpClient(internalRequest, CreatePrivateZoneResponse.class); + } + + public void deletePrivateZone(String zoneId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("deletePrivateZone")); + String apiPath = apiInfo.getPath().withPathParameter("zoneId", zoneId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void deleteRecord(String recordId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("deleteRecord")); + String apiPath = apiInfo.getPath() + .withPathParameter("recordId", recordId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void disableRecord(String recordId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("disableRecord")); + String apiPath = apiInfo.getPath() + .withPathParameter("recordId", recordId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void enableRecord(String recordId, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("enableRecord")); + String apiPath = apiInfo.getPath() + .withPathParameter("recordId", recordId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public GetPrivateZoneResponse getPrivateZone(String zoneId) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("getPrivateZone")); + String apiPath = apiInfo.getPath() + .withPathParameter("zoneId", zoneId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, GetPrivateZoneResponse.class); + } + + public ListPrivateZoneResponse listPrivateZone(String marker, Integer maxKeys) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("listPrivateZone")); + String apiPath = apiInfo.getPath().get(); + apiInfo.getQueries().put("marker", marker); + apiInfo.getQueries().put("maxKeys", String.valueOf(maxKeys)); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListPrivateZoneResponse.class); + } + + public ListRecordResponse listRecord(String zoneId) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("listRecord")); + String apiPath = apiInfo.getPath() + .withPathParameter("zoneId", zoneId).get(); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), null); + return invokeHttpClient(internalRequest, ListRecordResponse.class); + } + + public void unbindVpc(String zoneId, UnbindVpcRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("unbindVpc")); + String apiPath = apiInfo.getPath().withPathParameter("zoneId", zoneId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + + public void updateRecord(String recordId, UpdateRecordRequest body, String clientToken) { + ApiInfo apiInfo = new ApiInfo(LD_APIS.get("updateRecord")); + String apiPath = apiInfo.getPath() + .withPathParameter("recordId", recordId).get(); + apiInfo.getQueries().put("clientToken", clientToken); + InternalRequest internalRequest = createRequest(apiInfo.getMethod(), apiPath, apiInfo.getQueries(), + apiInfo.getHeaders(), body); + invokeHttpClient(internalRequest, BaseBceResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/localdns/api/LdApi.java b/src/main/java/com/baidubce/services/localdns/api/LdApi.java new file mode 100644 index 00000000..86f996f6 --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/api/LdApi.java @@ -0,0 +1,148 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.api; + +import java.util.HashMap; +import java.util.Map; + +import com.baidubce.common.ApiInfo; +import com.baidubce.common.ApiPath; +import com.baidubce.http.HttpMethodName; + +public class LdApi { + /** + * Api list with api name + */ + private static Map apis = new HashMap(); + + public static Map getApis() { + // + apis.put("addRecord", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/privatezone/[zoneId]/record"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("bindVpc", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/privatezone/[zoneId]"), + new HashMap() { + { + put("bind", ""); + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("createPrivateZone", new ApiInfo( + HttpMethodName.valueOf("POST"), + new ApiPath("/v1/privatezone"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("deletePrivateZone", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/privatezone/[zoneId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("deleteRecord", new ApiInfo( + HttpMethodName.valueOf("DELETE"), + new ApiPath("/v1/privatezone/record/[recordId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("disableRecord", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/privatezone/record/[recordId]"), + new HashMap() { + { + put("disable", ""); + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("enableRecord", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/privatezone/record/[recordId]"), + new HashMap() { + { + put("enable", null); + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("getPrivateZone", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/privatezone/[zoneId]"), + new HashMap(), + new HashMap())); + // + apis.put("listPrivateZone", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/privatezone"), + new HashMap() { + { + put("marker", null); + put("maxKeys", null); + } + }, + new HashMap())); + // + apis.put("listRecord", new ApiInfo( + HttpMethodName.valueOf("GET"), + new ApiPath("/v1/privatezone/[zoneId]/record"), + new HashMap(), + new HashMap())); + // + apis.put("unbindVpc", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/privatezone/[zoneId]"), + new HashMap() { + { + put("unbind", ""); + put("clientToken", null); + } + }, + new HashMap())); + // + apis.put("updateRecord", new ApiInfo( + HttpMethodName.valueOf("PUT"), + new ApiPath("/v1/privatezone/record/[recordId]"), + new HashMap() { + { + put("clientToken", null); + } + }, + new HashMap())); + return apis; + } +} diff --git a/src/main/java/com/baidubce/services/localdns/model/AddRecordRequest.java b/src/main/java/com/baidubce/services/localdns/model/AddRecordRequest.java new file mode 100644 index 00000000..0a622aa1 --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/AddRecordRequest.java @@ -0,0 +1,124 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class AddRecordRequest extends BaseBceRequest { + /** + * 解析记录的ID + */ + private String recordId; + + /** + * 主机记录 + */ + private String rr; + + /** + * 记录值 + */ + private String value; + + /** + * 解析记录类型,目前支持A, AAAA,CNAME, TXT, MX, PTR, SRV + */ + private String type; + + /** + * 生存时间,值为[5,24*3600],默认为60 + */ + private Integer ttl; + + /** + * MX记录的优先级,取值范围:[0,100]。记录类型为MX记录时,此参数必选。 + */ + private Integer priority; + + /** + * 描述 + */ + private String description; + + public void setRecordId(String recordId) { + this.recordId = recordId; + } + + public String getRecordId() { + return this.recordId; + } + + public void setRr(String rr) { + this.rr = rr; + } + + public String getRr() { + return this.rr; + } + + public void setValue(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public Integer getTtl() { + return this.ttl; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "AddRecordRequest{" + + "recordId=" + recordId + "\n" + + "rr=" + rr + "\n" + + "value=" + value + "\n" + + "type=" + type + "\n" + + "ttl=" + ttl + "\n" + + "priority=" + priority + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/AddRecordResponse.java b/src/main/java/com/baidubce/services/localdns/model/AddRecordResponse.java new file mode 100644 index 00000000..21bb689c --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/AddRecordResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class AddRecordResponse extends BaseBceResponse { + /** + * 记录的ID + */ + private String recordId; + + public void setRecordId(String recordId) { + this.recordId = recordId; + } + + public String getRecordId() { + return this.recordId; + } + + @Override + public String toString() { + return "AddRecordResponse{" + + "recordId=" + recordId + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/BindVpcRequest.java b/src/main/java/com/baidubce/services/localdns/model/BindVpcRequest.java new file mode 100644 index 00000000..5a21d706 --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/BindVpcRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class BindVpcRequest extends BaseBceRequest { + /** + * region + */ + private String region; + + /** + * vpcIds + */ + private List vpcIds; + + public void setRegion(String region) { + this.region = region; + } + + public String getRegion() { + return this.region; + } + + public void setVpcIds(List vpcIds) { + this.vpcIds = vpcIds; + } + + public List getVpcIds() { + return this.vpcIds; + } + + @Override + public String toString() { + return "BindVpcRequest{" + + "region=" + region + "\n" + + "vpcIds=" + vpcIds + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/CreatePrivateZoneRequest.java b/src/main/java/com/baidubce/services/localdns/model/CreatePrivateZoneRequest.java new file mode 100644 index 00000000..eefaa22d --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/CreatePrivateZoneRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreatePrivateZoneRequest extends BaseBceRequest { + /** + * Zone名称,由两个及其以上的字母或者数字组成,最大长度不能超过240 + */ + private String zoneName; + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getZoneName() { + return this.zoneName; + } + + @Override + public String toString() { + return "CreatePrivateZoneRequest{" + + "zoneName=" + zoneName + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/CreatePrivateZoneResponse.java b/src/main/java/com/baidubce/services/localdns/model/CreatePrivateZoneResponse.java new file mode 100644 index 00000000..1fae6f55 --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/CreatePrivateZoneResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreatePrivateZoneResponse extends BaseBceResponse { + /** + * Zone的ID + */ + private String zoneId; + + public void setZoneId(String zoneId) { + this.zoneId = zoneId; + } + + public String getZoneId() { + return this.zoneId; + } + + @Override + public String toString() { + return "CreatePrivateZoneResponse{" + + "zoneId=" + zoneId + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/DeletePrivateZoneRequest.java b/src/main/java/com/baidubce/services/localdns/model/DeletePrivateZoneRequest.java new file mode 100644 index 00000000..d2f57334 --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/DeletePrivateZoneRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeletePrivateZoneRequest extends BaseBceRequest { + /** + * Zone名称,由两个及其以上的字母或者数字组成,最大长度不能超过240 + */ + private String zoneName; + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getZoneName() { + return this.zoneName; + } + + @Override + public String toString() { + return "DeletePrivateZoneRequest{" + + "zoneName=" + zoneName + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/DeleteRecordRequest.java b/src/main/java/com/baidubce/services/localdns/model/DeleteRecordRequest.java new file mode 100644 index 00000000..17069776 --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/DeleteRecordRequest.java @@ -0,0 +1,124 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeleteRecordRequest extends BaseBceRequest { + /** + * 解析记录的ID + */ + private String recordId; + + /** + * 主机记录 + */ + private String rr; + + /** + * 记录值 + */ + private String value; + + /** + * 解析记录类型,目前支持A, AAAA,CNAME, TXT, MX, PTR, SRV + */ + private String type; + + /** + * 生存时间,值为[5,24*3600],默认为60 + */ + private Integer ttl; + + /** + * MX记录的优先级,取值范围:[0,100]。记录类型为MX记录时,此参数必选。 + */ + private Integer priority; + + /** + * 描述 + */ + private String description; + + public void setRecordId(String recordId) { + this.recordId = recordId; + } + + public String getRecordId() { + return this.recordId; + } + + public void setRr(String rr) { + this.rr = rr; + } + + public String getRr() { + return this.rr; + } + + public void setValue(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public Integer getTtl() { + return this.ttl; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "DeleteRecordRequest{" + + "recordId=" + recordId + "\n" + + "rr=" + rr + "\n" + + "value=" + value + "\n" + + "type=" + type + "\n" + + "ttl=" + ttl + "\n" + + "priority=" + priority + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/GetPrivateZoneResponse.java b/src/main/java/com/baidubce/services/localdns/model/GetPrivateZoneResponse.java new file mode 100644 index 00000000..7b6cd151 --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/GetPrivateZoneResponse.java @@ -0,0 +1,153 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetPrivateZoneResponse extends BaseBceResponse { + /** + * Zone的ID + */ + private String zoneId; + + /** + * Zone的名称 + */ + private String zoneName; + + /** + * 含有的解析记录总数 + */ + private Integer recordCount; + + /** + * 创建时间 + */ + private String createTime; + + /** + * 更新时间 + */ + private String updateTime; + + /** + * 关联的Vpc列表 + */ + private List bindVpcs; + + public void setZoneId(String zoneId) { + this.zoneId = zoneId; + } + + public String getZoneId() { + return this.zoneId; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getZoneName() { + return this.zoneName; + } + + public void setRecordCount(Integer recordCount) { + this.recordCount = recordCount; + } + + public Integer getRecordCount() { + return this.recordCount; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateTime() { + return this.createTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateTime() { + return this.updateTime; + } + + public void setBindVpcs(List bindVpcs) { + this.bindVpcs = bindVpcs; + } + + public List getBindVpcs() { + return this.bindVpcs; + } + + @Override + public String toString() { + return "GetPrivateZoneResponse{" + + "zoneId=" + zoneId + "\n" + + "zoneName=" + zoneName + "\n" + + "recordCount=" + recordCount + "\n" + + "createTime=" + createTime + "\n" + + "updateTime=" + updateTime + "\n" + + "bindVpcs=" + bindVpcs + "\n" + + "}"; + } + + public static class Vpc { + private String vpcId; + + private String vpcName; + + private String vpcRegion; + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getVpcId() { + return this.vpcId; + } + + public void setVpcName(String vpcName) { + this.vpcName = vpcName; + } + + public String getVpcName() { + return this.vpcName; + } + + public void setVpcRegion(String vpcRegion) { + this.vpcRegion = vpcRegion; + } + + public String getVpcRegion() { + return this.vpcRegion; + } + + @Override + public String toString() { + return "Vpc{" + + "vpcId=" + vpcId + "\n" + + "vpcName=" + vpcName + "\n" + + "vpcRegion=" + vpcRegion + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/ListPrivateZoneResponse.java b/src/main/java/com/baidubce/services/localdns/model/ListPrivateZoneResponse.java new file mode 100644 index 00000000..dd8363bb --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/ListPrivateZoneResponse.java @@ -0,0 +1,161 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListPrivateZoneResponse extends BaseBceResponse { + /** + * 标记查询的起始位置 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private Integer maxKeys; + + /** + * Zone列表 + */ + private List zones; + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + public void setZones(List zones) { + this.zones = zones; + } + + public List getZones() { + return this.zones; + } + + @Override + public String toString() { + return "ListPrivateZoneResponse{" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "zones=" + zones + "\n" + + "}"; + } + + public static class Zone { + private String zoneId; + + private String zoneName; + + private Integer recordCount; + + private String createTime; + + private String updateTime; + + public void setZoneId(String zoneId) { + this.zoneId = zoneId; + } + + public String getZoneId() { + return this.zoneId; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getZoneName() { + return this.zoneName; + } + + public void setRecordCount(Integer recordCount) { + this.recordCount = recordCount; + } + + public Integer getRecordCount() { + return this.recordCount; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCreateTime() { + return this.createTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getUpdateTime() { + return this.updateTime; + } + + @Override + public String toString() { + return "Zone{" + + "zoneId=" + zoneId + "\n" + + "zoneName=" + zoneName + "\n" + + "recordCount=" + recordCount + "\n" + + "createTime=" + createTime + "\n" + + "updateTime=" + updateTime + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/ListRecordResponse.java b/src/main/java/com/baidubce/services/localdns/model/ListRecordResponse.java new file mode 100644 index 00000000..6b2d787f --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/ListRecordResponse.java @@ -0,0 +1,194 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListRecordResponse extends BaseBceResponse { + /** + * 标记查询的起始位置 + */ + private String marker; + + /** + * true表示后面还有数据,false表示已经是最后一页 + */ + private Boolean isTruncated; + + /** + * 获取下一页所需要传递的marker值。当isTruncated为false时,该域不出现 + */ + private String nextMarker; + + /** + * 每页包含的最大数量 + */ + private Integer maxKeys; + + /** + * 解析记录列表 + */ + private List records; + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getMarker() { + return this.marker; + } + + public void setIsTruncated(Boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public Boolean isIsTruncated() { + return this.isTruncated; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public void setMaxKeys(Integer maxKeys) { + this.maxKeys = maxKeys; + } + + public Integer getMaxKeys() { + return this.maxKeys; + } + + public void setRecords(List records) { + this.records = records; + } + + public List getRecords() { + return this.records; + } + + @Override + public String toString() { + return "ListRecordResponse{" + + "marker=" + marker + "\n" + + "isTruncated=" + isTruncated + "\n" + + "nextMarker=" + nextMarker + "\n" + + "maxKeys=" + maxKeys + "\n" + + "records=" + records + "\n" + + "}"; + } + + public static class Record { + private String recordId; + + private String rr; + + private String value; + + private String status; + + private String type; + + private Integer ttl; + + private Integer priority; + + private String description; + + public void setRecordId(String recordId) { + this.recordId = recordId; + } + + public String getRecordId() { + return this.recordId; + } + + public void setRr(String rr) { + this.rr = rr; + } + + public String getRr() { + return this.rr; + } + + public void setValue(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getStatus() { + return this.status; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public Integer getTtl() { + return this.ttl; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "Record{" + + "recordId=" + recordId + "\n" + + "rr=" + rr + "\n" + + "value=" + value + "\n" + + "status=" + status + "\n" + + "type=" + type + "\n" + + "ttl=" + ttl + "\n" + + "priority=" + priority + "\n" + + "description=" + description + "\n" + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/UnbindVpcRequest.java b/src/main/java/com/baidubce/services/localdns/model/UnbindVpcRequest.java new file mode 100644 index 00000000..3e72b54a --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/UnbindVpcRequest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import java.util.List; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UnbindVpcRequest extends BaseBceRequest { + /** + * 关联或者解关联的vpc所属的区域 + */ + private String region; + + /** + * 想要关联或者解关联的vpc的ID列表 + */ + private List vpcIds; + + public void setRegion(String region) { + this.region = region; + } + + public String getRegion() { + return this.region; + } + + public void setVpcIds(List vpcIds) { + this.vpcIds = vpcIds; + } + + public List getVpcIds() { + return this.vpcIds; + } + + @Override + public String toString() { + return "UnbindVpcRequest{" + + "region=" + region + "\n" + + "vpcIds=" + vpcIds + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/localdns/model/UpdateRecordRequest.java b/src/main/java/com/baidubce/services/localdns/model/UpdateRecordRequest.java new file mode 100644 index 00000000..c81239dc --- /dev/null +++ b/src/main/java/com/baidubce/services/localdns/model/UpdateRecordRequest.java @@ -0,0 +1,124 @@ +/* + * Copyright 2023 Baidu, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.localdns.model; + +import com.baidubce.common.BaseBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdateRecordRequest extends BaseBceRequest { + /** + * 解析记录的ID + */ + private String recordId; + + /** + * 主机记录 + */ + private String rr; + + /** + * 记录值 + */ + private String value; + + /** + * 解析记录类型,目前支持A, AAAA,CNAME, TXT, MX, PTR, SRV + */ + private String type; + + /** + * 生存时间,值为[5,24*3600],默认为60 + */ + private Integer ttl; + + /** + * MX记录的优先级,取值范围:[0,100]。记录类型为MX记录时,此参数必选。 + */ + private Integer priority; + + /** + * 描述 + */ + private String description; + + public void setRecordId(String recordId) { + this.recordId = recordId; + } + + public String getRecordId() { + return this.recordId; + } + + public void setRr(String rr) { + this.rr = rr; + } + + public String getRr() { + return this.rr; + } + + public void setValue(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public void setTtl(Integer ttl) { + this.ttl = ttl; + } + + public Integer getTtl() { + return this.ttl; + } + + public void setPriority(Integer priority) { + this.priority = priority; + } + + public Integer getPriority() { + return this.priority; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public String toString() { + return "UpdateRecordRequest{" + + "recordId=" + recordId + "\n" + + "rr=" + rr + "\n" + + "value=" + value + "\n" + + "type=" + type + "\n" + + "ttl=" + ttl + "\n" + + "priority=" + priority + "\n" + + "description=" + description + "\n" + + "}"; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lps/BaseLpsClient.java b/src/main/java/com/baidubce/services/lps/BaseLpsClient.java new file mode 100644 index 00000000..c61e9231 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/BaseLpsClient.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.DateUtils; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +/** + * Base lps client which is responsible for base request creation operation and other common operations. + * + * @author weizhijun + * @date 2019/03/11 + */ +public class BaseLpsClient extends AbstractBceClient { + + private static final int DEFAULT_SOCKET_TIMEOUT = 20 * 1000; + + private static final String ENDPOINT = "http://lps.baidubce.com"; + private static final String CONTENT_TYPE = "application/json;charset=utf-8"; + + private static final String[] HEADERS_TO_SIGN = {Headers.HOST, Headers.BCE_DATE}; + + private static HttpResponseHandler[] lmsHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Construct a default base LPS client. + */ + protected BaseLpsClient() { + this(new BceClientConfiguration()); + } + + /** + * Construct a base lps client with access key id and secret key. + * + * @param accessKey Access key id. + * @param secretKey Secret key. + */ + protected BaseLpsClient(String accessKey, String secretKey) { + this(new BceClientConfiguration() + .withSocketTimeoutInMillis(DEFAULT_SOCKET_TIMEOUT) + .withCredentials(new DefaultBceCredentials(accessKey, secretKey)) + .withEndpoint(ENDPOINT)); + } + + /** + * Construct a base lps client using the specified client configuration options (ex: max retry attempts, proxy + * settings, etc), and request metric collector. + * + * @param config Configuration options specifying how this client will communicate with BCE + * (ex: proxy settings, retry count, etc.). + */ + protected BaseLpsClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, lmsHandlers); + } + + protected InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String path) { + URI uri = HttpUtils.appendUri(this.getEndpoint(), path); + InternalRequest internalRequest = new InternalRequest(httpMethod, uri); + + internalRequest.addHeader(Headers.BCE_DATE, DateUtils.formatAlternateIso8601Date(new Date())); + + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + internalRequest.setSignOptions(signOptions); + internalRequest.setCredentials(this.config.getCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillInHeadAndBody(bceRequest, internalRequest); + } + return internalRequest; + } + + private void fillInHeadAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + private byte[] toJson(AbstractBceRequest bceRequest) { + try { + String jsonStr = JsonUtils.toJsonString(bceRequest); + return jsonStr.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } catch (IllegalStateException e) { + throw new BceClientException("Fail to convert request to json", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/lps/LpsClient.java b/src/main/java/com/baidubce/services/lps/LpsClient.java new file mode 100644 index 00000000..36fdb95a --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/LpsClient.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.http.HttpMethodName; +import com.baidubce.internal.InternalRequest; +import com.baidubce.services.lps.model.DirectionRequest; +import com.baidubce.services.lps.model.DirectionResponse; +import com.baidubce.services.lps.model.RouteMatrixRequest; +import com.baidubce.services.lps.model.RouteMatrixResponse; +import com.baidubce.util.JsonUtils; + +import lombok.extern.slf4j.Slf4j; + +/** + * Lps Client which provides the ability to communicating with logistic map service. + * + * @author weizhijun + * @date 2019/03/07 + */ +@Slf4j +public class LpsClient extends BaseLpsClient { + + private static final String DIRECTION_URL_PATH = "/v1/lps/logistics/direction"; + private static final String ROUTE_MATRIX_URL_PATH = "/v1/lps/logistics/routematrix"; + + /** + * Construct a lps client with default settings. + */ + public LpsClient() { + super(); + } + + /** + * Construct a lps client with customized bce client configuration. + * + * @param configuration BceClientConfiguration + */ + public LpsClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Construct a lps client access key, secret key and other default settings. + * + * @param accessKey access key id + * @param secretKey secret key + */ + public LpsClient(String accessKey, String secretKey) { + super(accessKey, secretKey); + } + + /** + * Direction the path between the given start point and end point, based on the given planning strategy. + * + * @param request DirectionRequest + * + * @return DirectionResponse + */ + public DirectionResponse direction(DirectionRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DIRECTION_URL_PATH); + log.info("direction request: {}", JsonUtils.toJsonString(internalRequest)); + return this.invokeHttpClient(internalRequest, DirectionResponse.class); + } + + /** + * Batch calculate the restriction, distance and duration information of the route according to the given point + * matrix (multiple start point and multiple end point). + * + * @param request RouteMatrixRequest + * + * @return RouteMatrixResponse + */ + public RouteMatrixResponse routeMatrix(RouteMatrixRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, ROUTE_MATRIX_URL_PATH); + log.info("route matrix request: {}", JsonUtils.toJsonString(internalRequest)); + return this.invokeHttpClient(internalRequest, RouteMatrixResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/lps/LpsRouteClient.java b/src/main/java/com/baidubce/services/lps/LpsRouteClient.java new file mode 100644 index 00000000..5889c365 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/LpsRouteClient.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps; + +import java.util.HashMap; +import java.util.Map; + +import com.baidubce.BceClientConfiguration; +import com.baidubce.http.HttpMethodName; +import com.baidubce.internal.InternalRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.lps.model.ListRouteResponse; +import com.baidubce.services.lps.model.UploadRouteRequest; +import com.baidubce.services.lps.model.UploadRouteResponse; +import com.baidubce.util.JsonUtils; + +import lombok.extern.slf4j.Slf4j; + +/** + * Lps Route Client which provides the ability to communicating with private route service. + *

+ * Created by chenbo14 on 2019/11/28. + */ +@Slf4j +public class LpsRouteClient extends BaseLpsClient { + + private static final String UPLOAD_ROUTE_URL_PATH = "/v1/lps/route/upload"; + private static final String LIST_ROUTE_URL_PATH = "/v1/lps/route/list"; + private static final String ROUTE_URL_PATH = "/v1/lps/route"; + private static final String PAGE_NO = "pageNo"; + private static final String PAGE_SIZE = "pageSize"; + + /** + * Construct a lps client with default settings. + */ + public LpsRouteClient() { + super(); + } + + /** + * Construct a lps client with customized bce client configuration. + * + * @param configuration BceClientConfiguration + */ + public LpsRouteClient(BceClientConfiguration configuration) { + super(configuration); + } + + /** + * Construct a lps client access key, secret key and other default settings. + * + * @param accessKey access key id + * @param secretKey secret key + */ + public LpsRouteClient(String accessKey, String secretKey) { + super(accessKey, secretKey); + } + + /** + * Upload the private route Info + * + * @param request UploadRouteRequest + * + * @return uploadRouteResponse with routeId + */ + public UploadRouteResponse uploadRouteInfo(UploadRouteRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, UPLOAD_ROUTE_URL_PATH); + log.info("uploadRouteInfo request: {}", JsonUtils.toJsonString(internalRequest)); + return this.invokeHttpClient(internalRequest, UploadRouteResponse.class); + } + + /** + * List route info + * + * @param pageNo + * @param pageSize + * + * @return + */ + public ListRouteResponse listRouteInfo(int pageNo, int pageSize) { + Map params = new HashMap(); + params.put(PAGE_NO, String.valueOf(pageNo)); + params.put(PAGE_SIZE, String.valueOf(pageSize)); + InternalRequest internalRequest = createRequest(null, HttpMethodName.GET, LIST_ROUTE_URL_PATH); + internalRequest.setParameters(params); + log.info("listRouteInfo request: {}", JsonUtils.toJsonString(internalRequest)); + return this.invokeHttpClient(internalRequest, ListRouteResponse.class); + } + + /** + * delete route info + * + * @param routeId + * + * @return + */ + public void deleteRouteInfo(String routeId) { + InternalRequest internalRequest = createRequest(null, HttpMethodName.DELETE, + ROUTE_URL_PATH + "/" + routeId); + log.info("deleteRouteInfo request: {}", JsonUtils.toJsonString(internalRequest)); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + +} diff --git a/src/main/java/com/baidubce/services/lps/model/Coordinate.java b/src/main/java/com/baidubce/services/lps/model/Coordinate.java new file mode 100644 index 00000000..4a004381 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/Coordinate.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Created by chenbo14 on 2019/11/28. + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Coordinate { + private double longitude; + private double latitude; +} diff --git a/src/main/java/com/baidubce/services/lps/model/DirectionRequest.java b/src/main/java/com/baidubce/services/lps/model/DirectionRequest.java new file mode 100644 index 00000000..be59fd82 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/DirectionRequest.java @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import com.baidubce.model.GenericAccountRequest; + +import lombok.Builder; +import lombok.Data; + +/** + * Request of truck direction service based on the truck parameters (eg. height, weight, length...) and driving tactics. + * + * @author weizhijun + * @date 2019/03/07 + */ +@Data +@Builder +public class DirectionRequest extends GenericAccountRequest { + + /** + * Unique task identifier, which is related to the result of orders and routes planning. + *

+ * It is optional. + */ + private String taskId; + + /** + * Unique vehicle identifier, which is related to the result of orders and routes planning. + *

+ * It is optional. + */ + private String vehicleId; + + /** + * Unique route identifier. + *

+ * It is necessary so that it must be initialized. + */ + private String routeId; + + /** + * The coordinate of the start point of the route. + *

+ * It is necessary so that it must be initialized. And the format is "latitude,longitude" (eg. "40.056878, + * 116.30815") + */ + private String origin; + + /** + * The coordinate of the end point of the route. + *

+ * It is necessary so that it must be initialized. And the format is "latitude,longitude" (eg. "40.056878, + * 116.30815") + */ + private String destination; + + /** + * The way points of the route. + *

+ * The default value is empty string. + */ + private String waypoints; + + /** + * Type of the coordinate of the start point and end point. + *

+ * Optional values are "bd09ll", "bd09mc", "gcj02", "wgs84". + */ + private String coordType; + + /** + * Expected type of the coordinate of returned result. + *

+ * Optional values are "bd09ll", "bd09mc", "gcj02", "wgs84". + */ + private String retCoordType; + + /** + * Height of the vehicle. + *

+ * The unit is meter. And the value of height must be between 0 and 5.0. + * The default value is 1.8. + */ + private Double height; + + /** + * Width of the vehicle. + *

+ * The unit is meter. And the value of width must be between 0 and 3.0. + * The default value is 1.9. + */ + private Double width; + + /** + * Total weight of the vehicle and the goods in it. + *

+ * The unit is ton. And the value of weight must be between 0 and 100. + * The default value is 2.5. + */ + private Double weight; + + /** + * Length of the vehicle. + *

+ * The unit is meter. And the value of weight must be between 0 and 20.0. + * The default value is 4.2. + */ + private Double length; + + /** + * Axle weight of the vehicle. + *

+ * The unit is ton. And the value of axle weight must be between 0 and 50. + * The default value is 2. + */ + private Double axleWeight; + + /** + * Axle counts of the vehicle. + *

+ * The value of axle counts must be between 0 and 50. + * The default value is 2. + */ + private Integer axleCount; + + /** + * If the vehicle is trailer. + *

+ * 1: yes + * 0: no + */ + private Integer isTrailer; + + /** + * Province which the plate of the vehicle belongs to. + * The default value is empty string. + */ + private String plateProvince; + + /** + * Plate number of the vehicle. + * The default value is empty string. + */ + private String plateNumber; + + /** + * Plate color of the vehicle. + *

+ * 0: blue (default value) + * 1: yellow + * 2: black + * 3: white + */ + private Integer plateColor; + + /** + * Departure time. + *

+ * The format is unix timestamp in seconds. + * And it must be the time of the next three days. + */ + private Long departureTime; + + /** + * Driving tactics. + *

+ * Util now, the optional value of tactics has to be 0, which represents the tactics of shortest time. + */ + private Integer tactics; + + /** + * If return alternative routes. + *

+ * 0(default value): only return one route. + * 1: return 1 to 3 alternative routes. + */ + private Integer alternatives; +} diff --git a/src/main/java/com/baidubce/services/lps/model/DirectionResponse.java b/src/main/java/com/baidubce/services/lps/model/DirectionResponse.java new file mode 100644 index 00000000..ffca28cd --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/DirectionResponse.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +/** + * Response of truck direction service. + * + * @author weizhijun + * @date 2019/03/07 + */ +@Data +public class DirectionResponse extends AbstractBceResponse { + /** + * Result of direction. + */ + private PathRoute result; + + /** + * Object which contains the detail of the planned path information between two points. + */ + @Data + public static class PathRoute { + /** + * The restriction information of the path. + *

+ * If the path matches multiple restriction information, then it only returns one of them. + */ + private List restriction; + + /** + * The total number of returned path. + */ + private Integer total; + + /** + * List of returned path. + */ + private List routes; + } + + /** + * Object which contains the detail of single route between two points. + */ + @Data + public static class Route { + + /** + * Location coordinate of the start point. + */ + private Location origin; + + /** + * Location coordinate of the end point. + */ + private Location destination; + + /** + * Distance between origin and destination. The unit is meter. + */ + private Double distance; + + /** + * Duration between origin and destination. The unit is second. + */ + private Integer duration; + + /** + * Tag of this planned route. + */ + private String tag; + + /** + * Road toll. The unit is "yuan" + */ + private Integer toll; + + /** + * Mileage of the tolled road. The unit is meter. + */ + private Double tollDistance; + + /** + * List of segmented route. + */ + private List steps; + } + + /** + * Object which represents a segmented route. + */ + @Data + public static class Step { + + /** + * Leg index of the step. + */ + private Integer legIndex; + + /** + * Angle of entry into the road. + */ + private Integer direction; + + /** + * Distance of the segmented route. + */ + private Double distance; + + /** + * Name of the segmented route. + */ + private String roadName; + + /** + * Type of the segmented route. + */ + private Integer roadType; + + /** + * Tolled distance of the segmented route. + */ + private Double tollDistance; + + /** + * Name of the toll station. + */ + private String tollGateName; + + /** + * Location coordinate of the toll station. + */ + private Location tollGateLocation; + + /** + * Location coordinate of start point of the segmented route. + */ + private Location startLocation; + + /** + * Location coordinate of end point of the segmented route. + */ + private Location endLocation; + + /** + * Coordinates of the segmented route. + * eg. "117.20525509975337,31.75394188978729;117.20521518267502,31.754031256443565;" + */ + private String path; + + /** + * List of traffic condition the segmented route (historical traffic condition). + */ + private List trafficCondition; + } + + /** + * Traffic condition information. + */ + @Data + public static class TrafficCondition { + + /** + * Road condition index. + */ + private Integer status; + + /** + * The number of coordinate points with the same road condition in the path from the current coordinate point. + */ + private Integer geoCnt; + + /** + * The same distance in the path from the current coordinate point. + * And the unit is meter. + */ + private Double distance; + } +} diff --git a/src/main/java/com/baidubce/services/lps/model/ListRouteResponse.java b/src/main/java/com/baidubce/services/lps/model/ListRouteResponse.java new file mode 100644 index 00000000..5a41b71e --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/ListRouteResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +/** + * Created by chenbo14 on 2019/11/19. + */ +@Data +public class ListRouteResponse extends AbstractBceResponse { + private Meta meta; + private List data; + + @Data + public static class Meta { + private Integer total; + private Integer pageNo; + private Integer pageSize; + } + + @Data + public static class RouteInfo { + private String userId; + private String routeId; + private String departureCoordinate; // 经度,纬度 + private String arrivalCoordinate; + private List routeCoordinateList; + private Integer distance; + private Integer duration; + } +} diff --git a/src/main/java/com/baidubce/services/lps/model/Location.java b/src/main/java/com/baidubce/services/lps/model/Location.java new file mode 100644 index 00000000..808b7f31 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/Location.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import lombok.Data; + +/** + * Location coordinate of point. + * + * @author weizhijun + * @date 2019/03/11 + */ +@Data +public class Location { + + /** + * Longitude of the point. + */ + private Double lng; + + /** + * Latitude of the point. + */ + private Double lat; +} diff --git a/src/main/java/com/baidubce/services/lps/model/PointMatrix.java b/src/main/java/com/baidubce/services/lps/model/PointMatrix.java new file mode 100644 index 00000000..77a80eb3 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/PointMatrix.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Points matrix. + * + * @author weizhijun + * @date 2019/03/07 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PointMatrix { + + /** + * Start points of routes. + *

+ * The format is string which is composed of coordinate string ("latitude, longitude") joined by '|' (eg. + * 21.22345,112.11478|21.47832,112.37854) + * And the product of the number of start points and end points must not be larger than 50. + */ + private String origins; + + /** + * End points of routes. + *

+ * The format and limitation are the same as origins. + */ + private String destinations; +} diff --git a/src/main/java/com/baidubce/services/lps/model/RestrictionInfo.java b/src/main/java/com/baidubce/services/lps/model/RestrictionInfo.java new file mode 100644 index 00000000..0b5b2585 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/RestrictionInfo.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import lombok.Data; + +/** + * Restriction information. + * + * @author weizhijun + * @date 2019/03/11 + */ +@Data +public class RestrictionInfo { + /** + * Type of restriction. + *

+ * Optional value: + * 0: no restriction. + * 1: restrict local vehicle. + * 2: restrict outland vehicle. + * 3: restrict tail number of local vehicle. + * 4: restrict tail number of outland vehicle. + * 5: other restrictions. + */ + private String type; + + /** + * The detail of restriction information. + */ + private String info; +} diff --git a/src/main/java/com/baidubce/services/lps/model/RouteMatrixRequest.java b/src/main/java/com/baidubce/services/lps/model/RouteMatrixRequest.java new file mode 100644 index 00000000..2a22ca25 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/RouteMatrixRequest.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Builder; +import lombok.Data; + +/** + * Request of batch calculating the distance, duration, restrict information of routes based on the truck parameters + * (eg. height, weight, length...) and driving tactics. + * + * @author weizhijun + * @date 2019/03/07 + */ +@Data +@Builder +public class RouteMatrixRequest extends GenericAccountRequest { + + /** + * Point matrix which includes the start points and end points of routes. + * + * @see PointMatrix + */ + private PointMatrix pointMatrix; + + /** + * Type of the coordinate of the start point and end point. + *

+ * Optional values are "bd09ll", "bd09mc", "gcj02", "wgs84". + */ + private String coordType; + + /** + * Height of the vehicle. + *

+ * The unit is meter. And the value of height must be between 0 and 5.0. + * The default value is 1.8. + */ + private Double height; + + /** + * Width of the vehicle. + *

+ * The unit is meter. And the value of width must be between 0 and 3.0. + * The default value is 1.9. + */ + private Double width; + + /** + * Total weight of the vehicle and the goods in it. + *

+ * The unit is ton. And the value of weight must be between 0 and 100. + * The default value is 2.5. + */ + private Double weight; + + /** + * Length of the vehicle. + *

+ * The unit is meter. And the value of weight must be between 0 and 20.0. + * The default value is 4.2. + */ + private Double length; + + /** + * Axle weight of the vehicle. + *

+ * The unit is ton. And the value of axle weight must be between 0 and 50. + * The default value is 2. + */ + private Double axleWeight; + + /** + * Axle counts of the vehicle. + *

+ * The value of axle counts must be between 0 and 50. + * The default value is 2. + */ + private Integer axleCount; + + /** + * If the vehicle is trailer. + *

+ * 1: yes + * 0: no + */ + private Integer isTrailer; + + /** + * Province which the plate of the vehicle belongs to. + * The default value is empty string. + */ + private String plateProvince; + + /** + * Plate number of the vehicle. + * The default value is empty string. + */ + private String plateNumber; + + /** + * Plate color of the vehicle. + *

+ * 0: blue (default value) + * 1: yellow + * 2: black + * 3: white + */ + private Integer plateColor; + + /** + * Departure time. + *

+ * The format is unix timestamp in seconds. + * And it must be the time of the next three days. + */ + private Long departureTime; + + /** + * Driving tactics. + *

+ * Util now, the optional value of tactics has to be 0, which represents the tactics of shortest time. + */ + private Integer tactics; + + /** + * If return alternative routes. + *

+ * 0(default value): only return one route. + * 1: return 1 to 3 alternative routes. + */ + private Integer alternatives; + + @JsonIgnore + public String getOrigins() { + return pointMatrix.getOrigins(); + } + + @JsonIgnore + public void setOrigins(String origins) { + pointMatrix.setOrigins(origins); + } + + @JsonIgnore + public String getDestinations() { + return pointMatrix.getDestinations(); + } + + @JsonIgnore + public void setDestinations(String destinations) { + pointMatrix.setDestinations(destinations); + } +} diff --git a/src/main/java/com/baidubce/services/lps/model/RouteMatrixResponse.java b/src/main/java/com/baidubce/services/lps/model/RouteMatrixResponse.java new file mode 100644 index 00000000..77ae07b1 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/RouteMatrixResponse.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +/** + * Response of batch routes calculating service. + * + * @author weizhijun + * @date 2019/03/07 + */ +@Data +public class RouteMatrixResponse extends AbstractBceResponse { + + /** + * Total result of routes calculation. + */ + private List result; + + /** + * Object including the calculate result of one point pair (one start point and one end point). + */ + @Data + public static class Distance { + + /** + * Restriction information. + */ + private RestrictionInfo restriction; + + /** + * Distance information. + */ + private DistanceInfo distance; + + /** + * Duration information. + */ + private DurationInfo duration; + } + + /** + * Object including the distance information of the route of one point pair. + */ + @Data + public static class DistanceInfo { + + /** + * Description of the distance. + *

+ * The unit would be meter or kilometer. + */ + private String text; + + /** + * Value of the distance. And the unit is meter. + */ + private Double value; + } + + /** + * Object including the duration information of the route of one point pair. + */ + @Data + public static class DurationInfo { + + /** + * Description of the duration. + *

+ * The unit would be minute or hour. + */ + private String text; + + /** + * Value of the duration. And the unit is second. + */ + private Double value; + } +} diff --git a/src/main/java/com/baidubce/services/lps/model/UploadRouteRequest.java b/src/main/java/com/baidubce/services/lps/model/UploadRouteRequest.java new file mode 100644 index 00000000..ab20a804 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/UploadRouteRequest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import java.util.List; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Created by chenbo14 on 2019/11/28. + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UploadRouteRequest extends GenericAccountRequest { + private Coordinate departureCoordinate; + private Coordinate arrivalCoordinate; + private List routeCoordinateList; + private Integer duration; + private Integer distance; +} diff --git a/src/main/java/com/baidubce/services/lps/model/UploadRouteResponse.java b/src/main/java/com/baidubce/services/lps/model/UploadRouteResponse.java new file mode 100644 index 00000000..4d7c90e9 --- /dev/null +++ b/src/main/java/com/baidubce/services/lps/model/UploadRouteResponse.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lps.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +/** + * Created by chenbo14 on 2019/11/28. + */ +@Data +public class UploadRouteResponse extends AbstractBceResponse { + private String routeId; +} diff --git a/src/main/java/com/baidubce/services/lss/LssClient.java b/src/main/java/com/baidubce/services/lss/LssClient.java old mode 100644 new mode 100755 index 401e76cb..87812d37 --- a/src/main/java/com/baidubce/services/lss/LssClient.java +++ b/src/main/java/com/baidubce/services/lss/LssClient.java @@ -25,6 +25,7 @@ import com.baidubce.internal.InternalRequest; import com.baidubce.internal.RestartableInputStream; import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; import com.baidubce.services.lss.model.AntiLeech; import com.baidubce.services.lss.model.Audio; import com.baidubce.services.lss.model.Auth; @@ -42,27 +43,30 @@ import com.baidubce.services.lss.model.DeletePresetResponse; import com.baidubce.services.lss.model.DeleteSessionRequest; import com.baidubce.services.lss.model.DeleteSessionResponse; +import com.baidubce.services.lss.model.DeleteStreamRequest; import com.baidubce.services.lss.model.Encryption; import com.baidubce.services.lss.model.GetAllDomainsBandwidthResponse; +import com.baidubce.services.lss.model.GetAllDomainsBandwidthResponseV2; import com.baidubce.services.lss.model.GetAllDomainsPlayCountResponse; import com.baidubce.services.lss.model.GetAllDomainsStatisticsRequest; +import com.baidubce.services.lss.model.GetAllDomainsStatisticsRequestV2; import com.baidubce.services.lss.model.GetAllDomainsTrafficResponse; +import com.baidubce.services.lss.model.GetAppRequest; +import com.baidubce.services.lss.model.GetAppResponse; +import com.baidubce.services.lss.model.GetAppStreamRequest; +import com.baidubce.services.lss.model.GetAppStreamResponse; import com.baidubce.services.lss.model.GetDomainStatisticsRequest; import com.baidubce.services.lss.model.GetDomainStatisticsResponse; import com.baidubce.services.lss.model.GetDomainSummaryStatisticsRequest; import com.baidubce.services.lss.model.GetDomainSummaryStatisticsResponse; -import com.baidubce.services.lss.model.GetOneDomainTrafficResponse; -import com.baidubce.services.lss.model.ListDomainStatisticsResponse; -import com.baidubce.services.lss.model.GetStreamStatisticsResponse; -import com.baidubce.services.lss.model.ListStreamStatisticsResponse; -import com.baidubce.services.lss.model.ListDomainStatisticsRequest; -import com.baidubce.services.lss.model.ListStreamStatisticsRequest; -import com.baidubce.services.lss.model.GetStreamStatisticsRequest; import com.baidubce.services.lss.model.GetNotificationRequest; import com.baidubce.services.lss.model.GetNotificationResponse; import com.baidubce.services.lss.model.GetOneDomainBandwidthResponse; +import com.baidubce.services.lss.model.GetOneDomainBandwidthResponseV2; import com.baidubce.services.lss.model.GetOneDomainPlayCountResponse; import com.baidubce.services.lss.model.GetOneDomainStatisticsRequest; +import com.baidubce.services.lss.model.GetOneDomainStatisticsRequestV2; +import com.baidubce.services.lss.model.GetOneDomainTrafficResponse; import com.baidubce.services.lss.model.GetPresetRequest; import com.baidubce.services.lss.model.GetPresetResponse; import com.baidubce.services.lss.model.GetRecordingRequest; @@ -73,18 +77,32 @@ import com.baidubce.services.lss.model.GetSessionResponse; import com.baidubce.services.lss.model.GetSessionSourceInfoRequest; import com.baidubce.services.lss.model.GetSessionSourceInfoResponse; +import com.baidubce.services.lss.model.GetSessionStatisticsRequest; +import com.baidubce.services.lss.model.GetSessionStatisticsResponse; import com.baidubce.services.lss.model.GetStreamRequest; import com.baidubce.services.lss.model.GetStreamResponse; +import com.baidubce.services.lss.model.GetStreamSourceInfoRequest; +import com.baidubce.services.lss.model.GetStreamSourceInfoResponse; +import com.baidubce.services.lss.model.GetStreamStatisticsRequest; +import com.baidubce.services.lss.model.GetStreamStatisticsResponse; import com.baidubce.services.lss.model.Hls; import com.baidubce.services.lss.model.InsertCuePointInnerRequest; import com.baidubce.services.lss.model.InsertCuePointRequest; import com.baidubce.services.lss.model.InsertCuePointResponse; +import com.baidubce.services.lss.model.ListAppRequest; +import com.baidubce.services.lss.model.ListAppResponse; +import com.baidubce.services.lss.model.ListAppStreamsRequest; +import com.baidubce.services.lss.model.ListAppStreamsResponse; import com.baidubce.services.lss.model.ListDomainAppRequest; import com.baidubce.services.lss.model.ListDomainAppResponse; +import com.baidubce.services.lss.model.ListDomainStatisticsRequest; +import com.baidubce.services.lss.model.ListDomainStatisticsResponse; import com.baidubce.services.lss.model.ListNotificationsRequest; import com.baidubce.services.lss.model.ListNotificationsResponse; import com.baidubce.services.lss.model.ListPresetsRequest; import com.baidubce.services.lss.model.ListPresetsResponse; +import com.baidubce.services.lss.model.ListRealtimeStreamStatisticsRequest; +import com.baidubce.services.lss.model.ListRealtimeStreamStatisticsResponse; import com.baidubce.services.lss.model.ListRecordingsResponse; import com.baidubce.services.lss.model.ListSecurityPoliciesRequest; import com.baidubce.services.lss.model.ListSecurityPoliciesResponse; @@ -92,6 +110,8 @@ import com.baidubce.services.lss.model.ListSessionsResponse; import com.baidubce.services.lss.model.ListStreamRequest; import com.baidubce.services.lss.model.ListStreamResponse; +import com.baidubce.services.lss.model.ListStreamStatisticsRequest; +import com.baidubce.services.lss.model.ListStreamStatisticsResponse; import com.baidubce.services.lss.model.LivePublishInfo; import com.baidubce.services.lss.model.LiveThumbnail; import com.baidubce.services.lss.model.PauseAppStreamRequest; @@ -100,14 +120,19 @@ import com.baidubce.services.lss.model.PauseDomainStreamResponse; import com.baidubce.services.lss.model.PauseSessionRequest; import com.baidubce.services.lss.model.PauseSessionResponse; +import com.baidubce.services.lss.model.RecordingClipRequest; +import com.baidubce.services.lss.model.RecordingClipResponse; import com.baidubce.services.lss.model.RefreshSessionRequest; import com.baidubce.services.lss.model.RefreshSessionResponse; +import com.baidubce.services.lss.model.ResetDomainStreamRequest; +import com.baidubce.services.lss.model.ResetDomainStreamRequestBody; +import com.baidubce.services.lss.model.ResetDomainStreamResponse; import com.baidubce.services.lss.model.ResumeAppStreamRequest; import com.baidubce.services.lss.model.ResumeAppStreamResponse; -import com.baidubce.services.lss.model.ResumeSessionRequest; -import com.baidubce.services.lss.model.ResumeSessionResponse; import com.baidubce.services.lss.model.ResumeDomainStreamRequest; import com.baidubce.services.lss.model.ResumeDomainStreamResponse; +import com.baidubce.services.lss.model.ResumeSessionRequest; +import com.baidubce.services.lss.model.ResumeSessionResponse; import com.baidubce.services.lss.model.Rtmp; import com.baidubce.services.lss.model.StartPullSessionRequest; import com.baidubce.services.lss.model.StartPullSessionResponse; @@ -115,21 +140,18 @@ import com.baidubce.services.lss.model.StartRecordingResponse; import com.baidubce.services.lss.model.StopRecordingRequest; import com.baidubce.services.lss.model.StopRecordingResponse; +import com.baidubce.services.lss.model.StreamingStreamRequest; +import com.baidubce.services.lss.model.StreamingStreamResponse; import com.baidubce.services.lss.model.UpdateSecurityPolicyInnerRequest; import com.baidubce.services.lss.model.UpdateSecurityPolicyRequest; import com.baidubce.services.lss.model.UpdateSecurityPolicyResponse; +import com.baidubce.services.lss.model.UpdateStreamDestinationPushUrlRequest; +import com.baidubce.services.lss.model.UpdateStreamPresetsRequest; +import com.baidubce.services.lss.model.UpdateStreamPullUrlRequest; +import com.baidubce.services.lss.model.UpdateStreamRecordingRequest; +import com.baidubce.services.lss.model.UpdateStreamWatermarkRequest; import com.baidubce.services.lss.model.Video; import com.baidubce.services.lss.model.Watermarks; -import com.baidubce.services.lss.model.GetAppResponse; -import com.baidubce.services.lss.model.GetAppRequest; -import com.baidubce.services.lss.model.GetAppStreamResponse; -import com.baidubce.services.lss.model.GetAppStreamRequest; -import com.baidubce.services.lss.model.ListAppResponse; -import com.baidubce.services.lss.model.ListAppRequest; -import com.baidubce.services.lss.model.ListAppStreamsResponse; -import com.baidubce.services.lss.model.ListAppStreamsRequest; -import com.baidubce.services.lss.model.GetSessionStatisticsRequest; -import com.baidubce.services.lss.model.GetSessionStatisticsResponse; import com.baidubce.util.HttpUtils; import com.baidubce.util.JsonUtils; import org.joda.time.DateTime; @@ -159,6 +181,8 @@ public class LssClient extends AbstractBceClient { */ private static final String VERSION = "v5"; + private static final String VERSION_V6 = "v6"; + /** * The common URI prefix for live preset services. */ @@ -204,6 +228,11 @@ public class LssClient extends AbstractBceClient { */ private static final String STATUS = "status"; + /** + * Parameter for reseting live session. + */ + private static final String RESET = "reset"; + /** * Parameter for pausing live session. */ @@ -219,11 +248,21 @@ public class LssClient extends AbstractBceClient { */ private static final String REFRESH = "refresh"; + /** + * The common URI prefix for get ongiong stream. + */ + private static final String ONGOING_STREAM = "streaming"; + /** * Parameter for starting pulling live session. */ private static final String PULL = "pull"; + /** + * Parameter for clip recording file. + */ + private static final String CLIP = "clip"; + /** * Parameter for getting live source info. */ @@ -239,6 +278,11 @@ public class LssClient extends AbstractBceClient { */ private static final String STATISTICS = "statistics"; + /** + * Parameter for realtime. + */ + private static final String REALTIME = "realtime"; + /** * Responsible for handling httpResponses from all service calls. */ @@ -259,7 +303,7 @@ public LssClient() { * Constructs a new client using the client configuration. * * @param clientConfiguration The client configuration options controlling how this client - * connects to Lss services (e.g. proxy settings, retry counts, etc). + * connects to Lss services (e.g. proxy settings, retry counts, etc). */ public LssClient(BceClientConfiguration clientConfiguration) { super(clientConfiguration, lssHandlers); @@ -269,6 +313,7 @@ public LssClient(BceClientConfiguration clientConfiguration) { * Create a live preset which contains parameters needed in the live stream service. * * @param request The request object containing all options for creating presets. + * @return the response */ public CreatePresetResponse createPreset(CreatePresetRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -314,18 +359,18 @@ public CreatePresetResponse createPreset(CreatePresetRequest request) { * Create a live preset which contains parameters needed in the live stream service, and not in forward only * mode, so that the input stream will be transcoded according to audio and video parameters. * - * @param name The name of the new live preset. + * @param name The name of the new live preset. * @param description The description of the new live preset - * @param audio Specify the audio parameters of live stream. - * @param video Specify the video parameters of live stream. - * @param hls Specify the hls parameters of live stream. - * @param rtmp Specify the rtmp parameters of live stream. - * @param thumbnail Specify the thumbnail parameters of live stream. - * @param watermarks Specify the watermarks parameters of live stream. - * + * @param audio Specify the audio parameters of live stream. + * @param video Specify the video parameters of live stream. + * @param hls Specify the hls parameters of live stream. + * @param rtmp Specify the rtmp parameters of live stream. + * @param thumbnail Specify the thumbnail parameters of live stream. + * @param watermarks Specify the watermarks parameters of live stream. + * @return the response */ public CreatePresetResponse createPreset(String name, String description, Audio audio, Video video, - Hls hls, Rtmp rtmp, LiveThumbnail thumbnail, Watermarks watermarks) { + Hls hls, Rtmp rtmp, LiveThumbnail thumbnail, Watermarks watermarks) { CreatePresetRequest request = new CreatePresetRequest(); request.setForwardOnly(false); request.setName(name); @@ -345,16 +390,16 @@ public CreatePresetResponse createPreset(String name, String description, Audio * Create a live preset which contains parameters needed in the live stream service, and in forward only mode, in * which the input stream's resolution ratio and code rate will be kept unchanged. * - * @param name The name of the new live preset. + * @param name The name of the new live preset. * @param description The description of the new live preset - * @param hls Specify the hls parameters of live stream. - * @param rtmp Specify the rtmp parameters of live stream. - * @param thumbnail Specify the thumbnail parameters of live stream. - * @param watermarks Specify the watermarks parameters of live stream. - * + * @param hls Specify the hls parameters of live stream. + * @param rtmp Specify the rtmp parameters of live stream. + * @param thumbnail Specify the thumbnail parameters of live stream. + * @param watermarks Specify the watermarks parameters of live stream. + * @return the response */ public CreatePresetResponse createForwardOnlyPreset(String name, String description, Hls hls, Rtmp rtmp, - LiveThumbnail thumbnail, Watermarks watermarks) { + LiveThumbnail thumbnail, Watermarks watermarks) { CreatePresetRequest request = new CreatePresetRequest(); request.setForwardOnly(true); request.setName(name); @@ -382,8 +427,7 @@ public ListPresetsResponse listPresets() { /** * Get your live preset by live preset name. * - * @param name Live preset name. - * + * @param name Live preset name. * @return Your live preset */ public GetPresetResponse getPreset(String name) { @@ -396,7 +440,6 @@ public GetPresetResponse getPreset(String name) { * Get your live preset by live preset name. * * @param request The request object containing all parameters for getting live preset. - * * @return Your live preset */ public GetPresetResponse getPreset(GetPresetRequest request) { @@ -410,8 +453,8 @@ public GetPresetResponse getPreset(GetPresetRequest request) { /** * Delete your live presets by live preset name. * - * @param name Live preset name. - * + * @param name Live preset name. + * @return the response */ public DeletePresetResponse deletePreset(String name) { DeletePresetRequest request = new DeletePresetRequest(); @@ -424,7 +467,7 @@ public DeletePresetResponse deletePreset(String name) { * Delete your live presets by live preset name. * * @param request The request object containing all parameters for deleting live preset. - * + * @return the response */ public DeletePresetResponse deletePreset(DeletePresetRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -435,20 +478,19 @@ public DeletePresetResponse deletePreset(DeletePresetRequest request) { } - /** * Create a live session in the live stream service. * * @param description The description of the new live session. - * @param preset The name of the new live session. + * @param preset The name of the new live session. * @param notification The notification of the new live session. * @param securityPolicy The security policy of the new live session. * @param recording The recording preset of the new live session. - * @param publish Specify the LivePublishInfo of live session. - * + * @param publish Specify the LivePublishInfo of live session. + * @return the response */ public CreateSessionResponse createSession(String description, String preset, String notification, - String securityPolicy, String recording, LivePublishInfo publish) { + String securityPolicy, String recording, LivePublishInfo publish) { CreateSessionRequest request = new CreateSessionRequest(); request.withPreset(preset).withDescription(description).withNotification(notification); request.withSecurityPolicy(securityPolicy).withPublish(publish).withRecording(recording); @@ -459,15 +501,15 @@ public CreateSessionResponse createSession(String description, String preset, St * Create a live session in the live stream service. * * @param description The description of the new live session. - * @param presets The name of the new live session. + * @param presets The name of the new live session. * @param notification The notification of the new live session. * @param securityPolicy The security policy of the new live session. * @param recording The recording preset of the new live session. - * @param publish Specify the LivePublishInfo of live session. - * + * @param publish Specify the LivePublishInfo of live session. + * @return the response */ public CreateSessionResponse createSession(String description, List presets, String notification, - String securityPolicy, String recording, LivePublishInfo publish) { + String securityPolicy, String recording, LivePublishInfo publish) { CreateSessionRequest request = new CreateSessionRequest(); Map presetMap = new HashMap(); for (int i = 0; i < presets.size(); i++) { @@ -482,18 +524,18 @@ public CreateSessionResponse createSession(String description, List pres * Create a live session in the live stream service. * * @param description The description of the new live session. - * @param presets The name of the new live session. + * @param presets The name of the new live session. * @param notification The notification of the new live session. * @param securityPolicy The security policy of the new live session. * @param recording The recording preset of the new live session. - * @param publish Specify the LivePublishInfo of live session. + * @param publish Specify the LivePublishInfo of live session. * @param thumbnail The thumbnail of new live session * @param watermarks The watermarks of new live session - * + * @return the response */ public CreateSessionResponse createSession(String description, List presets, String notification, - String securityPolicy, String recording, LivePublishInfo publish, - String thumbnail, Watermarks watermarks) { + String securityPolicy, String recording, LivePublishInfo publish, + String thumbnail, Watermarks watermarks) { CreateSessionRequest request = new CreateSessionRequest(); Map presetMap = new HashMap(); for (int i = 0; i < presets.size(); i++) { @@ -509,6 +551,7 @@ public CreateSessionResponse createSession(String description, List pres * Create a live session in the live stream service. * * @param request The request object containing all options for creating live session. + * @return the response */ public CreateSessionResponse createSession(CreateSessionRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -535,8 +578,7 @@ public ListSessionsResponse listSessions() { /** * List all your live sessions with given status. * - * @param status Live session status. - * + * @param status Live session status. * @return The list of all your live sessions. */ public ListSessionsResponse listSessions(String status) { @@ -548,7 +590,6 @@ public ListSessionsResponse listSessions(String status) { * List all your live sessions. * * @param request The request object containing all parameters for listing live sessions. - * * @return The list of all your live sessions. */ public ListSessionsResponse listSessions(ListSessionsRequest request) { @@ -565,8 +606,7 @@ public ListSessionsResponse listSessions(ListSessionsRequest request) { /** * Get your live session by live session id. * - * @param sessionId Live session id. - * + * @param sessionId Live session id. * @return Your live session. */ public GetSessionResponse getSession(String sessionId) { @@ -578,9 +618,8 @@ public GetSessionResponse getSession(String sessionId) { /** * Get your live session with token by live session id. * - * @param sessionId Live session id. - * @param timeoutInMinute Timeout of token. - * + * @param sessionId Live session id. + * @param timeoutInMinute Timeout of token. * @return Your live session with token. */ public GetSessionResponse getSessionWithToken(String sessionId, Integer timeoutInMinute) { @@ -703,7 +742,6 @@ public GetSessionResponse getSessionWithToken(String sessionId, Integer timeoutI * Get your live session by live session id. * * @param request The request object containing all parameters for getting live session. - * * @return Your live session. */ public GetSessionResponse getSession(GetSessionRequest request) { @@ -717,8 +755,8 @@ public GetSessionResponse getSession(GetSessionRequest request) { /** * Delete your live session by live session id. * - * @param sessionId Live session id. - * + * @param sessionId Live session id. + * @return the response */ public DeleteSessionResponse deleteSession(String sessionId) { DeleteSessionRequest request = new DeleteSessionRequest(); @@ -730,7 +768,7 @@ public DeleteSessionResponse deleteSession(String sessionId) { * Delete your live session by live session id. * * @param request The request object containing all parameters for deleting live session. - * + * @return the response */ public DeleteSessionResponse deleteSession(DeleteSessionRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -743,8 +781,8 @@ public DeleteSessionResponse deleteSession(DeleteSessionRequest request) { /** * Pause your live session by live session id. * - * @param sessionId Live session id. - * + * @param sessionId Live session id. + * @return the response */ public PauseSessionResponse pauseSession(String sessionId) { PauseSessionRequest request = new PauseSessionRequest(); @@ -756,7 +794,7 @@ public PauseSessionResponse pauseSession(String sessionId) { * Pause your live session by live session id. * * @param request The request object containing all parameters for pausing live session. - * + * @return the response */ public PauseSessionResponse pauseSession(PauseSessionRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -770,8 +808,8 @@ public PauseSessionResponse pauseSession(PauseSessionRequest request) { /** * get detail of your app by name * - * @param app app name - * + * @param app app name + * @return the response */ public GetAppResponse queryApp(String app) { GetAppRequest request = new GetAppRequest(); @@ -782,8 +820,8 @@ public GetAppResponse queryApp(String app) { /** * get detail of your app by name * - * @param request The request object containing all parameters for querying app. - * + * @param request The request object containing all parameters for querying app. + * @return the response */ public GetAppResponse queryApp(GetAppRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -795,7 +833,7 @@ public GetAppResponse queryApp(GetAppRequest request) { /** * list all your apps - * + * @return this object */ public ListAppResponse listApp() { ListAppRequest request = new ListAppRequest(); @@ -805,8 +843,8 @@ public ListAppResponse listApp() { /** * list all your apps * - * @param request The request object containing all parameters for list all apps. - * + * @param request The request object containing all parameters for list all apps. + * @return the response */ public ListAppResponse listApp(ListAppRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -817,9 +855,9 @@ public ListAppResponse listApp(ListAppRequest request) { /** * get detail of your stream by app name and stream name * - * @param app app name - * @param stream stream name - * + * @param app app name + * @param stream stream name + * @return the response */ public GetAppStreamResponse queryAppStream(String app, String stream) { GetAppStreamRequest request = new GetAppStreamRequest(); @@ -831,8 +869,8 @@ public GetAppStreamResponse queryAppStream(String app, String stream) { /** * get detail of your stream by app name and stream name * - * @param request The request object containing all parameters for query app stream. - * + * @param request The request object containing all parameters for query app stream. + * @return the response */ public GetAppStreamResponse queryAppStream(GetAppStreamRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -846,9 +884,9 @@ public GetAppStreamResponse queryAppStream(GetAppStreamRequest request) { /** * list your streams by app name and stream status * - * @param app app name + * @param app app name * @param status stream status - * + * @return the response */ public ListAppStreamsResponse listAppStreams(String app, String status) { ListAppStreamsRequest request = new ListAppStreamsRequest(); @@ -861,8 +899,8 @@ public ListAppStreamsResponse listAppStreams(String app, String status) { /** * list your streams by app name * - * @param app app name - * + * @param app app name + * @return the response */ public ListAppStreamsResponse listAppStreams(String app) { ListAppStreamsRequest request = new ListAppStreamsRequest(); @@ -874,7 +912,7 @@ public ListAppStreamsResponse listAppStreams(String app) { * list your streams by app name and stream status * * @param request The request object containing all parameters for list app streams. - * + * @return this object */ public ListAppStreamsResponse listAppStreams(ListAppStreamsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -890,9 +928,9 @@ public ListAppStreamsResponse listAppStreams(ListAppStreamsRequest request) { /** * Pause your app stream by app name and stream name * - * @param app app name - * @param stream stream name - * + * @param app app name + * @param stream stream name + * @return the response */ public PauseAppStreamResponse pauseAppStream(String app, String stream) { PauseAppStreamRequest pauseAppStreamRequest = new PauseAppStreamRequest(); @@ -904,8 +942,8 @@ public PauseAppStreamResponse pauseAppStream(String app, String stream) { /** * Pause your app stream by app name and stream name * - * @param request The request object containing all parameters for pausing app session. - * + * @param request The request object containing all parameters for pausing app session. + * @return the response */ public PauseAppStreamResponse pauseAppStream(PauseAppStreamRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -920,8 +958,8 @@ public PauseAppStreamResponse pauseAppStream(PauseAppStreamRequest request) { /** * Resume your live session by live session id. * - * @param sessionId Live session id. - * + * @param sessionId Live session id. + * @return the response */ public ResumeSessionResponse resumeSession(String sessionId) { ResumeSessionRequest request = new ResumeSessionRequest(); @@ -933,7 +971,7 @@ public ResumeSessionResponse resumeSession(String sessionId) { * Resume your live session by live session id. * * @param request The request object containing all parameters for resuming live session. - * + * @return the response */ public ResumeSessionResponse resumeSession(ResumeSessionRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -947,9 +985,9 @@ public ResumeSessionResponse resumeSession(ResumeSessionRequest request) { /** * Resume your app stream by app name and stream name * - * @param app app name - * @param stream stream name - * + * @param app app name + * @param stream stream name + * @return the response */ public ResumeAppStreamResponse resumeAppStream(String app, String stream) { ResumeAppStreamRequest request = new ResumeAppStreamRequest(); @@ -961,8 +999,8 @@ public ResumeAppStreamResponse resumeAppStream(String app, String stream) { /** * Resume your app stream by app name and stream name * - * @param request The request object containing all parameters for resuming app session. - * + * @param request The request object containing all parameters for resuming app session. + * @return the response */ public ResumeAppStreamResponse resumeAppStream(ResumeAppStreamRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -977,8 +1015,8 @@ public ResumeAppStreamResponse resumeAppStream(ResumeAppStreamRequest request) { /** * Refresh your live session by live session id. * - * @param sessionId Live session id. - * + * @param sessionId Live session id. + * @return the response */ public RefreshSessionResponse refreshSession(String sessionId) { RefreshSessionRequest request = new RefreshSessionRequest(); @@ -990,7 +1028,7 @@ public RefreshSessionResponse refreshSession(String sessionId) { * Refresh your live session by live session id. * * @param request The request object containing all parameters for refreshing live session. - * + * @return the response */ public RefreshSessionResponse refreshSession(RefreshSessionRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1004,8 +1042,8 @@ public RefreshSessionResponse refreshSession(RefreshSessionRequest request) { /** * Start your pulling live session by live session id. * - * @param sessionId Live session id. - * + * @param sessionId Live session id. + * @return the response */ public StartPullSessionResponse startPullSession(String sessionId) { StartPullSessionRequest request = new StartPullSessionRequest().withSessionId(sessionId); @@ -1016,7 +1054,7 @@ public StartPullSessionResponse startPullSession(String sessionId) { * Start your pulling live session by live session id. * * @param request The request object containing all parameters for starting pulling live session. - * + * @return the response */ public StartPullSessionResponse startPullSession(StartPullSessionRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1032,6 +1070,7 @@ public StartPullSessionResponse startPullSession(StartPullSessionRequest request * * @param sessionId Live session id. * @param recording Live recording preset name. + * @return the response */ public StartRecordingResponse startRecording(String sessionId, String recording) { checkStringNotEmpty(sessionId, "The parameter sessionId should NOT be null or empty string."); @@ -1046,6 +1085,7 @@ public StartRecordingResponse startRecording(String sessionId, String recording) * Stop live session recording. * * @param sessionId Live session id. + * @return the response */ public StopRecordingResponse stopRecording(String sessionId) { checkStringNotEmpty(sessionId, "The parameter sessionId should NOT be null or empty string."); @@ -1059,7 +1099,6 @@ public StopRecordingResponse stopRecording(String sessionId) { * Get your live session source info by live session id. * * @param sessionId Live session id. - * * @return Your live session source info */ public GetSessionSourceInfoResponse getSessionSourceInfo(String sessionId) { @@ -1071,12 +1110,33 @@ public GetSessionSourceInfoResponse getSessionSourceInfo(String sessionId) { } /** - * Insert a cue point into your live session by live session id. + * Get your live stream source info by live stream tuple (domain, app, stream). * - * @param sessionId Live session id. - * @param callback Call back method name. - * @param arguments Call back method arguments. + * @param domain live stream play domain + * @param app live stream app + * @param stream live stream name + * @return Live stream source info response + */ + public GetStreamSourceInfoResponse getStreamSourceInfo(String domain, String app, String stream) { + + checkStringNotEmpty(domain, "The parameter domain should NOT be null or empty string."); + checkStringNotEmpty(app, "The parameter app should NOT be null or empty string."); + checkStringNotEmpty(stream, "The parameter stream should NOT be null or empty string."); + + GetStreamSourceInfoRequest request = new GetStreamSourceInfoRequest(); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_DOMAIN, domain, LIVE_APP, app, + LIVE_STREAM, stream); + internalRequest.addParameter(SOURCE_INFO, null); + return invokeHttpClient(internalRequest, GetStreamSourceInfoResponse.class); + } + + /** + * Insert a cue point into your live session by live session id. * + * @param sessionId Live session id. + * @param callback Call back method name. + * @param arguments Call back method arguments. + * @return the response */ public InsertCuePointResponse insertCuePoint(String sessionId, String callback, Map arguments) { InsertCuePointRequest request = new InsertCuePointRequest() @@ -1088,7 +1148,7 @@ public InsertCuePointResponse insertCuePoint(String sessionId, String callback, * Insert a cue point into your live session by live session id. * * @param request The request object containing all parameters for inserting a cue point into session. - * + * @return the response */ public InsertCuePointResponse insertCuePoint(InsertCuePointRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1105,12 +1165,10 @@ public InsertCuePointResponse insertCuePoint(InsertCuePointRequest request) { } - /** * Get your live recording preset by live recording preset name. * * @param recording Live recording preset name. - * * @return Your live recording preset */ public GetRecordingResponse getRecording(String recording) { @@ -1131,6 +1189,23 @@ public ListRecordingsResponse listRecordings() { return invokeHttpClient(internalRequest, ListRecordingsResponse.class); } + /** + *Clip your recording file. + * + * @param The request object containing all params for clipping recording file. + * @return The details of your file clipping task; + */ + public RecordingClipResponse recordingClip(RecordingClipRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getPlayDomain(), "PlayDomain should NOT be empty."); + checkStringNotEmpty(request.getApp(), "App should NOT be empty."); + checkStringNotEmpty(request.getStream(), "Stream should NOT be empty."); + checkStringNotEmpty(request.getSourceFile(), "SourceFile should NOT be empty."); + + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, RECORDING, CLIP); + return invokeHttpClient(internalRequest, RecordingClipResponse.class); + } /** * List all your live notifications. @@ -1146,8 +1221,8 @@ public ListNotificationsResponse listNotifications() { /** * Delete your live notification by live notification name. * - * @param name Live notification name. - * + * @param name Live notification name. + * @return the response */ public DeleteNotificationResponse deleteNotification(String name) { DeleteNotificationRequest request = new DeleteNotificationRequest(); @@ -1159,7 +1234,7 @@ public DeleteNotificationResponse deleteNotification(String name) { * Delete your live notification by live notification name. * * @param request The request object containing all parameters for deleting live notification. - * + * @return the response */ public DeleteNotificationResponse deleteNotification(DeleteNotificationRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1172,8 +1247,7 @@ public DeleteNotificationResponse deleteNotification(DeleteNotificationRequest r /** * Get your live notification by live notification name. * - * @param name Live notification name. - * + * @param name Live notification name. * @return Your live notification. */ public GetNotificationResponse getNotification(String name) { @@ -1186,7 +1260,6 @@ public GetNotificationResponse getNotification(String name) { * Get your live notification by live notification name. * * @param request The request object containing all parameters for getting live notification. - * * @return Your live notification. */ public GetNotificationResponse getNotification(GetNotificationRequest request) { @@ -1200,9 +1273,9 @@ public GetNotificationResponse getNotification(GetNotificationRequest request) { /** * Create a live notification in the live stream service. * - * @param name The name of notification. + * @param name The name of notification. * @param endpoint The address to receive notification message. - * + * @return the response */ public CreateNotificationResponse createNotification(String name, String endpoint) { CreateNotificationRequest request = new CreateNotificationRequest(); @@ -1214,6 +1287,7 @@ public CreateNotificationResponse createNotification(String name, String endpoin * Create a live notification in the live stream service. * * @param request The request object containing all options for creating live notification. + * @return the response */ public CreateNotificationResponse createNotification(CreateNotificationRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1241,8 +1315,7 @@ public ListSecurityPoliciesResponse listSecurityPolicies() { /** * Get your live security policy by live security policy name. * - * @param name Live security policy name. - * + * @param name Live security policy name. * @return Your live security policy. */ public GetSecurityPolicyResponse getSecurityPolicy(String name) { @@ -1255,7 +1328,6 @@ public GetSecurityPolicyResponse getSecurityPolicy(String name) { * Get your live security policy by live security policy name. * * @param request The request object containing all parameters for getting live security policy. - * * @return Your live security policy. */ public GetSecurityPolicyResponse getSecurityPolicy(GetSecurityPolicyRequest request) { @@ -1271,13 +1343,14 @@ public GetSecurityPolicyResponse getSecurityPolicy(GetSecurityPolicyRequest requ /** * Update your live security policy by live security policy name. * - * @param name Live security policy name. - * @param auth Configuration for authentication. - * @param antiLeech Configuration for anti-leech. - * @param encryption Configuration for encryption. + * @param name Live security policy name. + * @param auth Configuration for authentication. + * @param antiLeech Configuration for anti-leech. + * @param encryption Configuration for encryption. + * @return the response */ public UpdateSecurityPolicyResponse updateSecurityPolicy(String name, Auth auth, AntiLeech antiLeech, - Encryption encryption) { + Encryption encryption) { UpdateSecurityPolicyRequest request = new UpdateSecurityPolicyRequest(); request.withName(name).withAuth(auth).withAntiLeech(antiLeech).withEncryption(encryption); return updateSecurityPolicy(request); @@ -1287,7 +1360,8 @@ public UpdateSecurityPolicyResponse updateSecurityPolicy(String name, Auth auth, /** * Update your live security policy by live security policy name. * - * @param request The request object containing all parameters for updating live security policy. + * @param request The request object containing all parameters for updating live security policy. + * @return the response */ public UpdateSecurityPolicyResponse updateSecurityPolicy(UpdateSecurityPolicyRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1301,14 +1375,29 @@ public UpdateSecurityPolicyResponse updateSecurityPolicy(UpdateSecurityPolicyReq } + /** + * Returns the session statistics. + * + * @param sessionId the session id + * @param startDate the start date + * @param endDate the end date + * @param aggregate true if the result should be aggregated + * @return the response + */ public GetSessionStatisticsResponse getSessionStatistics(String sessionId, String startDate, - String endDate, Boolean aggregate) { + String endDate, Boolean aggregate) { GetSessionStatisticsRequest request = new GetSessionStatisticsRequest(); request.withSessionId(sessionId).withStartDate(startDate).withEndDate(endDate).withAggregate(aggregate); return getSessionStatistics(request); } + /** + * Returns the session statistics. + * + * @param request the request + * @return the response + */ public GetSessionStatisticsResponse getSessionStatistics(GetSessionStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); checkStringNotEmpty(request.getSessionId(), "The parameter sessionId should NOT be null or empty string."); @@ -1330,6 +1419,7 @@ public GetSessionStatisticsResponse getSessionStatistics(GetSessionStatisticsReq * Create a domain stream in the live stream service. * * @param request The request object containing all options for creating domain stream + * @return the response */ public CreateStreamResponse createStream(CreateStreamRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1350,6 +1440,7 @@ public CreateStreamResponse createStream(CreateStreamRequest request) { * @param playDomain The domain which this stream belongs to * @param app The app which this stream belongs to, may not exist when create stream * @param pushStream, name of this stream + * @return the response */ public CreateStreamResponse createStream(String playDomain, String app, String pushStream) { CreateStreamRequest request = new CreateStreamRequest(); @@ -1363,6 +1454,7 @@ public CreateStreamResponse createStream(String playDomain, String app, String p * List a domain's streams in the live stream service. * * @param request The request object containing all options for listing domain's streams + * @return the response */ public ListStreamResponse listStream(ListStreamRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1387,10 +1479,28 @@ public ListStreamResponse listStream(ListStreamRequest request) { } + /** + * List streaming streams for requested domain. + * + * @param playDomain The requested domain + * @return streaming streams + */ + public StreamingStreamResponse listOngiongStream(String playDomain) { + checkStringNotEmpty(playDomain, "PlayDomain should NOT be empty."); + + StreamingStreamRequest request = new StreamingStreamRequest(); + request.setPlayDomain(playDomain); + + InternalRequest internalRequest = createRequest(HttpMethodName.GET, + request, LIVE_DOMAIN, request.getPlayDomain(), ONGOING_STREAM); + return invokeHttpClient(internalRequest, StreamingStreamResponse.class); + } + /** * List a domain's streams in the live stream service. * * @param playDomain The requested domain + * @return the response */ public ListStreamResponse listStream(String playDomain) { ListStreamRequest request = new ListStreamRequest(); @@ -1403,6 +1513,7 @@ public ListStreamResponse listStream(String playDomain) { * List a domain's app in the live stream service. * * @param request The request object containing all options for listing domain's app + * @return the response */ public ListDomainAppResponse listDomainApp(ListDomainAppRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1418,6 +1529,7 @@ public ListDomainAppResponse listDomainApp(ListDomainAppRequest request) { * List a domain's streams in the live stream service. * * @param playDomain The requested domain name + * @return the response */ public ListDomainAppResponse listDomainApp(String playDomain) { ListDomainAppRequest request = new ListDomainAppRequest(); @@ -1429,6 +1541,7 @@ public ListDomainAppResponse listDomainApp(String playDomain) { * Get detail of stream in the live stream service. * * @param request The request object containing all options for querying detail of stream + * @return the response */ public GetStreamResponse getStream(GetStreamRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1450,6 +1563,7 @@ public GetStreamResponse getStream(GetStreamRequest request) { * @param domain The requested domain * @param app The requested app * @param stream The requested stream + * @return the response */ public GetStreamResponse getStream(String domain, String app, String stream) { GetStreamRequest request = new GetStreamRequest(); @@ -1458,10 +1572,65 @@ public GetStreamResponse getStream(String domain, String app, String stream) { } + /** + * reset domain's stream in the live stream service. + * + * @param request The request object containing all options for reset a domain's stream + * @return the response + */ + public ResetDomainStreamResponse resetDomainStream(ResetDomainStreamRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + checkStringNotEmpty(request.getApp(), "App should NOT be empty."); + checkStringNotEmpty(request.getStream(), "Stream should NOT be empty."); + + InternalRequest internalRequest = createRequest(HttpMethodName.PUT, + request, LIVE_DOMAIN, request.getDomain(), + LIVE_APP, request.getApp(), + LIVE_STREAM, request.getStream()); + internalRequest.addParameter(RESET, null); + if (request.getResumeTimeInSecond() != null) { + fillRequestPayload(internalRequest, new ResetDomainStreamRequestBody(request.getResumeTimeInSecond())); + } + return invokeHttpClient(internalRequest, ResetDomainStreamResponse.class); + } + + /** + * reset domain's stream in the live stream service. + * + * @param domain The requested domain which the specific stream belongs to + * @param app The requested app which the specific stream belongs to + * @param stream The requested stream to reset + * @return the response + */ + public ResetDomainStreamResponse resetDomainStream(String domain, String app, String stream) { + ResetDomainStreamRequest request = new ResetDomainStreamRequest(); + request.withDomain(domain).withApp(app).withStream(stream); + return resetDomainStream(request); + } + + /** + * reset domain's stream in the live stream service with resume timestamp. + * + * @param domain The requested domain which the specific stream belongs to + * @param app The requested app which the specific stream belongs to + * @param stream The requested stream to reset + * @param resumeTimeInSecond The timestamp to resume stream, timeunit : second + * @return the response + */ + public ResetDomainStreamResponse resetDomainStream(String domain, String app, String stream, + Long resumeTimeInSecond) { + ResetDomainStreamRequest request = new ResetDomainStreamRequest(); + request.withDomain(domain).withApp(app).withStream(stream).withResumeTimeInSecond(resumeTimeInSecond); + return resetDomainStream(request); + } + /** * pause domain's stream in the live stream service. * * @param request The request object containing all options for pause a domain's stream + * @return the response */ public PauseDomainStreamResponse pauseDomainStream(PauseDomainStreamRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1484,6 +1653,7 @@ public PauseDomainStreamResponse pauseDomainStream(PauseDomainStreamRequest requ * @param domain The requested domain which the specific stream belongs to * @param app The requested app which the specific stream belongs to * @param stream The requested stream to pause + * @return the response */ public PauseDomainStreamResponse pauseDomainStream(String domain, String app, String stream) { PauseDomainStreamRequest request = new PauseDomainStreamRequest(); @@ -1495,6 +1665,7 @@ public PauseDomainStreamResponse pauseDomainStream(String domain, String app, St * pause domain's stream in the live stream service. * * @param request The request object containing all options for pause a domain's stream + * @return the response */ public ResumeDomainStreamResponse resumeDomainStream(ResumeDomainStreamRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1517,6 +1688,7 @@ public ResumeDomainStreamResponse resumeDomainStream(ResumeDomainStreamRequest r * @param domain The requested domain which the specific stream belongs to * @param app The requested app which the specific stream belongs to * @param stream The requested stream to resume + * @return the response */ public ResumeDomainStreamResponse resumeDomainStream(String domain, String app, String stream) { ResumeDomainStreamRequest request = new ResumeDomainStreamRequest(); @@ -1524,11 +1696,226 @@ public ResumeDomainStreamResponse resumeDomainStream(String domain, String app, return resumeDomainStream(request); } + /** + * Delete stream in live stream service + * + * @param request The request object contains all info to decide which stream to delete + */ + public void deleteStream(DeleteStreamRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + checkStringNotEmpty(request.getApp(), "App should NOT be empty."); + checkStringNotEmpty(request.getStream(), "Stream should NOT be empty."); + + InternalRequest internalRequest = createRequest(HttpMethodName.DELETE, request, + LIVE_DOMAIN, request.getDomain(), LIVE_APP, request.getApp(), + LIVE_STREAM, request.getStream()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Delete stream in live stream service + * + * @param domain The requested domain which the specific stream belongs to + * @param app The requested app which the specific stream belongs to + * @param stream The requested stream to delete + */ + public void deleteStream(String domain, String app, String stream) { + DeleteStreamRequest request = new DeleteStreamRequest() + .withDomain(domain) + .withApp(app) + .withStream(stream); + deleteStream(request); + } + + /** + * Update stream's presets in the live stream service + * @param request THe request object containing all options for updating presets + */ + public void updateStreamPresets(UpdateStreamPresetsRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + checkStringNotEmpty(request.getApp(), "App should NOT be empty"); + checkStringNotEmpty(request.getStream(), "Stream should NOT be empty."); + // presets can be null for letting stream to use domain's presets, + // so no need to check if presets is null + + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, LIVE_DOMAIN, + request.getDomain(), LIVE_APP, request.getApp(), LIVE_STREAM, request.getStream()); + internalRequest.addParameter("presets", null); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Update stream's presets + * @param domain The requested domain which the specific stream belongs to + * @param app The requested app which the specific stream belongs to + * @param stream The requested stream which need to update the presets + * @param presets The new presets is setting to the specific stream; + * it's a map, and key is line number, and value is preset name + */ + public void updateStreamPresets(String domain, String app, String stream, Map presets) { + UpdateStreamPresetsRequest request = new UpdateStreamPresetsRequest() + .withDomain(domain) + .withApp(app) + .withStream(stream) + .withPresets(presets); + updateStreamPresets(request); + } + + /** + * Update stream recording in the live stream service + * + * @param request The request object containing all options for updating recording + * + */ + public void updateStreamRecording(UpdateStreamRecordingRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + checkStringNotEmpty(request.getApp(), "App should NOT be empty"); + checkStringNotEmpty(request.getStream(), "Stream should NOT be empty."); + // recording can be null for letting stream to use domain's recording, + // so no need to check if recording is null + + InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, + LIVE_DOMAIN, request.getDomain(), LIVE_APP, request.getApp(), + LIVE_STREAM, request.getStream()); + internalRequest.addParameter("recording", request.getRecording()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update stream recording in live stream service + * + * @param domain The requested domain which the specific stream belongs to + * @param app The requested app which the specific stream belongs to + * @param stream The requested stream which need to update the recording + * @param recording The new recording's name + * + */ + public void updateStreamRecording(String domain, String app, String stream, String recording) { + UpdateStreamRecordingRequest request = new UpdateStreamRecordingRequest() + .withDomain(domain) + .withApp(app) + .withStream(stream) + .withRecording(recording); + updateStreamRecording(request); + } + + /** + * Update stream watermarks in live stream service + * @param request The request object containing all options for updating watermark + * + */ + public void updateStreamWatermark(UpdateStreamWatermarkRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + checkStringNotEmpty(request.getApp(), "App should NOT be empty"); + checkStringNotEmpty(request.getStream(), "Stream should NOT be empty."); + + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, LIVE_DOMAIN, + request.getDomain(), LIVE_APP, request.getApp(), LIVE_STREAM, request.getStream()); + internalRequest.addParameter("watermark", null); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update stream watermark in live stream service + * @param domain The requested domain which the specific stream belongs to + * @param app The requested app which the specific stream belongs to + * @param stream The requested stream which need to update the watermark + * @param watermarks object of the new watermark, contains image watermark and timestamp watermark + * + */ + public void updateStreamWatermark(String domain, String app, String stream, Watermarks watermarks) { + UpdateStreamWatermarkRequest request = new UpdateStreamWatermarkRequest() + .withDomain(domain) + .withApp(app) + .withStream(stream) + .withWatermarks(watermarks); + updateStreamWatermark(request); + } + + + /** + * Update stream pullUrl in live stream service + * @param request The request object containing all options for updating pull url + */ + public void updateStreamPullUrl(UpdateStreamPullUrlRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + checkStringNotEmpty(request.getApp(), "App should NOT be empty"); + checkStringNotEmpty(request.getStream(), "Stream should NOT be empty."); + checkStringNotEmpty(request.getPullUrl(), "PullUrl should NOT be empty."); + + InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_DOMAIN, + request.getDomain(), LIVE_APP, request.getApp(), LIVE_STREAM, request.getStream()); + internalRequest.addParameter("pullUrl", request.getPullUrl()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + /** + * Update stream's destination push url + * @param domain The requested domain which the specific stream belongs to + * @param app The requested app which the specific stream belongs to + * @param stream The requested stream which need to update pull url + * @param pullUrl The new pull url is setting to this specific stream + */ + public void updateStreamPullUrl(String domain, String app, String stream, String pullUrl) { + UpdateStreamPullUrlRequest request = new UpdateStreamPullUrlRequest() + .withDomain(domain) + .withApp(app) + .withStream(stream) + .withPullUrl(pullUrl); + updateStreamPullUrl(request); + } + + /** + * Update stream destination push url in live stream service + * @param request The request object containing all options for updating destination push url + */ + public void updateStreamDestinationPushUrl(UpdateStreamDestinationPushUrlRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty."); + checkStringNotEmpty(request.getApp(), "App should NOT be empty"); + checkStringNotEmpty(request.getStream(), "Stream should NOT be empty."); + + InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_DOMAIN, + request.getDomain(), LIVE_APP, request.getApp(), LIVE_STREAM, request.getStream()); + internalRequest.addParameter("destinationPushUrl", request.getDestinationPushUrl()); + invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * + * @param domain The requested domain which the specific stream belongs to + * @param app The requested app which the specific stream belongs to + * @param stream The requested stream which need to update destination push url + * @param destinationPushUrl The new destination push url + */ + public void updateStreamDestinationPushUrl(String domain, String app, String stream, String destinationPushUrl) { + UpdateStreamDestinationPushUrlRequest request = new UpdateStreamDestinationPushUrlRequest() + .withDomain(domain) + .withApp(app) + .withStream(stream) + .withDestinationPushUrl(destinationPushUrl); + updateStreamDestinationPushUrl(request); + } /** * get domain's statistics in the live stream service. * * @param request The request object containing all options for getting domain's statistics + * @return the response */ public GetDomainStatisticsResponse getDomainStatistics(GetDomainStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1552,6 +1939,7 @@ public GetDomainStatisticsResponse getDomainStatistics(GetDomainStatisticsReques * Get domain's statistics in the live stream service. * * @param domain The requested domain + * @return the response */ public GetDomainStatisticsResponse getDomainStatistics(String domain) { GetDomainStatisticsRequest request = new GetDomainStatisticsRequest(); @@ -1564,6 +1952,7 @@ public GetDomainStatisticsResponse getDomainStatistics(String domain) { * get all domains' summary statistics in the live stream service. * * @param request The request object containing all options for getting all domains' summary statistics + * @return the response */ public GetDomainSummaryStatisticsResponse getDomainSummaryStatistics(GetDomainSummaryStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1583,6 +1972,7 @@ public GetDomainSummaryStatisticsResponse getDomainSummaryStatistics(GetDomainSu * * @param startTime start time * @param endTime start time + * @return the response */ public GetDomainSummaryStatisticsResponse getDomainSummaryStatistics(String startTime, String endTime) { GetDomainSummaryStatisticsRequest request = new GetDomainSummaryStatisticsRequest(); @@ -1595,6 +1985,7 @@ public GetDomainSummaryStatisticsResponse getDomainSummaryStatistics(String star * get all domains' total play count statistics in the live stream service. * * @param request The request object containing all options for getting all domains' play count statistics + * @return the response */ public GetAllDomainsPlayCountResponse getAllDomainsPlayCount(GetAllDomainsStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1616,6 +2007,7 @@ public GetAllDomainsPlayCountResponse getAllDomainsPlayCount(GetAllDomainsStatis * get one domain's play count statistics in the live stream service. * * @param request The request object containing all options for getting one domain's play count statistics + * @return the response */ public GetOneDomainPlayCountResponse getOneDomainPlayCount(GetOneDomainStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1639,6 +2031,7 @@ public GetOneDomainPlayCountResponse getOneDomainPlayCount(GetOneDomainStatistic * get all domains' bandwidth statistics in the live stream service. * * @param request The request object containing all options for getting all domains' total bandwidth statistics + * @return the response */ public GetAllDomainsBandwidthResponse getAllDomainsBandwidth(GetAllDomainsStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1660,6 +2053,7 @@ public GetAllDomainsBandwidthResponse getAllDomainsBandwidth(GetAllDomainsStatis * get one domain's bandwidth statistics in the live stream service. * * @param request The request object containing all options for getting one domain's bandwidth statistics + * @return the response */ public GetOneDomainBandwidthResponse getOneDomainBandwidth(GetOneDomainStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1682,6 +2076,7 @@ public GetOneDomainBandwidthResponse getOneDomainBandwidth(GetOneDomainStatistic * get all domains' traffic statistics in the live stream service. * * @param request The request object containing all options for getting all domains' total traffic statistics + * @return the response */ public GetAllDomainsTrafficResponse getAllDomainsTraffic(GetAllDomainsStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1703,6 +2098,7 @@ public GetAllDomainsTrafficResponse getAllDomainsTraffic(GetAllDomainsStatistics * get one domain's traffic statistics in the live stream service. * * @param request The request object containing all options for getting one domain's traffic statistics + * @return the response */ public GetOneDomainTrafficResponse getOneDomainTraffic(GetOneDomainStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1721,10 +2117,59 @@ public GetOneDomainTrafficResponse getOneDomainTraffic(GetOneDomainStatisticsReq return invokeHttpClient(internalRequest, GetOneDomainTrafficResponse.class); } + /** + * get all domains' traffic statistics in the live stream service. + * + * @param request The request object containing all options for getting all domains' total traffic statistics + * @return the response + */ + public GetAllDomainsBandwidthResponseV2 getAllDomainsBandwidthV2(GetAllDomainsStatisticsRequestV2 request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getTimeInterval(), "timeInterval should NOT be null"); + checkStringNotEmpty(request.getStartTime(), "startTime should NOT be null"); + checkStringNotEmpty(request.getEndTime(), "endTime should NOT be null"); + checkNotNull(request.getAllDomain(), "allDomain should NOT be null"); + + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, + STATISTICS, "table", LIVE_DOMAIN, "bandwidth"); + internalRequest.addParameter("timeInterval", request.getTimeInterval()); + internalRequest.addParameter("startTime", request.getStartTime()); + internalRequest.addParameter("endTime", request.getEndTime()); + internalRequest.addParameter("allDomain", request.getAllDomain().toString()); + + return invokeHttpClient(internalRequest, GetAllDomainsBandwidthResponseV2.class); + } + + /** + * get one domain's traffic statistics in the live stream service. + * + * @param request The request object containing all options for getting one domain's traffic statistics + * @return the response + */ + public GetOneDomainBandwidthResponseV2 getOneDomainBandwidthV2(GetOneDomainStatisticsRequestV2 request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getDomain(), "domain should NOT be null"); + checkStringNotEmpty(request.getTimeInterval(), "timeInterval should NOT be null"); + checkStringNotEmpty(request.getStartTime(), "startTime should NOT be null"); + checkStringNotEmpty(request.getEndTime(), "endTime should NOT be null"); + + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, + STATISTICS, "table", LIVE_DOMAIN, "bandwidth"); + internalRequest.addParameter("timeInterval", request.getTimeInterval()); + internalRequest.addParameter("startTime", request.getStartTime()); + internalRequest.addParameter("endTime", request.getEndTime()); + internalRequest.addParameter("domain", request.getDomain()); + + return invokeHttpClient(internalRequest, GetOneDomainBandwidthResponseV2.class); + } + /** * list domain's statistics in the live stream service. * * @param request The request object containing all options for listing domain's traffic statistics + * @return the response */ public ListDomainStatisticsResponse listDomainStatistics(ListDomainStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1753,6 +2198,7 @@ public ListDomainStatisticsResponse listDomainStatistics(ListDomainStatisticsReq * list domain's all streams statistics in the live stream service. * * @param request The request object containing all options for listing domain's all streams traffic statistics + * @return the response */ public ListStreamStatisticsResponse listStreamStatistics(ListStreamStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1791,6 +2237,7 @@ public ListStreamStatisticsResponse listStreamStatistics(ListStreamStatisticsReq * get a domain's all streams statistics in the live stream service. * * @param request The request object containing all options for getting a domain's all streams + * @return the response */ public GetStreamStatisticsResponse getStreamStatistics(GetStreamStatisticsRequest request) { checkNotNull(request, "The parameter request should NOT be null."); @@ -1814,7 +2261,25 @@ public GetStreamStatisticsResponse getStreamStatistics(GetStreamStatisticsReques return invokeHttpClient(internalRequest, GetStreamStatisticsResponse.class); } + public ListRealtimeStreamStatisticsResponse listRealTimeStreamStatistics(String playDomain, String app) { + ListRealtimeStreamStatisticsRequest request = new ListRealtimeStreamStatisticsRequest(); + + request.withPlayDomain(playDomain).withApp(app); + + return listRealTimeStreamStatistics(request); + } + + public ListRealtimeStreamStatisticsResponse listRealTimeStreamStatistics( + ListRealtimeStreamStatisticsRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getPlayDomain(), "playDomain should NOT be empty."); + checkStringNotEmpty(request.getApp(), "App should NOT be empty."); + InternalRequest internalRequest = createRequestV6(HttpMethodName.GET, request, + STATISTICS, REALTIME, LIVE_DOMAIN, request.getPlayDomain(), LIVE_APP, request.getApp()); + + return invokeHttpClient(internalRequest, ListRealtimeStreamStatisticsResponse.class); + } /** * Creates and initializes a new request object for the specified resource. @@ -1823,18 +2288,16 @@ public GetStreamStatisticsResponse getStreamStatistics(GetStreamStatisticsReques *

* Note: The Query parameters in URL should be specified by caller method. *

- * @param httpMethod - * The HTTP method to use when sending the request. - * @param request - * The original request, as created by the user. - * @param pathVariables - * The optional variables in URI path. + * + * @param httpMethod The HTTP method to use when sending the request. + * @param request The original request, as created by the user. + * @param pathVariables The optional variables in URI path. * @return A new request object, populated with endpoint, resource path, - * ready for callers to populate any additional headers or - * parameters, and execute. + * ready for callers to populate any additional headers or + * parameters, and execute. */ private InternalRequest createRequest( - HttpMethodName httpMethod, AbstractBceRequest request, String...pathVariables) { + HttpMethodName httpMethod, AbstractBceRequest request, String... pathVariables) { // build URL paths List pathComponents = new ArrayList(); @@ -1875,4 +2338,31 @@ private InternalRequest fillRequestPayload(InternalRequest internalRequest, Abst return internalRequest; } + + private InternalRequest createRequestV6( + HttpMethodName httpMethod, AbstractBceRequest request, String... pathVariables) { + + // build URL paths + List pathComponents = new ArrayList(); + pathComponents.add(VERSION_V6); + + // append resourceKeys,pathVariables, + // For example:/resourcekey1/resourcekey2/../pathVariable1/pathVariable2 + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + pathComponents.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(getEndpoint(), pathComponents.toArray(new String[pathComponents.size()])); + + // get a InternalRequest instance and set headers + InternalRequest internalRequest = new InternalRequest(httpMethod, uri); + internalRequest.setCredentials(request.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillRequestPayload(internalRequest, request); + } + return internalRequest; + } } \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lss/model/AntiLeech.java b/src/main/java/com/baidubce/services/lss/model/AntiLeech.java old mode 100644 new mode 100755 index f631a0a9..ca1fc07b --- a/src/main/java/com/baidubce/services/lss/model/AntiLeech.java +++ b/src/main/java/com/baidubce/services/lss/model/AntiLeech.java @@ -13,32 +13,69 @@ package com.baidubce.services.lss.model; -public class AntiLeech { +import java.io.Serializable; + +/** + * Reprsents the anti-leech settings. Currently only refer & single ip restriction are supported. + */ +public class AntiLeech implements Serializable { private Refer refer = null; private IP ip = null; + /** + * Returns the refer + * + * @return the refer + */ public Refer getRefer() { return refer; } + /** + * Sets the refer + * + * @param refer the refer + */ public void setRefer(Refer refer) { this.refer = refer; } + /** + * Sets the refer and returns this object. + * + * @param refer the refer + * @return this object + */ public AntiLeech withRefer(Refer refer) { this.refer = refer; return this; } + /** + * Returns the IP + * + * @return the IP + */ public IP getIp() { return ip; } + /** + * Sets the IP. + * + * @param ip the IP + */ public void setIp(IP ip) { this.ip = ip; } + /** + * Sets the IP and returns this object + * + * @param ip the IP + * @return this object + */ public AntiLeech withIp(IP ip) { this.ip = ip; return this; diff --git a/src/main/java/com/baidubce/services/lss/model/Audio.java b/src/main/java/com/baidubce/services/lss/model/Audio.java old mode 100644 new mode 100755 index 22457913..8de415f0 --- a/src/main/java/com/baidubce/services/lss/model/Audio.java +++ b/src/main/java/com/baidubce/services/lss/model/Audio.java @@ -13,56 +13,97 @@ package com.baidubce.services.lss.model; -public class Audio { - private Integer bitRateInBps = null; +import java.io.Serializable; + +public class Audio implements Serializable { + private Integer bitRateInBps = null; private Integer sampleRateInHz = null; - private Integer channels = null; + private Integer channels = null; /** - * 音频目标码率 + * Returns the audio bit rate + * + * @return the audio bit rate **/ public Integer getBitRateInBps() { return bitRateInBps; } + /** + * Sets the audio bit rate. + * + * @param bitRateInBps the audio bit rate + */ public void setBitRateInBps(Integer bitRateInBps) { this.bitRateInBps = bitRateInBps; } + /** + * Sets the audio bit rate and returns this object. + * + * @param bitRateInBps the audio bit rate + * @return this object + */ public Audio withBitRateInBps(Integer bitRateInBps) { this.bitRateInBps = bitRateInBps; return this; } /** - * 音频采样率 + * Returns the audio sample rate. + * + * @return the audio sample rate **/ public Integer getSampleRateInHz() { return sampleRateInHz; } + /** + * Sets the audio sample rate + * + * @param sampleRateInHz the audio sample rate + */ public void setSampleRateInHz(Integer sampleRateInHz) { this.sampleRateInHz = sampleRateInHz; } + /** + * Sets the audio sample rate and returns this object + * + * @param sampleRateInHz the audio sample rate + * @return this object + */ public Audio withSampleRateInHz(Integer sampleRateInHz) { this.sampleRateInHz = sampleRateInHz; return this; } /** - * 音频声道数目 + * Returns the number of audio channels. + * + * @return the number of audio channels **/ public Integer getChannels() { return channels; } + /** + * Sets the number of audio channels. + * + * @param channels the number of audio channels + */ public void setChannels(Integer channels) { this.channels = channels; } + /** + * Sets the number of audio channels and returns this object. + * + * @param channels the number of audio channels + * @return this object + */ public Audio withChannels(Integer channels) { this.channels = channels; return this; diff --git a/src/main/java/com/baidubce/services/lss/model/Auth.java b/src/main/java/com/baidubce/services/lss/model/Auth.java old mode 100644 new mode 100755 index d3db94be..d6714d23 --- a/src/main/java/com/baidubce/services/lss/model/Auth.java +++ b/src/main/java/com/baidubce/services/lss/model/Auth.java @@ -13,32 +13,67 @@ package com.baidubce.services.lss.model; +/** + * Represents the authentication settings. + */ public class Auth { private Boolean push = null; private Boolean play = null; + /** + * Returns true if authentication is required before push. + * + * @return true if authentication is required before push + */ public Boolean getPush() { return push; } + /** + * Sets to true if authentication is required before push + * + * @param push true if authentication is required before push + */ public void setPush(Boolean push) { this.push = push; } + /** + * Sets to true if authentication is required before push + * + * @param push true if authentication is required before push + * @return this object + */ public Auth withPush(Boolean push) { this.push = push; return this; } + /** + * Returns true if authentication is required before play + * + * @return true if authentication is required before play + */ public Boolean getPlay() { return play; } + /** + * Sets to true if authentication is required before play + * + * @param play true if authentication is required before play + */ public void setPlay(Boolean play) { this.play = play; } + /** + * Sets to true if authentication is required before play + * + * @param play true if authentication is required before play + * @return this object + */ public Auth withPlay(Boolean play) { this.play = play; return this; diff --git a/src/main/java/com/baidubce/services/lss/model/AuthInfo.java b/src/main/java/com/baidubce/services/lss/model/AuthInfo.java old mode 100644 new mode 100755 index 683d5a19..b26c1383 --- a/src/main/java/com/baidubce/services/lss/model/AuthInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/AuthInfo.java @@ -13,47 +13,100 @@ package com.baidubce.services.lss.model; -public class AuthInfo { +import java.io.Serializable; + +/** + * Represents the authentication settings. + */ +public class AuthInfo implements Serializable { private Boolean push = null; private Boolean play = null; private String key = null; + /** + * Returns true if authentication is required before push. + * + * @return true if authentication is required before push + */ public Boolean getPush() { return push; } + /** + * Sets to true if authentication is required before push + * + * @param push true if authentication is required before push + */ public void setPush(Boolean push) { this.push = push; } + /** + * Sets to true if authentication is required before push + * + * @param push true if authentication is required before push + * @return this object + */ public AuthInfo withPush(Boolean push) { this.push = push; return this; } + /** + * Returns true if authentication is required before play + * + * @return true if authentication is required before play + */ public Boolean getPlay() { return play; } + /** + * Sets to true if authentication is required before play + * + * @param play true if authentication is required before play + */ public void setPlay(Boolean play) { this.play = play; } + /** + * Sets to true if authentication is required before play + * + * @param play true if authentication is required before play + * @return this object + */ public AuthInfo withPlay(Boolean play) { this.play = play; return this; } + /** + * Returns the authentication key. + * + * @return the authentication key + */ public String getKey() { return key; } + /** + * Sets the authentication key. + * + * @param key the authentication key + */ public void setKey(String key) { this.key = key; } + /** + * Sets the authentication key. + * + * @param key the authentication key + * @return this object + */ public AuthInfo withKey(String key) { this.key = key; return this; diff --git a/src/main/java/com/baidubce/services/lss/model/Bos.java b/src/main/java/com/baidubce/services/lss/model/Bos.java old mode 100644 new mode 100755 index f6032c4b..8db43779 --- a/src/main/java/com/baidubce/services/lss/model/Bos.java +++ b/src/main/java/com/baidubce/services/lss/model/Bos.java @@ -13,32 +13,69 @@ package com.baidubce.services.lss.model; -public class Bos { +import java.io.Serializable; + +/** + * Represents the BOS information + */ +public class Bos implements Serializable { private String bucket = null; private String region = null; + /** + * Returns the bucket name. + * + * @return the bucket name + */ public String getBucket() { return bucket; } + /** + * Sets the bucket name. + * + * @param bucket the bucket name + */ public void setBucket(String bucket) { this.bucket = bucket; } + /** + * Sets the bucket name. + * + * @param bucket the bucket name + * @return this object + */ public Bos withBucket(String bucket) { this.bucket = bucket; return this; } + /** + * Returns the region ID. + * + * @return the region ID + */ public String getRegion() { return region; } + /** + * Sets the region ID. + * + * @param region the region ID + */ public void setRegion(String region) { this.region = region; } + /** + * Sets the region ID + * + * @param region the region ID + * @return this object + */ public Bos withRegion(String region) { this.region = region; return this; diff --git a/src/main/java/com/baidubce/services/lss/model/Capture.java b/src/main/java/com/baidubce/services/lss/model/Capture.java index 009f1d52..c6db9f71 100644 --- a/src/main/java/com/baidubce/services/lss/model/Capture.java +++ b/src/main/java/com/baidubce/services/lss/model/Capture.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class Capture { +import java.io.Serializable; + +public class Capture implements Serializable { private String mode = null; private Integer startTimeInSecond = null; diff --git a/src/main/java/com/baidubce/services/lss/model/CodecOptions.java b/src/main/java/com/baidubce/services/lss/model/CodecOptions.java old mode 100644 new mode 100755 index 7de98260..927e8520 --- a/src/main/java/com/baidubce/services/lss/model/CodecOptions.java +++ b/src/main/java/com/baidubce/services/lss/model/CodecOptions.java @@ -13,20 +13,35 @@ package com.baidubce.services.lss.model; -public class CodecOptions { +import java.io.Serializable; + +public class CodecOptions implements Serializable { private String profile = null; /** - * baseline, main, high + * Returns the profile. + * + * @return the profile **/ public String getProfile() { return profile; } + /** + * Sets the profile + * + * @param profile the profile + */ public void setProfile(String profile) { this.profile = profile; } + /** + * Sets the profile and returns this object. + * + * @param profile the profile + * @return this object + */ public CodecOptions withProfile(String profile) { this.profile = profile; return this; diff --git a/src/main/java/com/baidubce/services/lss/model/CreatePresetRequest.java b/src/main/java/com/baidubce/services/lss/model/CreatePresetRequest.java old mode 100644 new mode 100755 index 6cbe3b31..e23cf790 --- a/src/main/java/com/baidubce/services/lss/model/CreatePresetRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/CreatePresetRequest.java @@ -18,7 +18,7 @@ public class CreatePresetRequest extends AbstractBceRequest { - private String name = null; + private String name = null; private String description = null; @@ -37,119 +37,212 @@ public class CreatePresetRequest extends AbstractBceRequest { private Watermarks watermarks = null; /** - * 直播模板名称 + * Returns the name of the preset. + * + * @return the name of the preset **/ public String getName() { return name; } + /** + * Sets the name of the preset. + * + * @param name the name of the preset + */ public void setName(String name) { this.name = name; } + /** + * Sets the name of the preset and returns this object. + * + * @param name the name of the preset. + * @return this object + */ public CreatePresetRequest withName(String name) { this.name = name; return this; } /** - * 模板的描述 + * Returns the description of the preset. + * + * @return the description of the preset **/ public String getDescription() { return description; } + /** + * Sets the description of the preset. + * + * @param description the description of the preset + */ public void setDescription(String description) { this.description = description; } + /** + * Sets the description of the preset and returns this object. + * + * @param description the description of the preset. + * @return this object + */ public CreatePresetRequest withDescription(String description) { this.description = description; return this; } /** - * 是否仅进行直播转发,保持输入流分辨率与码率不变 + * Returns true if forward only. + * + * @return true if forward only. **/ public Boolean getForwardOnly() { return forwardOnly; } + /** + * Sets the forward option + * + * @param forwardOnly true if forward only + */ public void setForwardOnly(Boolean forwardOnly) { this.forwardOnly = forwardOnly; } + /** + * Sets the forward option and returns this object. + * + * @param forwardOnly true if forward only + * @return this object + */ public CreatePresetRequest withForwardOnly(Boolean forwardOnly) { this.forwardOnly = forwardOnly; return this; } /** - * 音频输出信息的集合 + * Returns the audio settings. + * + * @return the audio settings **/ public Audio getAudio() { return audio; } + /** + * Sets the audio settings. + * + * @param audio the audio settings + */ public void setAudio(Audio audio) { this.audio = audio; } + /** + * Sets the audio settings and returns this object. + * + * @param audio the audio settings + * @return this object + */ public CreatePresetRequest withAudio(Audio audio) { this.audio = audio; return this; } /** - * 视频输出信息的集合 + * Returns the video settings. + * + * @return the video settings **/ public Video getVideo() { return video; } + /** + * Sets the video settings. + * + * @param video the video settings + */ public void setVideo(Video video) { this.video = video; } + /** + * Sets the video settings and returns this object. + * + * @param video the video settings + * @return this object + */ public CreatePresetRequest withVideo(Video video) { this.video = video; return this; } /** - * hls输出参数 + * Returns the HLS settings. + * + * @return the HLS settings **/ public Hls getHls() { return hls; } + /** + * Sets the HLS settings. + * + * @param hls the HLS setting + */ public void setHls(Hls hls) { this.hls = hls; } + /** + * Sets the HLS settings and returns this object. + * + * @param hls the HLS settings + * @return this object + */ public CreatePresetRequest withHls(Hls hls) { this.hls = hls; return this; } /** - * rtmp参数 + * Returns the RTMP settings. + * + * @return the RTMP settings **/ public Rtmp getRtmp() { return rtmp; } + /** + * Sets the RTMP settings. + * + * @param rtmp the RTMP settings + */ public void setRtmp(Rtmp rtmp) { this.rtmp = rtmp; } + /** + * Sets the RTMP settings and returns this object. + * + * @param rtmp the RTMP settings + * @return this object + */ public CreatePresetRequest withRtmp(Rtmp rtmp) { this.rtmp = rtmp; return this; } /** - * 直播水印相关参数 + * Returns the watermark settings. + * + * @return the watermark settings **/ public Watermarks getWatermarks() { return watermarks; diff --git a/src/main/java/com/baidubce/services/lss/model/CreateStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/CreateStreamResponse.java index dd918155..c7761a56 100644 --- a/src/main/java/com/baidubce/services/lss/model/CreateStreamResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/CreateStreamResponse.java @@ -1,3 +1,15 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ package com.baidubce.services.lss.model; import com.baidubce.model.AbstractBceResponse; @@ -6,7 +18,7 @@ import java.util.Map; /** - * Created by wuyafei on 16/10/14. + * Represent the response for creating a stream */ public class CreateStreamResponse extends AbstractBceResponse { @@ -44,142 +56,296 @@ public class CreateStreamResponse extends AbstractBceResponse { private LivePlay play = null; + private String destinationPushUrl = null; + + /** + * Returns sessionId + * @return sessionId + */ public String getSessionId() { return sessionId; } + /** + * Sets sessionId + * @param sessionId + */ public void setSessionId(String sessionId) { this.sessionId = sessionId; } + /** + * Returns playDomain + * @return playDomain + */ public String getPlayDomain() { return playDomain; } + /** + * Sets playDomain + * @param playDomain + */ public void setPlayDomain(String playDomain) { this.playDomain = playDomain; } + /** + * Returns app + * @return app + */ public String getApp() { return app; } + /** + * Sets app + * @param app + */ public void setApp(String app) { this.app = app; } + /** + * Returns scene + * @return scene + */ public String getScene() { return scene; } - public void setScene() { + /** + * Sets scene + * @param scene + */ + public void setScene(String scene) { this.scene = scene; } + /** + * Returns description + * @return description + */ public String getDescription() { return description; } + /** + * Sets description + * @param description + */ public void setDescription(String description) { this.description = description; } + /** + * Returns preset + * @return preset + */ public String getPreset() { return preset; } + /** + * Sets presets + * @param preset + */ public void setPreset(String preset) { this.preset = preset; } + /** + * Returns createTime + * @return createTime + */ public String getCreateTime() { return createTime; } + /** + * Sets createTime + * @param createTime + */ public void setCreateTime(String createTime) { this.createTime = createTime; } + /** + * Returns status + * @return status + */ public String getStatus() { return status; } + /** + * Sets status + * @param status + */ public void setStatus(String status) { this.status = status; } + /** + * Returns notification + * @return notification + */ public String getNotification() { return notification; } + /** + * Sets notification + * @param notification + */ public void setNotification(String notification) { this.notification = notification; } + /** + * Returns securityPolicy + * @return securityPolicy + */ public String getSecurityPolicy() { return securityPolicy; } + /** + * Sets securityPolicy + * @param securityPolicy + */ public void setSecurityPolicy(String securityPolicy) { this.securityPolicy = securityPolicy; } + /** + * Returns recording + * @return recording + */ public String getRecording() { return recording; } + /** + * Sets recording + * @param recording + */ public void setRecording(String recording) { this.recording = recording; } + /** + * Returns thumbnail + * @return thumbnail + */ public String getThumbnail() { return thumbnail; } + /** + * Sets thumbnail + * @param thumbnail + */ public void setThumbnail(String thumbnail) { this.thumbnail = thumbnail; } + /** + * Returns thumbnails + * @return thumbnails + */ public List getThumbnails() { return thumbnails; } + /** + * Sets thumbnails + * @param thumbnails + */ public void setThumbnails(List thumbnails) { this.thumbnails = thumbnails; } + /** + * Returns watermarks + * @return watermarks + */ public Watermarks getWatermarks() { return watermarks; } + /** + * Sets watermarks + * @param watermarks + */ public void setWatermarks(Watermarks watermarks) { this.watermarks = watermarks; } + /** + * Returns publish + * @return publish + */ public LivePublish getPublish() { return publish; } + /** + * Sets publish + * @param publish + */ public void setPublish(LivePublish publish) { this.publish = publish; } + /** + * Returns play + * @return play + */ public LivePlay getPlay() { return play; } + /** + * Sets play + * @param play + */ public void setPlay(LivePlay play) { this.play = play; } + /** + * Returns presets + * @return presets + */ public Map getPresets() { return presets; } + /** + * Sets presets + * @param presets + */ public void setPresets(Map presets) { this.presets = presets; } + /** + * Returns destinationPushUrl + * @return destinationPushUrl + */ + public String getDestinationPushUrl() { + return destinationPushUrl; + } + + /** + * Sets destinationPushUrl + * @param destinationPushUrl + */ + public void setDestinationPushUrl(String destinationPushUrl) { + this.destinationPushUrl = destinationPushUrl; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); @@ -201,6 +367,7 @@ public String toString() { sb.append(" scene: ").append(scene).append("\n"); sb.append(" publish: ").append(publish).append("\n"); sb.append(" play: ").append(play).append("\n"); + sb.append(" destinationPushUrl: ").append(destinationPushUrl).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/lss/model/DeleteStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/DeleteStreamRequest.java new file mode 100644 index 00000000..a6ca22c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/DeleteStreamRequest.java @@ -0,0 +1,122 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent request for deleting a stream + */ +public class DeleteStreamRequest extends AbstractBceRequest { + + private String domain; + + private String app; + + private String stream; + + /** + * Returns domain + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * Sets domain + * @param domain + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * Sets domain + * @return returns this object for method chaining + */ + public DeleteStreamRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * Returns app + * @return app + */ + public String getApp() { + return app; + } + + /** + * Sets app + * @param app + */ + public void setApp(String app) { + this.app = app; + } + + /** + * Sets app + * @return returns this object for method chaining + */ + public DeleteStreamRequest withApp(String app) { + this.app = app; + return this; + } + + /** + * Returns stream + * @return stream + */ + public String getStream() { + return stream; + } + + /** + * Sets stream + * @param stream + */ + public void setStream(String stream) { + this.stream = stream; + } + + /** + * Sets stream + * @return returns this object for method chaining + */ + public DeleteStreamRequest withStream(String stream) { + this.stream = stream; + return this; + } + + /** + * Sets credentials + * @return returns this object for method chaining + */ + @Override + public DeleteStreamRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "DeleteStreamRequest{" + + "domain='" + domain + '\'' + + ", app='" + app + '\'' + + ", stream='" + stream + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/Encryption.java b/src/main/java/com/baidubce/services/lss/model/Encryption.java index 144588dc..a02967fe 100644 --- a/src/main/java/com/baidubce/services/lss/model/Encryption.java +++ b/src/main/java/com/baidubce/services/lss/model/Encryption.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class Encryption { +import java.io.Serializable; + +public class Encryption implements Serializable { private HlsEncryption hls = null; public HlsEncryption getHls() { diff --git a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsBandwidthResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsBandwidthResponse.java index da51a78a..93d0ff8b 100644 --- a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsBandwidthResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsBandwidthResponse.java @@ -2,6 +2,7 @@ import com.baidubce.model.AbstractBceResponse; +import java.io.Serializable; import java.util.List; /** @@ -60,7 +61,7 @@ public String toString() { return sb.toString(); } - public static class BandwidthStatistics { + public static class BandwidthStatistics implements Serializable { private String timestamp = null; diff --git a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsBandwidthResponseV2.java b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsBandwidthResponseV2.java new file mode 100644 index 00000000..335084ad --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsBandwidthResponseV2.java @@ -0,0 +1,104 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.io.Serializable; +import java.util.List; + +public class GetAllDomainsBandwidthResponseV2 extends AbstractBceResponse { + + private String startTime = null; + + private String endTime = null; + + private String allDomain = null; + + private String timeInterval = null; + + private List statistics = null; + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getTimeInterval() { + return timeInterval; + } + + public void setTimeInterval(String timeInterval) { + this.timeInterval = timeInterval; + } + + public String getAllDomain() { + return allDomain; + } + + public void setAllDomain(String allDomain) { + this.allDomain = allDomain; + } + + public List getStatistics() { + return statistics; + } + + public void setStatistics(List statistics) { + this.statistics = statistics; + } + + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetAllDomainsTrafficResponseV2 {\n"); + sb.append(" allDomain: ").append(allDomain).append("\n"); + sb.append(" startTime: ").append(startTime).append("\n"); + sb.append(" endTime: ").append(endTime).append("\n"); + sb.append(" timeInterval: ").append(timeInterval).append("\n"); + sb.append(" statistics: ").append(statistics).append("\n"); + sb.append("}\n"); + return sb.toString(); + } + + public static class BandwidthStatistics implements Serializable { + + private String timestamp = null; + + private Long downstreamInByte = null; + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public Long getDownstreamInByte() { + return downstreamInByte; + } + + public void setDownstreamInByte(Long downstreamInByte) { + this.downstreamInByte = downstreamInByte; + } + + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetOneDomainTrafficResponseV2 {\n"); + sb.append(" timestamp: ").append(timestamp).append("\n"); + sb.append(" downstreamInByte: ").append(downstreamInByte).append("\n"); + sb.append("}\n"); + return sb.toString(); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsPlayCountResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsPlayCountResponse.java index d5caef83..afdbc2b1 100644 --- a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsPlayCountResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsPlayCountResponse.java @@ -2,6 +2,7 @@ import com.baidubce.model.AbstractBceResponse; +import java.io.Serializable; import java.util.List; /** @@ -82,7 +83,7 @@ public String toString() { return sb.toString(); } - public static class PlayCountStatistics { + public static class PlayCountStatistics implements Serializable { private String timestamp = null; private Long playCount = null; diff --git a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsStatisticsRequestV2.java b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsStatisticsRequestV2.java new file mode 100644 index 00000000..a5610c20 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsStatisticsRequestV2.java @@ -0,0 +1,85 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class GetAllDomainsStatisticsRequestV2 extends AbstractBceRequest { + + private String startTime = null; + + private String endTime = null; + + private String timeInterval = null; + + private Boolean allDomain = null; + + @Override + public GetAllDomainsStatisticsRequestV2 withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public GetAllDomainsStatisticsRequestV2 withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public GetAllDomainsStatisticsRequestV2 withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + public String getTimeInterval() { + return timeInterval; + } + + public void setTimeInterval(String timeInterval) { + this.timeInterval = timeInterval; + } + + public GetAllDomainsStatisticsRequestV2 withTimeInterval(String timeInterval) { + this.timeInterval = timeInterval; + return this; + } + + public Boolean getAllDomain() { + return allDomain; + } + + public void setAllDomain(Boolean allDomain) { + this.allDomain = allDomain; + } + + public GetAllDomainsStatisticsRequestV2 withAllDomain(Boolean allDomain) { + this.allDomain = allDomain; + return this; + } + + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetAllDomainsStatisticsRequestV2 {\n"); + sb.append(" app: ").append(startTime).append("\n"); + sb.append(" endTime: ").append(endTime).append("\n"); + sb.append(" timeInterval: ").append(timeInterval).append("\n"); + sb.append(" allDomain: ").append(allDomain).append("\n"); + sb.append("}\n"); + return sb.toString(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsTrafficResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsTrafficResponse.java index ad44cd00..2351a008 100644 --- a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsTrafficResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsTrafficResponse.java @@ -2,6 +2,7 @@ import com.baidubce.model.AbstractBceResponse; +import java.io.Serializable; import java.util.List; /** @@ -60,7 +61,7 @@ public String toString() { return sb.toString(); } - public static class TrafficStatistics { + public static class TrafficStatistics implements Serializable { private String timestamp = null; diff --git a/src/main/java/com/baidubce/services/lss/model/GetOneDomainBandwidthResponseV2.java b/src/main/java/com/baidubce/services/lss/model/GetOneDomainBandwidthResponseV2.java new file mode 100644 index 00000000..e03b98e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetOneDomainBandwidthResponseV2.java @@ -0,0 +1,27 @@ +package com.baidubce.services.lss.model; + +public class GetOneDomainBandwidthResponseV2 extends GetAllDomainsBandwidthResponseV2 { + + private String domain = null; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetOneDomainTrafficResponseV2 {\n"); + sb.append(" domain: ").append(domain).append("\n"); + sb.append(" startTime: ").append(this.getStartTime()).append("\n"); + sb.append(" endTime: ").append(this.getEndTime()).append("\n"); + sb.append(" timeInterval: ").append(this.getTimeInterval()).append("\n"); + sb.append(" statistics: ").append(this.getStatistics()).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lss/model/GetOneDomainStatisticsRequestV2.java b/src/main/java/com/baidubce/services/lss/model/GetOneDomainStatisticsRequestV2.java new file mode 100644 index 00000000..19422a39 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetOneDomainStatisticsRequestV2.java @@ -0,0 +1,85 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class GetOneDomainStatisticsRequestV2 extends AbstractBceRequest { + + private String domain = null; + + private String startTime = null; + + private String endTime = null; + + private String timeInterval = null; + + @Override + public GetOneDomainStatisticsRequestV2 withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public GetOneDomainStatisticsRequestV2 withDomain(String domain) { + this.domain = domain; + return this; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public GetOneDomainStatisticsRequestV2 withStartTime(String startTime) { + this.startTime = startTime; + return this; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public GetOneDomainStatisticsRequestV2 withEndTime(String endTime) { + this.endTime = endTime; + return this; + } + + public String getTimeInterval() { + return timeInterval; + } + + public void setTimeInterval(String interval) { + this.timeInterval = interval; + } + + public GetOneDomainStatisticsRequestV2 withTimeInterval(String interval) { + this.timeInterval = interval; + return this; + } + + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetOneDomainStatisticsRequestV2 {\n"); + sb.append(" domain: ").append(domain).append("\n"); + sb.append(" startTime: ").append(startTime).append("\n"); + sb.append(" endTime: ").append(endTime).append("\n"); + sb.append(" timeInterval: ").append(timeInterval).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} + diff --git a/src/main/java/com/baidubce/services/lss/model/GetStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/GetStreamResponse.java index 999cddeb..b3a43ed4 100644 --- a/src/main/java/com/baidubce/services/lss/model/GetStreamResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetStreamResponse.java @@ -1,14 +1,28 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ package com.baidubce.services.lss.model; import com.baidubce.model.AbstractBceResponse; +import java.io.Serializable; import java.util.List; import java.util.Map; /** - * Created by wuyafei on 16/10/14. + * Represents response of querying a stream */ public class GetStreamResponse extends AbstractBceResponse { + private String sessionId = null; private String playDomain = null; @@ -43,189 +57,386 @@ public class GetStreamResponse extends AbstractBceResponse { private LivePlay play = null; - private String streamStatus = null; + private String streamingStatus = null; private StreamingStatistics statistics = null; private String audit = null; + private String destinationPushUrl = null; + + /** + * Returns sessionId + * @return sessionId + */ public String getSessionId() { return sessionId; } + /** + * Sets sessionId + * @param sessionId + */ public void setSessionId(String sessionId) { this.sessionId = sessionId; } + /** + * Returns playDomain + * @return playDomain + */ public String getPlayDomain() { return playDomain; } + /** + * Sets playDomain + * @param playDomain + */ public void setPlayDomain(String playDomain) { this.playDomain = playDomain; } + /** + * Returns app + * @return app + */ public String getApp() { return app; } + /** + * Sets app + * @param app + */ public void setApp(String app) { this.app = app; } + /** + * Returns scent + * @return scent + */ public String getScene() { return scene; } + /** + * Sets scene + * @param scene + */ public void setScene(String scene) { this.scene = scene; } + /** + * Returns description + * @return description + */ public String getDescription() { return description; } + /** + * Sets description + * @param description + */ public void setDescription(String description) { this.description = description; } + /** + * Returns preset + * @return preset + */ public String getPreset() { return preset; } + /** + * Sets preset + * @param preset + */ public void setPreset(String preset) { this.preset = preset; } + /** + * Returns createTime + * @return createTime + */ public String getCreateTime() { return createTime; } + /** + * Sets createTime + * @param createTime + */ public void setCreateTime(String createTime) { this.createTime = createTime; } + /** + * Returns status + * @return status + */ public String getStatus() { return status; } + /** + * Sets status + * @param status + */ public void setStatus(String status) { this.status = status; } + /** + * Returns notification + * @return notification + */ public String getNotification() { return notification; } + /** + * Sets notification + * @param notification + */ public void setNotification(String notification) { this.notification = notification; } + /** + * Returns securityPolicy + * @return securityPolicy + */ public String getSecurityPolicy() { return securityPolicy; } + /** + * Sets securityPolicy + * @param securityPolicy + */ public void setSecurityPolicy(String securityPolicy) { this.securityPolicy = securityPolicy; } + /** + * Returns recording + * @return recording + */ public String getRecording() { return recording; } + /** + * Sets recording + * @param recording + */ public void setRecording(String recording) { this.recording = recording; } + /** + * Returns thumbnail + * @return thumbnail + */ public String getThumbnail() { return thumbnail; } + /** + * Sets thumbnail + * @param thumbnail + */ public void setThumbnail(String thumbnail) { this.thumbnail = thumbnail; } + /** + * Returns thumbnails + * @return thumbnails + */ public List getThumbnails() { return thumbnails; } + /** + * Sets thumbnails + * @param thumbnails + */ public void setThumbnails(List thumbnails) { this.thumbnails = thumbnails; } + /** + * Returns watermarks + * @return watermarks + */ public Watermarks getWatermarks() { return watermarks; } + /** + * Sets watermarks + * @param watermarks + */ public void setWatermarks(Watermarks watermarks) { this.watermarks = watermarks; } + /** + * Returns publish + * @return publish + */ public LivePublish getPublish() { return publish; } + /** + * Sets publish + * @param publish + */ public void setPublish(LivePublish publish) { this.publish = publish; } + /** + * Returns play + * @return play + */ public LivePlay getPlay() { return play; } + /** + * Sets play + * @param play + */ public void setPlay(LivePlay play) { this.play = play; } + /** + * Returns presets + * @return presets + */ public Map getPresets() { return presets; } + /** + * Sets presets + * @param presets + */ public void setPresets(Map presets) { this.presets = presets; } - public String getStreamStatus() { - return streamStatus; + /** + * Returns streamingStatus + * @return streamingStatus + */ + public String getStreamingStatus() { + return streamingStatus; } - public void setStreamStatus(String streamStatus) { - this.streamStatus = streamStatus; + /** + * Sets streamingStatus + * @param streamingStatus + */ + public void setStreamingStatus(String streamingStatus) { + this.streamingStatus = streamingStatus; } + /** + * Returns statistics + * @return statistics + */ public StreamingStatistics getStatistics() { return statistics; } + /** + * Sets statistics + * @param statistics + */ public void setStatistics(StreamingStatistics statistics) { this.statistics = statistics; } + /** + * Returns audit + * @return audit + */ public String getAudit() { return audit; } + /** + * Sets audit + * @param audit + */ public void setAudit(String audit) { this.audit = audit; } - public static class StreamingStatistics { + /** + * Returns destinationPushUrl + * @return destinationPushUrl + */ + public String getDestinationPushUrl() { + return destinationPushUrl; + } + + /** + * Sets destinationPushUrl + * @param destinationPushUrl + */ + public void setDestinationPushUrl(String destinationPushUrl) { + this.destinationPushUrl = destinationPushUrl; + } + + /** + * Represents statistics of a streaming stream + */ + public static class StreamingStatistics implements Serializable { private Long bandwidthInBps = null; private Long playCount = null; + /** + * Returns bandwidthInBps + * @return bandwidthInBps + */ public Long getBandwidthInBps() { return bandwidthInBps; } + /** + * Sets bandwidthInBps + * @param bandwidthInBps + */ public void setBandwidthInBps(Long bandwidthInBps) { this.bandwidthInBps = bandwidthInBps; } + /** + * Returns playCount + * @return playCount + */ public Long getPlayCount() { return playCount; } + /** + * Sets playCount + * @param playCount + */ public void setPlayCount(Long playCount) { this.playCount = playCount; } @@ -252,7 +463,7 @@ public String toString() { sb.append(" presets: ").append(presets).append("\n"); sb.append(" createTime: ").append(createTime).append("\n"); sb.append(" status: ").append(status).append("\n"); - sb.append(" streamStatus: ").append(streamStatus).append("\n"); + sb.append(" streamingStatus: ").append(streamingStatus).append("\n"); sb.append(" notification: ").append(notification).append("\n"); sb.append(" securityPolicy: ").append(securityPolicy).append("\n"); sb.append(" audit: ").append(audit).append("\n"); @@ -264,6 +475,7 @@ public String toString() { sb.append(" publish: ").append(publish).append("\n"); sb.append(" play: ").append(play).append("\n"); sb.append(" StreamingStatistics ").append(statistics).append("\n"); + sb.append(" destinationPushUrl").append(destinationPushUrl).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/lss/model/GetStreamSourceInfoRequest.java b/src/main/java/com/baidubce/services/lss/model/GetStreamSourceInfoRequest.java new file mode 100644 index 00000000..1605823c --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetStreamSourceInfoRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request used to get stream source information. + */ +public class GetStreamSourceInfoRequest extends AbstractBceRequest { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetStreamSourceInfoRequest {\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/GetStreamSourceInfoResponse.java b/src/main/java/com/baidubce/services/lss/model/GetStreamSourceInfoResponse.java new file mode 100644 index 00000000..826ad2b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetStreamSourceInfoResponse.java @@ -0,0 +1,175 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.vodpro.model.common.UtcTime; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.Date; + +/** + * The response represents stream source info. + */ +@Data +public class GetStreamSourceInfoResponse extends AbstractBceResponse { + + /** + * global unique session id + */ + private String sessionId; + + /** + * live stream play domain + */ + private String playDomain; + + /** + * live stream app + */ + private String app; + + /** + * live stream name + */ + private String stream; + + /** + * ip of CDN server that push the stream to media server + */ + private String sourceIP; + + /** + * client ip that push the stream + */ + private String publishIP; + + /** + * quality of the stream, value between [0, 100], high score means good quality + */ + private Integer score; + + /** + * timestamp of this stream info + */ + @UtcTime + private Date captureTime; + + /** + * total input bit rate + */ + private Integer inputBitRateInBps; + + /** + * video info part + */ + private Video video; + + /** + * audio info part + */ + private Audio audio; + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetRecordingResponse {\n"); + sb.append(" sessionId: ").append(sessionId).append("\n"); + sb.append(" sourceIp: ").append(sourceIP).append("\n"); + sb.append(" publishIp: ").append(publishIP).append("\n"); + sb.append(" score: ").append(score).append("\n"); + sb.append(" captureTime: ").append(captureTime).append("\n"); + sb.append(" inputBitRateInBps: ").append(inputBitRateInBps).append("\n"); + sb.append(" video: {\n"); + sb.append(" codec: ").append(video.getCodec()).append("\n"); + sb.append(" profile: ").append(video.getProfile()).append("\n"); + sb.append(" level: ").append(video.getLevel()).append("\n"); + sb.append(" widthInPixel: ").append(video.getWidthInPixel()).append("\n"); + sb.append(" heightInPixel: ").append(video.getHeightInPixel()).append("\n"); + sb.append(" frameRate: ").append(video.getFrameRate()).append("\n"); + sb.append(" bitRateInBps: ").append(video.getBitRateInBps()).append("\n"); + sb.append(" realFPS: ").append(video.getRealFPS()).append("\n"); + sb.append(" }"); + sb.append(" audio: \n"); + sb.append(" codec: ").append(audio.getCodec()).append("\n"); + sb.append(" profile: ").append(audio.getProfile()).append("\n"); + sb.append(" sampleRateInHz: ").append(audio.getSampleRateInHz()).append("\n"); + sb.append(" channels: ").append(audio.getChannels()).append("\n"); + sb.append(" bitRateInBps: ").append(audio.getBitRateInBps()).append("\n"); + sb.append(" }"); + sb.append("}\n"); + return sb.toString(); + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Video { + /** + * video codec + */ + private String codec; + + /** + * video profile + */ + private String profile; + + /** + * video level + */ + private String level; + + /** + * video width + */ + private Integer widthInPixel; + + /** + * video height + */ + private Integer heightInPixel; + + /** + * video standard frame rate + */ + private Float frameRate; + + /** + * video input bit rate + */ + private Integer bitRateInBps; + + /** + * video real-time frame rate + */ + private Float realFPS; + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Audio { + /** + * audio codec + */ + private String codec; + + /** + * audio profile + */ + private String profile; + + /** + * audio sampling rate + */ + private Integer sampleRateInHz; + + /** + * audio channels number + */ + private Integer channels; + + /** + * audio input bit rate + */ + private Integer bitRateInBps; + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/Hls.java b/src/main/java/com/baidubce/services/lss/model/Hls.java index b965e59d..3abc367b 100644 --- a/src/main/java/com/baidubce/services/lss/model/Hls.java +++ b/src/main/java/com/baidubce/services/lss/model/Hls.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class Hls { +import java.io.Serializable; + +public class Hls implements Serializable { private Integer segmentTimeInSecond = null; private Integer segmentListSize = null; diff --git a/src/main/java/com/baidubce/services/lss/model/HlsEncryption.java b/src/main/java/com/baidubce/services/lss/model/HlsEncryption.java index 284b6a08..674fe1a7 100644 --- a/src/main/java/com/baidubce/services/lss/model/HlsEncryption.java +++ b/src/main/java/com/baidubce/services/lss/model/HlsEncryption.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class HlsEncryption { +import java.io.Serializable; + +public class HlsEncryption implements Serializable { private String strategy = null; // private List safeCodes = null; diff --git a/src/main/java/com/baidubce/services/lss/model/IP.java b/src/main/java/com/baidubce/services/lss/model/IP.java index 164b1f54..25c26ece 100644 --- a/src/main/java/com/baidubce/services/lss/model/IP.java +++ b/src/main/java/com/baidubce/services/lss/model/IP.java @@ -13,9 +13,10 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; import java.util.List; -public class IP { +public class IP implements Serializable { private List whitelist = null; private List blacklist = null; diff --git a/src/main/java/com/baidubce/services/lss/model/InnerSessionStatistics.java b/src/main/java/com/baidubce/services/lss/model/InnerSessionStatistics.java index 0b99fc5c..a02b0127 100644 --- a/src/main/java/com/baidubce/services/lss/model/InnerSessionStatistics.java +++ b/src/main/java/com/baidubce/services/lss/model/InnerSessionStatistics.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/7/11. */ -public class InnerSessionStatistics { +public class InnerSessionStatistics implements Serializable { private String date = null; private Long durationInMinute = null; diff --git a/src/main/java/com/baidubce/services/lss/model/ListRealtimeStreamStatisticsRequest.java b/src/main/java/com/baidubce/services/lss/model/ListRealtimeStreamStatisticsRequest.java new file mode 100644 index 00000000..97ae5cb1 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ListRealtimeStreamStatisticsRequest.java @@ -0,0 +1,64 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class ListRealtimeStreamStatisticsRequest extends AbstractBceRequest { + + private String playDomain = null; + + private String app = null; + + public ListRealtimeStreamStatisticsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getPlayDomain() { + return playDomain; + } + + public void setPlayDomain(String playDomain) { + this.playDomain = playDomain; + } + + public ListRealtimeStreamStatisticsRequest withPlayDomain(String playDomain) { + this.playDomain = playDomain; + return this; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public ListRealtimeStreamStatisticsRequest withApp(String app) { + this.app = app; + return this; + } + + @Override + public String toString() { + return "ListRealtimeStreamStatisticsRequest{" + + "playDomain='" + playDomain + '\'' + + ", app='" + app + '\'' + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/lss/model/ListRealtimeStreamStatisticsResponse.java b/src/main/java/com/baidubce/services/lss/model/ListRealtimeStreamStatisticsResponse.java new file mode 100644 index 00000000..8f66f110 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ListRealtimeStreamStatisticsResponse.java @@ -0,0 +1,29 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Created by zhengfeng on 17/10/17. + */ +public class ListRealtimeStreamStatisticsResponse extends AbstractBceResponse { + + List realTimeStreamStatisticsList = null; + + public List getRealTimeStreamStatisticsList() { + return realTimeStreamStatisticsList; + } + + public void setRealTimeStreamStatisticsList(List realTimeStreamStatisticsList) { + this.realTimeStreamStatisticsList = realTimeStreamStatisticsList; + } + + @Override + public String toString() { + return "ListRealtimeStreamStatisticsResponse{" + + "realTimeStreamStatisticsList=" + realTimeStreamStatisticsList + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/lss/model/LiveDomainStatistics.java b/src/main/java/com/baidubce/services/lss/model/LiveDomainStatistics.java index b9b30fb5..c7bede0d 100644 --- a/src/main/java/com/baidubce/services/lss/model/LiveDomainStatistics.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveDomainStatistics.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/10/18. */ -public class LiveDomainStatistics { +public class LiveDomainStatistics implements Serializable { private String domain = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LivePlay.java b/src/main/java/com/baidubce/services/lss/model/LivePlay.java index ac58c1a2..47914e19 100644 --- a/src/main/java/com/baidubce/services/lss/model/LivePlay.java +++ b/src/main/java/com/baidubce/services/lss/model/LivePlay.java @@ -13,9 +13,10 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; import java.util.Map; -public class LivePlay { +public class LivePlay implements Serializable { private String rtmpUrl = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LivePreset.java b/src/main/java/com/baidubce/services/lss/model/LivePreset.java index ad393c76..c9cfda34 100644 --- a/src/main/java/com/baidubce/services/lss/model/LivePreset.java +++ b/src/main/java/com/baidubce/services/lss/model/LivePreset.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class LivePreset { +import java.io.Serializable; + +public class LivePreset implements Serializable { private String name = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LivePublish.java b/src/main/java/com/baidubce/services/lss/model/LivePublish.java index f19d4b6c..97532aae 100644 --- a/src/main/java/com/baidubce/services/lss/model/LivePublish.java +++ b/src/main/java/com/baidubce/services/lss/model/LivePublish.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class LivePublish { +import java.io.Serializable; + +public class LivePublish implements Serializable { private String region = null; private String pullUrl = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LiveSession.java b/src/main/java/com/baidubce/services/lss/model/LiveSession.java index 185294c4..95235511 100644 --- a/src/main/java/com/baidubce/services/lss/model/LiveSession.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveSession.java @@ -13,9 +13,10 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; import java.util.Map; -public class LiveSession { +public class LiveSession implements Serializable { private String sessionId = null; private String description = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStatistics.java b/src/main/java/com/baidubce/services/lss/model/LiveStatistics.java index 0afb9c41..9fa2e507 100644 --- a/src/main/java/com/baidubce/services/lss/model/LiveStatistics.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveStatistics.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/10/17. */ -public class LiveStatistics { +public class LiveStatistics implements Serializable { private Long durationInMinute = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStatisticsSummary.java b/src/main/java/com/baidubce/services/lss/model/LiveStatisticsSummary.java index cc826173..84ae0c76 100644 --- a/src/main/java/com/baidubce/services/lss/model/LiveStatisticsSummary.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveStatisticsSummary.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/10/17. */ -public class LiveStatisticsSummary { +public class LiveStatisticsSummary implements Serializable { private Long downStreamInByte = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStatisticsWithDate.java b/src/main/java/com/baidubce/services/lss/model/LiveStatisticsWithDate.java index 46548740..c158652b 100644 --- a/src/main/java/com/baidubce/services/lss/model/LiveStatisticsWithDate.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveStatisticsWithDate.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/10/17. */ -public class LiveStatisticsWithDate extends LiveStatistics { +public class LiveStatisticsWithDate extends LiveStatistics implements Serializable { private String date = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStream.java b/src/main/java/com/baidubce/services/lss/model/LiveStream.java index 88bf527b..2bc30948 100644 --- a/src/main/java/com/baidubce/services/lss/model/LiveStream.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveStream.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/10/14. */ -public class LiveStream { +public class LiveStream implements Serializable { private String sessionId = null; private String playDomain = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStreamStatistics.java b/src/main/java/com/baidubce/services/lss/model/LiveStreamStatistics.java index e36b8719..4ce23166 100644 --- a/src/main/java/com/baidubce/services/lss/model/LiveStreamStatistics.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveStreamStatistics.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/10/19. */ -public class LiveStreamStatistics { +public class LiveStreamStatistics implements Serializable { private String startDate = null; diff --git a/src/main/java/com/baidubce/services/lss/model/LiveThumbnail.java b/src/main/java/com/baidubce/services/lss/model/LiveThumbnail.java index c88f8280..5264185f 100644 --- a/src/main/java/com/baidubce/services/lss/model/LiveThumbnail.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveThumbnail.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class LiveThumbnail { +import java.io.Serializable; + +public class LiveThumbnail implements Serializable { private Target target = null; private Capture capture = null; diff --git a/src/main/java/com/baidubce/services/lss/model/Notification.java b/src/main/java/com/baidubce/services/lss/model/Notification.java index 27d45d1c..27e315de 100644 --- a/src/main/java/com/baidubce/services/lss/model/Notification.java +++ b/src/main/java/com/baidubce/services/lss/model/Notification.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class Notification { +import java.io.Serializable; + +public class Notification implements Serializable { /** * 通知名称 **/ diff --git a/src/main/java/com/baidubce/services/lss/model/PlayPrefix.java b/src/main/java/com/baidubce/services/lss/model/PlayPrefix.java index 9c32c861..3aad1c3a 100644 --- a/src/main/java/com/baidubce/services/lss/model/PlayPrefix.java +++ b/src/main/java/com/baidubce/services/lss/model/PlayPrefix.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/6/28. */ -public class PlayPrefix { +public class PlayPrefix implements Serializable { private String rtmp; private String hls; diff --git a/src/main/java/com/baidubce/services/lss/model/PublishPrefix.java b/src/main/java/com/baidubce/services/lss/model/PublishPrefix.java index d8a31779..e7570df7 100644 --- a/src/main/java/com/baidubce/services/lss/model/PublishPrefix.java +++ b/src/main/java/com/baidubce/services/lss/model/PublishPrefix.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/6/28. */ -public class PublishPrefix { +public class PublishPrefix implements Serializable { private String push; public String getPush() { diff --git a/src/main/java/com/baidubce/services/lss/model/RealTimeSessionStatistics.java b/src/main/java/com/baidubce/services/lss/model/RealTimeSessionStatistics.java index 36dff105..e1eb704b 100644 --- a/src/main/java/com/baidubce/services/lss/model/RealTimeSessionStatistics.java +++ b/src/main/java/com/baidubce/services/lss/model/RealTimeSessionStatistics.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class RealTimeSessionStatistics { +import java.io.Serializable; + +public class RealTimeSessionStatistics implements Serializable { private Long bandwidthInBps = null; private Long playCount = null; diff --git a/src/main/java/com/baidubce/services/lss/model/RealTimeStreamStatistics.java b/src/main/java/com/baidubce/services/lss/model/RealTimeStreamStatistics.java new file mode 100644 index 00000000..4daca84e --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/RealTimeStreamStatistics.java @@ -0,0 +1,68 @@ +package com.baidubce.services.lss.model; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.io.Serializable; +import java.util.Date; + +/** + * Created by zhengfeng on 17/10/17. + */ +public class RealTimeStreamStatistics implements Serializable { + + private String stream; + + @JsonFormat( + shape = JsonFormat.Shape.STRING, + pattern = "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'", + timezone = "GMT+8" + ) + private Date date; + + private Long playCount; + + private Long bandwidthInBps; + + public String getStream() { + return stream; + } + + public void setStream(String stream) { + this.stream = stream; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public Long getPlayCount() { + return playCount; + } + + public void setPlayCount(Long playCount) { + this.playCount = playCount; + } + + public Long getBandwidthInBps() { + return bandwidthInBps; + } + + public void setBandwidthInBps(Long bandwidthInBps) { + this.bandwidthInBps = bandwidthInBps; + } + + @Override + public String toString() { + return "RealTimeStreamStatistics{" + + "stream='" + stream + '\'' + + ", date=" + date + + ", playCount=" + playCount + + ", bandwidthInBps=" + bandwidthInBps + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/lss/model/RecordingClipRequest.java b/src/main/java/com/baidubce/services/lss/model/RecordingClipRequest.java new file mode 100644 index 00000000..413ed8f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/RecordingClipRequest.java @@ -0,0 +1,158 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * clip recording file request + * + * @Author: yangwenyue + * @Date: Created in 2019-08-28 15:47 + */ +public class RecordingClipRequest extends AbstractBceRequest { + + private String playDomain; + + private String app; + + private String stream; + + private String filename; + + private Integer startTime; + + private Integer endTime; + + private String format = "m3u8"; + + private String pipeline; + + private String preset; + + private String clipId; + + private String sourceFile; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getPlayDomain() { + return playDomain; + } + + public void setPlayDomain(String playDomain) { + this.playDomain = playDomain; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getStream() { + return stream; + } + + public void setStream(String stream) { + this.stream = stream; + } + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + public Integer getStartTime() { + return startTime; + } + + public void setStartTime(Integer startTime) { + this.startTime = startTime; + } + + public Integer getEndTime() { + return endTime; + } + + public void setEndTime(Integer endTime) { + this.endTime = endTime; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getPipeline() { + return pipeline; + } + + public void setPipeline(String pipeline) { + this.pipeline = pipeline; + } + + public String getPreset() { + return preset; + } + + public void setPreset(String preset) { + this.preset = preset; + } + + public String getClipId() { + return clipId; + } + + public void setClipId(String clipId) { + this.clipId = clipId; + } + + public String getSourceFile() { + return sourceFile; + } + + public void setSourceFile(String sourceFile) { + this.sourceFile = sourceFile; + } + + @Override + public String toString() { + return "LssRecordingClipRequest{" + + "playDomain='" + playDomain + '\'' + + ", app='" + app + '\'' + + ", stream='" + stream + '\'' + + ", filename='" + filename + '\'' + + ", startTime=" + startTime + + ", endTime=" + endTime + + ", format='" + format + '\'' + + ", pipeline='" + pipeline + '\'' + + ", preset='" + preset + '\'' + + ", clipId='" + clipId + '\'' + + ", sourceFile='" + sourceFile + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lss/model/RecordingClipResponse.java b/src/main/java/com/baidubce/services/lss/model/RecordingClipResponse.java new file mode 100644 index 00000000..caea8522 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/RecordingClipResponse.java @@ -0,0 +1,74 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * clip recording file response + * + * @Author: yangwenyue + * @Date: Created in 2019-08-28 15:47 + */ +public class RecordingClipResponse extends AbstractBceResponse { + + private String fileUrl; + + private String jobId; + + private String clipId; + + private String message; + + public String getFileUrl() { + return fileUrl; + } + + public void setFileUrl(String fileUrl) { + this.fileUrl = fileUrl; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getClipId() { + return clipId; + } + + public void setClipId(String clipId) { + this.clipId = clipId; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return "LssRecordingClipResponse{" + + "fileUrl='" + fileUrl + '\'' + + ", jobId='" + jobId + '\'' + + ", clipId='" + clipId + '\'' + + ", message='" + message + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lss/model/RecordingInfo.java b/src/main/java/com/baidubce/services/lss/model/RecordingInfo.java index edbc256e..66cdd6ee 100644 --- a/src/main/java/com/baidubce/services/lss/model/RecordingInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/RecordingInfo.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class RecordingInfo { +import java.io.Serializable; + +public class RecordingInfo implements Serializable { private String name = null; private String description = null; diff --git a/src/main/java/com/baidubce/services/lss/model/Refer.java b/src/main/java/com/baidubce/services/lss/model/Refer.java index ed275b68..06664e3a 100644 --- a/src/main/java/com/baidubce/services/lss/model/Refer.java +++ b/src/main/java/com/baidubce/services/lss/model/Refer.java @@ -13,9 +13,10 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; import java.util.List; -public class Refer { +public class Refer implements Serializable { private List whitelist = null; private List blacklist = null; diff --git a/src/main/java/com/baidubce/services/lss/model/ResetDomainStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/ResetDomainStreamRequest.java new file mode 100644 index 00000000..428415a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ResetDomainStreamRequest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by yangwenyue on 20/07/07. + */ +public class ResetDomainStreamRequest extends AbstractBceRequest { + + private String domain = null; + + private String app = null; + + private String stream = null; + + private Long resumeTimeInSecond = null; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public ResetDomainStreamRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public ResetDomainStreamRequest withApp(String app) { + this.app = app; + return this; + } + + public String getStream() { + return stream; + } + + public void setStream(String stream) { + this.stream = stream; + } + + public ResetDomainStreamRequest withStream(String stream) { + this.stream = stream; + return this; + } + + public Long getResumeTimeInSecond() { + return resumeTimeInSecond; + } + + public void setResumeTimeInSecond(Long resumeTimeInSecond) { + this.resumeTimeInSecond = resumeTimeInSecond; + } + + public ResetDomainStreamRequest withResumeTimeInSecond(Long resumeTimeInSecond) { + this.resumeTimeInSecond = resumeTimeInSecond; + return this; + } + + public ResetDomainStreamRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ResetDomainStreamRequest {\n"); + sb.append(" domain: ").append(domain).append("\n"); + sb.append(" app: ").append(app).append("\n"); + sb.append(" stream: ").append(stream).append("\n"); + sb.append(" resumeTimeInSecond: ").append(resumeTimeInSecond).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/ResetDomainStreamRequestBody.java b/src/main/java/com/baidubce/services/lss/model/ResetDomainStreamRequestBody.java new file mode 100644 index 00000000..5a620f19 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ResetDomainStreamRequestBody.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created on 2020/7/7 + * + * @author yangwenyue + */ +public class ResetDomainStreamRequestBody extends AbstractBceRequest { + + private Long resumeTimestamp; + + public ResetDomainStreamRequestBody(Long resumeTimestamp) { + super(); + this.resumeTimestamp = resumeTimestamp; + } + + public Long getResumeTimestamp() { + return resumeTimestamp; + } + + public void setResumeTimestamp(Long resumeTimestamp) { + this.resumeTimestamp = resumeTimestamp; + } + + public ResetDomainStreamRequestBody withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/CreateDomainResponse.java b/src/main/java/com/baidubce/services/lss/model/ResetDomainStreamResponse.java similarity index 73% rename from src/main/java/com/baidubce/services/cdn/model/CreateDomainResponse.java rename to src/main/java/com/baidubce/services/lss/model/ResetDomainStreamResponse.java index 0abf1e8e..ec131e26 100644 --- a/src/main/java/com/baidubce/services/cdn/model/CreateDomainResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/ResetDomainStreamResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. + * Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -10,15 +10,18 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package com.baidubce.services.cdn.model; +package com.baidubce.services.lss.model; import com.baidubce.model.AbstractBceResponse; -public class CreateDomainResponse extends AbstractBceResponse { +/** + * Created by yangwenyue on 20/07/07. + */ +public class ResetDomainStreamResponse extends AbstractBceResponse { @Override public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class CreateDomainResponse {\n"); + sb.append("class PauseDomainStreamResponse {\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/lss/model/Rtmp.java b/src/main/java/com/baidubce/services/lss/model/Rtmp.java index 3d85e0fa..ebb0b44c 100644 --- a/src/main/java/com/baidubce/services/lss/model/Rtmp.java +++ b/src/main/java/com/baidubce/services/lss/model/Rtmp.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class Rtmp { +import java.io.Serializable; + +public class Rtmp implements Serializable { /** * 是否缓存一个gop */ diff --git a/src/main/java/com/baidubce/services/lss/model/SecurityPolicyInfo.java b/src/main/java/com/baidubce/services/lss/model/SecurityPolicyInfo.java index 32d0000b..3a2915cc 100644 --- a/src/main/java/com/baidubce/services/lss/model/SecurityPolicyInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/SecurityPolicyInfo.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class SecurityPolicyInfo { +import java.io.Serializable; + +public class SecurityPolicyInfo implements Serializable { private String name = null; private AuthInfo auth = null; diff --git a/src/main/java/com/baidubce/services/lss/model/SessionAggregate.java b/src/main/java/com/baidubce/services/lss/model/SessionAggregate.java index e55a318a..040415b9 100644 --- a/src/main/java/com/baidubce/services/lss/model/SessionAggregate.java +++ b/src/main/java/com/baidubce/services/lss/model/SessionAggregate.java @@ -1,9 +1,11 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; + /** * Created by wuyafei on 16/7/11. */ -public class SessionAggregate { +public class SessionAggregate implements Serializable { private Long durationInMinute = null; private Long peakPlayCount = null; diff --git a/src/main/java/com/baidubce/services/lss/model/SessionErrorInfo.java b/src/main/java/com/baidubce/services/lss/model/SessionErrorInfo.java index 3ea944b1..b4a0c385 100644 --- a/src/main/java/com/baidubce/services/lss/model/SessionErrorInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/SessionErrorInfo.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class SessionErrorInfo { +import java.io.Serializable; + +public class SessionErrorInfo implements Serializable { private String code = null; private String message = null; diff --git a/src/main/java/com/baidubce/services/lss/model/StreamingStream.java b/src/main/java/com/baidubce/services/lss/model/StreamingStream.java new file mode 100644 index 00000000..41448f30 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/StreamingStream.java @@ -0,0 +1,36 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import lombok.Data; + +/** + * info of streaming stream + * + * @Author: yangwenyue + * @Date: Created in 2019-08-30 11:41 + */ +@Data +public class StreamingStream { + + private String sessionId; + + private String app; + + private String playDomain; + + private String stream; + + private String userId; +} + diff --git a/src/main/java/com/baidubce/services/lss/model/StreamingStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/StreamingStreamRequest.java new file mode 100644 index 00000000..df02b11c --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/StreamingStreamRequest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * get streaming stream request. + * + * @Author: yangwenyue + * @Date: Created in 2019-08-30 11:41 + */ +@Data +public class StreamingStreamRequest extends AbstractBceRequest { + + private String playDomain; + + @Override + public StreamingStreamRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/StreamingStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/StreamingStreamResponse.java new file mode 100644 index 00000000..f2943e6b --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/StreamingStreamResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +import java.util.List; + +/** + * get streaming stream response. + * + * @Author: yangwenyue + * @Date: Created in 2019-08-30 11:41 + */ +@Data +public class StreamingStreamResponse extends AbstractBceResponse { + + List streams; +} + diff --git a/src/main/java/com/baidubce/services/lss/model/Target.java b/src/main/java/com/baidubce/services/lss/model/Target.java index 5bc3c51f..17ff9f0e 100644 --- a/src/main/java/com/baidubce/services/lss/model/Target.java +++ b/src/main/java/com/baidubce/services/lss/model/Target.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class Target { +import java.io.Serializable; + +public class Target implements Serializable { private String format = null; private String sizingPolicy = null; diff --git a/src/main/java/com/baidubce/services/lss/model/UpdateStreamDestinationPushUrlRequest.java b/src/main/java/com/baidubce/services/lss/model/UpdateStreamDestinationPushUrlRequest.java new file mode 100644 index 00000000..9948ac8a --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/UpdateStreamDestinationPushUrlRequest.java @@ -0,0 +1,150 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represents request for updating a stream's destination push url + */ +public class UpdateStreamDestinationPushUrlRequest extends AbstractBceRequest { + + private String domain; + + private String app; + + private String stream; + + private String destinationPushUrl; + + /** + * Returns domain + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * Sets domain + * @param domain + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * Sets domain + * @return returns this object for method chaining + */ + public UpdateStreamDestinationPushUrlRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * Returns app + * @return app + */ + public String getApp() { + return app; + } + + /** + * Sets app + * @param app + */ + public void setApp(String app) { + this.app = app; + } + + /** + * Sets app + * @return returns this object for method chaining + */ + public UpdateStreamDestinationPushUrlRequest withApp(String app) { + this.app = app; + return this; + } + + /** + * Returns stream + * @return stream + */ + public String getStream() { + return stream; + } + + /** + * Sets stream + * @param stream + */ + public void setStream(String stream) { + this.stream = stream; + } + + /** + * Sets stream + * @return returns this object for method chaining + */ + public UpdateStreamDestinationPushUrlRequest withStream(String stream) { + this.stream = stream; + return this; + } + + /** + * Returns destinationPushUrl + * @return destinationPushUrl + */ + public String getDestinationPushUrl() { + return destinationPushUrl; + } + + /** + * Sets destinationPushUrl + * @param destinationPushUrl + */ + public void setDestinationPushUrl(String destinationPushUrl) { + this.destinationPushUrl = destinationPushUrl; + } + + /** + * Sets destinationPushUrl + * @return returns this object for method chaining + */ + public UpdateStreamDestinationPushUrlRequest withDestinationPushUrl(String destinationPushUrl) { + this.destinationPushUrl = destinationPushUrl; + return this; + } + + /** + * Sets credentials + * @return returns this object for method chaining + */ + @Override + public UpdateStreamDestinationPushUrlRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "UpdateStreamDestinationPushUrlRequest{" + + "domain='" + domain + '\'' + + ", app='" + app + '\'' + + ", stream='" + stream + '\'' + + ", destinationPushUrl='" + destinationPushUrl + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/UpdateStreamPresetsRequest.java b/src/main/java/com/baidubce/services/lss/model/UpdateStreamPresetsRequest.java new file mode 100644 index 00000000..24ab25da --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/UpdateStreamPresetsRequest.java @@ -0,0 +1,153 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.Map; + +/** + * Represents request for updating a stream's presets + */ +public class UpdateStreamPresetsRequest extends AbstractBceRequest { + + private String domain; + + private String app; + + private String stream; + + private Map presets; + + /** + * Returns domain + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * Sets domain + * @param domain + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * Sets domain + * @return returns this object for method chaining + */ + public UpdateStreamPresetsRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * Returns app + * @return app + */ + public String getApp() { + return app; + } + + /** + * Sets app + * @param app + */ + public void setApp(String app) { + this.app = app; + } + + /** + * Sets app + * @return returns this object for method chaining + */ + public UpdateStreamPresetsRequest withApp(String app) { + this.app = app; + return this; + } + + /** + * Returns stream + * @return stream + */ + public String getStream() { + return stream; + } + + /** + * Sets stream + * @param stream + */ + public void setStream(String stream) { + this.stream = stream; + } + + /** + * Sets stream + * @return returns this object for method chaining + */ + public UpdateStreamPresetsRequest withStream(String stream) { + this.stream = stream; + return this; + } + + /** + * Returns presets + * @return presets + */ + public Map getPresets() { + return presets; + } + + /** + * Sets presets + * @param presets + */ + public void setPresets(Map presets) { + this.presets = presets; + } + + /** + * Sets presets + * @return returns this object for method chaining + */ + public UpdateStreamPresetsRequest withPresets(Map presets) { + this.presets = presets; + return this; + } + + /** + * Sets credentials + * @return returns this object for method chaining + */ + @Override + public UpdateStreamPresetsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "UpdateStreamPresetsRequest{" + + "domain='" + domain + '\'' + + ", app='" + app + '\'' + + ", stream='" + stream + '\'' + + ", presets=" + presets + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/lss/model/UpdateStreamPullUrlRequest.java b/src/main/java/com/baidubce/services/lss/model/UpdateStreamPullUrlRequest.java new file mode 100644 index 00000000..87028ff6 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/UpdateStreamPullUrlRequest.java @@ -0,0 +1,150 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represents request for updating a stream's pull url + */ +public class UpdateStreamPullUrlRequest extends AbstractBceRequest { + + private String domain; + + private String app; + + private String stream; + + private String pullUrl; + + /** + * Returns domain + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * Sets domain + * @param domain + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * Sets domain + * @return returns this object for method chaining + */ + public UpdateStreamPullUrlRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * Returns app + * @return app + */ + public String getApp() { + return app; + } + + /** + * Sets app + * @param app + */ + public void setApp(String app) { + this.app = app; + } + + /** + * Sets app + * @return returns this object for method chaining + */ + public UpdateStreamPullUrlRequest withApp(String app) { + this.app = app; + return this; + } + + /** + * Returns stream + * @return stream + */ + public String getStream() { + return stream; + } + + /** + * Sets stream + * @param stream + */ + public void setStream(String stream) { + this.stream = stream; + } + + /** + * Sets stream + * @return returns this object for method chaining + */ + public UpdateStreamPullUrlRequest withStream(String stream) { + this.stream = stream; + return this; + } + + /** + * Returns pullUrl + * @return pullUrl + */ + public String getPullUrl() { + return pullUrl; + } + + /** + * Sets pullUrl + * @param pullUrl + */ + public void setPullUrl(String pullUrl) { + this.pullUrl = pullUrl; + } + + /** + * Sets pullUrl + * @return returns this object for method chaining + */ + public UpdateStreamPullUrlRequest withPullUrl(String pullUrl) { + this.pullUrl = pullUrl; + return this; + } + + /** + * Sets credentials + * @return returns this object for method chaining + */ + @Override + public UpdateStreamPullUrlRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "UpdateStreamPullUrlRequest{" + + "domain='" + domain + '\'' + + ", app='" + app + '\'' + + ", stream='" + stream + '\'' + + ", pullUrl='" + pullUrl + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/UpdateStreamRecordingRequest.java b/src/main/java/com/baidubce/services/lss/model/UpdateStreamRecordingRequest.java new file mode 100644 index 00000000..13f5835e --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/UpdateStreamRecordingRequest.java @@ -0,0 +1,150 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represents request for updating a stream's recording + */ +public class UpdateStreamRecordingRequest extends AbstractBceRequest { + + private String domain; + + private String app; + + private String stream; + + private String recording; + + /** + * Returns domain + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * Sets domain + * @param domain + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * Sets domain + * @return returns this object for method chaining + */ + public UpdateStreamRecordingRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * Returns app + * @return app + */ + public String getApp() { + return app; + } + + /** + * Sets app + * @param app + */ + public void setApp(String app) { + this.app = app; + } + + /** + * Sets app + * @return returns this object for method chaining + */ + public UpdateStreamRecordingRequest withApp(String app) { + this.app = app; + return this; + } + + /** + * Returns stream + * @return stream + */ + public String getStream() { + return stream; + } + + /** + * Sets stream + * @param stream + */ + public void setStream(String stream) { + this.stream = stream; + } + + /** + * Sets stream + * @return returns this object for method chaining + */ + public UpdateStreamRecordingRequest withStream(String stream) { + this.stream = stream; + return this; + } + + /** + * Returns recording + * @return recording + */ + public String getRecording() { + return recording; + } + + /** + * Sets recording + * @param recording + */ + public void setRecording(String recording) { + this.recording = recording; + } + + /** + * Sets recording + * @return returns this object for method chaining + */ + public UpdateStreamRecordingRequest withRecording(String recording) { + this.recording = recording; + return this; + } + + /** + * Sets credentials + * @return returns this object for method chaining + */ + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "UpdateStreamRecordingRequest{" + + "domain='" + domain + '\'' + + ", app='" + app + '\'' + + ", stream='" + stream + '\'' + + ", recording='" + recording + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/UpdateStreamWatermarkRequest.java b/src/main/java/com/baidubce/services/lss/model/UpdateStreamWatermarkRequest.java new file mode 100644 index 00000000..a6bae2ce --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/UpdateStreamWatermarkRequest.java @@ -0,0 +1,150 @@ +/* + * Copyright 2017 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represents request for updating a stream's watermark + */ +public class UpdateStreamWatermarkRequest extends AbstractBceRequest { + + private String domain; + + private String app; + + private String stream; + + private Watermarks watermarks; + + /** + * Returns domain + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * Sets domain + * @param domain + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * Sets domain + * @return returns this object for method chaining + */ + public UpdateStreamWatermarkRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * Returns app + * @return app + */ + public String getApp() { + return app; + } + + /** + * Sets app + * @param app + */ + public void setApp(String app) { + this.app = app; + } + + /** + * Sets app + * @return returns this object for method chaining + */ + public UpdateStreamWatermarkRequest withApp(String app) { + this.app = app; + return this; + } + + /** + * Returns stream + * @return stream + */ + public String getStream() { + return stream; + } + + /** + * Sets stream + * @param stream + */ + public void setStream(String stream) { + this.stream = stream; + } + + /** + * Sets stream + * @return returns this object for method chaining + */ + public UpdateStreamWatermarkRequest withStream(String stream) { + this.stream = stream; + return this; + } + + /** + * Returns watermarks + * @return watermarks + */ + public Watermarks getWatermarks() { + return watermarks; + } + + /** + * Sets watermarks + * @param watermarks + */ + public void setWatermarks(Watermarks watermarks) { + this.watermarks = watermarks; + } + + /** + * Sets watermarks + * @return returns this object for method chaining + */ + public UpdateStreamWatermarkRequest withWatermarks(Watermarks watermarks) { + this.watermarks = watermarks; + return this; + } + + /** + * Sets credentials + * @return returns this object for method chaining + */ + @Override + public UpdateStreamWatermarkRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "UpdateStreamWatermarkRequest{" + + "domain='" + domain + '\'' + + ", app='" + app + '\'' + + ", stream='" + stream + '\'' + + ", watermarks=" + watermarks + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/Video.java b/src/main/java/com/baidubce/services/lss/model/Video.java index 6a2a2c04..303046fa 100644 --- a/src/main/java/com/baidubce/services/lss/model/Video.java +++ b/src/main/java/com/baidubce/services/lss/model/Video.java @@ -13,7 +13,9 @@ package com.baidubce.services.lss.model; -public class Video { +import java.io.Serializable; + +public class Video implements Serializable { private String codec = null; private CodecOptions codecOptions = null; private Integer bitRateInBps = null; diff --git a/src/main/java/com/baidubce/services/lss/model/Watermarks.java b/src/main/java/com/baidubce/services/lss/model/Watermarks.java index 829293d1..a984d0e3 100644 --- a/src/main/java/com/baidubce/services/lss/model/Watermarks.java +++ b/src/main/java/com/baidubce/services/lss/model/Watermarks.java @@ -13,9 +13,10 @@ package com.baidubce.services.lss.model; +import java.io.Serializable; import java.util.List; -public class Watermarks { +public class Watermarks implements Serializable { private List image = null; private List timestamp = null; diff --git a/src/main/java/com/baidubce/services/media/MediaClient.java b/src/main/java/com/baidubce/services/media/MediaClient.java old mode 100644 new mode 100755 index 1f26d101..eebe8125 --- a/src/main/java/com/baidubce/services/media/MediaClient.java +++ b/src/main/java/com/baidubce/services/media/MediaClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Baidu, Inc. + * Copyright 2015-2020 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -16,6 +16,7 @@ import java.io.UnsupportedEncodingException; import java.net.URI; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import com.baidubce.AbstractBceClient; @@ -30,65 +31,107 @@ import com.baidubce.internal.InternalRequest; import com.baidubce.internal.RestartableInputStream; import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.media.model.Area; import com.baidubce.services.media.model.Audio; import com.baidubce.services.media.model.Clip; import com.baidubce.services.media.model.CreateJobRequest; import com.baidubce.services.media.model.CreateJobResponse; +import com.baidubce.services.media.model.CreateNotificationRequest; +import com.baidubce.services.media.model.CreateNotificationResponse; import com.baidubce.services.media.model.CreatePipelineRequest; import com.baidubce.services.media.model.CreatePipelineResponse; import com.baidubce.services.media.model.CreatePresetRequest; import com.baidubce.services.media.model.CreatePresetResponse; +import com.baidubce.services.media.model.CreateSubtitleJobRequest; +import com.baidubce.services.media.model.CreateSubtitleJobResponse; import com.baidubce.services.media.model.CreateThumbnailJobRequest; import com.baidubce.services.media.model.CreateThumbnailJobResponse; +import com.baidubce.services.media.model.CreateThumbnailPresetRequest; +import com.baidubce.services.media.model.CreateThumbnailPresetResponse; import com.baidubce.services.media.model.CreateTranscodingJobRequest; import com.baidubce.services.media.model.CreateTranscodingJobResponse; import com.baidubce.services.media.model.CreateWaterMarkRequest; import com.baidubce.services.media.model.CreateWaterMarkResponse; +import com.baidubce.services.media.model.DeleteNotificationRequest; +import com.baidubce.services.media.model.DeleteNotificationResponse; import com.baidubce.services.media.model.DeletePipelineRequest; import com.baidubce.services.media.model.DeletePresetRequest; import com.baidubce.services.media.model.DeletePresetResponse; +import com.baidubce.services.media.model.DeleteThumbnailPresetRequest; import com.baidubce.services.media.model.DeleteWaterMarkRequest; import com.baidubce.services.media.model.DeleteWaterMarkResponse; import com.baidubce.services.media.model.Encryption; +import com.baidubce.services.media.model.ExtraCfg; import com.baidubce.services.media.model.GetJobRequest; import com.baidubce.services.media.model.GetJobResponse; import com.baidubce.services.media.model.GetMediaInfoOfFileRequest; import com.baidubce.services.media.model.GetMediaInfoOfFileResponse; +import com.baidubce.services.media.model.GetNotificationRequest; +import com.baidubce.services.media.model.GetNotificationResponse; import com.baidubce.services.media.model.GetPipelineRequest; import com.baidubce.services.media.model.GetPipelineResponse; import com.baidubce.services.media.model.GetPresetRequest; import com.baidubce.services.media.model.GetPresetResponse; +import com.baidubce.services.media.model.GetSubtitleJobRequest; +import com.baidubce.services.media.model.GetSubtitleJobResponse; import com.baidubce.services.media.model.GetThumbnailJobRequest; import com.baidubce.services.media.model.GetThumbnailJobResponse; +import com.baidubce.services.media.model.GetThumbnailPresetRequest; +import com.baidubce.services.media.model.GetThumbnailPresetResponse; +import com.baidubce.services.media.model.GetTranscodingEncryptionKeyRequest; +import com.baidubce.services.media.model.GetTranscodingEncryptionKeyResponse; import com.baidubce.services.media.model.GetTranscodingJobRequest; import com.baidubce.services.media.model.GetTranscodingJobResponse; import com.baidubce.services.media.model.GetWaterMarkRequest; import com.baidubce.services.media.model.GetWaterMarkResponse; +import com.baidubce.services.media.model.Insert; import com.baidubce.services.media.model.ListJobsRequest; import com.baidubce.services.media.model.ListJobsResponse; +import com.baidubce.services.media.model.ListNotificationsRequest; +import com.baidubce.services.media.model.ListNotificationsResponse; import com.baidubce.services.media.model.ListPipelinesRequest; import com.baidubce.services.media.model.ListPipelinesResponse; import com.baidubce.services.media.model.ListPresetsRequest; import com.baidubce.services.media.model.ListPresetsResponse; +import com.baidubce.services.media.model.ListSubtitleJobsRequest; +import com.baidubce.services.media.model.ListSubtitleJobsResponse; import com.baidubce.services.media.model.ListThumbnailJobsRequest; import com.baidubce.services.media.model.ListThumbnailJobsResponse; +import com.baidubce.services.media.model.ListThumbnailPresetsRequest; +import com.baidubce.services.media.model.ListThumbnailPresetsResponse; import com.baidubce.services.media.model.ListTranscodingJobsRequest; import com.baidubce.services.media.model.ListTranscodingJobsResponse; import com.baidubce.services.media.model.ListWaterMarkRequest; import com.baidubce.services.media.model.ListWaterMarkResponse; import com.baidubce.services.media.model.PipelineConfig; import com.baidubce.services.media.model.Source; +import com.baidubce.services.media.model.SourceClip; +import com.baidubce.services.media.model.SubtitleSource; +import com.baidubce.services.media.model.SubtitleTarget; import com.baidubce.services.media.model.Target; import com.baidubce.services.media.model.ThumbnailCapture; +import com.baidubce.services.media.model.ThumbnailPresetCapture; +import com.baidubce.services.media.model.ThumbnailPresetTarget; import com.baidubce.services.media.model.ThumbnailSource; import com.baidubce.services.media.model.ThumbnailTarget; +import com.baidubce.services.media.model.Timeline; +import com.baidubce.services.media.model.TransCfg; +import com.baidubce.services.media.model.UpdatePipelineRequest; +import com.baidubce.services.media.model.UpdatePipelineResponse; +import com.baidubce.services.media.model.UpdatePresetRequest; +import com.baidubce.services.media.model.UpdatePresetResponse; +import com.baidubce.services.media.model.UpdateThumbnailPresetRequest; +import com.baidubce.services.media.model.UpdateThumbnailPresetResponse; import com.baidubce.services.media.model.Video; +import com.baidubce.services.media.model.Watermarks; + import com.baidubce.util.HttpUtils; import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; import static com.baidubce.util.Validate.checkStringNotEmpty; import static com.baidubce.util.Validate.checkNotNull; -import static com.baidubce.util.Validate.checkIsTrue; /** @@ -118,6 +161,11 @@ public class MediaClient extends AbstractBceClient { * The common URI prefix for preset services. */ private static final String PRESET = "preset"; + + /** + * The common URI prefix for thumbnail preset services. + */ + private static final String THUMBNAIL_PRESET = "preset/thumbnail"; /** * The common URI prefix for media-info services. @@ -130,21 +178,55 @@ public class MediaClient extends AbstractBceClient { private static final String WATER_MARK = "watermark"; /** - * The common URI prefix for water mark services. + * The common URI prefix for thumbnail services. */ private static final String THUMBNAIL = "job/thumbnail"; + /** + * The common URI prefix for subtitle services. + */ + private static final String SUBTITLE = "job/subtitle"; + + /** + * The common URI prefix for subtitle services. + */ + private static final String TRANSCODING_KEY = "transcoding/key"; + + /** + * The common URI prefix for notification services. + */ + private static final String NOTIFICATION = "notification"; + /** * The default capacity of a new pipeline. */ private static final int DEFAULT_PIPELINE_CAPACITY = 20; + /** + * Exception messages. + */ + public static final String REQUEST_NULL_ERROR_MESSAGE = "request should not be null."; + public static final String PIPELINENAME_MESSAGE_KEY = "pipelineName"; + public static final String SOURCE_MESSAGE_KEY = "source"; + public static final String TARGET_MESSAGE_KEY = "target"; + public static final String SOURCEKEY_MESSAGE_KEY = "sourceKey"; + public static final String TARGETKEY_MESSAGE_KEY = "targetKey"; + public static final String SOURCEBUCKET_MESSAGE_KEY = "sourceBucket"; + public static final String TARGETBUCKET_MESSAGE_KEY = "targetBucket"; + public static final String NAME_MESSAGE_KEY = "name"; + public static final String ENDPOINT_MESSAGE_KEY = "endpoint"; + public static final String PRESETNAME_MESSAGE_KEY = "presetName"; + public static final String JOBID_MESSAGE_KEY = "jobId"; + public static final String BUCKET_MESSAGE_KEY = "bucket"; + public static final String KEY_MESSAGE_KEY = "key"; + public static final String WATERMARKID_MESSAGE_KEY = "watermarkId"; /** * Responsible for handling httpResponses from all service calls. */ private static final HttpResponseHandler[] mediaHandlers = new HttpResponseHandler[] { new BceMetadataResponseHandler(), new BceErrorResponseHandler(), + new MediaEncryptionKeyResponseHandler(), new BceJsonResponseHandler() }; @@ -197,22 +279,21 @@ public CreateJobResponse createJob(String pipelineName, String sourceKey, String * @param request The request object containing all options for creating a job. * * @return The newly created job ID. - * @deprecated As of release 0.8.5, replaced by {@link #createTranscodingJob(CreateJobRequest)}} + * @deprecated As of release 0.8.5, replaced by {@link #createTranscodingJob(CreateTranscodingJobRequest)}} */ @Deprecated public CreateJobResponse createJob(CreateJobRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); + + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); checkStringNotEmpty(request.getPipelineName(), - "The parameter pipelineName should NOT be null or empty string."); - checkNotNull(request.getSource(), "The parameter source should NOT be null."); - checkStringNotEmpty(request.getSource().getSourceKey(), - "The parameter sourceKey should NOT be null or empty string."); - checkNotNull(request.getTarget(), "The parameter target should NOT be null."); + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); + checkNotNull(request.getSource(), checkEmptyExceptionMessageFormat(SOURCE_MESSAGE_KEY)); + checkNotNull(request.getTarget(), checkEmptyExceptionMessageFormat(TARGET_MESSAGE_KEY)); checkStringNotEmpty(request.getTarget().getTargetKey(), - "The parameter targetKey should NOT be null or empty string."); + checkEmptyExceptionMessageFormat(TARGETKEY_MESSAGE_KEY)); checkStringNotEmpty(request.getTarget().getPresetName(), - "The parameter presetName should NOT be null or empty string."); + checkEmptyExceptionMessageFormat(PRESETNAME_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, TRANSCODE_JOB); @@ -240,15 +321,15 @@ public ListJobsResponse listJobs(String pipelineName) { * @param request The request object containing all options for list jobs. * * @return The list of job IDs. - * @deprecated As of release 0.8.5, replaced by {@link #listTranscodingJobs(ListJobsRequest)} + * @deprecated As of release 0.8.5, replaced by {@link #listTranscodingJobs(ListTranscodingJobsRequest)} */ @Deprecated public ListJobsResponse listJobs(ListJobsRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); checkStringNotEmpty(request.getPipelineName(), - "The parameter pipelineName should NOT be null or empty string."); + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, TRANSCODE_JOB); - internalRequest.addParameter("pipelineName", request.getPipelineName()); + internalRequest.addParameter(PIPELINENAME_MESSAGE_KEY, request.getPipelineName()); return invokeHttpClient(internalRequest, ListJobsResponse.class); } @@ -273,12 +354,12 @@ public GetJobResponse getJob(String jobId) { * @param request The request object containing all options for retrieving job status. * * @return The status of a job. - * @deprecated As of release 0.8.5, replaced by {@link #getTranscodingJob(GetJobRequest)} + * @deprecated As of release 0.8.5, replaced by {@link #getTranscodingJob(GetTranscodingJobRequest)} */ @Deprecated public GetJobResponse getJob(GetJobRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - checkStringNotEmpty(request.getJobId(), "The parameter jobId should NOT be null or empty string."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, TRANSCODE_JOB, request.getJobId()); return invokeHttpClient(internalRequest, GetJobResponse.class); @@ -296,6 +377,26 @@ public GetJobResponse getJob(GetJobRequest request) { */ public CreateTranscodingJobResponse createTranscodingJob( String pipelineName, String sourceKey, String targetKey, String presetName) { + return createTranscodingJob(pipelineName, sourceKey, targetKey, presetName, + null, null); + } + + /** + * Creates a new transcoder job which converts media files in BOS buckets with specified preset, watermarkId, and + * delogoArea. + * + * @param pipelineName The name of pipeline used by this job. + * @param sourceKey The key of the source media file in the bucket specified in the pipeline. + * @param targetKey The key of the target media file in the bucket specified in the pipeline. + * @param presetName The name of the preset used by this job. + * @param watermarkId Single watermarkId associated with the job. + * @param delogoArea The delogo area (x, y, width, height). + * + * @return The newly created job ID. + */ + public CreateTranscodingJobResponse createTranscodingJob( + String pipelineName, String sourceKey, String targetKey, String presetName, + String watermarkId, Area delogoArea) { CreateTranscodingJobRequest request = new CreateTranscodingJobRequest(); request.setPipelineName(pipelineName); Source source = new Source(); @@ -304,11 +405,119 @@ public CreateTranscodingJobResponse createTranscodingJob( Target target = new Target(); target.setTargetKey(targetKey); target.setPresetName(presetName); + if (!Strings.isNullOrEmpty(watermarkId)) { + List watermarkIds = Collections.singletonList(watermarkId); + target.setWatermarkIds(watermarkIds); + } + if (delogoArea != null) { + target.setDelogoArea(delogoArea); + } request.setTarget(target); return createTranscodingJob(request); } - + + /** + * Creates a new transcoder job which converts media files in BOS buckets with specified preset. + * + * @param pipelineName The name of pipeline used by this job. + * @param clips The keys of the source media file in the bucket specified in the pipeline. + * @param targetKey The key of the target media file in the bucket specified in the pipeline. + * @param presetName The name of the preset used by this job. + * + * @return The newly created job ID. + */ + public CreateTranscodingJobResponse createTranscodingJob( + String pipelineName, List clips, String targetKey, String presetName) { + return createTranscodingJob(pipelineName, clips, targetKey, presetName, + null, null); + } + + /** + * Creates a new transcoder job which converts media files in BOS buckets with specified preset and watermarkId + * associated with the job. + * + * @param pipelineName The name of pipeline used by this job. + * @param clips The keys of the source media file in the bucket specified in the pipeline. + * @param targetKey The key of the target media file in the bucket specified in the pipeline. + * @param presetName The name of the preset used by this job. + * @param watermarkId Single watermarkId associated with the job. + * + * @return The newly created job ID. + */ + public CreateTranscodingJobResponse createTranscodingJob( + String pipelineName, List clips, String targetKey, String presetName, + String watermarkId) { + return createTranscodingJob(pipelineName, clips, targetKey, presetName, + watermarkId, null); + } + + /** + * Creates a new transcoder job which converts media files in BOS buckets with specified preset, watermarkId, and + * delogoArea. + * + * @param pipelineName The name of pipeline used by this job. + * @param clips The keys of the source media file in the bucket specified in the pipeline. + * @param targetKey The key of the target media file in the bucket specified in the pipeline. + * @param presetName The name of the preset used by this job. + * @param watermarkId Single watermarkId associated with the job. + * @param delogoArea The delogo area (x, y, width, height). + * + * @return The newly created job ID. + */ + public CreateTranscodingJobResponse createTranscodingJob( + String pipelineName, List clips, String targetKey, String presetName, + String watermarkId, Area delogoArea) { + return createTranscodingJob(pipelineName, clips, targetKey, presetName, + watermarkId, delogoArea, null, null); + } + + /** + * Creates a new transcoder job which converts media files in BOS buckets with specified preset, watermarkId, and + * delogoArea. + * + * @param pipelineName The name of pipeline used by this job. + * @param clips The keys of the source media file in the bucket specified in the pipeline. + * @param targetKey The key of the target media file in the bucket specified in the pipeline. + * @param presetName The name of the preset used by this job. + * @param watermarkId Single watermarkId associated with the job. + * @param delogoArea The delogo area (x, y, width, height). + * @param crop The crop area (x, y, width, height). + * @param inserts The list of Insert. + * + * @return The newly created job ID. + */ + public CreateTranscodingJobResponse createTranscodingJob( + String pipelineName, List clips, String targetKey, String presetName, + String watermarkId, Area delogoArea, Area crop, List inserts) { + CreateTranscodingJobRequest request = new CreateTranscodingJobRequest(); + request.setPipelineName(pipelineName); + Source source = new Source(); + for (SourceClip clip : clips) { + source.addClip(clip); + } + request.setSource(source); + Target target = new Target(); + target.setTargetKey(targetKey); + target.setPresetName(presetName); + if (!Strings.isNullOrEmpty(watermarkId)) { + List watermarkIds = Collections.singletonList(watermarkId); + target.setWatermarkIds(watermarkIds); + } + if (delogoArea != null) { + target.setDelogoArea(delogoArea); + } + if (crop != null) { + target.setCrop(crop); + } + if (inserts != null) { + target.setInserts(inserts); + } + request.setTarget(target); + + return createTranscodingJob(request); + } + /** * Creates a new transcoder job which converts media files in BOS buckets with specified preset. * @@ -317,19 +526,16 @@ public CreateTranscodingJobResponse createTranscodingJob( * @return The newly created job ID. */ public CreateTranscodingJobResponse createTranscodingJob(CreateTranscodingJobRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPipelineName(), - "The parameter pipelineName should NOT be null or empty string."); - checkNotNull(request.getSource(), "The parameter source should NOT be null."); - checkStringNotEmpty(request.getSource().getSourceKey(), - "The parameter sourceKey should NOT be null or empty string."); - checkNotNull(request.getTarget(), "The parameter target should NOT be null."); + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); + checkNotNull(request.getSource(), checkEmptyExceptionMessageFormat(SOURCE_MESSAGE_KEY)); + checkNotNull(request.getTarget(), checkEmptyExceptionMessageFormat(TARGET_MESSAGE_KEY)); checkStringNotEmpty(request.getTarget().getTargetKey(), - "The parameter targetKey should NOT be null or empty string."); + checkEmptyExceptionMessageFormat(TARGETKEY_MESSAGE_KEY)); checkStringNotEmpty(request.getTarget().getPresetName(), - "The parameter presetName should NOT be null or empty string."); - + checkEmptyExceptionMessageFormat(PRESETNAME_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, TRANSCODE_JOB); return invokeHttpClient(internalRequest, CreateTranscodingJobResponse.class); @@ -356,11 +562,12 @@ public ListTranscodingJobsResponse listTranscodingJobs(String pipelineName) { * @return The list of job IDs. */ public ListTranscodingJobsResponse listTranscodingJobs(ListTranscodingJobsRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPipelineName(), - "The parameter pipelineName should NOT be null or empty string."); + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, TRANSCODE_JOB); - internalRequest.addParameter("pipelineName", request.getPipelineName()); + internalRequest.addParameter(PIPELINENAME_MESSAGE_KEY, request.getPipelineName()); return invokeHttpClient(internalRequest, ListTranscodingJobsResponse.class); } @@ -385,8 +592,9 @@ public GetTranscodingJobResponse getTranscodingJob(String jobId) { * @return The status of a job. */ public GetTranscodingJobResponse getTranscodingJob(GetTranscodingJobRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - checkStringNotEmpty(request.getJobId(), "The parameter jobId should NOT be null or empty string."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getJobId(), + checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, TRANSCODE_JOB, request.getJobId()); return invokeHttpClient(internalRequest, GetTranscodingJobResponse.class); @@ -416,7 +624,12 @@ public CreatePipelineResponse createPipeline( */ public CreatePipelineResponse createPipeline( String pipelineName, String sourceBucket, String targetBucket) { - return createPipeline(pipelineName, null, sourceBucket, targetBucket, DEFAULT_PIPELINE_CAPACITY); + CreatePipelineRequest request = new CreatePipelineRequest(); + request.setPipelineName(pipelineName); + request.setDescription(""); + request.setSourceBucket(sourceBucket); + request.setTargetBucket(targetBucket); + return createPipeline(request); } /** @@ -468,23 +681,38 @@ public CreatePipelineResponse createPipeline( * */ public CreatePipelineResponse createPipeline(CreatePipelineRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - checkStringNotEmpty(request.getPipelineName(), - "The parameter pipelineName should NOT be null or empty string."); - checkStringNotEmpty(request.getSourceBucket(), - "The parameter sourceBucket should NOT be null or empty string."); - checkStringNotEmpty(request.getTargetBucket(), - "The parameter targetBucket should NOT be null or empty string."); - if (request.getConfig() == null || request.getConfig().getCapacity() == null) { - PipelineConfig config = new PipelineConfig(); - config.setCapacity(DEFAULT_PIPELINE_CAPACITY); - request.setConfig(config); - } + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPipelineName(), + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getSourceBucket(), + checkEmptyExceptionMessageFormat(SOURCEBUCKET_MESSAGE_KEY)); + checkStringNotEmpty(request.getTargetBucket(), + checkEmptyExceptionMessageFormat(TARGETBUCKET_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, PIPELINE); return invokeHttpClient(internalRequest, CreatePipelineResponse.class); } + /** + * Creates a pipeline which enable you to perform multiple transcodes in parallel. + * + * @param request The request object containing all options for creating new pipeline. + * + */ + public UpdatePipelineResponse updatePipeline(UpdatePipelineRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPipelineName(), + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); + checkStringNotEmpty(request.getSourceBucket(), + checkEmptyExceptionMessageFormat(SOURCEBUCKET_MESSAGE_KEY)); + checkStringNotEmpty(request.getTargetBucket(), + checkEmptyExceptionMessageFormat(TARGETBUCKET_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request + , PIPELINE, request.getPipelineName()); + + return invokeHttpClient(internalRequest, UpdatePipelineResponse.class); + } + /** * List all your pipelines. * @@ -503,7 +731,7 @@ public ListPipelinesResponse listPipelines() { * @return The list of all your pipelines */ public ListPipelinesResponse listPipelines(ListPipelinesRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PIPELINE); return invokeHttpClient(internalRequest, ListPipelinesResponse.class); } @@ -529,9 +757,9 @@ public GetPipelineResponse getPipeline(String pipelineName) { * @return The information of your pipeline. */ public GetPipelineResponse getPipeline(GetPipelineRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - checkStringNotEmpty(request.getPipelineName(), - "The parameter pipelineName should NOT be null or empty string."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPipelineName(), + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PIPELINE, request.getPipelineName()); @@ -557,9 +785,9 @@ public void deletePipeline(String pipelineName) { * */ public void deletePipeline(DeletePipelineRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - checkStringNotEmpty(request.getPipelineName(), - "The parameter pipelineName should NOT be null or empty string."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPipelineName(), + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.DELETE, request, PIPELINE, request.getPipelineName()); @@ -798,19 +1026,68 @@ public CreatePresetResponse createPreset( return createPreset(request); } + /** + * Create a preset which help to convert media files on be played in a wide range of devices. This version + * contains all parameters for creating a preset except watermarkId, since watermarks and watermarkId is conflict. + * + * @param presetName The name of the new preset. + * @param description The description of the new preset + * @param container The container type for the output file. Valid values include mp4, flv, hls, mp3, m4a. + * @param transmux If true, means only convert source media file to a different container format without changing + * the file contents. + * @param clip The clip property of the preset. + * @param audio Specify the audio format of target file. + * @param video Specify the video format of target file. + * @param encryption Specify the encryption property of target file. + * @param watermarks Specify the watermarks. + * @param transCfg Specify the transcoding configuration. + * @param extraCfg Specify the extra configuration. + * + */ + public CreatePresetResponse createPreset( + String presetName, String description, String container, boolean transmux, Clip clip, Audio audio, + Video video, Encryption encryption, Watermarks watermarks, TransCfg transCfg, ExtraCfg extraCfg) { + CreatePresetRequest request = new CreatePresetRequest(); + request.setPresetName(presetName); + request.setDescription(description); + request.setContainer(container); + request.setTransmux(transmux); + request.setClip(clip); + request.setAudio(audio); + request.setVideo(video); + request.setEncryption(encryption); + request.setWatermarks(watermarks); + request.setTransCfg(transCfg); + request.setExtraCfg(extraCfg); + + return createPreset(request); + } + /** * Create a preset which help to convert media files on be played in a wide range of devices. * * @param request The request object containing all options for deleting presets. */ public CreatePresetResponse createPreset(CreatePresetRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, PRESET); return invokeHttpClient(internalRequest, CreatePresetResponse.class); } + /** + * Update a preset. + * + * @param request The request object containing all options for updating presets. + */ + public UpdatePresetResponse updatePreset(UpdatePresetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(HttpMethodName.PUT, + request, PRESET, request.getPresetName()); + return invokeHttpClient(internalRequest, UpdatePresetResponse.class); + } + /** * List all system and user's preset. * @@ -829,7 +1106,7 @@ public ListPresetsResponse listPresets() { * @return The list of all available preset. */ public ListPresetsResponse listPresets(ListPresetsRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PRESET); return invokeHttpClient(internalRequest, ListPresetsResponse.class); } @@ -855,8 +1132,9 @@ public GetPresetResponse getPreset(String presetName) { * @return The information of the preset. */ public GetPresetResponse getPreset(GetPresetRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - checkStringNotEmpty(request.getPresetName(), "The parameter presetName should NOT be null or empty string."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPresetName(), + checkEmptyExceptionMessageFormat(PRESETNAME_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PRESET, request.getPresetName()); return invokeHttpClient(internalRequest, GetPresetResponse.class); @@ -881,8 +1159,9 @@ public void deletePreset(String presetName) { * */ public void deletePreset(DeletePresetRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - checkStringNotEmpty(request.getPresetName(), "The parameter presetName should NOT be null or empty string."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPresetName(), + checkEmptyExceptionMessageFormat(PRESETNAME_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.DELETE, request, PRESET, request.getPresetName()); @@ -912,17 +1191,18 @@ public GetMediaInfoOfFileResponse getMediaInfoOfFile(String bucket, String key) * @return The media information of an object in Bos bucket. */ public GetMediaInfoOfFileResponse getMediaInfoOfFile(GetMediaInfoOfFileRequest request) { - checkNotNull(request, "The parameter request should NOT be null."); - checkStringNotEmpty(request.getBucket(), "The parameter bucket should NOT be null or empty string."); - checkStringNotEmpty(request.getKey(), "The parameter key should NOT be null or empty string."); + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getBucket(), + checkEmptyExceptionMessageFormat(BUCKET_MESSAGE_KEY)); + checkStringNotEmpty(request.getKey(), checkEmptyExceptionMessageFormat(KEY_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, MEDIAINFO); - internalRequest.addParameter("bucket", request.getBucket()); - internalRequest.addParameter("key", request.getKey()); + internalRequest.addParameter(BUCKET_MESSAGE_KEY, request.getBucket()); + internalRequest.addParameter(KEY_MESSAGE_KEY, request.getKey()); return invokeHttpClient(internalRequest, GetMediaInfoOfFileResponse.class); } /** - * Creates a water mark and return water mark ID. + * Creates a watermark and return water mark ID. * * @param bucket The bucket name of Bos object which you want to read. * @param key The key name of Bos object which your want to read. @@ -943,7 +1223,7 @@ public CreateWaterMarkResponse createWaterMark( } /** - * Creates a water mark and return water mark ID. + * Creates a watermark and return water mark ID. * * @param bucket The bucket name of Bos object which you want to read. * @param key The key name of Bos object which your want to read. @@ -964,7 +1244,7 @@ public CreateWaterMarkResponse createWaterMark( } /** - * Creates a water mark and return water mark ID. + * Creates a watermark and return water mark ID. * * @param bucket The bucket name of Bos object which you want to read. * @param key The key name of Bos object which your want to read. @@ -988,7 +1268,132 @@ public CreateWaterMarkResponse createWaterMark( return createWaterMark(request); } - + + /** + * Creates a watermark and return water mark ID. + * + * @param bucket The bucket name of Bos object which you want to read. + * @param key The key name of Bos object which your want to read. + * @param horizontalAlignment The horizontal alignment, includes left, center, right. + * @param verticalAlignment The vertical alignment, includes top, center, bottom. + * @param dx The horizontal offset. + * @param dy The vertical offset. + * + * @return watermarkId the unique ID of the new water mark. + */ + public CreateWaterMarkResponse createWaterMark( + String bucket, String key, String horizontalAlignment, String verticalAlignment, + String dx, String dy) { + + CreateWaterMarkRequest request = + new CreateWaterMarkRequest().withBucket(bucket).withKey(key) + .withHorizontalAlignment(horizontalAlignment) + .withVerticalAlignment(verticalAlignment) + .withDx(dx) + .withDy(dy); + + return createWaterMark(request); + } + + /** + * Creates a watermark and return water mark ID. + * + * @param bucket The bucket name of Bos object which you want to read. + * @param key The key name of Bos object which your want to read. + * @param horizontalAlignment The horizontal alignment, includes left, center, right. + * @param verticalAlignment The vertical alignment, includes top, center, bottom. + * @param dx The horizontal offset. + * @param dy The vertical offset. + * @param width The width of watermark. + * @param height The height of watermark. + * + * @return watermarkId the unique ID of the new water mark. + */ + public CreateWaterMarkResponse createWaterMark( + String bucket, String key, String horizontalAlignment, String verticalAlignment, + String dx, String dy, String width, String height) { + + CreateWaterMarkRequest request = + new CreateWaterMarkRequest().withBucket(bucket).withKey(key) + .withHorizontalAlignment(horizontalAlignment) + .withVerticalAlignment(verticalAlignment) + .withDx(dx) + .withDy(dy) + .withWidth(width) + .withHeight(height); + + return createWaterMark(request); + } + + /** + * Creates a watermark and return water mark ID. + * + * @param bucket The bucket name of Bos object which you want to read. + * @param key The key name of Bos object which your want to read. + * @param horizontalAlignment The horizontal alignment, includes left, center, right. + * @param verticalAlignment The vertical alignment, includes top, center, bottom. + * @param horizontalOffsetInPixel The horizontal offset in pixels. + * @param verticalOffsetInPixel The vertical offset in pixels. + * @param timeline The vertical offset in pixels. + * @param repeated The vertical offset in pixels. + * @param allowScaling The vertical offset in pixels. + * + * @return watermarkId the unique ID of the new water mark. + */ + public CreateWaterMarkResponse createWaterMark( + String bucket, String key, String horizontalAlignment, String verticalAlignment, + int horizontalOffsetInPixel, int verticalOffsetInPixel, + Timeline timeline, Integer repeated, Boolean allowScaling) { + + CreateWaterMarkRequest request = + new CreateWaterMarkRequest().withBucket(bucket).withKey(key) + .withHorizontalAlignment(horizontalAlignment) + .withVerticalAlignment(verticalAlignment) + .withHorizontalOffsetInPixel(horizontalOffsetInPixel) + .withVerticalOffsetInPixel(verticalOffsetInPixel) + .withTimeline(timeline) + .withRepeated(repeated) + .withAllowScaling(allowScaling); + + return createWaterMark(request); + } + + /** + * Creates a watermark and return water mark ID. + * + * @param bucket The bucket name of Bos object which you want to read. + * @param key The key name of Bos object which your want to read. + * @param horizontalAlignment The horizontal alignment, includes left, center, right. + * @param verticalAlignment The vertical alignment, includes top, center, bottom. + * @param dx The horizontal offset. + * @param dy The vertical offset. + * @param width The width of watermark. + * @param height The height of watermark. + * @param timeline The vertical offset in pixels. + * @param repeated The vertical offset in pixels. + * + * @return watermarkId the unique ID of the new water mark. + */ + public CreateWaterMarkResponse createWaterMark( + String bucket, String key, String horizontalAlignment, String verticalAlignment, + String dx, String dy, String width, String height, + Timeline timeline, Integer repeated) { + + CreateWaterMarkRequest request = + new CreateWaterMarkRequest().withBucket(bucket).withKey(key) + .withHorizontalAlignment(horizontalAlignment) + .withVerticalAlignment(verticalAlignment) + .withDx(dx) + .withDy(dy) + .withWidth(width) + .withHeight(height) + .withTimeline(timeline) + .withRepeated(repeated); + + return createWaterMark(request); + } + + /** * Creates a water mark and return water mark ID * @@ -997,8 +1402,9 @@ public CreateWaterMarkResponse createWaterMark( * @return watermarkId the unique ID of the new water mark. */ public CreateWaterMarkResponse createWaterMark(CreateWaterMarkRequest request) { - checkStringNotEmpty(request.getBucket(), "The parameter bucket should NOT be null or empty string."); - checkStringNotEmpty(request.getKey(), "The parameter key should NOT be null or empty string."); + checkStringNotEmpty(request.getBucket(), + checkEmptyExceptionMessageFormat(BUCKET_MESSAGE_KEY)); + checkStringNotEmpty(request.getKey(), checkEmptyExceptionMessageFormat(KEY_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, WATER_MARK); return invokeHttpClient(internalRequest, CreateWaterMarkResponse.class); @@ -1023,7 +1429,7 @@ public GetWaterMarkResponse getWaterMark(String watermarkId) { * @return The information of the water mark. */ public GetWaterMarkResponse getWaterMark(GetWaterMarkRequest request) { - checkStringNotEmpty(request.getWatermarkId(), "The parameter watermarkId should NOT be null or empty string."); + checkStringNotEmpty(request.getWatermarkId(), checkEmptyExceptionMessageFormat(WATERMARKID_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, WATER_MARK, request.getWatermarkId()); @@ -1071,7 +1477,7 @@ public void deleteWaterMark(String watermarkId) { * */ public void deleteWaterMark(DeleteWaterMarkRequest request) { - checkStringNotEmpty(request.getWatermarkId(), "The parameter watermarkId should NOT be null or empty string."); + checkStringNotEmpty(request.getWatermarkId(), checkEmptyExceptionMessageFormat(WATERMARKID_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.DELETE, request, WATER_MARK, request.getWatermarkId()); @@ -1100,45 +1506,177 @@ public CreateThumbnailJobResponse createThumbnailJob( return createThumbnailJob(request); } - + /** * Creates a thumbnail job and return job ID. * * @param pipelineName The name of a pipeline. + * @param presetName The name of a thumbnail preset. * @param sourceKey The key of source object. + * @param targetKeyPrefix The property container of target object. * * @return the unique ID of the new thumbnail job. */ - public CreateThumbnailJobResponse createThumbnailJob(String pipelineName, String sourceKey) { + public CreateThumbnailJobResponse createThumbnailJob(String pipelineName, String presetName, String sourceKey, + String targetKeyPrefix) { + ThumbnailSource source = new ThumbnailSource(); source.setKey(sourceKey); + + ThumbnailTarget target = new ThumbnailTarget(); + target.setKeyPrefix(targetKeyPrefix); CreateThumbnailJobRequest request = - new CreateThumbnailJobRequest().withPipelineName(pipelineName).withSource(source); - + new CreateThumbnailJobRequest().withPipelineName(pipelineName).withPresetName(presetName) + .withSource(source).withTarget(target); + return createThumbnailJob(request); } - + /** * Creates a thumbnail job and return job ID. * - * @param request The request object containing all options for creating new water mark. + * @param pipelineName The name of a pipeline. + * @param presetName The name of a thumbnail preset. + * @param sourceKey The key of source object. + * @param targetKeyPrefix The property container of target object. + * @param delogoArea The property container of delogo Area. * * @return the unique ID of the new thumbnail job. */ - public CreateThumbnailJobResponse createThumbnailJob(CreateThumbnailJobRequest request) { - checkStringNotEmpty(request.getPipelineName(), - "The parameter pipelineName should NOT be null or empty string."); - checkNotNull(request.getSource(), "The parameter source should NOT be null."); - checkStringNotEmpty(request.getSource().getKey(), - "The parameter source key should NOT be null or empty string."); - InternalRequest internalRequest = - createRequest(HttpMethodName.POST, request, THUMBNAIL); + public CreateThumbnailJobResponse createThumbnailJob(String pipelineName, String presetName, String sourceKey, + String targetKeyPrefix, Area delogoArea) { - return invokeHttpClient(internalRequest, CreateThumbnailJobResponse.class); - } - - /** + ThumbnailSource source = new ThumbnailSource(); + source.setKey(sourceKey); + + ThumbnailTarget target = new ThumbnailTarget(); + target.setKeyPrefix(targetKeyPrefix); + + CreateThumbnailJobRequest request = + new CreateThumbnailJobRequest().withPipelineName(pipelineName).withPresetName(presetName) + .withSource(source).withTarget(target).withDelogoArea(delogoArea); + + return createThumbnailJob(request); + } + + /** + * Creates a thumbnail job and return job ID. + * + * @param pipelineName The name of a pipeline. + * @param presetName The name of a thumbnail preset. + * @param sourceKey The key of source object. + * @param targetKeyPrefix The property container of target object. + * @param delogoArea The property container of delogo Area. + * @param crop The property container of crop Area. + * + * @return the unique ID of the new thumbnail job. + */ + public CreateThumbnailJobResponse createThumbnailJob(String pipelineName, String presetName, String sourceKey, + String targetKeyPrefix, Area delogoArea, Area crop) { + + ThumbnailSource source = new ThumbnailSource(); + source.setKey(sourceKey); + + ThumbnailTarget target = new ThumbnailTarget(); + target.setKeyPrefix(targetKeyPrefix); + + CreateThumbnailJobRequest request = + new CreateThumbnailJobRequest().withPipelineName(pipelineName).withPresetName(presetName) + .withSource(source).withTarget(target).withDelogoArea(delogoArea).withCrop(crop); + + return createThumbnailJob(request); + } + + /** + * Creates a thumbnail job and return job ID. + * + * @param pipelineName The name of a pipeline. + * @param sourceKey The key of source object. + * @param target The property container of target object. + * @param capture The property container of thumbnail generating policies. + * @param delogoArea The property container of delogo Area. + * + * @return the unique ID of the new thumbnail job. + */ + public CreateThumbnailJobResponse createThumbnailJob( + String pipelineName, String sourceKey, ThumbnailTarget target, + ThumbnailCapture capture, Area delogoArea) { + + ThumbnailSource source = new ThumbnailSource(); + source.setKey(sourceKey); + + CreateThumbnailJobRequest request = + new CreateThumbnailJobRequest().withPipelineName(pipelineName).withSource(source).withTarget(target) + .withCapture(capture).withDelogoArea(delogoArea); + + return createThumbnailJob(request); + } + + /** + * Creates a thumbnail job and return job ID. + * + * @param pipelineName The name of a pipeline. + * @param sourceKey The key of source object. + * @param target The property container of target object. + * @param capture The property container of thumbnail generating policies. + * @param delogoArea The property container of delogo Area. + * @param crop The property container of crop Area. + * + * @return the unique ID of the new thumbnail job. + */ + public CreateThumbnailJobResponse createThumbnailJob( + String pipelineName, String sourceKey, ThumbnailTarget target, + ThumbnailCapture capture, Area delogoArea, Area crop) { + + ThumbnailSource source = new ThumbnailSource(); + source.setKey(sourceKey); + + CreateThumbnailJobRequest request = + new CreateThumbnailJobRequest().withPipelineName(pipelineName).withSource(source).withTarget(target) + .withCapture(capture).withDelogoArea(delogoArea).withCrop(crop); + + return createThumbnailJob(request); + } + + /** + * Creates a thumbnail job and return job ID. + * + * @param pipelineName The name of a pipeline. + * @param sourceKey The key of source object. + * + * @return the unique ID of the new thumbnail job. + */ + public CreateThumbnailJobResponse createThumbnailJob(String pipelineName, String sourceKey) { + ThumbnailSource source = new ThumbnailSource(); + source.setKey(sourceKey); + + CreateThumbnailJobRequest request = + new CreateThumbnailJobRequest().withPipelineName(pipelineName).withSource(source); + + return createThumbnailJob(request); + } + + /** + * Creates a thumbnail job and return job ID. + * + * @param request The request object containing all options for creating new water mark. + * + * @return the unique ID of the new thumbnail job. + */ + public CreateThumbnailJobResponse createThumbnailJob(CreateThumbnailJobRequest request) { + checkStringNotEmpty(request.getPipelineName(), + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); + checkNotNull(request.getSource(), checkEmptyExceptionMessageFormat(SOURCE_MESSAGE_KEY)); + checkStringNotEmpty(request.getSource().getKey(), + checkEmptyExceptionMessageFormat(SOURCEKEY_MESSAGE_KEY)); + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, THUMBNAIL); + + return invokeHttpClient(internalRequest, CreateThumbnailJobResponse.class); + } + + /** * Get information of thumbnail job. * * @param jobId The unique ID of thumbnail job. @@ -1159,7 +1697,7 @@ public GetThumbnailJobResponse getThumbnailJob(String jobId) { * @return The information of the thumbnail job. */ public GetThumbnailJobResponse getThumbnailJob(GetThumbnailJobRequest request) { - checkStringNotEmpty(request.getJobId(), "The parameter jobId should NOT be null or empty string."); + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, THUMBNAIL, request.getJobId()); @@ -1187,11 +1725,72 @@ public ListThumbnailJobsResponse listThumbnailJobs(String pipelineName) { * @return List of thumbnail jobs. */ public ListThumbnailJobsResponse listThumbnailJobs(ListThumbnailJobsRequest request) { - checkStringNotEmpty(request.getPipeline(), "The parameter pipelineName should NOT be null or empty string."); + checkStringNotEmpty(request.getPipeline(), checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, THUMBNAIL); - internalRequest.addParameter("pipelineName", request.getPipeline()); + internalRequest.addParameter(PIPELINENAME_MESSAGE_KEY, request.getPipeline()); return invokeHttpClient(internalRequest, ListThumbnailJobsResponse.class); } + + /** + * get a notification. + * + * @param name notification name + */ + public GetNotificationResponse getNotification(String name) { + checkNotNull(name, checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + + GetNotificationRequest request = new GetNotificationRequest() + .withName(name); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request + , NOTIFICATION, request.getName()); + + return invokeHttpClient(internalRequest, GetNotificationResponse.class); + } + + /** + * list all notifications. + * + */ + public ListNotificationsResponse listNotification() { + ListNotificationsRequest request = new ListNotificationsRequest(); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, NOTIFICATION); + return invokeHttpClient(internalRequest, ListNotificationsResponse.class); + } + + /** + * Create a notification. + * + * @param name notification name + * @param endpoint notification endpoint + */ + public CreateNotificationResponse createNotification(String name, String endpoint) { + checkNotNull(name, checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + checkNotNull(endpoint, checkEmptyExceptionMessageFormat(ENDPOINT_MESSAGE_KEY)); + + CreateNotificationRequest request = new CreateNotificationRequest() + .withName(name) + .withEndpoint(endpoint); + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, NOTIFICATION); + + return invokeHttpClient(internalRequest, CreateNotificationResponse.class); + } + + /** + * Delete a notification. + * + * @param name notification name + */ + public DeleteNotificationResponse deleteNotification(String name) { + checkNotNull(name, checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + + DeleteNotificationRequest request = new DeleteNotificationRequest() + .withName(name); + InternalRequest internalRequest = createRequest(HttpMethodName.DELETE, request + , NOTIFICATION, request.getName()); + + return invokeHttpClient(internalRequest, DeleteNotificationResponse.class); + } + /** * Creates and initializes a new request object for the specified resource. @@ -1231,7 +1830,8 @@ private InternalRequest createRequest( InternalRequest internalRequest = new InternalRequest(httpMethod, uri); internalRequest.setCredentials(request.getRequestCredentials()); - if (httpMethod == HttpMethodName.POST) { + if (httpMethod == HttpMethodName.POST + || httpMethod == HttpMethodName.PUT) { fillRequestPayload(internalRequest, request); } return internalRequest; @@ -1253,5 +1853,306 @@ private InternalRequest fillRequestPayload(InternalRequest internalRequest, Abst return internalRequest; } + /** + * Create a thumbnail preset which help to convert video files to be pictures. + * + * @param presetName The name of the new preset. + * @param description The description of the new preset + * @param target The output config of the preset. + * @param capture The capture mode of the preset; + */ + public CreateThumbnailPresetResponse createThumbnailPreset(String presetName, String description, + ThumbnailPresetTarget target, ThumbnailPresetCapture capture) { + return createThumbnailPreset(new CreateThumbnailPresetRequest() + .withDescription(description) + .withPresetName(presetName) + .withTarget(target) + .withCapture(capture)); + } + + /** + * Create a thumbnail preset which help to convert video files to be pictures. + * + * @param request The request object containing all options for presets. + */ + public CreateThumbnailPresetResponse createThumbnailPreset(CreateThumbnailPresetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, THUMBNAIL_PRESET); + + return invokeHttpClient(internalRequest, CreateThumbnailPresetResponse.class); + } + + /** + * Delete a thumbnail preset with specified name. + * + * @param presetName The name of a preset. + * + */ + public void deleteThumbnailPreset(String presetName) { + DeleteThumbnailPresetRequest request = new DeleteThumbnailPresetRequest(); + request.setPresetName(presetName); + deleteThumbnailPreset(request); + } + + /** + * Delete a thumbnail preset with specified name. + * + * @param request The request object containing all options for deleting a preset. + * + */ + public void deleteThumbnailPreset(DeleteThumbnailPresetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPresetName(), + checkEmptyExceptionMessageFormat(PRESETNAME_MESSAGE_KEY)); + InternalRequest internalRequest = + createRequest(HttpMethodName.DELETE, request, THUMBNAIL_PRESET, request.getPresetName()); + + invokeHttpClient(internalRequest, DeletePresetResponse.class); + + } + + /** + * Get a thumbnail preset with specified name. + * + * @param presetName The name of a preset. + * + * @return The information of the preset. + */ + public GetThumbnailPresetResponse getThumbnailPreset(String presetName) { + GetThumbnailPresetRequest request = new GetThumbnailPresetRequest(); + request.setPresetName(presetName); + return getThumbnailPreset(request); + } + + /** + * Get a thumbnail preset with specified name. + * + * @param request The request object containing all options for getting a thumbnail preset. + * + * @return The information of the thumbnail preset. + */ + public GetThumbnailPresetResponse getThumbnailPreset(GetThumbnailPresetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getPresetName(), + checkEmptyExceptionMessageFormat(PRESETNAME_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, THUMBNAIL_PRESET, + request.getPresetName()); + + return invokeHttpClient(internalRequest, GetThumbnailPresetResponse.class); + } + + /** + * Update a thumbnail preset. + * + * @param request The request object containing all options for updating presets. + */ + public UpdateThumbnailPresetResponse updateThumbnailPreset(UpdateThumbnailPresetRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(HttpMethodName.PUT, + request, THUMBNAIL_PRESET, request.getPresetName()); + return invokeHttpClient(internalRequest, UpdateThumbnailPresetResponse.class); + } + + /** + * List all user's thumbnail preset. + * + * @return The list of all available thumbnail preset. + */ + public ListThumbnailPresetsResponse listThumbnailPresets() { + ListThumbnailPresetsRequest request = new ListThumbnailPresetsRequest(); + return listThumbnailPresets(request); + } + + /** + * List all user's thumbnail preset. + * + * @param request The request object containing all options for listing presets. + * + * @return The list of all available thumbnail preset. + */ + public ListThumbnailPresetsResponse listThumbnailPresets(ListThumbnailPresetsRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, THUMBNAIL_PRESET); + return invokeHttpClient(internalRequest, ListThumbnailPresetsResponse.class); + } + + /** + * Creates a subtitle job and return job ID. + * + * @param request The request object containing all options for creating new subtitle job. + * + * @return the unique ID of the new subtitle job. + */ + public CreateSubtitleJobResponse createSubtitleJob(CreateSubtitleJobRequest request) { + checkStringNotEmpty(request.getPipelineName(), + checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); + checkNotNull(request.getSource(), checkEmptyExceptionMessageFormat(SOURCE_MESSAGE_KEY)); + checkStringNotEmpty(request.getSource().getKey(), + checkEmptyExceptionMessageFormat(SOURCEKEY_MESSAGE_KEY)); + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, SUBTITLE); + + return invokeHttpClient(internalRequest, CreateSubtitleJobResponse.class); + } + + /** + * Creates a subtitle job and return job ID. + * + * @param pipelineName The name of a pipeline. + * @param sourceKey The key of source object. + * @param targetKeyPrefix The key prefix of target subtitle file in bos. + * + * @return the unique ID of the new subtitle job. + */ + public CreateSubtitleJobResponse createSubtitleJob( + String pipelineName, String sourceKey, String targetKeyPrefix) { + + SubtitleSource source = new SubtitleSource(); + source.setKey(sourceKey); + + SubtitleTarget target = new SubtitleTarget(); + target.setKeyPrefix(targetKeyPrefix); + + CreateSubtitleJobRequest request = + new CreateSubtitleJobRequest().withPipelineName(pipelineName).withSource(source).withTarget(target); + + return createSubtitleJob(request); + } + + /** + * Creates a subtitle job and return job ID. + * + * @param pipelineName The name of a pipeline. + * @param sourceKey The key of source object. + * @param targetKeyPrefix The key prefix of target subtitle file in bos. + * @param format The format of subtitle file, can be json / srt. + * + * @return the unique ID of the new subtitle job. + */ + public CreateSubtitleJobResponse createSubtitleJob( + String pipelineName, String sourceKey, String targetKeyPrefix, String format) { + + SubtitleSource source = new SubtitleSource(); + source.setKey(sourceKey); + + SubtitleTarget target = new SubtitleTarget(); + target.setKeyPrefix(targetKeyPrefix); + target.addFormat(format); + + CreateSubtitleJobRequest request = + new CreateSubtitleJobRequest().withPipelineName(pipelineName).withSource(source).withTarget(target); + + return createSubtitleJob(request); + } + + /** + * Creates a subtitle job and return job ID. + * + * @param pipelineName The name of a pipeline. + * @param sourceKey The key of source object. + * @param targetKeyPrefix The key prefix of target subtitle file in bos. + * @param formats The format of subtitle file, can be json / srt. + * + * @return the unique ID of the new subtitle job. + */ + public CreateSubtitleJobResponse createSubtitleJob( + String pipelineName, String sourceKey, String targetKeyPrefix, List formats) { + + SubtitleSource source = new SubtitleSource(); + source.setKey(sourceKey); + + SubtitleTarget target = new SubtitleTarget(); + target.setKeyPrefix(targetKeyPrefix); + target.setFormats(formats); + + CreateSubtitleJobRequest request = + new CreateSubtitleJobRequest().withPipelineName(pipelineName).withSource(source).withTarget(target); + + return createSubtitleJob(request); + } + + + /** + * Get information of subtitle job. + * + * @param jobId The unique ID of subtitle job. + * + * @return The information of the subtitle job. + */ + public GetSubtitleJobResponse getSubtitleJob(String jobId) { + GetSubtitleJobRequest request = new GetSubtitleJobRequest().withJobId(jobId); + + return getSubtitleJob(request); + } + + /** + * Get information of subtitle job. + * + * @param request The request object containing all options for getting a subtitle job. + * + * @return The information of the subtitle job. + */ + public GetSubtitleJobResponse getSubtitleJob(GetSubtitleJobRequest request) { + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); + InternalRequest internalRequest = + createRequest(HttpMethodName.GET, request, SUBTITLE, request.getJobId()); + + return invokeHttpClient(internalRequest, GetSubtitleJobResponse.class); + } + + + /** + * List subtitle jobs for a given pipeline. + * + * @param pipelineName The name of a pipeline. + * + * @return List of subtitle jobs. + */ + public ListSubtitleJobsResponse listSubtitleJobs(String pipelineName) { + ListSubtitleJobsRequest request = new ListSubtitleJobsRequest().withPipeline(pipelineName); + + return listSubtitleJobs(request); + } + + /** + * List subtitle jobs for a given pipeline. + * + * @param request The request object containing all options for getting subtitle jobs. + * + * @return List of subtitle jobs. + */ + public ListSubtitleJobsResponse listSubtitleJobs(ListSubtitleJobsRequest request) { + checkStringNotEmpty(request.getPipeline(), checkEmptyExceptionMessageFormat(PIPELINENAME_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, SUBTITLE); + internalRequest.addParameter(PIPELINENAME_MESSAGE_KEY, request.getPipeline()); + return invokeHttpClient(internalRequest, ListSubtitleJobsResponse.class); + } + + /** + * Get transcoding job encryption key + * + * @param request The request object containing all options for getting encryption key. + * + * @return Response Object contains transcoding encryption Aes key. + */ + public GetTranscodingEncryptionKeyResponse getTranscodingEncryptionKey(GetTranscodingEncryptionKeyRequest request) { + checkStringNotEmpty(request.getJobId(), checkEmptyExceptionMessageFormat(JOBID_MESSAGE_KEY)); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, + request, TRANSCODING_KEY, request.getJobId()); + + return invokeHttpClient(internalRequest, GetTranscodingEncryptionKeyResponse.class); + } + + /** + * Get transcoding job encryption key + * + * @param jobId The job ID want to query transcoding encryption key. + * + * @return Response Object contains transcoding encryption Aes keyl. + */ + public GetTranscodingEncryptionKeyResponse getTranscodingEncryptionKey(String jobId) { + return getTranscodingEncryptionKey(new GetTranscodingEncryptionKeyRequest().withJobId(jobId)); + } -} \ No newline at end of file +} diff --git a/src/main/java/com/baidubce/services/media/MediaEncryptionKeyResponseHandler.java b/src/main/java/com/baidubce/services/media/MediaEncryptionKeyResponseHandler.java new file mode 100644 index 00000000..4886f705 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/MediaEncryptionKeyResponseHandler.java @@ -0,0 +1,29 @@ +package com.baidubce.services.media; + +import java.io.InputStream; + +import com.baidubce.http.BceHttpResponse; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.media.model.GetTranscodingEncryptionKeyResponse; + +import org.apache.commons.io.IOUtils; + +public class MediaEncryptionKeyResponseHandler implements HttpResponseHandler { + + @Override + public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { + if (!(response instanceof GetTranscodingEncryptionKeyResponse)) { + return false; + } + InputStream inputStream = httpResponse.getContent(); + if (inputStream == null) { + return false; + } + GetTranscodingEncryptionKeyResponse keyResponse = (GetTranscodingEncryptionKeyResponse) response; + keyResponse.setEncryptionKey(IOUtils.toString(inputStream, "UTF-8")); + inputStream.close(); + return true; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/Area.java b/src/main/java/com/baidubce/services/media/model/Area.java new file mode 100644 index 00000000..9e2e90e3 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/Area.java @@ -0,0 +1,101 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +public class Area { + /** + * x from left + **/ + private Integer x = null; + + /** + * y from top + **/ + private Integer y = null; + + /** + * area width + **/ + private Integer width = null; + + /** + * area height + **/ + private Integer height = null; + + public Integer getX() { + return x; + } + + public void setX(Integer x) { + this.x = x; + } + + public Area withX(Integer x) { + this.x = x; + return this; + } + + public Integer getY() { + return y; + } + + public void setY(Integer y) { + this.y = y; + } + + public Area withY(Integer y) { + this.y = y; + return this; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public Area withWidth(Integer width) { + this.width = width; + return this; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + public Area withHeight(Integer height) { + this.height = height; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Area {\n"); + + sb.append(" x: ").append(x).append("\n"); + sb.append(" y: ").append(y).append("\n"); + sb.append(" width: ").append(width).append("\n"); + sb.append(" height: ").append(height).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/Audio.java b/src/main/java/com/baidubce/services/media/model/Audio.java index 02c26735..68429b5f 100644 --- a/src/main/java/com/baidubce/services/media/model/Audio.java +++ b/src/main/java/com/baidubce/services/media/model/Audio.java @@ -13,22 +13,145 @@ package com.baidubce.services.media.model; -public class Audio { - private Integer bitRateInBps = null; +import java.util.List; - // public enum bitRateInBpsEnum { }; +public class Audio { + /** + * audio target bitrate in bps + **/ + private Integer bitRateInBps = null; + /** + * audio sample rate in hz + **/ private Integer sampleRateInHz = null; - // public enum sampelRateInHzEnum { }; - - private Integer channels = null; + /** + * channels of audio + **/ + private Integer channels = null; - // public enum channelsEnum { }; + /** + * PCM format, options include s16le, can only be set when container is "pcm" + **/ + private String pcmFormat = null; /** - * 音频目标码率 + * settings about audio volume **/ + private VolumeAdjust volumeAdjust = null; + + /** + * setting about audio codec + */ + private String codec; + + private List mapping; + + private boolean mixAllTracks; + + private List tracks; + + public static class Tracks { + private int bitRateInBps; + private int sampleRateInHz; + private int channels; + private String codec; + private VolumeAdjust volumeAdjust; + private List mapping; + + public Tracks() { + } + + public int getBitRateInBps() { + return bitRateInBps; + } + + public void setBitRateInBps(int bitRateInBps) { + this.bitRateInBps = bitRateInBps; + } + + public int getSampleRateInHz() { + return sampleRateInHz; + } + + public void setSampleRateInHz(int sampleRateInHz) { + this.sampleRateInHz = sampleRateInHz; + } + + public int getChannels() { + return channels; + } + + public void setChannels(int channels) { + this.channels = channels; + } + + public String getCodec() { + return codec; + } + + public void setCodec(String codec) { + this.codec = codec; + } + + public VolumeAdjust getVolumeAdjust() { + return volumeAdjust; + } + + public void setVolumeAdjust(VolumeAdjust volumeAdjust) { + this.volumeAdjust = volumeAdjust; + } + + public List getMapping() { + return mapping; + } + + public void setMapping(List mapping) { + this.mapping = mapping; + } + } + + public static class InputIndex { + private int inputIndex; + private String padPolicy; + + public String getPadPolicy() { + return padPolicy; + } + + public void setPadPolicy(String padPolicy) { + this.padPolicy = padPolicy; + } + + public int getInputIndex() { + return inputIndex; + } + + public void setInputIndex(int inputIndex) { + this.inputIndex = inputIndex; + } + + public InputIndex() { + } + } + + public boolean isMixAllTracks() { + return mixAllTracks; + } + + public void setMixAllTracks(boolean mixAllTracks) { + this.mixAllTracks = mixAllTracks; + } + + public List getTracks() { + return tracks; + } + + public void setTracks(List tracks) { + this.tracks = tracks; + } + public Integer getBitRateInBps() { return bitRateInBps; } @@ -42,9 +165,6 @@ public Audio withBitRateInBps(Integer bitRateInBps) { return this; } - /** - * 音频采样率 - **/ public Integer getSampleRateInHz() { return sampleRateInHz; } @@ -58,9 +178,6 @@ public Audio withSampleRateInHz(Integer sampleRateInHz) { return this; } - /** - * 音频声道数目 - **/ public Integer getChannels() { return channels; } @@ -74,6 +191,48 @@ public Audio withChannels(Integer channels) { return this; } + public String getPcmFormat() { + return pcmFormat; + } + + public void setPcmFormat(String pcmFormat) { + this.pcmFormat = pcmFormat; + } + + public Audio withPcmFormat(String pcmFormat) { + this.pcmFormat = pcmFormat; + return this; + } + + public VolumeAdjust getVolumeAdjust() { + return volumeAdjust; + } + + public void setVolumeAdjust(VolumeAdjust volumeAdjust) { + this.volumeAdjust = volumeAdjust; + } + + public Audio withVolumeAdjust(VolumeAdjust volumeAdjust) { + this.volumeAdjust = volumeAdjust; + return this; + } + + public String getCodec() { + return codec; + } + + public void setCodec(String codec) { + this.codec = codec; + } + + public List getMapping() { + return mapping; + } + + public void setMapping(List mapping) { + this.mapping = mapping; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -82,6 +241,10 @@ public String toString() { sb.append(" bitRateInBps: ").append(bitRateInBps).append("\n"); sb.append(" sampleRateInHz: ").append(sampleRateInHz).append("\n"); sb.append(" channels: ").append(channels).append("\n"); + sb.append(" pcmFormat: ").append(pcmFormat).append("\n"); + sb.append(" volumeAdjust: ").append(volumeAdjust).append("\n"); + sb.append(" codec: ").append(codec).append("\n"); + sb.append(" mapping: ").append(mapping).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/CreateJobRequest.java b/src/main/java/com/baidubce/services/media/model/CreateJobRequest.java index 61983564..5a45a200 100644 --- a/src/main/java/com/baidubce/services/media/model/CreateJobRequest.java +++ b/src/main/java/com/baidubce/services/media/model/CreateJobRequest.java @@ -21,13 +21,21 @@ public class CreateJobRequest extends AbstractBceRequest { + /** + * the pipelineName of the job + **/ private String pipelineName = null; + + /** + * source information + **/ private Source source = null; - private Target target = null; /** - * 任务所属的pipelineName + * target and settings information **/ + private Target target = null; + public String getPipelineName() { return pipelineName; } @@ -43,9 +51,6 @@ public CreateJobRequest withPipelineName(String pipelineName) { return this; } - /** - * 输入的原始信息的集合 - **/ public Source getSource() { return source; } @@ -61,9 +66,6 @@ public CreateJobRequest withSource(Source source) { return this; } - /** - * 输出信息的结合 - **/ public Target getTarget() { return target; } diff --git a/src/main/java/com/baidubce/services/media/model/CreateNotificationRequest.java b/src/main/java/com/baidubce/services/media/model/CreateNotificationRequest.java new file mode 100644 index 00000000..72d238fe --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/CreateNotificationRequest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import static com.baidubce.services.media.MediaClient.ENDPOINT_MESSAGE_KEY; +import static com.baidubce.services.media.MediaClient.NAME_MESSAGE_KEY; +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkStringNotEmpty; + +/** + * The request for creating notification + */ +@Data +public class CreateNotificationRequest extends AbstractBceRequest { + + private String name = null; + private String endpoint = null; + + + public CreateNotificationRequest withName(String name) { + checkStringNotEmpty(name, checkEmptyExceptionMessageFormat(NAME_MESSAGE_KEY)); + this.name = name; + return this; + } + + public CreateNotificationRequest withEndpoint(String endpoint) { + checkStringNotEmpty(endpoint, checkEmptyExceptionMessageFormat(ENDPOINT_MESSAGE_KEY)); + this.endpoint = endpoint; + return this; + } + + public CreateNotificationRequest withRequestCredentials( + BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationRequest {\n"); + + sb.append("name: ").append(name).append("\n"); + sb.append("endpoint: ").append(endpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/CreateNotificationResponse.java b/src/main/java/com/baidubce/services/media/model/CreateNotificationResponse.java new file mode 100644 index 00000000..2af9fb0c --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/CreateNotificationResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for creating notification + */ +public class CreateNotificationResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/media/model/CreatePresetRequest.java b/src/main/java/com/baidubce/services/media/model/CreatePresetRequest.java index a830404f..cde33db0 100644 --- a/src/main/java/com/baidubce/services/media/model/CreatePresetRequest.java +++ b/src/main/java/com/baidubce/services/media/model/CreatePresetRequest.java @@ -20,20 +20,66 @@ import com.baidubce.model.AbstractBceRequest; public class CreatePresetRequest extends AbstractBceRequest { - + /** + * preset name + **/ private String presetName = null; + + /** + * preset description + **/ private String description = null; + + /** + * preset container, options include mp4, flv, hls, mp3, m4a, a-hls, pcm, dash + **/ private String container = null; + + /** + * transmux mode + **/ private Boolean transmux = null; + + /** + * clip source + **/ private Clip clip = null; + + /** + * audio settings + **/ private Audio audio = null; + + /** + * video settings + **/ private Video video = null; + + /** + * HLS encryption settings + **/ private Encryption encryption = null; + + /** + * watermark Id + **/ private String watermarkId = null; /** - * preset名称 + * multiple watermarks setting + **/ + private Watermarks watermarks = null; + + /** + * transcoding configurations **/ + private TransCfg transCfg = null; + + /** + * extra transcoding configurations + **/ + private ExtraCfg extraCfg = null; + public String getPresetName() { return presetName; } @@ -49,9 +95,6 @@ public CreatePresetRequest withPresetName(String presetName) { return this; } - /** - * preset详情描述 - **/ public String getDescription() { return description; } @@ -65,9 +108,6 @@ public CreatePresetRequest withDescription(String description) { return this; } - /** - * 音视频文件的容器(MP4, FLV, MOV, MP3, M4A) - **/ public String getContainer() { return container; } @@ -83,9 +123,6 @@ public CreatePresetRequest withContainer(String container) { return this; } - /** - * 是否仅执行容器格式转换 - **/ public Boolean getTransmux() { return transmux; } @@ -99,9 +136,6 @@ public CreatePresetRequest withTransmux(Boolean transmux) { return this; } - /** - * 片段截取设置 - **/ public Clip getClip() { return clip; } @@ -115,9 +149,6 @@ public CreatePresetRequest withClip(Clip clip) { return this; } - /** - * 音频输出信息 - **/ public Audio getAudio() { return audio; } @@ -131,9 +162,6 @@ public CreatePresetRequest withAudio(Audio audio) { return this; } - /** - * 视频输出信息的集合 - **/ public Video getVideo() { return video; } @@ -147,9 +175,6 @@ public CreatePresetRequest withVideo(Video video) { return this; } - /** - * HLS加解密信息的集合 - **/ public Encryption getEncryption() { return encryption; } @@ -163,11 +188,6 @@ public CreatePresetRequest withEncryption(Encryption encryption) { return this; } - public CreatePresetRequest withRequestCredentials(BceCredentials credentials) { - this.setRequestCredentials(credentials); - return this; - } - public String getWatermarkId() { return watermarkId; } @@ -181,6 +201,50 @@ public CreatePresetRequest withWatermarkId(String watermarkId) { return this; } + public Watermarks getWatermarks() { + return watermarks; + } + + public void setWatermarks(Watermarks watermarks) { + this.watermarks = watermarks; + } + + public CreatePresetRequest withWatermarks(Watermarks watermarks) { + this.watermarks = watermarks; + return this; + } + + public TransCfg getTransCfg() { + return transCfg; + } + + public void setTransCfg(TransCfg transCfg) { + this.transCfg = transCfg; + } + + public CreatePresetRequest withTransCfg(TransCfg transCfg) { + this.transCfg = transCfg; + return this; + } + + public ExtraCfg getExtraCfg() { + return extraCfg; + } + + public void setExtraCfg(ExtraCfg extraCfg) { + this.extraCfg = extraCfg; + } + + public CreatePresetRequest withExtraCfg(ExtraCfg extraCfg) { + this.extraCfg = extraCfg; + return this; + } + + public CreatePresetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -195,6 +259,9 @@ public String toString() { sb.append(" video: ").append(video).append("\n"); sb.append(" encryption: ").append(encryption).append("\n"); sb.append(" watermarkId: ").append(watermarkId).append("\n"); + sb.append(" watermarks: ").append(watermarks).append("\n"); + sb.append(" transCfg: ").append(transCfg).append("\n"); + sb.append(" extraCfg: ").append(extraCfg).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/CreateSubtitleJobRequest.java b/src/main/java/com/baidubce/services/media/model/CreateSubtitleJobRequest.java new file mode 100644 index 00000000..6ea347e7 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/CreateSubtitleJobRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +/** + * The request containing all options for creating a subtitle job. + */ +@Data +public class CreateSubtitleJobRequest extends AbstractBceRequest { + /** + * The pipeline name of the subtitle job + **/ + private String pipelineName = null; + + /** + * The source information of the subtitle job + **/ + private SubtitleSource source = null; + + /** + * The target configuration of the subtitle job + **/ + private SubtitleTarget target = null; + + /** + * The extra configuration of subtitle job + **/ + private SubtitleConfig config = null; + + public CreateSubtitleJobRequest withPipelineName(String pipelineName) { + this.pipelineName = pipelineName; + return this; + } + + + public CreateSubtitleJobRequest withSource(SubtitleSource source) { + this.source = source; + return this; + } + + public CreateSubtitleJobRequest withTarget(SubtitleTarget target) { + this.target = target; + return this; + } + + public CreateSubtitleJobRequest withConfig(SubtitleConfig config) { + this.config = config; + return this; + } + + @Override + public CreateSubtitleJobRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/CreateSubtitleJobResponse.java b/src/main/java/com/baidubce/services/media/model/CreateSubtitleJobResponse.java new file mode 100644 index 00000000..08cce59c --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/CreateSubtitleJobResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response containing id of the job created. + */ +public class CreateSubtitleJobResponse extends AbstractBceResponse { + + private String jobId = null; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + +} diff --git a/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobRequest.java b/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobRequest.java index 3c38696f..154a6c0a 100644 --- a/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobRequest.java +++ b/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobRequest.java @@ -17,15 +17,41 @@ import com.baidubce.model.AbstractBceRequest; public class CreateThumbnailJobRequest extends AbstractBceRequest { - + /** + * the pipeline name of the thumbnail job + **/ private String pipelineName = null; + /** + * the source information of the thumbnail job + **/ private ThumbnailSource source = null; - + + /** + * the preset name of the thumbnail job + **/ + private String presetName = null; + + /** + * the target information of the thumbnail job + **/ private ThumbnailTarget target = null; - + + /** + * the information that tells how to pick the thumbnails + **/ private ThumbnailCapture capture = null; + /** + * delogo area setting + **/ + private Area delogoArea = null; + + /** + * crop area setting + **/ + private Area crop = null; + public String getPipelineName() { return pipelineName; } @@ -52,6 +78,19 @@ public CreateThumbnailJobRequest withSource(ThumbnailSource source) { return this; } + public String getPresetName() { + return presetName; + } + + public void setPresetName(String presetName) { + this.presetName = presetName; + } + + public CreateThumbnailJobRequest withPresetName(String presetName) { + this.presetName = presetName; + return this; + } + public ThumbnailTarget getTarget() { return target; } @@ -78,8 +117,34 @@ public CreateThumbnailJobRequest withCapture(ThumbnailCapture capture) { return this; } + public Area getDelogoArea() { + return delogoArea; + } + + public void setDelogoArea(Area delogoArea) { + this.delogoArea = delogoArea; + } + + public CreateThumbnailJobRequest withDelogoArea(Area delogoArea) { + this.delogoArea = delogoArea; + return this; + } + + public Area getCrop() { + return crop; + } + + public void setCrop(Area crop) { + this.crop = crop; + } + + public CreateThumbnailJobRequest withCrop(Area crop) { + this.crop = crop; + return this; + } + @Override - public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + public CreateThumbnailJobRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } diff --git a/src/main/java/com/baidubce/services/media/model/CreateThumbnailPresetRequest.java b/src/main/java/com/baidubce/services/media/model/CreateThumbnailPresetRequest.java new file mode 100644 index 00000000..b106c5cc --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/CreateThumbnailPresetRequest.java @@ -0,0 +1,105 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import static com.baidubce.util.Validate.checkStringNotEmpty; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request containing all options for creating a preset. + */ +public class CreateThumbnailPresetRequest extends AbstractBceRequest { + + /** + * The name of the thumbnail preset + **/ + private String presetName = null; + + /** + * Preset description + **/ + private String description = null; + + /** + * The target information of the thumbnail preset + **/ + private ThumbnailPresetTarget target = null; + + /** + * The information that tells how to pick the thumbnails + **/ + private ThumbnailPresetCapture capture = null; + + public String getPresetName() { + return presetName; + } + + public void setPresetName(String presetName) { + checkStringNotEmpty(presetName, "The parameter presetName should NOT be null or empty string."); + this.presetName = presetName; + } + + public CreateThumbnailPresetRequest withPresetName(String presetName) { + this.setPresetName(presetName); + return this; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public CreateThumbnailPresetRequest withDescription(String description) { + this.description = description; + return this; + } + + public ThumbnailPresetTarget getTarget() { + return target; + } + + public void setTarget(ThumbnailPresetTarget target) { + this.target = target; + } + + public CreateThumbnailPresetRequest withTarget(ThumbnailPresetTarget target) { + this.target = target; + return this; + } + + public ThumbnailPresetCapture getCapture() { + return capture; + } + + public void setCapture(ThumbnailPresetCapture capture) { + this.capture = capture; + } + + public CreateThumbnailPresetRequest withCapture(ThumbnailPresetCapture capture) { + this.capture = capture; + return this; + } + + @Override + public CreateThumbnailPresetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/CreateThumbnailPresetResponse.java b/src/main/java/com/baidubce/services/media/model/CreateThumbnailPresetResponse.java new file mode 100644 index 00000000..0960360e --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/CreateThumbnailPresetResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of creating a preset. + */ +public class CreateThumbnailPresetResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/media/model/CreateWaterMarkRequest.java b/src/main/java/com/baidubce/services/media/model/CreateWaterMarkRequest.java index 78dab18a..ec83bebc 100644 --- a/src/main/java/com/baidubce/services/media/model/CreateWaterMarkRequest.java +++ b/src/main/java/com/baidubce/services/media/model/CreateWaterMarkRequest.java @@ -17,13 +17,85 @@ import com.baidubce.model.AbstractBceRequest; public class CreateWaterMarkRequest extends AbstractBceRequest { + /** + * Bos bucket + **/ private String bucket = null; + + /** + * Bos key + **/ private String key = null; + + /** + * vertical alignment, options include left, center, right + **/ private String verticalAlignment; + + /** + * horizontal alignment, options include left, center, right + **/ private String horizontalAlignment; + + /** + * vertical offset in pixel + **/ + @Deprecated private Integer verticalOffsetInPixel; + + /** + * horizontal offset in pixel + **/ + @Deprecated private Integer horizontalOffsetInPixel; + /** + * display timeline setting + **/ + private Timeline timeline = null; + + /** + * display repeated times, 0 for infinite times + **/ + private Integer repeated = null; + + /** + * allow watermarks to scale automatically + */ + private Boolean allowScaling = null; + + /** + * horizontal offset in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String dx; + + /** + * vertical offset in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String dy; + + /** + * width of watermark in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String width; + + /** + * height of watermark in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String height; + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; @@ -107,6 +179,97 @@ public CreateWaterMarkRequest withHorizontalAlignment(String horizontalAlignment return this; } + public Timeline getTimeline() { + return timeline; + } + + public void setTimeline(Timeline timeline) { + this.timeline = timeline; + } + + public CreateWaterMarkRequest withTimeline(Timeline timeline) { + this.timeline = timeline; + return this; + } + + public Integer getRepeated() { + return repeated; + } + + public void setRepeated(Integer repeated) { + this.repeated = repeated; + } + + public CreateWaterMarkRequest withRepeated(Integer repeated) { + this.repeated = repeated; + return this; + } + + public Boolean getAllowScaling() { + return allowScaling; + } + + public void setAllowScaling(Boolean allowScaling) { + this.allowScaling = allowScaling; + } + + public CreateWaterMarkRequest withAllowScaling(Boolean allowScaling) { + this.allowScaling = allowScaling; + return this; + } + + public String getDx() { + return dx; + } + + public void setDx(String dx) { + this.dx = dx; + } + + public CreateWaterMarkRequest withDx(String dx) { + this.dx = dx; + return this; + } + + public String getDy() { + return dy; + } + + public void setDy(String dy) { + this.dy = dy; + } + + public CreateWaterMarkRequest withDy(String dy) { + this.dy = dy; + return this; + } + + public String getHeight() { + return height; + } + + public void setHeight(String height) { + this.height = height; + } + + public CreateWaterMarkRequest withHeight(String height) { + this.height = height; + return this; + } + + public String getWidth() { + return width; + } + + public void setWidth(String width) { + this.width = width; + } + + public CreateWaterMarkRequest withWidth(String width) { + this.width = width; + return this; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -117,6 +280,13 @@ public String toString() { sb.append(" horizontalAlignment: ").append(horizontalAlignment).append("\n"); sb.append(" verticalOffsetInPixel: ").append(verticalOffsetInPixel).append("\n"); sb.append(" horizontalOffsetInPixel: ").append(horizontalOffsetInPixel).append("\n"); + sb.append(" dx: ").append(dx).append("\n"); + sb.append(" dy: ").append(dy).append("\n"); + sb.append(" width: ").append(width).append("\n"); + sb.append(" height: ").append(height).append("\n"); + sb.append(" timeline: ").append(timeline).append("\n"); + sb.append(" repeated: ").append(repeated).append("\n"); + sb.append(" allowScaling: ").append(allowScaling).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/DeleteNotificationRequest.java b/src/main/java/com/baidubce/services/media/model/DeleteNotificationRequest.java new file mode 100644 index 00000000..9e892d4c --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/DeleteNotificationRequest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +/** + * The request for deleting notification + */ +@Data +public class DeleteNotificationRequest extends AbstractBceRequest { + private String name = null; + + public DeleteNotificationRequest withName(String name) { + this.name = name; + return this; + } + + public DeleteNotificationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/media/model/DeleteNotificationResponse.java b/src/main/java/com/baidubce/services/media/model/DeleteNotificationResponse.java new file mode 100644 index 00000000..123fd647 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/DeleteNotificationResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for deleting notification + */ +public class DeleteNotificationResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/media/model/DeleteThumbnailPresetRequest.java b/src/main/java/com/baidubce/services/media/model/DeleteThumbnailPresetRequest.java new file mode 100644 index 00000000..e192c95b --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/DeleteThumbnailPresetRequest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import static com.baidubce.util.Validate.checkStringNotEmpty; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request containing all options for deleting a preset. + */ +public class DeleteThumbnailPresetRequest extends AbstractBceRequest { + + /** + * The thumbnail preset name to be delete. + */ + private String presetName = null; + + public String getPresetName() { + return presetName; + } + + public void setPresetName(String presetName) { + checkStringNotEmpty(presetName, "The parameter presetName should NOT be null or empty string."); + this.presetName = presetName; + } + + public DeleteThumbnailPresetRequest withPresetName(String presetName) { + this.setPresetName(presetName); + return this; + } + + public DeleteThumbnailPresetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/media/model/DeleteThumbnailPresetResponse.java b/src/main/java/com/baidubce/services/media/model/DeleteThumbnailPresetResponse.java new file mode 100644 index 00000000..485f8571 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/DeleteThumbnailPresetResponse.java @@ -0,0 +1,23 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of deleting a preset. + */ +public class DeleteThumbnailPresetResponse extends AbstractBceResponse { + +} diff --git a/src/main/java/com/baidubce/services/media/model/Encryption.java b/src/main/java/com/baidubce/services/media/model/Encryption.java index 549aa4a8..6de75d60 100644 --- a/src/main/java/com/baidubce/services/media/model/Encryption.java +++ b/src/main/java/com/baidubce/services/media/model/Encryption.java @@ -16,6 +16,7 @@ public class Encryption { private String strategy = null; private String aesKey = null; + private String keyServerUrl = null; /** * Fixed-表示固定密钥加密 @@ -49,6 +50,19 @@ public Encryption withAesKey(String aesKey) { return this; } + public String getKeyServerUrl() { + return keyServerUrl; + } + + public void setKeyServerUrl(String keyServerUrl) { + this.keyServerUrl = keyServerUrl; + } + + public Encryption withKeyServerUrl(String keyServerUrl) { + this.keyServerUrl = keyServerUrl; + return this; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -56,6 +70,7 @@ public String toString() { sb.append(" strategy: ").append(strategy).append("\n"); sb.append(" aesKey: ").append(aesKey).append("\n"); + sb.append(" keyServerUrl: ").append(keyServerUrl).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/ExtraCfg.java b/src/main/java/com/baidubce/services/media/model/ExtraCfg.java new file mode 100644 index 00000000..21ebf2d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/ExtraCfg.java @@ -0,0 +1,78 @@ +/* + * Copyright 2015-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import lombok.Data; + +import java.util.List; + +/** + * The model which will be used to set extra configs in preset + */ +@Data +public class ExtraCfg { + /** + * set the conditions of the video that will disable watermark, options include "portrait" + **/ + private List watermarkDisableWhitelist = null; + + /** + * set the segment duration of hls and dash + **/ + private Float segmentDurationInSecond = null; + + /** + * set the gop length + **/ + private Integer gopLength = null; + + /** + * enable skip black frame + **/ + private Boolean skipBlackFrame = null; + + + public ExtraCfg withWatermarkDisableWhitelist(List watermarkDisableWhitelist) { + this.watermarkDisableWhitelist = watermarkDisableWhitelist; + return this; + } + + public ExtraCfg withSegmentDurationInSecond(Float segmentDurationInSecond) { + this.segmentDurationInSecond = segmentDurationInSecond; + return this; + } + + public ExtraCfg withGopLength(Integer gopLength) { + this.gopLength = gopLength; + return this; + } + + public ExtraCfg withSkipBlackFrame(Boolean skipBlackFrame) { + this.skipBlackFrame = skipBlackFrame; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExtraCfg {\n"); + + sb.append(" watermarkDisableWhitelist: ").append(watermarkDisableWhitelist).append("\n"); + sb.append(" segmentDurationInSecond: ").append(segmentDurationInSecond).append("\n"); + sb.append(" gopLength: ").append(gopLength).append("\n"); + sb.append(" skipBlackFrame: ").append(skipBlackFrame).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/Font.java b/src/main/java/com/baidubce/services/media/model/Font.java new file mode 100644 index 00000000..434dedfe --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/Font.java @@ -0,0 +1,124 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import java.math.BigDecimal; + +public class Font { + /** + * font family + **/ + private String family = null; + + /** + * font size + **/ + private Integer sizeInPoint = null; + + private String color = null; + + private BigDecimal alpha = null; + + private Integer shadowX = null; + + private Integer shadowY = null; + private String shadowColor = null; + + private String fontName = null; + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public BigDecimal getAlpha() { + return alpha; + } + + public void setAlpha(BigDecimal alpha) { + this.alpha = alpha; + } + + public Integer getShadowX() { + return shadowX; + } + + public void setShadowX(Integer shadowX) { + this.shadowX = shadowX; + } + + public Integer getShadowY() { + return shadowY; + } + + public void setShadowY(Integer shadowY) { + this.shadowY = shadowY; + } + + public String getShadowColor() { + return shadowColor; + } + + public void setShadowColor(String shadowColor) { + this.shadowColor = shadowColor; + } + + public String getFontName() { + return fontName; + } + + public void setFontName(String fontName) { + this.fontName = fontName; + } + + public String getFamily() { + return family; + } + + public void setFamily(String family) { + this.family = family; + } + + public Font withFamily(String family) { + this.family = family; + return this; + } + + public Integer getSizeInPoint() { + return sizeInPoint; + } + + public void setSizeInPoint(Integer sizeInPoint) { + this.sizeInPoint = sizeInPoint; + } + + public Font withSizeInPoint(Integer sizeInPoint) { + this.sizeInPoint = sizeInPoint; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Font {\n"); + + sb.append(" family: ").append(family).append("\n"); + sb.append(" sizeInPoint: ").append(sizeInPoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileResponse.java b/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileResponse.java index 62614535..d2afed61 100644 --- a/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileResponse.java @@ -16,18 +16,57 @@ import com.baidubce.model.AbstractBceResponse; public class GetMediaInfoOfFileResponse extends AbstractBceResponse { + + /** + * 文件所在的BOS的Bucket + **/ private String bucket = null; + + /** + * 文件的BOS的Key + **/ private String key = null; + + /** + * 文件的大小 + **/ private Long fileSizeInByte = null; + /** + * 封装格式 + **/ private String container = null; + + /** + * 文件时长,单位:秒 + **/ private Integer durationInSecond = null; + /** + * 文件时长,单位:毫秒 + **/ + private Integer durationInMillisecond = null; + // public enum fileSizeInByteEnum { }; + /** + * 文件的MD5值 + **/ private String etag = null; + + /** + * 文件类型 + **/ private String type = null; + + /** + * 视频流信息 + **/ private VideoInfo video = null; + + /** + * 音频流信息 + **/ private AudioInfo audio = null; /** @@ -85,6 +124,9 @@ public void setType(String type) { this.type = type; } + /** + * 视频流信息 + **/ public VideoInfo getVideo() { return video; } @@ -93,6 +135,9 @@ public void setVideo(VideoInfo video) { this.video = video; } + /** + * 音频流信息 + **/ public AudioInfo getAudio() { return audio; } @@ -101,6 +146,9 @@ public void setAudio(AudioInfo audio) { this.audio = audio; } + /** + * 封装格式 + **/ public String getContainer() { return container; } @@ -109,6 +157,9 @@ public void setContainer(String container) { this.container = container; } + /** + * 文件时长,单位:秒 + **/ public Integer getDurationInSecond() { return durationInSecond; } @@ -117,6 +168,17 @@ public void setDurationInSecond(Integer durationInSecond) { this.durationInSecond = durationInSecond; } + /** + * 文件时长,单位:毫秒 + **/ + public Integer getDurationInMillisecond() { + return durationInMillisecond; + } + + public void setDurationInMillisecond(Integer durationInMillisecond) { + this.durationInMillisecond = durationInMillisecond; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -127,6 +189,7 @@ public String toString() { sb.append(" fileSizeInByte: ").append(fileSizeInByte).append("\n"); sb.append(" container: ").append(container).append("\n"); sb.append(" durationInSecond: ").append(durationInSecond).append("\n"); + sb.append(" durationInMillisecond: ").append(durationInMillisecond).append("\n"); sb.append(" etag: ").append(etag).append("\n"); sb.append(" type: ").append(type).append("\n"); sb.append(" video: ").append(video).append("\n"); diff --git a/src/main/java/com/baidubce/services/media/model/GetNotificationRequest.java b/src/main/java/com/baidubce/services/media/model/GetNotificationRequest.java new file mode 100644 index 00000000..23a13d71 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/GetNotificationRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import static com.baidubce.util.Validate.checkStringNotEmpty; + +/** + * The request for getting notification + */ +@Data +public class GetNotificationRequest extends AbstractBceRequest { + + private String name = null; + + + public GetNotificationRequest withName(String name) { + checkStringNotEmpty(name, "The parameter name should NOT be null or empty string."); + this.name = name; + return this; + } + + public GetNotificationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetNotificationRequest {\n"); + + sb.append("name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/GetNotificationResponse.java b/src/main/java/com/baidubce/services/media/model/GetNotificationResponse.java new file mode 100644 index 00000000..6c845603 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/GetNotificationResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * The response for getting notification + */ +@Data +public class GetNotificationResponse extends AbstractBceResponse { + private String name = null; + private String endpoint = null; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationRequest {\n"); + + sb.append("name: ").append(name).append("\n"); + sb.append("endpoint: ").append(endpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/GetPipelineResponse.java b/src/main/java/com/baidubce/services/media/model/GetPipelineResponse.java index 9d225c53..520d7131 100644 --- a/src/main/java/com/baidubce/services/media/model/GetPipelineResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetPipelineResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Baidu, Inc. + * Copyright 2015-2020 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -15,6 +15,9 @@ import com.baidubce.model.AbstractBceResponse; +/** + * The response for getting pipeline + */ public class GetPipelineResponse extends AbstractBceResponse { private String pipelineName = null; private String description = null; @@ -25,6 +28,15 @@ public class GetPipelineResponse extends AbstractBceResponse { private String lastUpdateTime = null; private JobStatus jobStatus = null; + public PipelineStatus getPipeline() { + PipelineStatus pipeline = new PipelineStatus(); + pipeline.setPipelineName(pipelineName); + pipeline.setDescription(description); + pipeline.setSourceBucket(sourceBucket); + pipeline.setTargetBucket(targetBucket); + pipeline.setConfig(config); + return pipeline; + } /** * 系统生成的队列唯一标示 **/ diff --git a/src/main/java/com/baidubce/services/media/model/GetPresetResponse.java b/src/main/java/com/baidubce/services/media/model/GetPresetResponse.java index d2c60ef4..b49251e1 100644 --- a/src/main/java/com/baidubce/services/media/model/GetPresetResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetPresetResponse.java @@ -16,21 +16,77 @@ import com.baidubce.model.AbstractBceResponse; public class GetPresetResponse extends AbstractBceResponse { + /** + * preset name + **/ private String presetName = null; + + /** + * preset description + **/ private String description = null; + + /** + * preset container, options include mp4, flv, hls, mp3, m4a, a-hls, pcm, dash + **/ private String container = null; + + /** + * transmux mode + **/ private Boolean transmux = null; + + /** + * clip source + **/ private Clip clip = null; + + /** + * audio settings + **/ private Audio audio = null; + + /** + * video settings + **/ private Video video = null; + + /** + * HLS encryption settings + **/ private Encryption encryption = null; + + /** + * watermark Id + **/ + private String watermarkId = null; + + /** + * multiple watermarks setting + **/ + private Watermarks watermarks = null; + + /** + * transcoding configurations + **/ + private TransCfg transCfg = null; + + /** + * extra transcoding configurations + **/ + private ExtraCfg extraCfg = null; + + + /** + * the state of the preset (ACTIVE/INACTIVE) + **/ private String state = null; - private String createdTime = null; - private String watermarkId = null; /** - * preset名称 + * the UTC created time of the preset **/ + private String createdTime = null; + public String getPresetName() { return presetName; } @@ -39,9 +95,6 @@ public void setPresetName(String presetName) { this.presetName = presetName; } - /** - * preset详情描述 - **/ public String getDescription() { return description; } @@ -50,9 +103,6 @@ public void setDescription(String description) { this.description = description; } - /** - * 音视频文件的容器(MP4, FLV, MOV, MP3, M4A) - **/ public String getContainer() { return container; } @@ -61,9 +111,6 @@ public void setContainer(String container) { this.container = container; } - /** - * 是否仅执行容器格式转换 - **/ public Boolean getTransmux() { return transmux; } @@ -72,9 +119,6 @@ public void setTransmux(Boolean transmux) { this.transmux = transmux; } - /** - * 片段截取设置 - **/ public Clip getClip() { return clip; } @@ -83,9 +127,6 @@ public void setClip(Clip clip) { this.clip = clip; } - /** - * 音频输出信息 - **/ public Audio getAudio() { return audio; } @@ -94,9 +135,6 @@ public void setAudio(Audio audio) { this.audio = audio; } - /** - * 视频输出信息的集合 - **/ public Video getVideo() { return video; } @@ -105,9 +143,6 @@ public void setVideo(Video video) { this.video = video; } - /** - * HLS加解密信息的集合 - **/ public Encryption getEncryption() { return encryption; } @@ -116,9 +151,6 @@ public void setEncryption(Encryption encryption) { this.encryption = encryption; } - /** - * 模板状态(ACTIVE/INACTIVE) - **/ public String getState() { return state; } @@ -127,9 +159,6 @@ public void setState(String state) { this.state = state; } - /** - * 模板创建的时间(UTC格式) - **/ public String getCreatedTime() { return createdTime; } @@ -146,6 +175,30 @@ public void setWatermarkId(String watermarkId) { this.watermarkId = watermarkId; } + public Watermarks getWatermarks() { + return watermarks; + } + + public void setWatermarks(Watermarks watermarks) { + this.watermarks = watermarks; + } + + public TransCfg getTransCfg() { + return transCfg; + } + + public void setTransCfg(TransCfg transCfg) { + this.transCfg = transCfg; + } + + public ExtraCfg getExtraCfg() { + return extraCfg; + } + + public void setExtraCfg(ExtraCfg extraCfg) { + this.extraCfg = extraCfg; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -159,6 +212,10 @@ public String toString() { sb.append(" audio: ").append(audio).append("\n"); sb.append(" video: ").append(video).append("\n"); sb.append(" encryption: ").append(encryption).append("\n"); + sb.append(" watermarkId: ").append(watermarkId).append("\n"); + sb.append(" watermarks: ").append(watermarks).append("\n"); + sb.append(" transCfg: ").append(transCfg).append("\n"); + sb.append(" extraCfg: ").append(extraCfg).append("\n"); sb.append(" state: ").append(state).append("\n"); sb.append(" createdTime: ").append(createdTime).append("\n"); sb.append("}\n"); diff --git a/src/main/java/com/baidubce/services/media/model/GetSubtitleJobRequest.java b/src/main/java/com/baidubce/services/media/model/GetSubtitleJobRequest.java new file mode 100644 index 00000000..e546837d --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/GetSubtitleJobRequest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + + +/** + * The request containing all options for getting a subtitle job. + */ +public class GetSubtitleJobRequest extends AbstractBceRequest { + + /** + * subtitle job id. + */ + private String jobId = null; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public GetSubtitleJobRequest withJobId(String jobId) { + this.jobId = jobId; + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/GetSubtitleJobResponse.java b/src/main/java/com/baidubce/services/media/model/GetSubtitleJobResponse.java new file mode 100644 index 00000000..d1b24b2b --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/GetSubtitleJobResponse.java @@ -0,0 +1,77 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +/** + * The response containing all information of a subtitle job. + */ +@Data +public class GetSubtitleJobResponse extends AbstractBceResponse { + /** + * the subtitle job Id + **/ + private String jobId = null; + + /** + * the subtitle job status + **/ + private String jobStatus = null; + + /** + * The pipeline name of the subtitle job + **/ + private String pipelineName = null; + + /** + * The source information of the subtitle job + **/ + private SubtitleSource source = null; + + /** + * The target configuration of the subtitle job + **/ + private SubtitleTargetStatus target = null; + + /** + * The extra configuration of subtitle job + **/ + private SubtitleConfig config = null; + + /** + * error information + **/ + private MediaError error = null; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetSubtitleJobResponse {\n"); + sb.append(" jobId: ").append(jobId).append("\n"); + sb.append(" jobStatus: ").append(jobStatus).append("\n"); + sb.append(" pipeline: ").append(pipelineName).append("\n"); + sb.append(" source: ").append(source).append("\n"); + sb.append(" target: ").append(target).append("\n"); + sb.append(" config: ").append(config).append("\n"); + if (error != null) { + sb.append(" error: ").append(error).append("\n"); + } + sb.append("}\n"); + return sb.toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/GetThumbnailJobResponse.java b/src/main/java/com/baidubce/services/media/model/GetThumbnailJobResponse.java index 63075376..df81162a 100644 --- a/src/main/java/com/baidubce/services/media/model/GetThumbnailJobResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetThumbnailJobResponse.java @@ -16,18 +16,54 @@ import com.baidubce.model.AbstractBceResponse; public class GetThumbnailJobResponse extends AbstractBceResponse { + /** + * the thumbnail job Id + **/ private String jobId = null; - + + /** + * the thumbnail job status + **/ private String jobStatus = null; - + + /** + * the pipeline name of the thumbnail job + **/ private String pipelineName = null; - + + /** + * the source information of the thumbnail job + **/ private ThumbnailSource source = null; - + + /** + * the preset name of the thumbnail job + **/ + private String presetName = null; + + /** + * the target information of the thumbnail job + **/ private ThumbnailTargetStatus target = null; - + + /** + * the information that tells how to pick the thumbnails + **/ private ThumbnailCapture capture = null; + /** + * delogo area + **/ + private Area delogoArea = null; + + /** + * crop area + **/ + private Area crop = null; + + /** + * error information + **/ private MediaError error = null; public String getJobId() { @@ -61,6 +97,14 @@ public ThumbnailSource getSource() { public void setSource(ThumbnailSource source) { this.source = source; } + + public String getPresetName() { + return presetName; + } + + public void setPresetName(String presetName) { + this.presetName = presetName; + } public ThumbnailTargetStatus getTarget() { return target; @@ -78,6 +122,22 @@ public void setCapture(ThumbnailCapture capture) { this.capture = capture; } + public Area getDelogoArea() { + return delogoArea; + } + + public void setDelogoArea(Area delogoArea) { + this.delogoArea = delogoArea; + } + + public Area getCrop() { + return crop; + } + + public void setCrop(Area crop) { + this.crop = crop; + } + public MediaError getError() { return error; } @@ -96,6 +156,12 @@ public String toString() { sb.append(" source: ").append(source).append("\n"); sb.append(" target: ").append(target).append("\n"); sb.append(" capture: ").append(capture).append("\n"); + if (delogoArea != null) { + sb.append(" delogoArea: ").append(delogoArea).append("\n"); + } + if (crop != null) { + sb.append(" crop: ").append(crop).append("\n"); + } if (error != null) { sb.append(error).append("\n"); } diff --git a/src/main/java/com/baidubce/services/media/model/GetThumbnailPresetRequest.java b/src/main/java/com/baidubce/services/media/model/GetThumbnailPresetRequest.java new file mode 100644 index 00000000..2b74b8d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/GetThumbnailPresetRequest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import static com.baidubce.util.Validate.checkStringNotEmpty; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + + +/** + * The request containing all options for getting a preset. + */ +public class GetThumbnailPresetRequest extends AbstractBceRequest { + + /** + * The thumbnail preset name to get. + */ + private String presetName = null; + + public String getPresetName() { + return presetName; + } + + public void setPresetName(String presetName) { + checkStringNotEmpty(presetName, "The parameter presetName should NOT be null or empty string."); + this.presetName = presetName; + } + + public GetThumbnailPresetRequest withPresetName(String presetName) { + checkStringNotEmpty(presetName, "The parameter presetName should NOT be null or empty string."); + this.presetName = presetName; + return this; + } + + public GetThumbnailPresetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetThumbnailPresetRequest {\n"); + + sb.append(" PresetName: ").append(presetName).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/GetThumbnailPresetResponse.java b/src/main/java/com/baidubce/services/media/model/GetThumbnailPresetResponse.java new file mode 100644 index 00000000..54e838ac --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/GetThumbnailPresetResponse.java @@ -0,0 +1,114 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response contains all information of the getted thumbnail preset. + **/ +public class GetThumbnailPresetResponse extends AbstractBceResponse { + /** + * The name of the thumbnail preset + **/ + private String presetName = null; + + /** + * Preset description + **/ + private String description = null; + + /** + * The UTC created time of the thumbnail preset + **/ + private String createdTime = null; + + /** + * The state of the thumbnail preset (ACTIVE/INACTIVE) + **/ + private String state = null; + + /** + * The target information of the thumbnail preset + **/ + private ThumbnailPresetTarget target = null; + + /** + * The information that tells how to pick the thumbnails + **/ + private ThumbnailPresetCapture capture = null; + + public String getPresetName() { + return presetName; + } + + public void setPresetName(String presetName) { + this.presetName = presetName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public ThumbnailPresetTarget getTarget() { + return target; + } + + public void setTarget(ThumbnailPresetTarget target) { + this.target = target; + } + + public ThumbnailPresetCapture getCapture() { + return capture; + } + + public void setCapture(ThumbnailPresetCapture capture) { + this.capture = capture; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetThumbnailPresetResponse {\n"); + + sb.append(" presetName: ").append(presetName).append("\n"); + sb.append(" description: ").append(description).append("\n"); + sb.append(" state: ").append(state).append("\n"); + sb.append(" createdTime: ").append(createdTime).append("\n"); + sb.append(" target: ").append(target).append("\n"); + sb.append(" capture: ").append(capture).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/GetTranscodingEncryptionKeyRequest.java b/src/main/java/com/baidubce/services/media/model/GetTranscodingEncryptionKeyRequest.java new file mode 100644 index 00000000..3a8b5194 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/GetTranscodingEncryptionKeyRequest.java @@ -0,0 +1,41 @@ +package com.baidubce.services.media.model; + +import static com.baidubce.util.Validate.checkStringNotEmpty; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class GetTranscodingEncryptionKeyRequest extends AbstractBceRequest { + + private String jobId = null; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + checkStringNotEmpty(jobId, "The parameter jobId should NOT be null or empty string."); + this.jobId = jobId; + } + + public GetTranscodingEncryptionKeyRequest withJobId(String jobId) { + checkStringNotEmpty(jobId, "The parameter jobId should NOT be null or empty string."); + this.jobId = jobId; + return this; + } + + public GetTranscodingEncryptionKeyRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetTranscodingEncryptionKeyRequest {\n"); + sb.append(" JobId: ").append(jobId).append("\n"); + sb.append("}\n"); + return sb.toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/GetTranscodingEncryptionKeyResponse.java b/src/main/java/com/baidubce/services/media/model/GetTranscodingEncryptionKeyResponse.java new file mode 100644 index 00000000..51d425fb --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/GetTranscodingEncryptionKeyResponse.java @@ -0,0 +1,26 @@ +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +public class GetTranscodingEncryptionKeyResponse extends AbstractBceResponse{ + + private String encryptionKey = null; + + public String getEncryptionKey() { + return encryptionKey; + } + + public void setEncryptionKey(String encryptionKey) { + this.encryptionKey = encryptionKey; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetTranscodingEncryptionKeyResponse {\n"); + sb.append(" encryptionKey: ").append(encryptionKey).append("\n"); + sb.append("}\n"); + return sb.toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/GetTranscodingJobResponse.java b/src/main/java/com/baidubce/services/media/model/GetTranscodingJobResponse.java index 7a10567e..dbfc83d1 100644 --- a/src/main/java/com/baidubce/services/media/model/GetTranscodingJobResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetTranscodingJobResponse.java @@ -14,6 +14,11 @@ public class GetTranscodingJobResponse extends AbstractBceResponse { private Date endTime = null; private MediaError error = null; + /** + * job output info + */ + private JobOutputInfo output = null; + /** * 任务的唯一标识 **/ @@ -100,6 +105,10 @@ public void setError(MediaError error) { this.error = error; } + public JobOutputInfo getOutput() { return output; } + + public void setOutput(JobOutputInfo inputInfo) { this.output = inputInfo; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -112,6 +121,9 @@ public String toString() { sb.append(" jobStatus: ").append(jobStatus).append("\n"); sb.append(" startTime: ").append(startTime).append("\n"); sb.append(" endTime: ").append(endTime).append("\n"); + if (output.getVideo() != null || output.getAudio() != null) { + sb.append(" output: ").append(output).append("\n"); + } if (error != null) { sb.append(error).append("\n"); } diff --git a/src/main/java/com/baidubce/services/media/model/GetWaterMarkResponse.java b/src/main/java/com/baidubce/services/media/model/GetWaterMarkResponse.java index dbbd44b9..68686375 100644 --- a/src/main/java/com/baidubce/services/media/model/GetWaterMarkResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetWaterMarkResponse.java @@ -16,15 +16,94 @@ import com.baidubce.model.AbstractBceResponse; public class GetWaterMarkResponse extends AbstractBceResponse { + /** + * the auto-generated watermark Id + **/ private String watermarkId = null; + + /** + * the create time of the watermark + **/ private String createTime = null; + + /** + * Bos bucket + **/ private String bucket = null; + + /** + * Bos key + **/ private String key = null; + + /** + * vertical offset in pixel + **/ private Integer verticalOffsetInPixel = null; + + + /** + * horizontal offset in pixel + **/ private Integer horizontalOffsetInPixel = null; + + /** + * vertical alignment, options include left, center, right + **/ private String verticalAlignment = null; + + /** + * horizontal alignment, options include left, center, right + **/ private String horizontalAlignment = null; + + /** + * display timeline setting + **/ + private Timeline timeline = null; + + /** + * display repeated times, 0 for infinite times + **/ + private Integer repeated = null; + + /** + * allow watermarks to scale automatically + */ + private Boolean allowScaling = null; + /** + * horizontal offset in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String dx; + + /** + * vertical offset in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String dy; + + /** + * width of watermark in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String width; + + /** + * height of watermark in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String height; + public String getWatermarkId() { return watermarkId; } @@ -89,6 +168,81 @@ public void setHorizontalAlignment(String horizontalAlignment) { this.horizontalAlignment = horizontalAlignment; } + public Timeline getTimeline() { + return timeline; + } + + public void setTimeline(Timeline timeline) { + this.timeline = timeline; + } + + public Integer getRepeated() { + return repeated; + } + + public void setRepeated(Integer repeated) { + this.repeated = repeated; + } + + public Boolean getAllowScaling() { + return allowScaling; + } + + public void setAllowScaling(Boolean allowScaling) { + this.allowScaling = allowScaling; + } + + public String getDx() { + return dx; + } + + public void setDx(String dx) { + this.dx = dx; + } + + public GetWaterMarkResponse withDx(String dx) { + this.dx = dx; + return this; + } + + public String getDy() { + return dy; + } + + public void setDy(String dy) { + this.dy = dy; + } + + public GetWaterMarkResponse withDy(String dy) { + this.dy = dy; + return this; + } + + public String getHeight() { + return height; + } + + public void setHeight(String height) { + this.height = height; + } + + public GetWaterMarkResponse withHeight(String height) { + this.height = height; + return this; + } + + public String getWidth() { + return width; + } + + public void setWidth(String width) { + this.width = width; + } + + public GetWaterMarkResponse withWidth(String width) { + this.width = width; + return this; + } @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -101,6 +255,13 @@ public String toString() { sb.append(" verticalAlignment: ").append(verticalAlignment).append("\n"); sb.append(" verticalOffsetInPixel: ").append(verticalOffsetInPixel).append("\n"); sb.append(" horizontalOffsetInPixel: ").append(horizontalOffsetInPixel).append("\n"); + sb.append(" dx: ").append(dx).append("\n"); + sb.append(" dy: ").append(dy).append("\n"); + sb.append(" width: ").append(width).append("\n"); + sb.append(" height: ").append(height).append("\n"); + sb.append(" timeline: ").append(timeline).append("\n"); + sb.append(" repeated: ").append(repeated).append("\n"); + sb.append(" allowScaling: ").append(allowScaling).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/HighlightOutputCfg.java b/src/main/java/com/baidubce/services/media/model/HighlightOutputCfg.java new file mode 100644 index 00000000..0615735f --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/HighlightOutputCfg.java @@ -0,0 +1,43 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import javax.validation.constraints.DecimalMax; +import javax.validation.constraints.DecimalMin; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.Data; + +/** + * @description: Configurations of output of highlight mode, including durationInSecond, frameRate, playbackSpeed, reverseConcat etc. + **/ +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class HighlightOutputCfg { + @DecimalMin("0.1") + @DecimalMax("7200.0") + private Float durationInSecond; + + @DecimalMin("0.1") + @DecimalMax("60.0") + private Float frameRate; + + @DecimalMin("0.05") + @DecimalMax("20.0") + private Float playbackSpeed; + + private Boolean reverseConcat; +} + diff --git a/src/main/java/com/baidubce/services/media/model/Insert.java b/src/main/java/com/baidubce/services/media/model/Insert.java new file mode 100644 index 00000000..ed9bb87f --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/Insert.java @@ -0,0 +1,157 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +public class Insert { + /** + * BOS bucket + */ + private String bucket = null; + + /** + * BOS key + */ + private String key = null; + + /** + * Insert type, options include video, image, audio, subtitle, text etc. + */ + private String type = null; + + /** + * Insert text content, can only be set when type is "text" + */ + private String text; + + /** + * text or subtitle font + **/ + private Font font; + + /** + * display timeline + **/ + private Timeline timeline; + + /** + * display position + **/ + private Layout layout; + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public Insert withBucket(String bucket) { + this.bucket = bucket; + return this; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Insert withKey(String key) { + this.key = key; + return this; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Insert withType(String type) { + this.type = type; + return this; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Insert withText(String text) { + this.text = text; + return this; + } + + public Font getFont() { + return font; + } + + public void setFont(Font font) { + this.font = font; + } + + public Insert withFont(Font font) { + this.font = font; + return this; + } + + public Timeline getTimeline() { + return timeline; + } + + public void setTimeline(Timeline timeline) { + this.timeline = timeline; + } + + public Insert withTimeline(Timeline timeline) { + this.timeline = timeline; + return this; + } + + public Layout getLayout() { + return layout; + } + + public void setLayout(Layout layout) { + this.layout = layout; + } + + public Insert withLayout(Layout layout) { + this.layout = layout; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Insert {\n"); + sb.append(" bucket: ").append(bucket).append("\n"); + sb.append(" key: ").append(key).append("\n"); + sb.append(" type: ").append(type).append("\n"); + sb.append(" text: ").append(text).append("\n"); + sb.append(" font: ").append(font).append("\n"); + sb.append(" timeline: ").append(timeline).append("\n"); + sb.append(" layout: ").append(layout).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/JobOutputInfo.java b/src/main/java/com/baidubce/services/media/model/JobOutputInfo.java new file mode 100644 index 00000000..8b77ffc9 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/JobOutputInfo.java @@ -0,0 +1,48 @@ +package com.baidubce.services.media.model; + +public class JobOutputInfo { + /** + * output job video info + */ + private JobOutputInfoVideo video = null; + + /** + * output job audio info + */ + private JobOutputInfoAudio audio = null; + + private Double bitRateInKBps = null; + + public JobOutputInfoVideo getVideo() { return video; } + + public void setVideo(JobOutputInfoVideo inputVideo) { this.video = inputVideo; } + + public JobOutputInfoAudio getAudio() { return audio; } + + public void setAudio(JobOutputInfoAudio inputAudio) { this.audio = inputAudio; } + + public Double getBitRateInKBps() { + return bitRateInKBps; + } + + public void setBitRateInKBps(Double bitRateInKBps) { + this.bitRateInKBps = bitRateInKBps; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class JobOutputInfo {\n"); + if (video != null) { + sb.append(" video: ").append(video).append("\n"); + } + if (audio != null) { + sb.append(" audio: ").append(audio).append("\n"); + } + if (bitRateInKBps != null) { + sb.append(" bitRateInKBps: ").append(bitRateInKBps).append("\n"); + } + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/JobOutputInfoAudio.java b/src/main/java/com/baidubce/services/media/model/JobOutputInfoAudio.java new file mode 100644 index 00000000..e46518b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/JobOutputInfoAudio.java @@ -0,0 +1,31 @@ +package com.baidubce.services.media.model; + +public class JobOutputInfoAudio { + /** + * output job audio sample rate in Hz + */ + private Integer sampleRateInHz; + + /** + * ouput job audio channels + */ + private Integer channels; + + public Integer getSampleRateInHz() { return sampleRateInHz; } + + public void setSampleRateInHz(Integer inputSampleRate) { this.sampleRateInHz = inputSampleRate; } + + public Integer getChannels() { return channels; } + + public void setChannels(Integer inputChannel) { this.channels = inputChannel; } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class JobOutputInfoAudio {\n"); + sb.append(" sampleRateInHz: ").append(sampleRateInHz).append("\n"); + sb.append(" channels: ").append(channels).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/JobOutputInfoVideo.java b/src/main/java/com/baidubce/services/media/model/JobOutputInfoVideo.java new file mode 100644 index 00000000..d6081077 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/JobOutputInfoVideo.java @@ -0,0 +1,71 @@ +package com.baidubce.services.media.model; + +public class JobOutputInfoVideo { + /** + * output video duration in seconds + */ + private Integer durationInSeconds; + + /** + * output video file size in kiloByte + */ + private Double sizeInKiloByte; + + /** + * output video width in pixel + */ + private Integer widthInPixel; + + /** + * output video geight in pixel + */ + private Integer heightInPixel; + + /** + * output video frameRate + */ + private Integer frameRate; + + /** + * output(just mp4 file with video) moov size in Byte + */ + private Integer mp4MoovSize; + + public Integer getDurationInSeconds() { return durationInSeconds; } + + public void setDurationInSeconds(Integer inputDuration) { this.durationInSeconds = inputDuration; } + + public Double getSizeInKiloByte() { return sizeInKiloByte; } + + public void setSizeInKiloByte(Double inputSize) { this.sizeInKiloByte = inputSize; } + + public Integer getWidthInPixel() { return widthInPixel; } + + public void setWidthInPixel(Integer inputWidth) { this.widthInPixel = inputWidth; } + + public Integer getHeightInPixel() { return heightInPixel; } + + public void setHeightInPixel(Integer inputHeight) { this.heightInPixel = inputHeight; } + + public Integer getFrameRate() { return frameRate; } + + public void setFrameRate(Integer inputFrameRate) { this.frameRate = inputFrameRate; } + + public Integer getMp4MoovSize() { return mp4MoovSize; } + + public void setMp4MoovSize(Integer inputMoovszie) { this.mp4MoovSize = inputMoovszie; } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class JobOutputInfoVideo {\n"); + sb.append(" durationInSeconds: ").append(durationInSeconds).append("\n"); + sb.append(" sizeInKiloByte: ").append(sizeInKiloByte).append("\n"); + sb.append(" widthInPixel: ").append(widthInPixel).append("\n"); + sb.append(" heightInPixel: ").append(heightInPixel).append("\n"); + sb.append(" frameRate: ").append(frameRate).append("\n"); + sb.append(" mp4MoovSize: ").append(mp4MoovSize).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/Layout.java b/src/main/java/com/baidubce/services/media/model/Layout.java new file mode 100644 index 00000000..35905cee --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/Layout.java @@ -0,0 +1,101 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +public class Layout { + /** + * vertical alignment, options include top, center, bottom + */ + private String verticalAlignment = null; + + /** + * horizontal alignment, options include left, center, right + */ + private String horizontalAlignment = null; + + /** + * vertical offset in pixel + */ + private Integer verticalOffsetInPixel = null; + + /** + * horizontal offset in pixel + */ + private Integer horizontalOffsetInPixel = null; + + public String getVerticalAlignment() { + return verticalAlignment; + } + + public void setVerticalAlignment(String verticalAlignment) { + this.verticalAlignment = verticalAlignment; + } + + public Layout withVerticalAlignment(String verticalAlignment) { + this.verticalAlignment = verticalAlignment; + return this; + } + + public Integer getVerticalOffsetInPixel() { + return verticalOffsetInPixel; + } + + public void setVerticalOffsetInPixel(Integer verticalOffsetInPixel) { + this.verticalOffsetInPixel = verticalOffsetInPixel; + } + + public Layout withVerticalOffsetInPixel(Integer verticalOffsetInPixel) { + this.verticalOffsetInPixel = verticalOffsetInPixel; + return this; + } + + public String getHorizontalAlignment() { + return horizontalAlignment; + } + + public void setHorizontalAlignment(String horizontalAlignment) { + this.horizontalAlignment = horizontalAlignment; + } + + public Layout withHorizontalAlignment(String horizontalAlignment) { + this.horizontalAlignment = horizontalAlignment; + return this; + } + + public Integer getHorizontalOffsetInPixel() { + return horizontalOffsetInPixel; + } + + public void setHorizontalOffsetInPixel(Integer horizontalOffsetInPixel) { + this.horizontalOffsetInPixel = horizontalOffsetInPixel; + } + + public Layout withHorizontalOffsetInPixel(Integer horizontalOffsetInPixel) { + this.horizontalOffsetInPixel = horizontalOffsetInPixel; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Layout {\n"); + + sb.append(" verticalAlignment: ").append(verticalAlignment).append("\n"); + sb.append(" horizontalAlignment: ").append(horizontalAlignment).append("\n"); + sb.append(" verticalOffsetInPixel: ").append(verticalOffsetInPixel).append("\n"); + sb.append(" horizontalOffsetInPixel: ").append(horizontalOffsetInPixel).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/ListNotificationsRequest.java b/src/main/java/com/baidubce/services/media/model/ListNotificationsRequest.java new file mode 100644 index 00000000..3fc17288 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/ListNotificationsRequest.java @@ -0,0 +1,27 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for listing notification + */ +public class ListNotificationsRequest extends AbstractBceRequest { + public ListNotificationsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/media/model/ListNotificationsResponse.java b/src/main/java/com/baidubce/services/media/model/ListNotificationsResponse.java new file mode 100644 index 00000000..aa80e6c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/ListNotificationsResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.ArrayList; +import java.util.List; + +/** + * The response for listing notification + */ +public class ListNotificationsResponse extends AbstractBceResponse { + private List notifications = new ArrayList(); + + /** + * list of notification information + **/ + public List getNotifications() { + return notifications; + } + + + @Override + public String toString() { + return "ListNotificationsResponse [notifications=" + notifications + "]"; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/ListSubtitleJobsRequest.java b/src/main/java/com/baidubce/services/media/model/ListSubtitleJobsRequest.java new file mode 100644 index 00000000..70e8bdc9 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/ListSubtitleJobsRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import lombok.Data; + +/** + * The request containing all options for getting all subtitle job of a pipeline. + */ +@Data +public class ListSubtitleJobsRequest extends AbstractBceRequest { + + private String pipeline = null; + + public ListSubtitleJobsRequest withPipeline(String pipeline) { + this.pipeline = pipeline; + return this; + } + + @Override + public ListSubtitleJobsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/ListSubtitleJobsResponse.java b/src/main/java/com/baidubce/services/media/model/ListSubtitleJobsResponse.java new file mode 100644 index 00000000..45dd69d8 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/ListSubtitleJobsResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Data; + +/** + * The response contains all subtitle jobs. + */ +@Data +public class ListSubtitleJobsResponse extends AbstractBceResponse { + + /** + * subtitle job list. + */ + private List subtitles = new ArrayList(); + +} diff --git a/src/main/java/com/baidubce/services/media/model/ListThumbnailPresetsRequest.java b/src/main/java/com/baidubce/services/media/model/ListThumbnailPresetsRequest.java new file mode 100644 index 00000000..06c74522 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/ListThumbnailPresetsRequest.java @@ -0,0 +1,27 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request containing all options for getting all presets. + */ +public class ListThumbnailPresetsRequest extends AbstractBceRequest { + public ListThumbnailPresetsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/media/model/ListThumbnailPresetsResponse.java b/src/main/java/com/baidubce/services/media/model/ListThumbnailPresetsResponse.java new file mode 100644 index 00000000..9195c956 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/ListThumbnailPresetsResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.ArrayList; +import java.util.List; + +/** + * The response contains all thumbnail presets. + **/ +public class ListThumbnailPresetsResponse extends AbstractBceResponse { + private List presets = new ArrayList(); + + public List getPresets() { + return presets; + } + + public void setPresets(List presets) { + this.presets = presets; + } +} diff --git a/src/main/java/com/baidubce/services/media/model/Notification.java b/src/main/java/com/baidubce/services/media/model/Notification.java new file mode 100644 index 00000000..51ca3445 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/Notification.java @@ -0,0 +1,37 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Data; + +/** + * The model which will be used in listing notifications + */ +@Data +public class Notification extends AbstractBceResponse { + private String name = null; + private String endpoint = null; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Notification {\n"); + + sb.append("name: ").append(name).append("\n"); + sb.append("endpoint: ").append(endpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/Source.java b/src/main/java/com/baidubce/services/media/model/Source.java index ea902ea5..1a49f3e5 100644 --- a/src/main/java/com/baidubce/services/media/model/Source.java +++ b/src/main/java/com/baidubce/services/media/model/Source.java @@ -15,9 +15,14 @@ import static com.baidubce.util.Validate.checkStringNotEmpty; +import java.util.ArrayList; +import java.util.List; + public class Source { private String sourceKey = null; + private List clips = null; + /** * 原始文件的BOS Key **/ @@ -36,12 +41,39 @@ public Source withSourceKey(String sourceKey) { return this; } + /** + * 多输入情况 + */ + public List getClips() { + return clips; + } + + public void setClips(List clips) { + this.clips = clips; + } + + public Source withClips(List clips) { + this.clips = clips; + return this; + } + + public void addClip(SourceClip clip) { + if (clips == null) { + clips = new ArrayList(); + } + clips.add(clip); + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Source {\n"); - sb.append(" sourceKey: ").append(sourceKey).append("\n"); + if (sourceKey != null) { + sb.append(" sourceKey: ").append(sourceKey).append("\n"); + } else if (clips != null) { + sb.append(" clips: ").append(clips).append("\n"); + } sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/SourceClip.java b/src/main/java/com/baidubce/services/media/model/SourceClip.java new file mode 100644 index 00000000..508fc27d --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/SourceClip.java @@ -0,0 +1,150 @@ +/* + * Copyright 2015-2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The model which will be used to set source clip info in creating transcoding job + */ +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class SourceClip { + /** + * source bucket + */ + private String bucket = null; + /** + * Bos key + */ + private String sourceKey = null; + + /** + * clip start time in seconds + */ + private Integer startTimeInSecond = null; + + /** + * clip duration time in seconds + */ + private Integer durationInSecond = null; + + /** + * clip start time in milliseconds + */ + private Integer startTimeInMillisecond = null; + + /** + * clip duration time in milliseconds + */ + private Integer durationInMillisecond = null; + + /** + * the clip will enable watermarks + */ + private Boolean enableLogo = null; + + /** + * the clip will be the master clip + */ + private Boolean asMasterClip; + + /** + * the clip will enable delogo + */ + private Boolean enableDelogo; + + /** + * the clip will enable crop + */ + private Boolean enableCrop; + + public String getSourceKey() { + return sourceKey; + } + + public void setSourceKey(String sourceKey) { + this.sourceKey = sourceKey; + } + + public SourceClip withSourceKey(String sourceKey) { + this.sourceKey = sourceKey; + return this; + } + + public SourceClip withStartTimeInSecond(Integer startTimeInSecond) { + this.startTimeInSecond = startTimeInSecond; + return this; + } + + + public SourceClip withDurationInSecond(Integer durationInSecond) { + this.durationInSecond = durationInSecond; + return this; + } + + public SourceClip withStartTimeInMillisecond(Integer startTimeInMillisecond) { + this.startTimeInMillisecond = startTimeInMillisecond; + return this; + } + + public SourceClip withDurationInMillisecond(Integer durationInMillisecond) { + this.durationInMillisecond = durationInMillisecond; + return this; + } + + public SourceClip withEnableLogo(Boolean enableLogo) { + this.enableLogo = enableLogo; + return this; + } + + public SourceClip withBucket(String bucket) { + this.bucket = bucket; + return this; + } + + public SourceClip withAsMasterClip(Boolean enableDelogo) { + this.asMasterClip = asMasterClip; + return this; + } + + public SourceClip withEnableDelogo(Boolean enableDelogo) { + this.enableDelogo = enableDelogo; + return this; + } + + public SourceClip withEnableCrop(Boolean enableCrop) { + this.enableCrop = enableCrop; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Clip {\n"); + sb.append(" bucket: ").append(bucket).append("\n"); + sb.append(" sourceKey: ").append(sourceKey).append("\n"); + sb.append(" startTimeInSecond: ").append(startTimeInSecond).append("\n"); + sb.append(" durationInSecond: ").append(durationInSecond).append("\n"); + sb.append(" startTimeInMillisecond: ").append(startTimeInMillisecond).append("\n"); + sb.append(" durationInMillisecond: ").append(durationInMillisecond).append("\n"); + sb.append(" enableLogo: ").append(enableLogo).append("\n"); + sb.append(" asMasterClip: ").append(asMasterClip).append("\n"); + sb.append(" enableDelogo: ").append(enableDelogo).append("\n"); + sb.append(" enableCrop: ").append(enableCrop).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/SpriteOutputCfg.java b/src/main/java/com/baidubce/services/media/model/SpriteOutputCfg.java new file mode 100644 index 00000000..2f8d4f94 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/SpriteOutputCfg.java @@ -0,0 +1,51 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.Size; + +/** + * @description: thumbnail sprite output configuration. + **/ + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SpriteOutputCfg { + @Min(1) + @Max(100) + private Integer rows = 10; + + @Min(1) + @Max(100) + private Integer columns = 10; + + @Min(0) + @Max(1000) + private Integer margin = 0; + + @Min(0) + @Max(1000) + private Integer padding = 0; + + private Boolean keepCellPic = true; + + @Size(min = 1, max = 100) + private String spriteKeyTag = "-SPRITE-"; +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/media/model/SubtitleConfig.java b/src/main/java/com/baidubce/services/media/model/SubtitleConfig.java new file mode 100644 index 00000000..a3351c3e --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/SubtitleConfig.java @@ -0,0 +1,33 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import lombok.Data; + +/** + * Subtitle job target configuration. + */ +@Data +public class SubtitleConfig { + + /** + * Max number of words in one sentence. + */ + private Integer maxSentenceLen; + + public SubtitleConfig withMaxSentenceLen(Integer maxSentenceLen) { + this.maxSentenceLen = maxSentenceLen; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/media/model/SubtitleJobStatus.java b/src/main/java/com/baidubce/services/media/model/SubtitleJobStatus.java new file mode 100644 index 00000000..02e0c453 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/SubtitleJobStatus.java @@ -0,0 +1,72 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import lombok.Data; + +@Data +public class SubtitleJobStatus { + /** + * the subtitle job Id + **/ + private String jobId = null; + + /** + * the subtitle job status + **/ + private String jobStatus = null; + + /** + * The pipeline name of the subtitle job + **/ + private String pipelineName = null; + + /** + * The source information of the subtitle job + **/ + private SubtitleSource source = null; + + /** + * The target configuration of the subtitle job + **/ + private SubtitleTargetStatus target = null; + + /** + * The extra configuration of subtitle job + **/ + private SubtitleConfig config = null; + + /** + * error information + **/ + private MediaError error = null; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetSubtitleJobResponse {\n"); + sb.append(" jobId: ").append(jobId).append("\n"); + sb.append(" jobStatus: ").append(jobStatus).append("\n"); + sb.append(" pipeline: ").append(pipelineName).append("\n"); + sb.append(" source: ").append(source).append("\n"); + sb.append(" target: ").append(target).append("\n"); + sb.append(" config: ").append(config).append("\n"); + if (error != null) { + sb.append(" error: ").append(error).append("\n"); + } + sb.append("}\n"); + return sb.toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/SubtitleSource.java b/src/main/java/com/baidubce/services/media/model/SubtitleSource.java new file mode 100644 index 00000000..01fea5f9 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/SubtitleSource.java @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import lombok.Data; + +/** + * Subtitle job Source configuration. + */ +@Data +public class SubtitleSource { + /** + * Media file key in bos to create subtitle + */ + private String key = null; + + public SubtitleSource withKey(String key) { + this.key = key; + return this; + } + + @Override + public String toString() { + return "SubtitleSource [key=" + key + "]"; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/SubtitleTarget.java b/src/main/java/com/baidubce/services/media/model/SubtitleTarget.java new file mode 100644 index 00000000..7176ad11 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/SubtitleTarget.java @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import java.util.ArrayList; +import java.util.List; + +import lombok.Data; + +/** + * Subtitle job target configuration. + */ +@Data +public class SubtitleTarget { + + /** + * The key prefix of subtitle file in bos. + */ + private String keyPrefix; + + /** + * The format of subtitls, can be json, srt. + */ + private List formats; + + public SubtitleTarget withKeyPrefix(String keyPrefix) { + this.keyPrefix = keyPrefix; + return this; + } + + public SubtitleTarget withFormats(List formats) { + this.formats = formats; + return this; + } + + public SubtitleTarget addFormat(String format) { + if (this.formats == null) { + this.formats = new ArrayList(); + } + this.formats.add(format); + return this; + } + + +} diff --git a/src/main/java/com/baidubce/services/media/model/SubtitleTargetStatus.java b/src/main/java/com/baidubce/services/media/model/SubtitleTargetStatus.java new file mode 100644 index 00000000..3135a7bd --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/SubtitleTargetStatus.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import java.util.List; + +import lombok.Data; + +/** + * Subtitle job target information. + */ +@Data +public class SubtitleTargetStatus { + + private String keyPrefix; + + private List formats; + + private List keys; + +} diff --git a/src/main/java/com/baidubce/services/media/model/Target.java b/src/main/java/com/baidubce/services/media/model/Target.java index a6f04998..4fa4686d 100644 --- a/src/main/java/com/baidubce/services/media/model/Target.java +++ b/src/main/java/com/baidubce/services/media/model/Target.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Baidu, Inc. + * Copyright 2015-2020 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -13,48 +13,268 @@ package com.baidubce.services.media.model; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + import static com.baidubce.util.Validate.checkStringNotEmpty; +/** + * The model which will be used to set target info in creating transcoding job + */ +@Data public class Target { + + private String targetBucket = null; + + /** + * target BOS key + **/ private String targetKey = null; + + /** + * preset name + **/ private String presetName = null; /** - * 目标文件的BOS key + * auto delogo + */ + private Boolean autoDelogo; + + /** + * delogo mode, can be Normal, Inpainting + */ + private String delogoMode; + + /** + * delogo area + * use delogoAreas instead. + **/ + @Deprecated + private Area delogoArea = null; + + /** + * delogo areas + **/ + private List delogoAreas = null; + + /** + * enable auto crop + **/ + private Boolean autoCrop = null; + + /** + * crop area + **/ + private Area crop = null; + + /** + * watermark with job + **/ + private List watermarkIds = null; + + /** + * inserts of video, audio, image, text types **/ + private List inserts = null; + + private JobCfg jobCfg; + + public String getTargetBucket() { + return targetBucket; + } + + public void setTargetBucket(String targetBucket) { + this.targetBucket = targetBucket; + } + public String getTargetKey() { return targetKey; } public void setTargetKey(String targetKey) { - checkStringNotEmpty(targetKey, "The parameter targetKey should NOT be null or empty string."); - this.targetKey = targetKey; - } - - public Target withTargetKey(String targetKey) { - checkStringNotEmpty(targetKey, "The parameter targetKey should NOT be null or empty string."); this.targetKey = targetKey; - return this; } - /** - * 输出处理的模板的presetName - **/ public String getPresetName() { return presetName; } public void setPresetName(String presetName) { - checkStringNotEmpty(presetName, "The parameter presetName should NOT be null or empty string."); this.presetName = presetName; } + public Boolean getAutoDelogo() { + return autoDelogo; + } + + public void setAutoDelogo(Boolean autoDelogo) { + this.autoDelogo = autoDelogo; + } + + public String getDelogoMode() { + return delogoMode; + } + + public void setDelogoMode(String delogoMode) { + this.delogoMode = delogoMode; + } + + public Area getDelogoArea() { + return delogoArea; + } + + public void setDelogoArea(Area delogoArea) { + this.delogoArea = delogoArea; + } + + public List getDelogoAreas() { + return delogoAreas; + } + + public void setDelogoAreas(List delogoAreas) { + this.delogoAreas = delogoAreas; + } + + public Boolean getAutoCrop() { + return autoCrop; + } + + public void setAutoCrop(Boolean autoCrop) { + this.autoCrop = autoCrop; + } + + public Area getCrop() { + return crop; + } + + public void setCrop(Area crop) { + this.crop = crop; + } + + public List getWatermarkIds() { + return watermarkIds; + } + + public void setWatermarkIds(List watermarkIds) { + this.watermarkIds = watermarkIds; + } + + public List getInserts() { + return inserts; + } + + public void setInserts(List inserts) { + this.inserts = inserts; + } + + public static class JobCfg { + private String notification; + + public JobCfg() { + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + public JobCfg withNotification(String notification) { + this.notification = notification; + return this; + } + } + + public JobCfg getJobCfg() { + return jobCfg; + } + + public void setJobCfg(JobCfg jobCfg) { + this.jobCfg = jobCfg; + } + + public Target withTargetBucket(String targetBucket) { + this.targetBucket = targetBucket; + return this; + } + + public Target withTargetKey(String targetKey) { + checkStringNotEmpty(targetKey, "The parameter targetKey should NOT be null or empty string."); + this.targetKey = targetKey; + return this; + } + public Target withPresetName(String presetName) { checkStringNotEmpty(presetName, "The parameter presetName should NOT be null or empty string."); this.presetName = presetName; return this; } + public Target withAutoDelogo(Boolean autoDelogo) { + this.autoDelogo = autoDelogo; + return this; + } + + public Target withDelogoMode(String delogoMode) { + this.delogoMode = delogoMode; + return this; + } + + @Deprecated + public Target withDelogoArea(Area delogoArea) { + this.delogoArea = delogoArea; + return this; + } + + public Target withDelogoAreas(List delogoAreas) { + this.delogoAreas = delogoAreas; + return this; + } + + public Target addDelogoArea(Area delogoArea) { + if (this.delogoAreas == null) { + delogoAreas = new ArrayList(); + } + delogoAreas.add(delogoArea); + return this; + } + + public Target withAutpCrop(Boolean autoCrop) { + this.autoCrop = autoCrop; + return this; + } + + public Target withCrop(Area crop) { + this.crop = crop; + return this; + } + + public Target withWatermarkIds(List watermarkIds) { + this.watermarkIds = watermarkIds; + return this; + } + + public Target withJobCfg(JobCfg jobCfg) { + this.jobCfg = jobCfg; + return this; + } + + public Target withInserts(List inserts) { + this.inserts = inserts; + return this; + } + + public void addInsert(Insert insert) { + if (inserts == null) { + inserts = new ArrayList(); + } + inserts.add(insert); + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -62,6 +282,11 @@ public String toString() { sb.append(" targetKey: ").append(targetKey).append("\n"); sb.append(" presetName: ").append(presetName).append("\n"); + sb.append(" delogoArea: ").append(delogoArea).append("\n"); + sb.append(" autoCrop: ").append(autoCrop).append("\n"); + sb.append(" crop: ").append(crop).append("\n"); + sb.append(" watermarkIds: ").append(watermarkIds).append("\n"); + sb.append(" inserts: ").append(inserts).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailCapture.java b/src/main/java/com/baidubce/services/media/model/ThumbnailCapture.java index 229bce73..8d1f6304 100644 --- a/src/main/java/com/baidubce/services/media/model/ThumbnailCapture.java +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailCapture.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Baidu, Inc. + * Copyright 2015-2020 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -13,15 +13,66 @@ package com.baidubce.services.media.model; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; + +/** + * The model which will be used to set capture info in creating thumbnail job + */ +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) public class ThumbnailCapture { + /** + * The mode of thumbnail preset, can auto, manual, split, shot, idl or highlight. + */ private String mode = null; - private Integer startTimeInSecond = null; + /** + * The start time to create thumbnails, support in manual or split mode, default 0.0. + */ + @JsonIgnore + private Double startTimeInSecond = null; - private Integer endTimeInSecond = null; + /** + * The end time to create thumbnails, support in manual or split mode, default is video duration. + */ + @JsonIgnore + private Double endTimeInSecond = null; - private Integer intervalInSecond = null; + /** + * The interval between two thumbnails, only support in manual mode, default 1.0. + */ + @JsonIgnore + private Double intervalInSecond = null; + + /** + * The minium interval between two thumbnails, only support in split mode, default 1.0. + */ + private Double minIntervalInSecond = null; + + /** + * The max frame Number of thumbnsils, only support in split mode. + */ + private Integer frameNumber = null; + + /** + * Do not generate when frame is whole black if skipBlackFrame == true; + */ + private Boolean skipBlackFrame = null; + + /** + * Highlight mode configuration. + */ + private HighlightOutputCfg highlightOutputCfg = null; + + /** + * Thumbnail sprite output configuration. + */ + private SpriteOutputCfg spriteOutputCfg = null; public String getMode() { return mode; @@ -36,49 +87,220 @@ public ThumbnailCapture withMode(String mode) { return this; } + /** + * Use getStartTimeInSecondDouble instead. + */ + @Deprecated public Integer getStartTimeInSecond() { - return startTimeInSecond; + if (startTimeInSecond == null) { + return null; + } + return startTimeInSecond.intValue(); } + /** + * Use setStartTimeInSecondDouble instead. + */ + @Deprecated public void setStartTimeInSecond(Integer startTimeInSecond) { - this.startTimeInSecond = startTimeInSecond; + if (startTimeInSecond == null) { + this.startTimeInSecond = null; + } + else { + this.startTimeInSecond = startTimeInSecond.doubleValue(); + } } + /** + * Use withStartTimeInSecondDouble instead. + */ + @Deprecated public ThumbnailCapture withStartTimeInSecond(Integer startTimeInSecond) { + this.setStartTimeInSecond(startTimeInSecond); + return this; + } + + /** + * Get the start time to create thumbnails. + */ + @JsonProperty("startTimeInSecond") + public Double getStartTimeInSecondDouble() { + return startTimeInSecond; + } + + /** + * Set the start time to create thumbnails, support in manual or split mode, default 0.0. + */ + public void setStartTimeInSecondDouble(Double startTimeInSecond) { + this.startTimeInSecond = startTimeInSecond; + } + + /** + * Set the start time to create thumbnails, support in manual or split mode, default 0.0. + */ + public ThumbnailCapture withStartTimeInSecondDouble(Double startTimeInSecond) { this.startTimeInSecond = startTimeInSecond; return this; } + /** + * Use getEndTimeInSecondDouble instead. + */ + @Deprecated public Integer getEndTimeInSecond() { - return endTimeInSecond; + if (endTimeInSecond == null) { + return null; + } + return endTimeInSecond.intValue(); } + /** + * Use setEndTimeInSecondDouble instead. + */ + @Deprecated public void setEndTimeInSecond(Integer endTimeInSecond) { - this.endTimeInSecond = endTimeInSecond; + if (endTimeInSecond == null) { + this.endTimeInSecond = null; + } + else { + this.endTimeInSecond = endTimeInSecond.doubleValue(); + } } + /** + * Use withEndTimeInSecondDouble instead. + */ + @Deprecated public ThumbnailCapture withEndTimeInSecond(Integer endTimeInSecond) { + this.setEndTimeInSecond(endTimeInSecond); + return this; + } + + /** + * Get the end time to create thumbnails. + */ + @JsonProperty("endTimeInSecond") + public Double getEndTimeInSecondDouble() { + return endTimeInSecond; + } + + /** + * Set the end time to create thumbnails, support in manual or split mode, default is video duration. + */ + public void setEndTimeInSecondDouble(Double endTimeInSecond) { + this.endTimeInSecond = endTimeInSecond; + } + + /** + * Set the end time to create thumbnails, support in manual or split mode, default is video duration. + */ + public ThumbnailCapture withEndTimeInSecondDouble(Double endTimeInSecond) { this.endTimeInSecond = endTimeInSecond; return this; } + /** + * Use getIntervalInSecondDouble instead. + */ + @Deprecated public Integer getIntervalInSecond() { - return intervalInSecond; + if (intervalInSecond == null) { + return null; + } + return intervalInSecond.intValue(); } + /** + * Use setIntervalInSecondDouble instead. + */ + @Deprecated public void setIntervalInSecond(Integer intervalInSecond) { + if (intervalInSecond == null) { + this.intervalInSecond = null; + } + else { + this.intervalInSecond = intervalInSecond.doubleValue(); + } + } + + /** + * Use withIntervalInSecondDouble instead. + */ + @Deprecated + public ThumbnailCapture withIntervalInSecond(Integer intervalInSecond) { + this.setIntervalInSecond(intervalInSecond); + return this; + } + + /** + * Get the interval between two thumbnails. + */ + @JsonProperty("intervalInSecond") + public Double getIntervalInSecondDouble() { + return intervalInSecond; + } + + /** + * Set the interval between two thumbnails, only support in manual mode, default 1.0. + */ + public void setIntervalInSecondDouble(Double intervalInSecond) { this.intervalInSecond = intervalInSecond; } - public ThumbnailCapture withIntervalInSecond(Integer intervalInSecond) { + /** + * Set the interval between two thumbnails, only support in manual mode, default 1.0. + */ + public ThumbnailCapture withIntervalInSecondDouble(Double intervalInSecond) { this.intervalInSecond = intervalInSecond; return this; } + public ThumbnailCapture withMinIntervalInSecond(Double minIntervalInSecond) { + this.minIntervalInSecond = minIntervalInSecond; + return this; + } + + public ThumbnailCapture withFrameNumber(Integer frameNumber) { + this.frameNumber = frameNumber; + return this; + } + + public ThumbnailCapture withSkipBlackFrame(Boolean skipBlackFrame) { + this.skipBlackFrame = skipBlackFrame; + return this; + } + + public ThumbnailCapture withHighlightOutputCfg(HighlightOutputCfg highlightOutputCfg) { + this.highlightOutputCfg = highlightOutputCfg; + return this; + } + + public SpriteOutputCfg getSpriteOutputCfg() { + return spriteOutputCfg; + } + + /** + * Use ThumbnailTarget.setSpriteOutputCfg instead. + */ + @Deprecated + public SpriteOutputCfg setSpriteOutputCfg(SpriteOutputCfg spriteOutputCfg) { + return this.spriteOutputCfg = spriteOutputCfg; + } + + /** + * Use ThumbnailTarget.withSpriteOutputCfg instead. + */ + @Deprecated + public ThumbnailCapture withSpriteOutputCfg(SpriteOutputCfg spriteOutputCfg) { + this.spriteOutputCfg = spriteOutputCfg; + return this; + } + @Override public String toString() { return "ThumbnailCapture [mode=" + mode + ", startTimeInSecond=" + startTimeInSecond + ", endTimeInSecond=" - + endTimeInSecond + ", intervalInSecond=" + intervalInSecond + "]"; + + endTimeInSecond + ", intervalInSecond=" + intervalInSecond + + ", frameNumber=" + frameNumber + ", skipBlackFrame=" + skipBlackFrame + "]"; } - + } diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailJobStatus.java b/src/main/java/com/baidubce/services/media/model/ThumbnailJobStatus.java index fd98820f..bc307d14 100644 --- a/src/main/java/com/baidubce/services/media/model/ThumbnailJobStatus.java +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailJobStatus.java @@ -14,19 +14,49 @@ package com.baidubce.services.media.model; public class ThumbnailJobStatus { - + /** + * the thumbnail job Id + **/ private String jobId = null; - + + /** + * the thumbnail job status + **/ private String jobStatus = null; - + + /** + * the pipeline name of the thumbnail job + **/ private String pipelineName = null; - + + /** + * the source information of the thumbnail job + **/ private ThumbnailSource source = null; - + + /** + * the target information of the thumbnail job + **/ private ThumbnailTargetStatus target = null; - + + /** + * the information that tells how to pick the thumbnails + **/ private ThumbnailCapture capture = null; + /** + * delogo area + **/ + private Area delogoArea = null; + + /** + * crop area + **/ + private Area crop = null; + + /** + * error information + **/ private MediaError error = null; public String getJobId() { @@ -77,6 +107,22 @@ public void setCapture(ThumbnailCapture capture) { this.capture = capture; } + public Area getDelogoArea() { + return delogoArea; + } + + public void setDelogoArea(Area delogoArea) { + this.delogoArea = delogoArea; + } + + public Area getCrop() { + return crop; + } + + public void setCrop(Area crop) { + this.crop = crop; + } + public MediaError getError() { return error; } @@ -95,6 +141,12 @@ public String toString() { sb.append(" source: ").append(source).append("\n"); sb.append(" target: ").append(target).append("\n"); sb.append(" capture: ").append(capture).append("\n"); + if (delogoArea != null) { + sb.append(" delogoArea: ").append(delogoArea).append("\n"); + } + if (crop != null) { + sb.append(" crop: ").append(crop).append("\n"); + } if (error != null) { sb.append(error).append("\n"); } diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailPresetCapture.java b/src/main/java/com/baidubce/services/media/model/ThumbnailPresetCapture.java new file mode 100644 index 00000000..f17aad7e --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailPresetCapture.java @@ -0,0 +1,153 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * The model which will be used to set capture info in creating thumbnail. + */ +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ThumbnailPresetCapture { + + /** + * The mode of thumbnail preset, can auto, manual, split, shot, idl or highlight. + */ + private String mode = null; + + /** + * The start time to create thumbnails, support in manual or split mode, default 0.0. + */ + private Double startTimeInSecond = null; + + /** + * The end time to create thumbnails, support in manual or split mode, default is video duration. + */ + private Double endTimeInSecond = null; + + /** + * The interval between two thumbnails, only support in manual mode, default 1.0. + */ + private Double intervalInSecond = null; + + /** + * The minium interval between two thumbnails, only support in split mode, default 1.0. + */ + private Double minIntervalInSecond = null; + + /** + * The max frame Number of thumbnsils, only support in split mode. + */ + private Integer frameNumber = null; + + /** + * Do not generate when frame is whole black if skipBlackFrame == true; + */ + private Boolean skipBlackFrame = null; + + /** + * Highlight mode configuration. + */ + private HighlightOutputCfg highlightOutputCfg = null; + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public ThumbnailPresetCapture withMode(String mode) { + this.mode = mode; + return this; + } + + public Double getStartTimeInSecond() { + return startTimeInSecond; + } + + public void setStartTimeInSecond(Double startTimeInSecond) { + this.startTimeInSecond = startTimeInSecond.doubleValue(); + } + + public ThumbnailPresetCapture withStartTimeInSecond(Double startTimeInSecond) { + this.startTimeInSecond = startTimeInSecond.doubleValue(); + return this; + } + + public Double getEndTimeInSecond() { + return endTimeInSecond; + } + + public void setEndTimeInSecond(Double endTimeInSecond) { + this.endTimeInSecond = endTimeInSecond.doubleValue(); + } + + public ThumbnailPresetCapture withEndTimeInSecond(Double endTimeInSecond) { + this.endTimeInSecond = endTimeInSecond.doubleValue(); + return this; + } + + public Double getIntervalInSecond() { + return intervalInSecond; + } + + public void setIntervalInSecond(Double intervalInSecond) { + this.intervalInSecond = intervalInSecond.doubleValue(); + } + + public ThumbnailPresetCapture withIntervalInSecond(Double intervalInSecond) { + this.intervalInSecond = intervalInSecond.doubleValue(); + return this; + } + + public Double getMinIntervalInSecond() { + return minIntervalInSecond; + } + + public void setMinIntervalInSecond(Double minIntervalInSecond) { + this.minIntervalInSecond = minIntervalInSecond.doubleValue(); + } + + public ThumbnailPresetCapture withMinIntervalInSecond(Double minIntervalInSecond) { + this.minIntervalInSecond = minIntervalInSecond.doubleValue(); + return this; + } + + public ThumbnailPresetCapture withFrameNumber(Integer frameNumber) { + this.frameNumber = frameNumber; + return this; + } + + public ThumbnailPresetCapture withSkipBlackFrame(Boolean skipBlackFrame) { + this.skipBlackFrame = skipBlackFrame; + return this; + } + + public ThumbnailPresetCapture withHighlightOutputCfg(HighlightOutputCfg highlightOutputCfg) { + this.highlightOutputCfg = highlightOutputCfg; + return this; + } + + @Override + public String toString() { + return "ThumbnailPresetCapture [mode=" + mode + ", startTimeInSecond=" + startTimeInSecond + + ", endTimeInSecond=" + endTimeInSecond + ", intervalInSecond=" + intervalInSecond + + ", frameNumber=" + frameNumber + ", skipBlackFrame=" + skipBlackFrame + "]"; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailPresetTarget.java b/src/main/java/com/baidubce/services/media/model/ThumbnailPresetTarget.java new file mode 100644 index 00000000..5310aa49 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailPresetTarget.java @@ -0,0 +1,147 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +/** + * Thumbnail preset target configuration. + */ +public class ThumbnailPresetTarget { + + /** + * The file format of the thumbnails, can be jpg, png, mp4, gif or webp. + */ + private String format = null; + + /** + * The display frame rate of thumbnails, only support in gif, webp, mp4 format, 0.01 - 30.0. + */ + private Double frameRate = null; + + /** + * The quality of gif, only support in gif format, can be medium or high. + */ + private String gifQuality = null; + + /** + * The sizing Policy of thumbnail, can be keep, shrinkToFit or stretch. + */ + private String sizingPolicy = null; + + /** + * The expected with of thumbnail, 10 - 2000. + */ + private Integer widthInPixel = null; + + /** + * The expected height of thumbnail, 10 - 2000. + */ + private Integer heightInPixel = null; + + /** + * Thumbnail sprite output configuration. + */ + private SpriteOutputCfg spriteOutputCfg = null; + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public ThumbnailPresetTarget withFormat(String format) { + this.format = format; + return this; + } + + public Double getFrameRate() { + return frameRate; + } + + public void setFrameRate(Double frameRate) { + this.frameRate = frameRate; + } + + public ThumbnailPresetTarget withFrameRate(Double frameRate) { + this.frameRate = frameRate; + return this; + } + + public String getGifQuality() { + return gifQuality; + } + + public void setGifQuality(String gifQuality) { + this.gifQuality = gifQuality; + } + + public ThumbnailPresetTarget withGifQuality(String gifQuality) { + this.gifQuality = gifQuality; + return this; + } + + public String getSizingPolicy() { + return sizingPolicy; + } + + public void setSizingPolicy(String sizingPolicy) { + this.sizingPolicy = sizingPolicy; + } + + public ThumbnailPresetTarget withSizingPolicy(String sizingPolicy) { + this.sizingPolicy = sizingPolicy; + return this; + } + + public Integer getWidthInPixel() { + return widthInPixel; + } + + public void setWidthInPixel(Integer widthInPixel) { + this.widthInPixel = widthInPixel; + } + + public ThumbnailPresetTarget withWidthInPixel(Integer widthInPixel) { + this.widthInPixel = widthInPixel; + return this; + } + + public Integer getHeightInPixel() { + return heightInPixel; + } + + public void setHeightInPixel(Integer heightInPixel) { + this.heightInPixel = heightInPixel; + } + + public ThumbnailPresetTarget withHeightInPixel(Integer heightInPixel) { + this.heightInPixel = heightInPixel; + return this; + } + + public SpriteOutputCfg getSpriteOutputCfg() { + return spriteOutputCfg; + } + + public SpriteOutputCfg setSpriteOutputCfg(SpriteOutputCfg spriteOutputCfg) { + return this.spriteOutputCfg = spriteOutputCfg; + } + + public ThumbnailPresetTarget withSpriteOutputCfg(SpriteOutputCfg spriteOutputCfg) { + this.spriteOutputCfg = spriteOutputCfg; + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailTarget.java b/src/main/java/com/baidubce/services/media/model/ThumbnailTarget.java index 84241d94..560c14d3 100644 --- a/src/main/java/com/baidubce/services/media/model/ThumbnailTarget.java +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailTarget.java @@ -13,19 +13,51 @@ package com.baidubce.services.media.model; - +/** + * Thumbnail job target configuration. + */ public class ThumbnailTarget { + /** + * The target key prefix of thumbnails. + */ private String keyPrefix = null; - + + /** + * The file format of the thumbnails, can be jpg, png, mp4, gif or webp. + */ private String format = null; - + + /** + * The display frame rate of thumbnails, only support in gif, webp, mp4 format, 0.01 - 30.0. + */ + private Double frameRate = null; + + /** + * The quality of gif, only support in gif format, can be medium or high. + */ + private String gifQuality = null; + + /** + * The sizing Policy of thumbnail, can be keep, shrinkToFit or stretch. + */ private String sizingPolicy = null; + /** + * The expected with of thumbnail, 10 - 2000. + */ private Integer widthInPixel = null; + /** + * The expected height of thumbnail, 10 - 2000. + */ private Integer heightInPixel = null; + /** + * Thumbnail sprite output configuration. + */ + private SpriteOutputCfg spriteOutputCfg = null; + public String getKeyPrefix() { return keyPrefix; } @@ -52,6 +84,32 @@ public ThumbnailTarget withFormat(String format) { return this; } + public Double getFrameRate() { + return frameRate; + } + + public void setFrameRate(Double frameRate) { + this.frameRate = frameRate; + } + + public ThumbnailTarget withFrameRate(Double frameRate) { + this.frameRate = frameRate; + return this; + } + + public String getGifQuality() { + return gifQuality; + } + + public void setGifQuality(String gifQuality) { + this.gifQuality = gifQuality; + } + + public ThumbnailTarget withGifQuality(String gifQuality) { + this.gifQuality = gifQuality; + return this; + } + public String getSizingPolicy() { return sizingPolicy; } @@ -91,5 +149,17 @@ public ThumbnailTarget withHeightInPixel(Integer heightInPixel) { return this; } + public SpriteOutputCfg getSpriteOutputCfg() { + return spriteOutputCfg; + } + + public SpriteOutputCfg setSpriteOutputCfg(SpriteOutputCfg spriteOutputCfg) { + return this.spriteOutputCfg = spriteOutputCfg; + } + + public ThumbnailTarget withSpriteOutputCfg(SpriteOutputCfg spriteOutputCfg) { + this.spriteOutputCfg = spriteOutputCfg; + return this; + } } diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailTargetStatus.java b/src/main/java/com/baidubce/services/media/model/ThumbnailTargetStatus.java index f4bfe929..0ec46915 100644 --- a/src/main/java/com/baidubce/services/media/model/ThumbnailTargetStatus.java +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailTargetStatus.java @@ -4,16 +4,47 @@ import java.util.List; public class ThumbnailTargetStatus { + + /** + * The target key prefix of thumbnails. + */ private String keyPrefix = null; - + + /** + * The file format of the thumbnails, can be jpg, png, mp4, gif or webp. + */ private String format = null; - + + /** + * The display frame rate of thumbnails, only support in gif, webp, mp4 format, 0.01 - 30.0. + */ + private Double frameRate = null; + + /** + * The quality of gif, only support in gif format, can be medium or high. + */ + private String gifQuality = null; + + /** + * The sizing Policy of thumbnail, can be keep, shrinkToFit or stretch. + */ private String sizingPolicy = null; + /** + * The expected with of thumbnail, 10 - 2000. + */ private Integer widthInPixel = null; + /** + * The expected height of thumbnail, 10 - 2000. + */ private Integer heightInPixel = null; + /** + * Thumbnail sprite output configuration. + */ + private SpriteOutputCfg spriteOutputCfg = null; + public String getKeyPrefix() { return keyPrefix; } @@ -40,6 +71,32 @@ public ThumbnailTargetStatus withFormat(String format) { return this; } + public Double getFrameRate() { + return frameRate; + } + + public void setFrameRate(Double frameRate) { + this.frameRate = frameRate; + } + + public ThumbnailTargetStatus withFrameRate(Double frameRate) { + this.frameRate = frameRate; + return this; + } + + public String getGifQuality() { + return gifQuality; + } + + public void setGifQuality(String gifQuality) { + this.gifQuality = gifQuality; + } + + public ThumbnailTargetStatus withGifQuality(String gifQuality) { + this.gifQuality = gifQuality; + return this; + } + public String getSizingPolicy() { return sizingPolicy; } @@ -79,6 +136,19 @@ public ThumbnailTargetStatus withHeightInPixel(Integer heightInPixel) { return this; } + public SpriteOutputCfg getSpriteOutputCfg() { + return spriteOutputCfg; + } + + public SpriteOutputCfg setSpriteOutputCfg(SpriteOutputCfg spriteOutputCfg) { + return this.spriteOutputCfg = spriteOutputCfg; + } + + public ThumbnailTargetStatus withSpriteOutputCfg(SpriteOutputCfg spriteOutputCfg) { + this.spriteOutputCfg = spriteOutputCfg; + return this; + } + private List keys = new ArrayList(); public List getKeys() { @@ -96,9 +166,10 @@ public ThumbnailTargetStatus withKeys(List keys) { @Override public String toString() { - return "ThumbnailTargetStatus [keyPrefix=" + keyPrefix + ", format=" + format + ", sizingPolicy=" - + sizingPolicy + ", widthInPixel=" + widthInPixel + ", heightInPixel=" + heightInPixel + ", keys=" - + keys + "]"; + return "ThumbnailTargetStatus [keyPrefix=" + keyPrefix + + ", format=" + format + ", frameRate=" + frameRate + ", gifQuality=" + gifQuality + + ", sizingPolicy=" + sizingPolicy + ", widthInPixel=" + widthInPixel + + ", heightInPixel=" + heightInPixel + ", keys=" + keys + "]"; } } diff --git a/src/main/java/com/baidubce/services/media/model/Timeline.java b/src/main/java/com/baidubce/services/media/model/Timeline.java new file mode 100644 index 00000000..21b48291 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/Timeline.java @@ -0,0 +1,63 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +public class Timeline { + /** + * start time in milliseconds + */ + private Integer startTimeInMillisecond = null; + + /** + * duration in milliseconds + */ + private Integer durationInMillisecond = null; + + public Integer getStartTimeInMillisecond() { + return startTimeInMillisecond; + } + + public void setStartTimeInMillisecond(Integer startTimeInMillisecond) { + this.startTimeInMillisecond = startTimeInMillisecond; + } + + public Timeline withStartTimeInMillisecond(Integer startTimeInMillisecond) { + this.startTimeInMillisecond = startTimeInMillisecond; + return this; + } + + public Integer getDurationInMillisecond() { + return durationInMillisecond; + } + + public void setDurationInMillisecond(Integer durationInMillisecond) { + this.durationInMillisecond = durationInMillisecond; + } + + public Timeline withDurationInMillisecond(Integer durationInMillisecond) { + this.durationInMillisecond = durationInMillisecond; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Timeline {\n"); + + sb.append(" startTimeInMillisecond: ").append(startTimeInMillisecond).append("\n"); + sb.append(" durationInMillisecond: ").append(durationInMillisecond).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/TransCfg.java b/src/main/java/com/baidubce/services/media/model/TransCfg.java new file mode 100644 index 00000000..da8a299c --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/TransCfg.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +public class TransCfg { + /** + * transcoding mode, options include normal, twopass, cae, cae_enhanced + **/ + private String transMode = null; + + public String getTransMode() { + return transMode; + } + + public void setTransMode(String transMode) { + this.transMode = transMode; + } + + public TransCfg withTransMode(String transMode) { + this.transMode = transMode; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TransCfg {\n"); + + sb.append(" transMode: ").append(transMode).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/UpdatePipelineRequest.java b/src/main/java/com/baidubce/services/media/model/UpdatePipelineRequest.java new file mode 100644 index 00000000..baceb19c --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/UpdatePipelineRequest.java @@ -0,0 +1,91 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import static com.baidubce.util.Validate.checkStringNotEmpty; + +/** + * The request for updating pipeline + */ +@Data +public class UpdatePipelineRequest extends AbstractBceRequest { + + private String pipelineName = null; + private String description = null; + private String sourceBucket = null; + private String targetBucket = null; + private PipelineConfig config = null; + + + public UpdatePipelineRequest withPipelineName(String pipelineName) { + checkStringNotEmpty(pipelineName, "The parameter pipelineName should NOT be null or empty string."); + this.pipelineName = pipelineName; + return this; + } + + public UpdatePipelineRequest withDescription(String description) { + this.description = description; + return this; + } + + public UpdatePipelineRequest withSourceBucket(String sourceBucket) { + checkStringNotEmpty(sourceBucket, "The parameter sourceBucket should NOT be null or empty string."); + this.sourceBucket = sourceBucket; + return this; + } + + public UpdatePipelineRequest withTargetBucket(String targetBucket) { + checkStringNotEmpty(targetBucket, "The parameter targetBucket should NOT be null or empty string."); + this.targetBucket = targetBucket; + return this; + } + + public UpdatePipelineRequest withConfig(PipelineConfig config) { + this.config = config; + return this; + } + + public UpdatePipelineRequest withPipeline(PipelineStatus pipeline) { + this.pipelineName = pipeline.getPipelineName(); + this.description = pipeline.getDescription(); + this.sourceBucket = pipeline.getSourceBucket(); + this.targetBucket = pipeline.getTargetBucket(); + this.config = pipeline.getConfig(); + return this; + } + + public UpdatePipelineRequest withRequestCredentials( + BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdatePipelineRequest {\n"); + + sb.append(" : ").append(pipelineName).append("\n"); + sb.append(" : ").append(description).append("\n"); + sb.append(" : ").append(sourceBucket).append("\n"); + sb.append(" : ").append(targetBucket).append("\n"); + sb.append(" : ").append(config).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/UpdatePipelineResponse.java b/src/main/java/com/baidubce/services/media/model/UpdatePipelineResponse.java new file mode 100644 index 00000000..5d7b344d --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/UpdatePipelineResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for updating pipeline + */ +public class UpdatePipelineResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/media/model/UpdatePresetRequest.java b/src/main/java/com/baidubce/services/media/model/UpdatePresetRequest.java new file mode 100644 index 00000000..8756bdeb --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/UpdatePresetRequest.java @@ -0,0 +1,193 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.Data; + +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; + +/** + * The request for updating preset + */ +@Data +public class UpdatePresetRequest extends AbstractBceRequest { + /** + * preset name + **/ + private String presetName = null; + + /** + * preset description + **/ + private String description = null; + + /** + * preset container, options include mp4, flv, hls, mp3, m4a, a-hls, pcm, dash + **/ + private String container = null; + + /** + * transmux mode + **/ + private Boolean transmux = null; + + /** + * clip source + **/ + private Clip clip = null; + + /** + * audio settings + **/ + private Audio audio = null; + + /** + * video settings + **/ + private Video video = null; + + /** + * HLS encryption settings + **/ + private Encryption encryption = null; + + /** + * watermark Id + **/ + private String watermarkId = null; + + /** + * multiple watermarks setting + **/ + private Watermarks watermarks = null; + + /** + * transcoding configurations + **/ + private TransCfg transCfg = null; + + /** + * extra transcoding configurations + **/ + private ExtraCfg extraCfg = null; + + public UpdatePresetRequest withPreset(GetPresetResponse preset) { + checkStringNotEmpty(preset.getPresetName(), + "The parameter presetName should NOT be null or empty string."); + this.presetName = preset.getPresetName(); + this.description = preset.getDescription(); + this.container = preset.getContainer(); + this.transmux = preset.getTransmux(); + this.clip = preset.getClip(); + this.audio = preset.getAudio(); + this.video = preset.getVideo(); + this.encryption = preset.getEncryption(); + this.watermarkId = preset.getWatermarkId(); + this.watermarks = preset.getWatermarks(); + this.transCfg = preset.getTransCfg(); + this.extraCfg = preset.getExtraCfg(); + return this; + } + + public UpdatePresetRequest withPresetName(String presetName) { + checkStringNotEmpty(presetName, "The parameter presetName should NOT be null or empty string."); + this.presetName = presetName; + return this; + } + + public UpdatePresetRequest withDescription(String description) { + this.description = description; + return this; + } + + public UpdatePresetRequest withContainer(String container) { + checkNotNull(container, "The parameter container should NOT be null."); + this.container = container; + return this; + } + + public UpdatePresetRequest withTransmux(Boolean transmux) { + this.transmux = transmux; + return this; + } + + public UpdatePresetRequest withClip(Clip clip) { + this.clip = clip; + return this; + } + + public UpdatePresetRequest withAudio(Audio audio) { + this.audio = audio; + return this; + } + + public UpdatePresetRequest withVideo(Video video) { + this.video = video; + return this; + } + + public UpdatePresetRequest withEncryption(Encryption encryption) { + this.encryption = encryption; + return this; + } + + public UpdatePresetRequest withWatermarkId(String watermarkId) { + this.watermarkId = watermarkId; + return this; + } + + public UpdatePresetRequest withWatermarks(Watermarks watermarks) { + this.watermarks = watermarks; + return this; + } + + public UpdatePresetRequest withTransCfg(TransCfg transCfg) { + this.transCfg = transCfg; + return this; + } + + public UpdatePresetRequest withExtraCfg(ExtraCfg extraCfg) { + this.extraCfg = extraCfg; + return this; + } + + public UpdatePresetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreatePresetRequest {\n"); + + sb.append(" presetName: ").append(presetName).append("\n"); + sb.append(" description: ").append(description).append("\n"); + sb.append(" container: ").append(container).append("\n"); + sb.append(" transmux: ").append(transmux).append("\n"); + sb.append(" clip: ").append(clip).append("\n"); + sb.append(" audio: ").append(audio).append("\n"); + sb.append(" video: ").append(video).append("\n"); + sb.append(" encryption: ").append(encryption).append("\n"); + sb.append(" watermarkId: ").append(watermarkId).append("\n"); + sb.append(" watermarks: ").append(watermarks).append("\n"); + sb.append(" transCfg: ").append(transCfg).append("\n"); + sb.append(" extraCfg: ").append(extraCfg).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/UpdatePresetResponse.java b/src/main/java/com/baidubce/services/media/model/UpdatePresetResponse.java new file mode 100644 index 00000000..30b4d0f5 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/UpdatePresetResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for updating pipeline + */ +public class UpdatePresetResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/media/model/UpdateThumbnailPresetRequest.java b/src/main/java/com/baidubce/services/media/model/UpdateThumbnailPresetRequest.java new file mode 100644 index 00000000..4d7bcd31 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/UpdateThumbnailPresetRequest.java @@ -0,0 +1,117 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request containing all options for updating a preset. + */ +public class UpdateThumbnailPresetRequest extends AbstractBceRequest { + + /** + * The name of the thumbnail preset + **/ + private String presetName = null; + + /** + * Preset description + **/ + private String description = null; + + /** + * The target information of the thumbnail preset + **/ + private ThumbnailPresetTarget target = null; + + /** + * The information that tells how to pick the thumbnails + **/ + private ThumbnailPresetCapture capture = null; + + public UpdateThumbnailPresetRequest withPreset(GetThumbnailPresetResponse preset) { + checkStringNotEmpty(preset.getPresetName(), + "The parameter presetName should NOT be null or empty string."); + this.presetName = preset.getPresetName(); + this.description = preset.getDescription(); + this.target = preset.getTarget(); + this.capture = preset.getCapture(); + return this; + } + + private void checkStringNotEmpty(String presetName2, String string) { + } + + public String getPresetName() { + return presetName; + } + + public void setPresetName(String presetName) { + checkStringNotEmpty(presetName, + "The parameter presetName should NOT be null or empty string."); + this.presetName = presetName; + } + + public UpdateThumbnailPresetRequest withPresetName(String presetName) { + this.presetName = presetName; + return this; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public UpdateThumbnailPresetRequest withDescription(String description) { + this.description = description; + return this; + } + + public ThumbnailPresetTarget getTarget() { + return target; + } + + public void setTarget(ThumbnailPresetTarget target) { + this.target = target; + } + + public UpdateThumbnailPresetRequest withTarget(ThumbnailPresetTarget target) { + this.target = target; + return this; + } + + public ThumbnailPresetCapture getCapture() { + return capture; + } + + public void setCapture(ThumbnailPresetCapture capture) { + this.capture = capture; + } + + public UpdateThumbnailPresetRequest withCapture(ThumbnailPresetCapture capture) { + this.capture = capture; + return this; + } + + @Override + public UpdateThumbnailPresetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/media/model/UpdateThumbnailPresetResponse.java b/src/main/java/com/baidubce/services/media/model/UpdateThumbnailPresetResponse.java new file mode 100644 index 00000000..35ac12ef --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/UpdateThumbnailPresetResponse.java @@ -0,0 +1,22 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response of updating a preset. + */ +public class UpdateThumbnailPresetResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/media/model/Video.java b/src/main/java/com/baidubce/services/media/model/Video.java index a46f2c97..3d0a8dfc 100644 --- a/src/main/java/com/baidubce/services/media/model/Video.java +++ b/src/main/java/com/baidubce/services/media/model/Video.java @@ -14,25 +14,59 @@ package com.baidubce.services.media.model; public class Video { + /** + * codec, options include h264, h265 + */ private String codec = null; + + /** + * codec options like profile + **/ private CodecOptions codecOptions = null; + + private String rateControl = null; + + /** + * target bitrate in bps + **/ private Integer bitRateInBps = null; - /* + /** * The max frames per second, * possible values include: 10,15, 23.97, 24, 25, 29.97, 30, 50, 60 - */ + **/ private Float maxFrameRate = null; + /** + * target max width in pixel + **/ private Integer maxWidthInPixel = null; + /** + * target max height in pixel + **/ private Integer maxHeigtInPixel = null; + /** + * sizing policy, options include keep、shrinkToFit、stretch + **/ private String sizingPolicy = null; /** - * 视频编码信息集合(H.264) + * playback speed + **/ + private Float playbackSpeed = null; + + /** + * constant rate factor + **/ + private Integer crf = null; + + /** + * auto adjust resolution if video is portrait and preset's width bigger than its height **/ + private Boolean autoAdjustResolution = null; + public String getCodec() { return codec; } @@ -46,9 +80,6 @@ public Video withCodec(String codec) { return this; } - /** - * 视频编码的配置选项 - **/ public CodecOptions getCodecOptions() { return codecOptions; } @@ -62,9 +93,6 @@ public Video withCodecOptions(CodecOptions codecOptions) { return this; } - /** - * 视频目标码率 - **/ public Integer getBitRateInBps() { return bitRateInBps; } @@ -73,14 +101,19 @@ public void setBitRateInBps(Integer bitRateInBps) { this.bitRateInBps = bitRateInBps; } + public String getRateControl() { + return rateControl; + } + + public void setRateControl(String rateControl) { + this.rateControl = rateControl; + } + public Video withBitRateInBps(Integer bitRateInBps) { this.bitRateInBps = bitRateInBps; return this; } - /** - * 目标视频最大帧率 - **/ public Float getMaxFrameRate() { return maxFrameRate; } @@ -94,9 +127,6 @@ public Video withMaxFrameRate(Float maxFrameRate) { return this; } - /** - * 目标视频最大帧率 - **/ public Integer getMaxWidthInPixel() { return maxWidthInPixel; } @@ -110,9 +140,6 @@ public Video withMaxWidthInPixel(Integer maxWidth) { return this; } - /** - * 目标视频的最大高度 - **/ public Integer getMaxHeightInPixel() { return maxHeigtInPixel; } @@ -126,9 +153,6 @@ public Video withMaxHeightInPixel(Integer maxHeight) { return this; } - /** - * 尺寸伸缩策略 - **/ public String getSizingPolicy() { return sizingPolicy; } @@ -142,6 +166,45 @@ public Video withSizingPolicy(String sizingPolicy) { return this; } + public Float getPlaybackSpeed() { + return playbackSpeed; + } + + public void setPlaybackSpeed(Float playbackSpeed) { + this.playbackSpeed = playbackSpeed; + } + + public Video withPlaybackSpeed(Float playbackSpeed) { + this.playbackSpeed = playbackSpeed; + return this; + } + + public Integer getCrf() { + return crf; + } + + public void setCrf(Integer crf) { + this.crf = crf; + } + + public Video withCrf(Integer crf) { + this.crf = crf; + return this; + } + + public Boolean getAutoAdjustResolution() { + return autoAdjustResolution; + } + + public void setAutoAdjustResolution(Boolean autoAdjustResolution) { + this.autoAdjustResolution = autoAdjustResolution; + } + + public Video withAutoAdjustResolution(Boolean autoAdjustResolution) { + this.autoAdjustResolution = autoAdjustResolution; + return this; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -149,11 +212,15 @@ public String toString() { sb.append(" codec: ").append(codec).append("\n"); sb.append(" codecOptions: ").append(codecOptions).append("\n"); + sb.append(" rateControl: ").append(rateControl).append("\n"); sb.append(" bitRateInBps: ").append(bitRateInBps).append("\n"); sb.append(" maxFrameRate: ").append(maxFrameRate).append("\n"); sb.append(" maxWidth: ").append(maxWidthInPixel).append("\n"); sb.append(" maxHeight: ").append(maxHeigtInPixel).append("\n"); sb.append(" sizingPolicy: ").append(sizingPolicy).append("\n"); + sb.append(" playbackSpeed: ").append(playbackSpeed).append("\n"); + sb.append(" crf: ").append(crf).append("\n"); + sb.append(" autoAdjustResolution: ").append(autoAdjustResolution).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/VideoInfo.java b/src/main/java/com/baidubce/services/media/model/VideoInfo.java index dacf6c8b..57767423 100644 --- a/src/main/java/com/baidubce/services/media/model/VideoInfo.java +++ b/src/main/java/com/baidubce/services/media/model/VideoInfo.java @@ -33,6 +33,10 @@ public class VideoInfo { // public enum frameRateEnum { }; + private Integer rotate; + + private String dar; + /** * 视频文件的编码规格 **/ @@ -87,6 +91,27 @@ public Integer getFrameRate() { public void setFrameRate(Integer frameRate) { this.frameRate = frameRate; } + /** + * 视频媒体的旋转角度 + **/ + public Integer getRotate() { + return rotate; + } + + public void setRotate(Integer rotate) { + this.rotate = rotate; + } + + /** + * 视频媒体的显示比例 + **/ + public String getDar() { + return dar; + } + + public void setDar(String dar) { + this.dar = dar; + } @Override public String toString() { @@ -98,6 +123,8 @@ public String toString() { sb.append(" widthInPixel: ").append(widthInPixel).append("\n"); sb.append(" bitRateInBps: ").append(bitRateInBps).append("\n"); sb.append(" frameRate: ").append(frameRate).append("\n"); + sb.append(" rotate: ").append(rotate).append("\n"); + sb.append(" dar: ").append(dar).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/VolumeAdjust.java b/src/main/java/com/baidubce/services/media/model/VolumeAdjust.java new file mode 100644 index 00000000..58efef72 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/VolumeAdjust.java @@ -0,0 +1,82 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +public class VolumeAdjust { + /** + * mute audio + */ + private Boolean mute = null; + + /** + * audio normalization + */ + private Boolean norm = null; + + /** + * volume gain + */ + private Integer gain = null; + + public Boolean getMute() { + return mute; + } + + public void setMute(Boolean mute) { + this.mute = mute; + } + + public VolumeAdjust withMute(Boolean mute) { + this.mute = mute; + return this; + } + + public Boolean getNorm() { + return norm; + } + + public void setNorm(Boolean norm) { + this.norm = norm; + } + + public VolumeAdjust withNorm(Boolean norm) { + this.norm = norm; + return this; + } + + public Integer getGain() { + return gain; + } + + public void setGain(Integer gain) { + this.gain = gain; + } + + public VolumeAdjust withGain(Integer gain) { + this.gain = gain; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VolumeAdjust {\n"); + + sb.append(" mute: ").append(mute).append("\n"); + sb.append(" norm: ").append(norm).append("\n"); + sb.append(" gain: ").append(gain).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/WaterMark.java b/src/main/java/com/baidubce/services/media/model/WaterMark.java index b310ceb6..bc2fe013 100644 --- a/src/main/java/com/baidubce/services/media/model/WaterMark.java +++ b/src/main/java/com/baidubce/services/media/model/WaterMark.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Baidu, Inc. + * Copyright 2015-2020 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -13,6 +13,12 @@ package com.baidubce.services.media.model; +import lombok.Data; + +/** + * The model of watermark + */ +@Data public class WaterMark { private String bucket = null; @@ -21,93 +27,76 @@ public class WaterMark { private Integer horizontalOffsetInPixel = null; private String watermarkId = null; private String createTime = null; + + @Deprecated private String verticalAlignment = null; + + @Deprecated private String horizontalAlignment = null; - public String getBucket() { - return bucket; - } - public void setBucket(String bucket) { - this.bucket = bucket; - } + /** + * horizontal offset in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String dx; + + /** + * vertical offset in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String dy; + + /** + * width of watermark in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String width; + + /** + * height of watermark in pixel or percent + * example: + * "100" means 100 pixel + * "0.1" means 10% + **/ + private String height; + + private Timeline timeline = null; + private Integer repeated = null; + private Boolean allowScaling = null; + public WaterMark withBucket(String bucket) { this.bucket = bucket; return this; } - public String getKey() { - return key; - } - public void setKey(String key) { - this.key = key; - } public WaterMark withKey(String key) { this.key = key; return this; } - public Integer getVerticalOffsetInPixel() { - return verticalOffsetInPixel; - } - public void setVerticalOffsetInPixel(Integer verticalOffsetInPixel) { - this.verticalOffsetInPixel = verticalOffsetInPixel; - } public WaterMark withVerticalOffsetInPixel(Integer verticalOffsetInPixel) { this.verticalOffsetInPixel = verticalOffsetInPixel; return this; } - - public Integer getHorizontalOffsetInPixel() { - return horizontalOffsetInPixel; - } - public void setHorizontalOffsetInPixel(Integer horizontalOffsetInPixel) { - this.horizontalOffsetInPixel = horizontalOffsetInPixel; - } + public WaterMark withHorizontalOffsetInPixel(Integer horizontalOffsetInPixel) { this.horizontalOffsetInPixel = horizontalOffsetInPixel; return this; } - - public String getWatermarkId() { - return watermarkId; - } - public void setWatermarkId(String watermarkId) { - this.watermarkId = watermarkId; - } - public WaterMark withWatermarkId(String watermarkId) { - this.watermarkId = watermarkId; - return this; - } - - public String getCreateTime() { - return createTime; - } - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - public WaterMark withCreateTime(String createTime) { - this.createTime = createTime; - return this; - } - - public String getVerticalAlignment() { - return verticalAlignment; - } - public void setVerticalAlignment(String verticalAlignment) { - this.verticalAlignment = verticalAlignment; - } - public String getHorizontalAlignment() { - return horizontalAlignment; - } - public void setHorizontalAlignment(String horizontalAlignment) { - this.horizontalAlignment = horizontalAlignment; - } - + @Override public String toString() { return "WaterMark [bucket=" + bucket + ", key=" + key + ", verticalOffsetInPixel=" + verticalOffsetInPixel + ", horizontalOffsetInPixel=" + horizontalOffsetInPixel + ", watermarkId=" + watermarkId + ", createTime=" + createTime + ", horizontalAlignment= " + horizontalAlignment - + ", verticalAlignment= " + verticalAlignment + "]"; + + ", verticalAlignment= " + verticalAlignment + ", dx = " + dx + + ", dy= " + dy + ", width= " + width + ", height= " + height + ", timeline= " + timeline + + ", repeated= " + repeated + ", allowScaling= " + allowScaling + "]"; } } diff --git a/src/main/java/com/baidubce/services/media/model/Watermarks.java b/src/main/java/com/baidubce/services/media/model/Watermarks.java new file mode 100644 index 00000000..6dd998c5 --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/Watermarks.java @@ -0,0 +1,46 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +import java.util.List; + +public class Watermarks { + /** + * the list of image watermark IDs + **/ + private List image = null; + + public List getImage() { + return image; + } + + public void setImage(List image) { + this.image = image; + } + + public Watermarks withImage(List image) { + this.image = image; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Watermarks {\n"); + + sb.append(" image: ").append(image).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/mms/MmsClient.java b/src/main/java/com/baidubce/services/mms/MmsClient.java new file mode 100644 index 00000000..156dcd4f --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/MmsClient.java @@ -0,0 +1,389 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mms; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.baidubce.services.mms.model.SourceAndDescRequest; +import com.baidubce.services.mms.model.InsertVideoResultResponse; +import com.baidubce.services.mms.model.SourceRequest; +import com.baidubce.services.mms.model.MmsBaseResponse; +import com.baidubce.services.mms.model.MmsListLibResponse; +import com.baidubce.services.mms.model.MmsListMediaResponse; +import com.baidubce.services.mms.model.SearchImageResponse; +import com.baidubce.services.mms.model.SearchVideoResponse; +import com.baidubce.services.mms.model.CreateLibRequest; +import com.baidubce.services.mms.model.ListLibRequest; +import com.baidubce.services.mms.model.ListMediaRequest; + +/** Provides the client for accessing the BCE MMS service. */ +public class MmsClient extends AbstractBceClient { + + private static final String VERSION = "v2"; + + private static final String VIDEO_LIB = "videolib"; + + private static final String IMAGE_LIB = "imagelib"; + + private static final String LIB = "lib"; + + private static final String LIST = "list"; + + private static final String ITEM = "item"; + + private static final String SEARCH_BY_IMAGE = "searchByImage"; + + private static final String SEARCH_BY_VIDEO = "searchByVideo"; + + private static final String DELETE_VIDEO = "deleteVideo"; + + private static final String DELETE_IMAGE = "deleteImage"; + + private static final String DELETE_VIDEO_BY_ID = "deleteVideoById"; + + private static final String DELETE_IMAGE_BY_ID = "deleteImageById"; + + private static final String DELETE_LIB_BY_ID = "deleteLibById"; + + private static final String SOURCE = "source"; + + private static final String MEDIA_ID = "mediaId"; + + private static final String TASK_ID = "taskId"; + + private static final String GET_INSERT_RESPONSE_BY_ID = "getInsertResponseById"; + + private static final String GET_SEARCH_RESPONSE_BY_TASK_ID = "getSearchResponseByTaskId"; + + private static HttpResponseHandler[] mmsHandlers = + new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public MmsClient(BceClientConfiguration config) { + super(config, mmsHandlers); + } + + /** + * create a video lib. + * + * @param request The params of create video lib. + * @return BaseResponse + */ + public MmsBaseResponse createVideoLib(CreateLibRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, VERSION, VIDEO_LIB); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * delete a video lib. + * + * @param libId video lib id. + * @return BaseResponse + */ + public MmsBaseResponse deleteVideoLib(String libId) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, new SourceRequest(), VERSION, VIDEO_LIB, libId); + internalRequest.addParameter(DELETE_LIB_BY_ID, ""); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * create a image lib. + * + * @param request The params of create video lib. + * @return BaseResponse + */ + public MmsBaseResponse createImageLib(CreateLibRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, VERSION, IMAGE_LIB); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * delete a image lib. + * + * @param libId image lib id. + * @return BaseResponse + */ + public MmsBaseResponse deleteImageLib(String libId) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, new SourceRequest(), VERSION, IMAGE_LIB, libId); + internalRequest.addParameter(DELETE_LIB_BY_ID, ""); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * list lib of user. + * + * @param request The params of list user lib. + * @return BaseResponse + */ + public MmsListLibResponse listLib(ListLibRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, VERSION, LIB, LIST); + return this.invokeHttpClient(internalRequest, MmsListLibResponse.class); + } + + /** + * list lib media. + * + * @param request The params of list lib media. + * @return BaseResponse + */ + public MmsListMediaResponse listMedia(ListMediaRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, VERSION, LIB, ITEM, LIST); + return this.invokeHttpClient(internalRequest, MmsListMediaResponse.class); + } + + /** + * Insert a video into lib. + * + * @param libName The name of video lib. + * @return BaseResponse + */ + public MmsBaseResponse insertVideo(String libName, SourceAndDescRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.PUT, request, VERSION, VIDEO_LIB, libName); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * Get insert video task result. + * + * @param libId The name of video lib id. + * @return InsertVideoResultResponse + */ + public InsertVideoResultResponse getInsertVideoResultById(String libId, String mediaId) { + InternalRequest internalRequest = + createRequest(HttpMethodName.GET, new SourceRequest(), VERSION, VIDEO_LIB, libId); + internalRequest.addParameter(MEDIA_ID, mediaId); + internalRequest.addParameter(GET_INSERT_RESPONSE_BY_ID, ""); + return this.invokeHttpClient(internalRequest, InsertVideoResultResponse.class); + } + + /** + * Get insert video task result by id. + * + * @param libName The name of video lib. + * @return InsertVideoResultResponse + */ + public InsertVideoResultResponse getInsertVideoResult(String libName, SourceRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.GET, request, VERSION, VIDEO_LIB, libName); + internalRequest.addParameter(SOURCE, request.getSource()); + return this.invokeHttpClient(internalRequest, InsertVideoResultResponse.class); + } + + /** + * Create search video by video task. + * + * @param libName The name of video lib. + * @return MmsBaseResponse + */ + public MmsBaseResponse searchVideoByVideo(String libName, SourceAndDescRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, VERSION, VIDEO_LIB, libName); + internalRequest.addParameter(SEARCH_BY_VIDEO, ""); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * Get search video by video task result by id. + * + * @param libName The name of video lib. + * @return SearchVideoResponse + */ + public SearchVideoResponse getSearchVideoByVideoResultById(String libName, String taskId) { + InternalRequest internalRequest = + createRequest(HttpMethodName.GET, new SourceRequest(), VERSION, VIDEO_LIB, libName); + internalRequest.addParameter(TASK_ID, taskId); + internalRequest.addParameter(GET_SEARCH_RESPONSE_BY_TASK_ID, ""); + return this.invokeHttpClient(internalRequest, SearchVideoResponse.class); + } + + /** + * Get search video by video task result. + * + * @param libName The name of video lib. + * @return SearchVideoResponse + */ + public SearchVideoResponse getSearchVideoByVideoResult(String libName, SourceRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.GET, request, VERSION, VIDEO_LIB, libName); + internalRequest.addParameter(SOURCE, request.getSource()); + internalRequest.addParameter(SEARCH_BY_VIDEO, ""); + return this.invokeHttpClient(internalRequest, SearchVideoResponse.class); + } + + /** + * Search video by image. + * + * @param libName The name of video lib. + * @return SearchVideoResponse + */ + public SearchVideoResponse searchVideoByImage(String libName, SourceAndDescRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, VERSION, VIDEO_LIB, libName); + internalRequest.addParameter(SOURCE, request.getSource()); + internalRequest.addParameter(SEARCH_BY_IMAGE, ""); + return this.invokeHttpClient(internalRequest, SearchVideoResponse.class); + } + + /** + * Delete a video from lib. + * + * @param libName The name of video lib. + * @return MmsBaseResponse + */ + public MmsBaseResponse deleteVideo(String libName, SourceRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, VERSION, VIDEO_LIB, libName); + internalRequest.addParameter(SOURCE, request.getSource()); + internalRequest.addParameter(DELETE_VIDEO, ""); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * Delete a video from lib. + * + * @param libId The id of video lib. + * @return MmsBaseResponse + */ + public MmsBaseResponse deleteVideoById(String libId, String mediaId) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, new SourceRequest(), VERSION, VIDEO_LIB, libId); + internalRequest.addParameter(MEDIA_ID, mediaId); + internalRequest.addParameter(DELETE_VIDEO_BY_ID, ""); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * Insert an image into lib. + * + * @param libName The name of image lib. + * @return MmsBaseResponse + */ + public MmsBaseResponse insertImage(String libName, SourceAndDescRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.PUT, request, VERSION, IMAGE_LIB, libName); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * Search image by image. + * + * @param libName The name of image lib. + * @return SearchImageResponse + */ + public SearchImageResponse searchImageByImage(String libName, SourceAndDescRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, VERSION, IMAGE_LIB, libName); + internalRequest.addParameter(SEARCH_BY_IMAGE, ""); + return this.invokeHttpClient(internalRequest, SearchImageResponse.class); + } + + /** + * Delete an image from lib. + * + * @param libName The name of image lib. + * @return MmsBaseResponse + */ + public MmsBaseResponse deleteImage(String libName, SourceRequest request) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, VERSION, IMAGE_LIB, libName); + internalRequest.addParameter(SOURCE, request.getSource()); + internalRequest.addParameter(DELETE_IMAGE, ""); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + /** + * Delete an image from lib. + * + * @param libId The id of image lib. + * @return MmsBaseResponse + */ + public MmsBaseResponse deleteImageById(String libId, String mediaId) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, new SourceRequest(), VERSION, IMAGE_LIB, libId); + internalRequest.addParameter(MEDIA_ID, mediaId); + internalRequest.addParameter(DELETE_IMAGE_BY_ID, ""); + return this.invokeHttpClient(internalRequest, MmsBaseResponse.class); + } + + private InternalRequest createRequest( + HttpMethodName httpMethod, AbstractBceRequest request, String... pathVariables) { + // build URL paths + List pathComponents = new ArrayList(); + + // append resourceKeys,pathVariables, + // For example:/resourcekey1/resourcekey2/../pathVariable1/pathVariable2 + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + pathComponents.add(pathVariable); + } + } + + URI uri = + HttpUtils.appendUri( + getEndpoint(), pathComponents.toArray(new String[pathComponents.size()])); + + // get a InternalRequest instance and set headers + InternalRequest internalRequest = new InternalRequest(httpMethod, uri); + internalRequest.setCredentials(request.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillRequestPayload(internalRequest, request); + } + return internalRequest; + } + + private InternalRequest fillRequestPayload( + InternalRequest internalRequest, AbstractBceRequest request) { + String strJson = JsonUtils.toJsonString(request); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + + return internalRequest; + } +} diff --git a/src/main/java/com/baidubce/services/mms/model/CreateLibRequest.java b/src/main/java/com/baidubce/services/mms/model/CreateLibRequest.java new file mode 100644 index 00000000..0e4efa2d --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/CreateLibRequest.java @@ -0,0 +1,98 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.mms.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * MMS create lib request. + */ +public class CreateLibRequest extends AbstractBceRequest { + + private String name; + + private String description; + + /** + * scoreThreshold: image search score threshold, value is 0-100 + */ + private int scoreThreshold; + + /** + * video perhaps need. + * videoScoreThreshold: video score threshold, value is 0-100 + * frameType: default is 0, mean use ffmpeg and 5s per frame; or 1, mean use mix strategy, 5s must has one frame. + * interval: mean how much second per frame + */ + private int videoScoreThreshold; + + private int frameType; + + private int interval; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getScoreThreshold() { + return scoreThreshold; + } + + public void setScoreThreshold(int scoreThreshold) { + this.scoreThreshold = scoreThreshold; + } + + public int getVideoScoreThreshold() { + return videoScoreThreshold; + } + + public void setVideoScoreThreshold(int videoScoreThreshold) { + this.videoScoreThreshold = videoScoreThreshold; + } + + public int getFrameType() { + return frameType; + } + + public void setFrameType(int frameType) { + this.frameType = frameType; + } + + public int getInterval() { + return interval; + } + + public void setInterval(int interval) { + this.interval = interval; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/mms/model/InsertVideoResultResponse.java b/src/main/java/com/baidubce/services/mms/model/InsertVideoResultResponse.java new file mode 100644 index 00000000..5673b4c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/InsertVideoResultResponse.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.mms.model; + +import java.util.Date; + +/** + * MMS insert video result response. + */ +public class InsertVideoResultResponse extends MmsBaseResponse { + + private String source; + private float duration; + private String description; + private Date createTime; + private Date startTime; + private Date finishTime; + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getFinishTime() { + return finishTime; + } + + public void setFinishTime(Date finishTime) { + this.finishTime = finishTime; + } + + public float getDuration() { + return duration; + } + + public void setDuration(float duration) { + this.duration = duration; + } + + @Override + public String toString() { + return "InsertVideoResultResponse{" + + "source='" + source + '\'' + + ", duration=" + duration + + ", description='" + description + '\'' + + ", createTime=" + createTime + + ", startTime=" + startTime + + ", finishTime=" + finishTime + + ", metadata=" + metadata + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/mms/model/ListLibRequest.java b/src/main/java/com/baidubce/services/mms/model/ListLibRequest.java new file mode 100644 index 00000000..23780598 --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/ListLibRequest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.mms.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * MMS create lib request. + */ +public class ListLibRequest extends AbstractBceRequest { + + /** + * media type. IMAGE or VIDEO. + */ + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/mms/model/ListMediaRequest.java b/src/main/java/com/baidubce/services/mms/model/ListMediaRequest.java new file mode 100644 index 00000000..aa7e1c68 --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/ListMediaRequest.java @@ -0,0 +1,85 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.mms.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * MMS create lib request. + */ +public class ListMediaRequest extends AbstractBceRequest { + + /** + * media type. IMAGE or VIDEO. + */ + private String type; + + /** + * lib id + */ + private String id; + + private Integer pageNo; + + private Integer pageSize; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + @Override + public String toString() { + return "ListMediaRequest{" + + "type='" + type + '\'' + + ", id='" + id + '\'' + + ", pageNo=" + pageNo + + ", pageSize=" + pageSize + + '}'; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/mms/model/MmsBaseResponse.java b/src/main/java/com/baidubce/services/mms/model/MmsBaseResponse.java new file mode 100644 index 00000000..3bf3dbfe --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/MmsBaseResponse.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mms.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + MMS base response. + */ +public class MmsBaseResponse extends AbstractBceResponse { + + private String status; + private String taskId; + private String libId; + private String mediaId; + private MmsError error; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getLibId() { + return libId; + } + + public void setLibId(String libId) { + this.libId = libId; + } + + public MmsError getError() { + return error; + } + + public void setError(MmsError error) { + this.error = error; + } + + public String getMediaId() { + return mediaId; + } + + public void setMediaId(String mediaId) { + this.mediaId = mediaId; + } + + @Override + public String toString() { + return "MmsBaseResponse{" + + "status='" + status + '\'' + + ", taskId='" + taskId + '\'' + + ", mediaId='" + mediaId + '\'' + + ", error=" + error + + ", metadata=" + metadata + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/mms/model/MmsError.java b/src/main/java/com/baidubce/services/mms/model/MmsError.java new file mode 100644 index 00000000..a5074d3e --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/MmsError.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mms.model; + +/** + MMS error. + */ +public class MmsError { + private String code; + private String message; + private String requestId; + + public MmsError() { + } + + public MmsError(String code, String message) { + this.code = code; + this.message = message; + } + + public MmsError(String code, String message, String requestId) { + this.code = code; + this.message = message; + this.requestId = requestId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return "MMS Error{" + + "code='" + code + '\'' + + ", message='" + message + '\'' + + ", requestId='" + requestId + '\'' + + '}'; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } +} diff --git a/src/main/java/com/baidubce/services/mms/model/MmsListLibResponse.java b/src/main/java/com/baidubce/services/mms/model/MmsListLibResponse.java new file mode 100644 index 00000000..ffe55b34 --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/MmsListLibResponse.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mms.model; + +import java.util.List; + +/** + * MMS list lib response. + */ +public class MmsListLibResponse extends MmsBaseResponse { + + private Integer pageNo; + private Integer pageSize; + private Integer totalCount; + private List result; + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + @Override + public String toString() { + return "MmsListLibResponse{" + + "pageNo=" + pageNo + + ", pageSize=" + pageSize + + ", totalCount=" + totalCount + + ", result=" + result + + '}'; + } + + public static class Result { + private String docId; + private String name; + private String type; + private String description; + private String createTime; + private String updateTime; + + public String getDocId() { + return docId; + } + + public void setDocId(String docId) { + this.docId = docId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return "Result{" + + "docId='" + docId + '\'' + + ", name='" + name + '\'' + + ", type='" + type + '\'' + + ", description='" + description + '\'' + + ", createTime='" + createTime + '\'' + + ", updateTime='" + updateTime + '\'' + + '}'; + } + } +} diff --git a/src/main/java/com/baidubce/services/mms/model/MmsListMediaResponse.java b/src/main/java/com/baidubce/services/mms/model/MmsListMediaResponse.java new file mode 100644 index 00000000..e504b398 --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/MmsListMediaResponse.java @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mms.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * MMS list lib response. + */ +public class MmsListMediaResponse extends AbstractBceResponse { + + private Integer pageNo; + private Integer pageSize; + private Integer totalCount; + private List result; + + public Integer getPageNo() { + return pageNo; + } + + public void setPageNo(Integer pageNo) { + this.pageNo = pageNo; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + @Override + public String toString() { + return "MmsListMediaResponse{" + + "pageNo=" + pageNo + + ", pageSize=" + pageSize + + ", totalCount=" + totalCount + + ", result=" + result + + '}'; + } + + public static class Result { + + private String id; + private String name; + private String cover; + private String source; + private String status; + private String duration; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCover() { + return cover; + } + + public void setCover(String cover) { + this.cover = cover; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + @Override + public String toString() { + return "Result{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", cover='" + cover + '\'' + + ", source='" + source + '\'' + + ", status='" + status + '\'' + + ", duration='" + duration + '\'' + + '}'; + } + } +} diff --git a/src/main/java/com/baidubce/services/mms/model/SearchImageResponse.java b/src/main/java/com/baidubce/services/mms/model/SearchImageResponse.java new file mode 100644 index 00000000..52ae8b98 --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/SearchImageResponse.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mms.model; + +import java.util.Date; +import java.util.List; + +/** + * MMS search image by image response. + */ +public class SearchImageResponse extends MmsBaseResponse { + + private String lib; + private String description; + private String source; + private Date createTime; + private Date finishTime; + + private List results; + + public String getLib() { + return lib; + } + + public void setLib(String lib) { + this.lib = lib; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getFinishTime() { + return finishTime; + } + + public void setFinishTime(Date finishTime) { + this.finishTime = finishTime; + } + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } + + @Override + public String toString() { + return "SearchImageResponse{" + + "lib='" + lib + '\'' + + ", description='" + description + '\'' + + ", source='" + source + '\'' + + ", createTime=" + createTime + + ", finishTime=" + finishTime + + ", results=" + results + + ", metadata=" + metadata + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/mms/model/SearchTaskResult.java b/src/main/java/com/baidubce/services/mms/model/SearchTaskResult.java new file mode 100644 index 00000000..207d0ebb --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/SearchTaskResult.java @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mms.model; + +import java.util.List; + +/** + * MMS search result. + */ +public class SearchTaskResult { + + private String id; + + private String name; + + private String source; + + private Float duration; + + private String description; + + private Float distance; + + private Float score; + + private List clips; + + private List frames; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public Float getDuration() { + return duration; + } + + public void setDuration(Float duration) { + this.duration = duration; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Float getDistance() { + return distance; + } + + public void setDistance(Float distance) { + this.distance = distance; + } + + public Float getScore() { + return score; + } + + public void setScore(Float score) { + this.score = score; + } + + public List getClips() { + return clips; + } + + public void setClips(List clips) { + this.clips = clips; + } + + public List getFrames() { + return frames; + } + + public void setFrames(List frames) { + this.frames = frames; + } + + @Override + public String toString() { + return "SearchTaskResult{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", source='" + source + '\'' + + ", duration=" + duration + + ", description='" + description + '\'' + + ", distance=" + distance + + ", score=" + score + + ", clips=" + clips + + ", frames=" + frames + + '}'; + } + + public static class VideoClip { + + private float inputStartTime; + + private float inputEndTime; + + private float outputStartTime; + + private float outputEndTime; + + public float getInputStartTime() { + return inputStartTime; + } + + public void setInputStartTime(float inputStartTime) { + this.inputStartTime = inputStartTime; + } + + public float getInputEndTime() { + return inputEndTime; + } + + public void setInputEndTime(float inputEndTime) { + this.inputEndTime = inputEndTime; + } + + public float getOutputStartTime() { + return outputStartTime; + } + + public void setOutputStartTime(float outputStartTime) { + this.outputStartTime = outputStartTime; + } + + public float getOutputEndTime() { + return outputEndTime; + } + + public void setOutputEndTime(float outputEndTime) { + this.outputEndTime = outputEndTime; + } + + @Override + public String toString() { + return "VideoClip{" + + "inputStartTime=" + inputStartTime + + ", inputEndTime=" + inputEndTime + + ", outputStartTime=" + outputStartTime + + ", outputEndTime=" + outputEndTime + + '}'; + } + } + + public static class MatchFrame { + + private int position; + + private float timestamp; + + private float distance; + + public int getPosition() { + return position; + } + + public void setPosition(int position) { + this.position = position; + } + + public float getTimestamp() { + return timestamp; + } + + public void setTimestamp(float timestamp) { + this.timestamp = timestamp; + } + + public float getDistance() { + return distance; + } + + public void setDistance(float distance) { + this.distance = distance; + } + + @Override + public String toString() { + return "MatchFrame{" + + "position=" + position + + ", timestamp=" + timestamp + + ", distance=" + distance + + '}'; + } + } +} diff --git a/src/main/java/com/baidubce/services/mms/model/SearchVideoResponse.java b/src/main/java/com/baidubce/services/mms/model/SearchVideoResponse.java new file mode 100644 index 00000000..b9d17e14 --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/SearchVideoResponse.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mms.model; + +import java.util.Date; +import java.util.List; + +/** + * MMS search video by video/image response. + */ +public class SearchVideoResponse extends MmsBaseResponse { + + private String lib; + private String description; + private String source; + private Float duration; + private Date createTime; + private Date startTime; + private Date finishTime; + + private List results; + + public String getLib() { + return lib; + } + + public void setLib(String lib) { + this.lib = lib; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public Float getDuration() { + return duration; + } + + public void setDuration(Float duration) { + this.duration = duration; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getFinishTime() { + return finishTime; + } + + public void setFinishTime(Date finishTime) { + this.finishTime = finishTime; + } + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } + + @Override + public String toString() { + return "SearchVideoResponse{" + + "lib='" + lib + '\'' + + ", description='" + description + '\'' + + ", source='" + source + '\'' + + ", duration=" + duration + + ", createTime=" + createTime + + ", startTime=" + startTime + + ", finishTime=" + finishTime + + ", results=" + results + + ", metadata=" + metadata + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/mms/model/SourceAndDescRequest.java b/src/main/java/com/baidubce/services/mms/model/SourceAndDescRequest.java new file mode 100644 index 00000000..f2ddd2e7 --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/SourceAndDescRequest.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2020 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mms.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * MMS video/image and desc request. + */ +public class SourceAndDescRequest extends AbstractBceRequest { + + private String source; + private String description; + private String notification; + + public SourceAndDescRequest() { + } + + public SourceAndDescRequest(String source, String description) { + this.source = source; + this.description = description; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + @Override + public String toString() { + return "SourceAndDescRequest{" + + "source='" + source + '\'' + + ", description='" + description + '\'' + + ", notification='" + notification + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/mms/model/SourceRequest.java b/src/main/java/com/baidubce/services/mms/model/SourceRequest.java new file mode 100644 index 00000000..00f17ab0 --- /dev/null +++ b/src/main/java/com/baidubce/services/mms/model/SourceRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2020 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.mms.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * MMS query video task request. + */ +public class SourceRequest extends AbstractBceRequest { + + private String source; + + public SourceRequest() { + } + + public SourceRequest(String source) { + this.source = source; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + +} diff --git a/src/main/java/com/baidubce/services/modbus/ModbusClient.java b/src/main/java/com/baidubce/services/modbus/ModbusClient.java new file mode 100755 index 00000000..59bbfa01 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/ModbusClient.java @@ -0,0 +1,435 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.auth.BceCredentials; +import com.baidubce.http.HttpMethodName; +import com.baidubce.internal.InternalRequest; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.model.GenericAccountRequest; +import com.baidubce.services.modbus.model.BaseResponse; +import com.baidubce.services.modbus.model.CreateCustomFieldRequest; +import com.baidubce.services.modbus.model.CreateDataDescRequest; +import com.baidubce.services.modbus.model.DataDescRequest; +import com.baidubce.services.modbus.model.ListCustomFieldRespons; +import com.baidubce.services.modbus.model.ListDataDescResponse; +import com.baidubce.services.modbus.model.ListParserObjectResponse; +import com.baidubce.services.modbus.model.ParserObjectRequest; +import com.baidubce.services.modbus.model.QueryDataDescResponse; +import com.baidubce.services.modbus.model.UpdateDataDescRequest; +import com.baidubce.services.modbus.model.device.CreateDevice; +import com.baidubce.services.modbus.model.device.DeviceResponse; +import com.baidubce.services.modbus.model.device.ListDeviceRequest; +import com.baidubce.services.modbus.model.device.ListDeviceResponse; +import com.baidubce.services.modbus.model.device.UpdateDeviceRequest; +import com.baidubce.services.modbus.model.gateway.CreateGatewayRequest; +import com.baidubce.services.modbus.model.gateway.GatewayResponse; +import com.baidubce.services.modbus.model.gateway.ListGatewayRequest; +import com.baidubce.services.modbus.model.gateway.ListGatewayResponse; +import com.baidubce.services.modbus.model.gateway.UpdateGatewayRequest; +import com.baidubce.services.modbus.model.parserobject.CreateParserObjectRequest; +import com.baidubce.services.modbus.model.parserobject.ParserObjectResponse; +import com.baidubce.services.modbus.model.parserobject.UpdateParserObject; +import com.baidubce.services.modbus.model.pullrule.CreatePullRuleRequest; +import com.baidubce.services.modbus.model.pullrule.CreatePullRuleResponse; +import com.baidubce.services.modbus.model.pullrule.ListPullRuleRequest; +import com.baidubce.services.modbus.model.pullrule.ListPullRuleResponse; +import com.baidubce.services.modbus.model.pullrule.PullRuleResponse; +import com.baidubce.services.modbus.model.pullrule.PullRuleResponseWithDevice; +import com.baidubce.services.modbus.model.pullrule.UpdatePullRuleRequest; +import com.google.common.base.Preconditions; + + +/** + * Provides the client for use iot modbus service. + */ +public class ModbusClient extends AbstractBceClient { + + private static final String ENDPOINT_HOST = "parser.iot.gz.baidubce.com"; + private static final String GATEWAY = "gateway"; + private static final String DEVICE = "device"; + private static final String PARSER_OBJECT = "parser-object"; + private static final String DATA_DESCRIPTION = "data-description"; + private static final String PULL_RULE = "pull-rule"; + private static final String CUSTOM_FIELD = "custom-field"; + private static final String ACTION = "action/deploy-config"; + + private static final String PARSEROBJECTUUID = "parserObjectUuid"; + private AbstractBceRequest abstractBceRequest; + + public ModbusClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT_HOST) : config, + ModbusClientHelper.MODBUS_HANDLERS); + abstractBceRequest = new AbstractBceRequest() { + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + return null; + } + }; + } + + // 网关 + public GatewayResponse createGateway(CreateGatewayRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, GATEWAY); + return this.invokeHttpClient(internalRequest, GatewayResponse.class); + } + + public ListGatewayResponse listGateway(ListGatewayRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, GATEWAY); + if (request.getState() != null) { + internalRequest.addParameter("state", request.getState()); + } + orderAndPagination( + internalRequest, + request.getOrder(), + request.getOrderBy(), + request.getPageNo(), + request.getPageSize()); + ListGatewayResponse response = this.invokeHttpClient(internalRequest, ListGatewayResponse.class); + for (GatewayResponse gateway : response.getResult()) { + gateway.setDeviceNum(getDeviceNumByGatewayUuid(gateway.getUuid())); + } + return response; + } + + public GatewayResponse getGateway(String uuid) { + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.GET, GATEWAY, uuid); + GatewayResponse response = this.invokeHttpClient(internalRequest, GatewayResponse.class); + response.setDeviceNum(getDeviceNumByGatewayUuid(response.getUuid())); + return response; + } + + public GatewayResponse updateGateway(String uuid, UpdateGatewayRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, GATEWAY, uuid); + GatewayResponse response = this.invokeHttpClient(internalRequest, GatewayResponse.class); + response.setDeviceNum(getDeviceNumByGatewayUuid(response.getUuid())); + return response; + } + + public GatewayResponse regenGatewayPassword(String uuid) { + InternalRequest internalRequest = createRequest( + abstractBceRequest, + HttpMethodName.PUT, + GATEWAY, uuid, "regen"); + GatewayResponse response = this.invokeHttpClient(internalRequest, GatewayResponse.class); + response.setDeviceNum(getDeviceNumByGatewayUuid(response.getUuid())); + return response; + } + + public void deleteGateway(String uuid) { + InternalRequest internalRequest = createRequest( + abstractBceRequest, + HttpMethodName.DELETE, + GATEWAY, uuid); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public int getDeviceNumByGatewayUuid(String uuid) { + ListDeviceRequest deviceRequest = new ListDeviceRequest(); + deviceRequest.setGatewayUuid(uuid); + deviceRequest.setPageSize(5); + ListDeviceResponse deviceResponse = this.listDevice(deviceRequest); + return deviceResponse.getTotalCount(); + } + + // 子设备 + public DeviceResponse createDevice(CreateDevice request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DEVICE); + return this.invokeHttpClient(internalRequest, DeviceResponse.class); + } + + public ListDeviceResponse listDevice(ListDeviceRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DEVICE); + if (request.getState() != null) { + internalRequest.addParameter("state", request.getState()); + } + if (request.getGatewayUuid() != null) { + internalRequest.addParameter("gatewayUuid", request.getGatewayUuid()); + } + if (request.getStatus() != null) { + internalRequest.addParameter("status", request.getStatus()); + } + orderAndPagination( + internalRequest, + request.getOrder(), + request.getOrderBy(), + request.getPageNo(), + request.getPageSize()); + return this.invokeHttpClient(internalRequest, ListDeviceResponse.class); + } + + public DeviceResponse getDevice(String uuid) { + InternalRequest internalRequest = createRequest(abstractBceRequest, HttpMethodName.GET, DEVICE, uuid); + return this.invokeHttpClient(internalRequest, DeviceResponse.class); + } + + public DeviceResponse updateDevice(String uuid, UpdateDeviceRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DEVICE, uuid); + return this.invokeHttpClient(internalRequest, DeviceResponse.class); + } + + public void deleteDevice(String uuid) { + InternalRequest internalRequest = createRequest( + abstractBceRequest, + HttpMethodName.DELETE, + DEVICE, uuid); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // ParserObject + public ParserObjectResponse createParserObject(CreateParserObjectRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, PARSER_OBJECT); + return this.invokeHttpClient(internalRequest, ParserObjectResponse.class); + } + public ListParserObjectResponse listParserObject(ParserObjectRequest parserObjectRequest) { + return listParserObject(parserObjectRequest, null, null, null, null, null); + } + public ListParserObjectResponse listParserObject(ParserObjectRequest parserObjectRequest, + String order, + String orderBy, + String pageNo, + String pageSize, + String q) { + InternalRequest internalRequest = createRequest(parserObjectRequest, HttpMethodName.GET, PARSER_OBJECT); + if (parserObjectRequest.getState() != null) { + internalRequest.addParameter("state", parserObjectRequest.getState()); + } + if (parserObjectRequest.getGatewayUuid() != null) { + internalRequest.addParameter("gatewayUuid", parserObjectRequest.getGatewayUuid()); + } + orderAndPagination(internalRequest, order, orderBy, pageNo, pageSize, q); + return this.invokeHttpClient(internalRequest, ListParserObjectResponse.class); + } + + public ParserObjectResponse getParserObject(String uuid) { + InternalRequest internalRequest = createRequest(abstractBceRequest, HttpMethodName.GET, PARSER_OBJECT, uuid); + return this.invokeHttpClient(internalRequest, ParserObjectResponse.class); + } + + public ParserObjectResponse updateParserObject(String uuid, UpdateParserObject request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, PARSER_OBJECT, uuid); + return this.invokeHttpClient(internalRequest, ParserObjectResponse.class); + } + + public void deleteParserObject(String uuid) { + InternalRequest internalRequest = createRequest( + abstractBceRequest, + HttpMethodName.DELETE, + PARSER_OBJECT, uuid); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // DataDescription 通讯地址表 + public QueryDataDescResponse createDataDesc(CreateDataDescRequest createDataDescRequest) { + Preconditions.checkNotNull(createDataDescRequest.getParserObjectUuid(), "ParserObjectUuid should not be null."); + Preconditions.checkNotNull(createDataDescRequest.getLength(), "Length should not be null."); + Preconditions.checkNotNull(createDataDescRequest.getAddress(), "Address should not be null."); + Preconditions.checkNotNull(createDataDescRequest.getKind(), "Kind should not be null."); + Preconditions.checkNotNull(createDataDescRequest.getName(), "Name should not be null."); + if (createDataDescRequest.getBit() == null) { + createDataDescRequest.setBit(-1); + } + if (createDataDescRequest.getUnit() == "N/A") { + createDataDescRequest.setUnit(""); + } + InternalRequest internalRequest = createRequest(createDataDescRequest, HttpMethodName.POST, DATA_DESCRIPTION); + return this.invokeHttpClient(internalRequest, QueryDataDescResponse.class); + } + + public ListDataDescResponse listDataDesc(DataDescRequest dataDescRequest) { + return listDataDesc(dataDescRequest, null, null, null, null, null); + } + public ListDataDescResponse listDataDesc(DataDescRequest dataDescRequest, + String order, + String orderBy, + String pageNo, + String pageSize, + String q) { + Preconditions.checkNotNull(dataDescRequest.getParserObjectUuid(), "ParserObjectUuid should not be null."); + InternalRequest internalRequest = createRequest(dataDescRequest, HttpMethodName.GET, DATA_DESCRIPTION); + internalRequest.addParameter(PARSEROBJECTUUID, dataDescRequest.getParserObjectUuid()); + if (dataDescRequest.getState() != null) { + internalRequest.addParameter("state", dataDescRequest.getState()); + } + if (dataDescRequest.getAddressStart() != null) { + internalRequest.addParameter("addressStart", dataDescRequest.getAddressStart().toString()); + } + orderAndPagination(internalRequest, order, orderBy, pageNo, pageSize, q); + return this.invokeHttpClient(internalRequest, ListDataDescResponse.class); + } + + public QueryDataDescResponse queryDataDesc(String dataDescriptionUuid) { + Preconditions.checkNotNull(dataDescriptionUuid, "dataDescriptionUuid should not be null."); + InternalRequest internalRequest = createRequest(abstractBceRequest, + HttpMethodName.GET, + DATA_DESCRIPTION, + dataDescriptionUuid); + return this.invokeHttpClient(internalRequest, QueryDataDescResponse.class); + } + + public QueryDataDescResponse updateDataDesc(UpdateDataDescRequest updateDataDescRequest) { + Preconditions.checkNotNull(updateDataDescRequest.getDataDescriptionUuid(), + "DataDescriptionUuid should not be null."); + InternalRequest internalRequest = createRequest(updateDataDescRequest, + HttpMethodName.PUT, + DATA_DESCRIPTION, + updateDataDescRequest.getDataDescriptionUuid()); + return this.invokeHttpClient(internalRequest, QueryDataDescResponse.class); + } + + public AbstractBceResponse deleteDataDesc(String dataDescriptionUuid) { + Preconditions.checkNotNull(dataDescriptionUuid, "DataDescriptionUuid should not be null."); + InternalRequest internalRequest = createRequest(abstractBceRequest, + HttpMethodName.DELETE, + DATA_DESCRIPTION, + dataDescriptionUuid); + return this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // pull rule + public CreatePullRuleResponse createPullRule(CreatePullRuleRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, PULL_RULE); + return this.invokeHttpClient(internalRequest, CreatePullRuleResponse.class); + } + + public ListPullRuleResponse listPullRule(ListPullRuleRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, PULL_RULE); + if (request.getParserObjectUuid() != null) { + internalRequest.addParameter("parserObjectUuid", request.getParserObjectUuid()); + } + if (request.isWithDevice() != null) { + internalRequest.addParameter("withDevice", Boolean.toString(request.isWithDevice())); + } + orderAndPagination( + internalRequest, + request.getOrder(), + request.getOrderBy(), + request.getPageNo(), + request.getPageSize()); + return this.invokeHttpClient(internalRequest, ListPullRuleResponse.class); + } + + public PullRuleResponseWithDevice getPullRule(String uuid) { + InternalRequest internalRequest = createRequest(abstractBceRequest, HttpMethodName.GET, PULL_RULE, uuid); + internalRequest.addParameter("withDevice", Boolean.toString(true)); + return this.invokeHttpClient(internalRequest, PullRuleResponseWithDevice.class); + } + + public PullRuleResponse updatePullRule(String uuid, UpdatePullRuleRequest request) { + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, PULL_RULE, uuid); + return this.invokeHttpClient(internalRequest, PullRuleResponse.class); + } + + public void deletePullRule(String uuid) { + InternalRequest internalRequest = createRequest( + abstractBceRequest, + HttpMethodName.DELETE, + PULL_RULE, uuid); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // 下发配置 + public void deployGateway() { + InternalRequest internalRequest = createRequest( + abstractBceRequest, + HttpMethodName.POST, + ACTION); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + public void deployGateway(String gatewayUuid) { + InternalRequest internalRequest = createRequest( + abstractBceRequest, + HttpMethodName.POST, + ACTION, gatewayUuid); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + // 高级设置 + public BaseResponse createCustomField(String name) { + Preconditions.checkNotNull(name, "name should not be null."); + CreateCustomFieldRequest createCustomFieldRequest = (new CreateCustomFieldRequest()).withName(name); + InternalRequest internalRequest = createRequest(createCustomFieldRequest, + HttpMethodName.POST, + CUSTOM_FIELD); + return this.invokeHttpClient(internalRequest, BaseResponse.class); + } + + public ListCustomFieldRespons listCustomField() { + InternalRequest internalRequest = createRequest(abstractBceRequest, + HttpMethodName.GET, + CUSTOM_FIELD); + return this.invokeHttpClient(internalRequest, ListCustomFieldRespons.class); + } + + public BaseResponse deleteCustomField(String name) { + Preconditions.checkNotNull(name, "name should not be null."); + CreateCustomFieldRequest createCustomFieldRequest = (new CreateCustomFieldRequest()).withName(name); + InternalRequest internalRequest = createRequest(createCustomFieldRequest, + HttpMethodName.PUT, + CUSTOM_FIELD, + "delete"); + return this.invokeHttpClient(internalRequest, BaseResponse.class); + } + + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + return ModbusClientHelper.createRequest(bceRequest, httpMethod, this.getEndpoint(), null, pathVariables); + } + + private void orderAndPagination(InternalRequest internalRequest, + String order, + String orderBy, + String pageNo, + String pageSize, + String q) { + if (order != null) { + internalRequest.addParameter("order", order); + } + if (orderBy != null) { + internalRequest.addParameter("orderBy", orderBy); + } + if (pageNo != null) { + internalRequest.addParameter("pageNo", pageNo); + } + if (pageSize != null) { + internalRequest.addParameter("pageSize", pageSize); + } + if (q != null) { + internalRequest.addParameter("q", q); + } + } + + private void orderAndPagination(InternalRequest internalRequest, + String order, + String orderBy, + int pageNo, + int pageSize) { + if (order != null) { + internalRequest.addParameter("order", order); + } + if (orderBy != null) { + internalRequest.addParameter("orderBy", orderBy); + } + if (pageNo > 0) { + internalRequest.addParameter("pageNo", Integer.toString(pageNo)); + } + if (pageSize > 0) { + internalRequest.addParameter("pageSize", Integer.toString(pageSize)); + } + } + +} diff --git a/src/main/java/com/baidubce/services/modbus/ModbusClientHelper.java b/src/main/java/com/baidubce/services/modbus/ModbusClientHelper.java new file mode 100755 index 00000000..a12e0992 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/ModbusClientHelper.java @@ -0,0 +1,93 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +public class ModbusClientHelper { + + private static final String VERSION = "v1"; + + private static final String[] HEADERS_TO_SIGN = { Headers.HOST, Headers.BCE_DATE }; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; + + /** + * Responsible for handling HttpResponse from all modbus service calls. + */ + static final HttpResponseHandler[] MODBUS_HANDLERS = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() + }; + + static InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + URI endpoint, SignOptions signOptions, String... pathVariables) { + List path = new ArrayList(); + path.addAll(Arrays.asList(VERSION)); + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + if (signOptions == null) { + signOptions = SignOptions.DEFAULT; + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + } + + URI uri = HttpUtils.appendUri(endpoint, path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + + if (httpMethod == HttpMethodName.PUT || httpMethod == HttpMethodName.POST) { + fillInHeaderAndBody(bceRequest, request); + } + + return request; + } + + private static void fillInHeaderAndBody(AbstractBceRequest bceRequest, InternalRequest request) { + byte[] content = toJson(bceRequest); + request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(content.length)); + request.addHeader(Headers.CONTENT_TYPE, CONTENT_TYPE); + request.setContent(RestartableInputStream.wrap(content)); + } + + private static byte[] toJson(AbstractBceRequest request) { + String jsonStr = JsonUtils.toJsonString(request); + try { + return jsonStr.getBytes(AbstractBceClient.DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/BaseResponse.java b/src/main/java/com/baidubce/services/modbus/model/BaseResponse.java new file mode 100755 index 00000000..0addf97d --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/BaseResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the base request for all modbus response. + */ +public class BaseResponse extends AbstractBceResponse { + + private String success; + + public String getSuccess() { + return success; + } + + public void setSuccess(String success) { + this.success = success; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/CreateCustomFieldRequest.java b/src/main/java/com/baidubce/services/modbus/model/CreateCustomFieldRequest.java new file mode 100755 index 00000000..33e5126c --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/CreateCustomFieldRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent the request for create custom field. + */ +public class CreateCustomFieldRequest extends AbstractBceRequest { + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public CreateCustomFieldRequest withName(String name) { + this.name = name; + return this; + } + + @Override + public CreateCustomFieldRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/CreateDataDescRequest.java b/src/main/java/com/baidubce/services/modbus/model/CreateDataDescRequest.java new file mode 100755 index 00000000..989c0c15 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/CreateDataDescRequest.java @@ -0,0 +1,203 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.HashMap; + +/** + * Represent the request for create Data description.. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateDataDescRequest extends AbstractBceRequest { + + private String parserObjectUuid; // 数据长度 必填 + + private Integer length; // 数据长度 必填 + + private Integer address; // 十进制地址 必填 + + private Integer bit; // bit位 默认-1 + + private String name; // 显示名称 必填 + + private String kind; // 数据类型 必填 INT, BOOL, REAL, INT32, REAL32 + + private String unit; // 单位 有默认值 + + @JsonProperty("rh") + private Double rangeHigher; // 量程上限 可以为空 + + @JsonProperty("rl") + private Double rangeLower; // 量程下限 可以为空 + + private String formula; // 公式 可以为空 + + @JsonProperty("user_properties") + private HashMap userProperties; + + public String getParserObjectUuid() { + return parserObjectUuid; + } + + public void setParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + } + + public CreateDataDescRequest withParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + return this; + } + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public CreateDataDescRequest withLength(Integer length) { + this.length = length; + return this; + } + + public Integer getAddress() { + return address; + } + + public void setAddress(Integer address) { + this.address = address; + } + + public CreateDataDescRequest withAddress(Integer address) { + this.address = address; + return this; + } + + public Integer getBit() { + return bit; + } + + public void setBit(Integer bit) { + this.bit = bit; + } + + public CreateDataDescRequest withBit(Integer bit) { + this.bit = bit; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public CreateDataDescRequest withName(String name) { + this.name = name; + return this; + } + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + public CreateDataDescRequest withKind(String kind) { + this.kind = kind; + return this; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public CreateDataDescRequest withUnit(String unit) { + this.unit = unit; + return this; + } + + public Double getRangeHigher() { + return rangeHigher; + } + + public void setRangeHigher(Double rangeHigher) { + this.rangeHigher = rangeHigher; + } + + public CreateDataDescRequest withRangeHigher(Double rangeHigher) { + this.rangeHigher = rangeHigher; + return this; + } + + public Double getRangeLower() { + return rangeLower; + } + + public void setRangeLower(Double rangeLower) { + this.rangeLower = rangeLower; + } + + public CreateDataDescRequest withRangeLower(Double rangeLower) { + this.rangeLower = rangeLower; + return this; + } + + public String getFormula() { + return formula; + } + + public void setFormula(String formula) { + this.formula = formula; + } + + public CreateDataDescRequest withFormula(String formula) { + this.formula = formula; + return this; + } + + public HashMap getUserProperties() { + return userProperties; + } + + public void setUserProperties(HashMap userProperties) { + this.userProperties = userProperties; + } + + public CreateDataDescRequest withUserProperties(HashMap userProperties) { + this.userProperties = userProperties; + return this; + } + + @Override + public CreateDataDescRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/DataDescRequest.java b/src/main/java/com/baidubce/services/modbus/model/DataDescRequest.java new file mode 100755 index 00000000..4eabf071 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/DataDescRequest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent the request for Data description. + */ +public class DataDescRequest extends AbstractBceRequest { + + private String parserObjectUuid; + + private String state; // ENABLED, DISABLED + + private Integer addressStart; + + public String getParserObjectUuid() { + return parserObjectUuid; + } + + public void setParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + } + + public DataDescRequest withParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + return this; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public DataDescRequest withState(String state) { + this.state = state; + return this; + } + + public Integer getAddressStart() { + return addressStart; + } + + public void setAddressStart(Integer addressStart) { + this.addressStart = addressStart; + } + + public DataDescRequest withAddressStart(Integer addressStart) { + this.addressStart = addressStart; + return this; + } + + @Override + public DataDescRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/DataDescription.java b/src/main/java/com/baidubce/services/modbus/model/DataDescription.java new file mode 100755 index 00000000..168dd6e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/DataDescription.java @@ -0,0 +1,201 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.HashMap; + +/** + * This is a DataDescription + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DataDescription { + + private String uuid; + + private String parserObjectUuid; // 所属project 不可为空 + + private Integer bit = -1; // bit位 默认-1 + + private Integer length; // 数据长度 不可为空 + + private String address; // 十进制地址 不可为空 + + private String name; // 显示名称 不可为空 + + private String abbreviation; // 缩写 可以为空 + + private String kind; // 数据类型 必填 INT, BOOL, REAL, INT32, REAL32 + + private String unit; // 单位 有默认值 + + @JsonProperty("rh") + private Double rangeHigher; // 量程上限 可以为空 + + @JsonProperty("rl") + private Double rangeLower; // 量程下限 可以为空 + + private String formula; // 公式 可以为空 + + private String state; + + private String status; + + private String createTime; + + private String updateTime; + + @JsonProperty("user_properties") + private HashMap userProperties; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getParserObjectUuid() { + return parserObjectUuid; + } + + public void setParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + } + + public Integer getBit() { + return bit; + } + + public void setBit(Integer bit) { + this.bit = bit; + } + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAbbreviation() { + return abbreviation; + } + + public void setAbbreviation(String abbreviation) { + this.abbreviation = abbreviation; + } + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public Double getRangeHigher() { + return rangeHigher; + } + + public void setRangeHigher(Double rangeHigher) { + this.rangeHigher = rangeHigher; + } + + public Double getRangeLower() { + return rangeLower; + } + + public void setRangeLower(Double rangeLower) { + this.rangeLower = rangeLower; + } + + public String getFormula() { + return formula; + } + + public void setFormula(String formula) { + this.formula = formula; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public HashMap getUserProperties() { + return userProperties; + } + + public void setUserProperties(HashMap userProperties) { + this.userProperties = userProperties; + } + +} diff --git a/src/main/java/com/baidubce/services/modbus/model/ListCustomFieldRespons.java b/src/main/java/com/baidubce/services/modbus/model/ListCustomFieldRespons.java new file mode 100755 index 00000000..f3c5fff5 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/ListCustomFieldRespons.java @@ -0,0 +1,34 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Represent the response for list custom field. + */ +public class ListCustomFieldRespons extends AbstractBceResponse { + + private List fields; + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/ListDataDescResponse.java b/src/main/java/com/baidubce/services/modbus/model/ListDataDescResponse.java new file mode 100755 index 00000000..f95d1ff1 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/ListDataDescResponse.java @@ -0,0 +1,82 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Represent the response for DataDescription list response. + */ +public class ListDataDescResponse extends AbstractBceResponse { + private int totalCount; + + private List result; + + private String order; + + private String orderBy; + + private int pageSize; + + private int pageNo; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/ListParserObjectResponse.java b/src/main/java/com/baidubce/services/modbus/model/ListParserObjectResponse.java new file mode 100755 index 00000000..8f9aa98a --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/ListParserObjectResponse.java @@ -0,0 +1,82 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Represent the response for ParserObject list response. + */ +public class ListParserObjectResponse extends AbstractBceResponse { + private int totalCount; + + private List result; + + private String order; + + private String orderBy; + + private int pageSize; + + private int pageNo; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/ListResponse.java b/src/main/java/com/baidubce/services/modbus/model/ListResponse.java new file mode 100755 index 00000000..b96709f5 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/ListResponse.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Represent the base response for all modbus list response. + */ +public class ListResponse extends AbstractBceResponse { + private int totalCount; + + private List result; + + private String order; + + private String orderBy; + + private int pageSize; + + private int pageNo; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + +} diff --git a/src/main/java/com/baidubce/services/modbus/model/ParserObject.java b/src/main/java/com/baidubce/services/modbus/model/ParserObject.java new file mode 100755 index 00000000..df23ef0c --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/ParserObject.java @@ -0,0 +1,154 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * This is a ParserObject + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ParserObject { + + private String uuid; // + + private String state; // 'RUNNING', 'PAUSED', 'ERROR',三个可能值,默认为PAUSED + + private String dataTopic; // + + private String name; // + + private String protocol; // + + private String status; // + + private String gatewayUuid; // + + private String gatewayCode; // 用户可见的ID + + private String storage; // + + private String storageTaskId; // modbus 需存储这个id 以便去iotapi删除这个task + + private String createTime; // + + private String updateTime; // + + private String destTopic; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getDataTopic() { + return dataTopic; + } + + public void setDataTopic(String dataTopic) { + this.dataTopic = dataTopic; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getGatewayUuid() { + return gatewayUuid; + } + + public void setGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + } + + public String getGatewayCode() { + return gatewayCode; + } + + public void setGatewayCode(String gatewayCode) { + this.gatewayCode = gatewayCode; + } + + public String getStorage() { + return storage; + } + + public void setStorage(String storage) { + this.storage = storage; + } + + public String getStorageTaskId() { + return storageTaskId; + } + + public void setStorageTaskId(String storageTaskId) { + this.storageTaskId = storageTaskId; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getDestTopic() { + return destTopic; + } + + public void setDestTopic(String destTopic) { + this.destTopic = destTopic; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/ParserObjectRequest.java b/src/main/java/com/baidubce/services/modbus/model/ParserObjectRequest.java new file mode 100755 index 00000000..de98caaf --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/ParserObjectRequest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent the request for ParserObject. + */ +public class ParserObjectRequest extends AbstractBceRequest { + + private String gatewayUuid; + + private String state; // ERROR, RUNNING, PAUSED; + + public String getGatewayUuid() { + return gatewayUuid; + } + + public void setGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + } + + public ParserObjectRequest withGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + return this; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public ParserObjectRequest withState(String state) { + this.state = state; + return this; + } + @Override + public ParserObjectRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/QueryDataDescResponse.java b/src/main/java/com/baidubce/services/modbus/model/QueryDataDescResponse.java new file mode 100755 index 00000000..35afe129 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/QueryDataDescResponse.java @@ -0,0 +1,200 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.HashMap; + +/** + * Represent the response for get specified Data description. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class QueryDataDescResponse extends AbstractBceResponse { + private String uuid; + + private String parserObjectUuid; // 所属project + + private Integer bit = -1; // bit位 默认-1 + + private Integer length; // 数据长度 + + private String address; // 十进制地址 + + private String name; // 显示名称 + + private String abbreviation; // 缩写 + + private String kind; // 数据类型 INT, BOOL, REAL, INT32, REAL32 + + private String unit; // 单位 有默认值 + + @JsonProperty("rh") + private Double rangeHigher; // 量程上限 + + @JsonProperty("rl") + private Double rangeLower; // 量程下限 + + private String formula; // 公式 + + private String state; + + private String status; + + private String createTime; + + private String updateTime; + + @JsonProperty("user_properties") + private HashMap userProperties; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getParserObjectUuid() { + return parserObjectUuid; + } + + public void setParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + } + + public Integer getBit() { + return bit; + } + + public void setBit(Integer bit) { + this.bit = bit; + } + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAbbreviation() { + return abbreviation; + } + + public void setAbbreviation(String abbreviation) { + this.abbreviation = abbreviation; + } + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public Double getRangeHigher() { + return rangeHigher; + } + + public void setRangeHigher(Double rangeHigher) { + this.rangeHigher = rangeHigher; + } + + public Double getRangeLower() { + return rangeLower; + } + + public void setRangeLower(Double rangeLower) { + this.rangeLower = rangeLower; + } + + public String getFormula() { + return formula; + } + + public void setFormula(String formula) { + this.formula = formula; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public HashMap getUserProperties() { + return userProperties; + } + + public void setUserProperties(HashMap userProperties) { + this.userProperties = userProperties; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/UpdateDataDescRequest.java b/src/main/java/com/baidubce/services/modbus/model/UpdateDataDescRequest.java new file mode 100755 index 00000000..9e512710 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/UpdateDataDescRequest.java @@ -0,0 +1,212 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.modbus.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.HashMap; + +/** + * Represent the request for update Data description. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateDataDescRequest extends AbstractBceRequest { + + private String dataDescriptionUuid; + + private String state; // ENABLED, DISABLED + + private Integer length; // 数据长度 + + private Integer address; // 十进制地址 + + private Integer bit; // bit位 默认-1 + + private String name; // 显示名称 + + private String kind; // 数据类型 INT, BOOL, REAL, INT32, REAL32 + + private String unit; // 单位 有默认值 + + @JsonProperty("rh") + private Double rangeHigher; // 量程上限 + + @JsonProperty("rl") + private Double rangeLower; // 量程下限 + + private String formula; // 公式 + + @JsonProperty("user_properties") + private HashMap userProperties; + + public String getDataDescriptionUuid() { + return dataDescriptionUuid; + } + + public void setDataDescriptionUuid(String dataDescriptionUuid) { + this.dataDescriptionUuid = dataDescriptionUuid; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public UpdateDataDescRequest withDataDescriptionUuid(String dataDescriptionUuid) { + this.dataDescriptionUuid = dataDescriptionUuid; + return this; + } + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public UpdateDataDescRequest withLength(Integer length) { + this.length = length; + return this; + } + public Integer getAddress() { + return address; + } + + public void setAddress(Integer address) { + this.address = address; + } + + public UpdateDataDescRequest withAddress(Integer address) { + this.address = address; + return this; + } + + public Integer getBit() { + return bit; + } + + public void setBit(Integer bit) { + this.bit = bit; + } + + public UpdateDataDescRequest withBit(Integer bit) { + this.bit = bit; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public UpdateDataDescRequest withName(String name) { + this.name = name; + return this; + } + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + public UpdateDataDescRequest withKind(String kind) { + this.kind = kind; + return this; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public UpdateDataDescRequest withUnit(String unit) { + this.unit = unit; + return this; + } + + public Double getRangeHigher() { + return rangeHigher; + } + + public void setRangeHigher(Double rangeHigher) { + this.rangeHigher = rangeHigher; + } + + public UpdateDataDescRequest withRangeHigher(Double rangeHigher) { + this.rangeHigher = rangeHigher; + return this; + } + + public Double getRangeLower() { + return rangeLower; + } + + public void setRangeLower(Double rangeLower) { + this.rangeLower = rangeLower; + } + + public UpdateDataDescRequest withRangeLower(Double rangeLower) { + this.rangeLower = rangeLower; + return this; + } + + public String getFormula() { + return formula; + } + + public void setFormula(String formula) { + this.formula = formula; + } + + public UpdateDataDescRequest withFormula(String formula) { + this.formula = formula; + return this; + } + + public HashMap getUserProperties() { + return userProperties; + } + + public void setUserProperties(HashMap userProperties) { + this.userProperties = userProperties; + } + + public UpdateDataDescRequest withUserProperties(HashMap userProperties) { + this.userProperties = userProperties; + return this; + } + + @Override + public UpdateDataDescRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/device/CreateDevice.java b/src/main/java/com/baidubce/services/modbus/model/device/CreateDevice.java new file mode 100755 index 00000000..6178f21a --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/device/CreateDevice.java @@ -0,0 +1,111 @@ +package com.baidubce.services.modbus.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CreateDevice extends GenericAccountRequest { + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Integer getSlaveId() { + return slaveId; + } + + public void setSlaveId(Integer slaveId) { + this.slaveId = slaveId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getGatewayUuid() { + return gatewayUuid; + } + + public void setGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + } + + public Integer getBaud() { + return baud; + } + + public void setBaud(Integer baud) { + this.baud = baud; + } + + public Integer getDatabits() { + return databits; + } + + public void setDatabits(Integer databits) { + this.databits = databits; + } + + public Integer getStopbits() { + return stopbits; + } + + public void setStopbits(Integer stopbits) { + this.stopbits = stopbits; + } + + public String getParity() { + return parity; + } + + public void setParity(String parity) { + this.parity = parity; + } + + private String code; // 设备名字 必填 + + private Integer slaveId; // 1~247 必填 + + private String description; + + private String address; // 必填 host:port, or com port, like "COM1 + + private String mode; // 必填 TCP OR RTU + + private String gatewayUuid; // 必填 + + // baud databits stopbits parity only for RTU + private Integer baud; // mode为RTU时必填 + + private Integer databits; // mode为RTU时必填 + + private Integer stopbits; // mode为RTU时必填 + + private String parity; // mode为RTU时必填 "NONE", "EVEN", "ODD" + +} diff --git a/src/main/java/com/baidubce/services/modbus/model/device/Device.java b/src/main/java/com/baidubce/services/modbus/model/device/Device.java new file mode 100755 index 00000000..874282c9 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/device/Device.java @@ -0,0 +1,146 @@ +package com.baidubce.services.modbus.model.device; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class Device { + private String uuid; + + private String code; + + private int slaveId; + + private String description; + + private String address; + + private String state; // "ENABLED" or "DISABLED" + + private String mode; // TCP or RTU + + private String gatewayUuid; + + private String createTime; + + private String updateTime; + + private int baud; // 波特率, RTU模式的参数 + + private int databits; // 数据位数, RTU模式的参数 + + private int stopbits; // 停止位数, RTU模式的参数 + + private String parity; // 校验方式, RTU模式的参数 "NONE", "EVEN", "ODD" + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public int getSlaveId() { + return slaveId; + } + + public void setSlaveId(int slaveId) { + this.slaveId = slaveId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getGatewayUuid() { + return gatewayUuid; + } + + public void setGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public int getBaud() { + return baud; + } + + public void setBaud(int baud) { + this.baud = baud; + } + + public int getDatabits() { + return databits; + } + + public void setDatabits(int databits) { + this.databits = databits; + } + + public int getStopbits() { + return stopbits; + } + + public void setStopbits(int stopbits) { + this.stopbits = stopbits; + } + + public String getParity() { + return parity; + } + + public void setParity(String parity) { + this.parity = parity; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/device/DeviceResponse.java b/src/main/java/com/baidubce/services/modbus/model/device/DeviceResponse.java new file mode 100755 index 00000000..2bb92366 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/device/DeviceResponse.java @@ -0,0 +1,147 @@ +package com.baidubce.services.modbus.model.device; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceResponse extends AbstractBceResponse { + private String uuid; + + private String code; + + private int slaveId; + + private String description; + + private String address; + + private String state; + + private String mode; // TCP or RTU + + private String gatewayUuid; + + private String createTime; + + private String updateTime; + + private int baud; // 波特率, RTU模式的参数 + + private int databits; // 数据位数, RTU模式的参数 + + private int stopbits; // 停止位数, RTU模式的参数 + + private String parity; // 校验方式, RTU模式的参数 "NONE", "EVEN", "ODD" + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public int getSlaveId() { + return slaveId; + } + + public void setSlaveId(int slaveId) { + this.slaveId = slaveId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getGatewayUuid() { + return gatewayUuid; + } + + public void setGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public int getBaud() { + return baud; + } + + public void setBaud(int baud) { + this.baud = baud; + } + + public int getDatabits() { + return databits; + } + + public void setDatabits(int databits) { + this.databits = databits; + } + + public int getStopbits() { + return stopbits; + } + + public void setStopbits(int stopbits) { + this.stopbits = stopbits; + } + + public String getParity() { + return parity; + } + + public void setParity(String parity) { + this.parity = parity; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/device/ListDeviceRequest.java b/src/main/java/com/baidubce/services/modbus/model/device/ListDeviceRequest.java new file mode 100755 index 00000000..4b626ce5 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/device/ListDeviceRequest.java @@ -0,0 +1,77 @@ +package com.baidubce.services.modbus.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListDeviceRequest extends GenericAccountRequest { + public String getGatewayUuid() { + return gatewayUuid; + } + + public void setGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + private String gatewayUuid; + + private String order = "desc"; + + private String orderBy = "createTime"; + + private int pageNo = 1; + + private int pageSize = 50; + + private String state; + + private String status = "ACTIVE"; +} diff --git a/src/main/java/com/baidubce/services/modbus/model/device/ListDeviceResponse.java b/src/main/java/com/baidubce/services/modbus/model/device/ListDeviceResponse.java new file mode 100755 index 00000000..8f2c560b --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/device/ListDeviceResponse.java @@ -0,0 +1,69 @@ +package com.baidubce.services.modbus.model.device; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListDeviceResponse extends AbstractBceResponse { + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + private int totalCount; + + private List result; + + private String order; + + private String orderBy; + + private int pageSize; + + private int pageNo; +} diff --git a/src/main/java/com/baidubce/services/modbus/model/device/UpdateDeviceRequest.java b/src/main/java/com/baidubce/services/modbus/model/device/UpdateDeviceRequest.java new file mode 100755 index 00000000..db25c424 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/device/UpdateDeviceRequest.java @@ -0,0 +1,99 @@ +package com.baidubce.services.modbus.model.device; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateDeviceRequest extends GenericAccountRequest { + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public Integer getSlaveId() { + return slaveId; + } + + public void setSlaveId(Integer slaveId) { + this.slaveId = slaveId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public Integer getBaud() { + return baud; + } + + public void setBaud(Integer baud) { + this.baud = baud; + } + + public Integer getDatabits() { + return databits; + } + + public void setDatabits(Integer databits) { + this.databits = databits; + } + + public Integer getStopbits() { + return stopbits; + } + + public void setStopbits(Integer stopbits) { + this.stopbits = stopbits; + } + + public String getParity() { + return parity; + } + + public void setParity(String parity) { + this.parity = parity; + } + + private String state; + + private Integer slaveId; + + private String description; + + private String address; // host:port, or com port, like "COM1 + + private String mode; // TCP OR RTU + + private Integer baud; + + private Integer databits; + + private Integer stopbits; + + private String parity; // "NONE", "EVEN", "ODD" +} diff --git a/src/main/java/com/baidubce/services/modbus/model/gateway/CreateGatewayRequest.java b/src/main/java/com/baidubce/services/modbus/model/gateway/CreateGatewayRequest.java new file mode 100755 index 00000000..8442ad12 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/CreateGatewayRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.modbus.model.gateway; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateGatewayRequest extends GenericAccountRequest { + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isUseSsl() { + return useSsl; + } + + public void setUseSsl(boolean useSsl) { + this.useSsl = useSsl; + } + + private String code; // 网关ID,唯一 必填 + + private String description; // 网关描述 必填 + + private boolean useSsl; // 是否ssl,否则为tcp 必填 + +} diff --git a/src/main/java/com/baidubce/services/modbus/model/gateway/Gateway.java b/src/main/java/com/baidubce/services/modbus/model/gateway/Gateway.java new file mode 100644 index 00000000..72f549b0 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/Gateway.java @@ -0,0 +1,54 @@ +package com.baidubce.services.modbus.model.gateway; + +/** + * Created by yuanyoujun on 2017/7/31. + */ +public interface Gateway { + public String getUuid(); + + public void setUuid(String uuid); + + public boolean isUseSsl(); + + public void setUseSsl(boolean useSsl); + + public String getUsername(); + + public void setUsername(String username); + + public String getPassword(); + + public void setPassword(String password); + + public String getHost(); + + public void setHost(String host); + + public String getCommandTopic(); + + public void setCommandTopic(String commandTopic); + + public String getState(); + + public void setState(String state); + + public String getDescription(); + + public void setDescription(String description); + + public String getCode(); + + public void setCode(String code); + + public String getCreateTime(); + + public void setCreateTime(String createTime); + + public String getUpdateTime(); + + public void setUpdateTime(String updateTime); + + public int getDeviceNum(); + + public void setDeviceNum(int deviceNum); +} diff --git a/src/main/java/com/baidubce/services/modbus/model/gateway/GatewayResponse.java b/src/main/java/com/baidubce/services/modbus/model/gateway/GatewayResponse.java new file mode 100755 index 00000000..d299e9d0 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/GatewayResponse.java @@ -0,0 +1,138 @@ +package com.baidubce.services.modbus.model.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GatewayResponse extends AbstractBceResponse implements Gateway { + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public boolean isUseSsl() { + return useSsl; + } + + public void setUseSsl(boolean useSsl) { + this.useSsl = useSsl; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getCommandTopic() { + return commandTopic; + } + + public void setCommandTopic(String commandTopic) { + this.commandTopic = commandTopic; + } + + public String getBackControlTopic() { + return backControlTopic; + } + + public void setBackControlTopic(String backControlTopic) { + this.backControlTopic = backControlTopic; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public int getDeviceNum() { + return deviceNum; + } + + public void setDeviceNum(int deviceNum) { + this.deviceNum = deviceNum; + } + + private String uuid; + + private boolean useSsl; // 是否ssl,否则为tcp + + private String username; + + private String password; + + private String host; + + private String commandTopic; + + private String backControlTopic; + + private String state; // ENABLED, DISABLED + + private String description; // 网关描述 + + private String code; + + private String createTime; + + private String updateTime; + + private int deviceNum; +} diff --git a/src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayRequest.java b/src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayRequest.java new file mode 100755 index 00000000..57676b1f --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayRequest.java @@ -0,0 +1,59 @@ +package com.baidubce.services.modbus.model.gateway; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListGatewayRequest extends GenericAccountRequest { + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + private String order = "desc"; + + private String orderBy = "createTime"; + + private int pageNo = 1; + + private int pageSize = 50; + + private String state; // ENABLED, DISABLED + +} diff --git a/src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayResponse.java b/src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayResponse.java new file mode 100755 index 00000000..369d4bf8 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayResponse.java @@ -0,0 +1,69 @@ +package com.baidubce.services.modbus.model.gateway; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListGatewayResponse extends AbstractBceResponse { + private int totalCount; + + private List result; + + private String order; + + private String orderBy; + + private int pageSize; + + private int pageNo; + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/gateway/UpdateGatewayRequest.java b/src/main/java/com/baidubce/services/modbus/model/gateway/UpdateGatewayRequest.java new file mode 100755 index 00000000..b7bc2b1a --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/UpdateGatewayRequest.java @@ -0,0 +1,39 @@ +package com.baidubce.services.modbus.model.gateway; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateGatewayRequest extends GenericAccountRequest { + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Boolean isUseSsl() { + return useSsl; + } + + public void setUseSsl(Boolean useSsl) { + this.useSsl = useSsl; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + private String description; // 网关描述 + + private Boolean useSsl; // 是否ssl,否则为tcp + + private String state; +} diff --git a/src/main/java/com/baidubce/services/modbus/model/parserobject/CreateParserObjectRequest.java b/src/main/java/com/baidubce/services/modbus/model/parserobject/CreateParserObjectRequest.java new file mode 100755 index 00000000..4543d90d --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/parserobject/CreateParserObjectRequest.java @@ -0,0 +1,58 @@ +package com.baidubce.services.modbus.model.parserobject; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreateParserObjectRequest extends GenericAccountRequest { + + private String name; // 必填 + + private String gatewayUuid; // 必填 + + private String storage; // format "bos://xxx/yyy/" + + private String protocol = "MODBUS"; // 目前支持 MODBUS 必填 + + private String destTopic; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getGatewayUuid() { + return gatewayUuid; + } + + public void setGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + } + + public String getStorage() { + return storage; + } + + public void setStorage(String storage) { + this.storage = storage; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getDestTopic() { + return destTopic; + } + + public void setDestTopic(String destTopic) { + this.destTopic = destTopic; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/parserobject/ParserObjectResponse.java b/src/main/java/com/baidubce/services/modbus/model/parserobject/ParserObjectResponse.java new file mode 100755 index 00000000..2a975486 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/parserobject/ParserObjectResponse.java @@ -0,0 +1,117 @@ +package com.baidubce.services.modbus.model.parserobject; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ParserObjectResponse extends AbstractBceResponse { + private String uuid; // + + private String state; // 'RUNNING', 'PAUSED', 'ERROR',三个可能值,默认为PAUSED + + private String dataTopic; + + private String name; + + private String protocol; + + private String gatewayUuid; + + private String gatewayCode; + + private String storage; + + private String createTime; + + private String updateTime; + + private String destTopic; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getDataTopic() { + return dataTopic; + } + + public void setDataTopic(String dataTopic) { + this.dataTopic = dataTopic; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getGatewayUuid() { + return gatewayUuid; + } + + public void setGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + } + + public String getGatewayCode() { + return gatewayCode; + } + + public void setGatewayCode(String gatewayCode) { + this.gatewayCode = gatewayCode; + } + + public String getStorage() { + return storage; + } + + public void setStorage(String storage) { + this.storage = storage; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getDestTopic() { + return destTopic; + } + + public void setDestTopic(String destTopic) { + this.destTopic = destTopic; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/parserobject/UpdateParserObject.java b/src/main/java/com/baidubce/services/modbus/model/parserobject/UpdateParserObject.java new file mode 100755 index 00000000..5b7298b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/parserobject/UpdateParserObject.java @@ -0,0 +1,70 @@ +package com.baidubce.services.modbus.model.parserobject; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UpdateParserObject extends GenericAccountRequest { + + private String state; // 只能为RUNNING or PAUSED + + private String name; + + private String gatewayUuid; + + private String storage; + + private String protocol = "MODBUS"; // 目前支持 MODBUS + + private String destTopic; + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getGatewayUuid() { + return gatewayUuid; + } + + public void setGatewayUuid(String gatewayUuid) { + this.gatewayUuid = gatewayUuid; + } + + public String getStorage() { + return storage; + } + + public void setStorage(String storage) { + this.storage = storage; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getDestTopic() { + return destTopic; + } + + public void setDestTopic(String destTopic) { + this.destTopic = destTopic; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/pullrule/CreatePullRuleRequest.java b/src/main/java/com/baidubce/services/modbus/model/pullrule/CreatePullRuleRequest.java new file mode 100755 index 00000000..99df047a --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/pullrule/CreatePullRuleRequest.java @@ -0,0 +1,71 @@ +package com.baidubce.services.modbus.model.pullrule; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreatePullRuleRequest extends GenericAccountRequest { + + public String getParserObjectUuid() { + return parserObjectUuid; + } + + public void setParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + } + + public List getDeviceUuids() { + return deviceUuids; + } + + public void setDeviceUuids(List deviceUuids) { + this.deviceUuids = deviceUuids; + } + + public int getFunctionCode() { + return functionCode; + } + + public void setFunctionCode(int functionCode) { + this.functionCode = functionCode; + } + + public int getStartAddress() { + return startAddress; + } + + public void setStartAddress(int startAddress) { + this.startAddress = startAddress; + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length = length; + } + + public int getPullInterval() { + return pullInterval; + } + + public void setPullInterval(int pullInterval) { + this.pullInterval = pullInterval; + } + + private String parserObjectUuid; // 必填 + + private List deviceUuids; // 必填 + + private int functionCode; // 必填 + + private int startAddress; // 开始地址 必填 + + private int length; // 读取数据长度 必填 + + private int pullInterval; // 请求间隔 必填 + +} diff --git a/src/main/java/com/baidubce/services/modbus/model/pullrule/CreatePullRuleResponse.java b/src/main/java/com/baidubce/services/modbus/model/pullrule/CreatePullRuleResponse.java new file mode 100755 index 00000000..8f28498a --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/pullrule/CreatePullRuleResponse.java @@ -0,0 +1,22 @@ +package com.baidubce.services.modbus.model.pullrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CreatePullRuleResponse extends AbstractBceResponse { + + private List result; + + + public List getResult() { + return result; + } + + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/pullrule/DeviceUnitDto.java b/src/main/java/com/baidubce/services/modbus/model/pullrule/DeviceUnitDto.java new file mode 100755 index 00000000..c2700b9a --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/pullrule/DeviceUnitDto.java @@ -0,0 +1,46 @@ +package com.baidubce.services.modbus.model.pullrule; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class DeviceUnitDto { + public int getSlaveId() { + return slaveId; + } + + public void setSlaveId(int slaveId) { + this.slaveId = slaveId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + private int slaveId; + + private String code; + + private String description; + + private String address; +} diff --git a/src/main/java/com/baidubce/services/modbus/model/pullrule/ListPullRuleRequest.java b/src/main/java/com/baidubce/services/modbus/model/pullrule/ListPullRuleRequest.java new file mode 100755 index 00000000..cc7ae671 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/pullrule/ListPullRuleRequest.java @@ -0,0 +1,69 @@ +package com.baidubce.services.modbus.model.pullrule; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListPullRuleRequest extends GenericAccountRequest { + + public String getParserObjectUuid() { + return parserObjectUuid; + } + + public void setParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + } + + public Boolean isWithDevice() { + return withDevice; + } + + public void setWithDevice(Boolean withDevice) { + this.withDevice = withDevice; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + private String parserObjectUuid; // list某个解析项目下的从站轮询设置 + + private Boolean withDevice = false; // true则会返回对应device的信息 + + private String order = "desc"; + + private String orderBy = "createTime"; + + private int pageNo = 1; + + private int pageSize = 50; + +} diff --git a/src/main/java/com/baidubce/services/modbus/model/pullrule/ListPullRuleResponse.java b/src/main/java/com/baidubce/services/modbus/model/pullrule/ListPullRuleResponse.java new file mode 100755 index 00000000..339ac0cb --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/pullrule/ListPullRuleResponse.java @@ -0,0 +1,71 @@ +package com.baidubce.services.modbus.model.pullrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ListPullRuleResponse extends AbstractBceResponse { + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + private int totalCount; + + private List result; + + private String order; + + private String orderBy; + + private int pageSize; + + private int pageNo; + +} diff --git a/src/main/java/com/baidubce/services/modbus/model/pullrule/PullRule.java b/src/main/java/com/baidubce/services/modbus/model/pullrule/PullRule.java new file mode 100755 index 00000000..c8f15e7a --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/pullrule/PullRule.java @@ -0,0 +1,106 @@ +package com.baidubce.services.modbus.model.pullrule; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class PullRule { + private String uuid; + + private String parserObjectUuid; + + private String deviceUuid; + + private int functionCode; + + private int startAddress; + + private int length; + + private int pullInterval; + + private String createTime; + + private String updateTime; + + private DeviceUnitDto device; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getParserObjectUuid() { + return parserObjectUuid; + } + + public void setParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + } + + public String getDeviceUuid() { + return deviceUuid; + } + + public void setDeviceUuid(String deviceUuid) { + this.deviceUuid = deviceUuid; + } + + public int getFunctionCode() { + return functionCode; + } + + public void setFunctionCode(int functionCode) { + this.functionCode = functionCode; + } + + public int getStartAddress() { + return startAddress; + } + + public void setStartAddress(int startAddress) { + this.startAddress = startAddress; + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length = length; + } + + public int getPullInterval() { + return pullInterval; + } + + public void setPullInterval(int pullInterval) { + this.pullInterval = pullInterval; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public DeviceUnitDto getDevice() { + return device; + } + + public void setDevice(DeviceUnitDto device) { + this.device = device; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/pullrule/PullRuleResponse.java b/src/main/java/com/baidubce/services/modbus/model/pullrule/PullRuleResponse.java new file mode 100755 index 00000000..58b4c83b --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/pullrule/PullRuleResponse.java @@ -0,0 +1,97 @@ +package com.baidubce.services.modbus.model.pullrule; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class PullRuleResponse extends AbstractBceResponse { + private String uuid; + + private String parserObjectUuid; + + private String deviceUuid; + + private int functionCode; + + private int startAddress; + + private int length; + + private int pullInterval; + + private String createTime; + + private String updateTime; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getParserObjectUuid() { + return parserObjectUuid; + } + + public void setParserObjectUuid(String parserObjectUuid) { + this.parserObjectUuid = parserObjectUuid; + } + + public String getDeviceUuid() { + return deviceUuid; + } + + public void setDeviceUuid(String deviceUuid) { + this.deviceUuid = deviceUuid; + } + + public int getFunctionCode() { + return functionCode; + } + + public void setFunctionCode(int functionCode) { + this.functionCode = functionCode; + } + + public int getStartAddress() { + return startAddress; + } + + public void setStartAddress(int startAddress) { + this.startAddress = startAddress; + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length = length; + } + + public int getPullInterval() { + return pullInterval; + } + + public void setPullInterval(int pullInterval) { + this.pullInterval = pullInterval; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } +} diff --git a/src/main/java/com/baidubce/services/modbus/model/pullrule/PullRuleResponseWithDevice.java b/src/main/java/com/baidubce/services/modbus/model/pullrule/PullRuleResponseWithDevice.java new file mode 100755 index 00000000..95b43de8 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/pullrule/PullRuleResponseWithDevice.java @@ -0,0 +1,16 @@ +package com.baidubce.services.modbus.model.pullrule; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class PullRuleResponseWithDevice extends PullRuleResponse { + public DeviceUnitDto getDevice() { + return device; + } + + public void setDevice(DeviceUnitDto device) { + this.device = device; + } + + private DeviceUnitDto device; +} diff --git a/src/main/java/com/baidubce/services/modbus/model/pullrule/UpdatePullRuleRequest.java b/src/main/java/com/baidubce/services/modbus/model/pullrule/UpdatePullRuleRequest.java new file mode 100755 index 00000000..11b15b6a --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/pullrule/UpdatePullRuleRequest.java @@ -0,0 +1,17 @@ +package com.baidubce.services.modbus.model.pullrule; + +import com.baidubce.model.GenericAccountRequest; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class UpdatePullRuleRequest extends GenericAccountRequest { + public Integer getPullInterval() { + return pullInterval; + } + + public void setPullInterval(Integer pullInterval) { + this.pullInterval = pullInterval; + } + + private Integer pullInterval; // 请求时间间隔 +} diff --git a/src/main/java/com/baidubce/services/moladb/MolaDbClient.java b/src/main/java/com/baidubce/services/moladb/MolaDbClient.java old mode 100644 new mode 100755 index 2e61f121..a9f7d197 --- a/src/main/java/com/baidubce/services/moladb/MolaDbClient.java +++ b/src/main/java/com/baidubce/services/moladb/MolaDbClient.java @@ -239,7 +239,7 @@ public DeleteInstanceResponse deleteInstance(DeleteInstanceRequest request) { * * NOTE: There MUST be no table within the instance to be deleted. * - * @param Instance name to be deleted. + * @param instanceName the name of instance to be deleted. * * @return The responseContent from the Delete instance service method, as returned by * Moladb. diff --git a/src/main/java/com/baidubce/services/moladb/model/BatchGetItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/BatchGetItemRequest.java old mode 100644 new mode 100755 index e0b387b7..db407a5f --- a/src/main/java/com/baidubce/services/moladb/model/BatchGetItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/BatchGetItemRequest.java @@ -60,7 +60,7 @@ public BatchGetItemRequest withRequestItems( /** * Get the request Items set in this BatchGetItem operation. * - * @return Returns the map of attributes with name and key, the type is in Map. + * @return Returns the map of attributes with name and key. */ public Map getRequestItems() { return this.requestItems; diff --git a/src/main/java/com/baidubce/services/moladb/model/BatchGetItemResponse.java b/src/main/java/com/baidubce/services/moladb/model/BatchGetItemResponse.java old mode 100644 new mode 100755 index e3c51d48..28bfe862 --- a/src/main/java/com/baidubce/services/moladb/model/BatchGetItemResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/BatchGetItemResponse.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Map; + import com.baidubce.model.AbstractBceResponse; /** @@ -33,8 +34,8 @@ public BatchGetItemResponse() { /** * Get all of the unprocessed items in this BatchGetItem request. - * - * @return All of the unprocessed items in this BatchGetItem request, the type is in Map type. + * + * @return All of the unprocessed items in this BatchGetItem request. */ public Map getUnprocessedItems() { return this.unprocessedItems; @@ -42,13 +43,13 @@ public Map getUnprocessedItems() { /** * Set all of the unprocessed items in this BatchGetItem request. - * - * @param items All of the unprocessed items in this BatchGetItem request, the type is in Map type. + * + * @param items All of the unprocessed items in this BatchGetItem request. */ public void setUnprocessedItems(Map items) { this.unprocessedItems = items; } - + /** * Return a string representation of the response information. * @@ -68,16 +69,16 @@ public String toString() { /** * Set the processed items' content for this BatchGetItem request. - * + * * @param responses The processed items' content for this BatchGetItem request. */ public void setResponses(Map>> responses) { this.responses = responses; } - + /** * Get the processed items' content for this BatchGetItem request. - * + * * @return The processed items' content for this BatchGetItem request. */ public Map>> getResponses() { diff --git a/src/main/java/com/baidubce/services/moladb/model/CreateTableRequest.java b/src/main/java/com/baidubce/services/moladb/model/CreateTableRequest.java old mode 100644 new mode 100755 index a022d372..9336e852 --- a/src/main/java/com/baidubce/services/moladb/model/CreateTableRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/CreateTableRequest.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; + import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; import com.baidubce.services.moladb.MolaDbConstants; @@ -19,7 +20,6 @@ public class CreateTableRequest extends AbstractBceRequest { private List attributeDefinitions; /** - * * Constructs a new CreateTableRequest object. * Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. @@ -31,7 +31,7 @@ public CreateTableRequest() { * Constructs a new CreateTableRequest object. * Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. - * + * * @param name The name of the table to create. */ public CreateTableRequest(String name) { @@ -40,7 +40,7 @@ public CreateTableRequest(String name) { /** * Get the name of the table to create. - * + * * @return The name of the table to create. */ public String getTableName() { @@ -49,28 +49,29 @@ public String getTableName() { /** * Set the name of the table to create. - * + * * @param tableName The name of the table to create. */ public void setTableName(String tableName) { this.tableName = tableName; } - + /** * Set the name of the table to create. - * - * @param tableName The name of the table to create. + * + * @param tableName The name of the table to create. * @return A reference to this object so that method calls can be chained together. */ public CreateTableRequest withTableName(String tableName) { this.setTableName(tableName); return this; } - + /** * Add attributes with value type and name when creating a table. - * - * @param attributeDefinitions A list of attributes with name and value for creating a table, the type is List. + * + * @param attributeDefinitions A list of attributes with name and value for creating a table, the type is + * List<AttributeDefinition>. * @see AttributeDefinition */ public void setAttributeDefinitions(List attributeDefinitions) { @@ -79,31 +80,32 @@ public void setAttributeDefinitions(List attributeDefinitio /** * Add attributes with value type and name when creating a table. - * - * @param attributeDefinitions A list of attributes with name and value for creating a table, the type is List. - * @see AttributeDefinition + * + * @param attributeDefinitions A list of attributes with name and value for creating a table, the type is + * List<AttributeDefinition>. * @return A reference to this object so that method calls can be chained together. + * @see AttributeDefinition */ public CreateTableRequest withAttributeDefinitions(List attributeDefinitions) { this.setAttributeDefinitions(attributeDefinitions); return this; } - + /** * Get the attribute definitions. - * - * @see AttributeDefinition + * * @return The attribute definitions. + * @see AttributeDefinition */ public List getAttributeDefinitions() { return this.attributeDefinitions; } /** - * Set the Key information for creating a table, contains hashkey or hashkey and rangekey. - * The type is List type. - * - * @param keySchema The Key information for creating a table, contains hashkey or hashkey and rangekey. + * Set the Key information for creating a table, contains hashkey or hashkey and rangekey. + * The type is List<KeySchemaElement> type. + * + * @param keySchema The Key information for creating a table, contains hashkey or hashkey and rangekey. * The type is List type. * @see KeySchemaElement */ @@ -112,13 +114,13 @@ public void setKeySchema(List keySchema) { } /** - * Set the Key information for creating a table, contains hashkey or hashkey and rangekey. - * The type is List type. - * - * @param keySchema The Key information for creating a table, contains hashkey or hashkey and rangekey. - * The type is List type. - * @see KeySchemaElement + * Set the Key information for creating a table, contains hashkey or hashkey and rangekey. + * The type is List<KeySchemaElement> type. + * + * @param keySchema The Key information for creating a table, contains hashkey or hashkey and rangekey. + * The type is List<KeySchemaElement> type. * @return A reference to this object so that method calls can be chained together. + * @see KeySchemaElement */ public CreateTableRequest withKeySchema(List keySchema) { this.setKeySchema(keySchema); @@ -126,20 +128,20 @@ public CreateTableRequest withKeySchema(List keySchema) { } /** - * Get the Key information for creating a table, contains hashkey or hashkey and rangekey. - * The type is List type. - * - * @return The Key information for creating a table, contains hashkey or hashkey and rangekey. - * The type is List type. + * Get the Key information for creating a table, contains hashkey or hashkey and rangekey. + * The type is List<KeySchemaElement> type. + * + * @return The Key information for creating a table, contains hashkey or hashkey and rangekey. + * The type is List<KeySchemaElement> type. * @see KeySchemaElement */ public List getKeySchema() { return this.keySchema; } - + /** * Set the privisioned throughput when creating a table. - * + * * @param provision The privisioned throughtput information when creating a table. * @see ProvisionedThroughput */ @@ -149,19 +151,19 @@ public void setProvisionedThroughput(ProvisionedThroughput provision) { /** * Set the provisioned throughput when creating a table. - * + * * @param provision The provisioned throughtput information when creating a table. - * @see ProvisionedThroughput * @return A reference to this object so that method calls can be chained together. + * @see ProvisionedThroughput */ public CreateTableRequest withProvisionedThroughput(ProvisionedThroughput provision) { this.setProvisionedThroughput(provision); return this; } - + /** * Get the privisioned throughput when creating a table. - * + * * @return The privisioned throughtput information when creating a table. * @see ProvisionedThroughput */ @@ -176,21 +178,21 @@ public ProvisionedThroughput getProvisionedThroughput() { */ public String toString() { HashMap result = new HashMap(); - result.put(MolaDbConstants.JSON_ATTRIBUTE_DEFINITIONS, - this.attributeDefinitionsToJson(this.attributeDefinitions)); + result.put(MolaDbConstants.JSON_ATTRIBUTE_DEFINITIONS, + this.attributeDefinitionsToJson(this.attributeDefinitions)); result.put(MolaDbConstants.JSON_KEY_SCHEMA, this.keySchemaToJson(this.keySchema)); result.put(MolaDbConstants.JSON_PROVISION_THROUGHPUT, - this.provisionedThroughput.toJsonObj()); + this.provisionedThroughput.toJsonObj()); result.put(MolaDbConstants.JSON_TABLENAME, this.tableName); return JsonUtils.toJsonString(result); } - + @Override public CreateTableRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } - + private List keySchemaToJson(List schema) { List obj = new ArrayList(); for (KeySchemaElement element : schema) { @@ -198,7 +200,7 @@ private List keySchemaToJson(List schema) { } return obj; } - + private List attributeDefinitionsToJson(List attributes) { List obj = new ArrayList(); for (AttributeDefinition element : attributes) { diff --git a/src/main/java/com/baidubce/services/moladb/model/GetInstanceResponse.java b/src/main/java/com/baidubce/services/moladb/model/GetInstanceResponse.java old mode 100644 new mode 100755 index 255ecedd..12ad65c6 --- a/src/main/java/com/baidubce/services/moladb/model/GetInstanceResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/GetInstanceResponse.java @@ -1,6 +1,7 @@ package com.baidubce.services.moladb.model; import java.util.List; + import com.baidubce.model.AbstractBceResponse; /** @@ -10,7 +11,7 @@ public class GetInstanceResponse extends AbstractBceResponse { private String description; private String name; private List tableNames; - + /** * Constructs a new GetInstanceResponse object. * Callers should use the setter or fluent setter (with...) methods to @@ -21,7 +22,7 @@ public GetInstanceResponse() { /** * Get the description information for this instance. - * + * * @return The description information for this instance. */ public String getDescription() { @@ -30,7 +31,7 @@ public String getDescription() { /** * Get the name of this instance. - * + * * @return The name of this instance. */ public String getInstanceName() { @@ -39,8 +40,8 @@ public String getInstanceName() { /** * Get all of the table names belong to this instance. - * - * @return All of the table names belong to this instance, the type is in List type. + * + * @return All of the table names belong to this instance. */ public List getTableNames() { return tableNames; @@ -48,7 +49,7 @@ public List getTableNames() { /** * Set the description information for this instance. - * + * * @param description The description information for this instance. */ public void setDescription(String description) { @@ -57,7 +58,7 @@ public void setDescription(String description) { /** * Set the name of the requested instance for response. - * + * * @param instanceName The name of the requested instance. */ public void setInstanceName(String instanceName) { @@ -66,8 +67,8 @@ public void setInstanceName(String instanceName) { /** * Set the table names to the response tables set. - * - * @param tableNames The names of tables to be added to the response tables set, the type is in List type. + * + * @param tableNames The names of tables to be added to the response tables set. */ public void setTableNames(List tableNames) { this.tableNames = tableNames; diff --git a/src/main/java/com/baidubce/services/moladb/model/GetItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/GetItemRequest.java old mode 100644 new mode 100755 index d6c14abb..3c95a3c4 --- a/src/main/java/com/baidubce/services/moladb/model/GetItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/GetItemRequest.java @@ -169,7 +169,6 @@ public String getTableName() { * together. * * @param attributeNames The attribute name list which are expected to be returned from the table. - * @return A reference to this object so that method calls can be chained together */ public void setAttributesToGet(List attributeNames) { this.attributesToGet = attributeNames; diff --git a/src/main/java/com/baidubce/services/moladb/model/GetItemResponse.java b/src/main/java/com/baidubce/services/moladb/model/GetItemResponse.java old mode 100644 new mode 100755 index c6fe34a4..ea3ff895 --- a/src/main/java/com/baidubce/services/moladb/model/GetItemResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/GetItemResponse.java @@ -32,7 +32,7 @@ public GetItemResponse() { /** * The method return the Item that got from table in Moladb. * - * @return The Item got from the table in Moladb, the type is Map. + * @return The Item got from the table in Moladb. */ public Map getItem() { return item; @@ -50,7 +50,7 @@ public String toString() { /** * The method set the Item that in GetItemResponse. * - * @param other The Items got from the table in MolaDB, the type is Map. + * @param other The Items got from the table in MolaDB. */ public void setItem(Map other) { item = other; diff --git a/src/main/java/com/baidubce/services/moladb/model/Key.java b/src/main/java/com/baidubce/services/moladb/model/Key.java old mode 100644 new mode 100755 index 5eef9c89..d5162cca --- a/src/main/java/com/baidubce/services/moladb/model/Key.java +++ b/src/main/java/com/baidubce/services/moladb/model/Key.java @@ -87,7 +87,7 @@ public Key withAttribute(String attributeName, AttributeValue value) { /** * Get this object's attribute map with name and value. * - * @return A map of attributes with name and value, the type is Map. + * @return A map of attributes with name and value. */ public Map getAttributes() { return attributes; diff --git a/src/main/java/com/baidubce/services/moladb/model/KeySchemaElement.java b/src/main/java/com/baidubce/services/moladb/model/KeySchemaElement.java old mode 100644 new mode 100755 index 191237fd..0c77a2a6 --- a/src/main/java/com/baidubce/services/moladb/model/KeySchemaElement.java +++ b/src/main/java/com/baidubce/services/moladb/model/KeySchemaElement.java @@ -29,7 +29,7 @@ public KeySchemaElement() { * initialize any additional object members. * * @param attributeName The attribute name for a key. - * @param KeyType The type of the key, it is hashKey or rangeKey. + * @param keyType The type of the key, it is hashKey or rangeKey. */ public KeySchemaElement(String attributeName, String keyType) { this.attributeName = attributeName; diff --git a/src/main/java/com/baidubce/services/moladb/model/KeysAndAttributes.java b/src/main/java/com/baidubce/services/moladb/model/KeysAndAttributes.java old mode 100644 new mode 100755 index acdd9414..09be0a66 --- a/src/main/java/com/baidubce/services/moladb/model/KeysAndAttributes.java +++ b/src/main/java/com/baidubce/services/moladb/model/KeysAndAttributes.java @@ -39,7 +39,7 @@ public KeysAndAttributes() { /** * Set the list of Keys to get associated items. * - * @param keys The key attributes and values to get items from a table, the type is List. + * @param keys The key attributes and values to get items from a table. * @return Returns a reference to this object so that method calls can be chained together. */ public KeysAndAttributes withKeys(List keys) { @@ -50,7 +50,7 @@ public KeysAndAttributes withKeys(List keys) { /** * Set the list of Keys to get associated items. * - * @param keys The key attributes and values to get items from a table, the type is List. + * @param keys The key attributes and values to get items from a table. * @throws IllegalArgumentException * if the list is empty. */ @@ -138,7 +138,7 @@ public boolean isConsistentRead() { /** * Get all of the attributes to retrieve from a table. * - * @return All of the attributes to retrieve from a table, the type is List. + * @return All of the attributes to retrieve from a table. */ public List getAttributesToGet() { return attributesToGet; diff --git a/src/main/java/com/baidubce/services/moladb/model/ListInstancesResponse.java b/src/main/java/com/baidubce/services/moladb/model/ListInstancesResponse.java old mode 100644 new mode 100755 index 7bfdaa82..a3d78d5e --- a/src/main/java/com/baidubce/services/moladb/model/ListInstancesResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/ListInstancesResponse.java @@ -20,7 +20,7 @@ public ListInstancesResponse() { /** * Get the names of all instances got from server side. * - * @return The names of all instances got from server side, the type is in List. + * @return The names of all instances got from server side. */ public List getInstanceNames() { return this.instanceNames; @@ -29,7 +29,7 @@ public List getInstanceNames() { /** * Set the names of all instances got from server side. * - * @param names The names of all instances got from server side, the type is in List. + * @param names The names of all instances got from server side. */ public void setInstanceNames(List names) { this.instanceNames = names; diff --git a/src/main/java/com/baidubce/services/moladb/model/ListTablesResponse.java b/src/main/java/com/baidubce/services/moladb/model/ListTablesResponse.java old mode 100644 new mode 100755 index 2f48853b..8e0734bc --- a/src/main/java/com/baidubce/services/moladb/model/ListTablesResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/ListTablesResponse.java @@ -20,7 +20,7 @@ public ListTablesResponse() { /** * Get the names of all tables got from server side. * - * @return The names of all tables got from server side, the type is in List. + * @return The names of all tables got from server side. */ public List getTableNames() { return this.tableNames; @@ -30,7 +30,7 @@ public List getTableNames() { /** * Set the names of all tables got from server side. * - * @param names The names of all tables got from server side, the type is in ArrayList. + * @param names The names of all tables got from server side. */ public void setTableNames(List names) { this.tableNames = names; diff --git a/src/main/java/com/baidubce/services/moladb/model/PutItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/PutItemRequest.java old mode 100644 new mode 100755 index f5c33fdb..79919752 --- a/src/main/java/com/baidubce/services/moladb/model/PutItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/PutItemRequest.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.Map; + import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; import com.baidubce.services.moladb.MolaDbConstants; @@ -39,7 +40,7 @@ public PutItemRequest() { * Constructs a new PutItemRequest object. * Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. - * + * * @param name The name of the table to contain the item. */ public PutItemRequest(String name) { @@ -49,35 +50,35 @@ public PutItemRequest(String name) { /** * Get the name of the table to contain the item. *

- * Constraints:
- * Length: 3 - 32
- * Pattern: [a-zA-Z0-9_.-]+
+ * Constraints:
+ * Length: 3 - 32
+ * Pattern: [a-zA-Z0-9_.-]+
* * @return The name of the table to contain the item. */ public String getTableName() { return this.tableName; } - + /** * Set the name of the table to contain the item. *

- * Constraints:
- * Length: 3 - 32
- * Pattern: [a-zA-Z0-9_.-]+
+ * Constraints:
+ * Length: 3 - 32
+ * Pattern: [a-zA-Z0-9_.-]+
* * @param tableName The name of the table to contain the item. */ public void setTableName(String tableName) { this.tableName = tableName; } - + /** * Set the name of the table to contain the item. *

- * Constraints:
- * Length: 3 - 32
- * Pattern: [a-zA-Z0-9_.-]+
+ * Constraints:
+ * Length: 3 - 32
+ * Pattern: [a-zA-Z0-9_.-]+
* * @param tableName The name of the table to contain the item. * @return Returns a reference to the object so that method calls can be chained together. @@ -92,43 +93,41 @@ public PutItemRequest withTableName(String tableName) { * Returns a reference to this object so that method calls can be chained together. * * @param item An container of attribute name/value pairs. Only the - * primary key attributes are required; you can optionally provide other - * attribute name-value pairs for the item.

You must provide all of - * the attributes for the primary key. For example, with a hash type - * primary key, you only need to provide the hash attribute. For a - * hash-and-range type primary key, you must provide both the hash - * attribute and the range attribute.

If you specify any attributes - * that are part of an key, then the data types for those - * attributes must match those of the schema in the table's attribute - * definition.

- * + * primary key attributes are required; you can optionally provide other + * attribute name-value pairs for the item.

You must provide all of + * the attributes for the primary key. For example, with a hash type + * primary key, you only need to provide the hash attribute. For a + * hash-and-range type primary key, you must provide both the hash + * attribute and the range attribute.

If you specify any attributes + * that are part of an key, then the data types for those + * attributes must match those of the schema in the table's attribute + * definition.

* @return A reference to this updated object so that method calls can be chained - * together. + * together. */ public PutItemRequest withItem(Map item) { this.setItem(item); return this; } - + /** * Set the Item object to be put in in table. * * @param item An container of attribute name/value pairs. Only the - * primary key attributes are required; you can optionally provide other - * attribute name-value pairs for the item.

You must provide all of - * the attributes for the primary key. For example, with a hash type - * primary key, you only need to provide the hash attribute. For a - * hash-and-range type primary key, you must provide both the hash - * attribute and the range attribute.

If you specify any attributes - * that are part of an key, then the data types for those - * attributes must match those of the schema in the table's attribute - * definition.

- * + * primary key attributes are required; you can optionally provide other + * attribute name-value pairs for the item.

You must provide all of + * the attributes for the primary key. For example, with a hash type + * primary key, you only need to provide the hash attribute. For a + * hash-and-range type primary key, you must provide both the hash + * attribute and the range attribute.

If you specify any attributes + * that are part of an key, then the data types for those + * attributes must match those of the schema in the table's attribute + * definition.

*/ public void setItem(Map item) { this.item = item; } - + /** * Get the Item objects to be put in in table. * @@ -149,7 +148,7 @@ public String toString() { jsonObj.put(MolaDbConstants.JSON_ITEM, itemObj); return JsonUtils.toJsonString(jsonObj); } - + protected Map marshallerItem(Map item) { Map obj = new HashMap(); for (Map.Entry entry : item.entrySet()) { diff --git a/src/main/java/com/baidubce/services/moladb/model/QueryRequest.java b/src/main/java/com/baidubce/services/moladb/model/QueryRequest.java old mode 100644 new mode 100755 index 02941c99..f25bf935 --- a/src/main/java/com/baidubce/services/moladb/model/QueryRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/QueryRequest.java @@ -15,6 +15,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; import com.baidubce.services.moladb.MolaDbConstants; @@ -33,7 +34,7 @@ public class QueryRequest extends AbstractBceRequest { private String keyConditionExpression; private Map expressionAttributeValues; private String order = MolaDbConstants.JSON_ASC; - + /** * Constructs a new QueryRequest object. * Callers should use the setter or fluent setter (with...) methods to @@ -46,7 +47,7 @@ public QueryRequest() { * Constructs a new QueryRequest object. * Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. - * + * * @param tableName The name of the table to query. */ public QueryRequest(String tableName) { @@ -61,7 +62,7 @@ public QueryRequest(String tableName) { public String getKeyConditionExpression() { return this.keyConditionExpression; } - + /** * Set the query condition expression for this query request. * @@ -70,7 +71,7 @@ public String getKeyConditionExpression() { public void setKeyConditionExpression(String expression) { this.keyConditionExpression = expression; } - + /** * Set the query condition expression for this query request. * @@ -81,7 +82,7 @@ public QueryRequest withKeyConditionExpression(String expression) { this.setKeyConditionExpression(expression); return this; } - + /** * Get the values for the parameters in the the query condition expression for this query request. * @@ -90,7 +91,7 @@ public QueryRequest withKeyConditionExpression(String expression) { public Map getExpressionAttributeValues() { return this.expressionAttributeValues; } - + /** * Set the values for the parameters in the the query condition expression for this query request. * @@ -99,7 +100,7 @@ public Map getExpressionAttributeValues() { public void setExpressionAttributeValues(Map attributes) { this.expressionAttributeValues = attributes; } - + /** * Set the values for the parameters in the the query condition expression for this query request. * @@ -119,7 +120,7 @@ public QueryRequest withExpressionAttributeValues(Map at public void setTableName(String tableName) { this.tableName = tableName; } - + /** * Set the name of table for this query items. * @@ -134,7 +135,7 @@ public QueryRequest withTableName(String tableName) { /** * Get the name of table for this query items. * - * @param tableName The name of table for query items. + * @return The name of table for query items. */ public String getTableName() { return this.tableName; @@ -143,7 +144,7 @@ public String getTableName() { /** * Set the type of the consistency of a read operation.The default value is false, representing that it is * eventually consistent read. If the value is true, it is a strongly consistent read. - * + * * @param consistent The consistency of a read operation. The default value is false, representing that it is * eventually consistent read. If the value is true, it is a strongly consistent read. */ @@ -154,7 +155,7 @@ public void setConsistentRead(boolean consistent) { /** * Set the type of the consistency of a read operation.The default value is false, representing that it is * eventually consistent read. If the value is true, it is a strongly consistent read. - * + * * @param consistent The consistency of a read operation. The default value is false, representing that it is * eventually consistent read. If the value is true, it is a strongly consistent read. * @return A reference to this object so that method calls can be chained together. @@ -163,6 +164,7 @@ public QueryRequest withConsistentRead(boolean consistent) { this.setConsistentRead(consistent); return this; } + /** * Return true if the consistency is a strongly consistent read; else return false. * @@ -172,7 +174,7 @@ public QueryRequest withConsistentRead(boolean consistent) { public boolean isConsistentRead() { return this.consistentRead; } - + /** * Set the order by rangekey for the query items result, in descedning order or in ascending order. * @@ -181,7 +183,7 @@ public boolean isConsistentRead() { public void setOrder(String order) { this.order = order; } - + /** * Set the order by rangekey for the query items result, in descedning order or in ascending order. * @@ -191,7 +193,7 @@ public QueryRequest withOrder(String order) { this.setOrder(order); return this; } - + /** * Get the order by rangekey for the query items result, in descedning order or in ascending order. * @@ -200,10 +202,10 @@ public QueryRequest withOrder(String order) { public String getOrder() { return this.order; } - + /** * Set the query items result in descending order by rangekey. - * + * * @return A reference to this object so that method calls can be chained together. */ public QueryRequest orderByDesc() { @@ -213,17 +215,17 @@ public QueryRequest orderByDesc() { /** * Set the query items result in ascending order by rangekey. - * + * * @return A reference to this object so that method calls can be chained together. */ public QueryRequest orderByAsc() { this.order = MolaDbConstants.JSON_ASC; return this; } - + /** * Set the maximum number of return query items in one time. - * + * * @param limit The maximum number of return query items in one time. */ public void setLimit(int limit) { @@ -232,7 +234,7 @@ public void setLimit(int limit) { /** * Set the maximum number of return query items in one time. - * + * * @param limit The maximum number of return query items in one time. * @return A reference to this object so that method calls can be chained together. */ @@ -240,10 +242,10 @@ public QueryRequest withLimit(int limit) { this.setLimit(limit); return this; } - + /** * Get the maximum number of return query items in one time. - * + * * @return The maximum number of return query items in one time. */ public int getLimit() { @@ -252,16 +254,16 @@ public int getLimit() { /** * Get the attributes to retrieve from the QueryRequest. - * - * @return The attributes to retrieve from the QueryRequest, the type is List. + * + * @return The attributes to retrieve from the QueryRequest. */ public List getAttributesToGet() { return this.attributesToGet; } - + /** * Set the names of attributes to retrieve from the result items. - * + * * @param attributes The names of attributes to retrieve from the result items. */ public void setAttributesToGet(List attributes) { @@ -270,21 +272,21 @@ public void setAttributesToGet(List attributes) { /** * Set the names of attributes to retrieve from the result items. - * - * @param attributes The names of attributes to retrieve from the result items, the type is List. + * + * @param attributes The names of attributes to retrieve from the result items. * @return A reference to this object so that method calls can be chained together. */ public QueryRequest withAttributesToGet(List attributes) { this.setAttributesToGet(attributes); return this; } - + /** - * Set the primary key(hashkey or hashkey and rangekey) of the first item that this + * Set the primary key(hashkey or hashkey and rangekey) of the first item that this * operation will evaluate. Use the value that was returned for LastEvaluatedKey * in the previous operation. - * - * @param exclusiveStartKey The primary key(hashkey or hashkey and rangekey) of the first item that this + * + * @param exclusiveStartKey The primary key(hashkey or hashkey and rangekey) of the first item that this * operation will evaluate. Use the value that was returned for LastEvaluatedKey in the previous operation. */ public void setExclusiveStartKey(Key exclusiveStartKey) { @@ -292,12 +294,12 @@ public void setExclusiveStartKey(Key exclusiveStartKey) { } /** - * Set the primary key(hashkey or hashkey and rangekey) of the first item that this + * Set the primary key(hashkey or hashkey and rangekey) of the first item that this * operation will evaluate. Use the value that was returned for LastEvaluatedKey * in the previous operation. - * - * @param exclusiveStartKey The primary key(hashkey or hashkey and rangekey) of the first item that this - * operation will evaluate. Use the value that was returned for LastEvaluatedKey + * + * @param exclusiveStartKey The primary key(hashkey or hashkey and rangekey) of the first item that this + * operation will evaluate. Use the value that was returned for LastEvaluatedKey * in the previous operation. * @return A reference to this object so that method calls can be chained together. */ @@ -305,31 +307,31 @@ public QueryRequest withExclusiveStartKey(Key exclusiveStartKey) { this.setExclusiveStartKey(exclusiveStartKey); return this; } - + /** - * Get the primary key(hashkey or hashkey and rangekey) of the first item that this + * Get the primary key(hashkey or hashkey and rangekey) of the first item that this * operation will evaluate. Use the value that was returned for LastEvaluatedKey * in the previous operation. - * - * @return The primary key(hashkey or hashkey and rangekey) of the first item that this + * + * @return The primary key(hashkey or hashkey and rangekey) of the first item that this * operation will evaluate. Use the value that was returned for LastEvaluatedKey in the previous operation. */ public Key getExclusiveStartKey() { return this.exclusiveStartKey; } - + /** * Return a string representation of the object. - * + * * @return A string representation of the object. */ public String toString() { HashMap jsonObj = new HashMap(); jsonObj.put(MolaDbConstants.JSON_TABLENAME, this.tableName); - + if (!this.attributesToGet.isEmpty()) { jsonObj.put(MolaDbConstants.JSON_ATTRIBUTES_TO_GET, - this.attributesToGet); + this.attributesToGet); } if (null != this.exclusiveStartKey) { jsonObj.put(MolaDbConstants.JSON_EXCLUSIVE_START_KEY, this.exclusiveStartKey.toJsonObj()); @@ -341,10 +343,10 @@ public String toString() { if (this.limit > 0) { jsonObj.put(MolaDbConstants.JSON_LIMIT, Integer.toString(this.limit)); } - + jsonObj.put(MolaDbConstants.JSON_KEY_CONDITION_EXPRESSION, this.keyConditionExpression); - jsonObj.put(MolaDbConstants.JSON_EXPRESSION_ATTRIBUTEVALUES, - this.attributeValueToJson(this.expressionAttributeValues)); + jsonObj.put(MolaDbConstants.JSON_EXPRESSION_ATTRIBUTEVALUES, + this.attributeValueToJson(this.expressionAttributeValues)); jsonObj.put(MolaDbConstants.JSON_ORDER, this.order); return JsonUtils.toJsonString(jsonObj); } @@ -353,7 +355,7 @@ public QueryRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } - + private Map attributeValueToJson(Map attributes) { Map obj = new HashMap(); for (Map.Entry entry : attributes.entrySet()) { diff --git a/src/main/java/com/baidubce/services/moladb/model/QueryResponse.java b/src/main/java/com/baidubce/services/moladb/model/QueryResponse.java old mode 100644 new mode 100755 index 89bf8bd5..eb80b114 --- a/src/main/java/com/baidubce/services/moladb/model/QueryResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/QueryResponse.java @@ -45,7 +45,7 @@ public void setLastEvaluatedKey(Key lastKey) { /** * Set the list of result items from this query operation. * - * @param item A list of result items from this query operation. + * @param items A list of result items from this query operation. */ public void setItems(List> items) { this.items = items; diff --git a/src/main/java/com/baidubce/services/moladb/model/UpdateItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/UpdateItemRequest.java old mode 100644 new mode 100755 index 0b592ebc..283b491a --- a/src/main/java/com/baidubce/services/moladb/model/UpdateItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/UpdateItemRequest.java @@ -112,7 +112,7 @@ public String toString() { /** * Set new attribute value with corresponding attribute name which will be updated. * - * @param attributes A map of attributes to update in an item, the type is Map. + * @param attributes A map of attributes to update in an item. */ public void setAttributeUpdates(Map attributes) { this.attributeUpdates = attributes; @@ -121,7 +121,7 @@ public void setAttributeUpdates(Map attributes) { /** * Set new attribute value with corresponding attribute name which will be updated. * - * @param attributes A map of attributes to update in an item, the type is Map. + * @param attributes A map of attributes to update in an item. * @return A reference to this object so that method calls can be chained together. */ public UpdateItemRequest withAttributeUpdates(Map attributes) { @@ -132,7 +132,7 @@ public UpdateItemRequest withAttributeUpdates(Map /** * Get new attribute value with corresponding attribute name which will be updated. * - * @return A map of attributes to update in an item, the type is Map. + * @return A map of attributes to update in an item. */ public Map getAttributeUpdates() { return this.attributeUpdates; diff --git a/src/main/java/com/baidubce/services/mvs/MvsClient.java b/src/main/java/com/baidubce/services/mvs/MvsClient.java new file mode 100644 index 00000000..82dafdc8 --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/MvsClient.java @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.mvs.model.InsertImageRequest; +import com.baidubce.services.mvs.model.InsertImageResponse; +import com.baidubce.services.mvs.model.InsertVideoRequest; +import com.baidubce.services.mvs.model.InsertVideoResponse; +import com.baidubce.services.mvs.model.SearchImageByImageRequest; +import com.baidubce.services.mvs.model.SearchImageByImageResponse; +import com.baidubce.services.mvs.model.SearchVideoByVideoRequest; +import com.baidubce.services.mvs.model.SearchVideoByVideoResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Provides the client for accessing the BCE Multi-model Video Search service. + */ +public class MvsClient extends AbstractBceClient { + private static final String VERSION = "v2"; + + private static final String VIDEO_LIB = "videolib"; + + private static final String IMAGE_LIB = "imagelib"; + + private static final String SEARCH_BY_IMAGE = "searchByImage"; + + private static final String SEARCH_BY_VIDEO = "searchByVideo"; + + private static HttpResponseHandler[] mvsHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public MvsClient(BceClientConfiguration config) { + super(config, mvsHandlers); + } + + public InsertVideoResponse insertVideo(String lib, InsertVideoRequest insertVideoRequest) { + InternalRequest internalRequest = + createRequest(HttpMethodName.PUT, insertVideoRequest, VERSION, VIDEO_LIB, lib); + return this.invokeHttpClient(internalRequest, InsertVideoResponse.class); + } + + public SearchVideoByVideoResponse searchVideoByVideo(String lib, + SearchVideoByVideoRequest searchVideoByVideoRequest) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, searchVideoByVideoRequest, VERSION, VIDEO_LIB, lib); + internalRequest.addParameter(SEARCH_BY_VIDEO, ""); + return this.invokeHttpClient(internalRequest, SearchVideoByVideoResponse.class); + } + + public InsertImageResponse insertImage(String lib, InsertImageRequest insertImageRequest) { + InternalRequest internalRequest = + createRequest(HttpMethodName.PUT, insertImageRequest, VERSION, IMAGE_LIB, lib); + return this.invokeHttpClient(internalRequest, InsertImageResponse.class); + } + + public SearchImageByImageResponse searchImageByImage(String lib, + SearchImageByImageRequest searchImageByImageRequest) { + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, searchImageByImageRequest, VERSION, IMAGE_LIB, lib); + internalRequest.addParameter(SEARCH_BY_IMAGE, ""); + return this.invokeHttpClient(internalRequest, SearchImageByImageResponse.class); + } + + private InternalRequest createRequest(HttpMethodName httpMethod, + AbstractBceRequest request, + String... pathVariables) { + // build URL paths + List pathComponents = new ArrayList(); + + // append resourceKeys,pathVariables, + // For example:/resourcekey1/resourcekey2/../pathVariable1/pathVariable2 + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + pathComponents.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(getEndpoint(), pathComponents.toArray(new String[pathComponents.size()])); + + // get a InternalRequest instance and set headers + InternalRequest internalRequest = new InternalRequest(httpMethod, uri); + internalRequest.setCredentials(request.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST || httpMethod == HttpMethodName.PUT) { + fillRequestPayload(internalRequest, request); + } + return internalRequest; + } + + private InternalRequest fillRequestPayload(InternalRequest internalRequest, AbstractBceRequest request) { + String strJson = JsonUtils.toJsonString(request); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + + return internalRequest; + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/InsertImageRequest.java b/src/main/java/com/baidubce/services/mvs/model/InsertImageRequest.java new file mode 100644 index 00000000..4c3389b8 --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/InsertImageRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * MVS insert image request. + */ +public class InsertImageRequest extends AbstractBceRequest { + private String source; + private String description; + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String source; + private String description; + + public Builder withSource(String source) { + this.source = source; + return this; + } + + public Builder withDescription(String description) { + this.description = description; + return this; + } + + public InsertImageRequest build() { + InsertImageRequest insertImageRequest = new InsertImageRequest(); + insertImageRequest.setSource(this.source); + insertImageRequest.setDescription(this.description); + return insertImageRequest; + } + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "InsertImageRequest{" + + "source='" + source + '\'' + + ", description='" + description + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/InsertImageResponse.java b/src/main/java/com/baidubce/services/mvs/model/InsertImageResponse.java new file mode 100644 index 00000000..b80db3ae --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/InsertImageResponse.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * MVS insert image response. + */ +public class InsertImageResponse extends AbstractBceResponse { + private String status; + private String lib; + private String source; + private String description; + private MvsError error; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getLib() { + return lib; + } + + public void setLib(String lib) { + this.lib = lib; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public MvsError getError() { + return error; + } + + public void setError(MvsError error) { + this.error = error; + } + + @Override + public String toString() { + return "InsertImageResponse{" + + "status='" + status + '\'' + + ", lib='" + lib + '\'' + + ", source='" + source + '\'' + + ", description='" + description + '\'' + + ", error=" + error + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/InsertVideoRequest.java b/src/main/java/com/baidubce/services/mvs/model/InsertVideoRequest.java new file mode 100644 index 00000000..ca666642 --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/InsertVideoRequest.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * MVS insert video request. + */ +public class InsertVideoRequest extends AbstractBceRequest { + private String source; + private String notification; + private String description; + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String source; + private String notification; + private String description; + + public Builder withSource(String source) { + this.source = source; + return this; + } + + public Builder withNotification(String notification) { + this.notification = notification; + return this; + } + + public Builder withDescription(String description) { + this.description = description; + return this; + } + + public InsertVideoRequest build() { + InsertVideoRequest insertVideoRequest = new InsertVideoRequest(); + insertVideoRequest.setSource(this.source); + insertVideoRequest.setNotification(this.notification); + insertVideoRequest.setDescription(this.description); + return insertVideoRequest; + } + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "InsertVideoRequest{" + + "source='" + source + '\'' + + ", notification='" + notification + '\'' + + ", description='" + description + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/InsertVideoResponse.java b/src/main/java/com/baidubce/services/mvs/model/InsertVideoResponse.java new file mode 100644 index 00000000..375bbb1d --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/InsertVideoResponse.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * MVS insert video response. + */ +public class InsertVideoResponse extends AbstractBceResponse { + private String requestId; + private String code; + private String message; + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return "InsertVideoResponse{" + + "requestId='" + requestId + '\'' + + ", code='" + code + '\'' + + ", message='" + message + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/MvsError.java b/src/main/java/com/baidubce/services/mvs/model/MvsError.java new file mode 100644 index 00000000..b999d43b --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/MvsError.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +/** + * MVS error. + */ +public class MvsError { + private String code; + private String message; + + public MvsError(String code, String message) { + this.code = code; + this.message = message; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return "MVSError{" + + "code='" + code + '\'' + + ", message='" + message + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/SearchImageByImageRequest.java b/src/main/java/com/baidubce/services/mvs/model/SearchImageByImageRequest.java new file mode 100644 index 00000000..e653796a --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/SearchImageByImageRequest.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * MVS search image by image request. + */ +public class SearchImageByImageRequest extends AbstractBceRequest { + private String source; + private String description; + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String source; + private String description; + + public Builder withSource(String source) { + this.source = source; + return this; + } + + public Builder withDescription(String description) { + this.description = description; + return this; + } + + public SearchImageByImageRequest build() { + SearchImageByImageRequest searchImageByImageRequest = new SearchImageByImageRequest(); + searchImageByImageRequest.setSource(this.source); + searchImageByImageRequest.setDescription(this.description); + return searchImageByImageRequest; + } + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "SearchImageByImageRequest{" + + "source='" + source + '\'' + + ", description='" + description + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/SearchImageByImageResponse.java b/src/main/java/com/baidubce/services/mvs/model/SearchImageByImageResponse.java new file mode 100644 index 00000000..ca073873 --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/SearchImageByImageResponse.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * MVS search image by image response. + */ +public class SearchImageByImageResponse extends AbstractBceResponse { + private String status; + private String lib; + private String source; + private String description; + private MvsError error; + private List results; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getLib() { + return lib; + } + + public void setLib(String lib) { + this.lib = lib; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public MvsError getError() { + return error; + } + + public void setError(MvsError error) { + this.error = error; + } + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } + + @Override + public String toString() { + return "SearchImageByImageResponse{" + + "status='" + status + '\'' + + ", lib='" + lib + '\'' + + ", source='" + source + '\'' + + ", description='" + description + '\'' + + ", error=" + error + + ", results=" + results + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/SearchImageByImageResult.java b/src/main/java/com/baidubce/services/mvs/model/SearchImageByImageResult.java new file mode 100644 index 00000000..71b8459e --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/SearchImageByImageResult.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +/** + * MVS search image by image result. + */ +public class SearchImageByImageResult { + private double score; + private String source; + private String description; + + public double getScore() { + return score; + } + + public void setScore(double score) { + this.score = score; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "SearchImageByImageResult{" + + "score=" + score + + ", source='" + source + '\'' + + ", description='" + description + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/SearchVideoByVideoRequest.java b/src/main/java/com/baidubce/services/mvs/model/SearchVideoByVideoRequest.java new file mode 100644 index 00000000..275a5f0f --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/SearchVideoByVideoRequest.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * MVS search video by video request. + */ +public class SearchVideoByVideoRequest extends AbstractBceRequest { + private String source; + private String notification; + private String description; + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String source; + private String notification; + private String description; + + public Builder withSource(String source) { + this.source = source; + return this; + } + + public Builder withNotification(String notification) { + this.notification = notification; + return this; + } + + public Builder withDescription(String description) { + this.description = description; + return this; + } + + public SearchVideoByVideoRequest build() { + SearchVideoByVideoRequest searchVideoByVideoRequest = new SearchVideoByVideoRequest(); + searchVideoByVideoRequest.setSource(this.source); + searchVideoByVideoRequest.setNotification(this.notification); + searchVideoByVideoRequest.setDescription(this.description); + return searchVideoByVideoRequest; + } + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "SearchVideoByVideoRequest{" + + "source='" + source + '\'' + + ", notification='" + notification + '\'' + + ", description='" + description + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/mvs/model/SearchVideoByVideoResponse.java b/src/main/java/com/baidubce/services/mvs/model/SearchVideoByVideoResponse.java new file mode 100644 index 00000000..3ae1a9f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/mvs/model/SearchVideoByVideoResponse.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2019 Baidu, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.mvs.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * MVS search video by video response. + */ +public class SearchVideoByVideoResponse extends AbstractBceResponse { + private String requestId; + private String code; + private String message; + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return "SearchVideoByVideoResponse{" + + "requestId='" + requestId + '\'' + + ", code='" + code + '\'' + + ", message='" + message + '\'' + + "} " + super.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/nat/NatClient.java b/src/main/java/com/baidubce/services/nat/NatClient.java new file mode 100644 index 00000000..881ca1c7 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/NatClient.java @@ -0,0 +1,619 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat; + +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.nat.model.BatchAddDnatRulesRequest; +import com.baidubce.services.nat.model.BatchAddSnatRuleRequest; +import com.baidubce.services.nat.model.BindDnatEipRequest; +import com.baidubce.services.nat.model.BindEipRequest; +import com.baidubce.services.nat.model.CreateBatchDnatRuleIdsResponse; +import com.baidubce.services.nat.model.CreateBatchSnatRuleIdsResponse; +import com.baidubce.services.nat.model.CreateDnatRuleRequest; +import com.baidubce.services.nat.model.CreateNatRequest; +import com.baidubce.services.nat.model.CreateNatResponse; +import com.baidubce.services.nat.model.CreateNatRuleResponse; +import com.baidubce.services.nat.model.CreateSnatRuleRequest; +import com.baidubce.services.nat.model.DeleteNatRuleRequest; +import com.baidubce.services.nat.model.GetNatRequest; +import com.baidubce.services.nat.model.GetNatResponse; +import com.baidubce.services.nat.model.ListDnatRuleResponse; +import com.baidubce.services.nat.model.ListNatRequest; +import com.baidubce.services.nat.model.ListNatResponse; +import com.baidubce.services.nat.model.ListNatRuleRequest; +import com.baidubce.services.nat.model.ListSnatRuleResponse; +import com.baidubce.services.nat.model.ModifyNatRequest; +import com.baidubce.services.nat.model.PurchaseReservedNatRequest; +import com.baidubce.services.nat.model.ReleaseNatRequest; +import com.baidubce.services.nat.model.UpdateDnatRuleRequest; +import com.baidubce.services.nat.model.UpdateSnatRuleRequest; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; + +/** + * Provides the client for accessing the Baidu Cloud network Service nat part. + */ +public class NatClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(NatClient.class); + + private static final String VERSION = "v1"; + private static final String NAT_PREFIX = "nat"; + private static final String CLIENT_TOKEN = "clientToken"; + private static final String SNAT_RULE_PREFIX = "snatRule"; + private static final String DNAT_RULE_PREFIX = "dnatRule"; + + /** + * Responsible for handling httpResponses from all network service calls. + */ + private static final HttpResponseHandler[] natHandlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on network. + */ + public NatClient() { + this(new NatClientConfiguration()); + } + + /** + * Constructs a new network client using the client configuration to access network. + * + * @param clientConfiguration The network client configuration options controlling how this client + * connects to network (e.g. proxy settings, retry counts, etc). + */ + public NatClient(NatClientConfiguration clientConfiguration) { + super(clientConfiguration, natHandlers); + } + + /** + * Creates and initializes a new request object for the specified network resource. This method is responsible + * for determining the right way to address resources. + * + * @param bceRequest The original request, as created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + */ + private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, + String... pathVariables) { + List path = new ArrayList(); + + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * The method to fill the internalRequest's content field with bceRequest. + * Only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + private void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * The default method to generate the random String for clientToken if the optional parameter clientToken + * is not specified by the user. + *

+ * The default algorithm is using {@link UUID} to generate a random UUID, + * + * @return An random String generated by {@link UUID}. + */ + private String generateClientToken() { + return UUID.randomUUID().toString(); + } + + /** + * Create a nat with the specified options. + * You must fill the field of clientToken,which is especially for keeping idempotent. + *

+ * + * @param request The request containing all options for creating a nat. + * @return nat id newly created + * @throws BceClientException + */ + public CreateNatResponse createNat(CreateNatRequest request) { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkNotNull(request.getBilling(), "billing should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, NAT_PREFIX); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateNatResponse.class); + } + + /** + * Return a list of nats owned by the authenticated user. + * + * @param request The request containing all options for listing own's nat. + * @return The response containing a list of nats owned by the authenticated user. + */ + public ListNatResponse listNat(ListNatRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getVpcId(), "vpcId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, NAT_PREFIX); + if (StringUtils.isNotBlank(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + internalRequest.addParameter("vpcId", request.getVpcId()); + if (StringUtils.isNotBlank(request.getNatId())) { + internalRequest.addParameter("natId", request.getNatId()); + } + if (StringUtils.isNotBlank(request.getName())) { + internalRequest.addParameter("name", request.getName()); + } + if (StringUtils.isNotBlank(request.getIp())) { + internalRequest.addParameter("ip", request.getIp()); + } + + return invokeHttpClient(internalRequest, ListNatResponse.class); + } + + /** + * Get the detail information of specified nat. + * + * @param natId The id of the network. + * @return A nat detail model for the natId. + */ + public GetNatResponse getNat(String natId) { + checkStringNotEmpty(natId, "natId should not be empty."); + GetNatRequest request = new GetNatRequest().withNatId(natId); + return getNat(request); + } + + /** + * Get the detail information of specified nat. + * + * @param request The request of the network. + * @return A nat detail model for the request. + */ + public GetNatResponse getNat(GetNatRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, NAT_PREFIX, request.getNatId()); + return this.invokeHttpClient(internalRequest, GetNatResponse.class); + } + + /** + * Modifying the name of the specified nat. + * + * @param request The request containing all options for modifying the nat name; + */ + public void modifyNat(ModifyNatRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be null."); + checkStringNotEmpty(request.getName(), "name should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, NAT_PREFIX, request.getNatId()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Binding the eips to specified nat. + * + * @param request The request containing all options for binding the eips to specified nat. + */ + public void bindEip(BindEipRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getEips(), "eips should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, NAT_PREFIX, request.getNatId()); + internalRequest.addParameter("bind", null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Unbinding the eips to specified nat. + * + * @param request The request containing all options for binding the eips to specified nat. + */ + public void unbindEip(BindEipRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getEips(), "eips should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, NAT_PREFIX, request.getNatId()); + internalRequest.addParameter("unbind", null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Releasing specified nat. + * + * @param request The request containing all options for releasing the eips to specified nat. + */ + public void releaseNat(ReleaseNatRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, NAT_PREFIX, request.getNatId()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * PurchaseReserving specified nat. + * + * @param request The request containing all options for purchaseReserving the eips to specified nat. + */ + public void purchaseReservedNat(PurchaseReservedNatRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + checkNotNull(request.getBilling(), "billing should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, NAT_PREFIX, request.getNatId()); + internalRequest.addParameter("purchaseReserved", null); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Bind eips in the specified dnat. + * + * @param request The request containing all the parameters for binding the eips in the specified dnat. + */ + public void bindDnatEip(BindDnatEipRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + checkNotNull(request.getDnatEips(), "dnatEips should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, NAT_PREFIX, request.getNatId()); + internalRequest.addParameter("bind", null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Unbind eips in the specified dnat. + * + * @param request The request containing all the parameters for unbinding the eips in the specified dnat. + */ + public void unbindDnatEip(BindDnatEipRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + checkNotNull(request.getDnatEips(), "dnatEips should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, NAT_PREFIX, request.getNatId()); + internalRequest.addParameter("unbind", null); + internalRequest.addParameter(CLIENT_TOKEN, request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Create a snat rule for the specified snat. + * + * @param request The request contains all parameters for creating a snat rule. + * @return the nat rule id newly created + */ + public CreateNatRuleResponse createSnatRule(CreateSnatRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + checkStringNotEmpty(request.getRuleName(), "ruleName should not be empty."); + checkStringNotEmpty(request.getSourceCIDR(), "sourceCIDR should not be empty."); + checkNotNull(request.getPublicIpsAddress(), "publicIpsAddress should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.POST, + NAT_PREFIX, + request.getNatId(), + SNAT_RULE_PREFIX); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateNatRuleResponse.class); + } + + /** + * Delete a snat rule via the snat rule id in the specified snat. + * + * @param request The request contains the natId and ruleId for deleting a snat rule. + */ + public void deleteSnatRule(DeleteNatRuleRequest request){ + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + checkStringNotEmpty(request.getRuleId(), "ruleId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.DELETE, + NAT_PREFIX, + request.getNatId(), + SNAT_RULE_PREFIX, + request.getRuleId()); + internalRequest.addParameter("clientToken", request.getClientToken()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update a snat rule via the snat rule id in the specified snat. + * + * @param request The request contains all parameters for updating a snat rule. + */ + public void updateSnatRule(UpdateSnatRuleRequest request){ + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + checkStringNotEmpty(request.getRuleId(), "ruleId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.PUT, + NAT_PREFIX, + request.getNatId(), + SNAT_RULE_PREFIX, + request.getRuleId()); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * List the information of snat rules in one specified snat. + * + * @param natId The id of the snat. + * @return All rule information in one specified snat. + */ + public ListSnatRuleResponse listSnatRule(String natId) { + checkStringNotEmpty(natId, "natId should not be empty."); + return listSnatRule(new ListNatRuleRequest().withNatId(natId)); + } + + /** + * List the information of snat rules in one specified snat. + * + * @param request The request contains natId, marker and maxKeys for getting all snat rules. + * @return All rule information in one specified snat. + */ + public ListSnatRuleResponse listSnatRule (ListNatRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.GET, + NAT_PREFIX, + request.getNatId(), + SNAT_RULE_PREFIX); + if (StringUtils.isNotBlank(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListSnatRuleResponse.class); + } + + /** + * Create a dnat rule for the specified dnat. + * + * @param request The request contains all parameters for creating a dnat rule. + * @return the nat rule id newly created + */ + public CreateNatRuleResponse createDnatRule(CreateDnatRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + checkStringNotEmpty(request.getPublicIpAddress(), "publicIpAddress should not be empty."); + checkStringNotEmpty(request.getPrivateIpAddress(), "privateIpAddress should not be empty."); + checkStringNotEmpty(request.getProtocol(), "protocol should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.POST, + NAT_PREFIX, + request.getNatId(), + DNAT_RULE_PREFIX); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateNatRuleResponse.class); + } + + /** + * Delete a dnat rule via the dnat rule id in the specified dnat. + * + * @param request The request contains the natId and ruleId for deleting a dnat rule. + */ + public void deleteDnatRule(DeleteNatRuleRequest request){ + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + checkStringNotEmpty(request.getRuleId(), "ruleId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.DELETE, + NAT_PREFIX, + request.getNatId(), + DNAT_RULE_PREFIX, + request.getRuleId()); + internalRequest.addParameter("clientToken", request.getClientToken()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Update a dnat rule via the dnat rule id in the specified dnat. + * + * @param request The request contains all parameters for updating a dnat rule. + */ + public void updateDnatRule(UpdateDnatRuleRequest request){ + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + checkStringNotEmpty(request.getRuleId(), "ruleId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.PUT, + NAT_PREFIX, + request.getNatId(), + DNAT_RULE_PREFIX, + request.getRuleId()); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * List the information of dnat rules in one specified dnat. + * + * @param natId The id of the dnat. + * @return All rule information in one specified dnat. + */ + public ListDnatRuleResponse listDnatRule(String natId) { + checkStringNotEmpty(natId, "natId should not be empty."); + return listDnatRule(new ListNatRuleRequest().withNatId(natId)); + } + + /** + * List the information of dnat rules in one specified dnat. + * + * @param request The request contains natId, marker and maxKeys for getting all dnat rules. + * @return All rule information in one specified dnat. + */ + public ListDnatRuleResponse listDnatRule (ListNatRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.GET, + NAT_PREFIX, + request.getNatId(), + DNAT_RULE_PREFIX); + if (StringUtils.isNotBlank(request.getMarker())) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListDnatRuleResponse.class); + } + + + public CreateBatchDnatRuleIdsResponse batchAddDnatRules(BatchAddDnatRulesRequest request) { + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.POST, NAT_PREFIX, request.getNatId(), DNAT_RULE_PREFIX, "batchCreate"); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, CreateBatchDnatRuleIdsResponse.class); + } + + public CreateBatchSnatRuleIdsResponse batchAddSnatRules(BatchAddSnatRuleRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getNatId(), "natId should not be empty."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest(request, + HttpMethodName.POST, + NAT_PREFIX, + SNAT_RULE_PREFIX, + "batchCreate"); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + return this.invokeHttpClient(internalRequest, CreateBatchSnatRuleIdsResponse.class); + + } + +} diff --git a/src/main/java/com/baidubce/services/nat/NatClientConfiguration.java b/src/main/java/com/baidubce/services/nat/NatClientConfiguration.java new file mode 100644 index 00000000..23de4abe --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/NatClientConfiguration.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for nat service. + */ +public class NatClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/nat/model/BatchAddDnatRulesRequest.java b/src/main/java/com/baidubce/services/nat/model/BatchAddDnatRulesRequest.java new file mode 100644 index 00000000..d5fc671e --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/BatchAddDnatRulesRequest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.nat.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class BatchAddDnatRulesRequest extends AbstractBceRequest { + @JsonIgnore + private String clientToken; + + private String natId; + + private List rules; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/BatchAddSnatRuleRequest.java b/src/main/java/com/baidubce/services/nat/model/BatchAddSnatRuleRequest.java new file mode 100644 index 00000000..442285c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/BatchAddSnatRuleRequest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.nat.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class BatchAddSnatRuleRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + private String natId; + private List snatRules; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Getter + @Setter + public static class CreateSnatRule { + private String ruleName; + + /** + * The source cidr + */ + private String sourceCIDR; + + /** + * The list of the public ip addresses + */ + private List publicIpsAddress; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/BindDnatEipRequest.java b/src/main/java/com/baidubce/services/nat/model/BindDnatEipRequest.java new file mode 100644 index 00000000..bbcdca65 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/BindDnatEipRequest.java @@ -0,0 +1,52 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for binding or unbinding eips in the specified dnat. + */ +@Getter +@Setter +public class BindDnatEipRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The nat id of the nat to be bound. + */ + @JsonIgnore + private String natId; + + /** + * The dnat eip addresses to be bound + */ + private List dnatEips; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return BindDnatEipRequest with credentials. + */ + @Override + public BindDnatEipRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/BindEipRequest.java b/src/main/java/com/baidubce/services/nat/model/BindEipRequest.java new file mode 100644 index 00000000..9e9f5076 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/BindEipRequest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for nat binding eip. + */ +public class BindEipRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Eip addresses to be bound + */ + private List eips; + + /** + * The natId of nat to be bound. + */ + @JsonIgnore + private String natId; + + /** + * Configure natId for the request. + * + * @param natId NatId to be bound + * @return BindEipRequest with specific natId + */ + public BindEipRequest withNatId(String natId) { + this.natId = natId; + return this; + } + + /** + * Configure eips for the request. + * + * @param eips Eip addresses to be bound + * @return BindEipRequest with specific eips + */ + public BindEipRequest withEips(List eips) { + this.eips = eips; + return this; + } + + public List getEips() { + return eips; + } + + public void setEips(List eips) { + this.eips = eips; + } + + public String getNatId() { + return natId; + } + + public void setNatId(String natId) { + this.natId = natId; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + return null; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/CreateBatchDnatRuleIdsResponse.java b/src/main/java/com/baidubce/services/nat/model/CreateBatchDnatRuleIdsResponse.java new file mode 100644 index 00000000..58af4f9b --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/CreateBatchDnatRuleIdsResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.nat.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class CreateBatchDnatRuleIdsResponse extends AbstractBceResponse { + public List ruleIds; + + @Override + public String toString() { + return "CreateBatchDnatRuleIdsResponse{" + + "ruleIds=" + ruleIds + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/CreateBatchSnatRuleIdsResponse.java b/src/main/java/com/baidubce/services/nat/model/CreateBatchSnatRuleIdsResponse.java new file mode 100644 index 00000000..31732946 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/CreateBatchSnatRuleIdsResponse.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.nat.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class CreateBatchSnatRuleIdsResponse extends AbstractBceResponse { + private List snatRuleIds; + + @Override + public String toString() { + return "CreateBatchSnatRuleIdsResponse{" + + "snatRuleIds=" + snatRuleIds + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/CreateDnatRule.java b/src/main/java/com/baidubce/services/nat/model/CreateDnatRule.java new file mode 100644 index 00000000..82307442 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/CreateDnatRule.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.nat.model; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class CreateDnatRule { + + /** + * The name of the dnat rule + */ + private String ruleName; + + /** + * The public ip address + */ + private String publicIpAddress; + + /** + * The private ip address + */ + private String privateIpAddress; + + /** + * The type of protocol + */ + private String protocol; + + /** + * The public port + */ + private int publicPort; + + /** + * The private port + */ + private int privatePort; +} diff --git a/src/main/java/com/baidubce/services/nat/model/CreateDnatRuleRequest.java b/src/main/java/com/baidubce/services/nat/model/CreateDnatRuleRequest.java new file mode 100644 index 00000000..3f3b9a0d --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/CreateDnatRuleRequest.java @@ -0,0 +1,75 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for creating a dnat rule. + */ +@Getter +@Setter +public class CreateDnatRuleRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The nat id of the specified dnat + */ + @JsonIgnore + private String natId; + + /** + * The name of the dnat rule + */ + private String ruleName; + + /** + * The public ip address + */ + private String publicIpAddress; + + /** + * The private ip address + */ + private String privateIpAddress; + + /** + * The type of protocol + */ + private String protocol; + + /** + * The public port + */ + private String publicPort; + + /** + * The private port + */ + private String privatePort; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateDnatRuleRequest with credentials. + */ + @Override + public CreateDnatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/CreateNatRequest.java b/src/main/java/com/baidubce/services/nat/model/CreateNatRequest.java new file mode 100644 index 00000000..ff2b3678 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/CreateNatRequest.java @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import java.util.List; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.baidubce.services.bcc.model.TagModel; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for creating a nat. + */ +public class CreateNatRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The name of nat that will be created. + */ + private String name; + + /** + * The vpcId of nat that will be created. + */ + private String vpcId; + + /** + * The size of the NAT gateway, with options: + * small (supports binding up to 5 public IP addresses), + * medium (supports binding up to 10 public IP addresses), + * and large (supports binding up to 15 public IP addresses). + * This parameter and 'cuNum' can only be selected in one of the two + */ + private String spec; + + /** + * The number of compute units (CUs) for the NAT gateway. + * This parameter and 'spec' can only be selected in one of the two." + */ + private Integer cuNum; + + /** + * The eips of nat that will be created. + */ + private List eips; + + /** + * The billing of nat that will be created. + */ + private Billing billing; + + /** + * the list of tags which will be bound to nat instance + */ + private List tags; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure name for the request. + * + * @param name The name of CreateNatRequest + * @return CreateNatRequest with specific name + */ + public CreateNatRequest withName(String name) { + this.name = name; + return this; + } + + /** + * Configure vpcId for the request. + * + * @param vpcId The vpcId of CreateNatRequest + * @return CreateNatRequest with specific vpcId + */ + public CreateNatRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + /** + * Configure spec for the request. + * + * @param spec The spec of CreateNatRequest + * @return CreateNatRequest with specific spec + */ + public CreateNatRequest withSpec(String spec) { + this.spec = spec; + return this; + } + + /** + * Configure eips for the request. + * + * @param eips The spec of CreateNatRequest + * @return CreateNatRequest with specific eips + */ + public CreateNatRequest withEips(List eips) { + this.eips = eips; + return this; + } + + /** + * Configure billing for the request. + * + * @param billing The spec of CreateNatRequest + * @return CreateNatRequest with specific billing + */ + public CreateNatRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public List getEips() { + return eips; + } + + public void setEips(List eips) { + this.eips = eips; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Integer getCuNum() { + return cuNum; + } + + public void setCuNum(Integer cuNum) { + this.cuNum = cuNum; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/CreateNatResponse.java b/src/main/java/com/baidubce/services/nat/model/CreateNatResponse.java new file mode 100644 index 00000000..be8a8e59 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/CreateNatResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.ToString; + +/** + * The response for creating a nat. + */ + +@ToString +public class CreateNatResponse extends AbstractBceResponse { + + /** + * the id of nat created. + */ + private String natId; + + public String getNatId() { + return natId; + } + + public void setNatId(String natId) { + this.natId = natId; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/CreateNatRuleResponse.java b/src/main/java/com/baidubce/services/nat/model/CreateNatRuleResponse.java new file mode 100644 index 00000000..e5b3b5ad --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/CreateNatRuleResponse.java @@ -0,0 +1,18 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.model.AbstractBceResponse; +import lombok.Getter; +import lombok.Setter; + +/** + * The response for creating a nat rule. + */ +@Getter +@Setter +public class CreateNatRuleResponse extends AbstractBceResponse { + + /** + * the id of nat rule newly created. + */ + private String ruleId; +} diff --git a/src/main/java/com/baidubce/services/nat/model/CreateSnatRuleRequest.java b/src/main/java/com/baidubce/services/nat/model/CreateSnatRuleRequest.java new file mode 100644 index 00000000..df876551 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/CreateSnatRuleRequest.java @@ -0,0 +1,62 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for creating a snat rule. + */ +@Setter +@Getter +public class CreateSnatRuleRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The nat id of the specified snat + */ + @JsonIgnore + private String natId; + + /** + * The name of the snat rule + */ + private String ruleName; + + /** + * The source cidr + */ + private String sourceCIDR; + + /** + * The list of the public ip addresses + */ + private List publicIpsAddress; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateSnatRuleRequest with credentials. + */ + @Override + public CreateSnatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/DeleteNatRuleRequest.java b/src/main/java/com/baidubce/services/nat/model/DeleteNatRuleRequest.java new file mode 100644 index 00000000..8586c127 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/DeleteNatRuleRequest.java @@ -0,0 +1,50 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for deleting a nat rule in one specified nat. + */ +@Getter +@Setter +public class DeleteNatRuleRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The nat id of the specified nat + */ + @JsonIgnore + private String natId; + + /** + * The id of the nat rule to be deleted + */ + private String ruleId; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteNatRuleRequest with credentials. + */ + @Override + public DeleteNatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/DnatRule.java b/src/main/java/com/baidubce/services/nat/model/DnatRule.java new file mode 100644 index 00000000..7a8cc138 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/DnatRule.java @@ -0,0 +1,54 @@ +package com.baidubce.services.nat.model; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Dnat rule info model + */ +@Getter +@Setter +@ToString +public class DnatRule { + + /** + * The id of the dnat rule + */ + String ruleId; + + /** + * The name of the dnat rule + */ + String ruleName; + + /** + * The public ip address + */ + private String publicIpAddress; + + /** + * The private ip address + */ + private String privateIpAddress; + + /** + * The type of protocol + */ + private String protocol; + + /** + * The public port + */ + private String publicPort; + + /** + * The private port + */ + private String privatePort; + + /** + * The status of the dnat rule + */ + String status; +} diff --git a/src/main/java/com/baidubce/services/nat/model/GetNatRequest.java b/src/main/java/com/baidubce/services/nat/model/GetNatRequest.java new file mode 100644 index 00000000..e13f1cfb --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/GetNatRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for got a nat. + */ +public class GetNatRequest extends AbstractBceRequest { + + /** + * The id of nat that will be created. + */ + private String natId; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Configure id for the request. + * + * @param natId The name of GetNatRequest + * @return GetNatRequest with specific name + */ + public GetNatRequest withNatId(String natId) { + this.natId = natId; + return this; + } + + public String getNatId() { + return natId; + } + + public void setNatId(String natId) { + this.natId = natId; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/GetNatResponse.java b/src/main/java/com/baidubce/services/nat/model/GetNatResponse.java new file mode 100644 index 00000000..738e6e44 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/GetNatResponse.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.bcc.model.TagModel; +import lombok.ToString; + +/** + * The response for get nat. + */ +@ToString +public class GetNatResponse extends AbstractBceResponse { + + /** + * The id of this nat. + */ + private String id; + + /** + * The name of this nat. + */ + private String name; + + /** + * The vpcId of this nat. + */ + private String vpcId; + + /** + * The spec of this nat. + */ + private String spec; + + /** + * The eips of this nat. + */ + private List eips; + + /** + * The paymentTiming of this nat. + */ + private String paymentTiming; + + /** + * The expireTime of this nat. + */ + private String expireTime; + + /** + * The status of this nat. + */ + private String status; + + /** + * the list of tags which are bound to nat instance + */ + private List tags; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public List getEips() { + return eips; + } + + public void setEips(List eips) { + this.eips = eips; + } + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getExpireTime() { + return expireTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/ListDnatRuleResponse.java b/src/main/java/com/baidubce/services/nat/model/ListDnatRuleResponse.java new file mode 100644 index 00000000..8084683c --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/ListDnatRuleResponse.java @@ -0,0 +1,30 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.model.ListResponse; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The response for listing all dnat rules in one specified dnat. + */ +@Getter +@Setter +public class ListDnatRuleResponse extends ListResponse { + /** + * List of dnat rule info + */ + private List rules; + + @Override + public String toString() { + return "ListDnatRuleResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "rules=" + rules + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/ListNatRequest.java b/src/main/java/com/baidubce/services/nat/model/ListNatRequest.java new file mode 100644 index 00000000..bfe90059 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/ListNatRequest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.ListRequest; + +/** + * The request for list nat. + */ +public class ListNatRequest extends ListRequest { + + /** + * The vpcId of nat. + */ + private String vpcId; + + /** + * The natId of nat. + */ + private String natId; + + /** + * The name of nat. + */ + private String name; + + /** + * The ip of nat. + */ + private String ip; + + /** + * Configure vpcId for the request. + * + * @param vpcId The vpcId of ListNatRequest + * @return ListNatRequest with specific vpcId + */ + public ListNatRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + /** + * Configure natId for the request. + * + * @param natId The vpcId of ListNatRequest + * @return ListNatRequest with specific natId + */ + public ListNatRequest withNatId(String natId) { + this.natId = natId; + return this; + } + + /** + * Configure name for the request. + * + * @param name The vpcId of ListNatRequest + * @return ListNatRequest with specific name + */ + public ListNatRequest withName(String name) { + this.name = name; + return this; + } + + /** + * Configure ip for the request. + * + * @param ip The vpcId of ListNatRequest + * @return ListNatRequest with specific ip + */ + public ListNatRequest withIp(String ip) { + this.ip = ip; + return this; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getNatId() { + return natId; + } + + public void setNatId(String natId) { + this.natId = natId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/ListNatResponse.java b/src/main/java/com/baidubce/services/nat/model/ListNatResponse.java new file mode 100644 index 00000000..635ed9b7 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/ListNatResponse.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import java.util.List; + +import com.baidubce.model.ListResponse; + +/** + * The response for ListNatRequest. + */ +public class ListNatResponse extends ListResponse { + + /** + * List of nat info + */ + private List nats; + + public List getNats() { + return nats; + } + + public void setNats(List nats) { + this.nats = nats; + } + + @Override + public String toString() { + return "ListNatResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "nats=" + nats + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/ListNatRuleRequest.java b/src/main/java/com/baidubce/services/nat/model/ListNatRuleRequest.java new file mode 100644 index 00000000..d9440a59 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/ListNatRuleRequest.java @@ -0,0 +1,42 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for list all nat rule info in one specified nat. + */ +@Getter +@Setter +public class ListNatRuleRequest extends ListRequest { + + /** + * The id of the nat. + */ + private String natId; + + /** + * Configure natId for the request. + * + * @param natId The id of the nat + * @return GetNatRuleRequest with the nat id + */ + public ListNatRuleRequest withNatId(String natId) { + this.natId = natId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetNatRuleRequest with credentials. + */ + @Override + public ListNatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/ListSnatRuleResponse.java b/src/main/java/com/baidubce/services/nat/model/ListSnatRuleResponse.java new file mode 100644 index 00000000..8c0b8643 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/ListSnatRuleResponse.java @@ -0,0 +1,31 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.model.ListResponse; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The response for listing all snat rules in one specified snat. + */ +@Getter +@Setter +public class ListSnatRuleResponse extends ListResponse { + + /** + * List of snat rule info + */ + private List rules; + + @Override + public String toString() { + return "ListSnatRuleResponse{" + + "marker= " + getMarker() + "," + + "nextMarker= " + getNextMarker() + "," + + "maxKeys= " + getMaxKeys() + "," + + "isTruncated= " + getIsTruncated() + "," + + "rules=" + rules + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/ModifyNatRequest.java b/src/main/java/com/baidubce/services/nat/model/ModifyNatRequest.java new file mode 100644 index 00000000..c4bad7fb --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/ModifyNatRequest.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for updating nat. + */ +public class ModifyNatRequest extends AbstractBceRequest { + + /** + * The id of nat to be updated. + */ + @JsonIgnore + private String natId; + + /** + * The new value for nat's name. + */ + private String name; + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * Configure natId for the request. + * @param natId The id of the nat. + * @return ModifyNatRequest with specific natId + */ + public ModifyNatRequest withNatId(String natId) { + this.natId = natId; + return this; + } + + /** + * Configure name for the request. + * @param name The name of the nat. + * @return ModifyNatRequest with specific name + */ + public ModifyNatRequest withName(String name) { + this.name = name; + return this; + } + + public String getNatId() { + return natId; + } + + public void setNatId(String natId) { + this.natId = natId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/Nat.java b/src/main/java/com/baidubce/services/nat/model/Nat.java new file mode 100644 index 00000000..ede93cbb --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/Nat.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import lombok.ToString; + +import java.util.List; + +/** + * Nat detail info model + */ +@ToString +public class Nat { + + /** + * The id of this nat. + */ + private String id; + + /** + * The name of this nat. + */ + private String name; + + /** + * The vpcId of this nat. + */ + private String vpcId; + + /** + * The spec of this nat. + */ + private String spec; + + /** + * The eips of this nat. + */ + private List eips; + + /** + * The paymentTiming of this nat. + */ + private String paymentTiming; + + /** + * The expireTime of this nat. + */ + private String expireTime; + + /** + * The status of this nat. + */ + private String status; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public List getEips() { + return eips; + } + + public void setEips(List eips) { + this.eips = eips; + } + + public String getPaymentTiming() { + return paymentTiming; + } + + public void setPaymentTiming(String paymentTiming) { + this.paymentTiming = paymentTiming; + } + + public String getExpireTime() { + return expireTime; + } + + public void setExpireTime(String expireTime) { + this.expireTime = expireTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/PurchaseReservedNatRequest.java b/src/main/java/com/baidubce/services/nat/model/PurchaseReservedNatRequest.java new file mode 100644 index 00000000..2727d243 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/PurchaseReservedNatRequest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.bcc.model.Billing; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for purchaseReserving nat. + */ +public class PurchaseReservedNatRequest extends AbstractBceRequest { + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of nat. + */ + @JsonIgnore + private String natId; + + /** + * The billing of nat that will be purchaseReserved. + */ + private Billing billing; + + /** + * Configure billing for the request. + * + * @param billing The spec of CreateNatRequest + * @return CreateNatRequest with specific billing + */ + public PurchaseReservedNatRequest withBilling(Billing billing) { + this.billing = billing; + return this; + } + + /** + * Configure natId for the request. + * + * @param natId The id of the nat. + * @return PurchaseReservedNatRequest with specific natId + */ + public PurchaseReservedNatRequest withNatId(String natId) { + this.natId = natId; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getNatId() { + return natId; + } + + public void setNatId(String natId) { + this.natId = natId; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/ReleaseNatRequest.java b/src/main/java/com/baidubce/services/nat/model/ReleaseNatRequest.java new file mode 100644 index 00000000..ed51159b --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/ReleaseNatRequest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for releasing nat. + */ +public class ReleaseNatRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The id of nat to be updated. + */ + @JsonIgnore + private String natId; + + /** + * Configure natId for the request. + * + * @param natId The id of the nat. + * @return ReleaseNatRequest with specific natId + */ + public ReleaseNatRequest withNatId(String natId) { + this.natId = natId; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getNatId() { + return natId; + } + + public void setNatId(String natId) { + this.natId = natId; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/SnatRule.java b/src/main/java/com/baidubce/services/nat/model/SnatRule.java new file mode 100644 index 00000000..3d703151 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/SnatRule.java @@ -0,0 +1,41 @@ +package com.baidubce.services.nat.model; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * Snat rule info model + */ +@Getter +@Setter +@ToString +public class SnatRule { + + /** + * The id of the snat rule + */ + String ruleId; + + /** + * The name of the snat rule + */ + String ruleName; + + /** + * The list of the public ip addresses + */ + List publicIpsAddress; + + /** + * The source cidr + */ + String sourceCIDR; + + /** + * The status of the snat rule + */ + String status; +} diff --git a/src/main/java/com/baidubce/services/nat/model/UpdateDnatRuleRequest.java b/src/main/java/com/baidubce/services/nat/model/UpdateDnatRuleRequest.java new file mode 100644 index 00000000..0e5913a4 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/UpdateDnatRuleRequest.java @@ -0,0 +1,81 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +/** + * The request for updating one dnat rule in the specified dnat. + */ +@Getter +@Setter +public class UpdateDnatRuleRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + *

+ * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The nat id of the specified dnat + */ + @JsonIgnore + private String natId; + + /** + * The id of the dnat rule to de updated + */ + @JsonIgnore + private String ruleId; + + /** + * The name of the dnat rule + */ + private String ruleName; + + /** + * The type of protocol + */ + private String protocol; + + /** + * The public port + */ + private Integer publicPort; + + /** + * The private port + */ + private Integer privatePort; + + /** + * The public ip address + */ + private String publicIpAddress; + + /** + * The private ip address + */ + private String privateIpAddress; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateDnatRuleRequest with credentials. + */ + @Override + public UpdateDnatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/nat/model/UpdateSnatRuleRequest.java b/src/main/java/com/baidubce/services/nat/model/UpdateSnatRuleRequest.java new file mode 100644 index 00000000..3fbff354 --- /dev/null +++ b/src/main/java/com/baidubce/services/nat/model/UpdateSnatRuleRequest.java @@ -0,0 +1,68 @@ +package com.baidubce.services.nat.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * The request for updating one snat rule in the specified snat. + */ +@Getter +@Setter +public class UpdateSnatRuleRequest extends AbstractBceRequest { + + /** + * An ASCII string whose length is less than 64. + * + * The request will be idempotent if clientToken is provided. + * If the clientToken is not specified by the user, a random String generated by default algorithm will be used. + * See more detail at + * + * BCE API doc + */ + @JsonIgnore + private String clientToken; + + /** + * The nat id of the specified snat + */ + @JsonIgnore + private String natId; + + /** + * The id of the snat rule to de updated + */ + @JsonIgnore + private String ruleId; + + /** + * The name of the snat rule + */ + private String ruleName; + + /** + * The source cidr + */ + private String sourceCIDR; + + /** + * The list of the public ip addresses + */ + private List publicIpsAddress; + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return UpdateSnatRuleRequest with credentials. + */ + @Override + public UpdateSnatRuleRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/oos/OosClient.java b/src/main/java/com/baidubce/services/oos/OosClient.java new file mode 100644 index 00000000..b7690c84 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/OosClient.java @@ -0,0 +1,270 @@ +package com.baidubce.services.oos; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.oos.model.common.TemplateType; +import com.baidubce.services.oos.model.request.BaseTemplateRequest; +import com.baidubce.services.oos.model.request.BaseExecutionRequest; +import com.baidubce.services.oos.model.request.OperatorListRequest; +import com.baidubce.services.oos.model.request.TemplateListRequest; +import com.baidubce.services.oos.model.response.BaseExecutionResponse; +import com.baidubce.services.oos.model.response.BaseTemplateResponse; +import com.baidubce.services.oos.model.response.CheckTemplateResponse; +import com.baidubce.services.oos.model.response.OperatorListResponse; +import com.baidubce.services.oos.model.response.TemplateListResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.Arrays; +import java.util.HashSet; + +import static com.baidubce.services.media.MediaClient.REQUEST_NULL_ERROR_MESSAGE; +import static com.baidubce.util.StringFormatUtils.checkEmptyExceptionMessageFormat; +import static com.baidubce.util.Validate.checkIsTrue; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +public class OosClient extends AbstractBceClient { + + /** + * Generate signature with specified headers. + */ + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling httpResponses from all oos service calls. + */ + private static final HttpResponseHandler[] OOS_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + + /** + * Constructs a new client to invoke service methods on oos. + */ + public OosClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new bbc client using the client configuration to access oos. + * + * @param clientConfiguration The bcc client configuration options controlling how this client + * connects to bbc (e.g. proxy settings, retry counts, etc). + */ + public OosClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, OOS_HANDLERS); + } + + /** + * create get request with url + * @param bceRequest request body object + * @param httpMethod method name,such as put, post, delete et + * @param url method url + * @return InternalRequest + */ + private InternalRequest createRequestWithUrl(AbstractBceRequest bceRequest, HttpMethodName httpMethod, String url) { + URI uri = HttpUtils.appendUri(this.getEndpoint(), url); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * create request with json format body + * @param bceRequest request body object + * @param httpMethod method name,such as put, post, delete et + * @param url method url + * @return InternalRequest + */ + private InternalRequest createBodyRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod, String url) { + URI uri = HttpUtils.appendUri(this.getEndpoint(), url); + InternalRequest request = new InternalRequest(httpMethod, uri); + fillPayload(request, bceRequest); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + return request; + } + + /** + * the method to fill the internalRequest's content field with bceRequest + * only support HttpMethodName.POST or HttpMethodName.PUT + * + * @param internalRequest A request object, populated with endpoint, resource path, ready for callers to populate + * any additional headers or parameters, and execute. + * @param bceRequest The original request, as created by the user. + */ + protected void fillPayload(InternalRequest internalRequest, AbstractBceRequest bceRequest) { + if (internalRequest.getHttpMethod() == HttpMethodName.POST + || internalRequest.getHttpMethod() == HttpMethodName.PUT + || internalRequest.getHttpMethod() == HttpMethodName.PATCH) { + String strJson = JsonUtils.toJsonString(bceRequest); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + } + } + + /** + * 创建模板接口 + * @param request + * @return + */ + public BaseTemplateResponse createTemplate(BaseTemplateRequest request) { + checkBaseTemplateRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/api/logic/oos/v2/template"); + return invokeHttpClient(internalRequest, BaseTemplateResponse.class); + } + + /** + * 校验模板接口 + * @param request + * @return + */ + public CheckTemplateResponse checkTemplate(BaseTemplateRequest request) { + checkBaseTemplateRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/api/logic/oos/v2/template/check"); + return invokeHttpClient(internalRequest, CheckTemplateResponse.class); + } + + /** + * 更新模板接口 + * @param request + * @return + */ + public BaseTemplateResponse updateTemplate(BaseTemplateRequest request) { + checkBaseTemplateRequest(request); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.PUT, + "/api/logic/oos/v2/template"); + return invokeHttpClient(internalRequest, BaseTemplateResponse.class); + } + + /** + * 删除模板接口 + * @param templateId + * @return + */ + public BaseTemplateResponse deleteTemplate(String templateId) { + checkStringNotEmpty(templateId, checkEmptyExceptionMessageFormat("templateId")); + BaseTemplateRequest request = new BaseTemplateRequest(); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.DELETE, + "/api/logic/oos/v2/template"); + internalRequest.addParameter("id", templateId); + return invokeHttpClient(internalRequest, BaseTemplateResponse.class); + } + + /** + * 获取模板详情接口 + * @param templateName + * @param templateType + * @return + */ + public BaseTemplateResponse getTemplateDetail(String templateName, TemplateType templateType) { + checkStringNotEmpty(templateName, checkEmptyExceptionMessageFormat("templateName")); + BaseTemplateRequest request = new BaseTemplateRequest(); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, + "/api/logic/oos/v2/template"); + internalRequest.addParameter("name", templateName); + internalRequest.addParameter("type", templateType.toString()); + return invokeHttpClient(internalRequest, BaseTemplateResponse.class); + } + + /** + * 获取模板列表接口 + * @param request + * @return + */ + public TemplateListResponse getTemplateList(TemplateListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkIsTrue(request.getPageNo() > 0, "pageNo should gt 0"); + checkIsTrue(request.getPageSize() > 0 && request.getPageSize() <= 100, + "pageSize should gt 0 and lt 100"); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/api/logic/oos/v2/template/list"); + return invokeHttpClient(internalRequest, TemplateListResponse.class); + } + + /** + * 获取算子列表接口 + * @param request + * @return + */ + public OperatorListResponse getOperatorList(OperatorListRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkIsTrue(request.getPageNo() > 0, "pageNo should gt 0"); + checkIsTrue(request.getPageSize() > 0 && request.getPageSize() <= 100, + "pageSize should gt 0 and lt 100"); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/api/logic/oos/v1/operator/list"); + return invokeHttpClient(internalRequest, OperatorListResponse.class); + } + + /** + * 创建执行接口 + * @param request + * @return + */ + public BaseExecutionResponse createExecution(BaseExecutionRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkIsTrue(null != request.getTemplate(), "template should not be null"); + checkIsTrue(StringUtils.isNotEmpty(request.getTemplate().getName()) || + StringUtils.isNotEmpty(request.getTemplate().getRef()), + "neither template ref nor template name is set"); + InternalRequest internalRequest = this.createBodyRequest(request, HttpMethodName.POST, + "/api/logic/oos/v2/execution"); + return invokeHttpClient(internalRequest, BaseExecutionResponse.class); + } + + /** + * 获取执行详情接口 + * @param executionId + * @return + */ + public BaseExecutionResponse getExecutionDetail(String executionId) { + checkStringNotEmpty(executionId, checkEmptyExceptionMessageFormat("executionId")); + BaseExecutionRequest request = new BaseExecutionRequest(); + InternalRequest internalRequest = this.createRequestWithUrl(request, HttpMethodName.GET, + "/api/logic/oos/v2/execution"); + internalRequest.addParameter("id", executionId); + return invokeHttpClient(internalRequest, BaseExecutionResponse.class); + } + + private void checkBaseTemplateRequest(BaseTemplateRequest request) { + checkNotNull(request, REQUEST_NULL_ERROR_MESSAGE); + checkStringNotEmpty(request.getName(), checkEmptyExceptionMessageFormat("name")); + checkIsTrue(CollectionUtils.isNotEmpty(request.getOperators()), "operators should not be empty"); + if (CollectionUtils.isEmpty(request.getLinks())) { + checkIsTrue(request.isLinear(), "linear is false, links should not be empty"); + } + } +} diff --git a/src/main/java/com/baidubce/services/oos/OosClientConfiguration.java b/src/main/java/com/baidubce/services/oos/OosClientConfiguration.java new file mode 100644 index 00000000..a1a138ad --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/OosClientConfiguration.java @@ -0,0 +1,6 @@ +package com.baidubce.services.oos; + +import com.baidubce.BceClientConfiguration; + +public class OosClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/oos/model/Execution.java b/src/main/java/com/baidubce/services/oos/model/Execution.java new file mode 100644 index 00000000..6752d8d8 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/Execution.java @@ -0,0 +1,26 @@ +package com.baidubce.services.oos.model; + +import com.baidubce.services.oos.model.common.KVModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Execution { + private String id; + private String description; + private Template template; + private long createdTimestamp; + private long updatedTimestamp; + private long finishedTimestamp; + private String state; + private Map properties; + private List tasks; + private List tags; + private String trigger; +} diff --git a/src/main/java/com/baidubce/services/oos/model/Log.java b/src/main/java/com/baidubce/services/oos/model/Log.java new file mode 100644 index 00000000..fac02105 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/Log.java @@ -0,0 +1,17 @@ +package com.baidubce.services.oos.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Log { + private String timestamp; + private String level; + private String msg; + private Map tags; +} diff --git a/src/main/java/com/baidubce/services/oos/model/Operator.java b/src/main/java/com/baidubce/services/oos/model/Operator.java new file mode 100644 index 00000000..6e8862cf --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/Operator.java @@ -0,0 +1,27 @@ +package com.baidubce.services.oos.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.HashMap; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Operator { + private String name; + private String description; + private String operator; + private int retries; + private int retryInterval = 300000; + private int timeout = 6 * 3600 * 1000; + private RateControl parallelismControl; + private RateControl allowedFailureControl; + private boolean manually; + private int scheduleDelayMilli; + private boolean pauseOnFailure; + private Map properties = new HashMap(); + private Map initContext = new HashMap(); +} diff --git a/src/main/java/com/baidubce/services/oos/model/OperatorSpec.java b/src/main/java/com/baidubce/services/oos/model/OperatorSpec.java new file mode 100644 index 00000000..05da78f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/OperatorSpec.java @@ -0,0 +1,30 @@ +package com.baidubce.services.oos.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OperatorSpec { + private String name; + private String label; + private String description; + private String operator; + private int retries; + private int retryInterval; + private int timeout; + private double parallelismRatio; + private int parallelismCount; + private double allowedFailureRatio; + private int allowedFailureCount; + private boolean manually; + private int scheduleDelayMilli; + private boolean pauseOnFailure; + private List properties; + private Map initContext; +} diff --git a/src/main/java/com/baidubce/services/oos/model/Property.java b/src/main/java/com/baidubce/services/oos/model/Property.java new file mode 100644 index 00000000..b857a265 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/Property.java @@ -0,0 +1,24 @@ +package com.baidubce.services.oos.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Property { + private String name; + private boolean required; + private String type; + private String label; + private boolean multiple; + private String description; + private List options; + private Object value; + private Object defaultValue; + private String unit; + private List properties; +} diff --git a/src/main/java/com/baidubce/services/oos/model/RateControl.java b/src/main/java/com/baidubce/services/oos/model/RateControl.java new file mode 100644 index 00000000..0a3c9167 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/RateControl.java @@ -0,0 +1,13 @@ +package com.baidubce.services.oos.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class RateControl { + private double ratio; + private int count; +} diff --git a/src/main/java/com/baidubce/services/oos/model/Task.java b/src/main/java/com/baidubce/services/oos/model/Task.java new file mode 100644 index 00000000..0ede3197 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/Task.java @@ -0,0 +1,30 @@ +package com.baidubce.services.oos.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Task { + private String id; + private Integer loopIndex; + private long revision; + private long createdTimestamp; + private long updatedTimestamp; + private long finishedTimestamp; + private String state; + private Operator operator; + private String reason; + private Map initContext; + private Map context; + private Map outputContext; + private int tries; + private List children = new ArrayList(); + private List log; +} diff --git a/src/main/java/com/baidubce/services/oos/model/Template.java b/src/main/java/com/baidubce/services/oos/model/Template.java new file mode 100644 index 00000000..178ec5f1 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/Template.java @@ -0,0 +1,28 @@ +package com.baidubce.services.oos.model; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.oos.model.common.KVModel; +import com.baidubce.services.oos.model.common.LinkModel; +import com.baidubce.services.oos.model.common.TemplateType; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Template extends AbstractBceResponse { + private String id; + private String name; + private String ref; + private TemplateType type; + private String description; + private List tags; + private boolean linear; + + private List links; + private List operators; + private List properties; +} diff --git a/src/main/java/com/baidubce/services/oos/model/common/KVModel.java b/src/main/java/com/baidubce/services/oos/model/common/KVModel.java new file mode 100644 index 00000000..df5976b2 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/common/KVModel.java @@ -0,0 +1,13 @@ +package com.baidubce.services.oos.model.common; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class KVModel { + private String key; + private Object value; +} diff --git a/src/main/java/com/baidubce/services/oos/model/common/LinkModel.java b/src/main/java/com/baidubce/services/oos/model/common/LinkModel.java new file mode 100644 index 00000000..50fa48e6 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/common/LinkModel.java @@ -0,0 +1,13 @@ +package com.baidubce.services.oos.model.common; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LinkModel { + private String src; + private String dst; +} diff --git a/src/main/java/com/baidubce/services/oos/model/common/TemplateType.java b/src/main/java/com/baidubce/services/oos/model/common/TemplateType.java new file mode 100644 index 00000000..1a7d5891 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/common/TemplateType.java @@ -0,0 +1,5 @@ +package com.baidubce.services.oos.model.common; + +public enum TemplateType { + GLOBAL,INDIVIDUAL +} diff --git a/src/main/java/com/baidubce/services/oos/model/request/BaseExecutionRequest.java b/src/main/java/com/baidubce/services/oos/model/request/BaseExecutionRequest.java new file mode 100644 index 00000000..c5877538 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/request/BaseExecutionRequest.java @@ -0,0 +1,36 @@ +package com.baidubce.services.oos.model.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.oos.model.Task; +import com.baidubce.services.oos.model.Template; +import com.baidubce.services.oos.model.common.KVModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BaseExecutionRequest extends AbstractBceRequest { + private String id; + private String description; + private Template template; + private long createdTimestamp; + private long updatedTimestamp; + private long finishedTimestamp; + private String state; + private Map properties; + private List tasks; + private List tags; + private String trigger; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/oos/model/request/BaseTemplateRequest.java b/src/main/java/com/baidubce/services/oos/model/request/BaseTemplateRequest.java new file mode 100644 index 00000000..1ea7c66c --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/request/BaseTemplateRequest.java @@ -0,0 +1,37 @@ +package com.baidubce.services.oos.model.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.oos.model.Operator; +import com.baidubce.services.oos.model.Property; +import com.baidubce.services.oos.model.common.KVModel; +import com.baidubce.services.oos.model.common.LinkModel; +import com.baidubce.services.oos.model.common.TemplateType; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BaseTemplateRequest extends AbstractBceRequest { + private String id; + private String name; + private String ref; + private TemplateType type = TemplateType.INDIVIDUAL; + private String description; + private List tags; + private boolean linear; + + private List links; + private List operators; + private List properties; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/oos/model/request/OperatorListRequest.java b/src/main/java/com/baidubce/services/oos/model/request/OperatorListRequest.java new file mode 100644 index 00000000..c77bd30a --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/request/OperatorListRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.oos.model.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OperatorListRequest extends AbstractBceRequest { + private boolean ascending; + private String sort = "createTime"; + private int pageNo; + private int pageSize; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/oos/model/request/TemplateListRequest.java b/src/main/java/com/baidubce/services/oos/model/request/TemplateListRequest.java new file mode 100644 index 00000000..e43ecfc4 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/request/TemplateListRequest.java @@ -0,0 +1,25 @@ +package com.baidubce.services.oos.model.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TemplateListRequest extends AbstractBceRequest { + private boolean ascending; + private String sort = "createTime"; + private int pageNo; + private int pageSize; + private String name; + private String type; + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/oos/model/response/BaseExecutionResponse.java b/src/main/java/com/baidubce/services/oos/model/response/BaseExecutionResponse.java new file mode 100644 index 00000000..558ae99a --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/response/BaseExecutionResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.oos.model.response; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.oos.model.Execution; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BaseExecutionResponse extends AbstractBceResponse { + private boolean success; + private String msg; + private Integer code; + private Execution result; +} diff --git a/src/main/java/com/baidubce/services/oos/model/response/BaseTemplateResponse.java b/src/main/java/com/baidubce/services/oos/model/response/BaseTemplateResponse.java new file mode 100644 index 00000000..9a094b86 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/response/BaseTemplateResponse.java @@ -0,0 +1,17 @@ +package com.baidubce.services.oos.model.response; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.oos.model.Template; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BaseTemplateResponse extends AbstractBceResponse { + private boolean success; + private String msg; + private Integer code; + private Template result; +} diff --git a/src/main/java/com/baidubce/services/oos/model/response/CheckTemplateResponse.java b/src/main/java/com/baidubce/services/oos/model/response/CheckTemplateResponse.java new file mode 100644 index 00000000..f15a2655 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/response/CheckTemplateResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.oos.model.response; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CheckTemplateResponse extends AbstractBceResponse { + private boolean success; + private String msg; + private Integer code; + private CheckTemplateResult result; +} diff --git a/src/main/java/com/baidubce/services/oos/model/response/CheckTemplateResult.java b/src/main/java/com/baidubce/services/oos/model/response/CheckTemplateResult.java new file mode 100644 index 00000000..0a91f5e1 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/response/CheckTemplateResult.java @@ -0,0 +1,13 @@ +package com.baidubce.services.oos.model.response; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CheckTemplateResult { + private boolean isValid; + private String reason; +} diff --git a/src/main/java/com/baidubce/services/oos/model/response/OperatorListResponse.java b/src/main/java/com/baidubce/services/oos/model/response/OperatorListResponse.java new file mode 100644 index 00000000..bc157457 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/response/OperatorListResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.oos.model.response; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OperatorListResponse extends AbstractBceResponse { + private boolean success; + private String msg; + private Integer code; + private OperatorPageModel result; +} diff --git a/src/main/java/com/baidubce/services/oos/model/response/OperatorPageModel.java b/src/main/java/com/baidubce/services/oos/model/response/OperatorPageModel.java new file mode 100644 index 00000000..0adf0a50 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/response/OperatorPageModel.java @@ -0,0 +1,20 @@ +package com.baidubce.services.oos.model.response; + +import com.baidubce.services.oos.model.OperatorSpec; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OperatorPageModel { + private List operators; + private String orderBy; + private String order; + private int pageNo; + private int pageSize; + private int totalCount; +} diff --git a/src/main/java/com/baidubce/services/oos/model/response/TemplateListResponse.java b/src/main/java/com/baidubce/services/oos/model/response/TemplateListResponse.java new file mode 100644 index 00000000..0cce23c3 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/response/TemplateListResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.oos.model.response; + +import com.baidubce.model.AbstractBceResponse; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TemplateListResponse extends AbstractBceResponse { + private boolean success; + private String msg; + private Integer code; + private TemplatePageModel result; +} diff --git a/src/main/java/com/baidubce/services/oos/model/response/TemplatePageModel.java b/src/main/java/com/baidubce/services/oos/model/response/TemplatePageModel.java new file mode 100644 index 00000000..c1e83ae0 --- /dev/null +++ b/src/main/java/com/baidubce/services/oos/model/response/TemplatePageModel.java @@ -0,0 +1,20 @@ +package com.baidubce.services.oos.model.response; + +import com.baidubce.services.oos.model.Template; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TemplatePageModel { + private List